xiatian 2 năm trước cách đây
mục cha
commit
e7c961d3f9

+ 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);