|
@@ -24,6 +24,7 @@ import com.qmth.exam.reserve.config.SysProperty;
|
|
import com.qmth.exam.reserve.dao.StudentDao;
|
|
import com.qmth.exam.reserve.dao.StudentDao;
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
|
|
+import com.qmth.exam.reserve.entity.StudentCourseEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
import com.qmth.exam.reserve.enums.AsyncTaskType;
|
|
import com.qmth.exam.reserve.enums.AsyncTaskType;
|
|
import com.qmth.exam.reserve.enums.EventType;
|
|
import com.qmth.exam.reserve.enums.EventType;
|
|
@@ -231,8 +232,14 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void delete(Long[] studentIds, LoginUser loginUser) {
|
|
|
|
- for(Long studentId : studentIds) {
|
|
|
|
|
|
+ public void delete(Long[] studentCourseIds, LoginUser loginUser) {
|
|
|
|
+ // 考生科目ID
|
|
|
|
+ for(Long studentCourseId : studentCourseIds) {
|
|
|
|
+ StudentCourseEntity studentCourseEntity = studentCourseService.getById(studentCourseId);
|
|
|
|
+ if(studentCourseEntity == null) {
|
|
|
|
+ throw new StatusException("考生科目不存在");
|
|
|
|
+ }
|
|
|
|
+ Long studentId = studentCourseEntity.getStudentId();
|
|
List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
if (CollectionUtils.isNotEmpty(studentApplyList)) {
|
|
if (CollectionUtils.isNotEmpty(studentApplyList)) {
|
|
log.warn("[考生删除] 删除失败,存在预约信息,student_id:{}", studentId);
|
|
log.warn("[考生删除] 删除失败,存在预约信息,student_id:{}", studentId);
|
|
@@ -251,18 +258,31 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
Long loginUserCategoryId = loginUser.getCategoryId();
|
|
Long loginUserCategoryId = loginUser.getCategoryId();
|
|
if (!studentCategoryId.equals(loginUserCategoryId)) {
|
|
if (!studentCategoryId.equals(loginUserCategoryId)) {
|
|
log.warn("[考生删除] student_id:{}, 所在教学点{},登录用户的教学点:{} ", studentId, studentCategoryId, loginUserCategoryId);
|
|
log.warn("[考生删除] student_id:{}, 所在教学点{},登录用户的教学点:{} ", studentId, studentCategoryId, loginUserCategoryId);
|
|
- throw new StatusException("不能删除其他教学点的考生");
|
|
|
|
|
|
+ throw new StatusException("不能删除其他教学点的考生科目信息");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //删除考生信息
|
|
|
|
- this.removeById(studentId);
|
|
|
|
- //删除考生科目
|
|
|
|
- studentCourseService.removeStudentCourses(studentId, null);
|
|
|
|
- }
|
|
|
|
|
|
+ // 删除科目信息
|
|
|
|
+ studentCourseService.removeById(studentCourseId);
|
|
|
|
|
|
- //写入日志
|
|
|
|
- operateLogService.insertOperateLog(loginUser.getId(), EventType.DELETE_STUDENT, Arrays.toString(studentIds));
|
|
|
|
|
|
+ // 考生是否还有科目,没有科目,删除考生
|
|
|
|
+ LambdaQueryWrapper<StudentCourseEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(StudentCourseEntity::getStudentId, studentId);
|
|
|
|
+ List<StudentCourseEntity> studentCourseList = studentCourseService.list(wrapper);
|
|
|
|
+ if (CollectionUtils.isEmpty(studentCourseList)) {
|
|
|
|
+ //删除考生信息
|
|
|
|
+ this.removeById(studentId);
|
|
|
|
+ } else {
|
|
|
|
+ //更新考生的预约次数
|
|
|
|
+ this.updateStudentApplyNumber(studentId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 清空缓存
|
|
|
|
+ applyTaskCacheService.clearStudentApplyNumberCache(studentId);
|
|
|
|
+
|
|
|
|
+ //写入日志
|
|
|
|
+ operateLogService.insertOperateLog(loginUser.getId(), EventType.DELETE_STUDENT, String.join("-", studentId.toString(), studentCourseId.toString()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private List<StudentApplyEntity> getStudentApplyList(Long studentId) {
|
|
private List<StudentApplyEntity> getStudentApplyList(Long studentId) {
|