Compare commits

...

5 Commits

Author SHA1 Message Date
cf0a99383c Merge pull request 'Quella' (#3) from Quella into main
Reviewed-on: #3
2026-01-24 19:37:58 +08:00
c980830b61 增加删除,返回用户信息接口 2026-01-20 14:24:29 +08:00
3b76d7c660 新增返回课程类型信息 2026-01-15 15:20:30 +08:00
24fdf475f8 Merge pull request '分支测试' (#2) from Quella into main
Reviewed-on: #2
2026-01-15 11:21:44 +08:00
4e0f46105a 分支测试 2026-01-15 11:18:45 +08:00
21 changed files with 178 additions and 15 deletions

6
.idea/copilot.data.migration.agent.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.ask.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AskMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Ask2AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.edit.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EditMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

2
.idea/misc.xml generated
View File

@@ -8,7 +8,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -2,10 +2,11 @@ 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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("course")
@@ -13,6 +14,9 @@ public class CourseController {
@Autowired
private courseService courseService;
@Value("${app.courseLoadPath}")
private String courseLoadPath;
// 返回课程信息
@GetMapping("getAll")
public ResultVo getAllCourses() {
@@ -25,7 +29,29 @@ 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,6 +23,13 @@ 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){
@@ -35,8 +42,8 @@ public class userController {
}
//用户登录
@PostMapping("login")
public ResultVo login(@RequestBody User user) {
@PostMapping(value = "login")
public ResultVo login(@ModelAttribute User user) {
if(!userService.login(user.getUsername(),user.getPassword())){
return ResultVo.Error("","用户名或密码错误");
}
@@ -54,8 +61,18 @@ public class userController {
return ResultVo.Success("","用户信息修改成功");
}
catch (Exception e){
throw new RuntimeException("用户信息修改失败");
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,20 +1,25 @@
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
TrainingResourceMapper trainingResourceMapper;
CourseTypeMapper courseTypeMapper; //用于管理课程类型
@Autowired
TrainingResourceMapper trainingResourceMapper; //用于管理课程资源文件
// 返回课程信息
@Override
@@ -27,4 +32,17 @@ 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,4 +83,16 @@ 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,8 +1,10 @@
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;
@@ -10,4 +12,6 @@ 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,4 +14,8 @@ 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,6 +3,7 @@ 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;
@@ -49,4 +50,10 @@ public class Tools {
}
return PASSWORD_ENCODER.matches(rawPassword, encodedPassword);
}
//文件保存
public String saveIcoFile(MultipartFile icoFile){
return "";
}
}

View File

@@ -10,12 +10,16 @@ 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,4 +26,5 @@ public interface CourseMapper {
int updateByPrimaryKey(Course record);
int insertCourse(Course course);
}

View File

@@ -2,6 +2,8 @@ package com.backend.webbackend.mapper;
import com.backend.webbackend.domain.CourseType;
import java.util.List;
/**
* @author Quella
* @description 针对表【course_type】的数据库操作Mapper
@@ -18,6 +20,8 @@ public interface CourseTypeMapper {
CourseType selectByPrimaryKey(Long id);
List<CourseType> selectAllCourseTypes();
int updateByPrimaryKeySelective(CourseType record);
int updateByPrimaryKey(CourseType record);

View File

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

View File

@@ -1,5 +1,5 @@
server:
port: 8081
port: 8080
spring:
datasource:
@@ -16,3 +16,7 @@ mybatis:
# backend:
# webbackend:
# mapper: debug
app:
courseLoadPath: D:\\JavaWebProjects\\src\\ico

View File

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