|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|