From 79ab2cbd31c022916a8e696903d5eb34b70aa403 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期六, 25 十一月 2023 15:57:07 +0800 Subject: [PATCH] 讨论区关键字过滤、首页班级显示班级信息 --- src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java | 129 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 108 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java b/src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java index ce8f0ed..cebc39c 100644 --- a/src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java +++ b/src/main/java/com/qxueyou/scc/teach/student/service/impl/StudentService.java @@ -1,16 +1,15 @@ package com.qxueyou.scc.teach.student.service.impl; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.RandomUtil; import com.qxueyou.scc.admin.classes.model.ClsClass; +import com.qxueyou.scc.base.dao.CommonDAO; import com.qxueyou.scc.exam.model.ExamResultV; +import com.qxueyou.scc.exercise.model.ExerciseCompleteInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -32,6 +31,7 @@ import com.qxueyou.scc.user.model.QUser; import com.qxueyou.scc.user.model.User; import com.qxueyou.scc.user.service.IUserService; +import org.springframework.util.DigestUtils; @Service public class StudentService extends CommonAppService implements IStudentService { @@ -47,6 +47,9 @@ @Autowired StudentDAO dao; + + @Autowired + CommonDAO commonDAO; @Override public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId) { @@ -80,8 +83,15 @@ @Override - public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId,String comName) { + public Result insertStudent(String classId, String name, String studentNo, boolean sex, String phoneNo, String orgId, String comName, + String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace, + String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email, + String workUnit) { + User user1 = userService.getUserByAccount(studentNo,orgId); + if(user1 != null){ + return new Result(false, "韬唤璇佸凡瀛樺湪"); + } if (dao.exists(studentNo, orgId)) { return new Result(false, "韬唤璇佸凡瀛樺湪"); } @@ -105,7 +115,18 @@ student.setMobilePhone(phoneNo); //鍏徃鍚嶇О student.setSubjectId(comName); - + student.setPhoto(photo); + student.setPassporName(passporName); + student.setNationality(nationality); + student.setAncestralHome(ancestralHome); + student.setBirthday(birthday); + student.setBirthplace(birthplace); + student.setChinaStatus(chinaStatus); + student.setRegisteredAddress(registeredAddress); + student.setHomeAddress(homeAddress); + student.setReligiousBelief(religiousBelief); + student.setEmail(email); + student.setWorkUnit(workUnit); if(StringUtils.isNoneBlank(classId)) { bulkUpdate("update ClsClass set studentCount = studentCount + 1 where deleteFlag is false and classId = ?", new Object[]{classId}); } @@ -123,27 +144,48 @@ return new Result(true, "success"); } @Override - public Result updateStudent(String studentId, String name,String password, String studentNo, boolean sex, String phoneNo) { + public Result updateStudent(String studentId, String name,String password, String studentNo, boolean sex, String phoneNo + , String photo, String passporName, String nationality, String ancestralHome, String birthday, String birthplace, + String chinaStatus, String registeredAddress, String homeAddress, String religiousBelief, String email, + String workUnit, String graduationDestination) { //鏍规嵁瀛﹀鍛業D锛岃幏鍙栫敤鎴蜂俊鎭� StuStudent stu = this.read(StuStudent.class, studentId); - - if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) { - return new Result(false, "瀛﹀彿宸插瓨鍦�"); + if(stu.getStudentNo() != null){ + if (!stu.getStudentNo().equals(studentNo) && dao.exists(studentNo,ClientUtils.getOrgId())) { + return new Result(false, "瀛﹀彿宸插瓨鍦�"); + } } - stu.setName(name); stu.setSex(sex); stu.setStudentNo(studentNo); stu.setMobilePhone(phoneNo); TraceUtils.setUpdateTrace(stu); + stu.setPhoto(photo); + stu.setPassporName(passporName); + stu.setNationality(nationality); + stu.setAncestralHome(ancestralHome); + stu.setBirthday(birthday); + stu.setBirthplace(birthplace); + stu.setChinaStatus(chinaStatus); + stu.setRegisteredAddress(registeredAddress); + stu.setHomeAddress(homeAddress); + stu.setReligiousBelief(religiousBelief); + stu.setEmail(email); + stu.setWorkUnit(workUnit); save(stu); User user = this.read(User.class, stu.getUserId()); user.setAccount(studentNo); user.setSex(sex); user.setMobilePhone(phoneNo); - if(!StringUtils.isEmpty(password)){ - user.setPassword(password); + //闅忔満瀛楃涓� + String salt= UUID.randomUUID().toString(); + //鐩愬�� + user.setSalt(salt); + //瀵瑰瘑鐮佽繘琛屽姞瀵嗗鐞� + String newPassword= DigestUtils.md5DigestAsHex((salt+password).getBytes()); + if(!StringUtils.isEmpty(newPassword)){ + user.setPassword(newPassword); } user.setName(name); save(user); @@ -156,8 +198,10 @@ QUser qUser = QUser.user; QStuStudent qStuStudent = QStuStudent.stuStudent; return this.getQueryFactory() - .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex, - qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score, + .select(qStuStudent.photo,qStuStudent.passporName,qStuStudent.nationality,qStuStudent.ancestralHome,qStuStudent.birthday,qStuStudent.birthplace,qStuStudent.chinaStatus, + qStuStudent.registeredAddress,qStuStudent.homeAddress,qStuStudent.religiousBelief,qStuStudent.email,qStuStudent.workUnit,qStuStudent.graduationDestination, + qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex, + qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score, qStuStudent.graduationText, qUser.imgPath) .from(qUser, qStuStudent) .where(qUser.deleteFlag.isFalse().and(qUser.userId.eq(qStuStudent.userId)) @@ -174,7 +218,21 @@ map.put("studyDuration", tuple.get(qStuStudent.studyDuration)); map.put("tenantId", tuple.get(qStuStudent.tenantId)); map.put("score", tuple.get(qStuStudent.score)); + map.put("graduationText", tuple.get(qStuStudent.graduationText)); map.put("imgPath", tuple.get(qUser.imgPath)); + map.put("photo", tuple.get(qStuStudent.photo)); + map.put("passporName", tuple.get(qStuStudent.passporName)); + map.put("nationality", tuple.get(qStuStudent.nationality)); + map.put("ancestralHome", tuple.get(qStuStudent.ancestralHome)); + map.put("birthday", tuple.get(qStuStudent.birthday)); + map.put("birthplace", tuple.get(qStuStudent.birthplace)); + map.put("chinaStatus", tuple.get(qStuStudent.chinaStatus)); + map.put("registeredAddress", tuple.get(qStuStudent.registeredAddress)); + map.put("homeAddress", tuple.get(qStuStudent.homeAddress)); + map.put("religiousBelief", tuple.get(qStuStudent.religiousBelief)); + map.put("email", tuple.get(qStuStudent.email)); + map.put("workUnit", tuple.get(qStuStudent.workUnit)); + map.put("graduationDestination", tuple.get(qStuStudent.graduationDestination)); return map; }).collect(Collectors.toList()); } @@ -223,6 +281,7 @@ public Result doActivateStudent(String[] studentIds) { for (String studentId : studentIds) { activateStudent(studentId, StuStudent.STATUS_ACTIVE); + ModeUpdate(studentId,StuStudent.STATUS_ACTIVE); } return new Result(true); } @@ -231,6 +290,28 @@ public Result doDeActivateStudent(String[] studentIds) { for (String studentId : studentIds) { activateStudent(studentId, StuStudent.STATUS_DEACTIVE); + ModeUpdate(studentId,StuStudent.STATUS_DEACTIVE); + } + return new Result(true); + } + + private Result ModeUpdate(String studentId,String status){ + if(status.equals(StuStudent.STATUS_ACTIVE)){ + String hql = "from ExerciseCompleteInfo where studentId=? and deleteFlag is false"; + List<Object> Params = CollectionUtils.newList(studentId); + ExerciseCompleteInfo unique = findUnique(hql, Params, ExerciseCompleteInfo.class); + if(unique!=null) { + unique.setDeleteFlag(false); + commonDAO.update(unique); + } + }else { + String hql = "from ExerciseCompleteInfo where studentId=? and deleteFlag is false"; + List<Object> Params = CollectionUtils.newList(studentId); + ExerciseCompleteInfo unique = findUnique(hql, Params, ExerciseCompleteInfo.class); + if(unique!=null){ + unique.setDeleteFlag(true); + commonDAO.update(unique); + } } return new Result(true); } @@ -243,13 +324,13 @@ } TraceUtils.setUpdateTrace(student); - String currentTime = LocalDateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS"); - - String examCardNo = currentTime.concat(RandomUtil.randomNumbers(1)); - - student.setStudentNumber(examCardNo); +// String currentTime = LocalDateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS"); +// +// String examCardNo = currentTime.concat(RandomUtil.randomNumbers(1)); +// +// student.setStudentNumber(examCardNo); student.setStatus(status); - save(student); + commonDAO.update(student); clsService.addStudent(student.getClassId(), StuStudent.STATUS_DEACTIVE.equals(status) ? -1 : 1); @@ -277,6 +358,12 @@ public StuStudent getStudentByNo(String studentNo) { return this.findUnique("from StuStudent where studentNo=? ", CollectionUtils.newList(studentNo), StuStudent.class); } + + @Override + public StuStudent getStudentDetails(String userId) { + return this.findUnique("from StuStudent where deleteFlag is false and userId=? ", CollectionUtils.newList(userId), StuStudent.class); + } + @Override public List<StuStudent> getStudentByclassId(String classId) { QStuStudent qClassStudent=QStuStudent.stuStudent; -- Gitblit v1.8.0