Browse Source

Merge remote-tracking branch 'remotes/origin/dev_1.0.0' into release_1.0.0

xiatian 2 years ago
parent
commit
757b8f3e10

+ 21 - 4
src/main/java/cn/com/qmth/mps/service/impl/AuthServiceImpl.java

@@ -20,6 +20,7 @@ import com.qmth.boot.tools.uuid.FastUUID;
 
 import cn.com.qmth.mps.bean.User;
 import cn.com.qmth.mps.config.SysProperty;
+import cn.com.qmth.mps.entity.SchoolEntity;
 import cn.com.qmth.mps.entity.UserEntity;
 import cn.com.qmth.mps.entity.WxappAccessTokenEntity;
 import cn.com.qmth.mps.entity.WxappInfoEntity;
@@ -72,6 +73,10 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		if (!userEntity.getRoleId().equals(Role.SECTION_LEADER.getId())) {
 			throw new StatusException("该用户不是科组长");
 		}
+		SchoolEntity school=schoolService.getById(userEntity.getSchoolId());
+		if (!school.getEnable()) {
+			throw new StatusException("该学校已禁用");
+		}
 		User user = new User();
 		user.setName(userEntity.getName());
 		user.setSchoolId(userEntity.getSchoolId());
@@ -86,7 +91,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		vo.setSessionId(user.getSessionId());
 		vo.setSchoolId(user.getSchoolId());
 		vo.setRole(user.getRole());
-		vo.setSchoolName(schoolService.getById(user.getSchoolId()).getName());
+		vo.setSchoolName(school.getName());
 		return vo;
 	}
 
@@ -102,6 +107,10 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		if (userEntity.getRoleId().equals(Role.SECTION_LEADER.getId())) {
 			throw new StatusException("科组长无权限登录");
 		}
+		SchoolEntity school=schoolService.getById(userEntity.getSchoolId());
+		if (!school.getEnable()) {
+			throw new StatusException("该学校已禁用");
+		}
 		byte[] bytes = SHA256.encode(password);
 		String encodePassword = ByteUtil.toHexAscii(bytes);
 		if (!encodePassword.equals(userEntity.getPassword())) {
@@ -121,7 +130,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		vo.setSessionId(user.getSessionId());
 		vo.setSchoolId(user.getSchoolId());
 		vo.setRole(user.getRole());
-		vo.setSchoolName(schoolService.getById(user.getSchoolId()).getName());
+		vo.setSchoolName(school.getName());
 		return vo;
 	}
 
@@ -186,6 +195,10 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		if (!userEntity.getRoleId().equals(Role.SECTION_LEADER.getId())) {
 			throw new StatusException("该用户不是科组长");
 		}
+		SchoolEntity school=schoolService.getById(userEntity.getSchoolId());
+		if (!school.getEnable()) {
+			throw new StatusException("该学校已禁用");
+		}
 		WxappInfoEntity wi=wxappInfoService.getByOpenId(openid);
 		if(wi==null) {
 			wi=new WxappInfoEntity();
@@ -207,7 +220,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		vo.setSessionId(user.getSessionId());
 		vo.setSchoolId(user.getSchoolId());
 		vo.setRole(user.getRole());
-		vo.setSchoolName(schoolService.getById(user.getSchoolId()).getName());
+		vo.setSchoolName(school.getName());
 		return vo;
 	}
 
@@ -288,6 +301,10 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		if (!userEntity.getRoleId().equals(Role.SECTION_LEADER.getId())) {
 			throw new StatusException("该用户不是科组长");
 		}
+		SchoolEntity school=schoolService.getById(userEntity.getSchoolId());
+		if (!school.getEnable()) {
+			throw new StatusException("该学校已禁用");
+		}
 		JSONObject auth=getAuthorization(loginCode);
 		String openid=ByteUtil.toHexAscii(SHA256.encode(auth.getString("openid")));
 		WxappInfoEntity wi=wxappInfoService.getByOpenId(openid);
@@ -311,7 +328,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 		vo.setSessionId(user.getSessionId());
 		vo.setSchoolId(user.getSchoolId());
 		vo.setRole(user.getRole());
-		vo.setSchoolName(schoolService.getById(user.getSchoolId()).getName());
+		vo.setSchoolName(school.getName());
 		return vo;
 	}
 }

+ 3 - 0
src/main/java/cn/com/qmth/mps/service/impl/SchoolServiceImpl.java

@@ -156,6 +156,9 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolDao, SchoolEntity> impl
 		if (!user.getRole().equals(Role.SUPER_ADMIN)) {
 			throw new StatusException("没有权限");
 		}
+		if (ids.contains(1L)) {
+			throw new StatusException("默认学校不能禁用(ID:1)");
+		}
 		UpdateWrapper<SchoolEntity> wrapper = new UpdateWrapper<>();
 		LambdaUpdateWrapper<SchoolEntity> lw = wrapper.lambda();
 		lw.set(SchoolEntity::getEnable, enable);

+ 9 - 0
src/main/java/cn/com/qmth/mps/service/impl/UserServiceImpl.java

@@ -7,6 +7,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import org.apache.commons.collections4.CollectionUtils;
@@ -49,6 +50,7 @@ import cn.com.qmth.mps.vo.user.UserVo;
 @Service
 public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {
 	private static final String DEFAULT_PASSWD = "123456";
+	private static Pattern numberRex = Pattern.compile("^1[0-9]{10}$");
 
 	@Autowired
 	private UserCourseRelationService userCourseRelationService;
@@ -178,6 +180,13 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 
 				impuser.setRole(Role.getByName(role));
 
+				if (Role.SECTION_LEADER.equals(impuser.getRole()) && StringUtils.isNotBlank(impuser.getLoginName())) {
+					if (!numberRex.matcher(impuser.getLoginName()).find()) {
+						msg.append("  科组长登录名必须为手机号");
+					}
+
+				}
+
 				String coursecodes = trimAndNullIfBlank(line.getValue(3));
 				if (StringUtils.isNotBlank(coursecodes)) {
 					impuser.setCourse(Arrays.asList(coursecodes.split(",")));