Prechádzať zdrojové kódy

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-3/examcloud-core-basic.git

WANG 6 rokov pred
rodič
commit
c2238611af

+ 4 - 17
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -179,6 +180,8 @@ public class StudentController extends ControllerSupport {
 				studentCodeList.add(cur.getStudentCode());
 			}
 			bean.setStudentCodeList(studentCodeList);
+			bean.setStudentCodesStr(StringUtils.join(studentCodeList, "<br />"));
+
 			bean.setIdentityNumber(next.getIdentityNumber());
 			if (StringUtils.isNotBlank(next.getPhotoPath())) {
 				bean.setPhotoPath(urlPrefix + next.getPhotoPath());
@@ -486,23 +489,7 @@ public class StudentController extends ControllerSupport {
 	}
 
 	@ApiOperation(value = "解绑学号", notes = "")
-	@PutMapping("unbindStudentCode/{ids}")
-	public void unbindStudentCode(@PathVariable String ids) {
-		List<Long> studentIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-				.collect(Collectors.toList());
-		for (Long cur : studentIds) {
-			StudentEntity s = GlobalHelper.getEntity(studentRepo, cur, StudentEntity.class);
-			if (null == s) {
-				throw new StatusException("450110", "学生不存在");
-			}
-			validateRootOrgIsolation(s.getRootOrgId());
-
-			studentService.unbindStudentCode(s.getRootOrgId(), null, s.getIdentityNumber());
-		}
-	}
-
-	@ApiOperation(value = "解绑学号", notes = "")
-	@PutMapping("unbindStudentCode")
+	@PostMapping("unbindStudentCode")
 	public List<Long> unbindStudentCode(@RequestParam(required = false) String studentCode,
 			@RequestParam(required = false) String identityNumber,
 			@RequestParam(required = true) Long rootOrgId) {

+ 10 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/StudentDomain.java

@@ -24,6 +24,8 @@ public class StudentDomain implements JsonSerializable {
 
 	private List<String> studentCodeList;
 
+	private String studentCodesStr;
+
 	private String identityNumber;
 
 	private String photoPath;
@@ -70,6 +72,14 @@ public class StudentDomain implements JsonSerializable {
 		this.password = password;
 	}
 
+	public String getStudentCodesStr() {
+		return studentCodesStr;
+	}
+
+	public void setStudentCodesStr(String studentCodesStr) {
+		this.studentCodesStr = studentCodesStr;
+	}
+
 	public List<String> getStudentCodeList() {
 		return studentCodeList;
 	}

+ 39 - 40
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/AuthServiceImpl.java

@@ -113,17 +113,17 @@ public class AuthServiceImpl implements AuthService {
 		String imgCode = loginInfo.getImgCode();
 
 		if (StringUtils.isBlank(accountType)) {
-			throw new StatusException("001201", "accountType is null");
+			throw new StatusException("003201", "accountType is null");
 		}
 		if (StringUtils.isBlank(accountValue)) {
-			throw new StatusException("001202", "accountValue is null");
+			throw new StatusException("003202", "accountValue is null");
 		}
 
 		AccountType accountTypeEnum = null;
 		try {
 			accountTypeEnum = AccountType.valueOf(accountType);
 		} catch (Exception e) {
-			throw new StatusException("001204", "accountType is wrong");
+			throw new StatusException("003204", "accountType is wrong");
 		}
 
 		// 系统级别登陆限制
@@ -133,12 +133,12 @@ public class AuthServiceImpl implements AuthService {
 			Boolean stuClientLoginLimit = (Boolean) systemPropertyService
 					.get("STU_CLIENT_LOGIN_LIMIT");
 			if (stuClientLoginLimit) {
-				throw new StatusException("001505", "系统维护中... ...");
+				throw new StatusException("003505", "系统维护中... ...");
 			}
 		} else if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
 			Boolean commonLoginLimit = (Boolean) systemPropertyService.get("COMMON_LOGIN_LIMIT");
 			if (commonLoginLimit) {
-				throw new StatusException("001506", "系统维护中... ...");
+				throw new StatusException("003506", "系统维护中... ...");
 			}
 		}
 
@@ -146,10 +146,10 @@ public class AuthServiceImpl implements AuthService {
 		if (StringUtils.isNotBlank(sessionId) && StringUtils.isNotBlank(imgCode)) {
 			String rightImgCode = redisClient.get("$_IMG_" + sessionId, String.class);
 			if (null == rightImgCode || !rightImgCode.equalsIgnoreCase(imgCode)) {
-				throw new StatusException("002303", "验证码错误");
+				throw new StatusException("003303", "验证码错误");
 			}
 		} else if (5 < errorTimes) {
-			throw new StatusException("001205", "登陆失败次数已达到上限,请5分钟后重试");
+			throw new StatusException("003205", "登陆失败次数已达到上限,请5分钟后重试");
 		}
 
 		StudentEntity student = null;
@@ -157,7 +157,7 @@ public class AuthServiceImpl implements AuthService {
 		if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)) {
 			student = studentRepo.findBySecurityPhone(accountValue);
 			if (null == student) {
-				throw new StatusException("001110", "学生不存在");
+				throw new StatusException("003110", "学生不存在");
 			}
 			loginInfo.setRootOrgId(student.getRootOrgId());
 		}
@@ -166,25 +166,22 @@ public class AuthServiceImpl implements AuthService {
 		OrgEntity rootOrg = null;
 		if (null == rootOrgId) {
 			if (StringUtils.isBlank(loginInfo.getDomain())) {
-				throw new StatusException("001001", "domain,rootOrgId 必须有一个不为空");
+				throw new StatusException("003003", "domain,rootOrgId 必须有一个不为空");
 			}
-
-			try {
-				rootOrg = orgRepo.findByParentIdIsNullAndDomainName(loginInfo.getDomain());
-				rootOrgId = rootOrg.getId();
-			} catch (Exception e) {
-				throw new StatusException("001002", "机构不存在", e);
+			rootOrg = orgRepo.findByParentIdIsNullAndDomainName(loginInfo.getDomain());
+			if (null == rootOrg) {
+				throw new StatusException("003003", "机构不存在");
 			}
-
+			rootOrgId = rootOrg.getId();
 		} else {
 			rootOrg = GlobalHelper.getEntity(orgRepo, Long.valueOf(rootOrgId), OrgEntity.class);
 			if (null == rootOrg) {
-				throw new StatusException("001002", "机构不存在");
+				throw new StatusException("003003", "机构不存在");
 			}
 		}
 
 		if (!rootOrg.getEnable()) {
-			throw new StatusException("003001", "顶级机构被禁用");
+			throw new StatusException("003003", "顶级机构被禁用");
 		}
 
 		String accessibleRootOrgIds = (String) systemPropertyService
@@ -192,7 +189,7 @@ public class AuthServiceImpl implements AuthService {
 		if (StringUtils.isNotBlank(accessibleRootOrgIds)) {
 			accessibleRootOrgIds = "," + accessibleRootOrgIds + ",";
 			if (!accessibleRootOrgIds.contains("," + rootOrg.getId() + ",")) {
-				throw new StatusException("001101", "系统维护中... ...");
+				throw new StatusException("003101", "系统维护中... ...");
 			}
 		}
 
@@ -205,13 +202,13 @@ public class AuthServiceImpl implements AuthService {
 		if (AccountType.COMMON_LOGIN_NAME.equals(accountTypeEnum)) {
 			UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, accountValue);
 			if (null == userEntity) {
-				throw new StatusException("001004", "账号或密码错误");
+				throw new StatusException("003004", "账号或密码错误");
 			}
 			if (null != userEntity.getEnable() && !userEntity.getEnable()) {
-				throw new StatusException("001005", "账号被禁用");
+				throw new StatusException("003005", "账号被禁用");
 			}
 			if (StringUtils.isBlank(password)) {
-				throw new StatusException("001203", "账号或密码错误");
+				throw new StatusException("003203", "账号或密码错误");
 			}
 
 			user.setUserId(userEntity.getId());
@@ -227,12 +224,12 @@ public class AuthServiceImpl implements AuthService {
 				String encodePassword = ByteUtil.toHexAscii(bytes);
 				if (!encodePassword.equals(userEntity.getPassword())) {
 					whenLoginError(accountTypeEnum, accountValue, clientIp);
-					throw new StatusException("001003", "账号或密码错误");
+					throw new StatusException("003003", "账号或密码错误");
 				}
 			} else {
 				if (!password.equals(userEntity.getPassword())) {
 					whenLoginError(accountTypeEnum, accountValue, clientIp);
-					throw new StatusException("001003", "账号或密码错误");
+					throw new StatusException("003003", "账号或密码错误");
 				}
 			}
 
@@ -241,7 +238,9 @@ public class AuthServiceImpl implements AuthService {
 			if (AccountType.STUDENT_CODE.equals(accountTypeEnum)) {
 				StudentCodeEntity scEntity = studentCodeRepo
 						.findByStudentCodeAndRootOrgId(accountValue, rootOrg.getId());
-
+				if (null == scEntity) {
+					throw new StatusException("003009", "账号或密码错误");
+				}
 				student = GlobalHelper.getEntity(studentRepo, scEntity.getStudentId(),
 						StudentEntity.class);
 			}
@@ -252,10 +251,10 @@ public class AuthServiceImpl implements AuthService {
 			}
 
 			if (null == student) {
-				throw new StatusException("001110", "账号或密码错误");
+				throw new StatusException("003110", "账号或密码错误");
 			}
 			if (null != student.getEnable() && !student.getEnable()) {
-				throw new StatusException("001005", "账户被禁用");
+				throw new StatusException("003005", "账户被禁用");
 			}
 
 			// 验证码登录
@@ -271,12 +270,12 @@ public class AuthServiceImpl implements AuthService {
 			// 密码登录
 			else {
 				if (StringUtils.isBlank(password)) {
-					throw new StatusException("001203", "账号或密码错误");
+					throw new StatusException("003203", "账号或密码错误");
 				}
 				String rightPassword = student.getPassword();
 				if (!rightPassword.equals(password)) {
 					whenLoginError(accountTypeEnum, accountValue, clientIp);
-					throw new StatusException("001003", "账号或密码错误");
+					throw new StatusException("003003", "账号或密码错误");
 				}
 			}
 
@@ -306,7 +305,7 @@ public class AuthServiceImpl implements AuthService {
 				// 验证码为空时,发送验证码
 				else {
 					smsCodeService.sendSmsCode(phone);
-					throw new StatusException("001100", "请输入短信验证码");
+					throw new StatusException("003100", "请输入短信验证码");
 				}
 			}
 		}
@@ -323,7 +322,7 @@ public class AuthServiceImpl implements AuthService {
 		// 学习中心禁用时,学习中心用户禁止登录
 		if (1 == user.getRoleList().size() && isLcUser) {
 			if (null != org && !org.getEnable()) {
-				throw new StatusException("001008", "学习中心被禁用");
+				throw new StatusException("003008", "学习中心被禁用");
 			}
 		}
 
@@ -520,11 +519,11 @@ public class AuthServiceImpl implements AuthService {
 		int sessionTimeout = PropertyHolder.getInt(PropKeys.SESSION_TIMEOUT, 3600);
 		User user = redisClient.get(key, User.class, sessionTimeout);
 		if (null == user) {
-			throw new StatusException("001012", "未登录");
+			throw new StatusException("003012", "未登录");
 		}
 
 		if (!user.getToken().equals(token)) {
-			throw new StatusException("001012", "token错误");
+			throw new StatusException("003012", "token错误");
 		}
 
 		return user;
@@ -536,26 +535,26 @@ public class AuthServiceImpl implements AuthService {
 
 		OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
 		if (null == rootOrg) {
-			throw new StatusException("001002", "机构不存在");
+			throw new StatusException("003003", "机构不存在");
 		}
 
 		ThirdPartyAccessEntity thirdPartyAccess = GlobalHelper.getEntity(thirdPartyAccessRepo,
 				new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
 
 		if (null == thirdPartyAccess) {
-			throw new StatusException("001201", "第三方系统接入信息未配置");
+			throw new StatusException("003201", "第三方系统接入信息未配置");
 		}
 
 		long timestampLong = 0L;
 		try {
 			timestampLong = Long.parseLong(timestamp);
 		} catch (Exception e) {
-			throw new StatusException("001202", "timestamp错误");
+			throw new StatusException("003202", "timestamp错误");
 		}
 
 		long currentTimeMillis = System.currentTimeMillis();
 		if (Math.abs(currentTimeMillis - timestampLong) > thirdPartyAccess.getTimeRange()) {
-			throw new StatusException("001203", "timestamp超出时间差范围");
+			throw new StatusException("003203", "timestamp超出时间差范围");
 		}
 
 		String secretKey = thirdPartyAccess.getSecretKey();
@@ -564,12 +563,12 @@ public class AuthServiceImpl implements AuthService {
 		String hexAscii = ByteUtil.toHexAscii(bytes);
 
 		if (!hexAscii.equalsIgnoreCase(token)) {
-			throw new StatusException("001204", "token校验失败");
+			throw new StatusException("003204", "token校验失败");
 		}
 
 		UserEntity userEntity = userRepo.findByRootOrgIdAndLoginName(rootOrgId, loginName);
 		if (userEntity == null) {
-			throw new StatusException("001205", "用户不存在");
+			throw new StatusException("003205", "用户不存在");
 		}
 
 		User user = new User();
@@ -626,7 +625,7 @@ public class AuthServiceImpl implements AuthService {
 				Long roleId = cur.getRoleId();
 				RoleEntity roleEntity = GlobalHelper.getEntity(roleRepo, roleId, RoleEntity.class);
 				if (null == roleEntity) {
-					throw new StatusException("002002", "roleId is wrong. roleId=" + roleId);
+					throw new StatusException("003003", "roleId is wrong. roleId=" + roleId);
 				}
 				Role role = new Role(roleEntity.getId(), roleEntity.getCode(),
 						roleEntity.getName());