|
@@ -19,7 +19,6 @@ import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
import com.qmth.themis.business.enums.MqTopicEnum;
|
|
|
import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
-import com.qmth.themis.business.util.EhcacheUtil;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import com.qmth.themis.business.util.ServletUtil;
|
|
|
import com.qmth.themis.business.util.SessionUtil;
|
|
@@ -99,31 +98,45 @@ public class TBUserController {
|
|
|
String loginName = String.valueOf(mapParameter.get("loginName"));
|
|
|
String password = String.valueOf(mapParameter.get("password"));
|
|
|
String orgCode = String.valueOf(mapParameter.get("code"));
|
|
|
- TBOrg tbOrg = (TBOrg) EhcacheUtil.get(SystemConstant.orgCodeCache, orgCode);
|
|
|
- if (Objects.isNull(tbOrg)) {
|
|
|
- QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
|
|
|
- tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, orgCode);
|
|
|
- tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
|
|
|
- if (Objects.nonNull(tbOrg)) {
|
|
|
- EhcacheUtil.put(SystemConstant.orgCodeCache, orgCode, tbOrg);
|
|
|
+ TBOrg tbOrg = null;
|
|
|
+ if (!Objects.equals(orgCode.toUpperCase(), SystemConstant.ADMIN)) {
|
|
|
+ tbOrg = (TBOrg) redisUtil.getOrgCode(orgCode);
|
|
|
+ if (Objects.isNull(tbOrg)) {
|
|
|
+ QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
|
|
|
+ tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, orgCode);
|
|
|
+ tbOrg = tbOrgService.getOne(tbOrgQueryWrapper);
|
|
|
+ if (Objects.nonNull(tbOrg)) {
|
|
|
+ redisUtil.setOrgCode(orgCode, tbOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.isNull(tbOrg)) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.ORG_NO);
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(tbOrg.getEnable()) && tbOrg.getEnable().intValue() == 0) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.ORG_ENABLE);
|
|
|
}
|
|
|
- }
|
|
|
- if (Objects.isNull(tbOrg)) {
|
|
|
- throw new BusinessException(ExceptionResultEnum.ORG_NO);
|
|
|
- }
|
|
|
- if (Objects.nonNull(tbOrg.getEnable()) && tbOrg.getEnable().intValue() == 0) {
|
|
|
- throw new BusinessException(ExceptionResultEnum.ORG_ENABLE);
|
|
|
}
|
|
|
QueryWrapper<TBUser> wrapper = new QueryWrapper<>();
|
|
|
wrapper.lambda().eq(TBUser::getLoginName, loginName);
|
|
|
- if (!loginName.contains(SystemConstant.SYSTEM_ACCOUNT)) {
|
|
|
+ if (!Objects.equals(orgCode.toUpperCase(), SystemConstant.ADMIN)) {
|
|
|
wrapper.lambda().eq(TBUser::getOrgId, tbOrg.getId());
|
|
|
}
|
|
|
- TBUser user = tbUserService.getOne(wrapper);
|
|
|
+ List<TBUser> userList = tbUserService.list(wrapper);
|
|
|
//用户不存在
|
|
|
- if (Objects.isNull(user)) {
|
|
|
+ if (Objects.isNull(userList) || userList.size() == 0) {
|
|
|
throw new BusinessException(ExceptionResultEnum.USER_NO);
|
|
|
}
|
|
|
+ if (Objects.equals(orgCode.toUpperCase(), SystemConstant.ADMIN)) {
|
|
|
+ userList.forEach(s -> {
|
|
|
+ if (!Objects.equals(s.getRemark(), SystemConstant.SYSADMIN)) {
|
|
|
+ throw new BusinessException("机构code为admin只允许超级管理员登录");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (userList.size() > 1) {
|
|
|
+ throw new BusinessException("查询的用户有多条");
|
|
|
+ }
|
|
|
+ TBUser user = userList.get(0);
|
|
|
if (Objects.nonNull(user.getOrgId()) && user.getOrgId().longValue() != tbOrg.getId().longValue()) {
|
|
|
throw new BusinessException("用户机构不匹配");
|
|
|
}
|