Compare commits
3 Commits
24fdf475f8
...
cf0a99383c
| Author | SHA1 | Date | |
|---|---|---|---|
| cf0a99383c | |||
| c980830b61 | |||
| 3b76d7c660 |
@@ -2,10 +2,11 @@ package com.backend.webbackend.Controller;
|
|||||||
|
|
||||||
import com.backend.webbackend.Service.courseService;
|
import com.backend.webbackend.Service.courseService;
|
||||||
import com.backend.webbackend.Vo.ResultVo;
|
import com.backend.webbackend.Vo.ResultVo;
|
||||||
|
import com.backend.webbackend.domain.Course;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("course")
|
@RequestMapping("course")
|
||||||
@@ -13,6 +14,9 @@ public class CourseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private courseService courseService;
|
private courseService courseService;
|
||||||
|
|
||||||
|
@Value("${app.courseLoadPath}")
|
||||||
|
private String courseLoadPath;
|
||||||
|
|
||||||
// 返回课程信息
|
// 返回课程信息
|
||||||
@GetMapping("getAll")
|
@GetMapping("getAll")
|
||||||
public ResultVo getAllCourses() {
|
public ResultVo getAllCourses() {
|
||||||
@@ -25,7 +29,29 @@ public class CourseController {
|
|||||||
return ResultVo.Success("", courseService.getCourseResources());
|
return ResultVo.Success("", courseService.getCourseResources());
|
||||||
}
|
}
|
||||||
|
|
||||||
//用户上传课程资源
|
//返回课程类型信息
|
||||||
|
@GetMapping("getCourseTypes")
|
||||||
|
public ResultVo getAllCourseTypes() {
|
||||||
|
return ResultVo.Success("", courseService.getAllCourseTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增课程信息
|
||||||
|
@PostMapping(value = "addCourse", consumes = "multipart/form-data")
|
||||||
|
public ResultVo addCourse(@ModelAttribute Course course, @RequestPart(name = "icoFile",required = false)MultipartFile icoFile) {
|
||||||
|
try {
|
||||||
|
if(courseService.addCourse(course,icoFile)>0)
|
||||||
|
return ResultVo.Success("", "新增课程信息成功");
|
||||||
|
else
|
||||||
|
return ResultVo.Error("", "新增课程信息失败");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("新增课程信息失败!!!!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增课程资源
|
||||||
|
@PostMapping("addCourseResource")
|
||||||
|
public ResultVo addCourseResource() {
|
||||||
|
|
||||||
|
return ResultVo.Success("", "新增课程资源成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ public class userController {
|
|||||||
return ResultVo.Success("",userService.getAlldept());
|
return ResultVo.Success("",userService.getAlldept());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回全部用户信息
|
||||||
|
@GetMapping("allUsers")
|
||||||
|
public ResultVo getAllUsers(){
|
||||||
|
return ResultVo.Success("",userService.getAllUsers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//用户注册
|
//用户注册
|
||||||
@PostMapping("register")
|
@PostMapping("register")
|
||||||
public ResultVo register(@RequestBody User user){
|
public ResultVo register(@RequestBody User user){
|
||||||
@@ -35,8 +42,8 @@ public class userController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//用户登录
|
//用户登录
|
||||||
@PostMapping("login")
|
@PostMapping(value = "login")
|
||||||
public ResultVo login(@RequestBody User user) {
|
public ResultVo login(@ModelAttribute User user) {
|
||||||
if(!userService.login(user.getUsername(),user.getPassword())){
|
if(!userService.login(user.getUsername(),user.getPassword())){
|
||||||
return ResultVo.Error("","用户名或密码错误");
|
return ResultVo.Error("","用户名或密码错误");
|
||||||
}
|
}
|
||||||
@@ -54,8 +61,18 @@ public class userController {
|
|||||||
return ResultVo.Success("","用户信息修改成功");
|
return ResultVo.Success("","用户信息修改成功");
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
|
System.out.println(e.getMessage());
|
||||||
throw new RuntimeException("用户信息修改失败!!!!!!");
|
throw new RuntimeException("用户信息修改失败!!!!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("deleteUser")
|
||||||
|
public ResultVo deleteTest(@Param("id") Long id) {
|
||||||
|
if(userService.deleteUserById(id) == 1){
|
||||||
|
return ResultVo.Success("", "用户删除成功");
|
||||||
|
}else {
|
||||||
|
return ResultVo.Error("", "用户删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
package com.backend.webbackend.Service.Impl;
|
package com.backend.webbackend.Service.Impl;
|
||||||
|
|
||||||
import com.backend.webbackend.domain.Course;
|
import com.backend.webbackend.domain.Course;
|
||||||
|
import com.backend.webbackend.domain.CourseType;
|
||||||
import com.backend.webbackend.domain.TrainingResource;
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
import com.backend.webbackend.mapper.CourseMapper;
|
import com.backend.webbackend.mapper.CourseMapper;
|
||||||
|
import com.backend.webbackend.mapper.CourseTypeMapper;
|
||||||
import com.backend.webbackend.mapper.TrainingResourceMapper;
|
import com.backend.webbackend.mapper.TrainingResourceMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class courseServiceImpl implements com.backend.webbackend.Service.courseService {
|
public class courseServiceImpl implements com.backend.webbackend.Service.courseService {
|
||||||
@Autowired
|
@Autowired
|
||||||
CourseMapper courseMapper;
|
CourseMapper courseMapper; //用户管理信息
|
||||||
@Autowired
|
@Autowired
|
||||||
TrainingResourceMapper trainingResourceMapper;
|
CourseTypeMapper courseTypeMapper; //用于管理课程类型
|
||||||
|
@Autowired
|
||||||
|
TrainingResourceMapper trainingResourceMapper; //用于管理课程资源文件
|
||||||
|
|
||||||
// 返回课程信息
|
// 返回课程信息
|
||||||
@Override
|
@Override
|
||||||
@@ -27,4 +32,17 @@ public class courseServiceImpl implements com.backend.webbackend.Service.courseS
|
|||||||
public List<TrainingResource> getCourseResources(){
|
public List<TrainingResource> getCourseResources(){
|
||||||
return trainingResourceMapper.getAllTraningResources();
|
return trainingResourceMapper.getAllTraningResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回课程类型信息
|
||||||
|
@Override
|
||||||
|
public List<CourseType> getAllCourseTypes() {
|
||||||
|
return courseTypeMapper.selectAllCourseTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增课程信息
|
||||||
|
@Override
|
||||||
|
public int addCourse(Course course, MultipartFile icoFile) {
|
||||||
|
//如果有上传文件,先保存文件至服务器磁盘
|
||||||
|
return courseMapper.insertCourse(course);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,4 +83,16 @@ public class userServiceImpl implements userService {
|
|||||||
public int updateUserInfo(User user){
|
public int updateUserInfo(User user){
|
||||||
return userMapper.updateByName(user);
|
return userMapper.updateByName(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回全部用户信息
|
||||||
|
@Override
|
||||||
|
public List<User> getAllUsers() {
|
||||||
|
return userMapper.getAllUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除用户
|
||||||
|
@Override
|
||||||
|
public int deleteUserById(Long id) {
|
||||||
|
return userMapper.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.backend.webbackend.Service;
|
package com.backend.webbackend.Service;
|
||||||
|
|
||||||
import com.backend.webbackend.domain.Course;
|
import com.backend.webbackend.domain.Course;
|
||||||
|
import com.backend.webbackend.domain.CourseType;
|
||||||
import com.backend.webbackend.domain.TrainingResource;
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,4 +12,6 @@ import java.util.List;
|
|||||||
public interface courseService {
|
public interface courseService {
|
||||||
List<Course> getAllCourseInfo();
|
List<Course> getAllCourseInfo();
|
||||||
List<TrainingResource> getCourseResources();
|
List<TrainingResource> getCourseResources();
|
||||||
|
List<CourseType>getAllCourseTypes();
|
||||||
|
int addCourse(Course course, MultipartFile icoFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,8 @@ public interface userService {
|
|||||||
boolean login(String username, String password);
|
boolean login(String username, String password);
|
||||||
List<Dept> getAlldept();
|
List<Dept> getAlldept();
|
||||||
int updateUserInfo(User user);
|
int updateUserInfo(User user);
|
||||||
|
|
||||||
|
List<User> getAllUsers();
|
||||||
|
|
||||||
|
int deleteUserById(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import com.backend.webbackend.mapper.UserMapper;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -49,4 +50,10 @@ public class Tools {
|
|||||||
}
|
}
|
||||||
return PASSWORD_ENCODER.matches(rawPassword, encodedPassword);
|
return PASSWORD_ENCODER.matches(rawPassword, encodedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//文件保存
|
||||||
|
public String saveIcoFile(MultipartFile icoFile){
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,16 @@ import lombok.Data;
|
|||||||
public class Course {
|
public class Course {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@JsonProperty("course_name")
|
||||||
private String courseName;
|
private String courseName;
|
||||||
|
|
||||||
|
@JsonProperty("course_code")
|
||||||
private String courseCode;
|
private String courseCode;
|
||||||
|
|
||||||
|
@JsonProperty("course_desc")
|
||||||
private String courseDesc;
|
private String courseDesc;
|
||||||
|
|
||||||
|
@JsonProperty("course_category")
|
||||||
private String courseCategory;
|
private String courseCategory;
|
||||||
|
|
||||||
@JsonProperty("course_ico")
|
@JsonProperty("course_ico")
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ public interface CourseMapper {
|
|||||||
|
|
||||||
int updateByPrimaryKey(Course record);
|
int updateByPrimaryKey(Course record);
|
||||||
|
|
||||||
|
int insertCourse(Course course);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.backend.webbackend.mapper;
|
|||||||
|
|
||||||
import com.backend.webbackend.domain.CourseType;
|
import com.backend.webbackend.domain.CourseType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Quella
|
* @author Quella
|
||||||
* @description 针对表【course_type】的数据库操作Mapper
|
* @description 针对表【course_type】的数据库操作Mapper
|
||||||
@@ -18,6 +20,8 @@ public interface CourseTypeMapper {
|
|||||||
|
|
||||||
CourseType selectByPrimaryKey(Long id);
|
CourseType selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
List<CourseType> selectAllCourseTypes();
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(CourseType record);
|
int updateByPrimaryKeySelective(CourseType record);
|
||||||
|
|
||||||
int updateByPrimaryKey(CourseType record);
|
int updateByPrimaryKey(CourseType record);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.backend.webbackend.mapper;
|
|||||||
import com.backend.webbackend.domain.User;
|
import com.backend.webbackend.domain.User;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Quella
|
* @author Quella
|
||||||
* @description 针对表【user(用户表)】的数据库操作Mapper
|
* @description 针对表【user(用户表)】的数据库操作Mapper
|
||||||
@@ -30,4 +32,6 @@ public interface UserMapper {
|
|||||||
int updateById(User user);
|
int updateById(User user);
|
||||||
|
|
||||||
int updateByName(User user);
|
int updateByName(User user);
|
||||||
|
|
||||||
|
List<User> getAllUsers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,8 @@ mybatis:
|
|||||||
# com:
|
# com:
|
||||||
# backend:
|
# backend:
|
||||||
# webbackend:
|
# webbackend:
|
||||||
# mapper: debug
|
# mapper: debug
|
||||||
|
|
||||||
|
|
||||||
|
app:
|
||||||
|
courseLoadPath: D:\\JavaWebProjects\\src\\ico
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
( id,course_name,course_code,course_desc,course_category)
|
( id,course_name,course_code,course_desc,course_category)
|
||||||
values (#{id},#{courseName},#{courseCode},#{courseDesc},#{courseCategory})
|
values (#{id},#{courseName},#{courseCode},#{courseDesc},#{courseCategory})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.Course" useGeneratedKeys="true">
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.Course" useGeneratedKeys="true">
|
||||||
insert into course
|
insert into course
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
@@ -58,6 +59,24 @@
|
|||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertCourse" parameterType="com.backend.webbackend.domain.Course" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into course
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="courseName != null and courseName != ''">course_name,</if>
|
||||||
|
<if test="courseCode != null and courseCode != ''">course_code,</if>
|
||||||
|
<if test="courseDesc != null and courseDesc != ''">course_desc,</if>
|
||||||
|
<if test="courseCategory != null and courseCategory != ''">course_category,</if>
|
||||||
|
<if test="courseIco != null and courseIco != ''">course_ico,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="courseName != null and courseName != ''">#{courseName},</if>
|
||||||
|
<if test="courseCode != null and courseCode != ''">#{courseCode},</if>
|
||||||
|
<if test="courseDesc != null and courseDesc != ''">#{courseDesc},</if>
|
||||||
|
<if test="courseCategory != null and courseCategory != ''">#{courseCategory},</if>
|
||||||
|
<if test="courseIco != null and courseIco != ''">#{courseIco},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.backend.webbackend.domain.Course">
|
<update id="updateByPrimaryKeySelective" parameterType="com.backend.webbackend.domain.Course">
|
||||||
update course
|
update course
|
||||||
<set>
|
<set>
|
||||||
|
|||||||
@@ -19,6 +19,11 @@
|
|||||||
from course_type
|
from course_type
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectAllCourseTypes" resultType="com.backend.webbackend.domain.CourseType">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from course_type
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
delete from course_type
|
delete from course_type
|
||||||
|
|||||||
@@ -37,10 +37,14 @@
|
|||||||
from user
|
from user
|
||||||
where username = #{username}
|
where username = #{username}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getAllUsers" resultType="com.backend.webbackend.domain.User">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from user
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
delete from user
|
update user set status = 0 where id = #{id}
|
||||||
where id = #{id}
|
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.User" useGeneratedKeys="true">
|
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.User" useGeneratedKeys="true">
|
||||||
|
|||||||
Reference in New Issue
Block a user