添加Course的utils

优化课程删除逻辑
编辑课程加锁
master
Alan 6 months ago
parent 03758c7d3b
commit 2e9ea8cf6c
  1. 4
      src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java
  2. 11
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  3. 2
      src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java
  4. 11
      src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java
  5. 5
      src/main/java/com/teaching/backend/model/entity/courses/Courses.java
  6. 6
      src/main/java/com/teaching/backend/model/entity/courses/ObjectivesType.java
  7. 4
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  8. 70
      src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
  9. 137
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  10. 37
      src/main/java/com/teaching/backend/utils/CourseCode.java
  11. 1
      src/main/resources/mapper/CourseObjectivesMapper.xml

@ -14,7 +14,6 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@ -25,7 +24,7 @@ import java.util.List;
* @author zjh * @author zjh
* @since 2024-05-31 * @since 2024-05-31
*/ */
@Api(tags = "项目目标管理接口") @Api(tags = "课程目标管理接口")
@RestController @RestController
@RequestMapping("/course_objectives") @RequestMapping("/course_objectives")
public class CourseObjectivesController { public class CourseObjectivesController {
@ -62,7 +61,6 @@ public class CourseObjectivesController {
String pid = courseObjectivesDTO.getPid(); String pid = courseObjectivesDTO.getPid();
CourseObjectives courseObjectives = courseObjectivesMapper.selectById(pid); CourseObjectives courseObjectives = courseObjectivesMapper.selectById(pid);
BeanUtil.copyProperties(courseObjectivesDTO, courseObjectives); BeanUtil.copyProperties(courseObjectivesDTO, courseObjectives);
courseObjectives.setUpdateTime(LocalDateTime.now());
courseObjectivesService.updateById(courseObjectives); courseObjectivesService.updateById(courseObjectives);
return ResultUtils.success("编辑成功"); return ResultUtils.success("编辑成功");
} }

@ -49,10 +49,10 @@ public class CoursesController {
return ResultUtils.success(objectMap); return ResultUtils.success(objectMap);
} }
@ApiOperation("新增课程--同步新增课程的总体目标") @ApiOperation("新增课程--同步新增课程的总体目标并同时添加所有的分项目标")
@PostMapping("/addcourse") @PostMapping("/addcourse")
public BaseResponse<String> saveCourse(@RequestBody CoursesDTO coursesDTO, @RequestParam String teacherId){ public BaseResponse<String> saveCourse(@RequestBody CoursesDTO coursesDTO){
String data = coursesService.saveCourseWithObjective(coursesDTO, teacherId); String data = coursesService.saveCourseWithObjective(coursesDTO);
return ResultUtils.success(data); return ResultUtils.success(data);
} }
@ -76,10 +76,7 @@ public class CoursesController {
@ApiOperation("根据id修改课程") @ApiOperation("根据id修改课程")
@PutMapping @PutMapping
public BaseResponse<String> editCourse(@RequestBody CoursesDTO coursesDTO){ public BaseResponse<String> editCourse(@RequestBody CoursesDTO coursesDTO){
String courseId = coursesDTO.getId(); coursesService.updateCourse(coursesDTO);
Courses course = coursesService.getById(courseId);
BeanUtil.copyProperties(coursesDTO, course);
coursesService.updateById(course);
return ResultUtils.success("编辑成功"); return ResultUtils.success("编辑成功");
} }

@ -26,7 +26,7 @@ public class CourseObjectivesDTO implements Serializable {
* 分项目标类型 思政 知识素质价值 * 分项目标类型 思政 知识素质价值
*/ */
@ApiModelProperty(value = "分项目标类型",required = true) @ApiModelProperty(value = "分项目标类型",required = true)
private String type; private Integer type;
/** /**
* 父节点 * 父节点
*/ */

@ -33,24 +33,17 @@ public class CourseObjectives implements Serializable {
@TableId(value = "id", type = IdType.ASSIGN_UUID) @TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id; private String id;
@ApiModelProperty(value = "创建日期")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新日期")
private LocalDateTime updateTime;
@ApiModelProperty(value = "父级节点") @ApiModelProperty(value = "父级节点")
private String pid; private String pid;
@ApiModelProperty(value = "是否有子节点") @ApiModelProperty(value = "是否有子节点")
private String hasChild; private Integer hasChild;
@ApiModelProperty(value = "目标名称") @ApiModelProperty(value = "目标名称")
private String name; private String name;
@ApiModelProperty(value = "目标类型") @ApiModelProperty(value = "目标类型")
private String type; private Integer type;
@ApiModelProperty(value = "课程id") @ApiModelProperty(value = "课程id")

@ -139,5 +139,10 @@ public class Courses implements Serializable {
*/ */
private String description; private String description;
/**
*课程状态
*/
private int status;
} }

@ -27,9 +27,9 @@ public class ObjectivesType implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID) @TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value = "类型编码,不用输入,使用雪花算法生成") @ApiModelProperty(value = "类型编码,不用输入,使用自动生成")
private String id; private Integer id;
@ApiModelProperty(value = "类型名称",required = true) @ApiModelProperty(value = "类型名称",required = true)
private String typeName; private String typeName;

@ -21,7 +21,7 @@ import java.util.List;
*/ */
public interface ICoursesService extends IService<Courses> { public interface ICoursesService extends IService<Courses> {
String saveCourseWithObjective(CoursesDTO coursesDTO, String teacherId); String saveCourseWithObjective(CoursesDTO coursesDTO);
PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery, String teacherId); PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery, String teacherId);
@ -31,4 +31,6 @@ public interface ICoursesService extends IService<Courses> {
int countHours(String id); int countHours(String id);
List<CoursesVO> getPagePageSize(int page, int pageSize); List<CoursesVO> getPagePageSize(int page, int pageSize);
void updateCourse(CoursesDTO coursesDTO);
} }

@ -12,8 +12,12 @@ import com.teaching.backend.model.entity.courses.CourseObjectives;
import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.model.vo.CourseObjectivesTreeVO; import com.teaching.backend.model.vo.CourseObjectivesTreeVO;
import com.teaching.backend.service.courses.ICourseObjectivesService; import com.teaching.backend.service.courses.ICourseObjectivesService;
import com.teaching.backend.utils.CourseCode;
import io.swagger.models.auth.In;
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.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -39,37 +43,46 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
ObjectiveContentsMapper objectiveContentsMapper; ObjectiveContentsMapper objectiveContentsMapper;
@Override @Override
@Transactional
public String addObjectives(CourseObjectivesDTO courseObjectivesDTO) { public String addObjectives(CourseObjectivesDTO courseObjectivesDTO) {
CourseObjectives courseObjectivesNew = new CourseObjectives();
BeanUtil.copyProperties(courseObjectivesDTO,courseObjectivesNew);
String pid = courseObjectivesDTO.getPid(); String pid = courseObjectivesDTO.getPid();
if(pid.equals(null)){ if(pid.equals(null)){
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR,"pid父节点不能为空"); throw new BusinessException(ErrorCode.NOT_FOUND_ERROR,"pid父节点不能为空");
} }
String hasChild = courseObjectivesMapper.selectById(pid).getHasChild(); Integer type = courseObjectivesDTO.getType();
String type = courseObjectivesDTO.getType();
if (hasChild.equals("0") && !type.equals("71f73bd999f678bcbbdb101e23277feb")){
throw new BusinessException(ErrorCode.PARAMS_ILLEGAL,"请在添加完思政目标以后再添加此类型目标!");
}
//判断是否已经添加过该类型的目标 //判断是否已经添加过该类型的目标
//每个类型的目标只能有一个 //每个类型的目标只能有一个
LambdaQueryWrapper<CourseObjectives> queryWrapper = new LambdaQueryWrapper<>(); Long count = courseObjectivesMapper.selectCount(new LambdaQueryWrapper<CourseObjectives>()
queryWrapper
.eq(CourseObjectives::getPid, pid) .eq(CourseObjectives::getPid, pid)
.eq(CourseObjectives::getType, type); .eq(CourseObjectives::getType, type));
Long count = courseObjectivesMapper.selectCount(queryWrapper); if (count==CourseCode.OBJECTIVE_EXIT.getValue()){
if (count>0){
throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该类型的目标已存在,禁止重复添加!"); throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该类型的目标已存在,禁止重复添加!");
} }
//往表里面写分项目标 if (type!=CourseCode.SI_ZHENG_TYPE.getValue()){
CourseObjectives courseObjectivesNew = new CourseObjectives(); Long sz = SZ_EXIT(courseObjectivesDTO);
BeanUtil.copyProperties(courseObjectivesDTO,courseObjectivesNew); if (sz!=CourseCode.SI_ZHENG_EXIT.getValue()){
courseObjectivesNew.setCreateTime(LocalDateTime.now()); throw new BusinessException(ErrorCode.PARAMS_ILLEGAL,"请在添加完思政目标以后再添加此类型目标!");
}
}
courseObjectivesMapper.insert(courseObjectivesNew); courseObjectivesMapper.insert(courseObjectivesNew);
//插入数据以后要把总体目标那边的haschild改成1
CourseObjectives courseObjectivesOld = courseObjectivesMapper.selectById(pid);
courseObjectivesOld.setUpdateTime(LocalDateTime.now());
courseObjectivesOld.setHasChild("1");
courseObjectivesMapper.updateById(courseObjectivesOld);
return "添加成功"; return "添加成功";
//往表里面写分项目标
// courseObjectivesMapper.insert(courseObjectivesNew);
// //插入数据以后要把总体目标那边的haschild改成1
// CourseObjectives courseObjectivesOld = courseObjectivesMapper.selectById(pid);
// courseObjectivesOld.setHasChild(1);
// courseObjectivesMapper.updateById(courseObjectivesOld);
}
private Long SZ_EXIT(CourseObjectivesDTO courseObjectivesDTO) {
Long count = courseObjectivesMapper.selectCount(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getPid, courseObjectivesDTO.getPid())
.eq(CourseObjectives::getType, CourseCode.SI_ZHENG_TYPE.getValue()));
return count;
} }
/** /**
@ -82,21 +95,20 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
*/ */
@Override @Override
public String deleteObjectives(String id) { public String deleteObjectives(String id) {
final String SI_ZHENG_TYPE="71f73bd999f678bcbbdb101e23277feb";
CourseObjectives courseObjectives = courseObjectivesMapper.selectById(id); CourseObjectives courseObjectives = courseObjectivesMapper.selectById(id);
if (courseObjectives == null) { if (courseObjectives == null) {
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
} }
String type = courseObjectives.getType(); Integer type = courseObjectives.getType();
String pid = courseObjectives.getPid(); String pid = courseObjectives.getPid();
if (SI_ZHENG_TYPE.equals(type)){ if (type.equals(CourseCode.SI_ZHENG_TYPE.getValue())){
LambdaQueryWrapper<CourseObjectives> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CourseObjectives> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CourseObjectives::getPid, pid); queryWrapper.eq(CourseObjectives::getPid, pid);
Long count1 = courseObjectivesMapper.selectCount(queryWrapper); Long countSZ = courseObjectivesMapper.selectCount(queryWrapper);
if (count1==1){ if (countSZ==CourseCode.SI_ZHENG_EXIT.getValue()){
Long count2 = getCount(id); Long countContentsSZ = getCount(id);
if (count2==0) if (countContentsSZ<(CourseCode.CONTENT_EXIT.getValue()))
{ {
// 删除操作和更新父目标状态 // 删除操作和更新父目标状态
deleteObjectiveAndUpdateParent(id, pid); deleteObjectiveAndUpdateParent(id, pid);
@ -112,8 +124,8 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
} }
} }
else { else {
Long count3 = getCount(id); Long countContentsF = getCount(id);
if (count3==0){ if (countContentsF<CourseCode.CONTENT_EXIT.getValue()){
courseObjectivesMapper.deleteById(id); courseObjectivesMapper.deleteById(id);
return "删除成功"; return "删除成功";
} }
@ -133,7 +145,7 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
private void deleteObjectiveAndUpdateParent(String id, String pid) { private void deleteObjectiveAndUpdateParent(String id, String pid) {
courseObjectivesMapper.deleteById(id); courseObjectivesMapper.deleteById(id);
CourseObjectives parentObjective = courseObjectivesMapper.selectById(pid); CourseObjectives parentObjective = courseObjectivesMapper.selectById(pid);
parentObjective.setHasChild("0"); parentObjective.setHasChild(0);
courseObjectivesMapper.updateById(parentObjective); courseObjectivesMapper.updateById(parentObjective);
} }

@ -11,22 +11,26 @@ import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.mapper.courses.CourseObjectivesMapper;
import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; import com.teaching.backend.mapper.courses.ObjectiveContentsMapper;
import com.teaching.backend.mapper.courses.ObjectivesTypeMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.CourseObjectives;
import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.model.entity.courses.ObjectivesType;
import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.CoursesVO; import com.teaching.backend.model.vo.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.utils.CourseCode;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
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.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -46,17 +50,16 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
CourseObjectivesMapper courseObjectivesMapper; CourseObjectivesMapper courseObjectivesMapper;
@Autowired @Autowired
ObjectiveContentsMapper objectiveContentsMapper; ObjectiveContentsMapper objectiveContentsMapper;
@Autowired
ObjectivesTypeMapper objectivesTypeMapper;
@Override @Override
@Transactional @Transactional
public String saveCourseWithObjective(CoursesDTO coursesDTO, String teacherId) { public String saveCourseWithObjective(CoursesDTO coursesDTO) {
Courses courses = new Courses(); Courses courses = new Courses();
CourseObjectives courseObjectives = new CourseObjectives(); CourseObjectives courseObjectives = new CourseObjectives();
BeanUtils.copyProperties(coursesDTO, courses); BeanUtils.copyProperties(coursesDTO, courses);
// List<String> teacherIds = new ArrayList<>();
// teacherIds.add(teacherId);
// courses.setTeacher(String.valueOf(teacherIds));
courses.setTeacher(teacherId);
courses.setCreateTime(LocalDateTime.now()); courses.setCreateTime(LocalDateTime.now());
String code = coursesDTO.getCode(); String code = coursesDTO.getCode();
QueryWrapper<Courses> queryWrapper = new QueryWrapper<>(); QueryWrapper<Courses> queryWrapper = new QueryWrapper<>();
@ -65,11 +68,28 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
if (count == 0) { if (count == 0) {
int insert = coursesMapper.insert(courses); int insert = coursesMapper.insert(courses);
if (insert > 0) { if (insert > 0) {
Courses courses1 = coursesMapper.selectOne(queryWrapper); Courses coursesNew = coursesMapper.selectOne(queryWrapper);
courseObjectives.setCourseId(courses1.getId()); courseObjectives.setCourseId(coursesNew.getId());
courseObjectives.setCreateTime(courses1.getCreateTime()); courseObjectives.setName(coursesNew.getName() + "课程总体目标");
courseObjectives.setName(courses1.getName() + "课程总体目标"); // courseObjectives.setHasChild(1);
courseObjectivesMapper.insert(courseObjectives); int insertTotal = courseObjectivesMapper.insert(courseObjectives);
if (insertTotal>0){
CourseObjectives courseTotalObjectives = courseObjectivesMapper.selectOne
(new LambdaQueryWrapper<CourseObjectives>().eq(CourseObjectives::getCourseId, coursesNew.getId()));
String courseTotalObjectivesId = courseTotalObjectives.getId();
List<ObjectivesType> objectivesTypes = objectivesTypeMapper.selectList(new LambdaQueryWrapper<ObjectivesType>());
for (ObjectivesType objectivesType : objectivesTypes) {
Integer typeId = objectivesType.getId();
String typeName = objectivesType.getTypeName();
CourseObjectives courseObjectivesF = new CourseObjectives();
courseObjectivesF.setType(typeId);
courseObjectivesF.setName(typeName);
courseObjectivesF.setPid(courseTotalObjectivesId);
courseObjectivesMapper.insert(courseObjectivesF);
}
courseTotalObjectives.setHasChild(1);
courseObjectivesMapper.updateById(courseTotalObjectives);
}
} }
return "添加成功"; return "添加成功";
} else { } else {
@ -97,79 +117,54 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} }
@Override @Override
// @Transactional
public void deleteBatchByIds(String id) { public void deleteBatchByIds(String id) {
LambdaQueryWrapper<CourseObjectives> queryWrapper = new LambdaQueryWrapper<CourseObjectives>().eq(CourseObjectives::getCourseId, id); CourseObjectives courseObjectives= courseObjectivesMapper.selectOne
CourseObjectives courseObjectives = courseObjectivesMapper.selectOne(queryWrapper); (new LambdaQueryWrapper<CourseObjectives>().eq(CourseObjectives::getCourseId, id));
String objectivesId = courseObjectives.getId(); String objectivesId = courseObjectives.getId();
LambdaQueryWrapper<ObjectiveContents> queryWrapper2 = new LambdaQueryWrapper<ObjectiveContents>().eq(ObjectiveContents::getObjectiveId, objectivesId); List<CourseObjectivesTreeVO> courseObjectivesTreeVOList = courseObjectivesMapper.selectTreeNodes(objectivesId);
Long count = objectiveContentsMapper.selectCount(queryWrapper2); int contents = 0;
if (courseObjectives.getHasChild().equals("1")) { List<String> objectiveIds = new ArrayList<>();
throw new BusinessException(ErrorCode.CONTENT_EXISTS, "该课程已有分项目标,禁止删除"); for (CourseObjectivesTreeVO courseObjectivesTreeVO : courseObjectivesTreeVOList) {
} String objectiveId = courseObjectivesTreeVO.getId();
if (!count.equals(0)){ objectiveIds.add(objectiveId);
throw new BusinessException(ErrorCode.CONTENT_EXISTS, "总目标下面还有内容,禁止删除"); Long content = objectiveContentsMapper
.selectCount(new LambdaQueryWrapper<ObjectiveContents>().eq(ObjectiveContents::getObjectiveId, objectiveId));
contents+=content;
} }
else { if (contents==0){
coursesMapper.deleteById(id); coursesMapper.deleteById(id);
courseObjectivesMapper.deleteById(courseObjectives.getId()); courseObjectivesMapper.deleteBatchIds(objectiveIds);
}
else{
throw new BusinessException(ErrorCode.CONTENT_EXISTS, "该课程的目标下面还有内容,请把相关内容清空后再来删除课程");
} }
} }
@Override @Override
public List<CoursesVO> getPagePageSize(int page, int pageSize) { public int countHours(String id) {
int startIndex = (page-1) * pageSize; return 0;
List<Courses> list = coursesMapper.getItemsByPage(startIndex, pageSize);
// List<Courses> list = coursesMapper.selectList(null);
List<CoursesVO> coursesVo = BeanUtil.copyToList(list, CoursesVO.class);
coursesVo = coursesVo.stream().map((item) -> {
item.setTotalHours(countHours(item.getId()));
item.setTotalchapter(100);
item.setTotalKnow(100);
// if (StringUtils.isBlank(item.getName()) ||
// StringUtils.isBlank(item.getDescription()) ){
// throw new BusinessException(ErrorCode.OPERATION_ERROR,"数据格式有问题,请修改");
// }
return item;
}).collect(Collectors.toList());
return coursesVo;
} }
@Override @Override
public int countHours(String id) { public List<CoursesVO> getPagePageSize(int page, int pageSize) {
Courses courses = coursesMapper.selectById(id); return null;
}
Integer classhours = 0;
Integer theoryhours = 0;
Integer practicehours = 0;
Integer experimenthours = 0;
Integer otherhours = 0;
if (courses.getClasshours() != null) {
classhours = courses.getClasshours();
}
if (courses.getTheoryhours() != null) {
theoryhours = courses.getTheoryhours();
}
if (courses.getPracticehours() != null) {
practicehours = courses.getPracticehours();
}
if (courses.getExperimenthours() != null) {
experimenthours = courses.getExperimenthours();
}
if (courses.getOtherhours() != null) { /**
otherhours = courses.getOtherhours(); * 修改课程信息
* @param coursesDTO
*/
public void updateCourse(CoursesDTO coursesDTO) {
String courseId = coursesDTO.getId();
Courses course = coursesMapper.selectById(courseId);
if (course.getStatus()==CourseCode.COURSE_UODATING.getValue()){
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"课程正在修改中,请等待修改完成后再进行操作");
} }
int total = classhours + theoryhours + practicehours + experimenthours + otherhours; course.setStatus(CourseCode.COURSE_UODATING.getValue());
coursesMapper.updateById(course);
return total; BeanUtil.copyProperties(coursesDTO, course);
course.setStatus(0);
coursesMapper.updateById(course);
} }

@ -0,0 +1,37 @@
package com.teaching.backend.utils;
public enum CourseCode {
HAS_CHILD(1, "存在子节点"),
OBJECTIVE_EXIT(1,"目标存在"),
CONTENT_EXIT(1, "存在内容"),
SI_ZHENG_TYPE(1, "思政目标类型"),
SI_ZHENG_EXIT(1, "思政目标存在"),
COURSE_UODATING(1, "课程正在修改中");
/**
* 状态码
*/
private final int value;
/**
* 信息
*/
private final String message;
CourseCode(int value, String message) {
this.value = value;
this.message = message;
}
public int getValue() {
return value;
}
public String getMessage() {
return message;
}
}

@ -4,7 +4,6 @@
<select id="selectTreeNodes" resultType="com.teaching.backend.model.vo.CourseObjectivesTreeVO" <select id="selectTreeNodes" resultType="com.teaching.backend.model.vo.CourseObjectivesTreeVO"
parameterType="string"> parameterType="string">
with recursive t1 as ( with recursive t1 as (
select * from course_objectives where id=#{courseObjectivesId} select * from course_objectives where id=#{courseObjectivesId}
union all union all

Loading…
Cancel
Save