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.Vo.ResultVo;
import com.backend.webbackend.domain.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("course")
@@ -14,9 +13,6 @@ public class CourseController {
@Autowired
private courseService courseService;
@Value("${app.courseLoadPath}")
private String courseLoadPath;
// 返回课程信息
@GetMapping("getAll")
public ResultVo getAllCourses() {
@@ -29,29 +25,7 @@ public class CourseController {
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());
}
//返回全部用户信息
@GetMapping("allUsers")
public ResultVo getAllUsers(){
return ResultVo.Success("",userService.getAllUsers());
}
//用户注册
@PostMapping("register")
public ResultVo register(@RequestBody User user){
@@ -42,8 +35,8 @@ public class userController {
}
//用户登录
@PostMapping(value = "login")
public ResultVo login(@ModelAttribute User user) {
@PostMapping("login")
public ResultVo login(@RequestBody User user) {
if(!userService.login(user.getUsername(),user.getPassword())){
return ResultVo.Error("","用户名或密码错误");
}
@@ -61,18 +54,8 @@ public class userController {
return ResultVo.Success("","用户信息修改成功");
}
catch (Exception e){
System.out.println(e.getMessage());
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;
import com.backend.webbackend.domain.Course;
import com.backend.webbackend.domain.CourseType;
import com.backend.webbackend.domain.TrainingResource;
import com.backend.webbackend.mapper.CourseMapper;
import com.backend.webbackend.mapper.CourseTypeMapper;
import com.backend.webbackend.mapper.TrainingResourceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Service
public class courseServiceImpl implements com.backend.webbackend.Service.courseService {
@Autowired
CourseMapper courseMapper; //用户管理信息
CourseMapper courseMapper;
@Autowired
CourseTypeMapper courseTypeMapper; //用于管理课程类型
@Autowired
TrainingResourceMapper trainingResourceMapper; //用于管理课程资源文件
TrainingResourceMapper trainingResourceMapper;
// 返回课程信息
@Override
@@ -32,17 +27,4 @@ public class courseServiceImpl implements com.backend.webbackend.Service.courseS
public List<TrainingResource> getCourseResources(){
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){
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;
import com.backend.webbackend.domain.Course;
import com.backend.webbackend.domain.CourseType;
import com.backend.webbackend.domain.TrainingResource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -12,6 +10,4 @@ import java.util.List;
public interface courseService {
List<Course> getAllCourseInfo();
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);
List<Dept> getAlldept();
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.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.regex.Pattern;
@@ -50,10 +49,4 @@ public class Tools {
}
return PASSWORD_ENCODER.matches(rawPassword, encodedPassword);
}
//文件保存
public String saveIcoFile(MultipartFile icoFile){
return "";
}
}

View File

@@ -10,16 +10,12 @@ import lombok.Data;
public class Course {
private Long id;
@JsonProperty("course_name")
private String courseName;
@JsonProperty("course_code")
private String courseCode;
@JsonProperty("course_desc")
private String courseDesc;
@JsonProperty("course_category")
private String courseCategory;
@JsonProperty("course_ico")

View File

@@ -26,5 +26,4 @@ public interface CourseMapper {
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 java.util.List;
/**
* @author Quella
* @description 针对表【course_type】的数据库操作Mapper
@@ -20,8 +18,6 @@ public interface CourseTypeMapper {
CourseType selectByPrimaryKey(Long id);
List<CourseType> selectAllCourseTypes();
int updateByPrimaryKeySelective(CourseType record);
int updateByPrimaryKey(CourseType record);

View File

@@ -3,8 +3,6 @@ package com.backend.webbackend.mapper;
import com.backend.webbackend.domain.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author Quella
* @description 针对表【user(用户表)】的数据库操作Mapper
@@ -32,6 +30,4 @@ public interface UserMapper {
int updateById(User user);
int updateByName(User user);
List<User> getAllUsers();
}

View File

@@ -16,7 +16,3 @@ mybatis:
# backend:
# webbackend:
# mapper: debug
app:
courseLoadPath: D:\\JavaWebProjects\\src\\ico

View File

@@ -40,7 +40,6 @@
( id,course_name,course_code,course_desc,course_category)
values (#{id},#{courseName},#{courseCode},#{courseDesc},#{courseCategory})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.Course" useGeneratedKeys="true">
insert into course
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -59,24 +58,6 @@
</trim>
</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 course
<set>

View File

@@ -19,11 +19,6 @@
from course_type
where id = #{id}
</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 from course_type

View File

@@ -37,14 +37,10 @@
from user
where username = #{username}
</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">
update user set status = 0 where id = #{id}
delete from user
where id = #{id}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.User" useGeneratedKeys="true">