ソースを参照

修改课程学生用户的bug

宋悦 8 年 前
コミット
b0d37f4691

+ 1 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java

@@ -75,6 +75,7 @@ public class CourseApi {
         if(accessUser != null){
             course.setOrgId(accessUser.getRootOrgId());
         }
+        course.setEnable(true);
         return new ResponseEntity(courseService.findAll(course), HttpStatus.OK);
     }
     

+ 1 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java

@@ -42,6 +42,7 @@ public class CourseService {
             	Course course = new Course(dto.getName(),dto.getCode());
             	course.setOrgId(orgId);
             	course.setCreateTime(new Date());
+				course.setEnable(true);
             	if("0".equalsIgnoreCase(dto.getLevel())){
             		course.setLevel(CourseLevel.ZSB);
             	}

+ 2 - 2
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java

@@ -110,7 +110,7 @@ public class StudentService {
         if (student.getUser() == null || null == student.getUser().getId()) {//判断是否有用户
             //判断是否有该学生,
             if (!StringUtils.isEmpty(student.getStudentCode())) {
-                Student domain = studentRepo.findByUserRootOrgIdAndStudentCode(student.getUser().getRootOrgId(), student.getStudentCode());
+                Student domain = studentRepo.findByRootOrgIdAndStudentCode(student.getUser().getRootOrgId(), student.getStudentCode());
                 if (domain != null) {//学号查找不为空,更新身份证号
                     domain.setIdentityNumber(student.getIdentityNumber());
                     domain.setUpdateTime(new Date());
@@ -118,7 +118,7 @@ public class StudentService {
                 }
             }
 
-            Student entity = studentRepo.findByIdentityNumber(student.getIdentityNumber());
+            Student entity = studentRepo.findByIdentityNumberAndRootOrgId(student.getIdentityNumber(),student.getRootOrgId());
             if (entity != null) {//身份证查找不为空,更新学号
                 entity.setStudentCode(student.getStudentCode());
                 entity.setUpdateTime(new Date());

+ 3 - 2
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -116,8 +116,9 @@ public class UserService {
         }else if(user.getType() == UserType.STUDENT){
             //截取身份证后6位为学生登录密码
             Student student = studentRepo.findByUserId(userId);
-            if(StringUtils.isNotEmpty(student.getIdentityNumber())){
-                user.setPassword(StringUtils.substring(student.getIdentityNumber(),-6,-1));
+            String identityNumber = student.getIdentityNumber();
+            if(StringUtils.isNotEmpty(identityNumber)){
+                user.setPassword(StringUtils.substring(identityNumber,-6,identityNumber.length()));
             }else{
                 user.setPassword(UserParam.DEFAULT_PASSWORD);
             }

+ 4 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/repo/StudentRepo.java

@@ -14,5 +14,9 @@ public interface StudentRepo extends JpaRepository<Student,Long>,QueryByExampleE
 
 	Student findByIdentityNumber(String identityNumber);
 
+	Student findByIdentityNumberAndRootOrgId(String identityNumber,Long rootOrgId);
+
 	Student findByUserRootOrgIdAndStudentCode(Long rootOrgId, String studentCode);
+
+	Student findByRootOrgIdAndStudentCode(Long rootOrgId, String studentCode);
 }