Compare commits

..

1 Commits

Author SHA1 Message Date
24fdf475f8 Merge pull request '分支测试' (#2) from Quella into main
Reviewed-on: #2
2026-01-15 11:21:44 +08:00
15 changed files with 11 additions and 144 deletions

View File

@@ -2,11 +2,10 @@ 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.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("course") @RequestMapping("course")
@@ -14,9 +13,6 @@ 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() {
@@ -29,29 +25,7 @@ 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("", "新增课程资源成功");
}
} }

View File

@@ -23,13 +23,6 @@ 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){
@@ -42,8 +35,8 @@ public class userController {
} }
//用户登录 //用户登录
@PostMapping(value = "login") @PostMapping("login")
public ResultVo login(@ModelAttribute User user) { public ResultVo login(@RequestBody User user) {
if(!userService.login(user.getUsername(),user.getPassword())){ if(!userService.login(user.getUsername(),user.getPassword())){
return ResultVo.Error("","用户名或密码错误"); return ResultVo.Error("","用户名或密码错误");
} }
@@ -61,18 +54,8 @@ 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("", "用户删除失败");
}
} }
} }

View File

@@ -1,25 +1,20 @@
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
CourseTypeMapper courseTypeMapper; //用于管理课程类型 TrainingResourceMapper trainingResourceMapper;
@Autowired
TrainingResourceMapper trainingResourceMapper; //用于管理课程资源文件
// 返回课程信息 // 返回课程信息
@Override @Override
@@ -32,17 +27,4 @@ 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);
}
} }

View File

@@ -83,16 +83,4 @@ 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);
}
} }

View File

@@ -1,10 +1,8 @@
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;
@@ -12,6 +10,4 @@ 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);
} }

View File

@@ -14,8 +14,4 @@ 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);
} }

View File

@@ -3,7 +3,6 @@ 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;
@@ -50,10 +49,4 @@ public class Tools {
} }
return PASSWORD_ENCODER.matches(rawPassword, encodedPassword); return PASSWORD_ENCODER.matches(rawPassword, encodedPassword);
} }
//文件保存
public String saveIcoFile(MultipartFile icoFile){
return "";
}
} }

View File

@@ -10,16 +10,12 @@ 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")

View File

@@ -26,5 +26,4 @@ public interface CourseMapper {
int updateByPrimaryKey(Course record); int updateByPrimaryKey(Course record);
int insertCourse(Course course);
} }

View File

@@ -2,8 +2,6 @@ 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
@@ -20,8 +18,6 @@ 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);

View File

@@ -3,8 +3,6 @@ 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
@@ -32,6 +30,4 @@ public interface UserMapper {
int updateById(User user); int updateById(User user);
int updateByName(User user); int updateByName(User user);
List<User> getAllUsers();
} }

View File

@@ -15,8 +15,4 @@ mybatis:
# com: # com:
# backend: # backend:
# webbackend: # webbackend:
# mapper: debug # mapper: debug
app:
courseLoadPath: D:\\JavaWebProjects\\src\\ico

View File

@@ -40,7 +40,6 @@
( 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=",">
@@ -59,24 +58,6 @@
</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>

View File

@@ -19,11 +19,6 @@
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

View File

@@ -37,14 +37,10 @@
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">
update user set status = 0 where id = #{id} delete from user
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">