|
@@ -1,10 +1,24 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.qmth.distributed.print.business.bean.params.CourseEvaluationParam;
|
|
|
+import com.qmth.distributed.print.business.bean.result.CourseEvaluationResult;
|
|
|
import com.qmth.distributed.print.business.entity.CourseEvaluation;
|
|
|
+import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
|
+import com.qmth.distributed.print.business.enums.CourseEvaluationTypeEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
|
|
|
import com.qmth.distributed.print.business.mapper.CourseEvaluationMapper;
|
|
|
import com.qmth.distributed.print.business.service.CourseEvaluationService;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.qmth.distributed.print.business.service.TeachCourseService;
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +31,53 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class CourseEvaluationServiceImpl extends ServiceImpl<CourseEvaluationMapper, CourseEvaluation> implements CourseEvaluationService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TeachCourseService teachCourseService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CourseEvaluationResult> findCourseEvaluationList(Long examId, String courseCode, Long userId) {
|
|
|
+ TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, userId);
|
|
|
+ return this.baseMapper.findCourseEvaluationList(teachCourse.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void saveCourseEvaluation(CourseEvaluationParam courseEvaluationParam, SysUser requestUser) {
|
|
|
+ Long requestUserId = requestUser.getId();
|
|
|
+ Long examId = courseEvaluationParam.getExamId();
|
|
|
+ String courseCode = courseEvaluationParam.getCourseCode();
|
|
|
+ String evaluation = courseEvaluationParam.getEvaluation();
|
|
|
+ String evaluationDesc = courseEvaluationParam.getEvaluationDesc();
|
|
|
+
|
|
|
+ TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, requestUserId);
|
|
|
+ Long teachCourseId = teachCourse.getId();
|
|
|
+ if (this.count(
|
|
|
+ new QueryWrapper<CourseEvaluation>().lambda().eq(CourseEvaluation::getTeachCourseId, teachCourseId)
|
|
|
+ .eq(CourseEvaluation::getEvaluation, evaluation)) > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("评价方式重复");
|
|
|
+ }
|
|
|
+
|
|
|
+ CourseEvaluation courseEvaluation = new CourseEvaluation();
|
|
|
+ courseEvaluation.setTeachCourseId(teachCourseId);
|
|
|
+ courseEvaluation.setSchoolId(requestUser.getSchoolId());
|
|
|
+ courseEvaluation.setExamId(examId);
|
|
|
+ courseEvaluation.setCourseCode(courseCode);
|
|
|
+ courseEvaluation.setUserId(requestUserId);
|
|
|
+ courseEvaluation.setType(CourseEvaluationTypeEnum.CUSTOM);
|
|
|
+ courseEvaluation.setEvaluation(evaluation);
|
|
|
+ courseEvaluation.setEvaluationDesc(evaluationDesc);
|
|
|
+ courseEvaluation.insertInfo(requestUserId);
|
|
|
+ this.save(courseEvaluation);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void deleteCourseEvaluation(Long id) {
|
|
|
+ CourseEvaluation courseEvaluation = this.getById(id);
|
|
|
+ if (Objects.nonNull(courseEvaluation)) {
|
|
|
+ Long teachCourseId = courseEvaluation.getTeachCourseId();
|
|
|
+ teachCourseService.clearCourseSetting(teachCourseId, CourseSettingTypeEnum.COURSE_EVALUATION);
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|