|
@@ -8,18 +8,23 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
|
import com.qmth.boot.core.fss.store.FileStore;
|
|
|
+import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
|
+import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
|
import com.qmth.exam.reserve.bean.student.StudentInfo;
|
|
|
import com.qmth.exam.reserve.bean.student.StudentReq;
|
|
|
import com.qmth.exam.reserve.bean.student.StudentVO;
|
|
|
import com.qmth.exam.reserve.bean.student.WechatBindReq;
|
|
|
+import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
|
import com.qmth.exam.reserve.cache.impl.CategoryCacheService;
|
|
|
+import com.qmth.exam.reserve.config.SysProperty;
|
|
|
import com.qmth.exam.reserve.dao.StudentDao;
|
|
|
import com.qmth.exam.reserve.entity.ApplyTaskEntity;
|
|
|
import com.qmth.exam.reserve.entity.StudentApplyEntity;
|
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
|
import com.qmth.exam.reserve.enums.AsyncTaskType;
|
|
|
import com.qmth.exam.reserve.enums.EventType;
|
|
|
+import com.qmth.exam.reserve.enums.Role;
|
|
|
import com.qmth.exam.reserve.service.*;
|
|
|
import com.qmth.exam.reserve.template.execute.StudentPhotoUploadService;
|
|
|
import com.qmth.exam.reserve.util.FileUtil;
|
|
@@ -35,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -64,6 +70,15 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
@Autowired
|
|
|
private StudentPhotoUploadService studentPhotoUploadService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ApplyTaskCacheService applyTaskCacheService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysProperty sysProperty;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentCourseService studentCourseService;
|
|
|
+
|
|
|
@Override
|
|
|
public StudentEntity findByStudentCode(Long applyTaskId, String studentCode) {
|
|
|
if (StringUtils.isEmpty(studentCode)) {
|
|
@@ -185,24 +200,57 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
@Override
|
|
|
public PageResult<StudentVO> pageStudent(StudentReq req) {
|
|
|
if(req.getTaskId() == null) {
|
|
|
- return new PageResult<>();
|
|
|
+ CurrentApplyTaskVO curApplyTask = applyTaskCacheService.currentApplyTask(null);
|
|
|
+ if(curApplyTask == null) {
|
|
|
+ return new PageResult<>();
|
|
|
+ } else {
|
|
|
+ req.setTaskId(curApplyTask.getTaskId());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
IPage<StudentVO> iPage = baseMapper.pageStudent(new Page<>(req.getPageNumber(), req.getPageSize()), req);
|
|
|
+ List<StudentVO> recordList = iPage.getRecords();
|
|
|
+ for (StudentVO student : recordList) {
|
|
|
+ //添加图片访问前缀
|
|
|
+ student.setPhotoPath(sysProperty.getServer() + File.separator + student.getPhotoPath());
|
|
|
+ }
|
|
|
return PageUtil.of(iPage);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void delete(Long studentId, Long operateId) {
|
|
|
- List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
|
- if (CollectionUtils.isNotEmpty(studentApplyList)) {
|
|
|
- log.warn("[考生删除] 删除失败,存在预约信息,student_id:{}", studentId);
|
|
|
- throw new StatusException("考生存在预约信息,无法删除");
|
|
|
+ @Transactional
|
|
|
+ public void delete(Long[] studentIds, LoginUser loginUser) {
|
|
|
+ for(Long studentId : studentIds) {
|
|
|
+ List<StudentApplyEntity> studentApplyList = getStudentApplyList(studentId);
|
|
|
+ if (CollectionUtils.isNotEmpty(studentApplyList)) {
|
|
|
+ log.warn("[考生删除] 删除失败,存在预约信息,student_id:{}", studentId);
|
|
|
+ throw new StatusException("考生存在预约信息,无法删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentEntity studentEntity = this.getById(studentId);
|
|
|
+ if (studentEntity == null) {
|
|
|
+ log.warn("[考生删除] 考生不存在,student_id:{}", studentId);
|
|
|
+ throw new StatusException("考生不存在,无法删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ //教学点管理员
|
|
|
+ if (loginUser.getRole().equals(Role.TEACHING)) {
|
|
|
+ Long studentCategoryId = studentEntity.getCategoryId();
|
|
|
+ Long loginUserCategoryId = loginUser.getCategoryId();
|
|
|
+ if (!studentCategoryId.equals(loginUserCategoryId)) {
|
|
|
+ log.warn("[考生删除] student_id:{}, 所在教学点{},登录用户的教学点:{} ", studentId, studentCategoryId, loginUserCategoryId);
|
|
|
+ throw new StatusException("不能删除其他教学点的考生");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除考生信息
|
|
|
+ this.removeById(studentId);
|
|
|
+ //删除考生科目
|
|
|
+ studentCourseService.removeStudentCourses(studentId, null);
|
|
|
}
|
|
|
|
|
|
- this.removeById(studentId);
|
|
|
-
|
|
|
//写入日志
|
|
|
- operateLogService.insertOperateLog(operateId, EventType.DELETE_STUDENT, studentId.toString());
|
|
|
+ operateLogService.insertOperateLog(loginUser.getId(), EventType.DELETE_STUDENT, Arrays.toString(studentIds));
|
|
|
}
|
|
|
|
|
|
private List<StudentApplyEntity> getStudentApplyList(Long studentId) {
|