From 9e6d06469d712b5a28a75d59645fc5d3d3dfa235 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 24 十月 2023 08:46:01 +0800
Subject: [PATCH] 羚羊配置问卷
---
server/src/main/java/doumeemes/config/shiro/ShiroRealm.java | 138 ++++++++++++++++++++++++----------------------
1 files changed, 72 insertions(+), 66 deletions(-)
diff --git a/server/src/main/java/doumeemes/config/shiro/ShiroRealm.java b/server/src/main/java/doumeemes/config/shiro/ShiroRealm.java
index 6c0da35..d87601b 100644
--- a/server/src/main/java/doumeemes/config/shiro/ShiroRealm.java
+++ b/server/src/main/java/doumeemes/config/shiro/ShiroRealm.java
@@ -90,76 +90,82 @@
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// 鑾峰彇鐢ㄦ埛鍚�
ShiroToken authenticationToken =(ShiroToken) token;
- String username = authenticationToken.getPrincipal().toString();
- boolean isDdLogin = authenticationToken.getDdLogin();
- // 鏍规嵁鐢ㄦ埛鍚嶆煡璇㈢敤鎴峰璞�
- SystemUser queryDto = new SystemUser();
- queryDto.setUsername(username);
- queryDto.setDeleted(Boolean.FALSE);
- SystemUser user = systemUserService.findOne(queryDto);
- if (user == null) {
- return null;
- }
- SystemRole role = new SystemRole();
- SystemPermission per = new SystemPermission();
- DepartmentExtListVO rootDepart = null,comDepart=null, depart = null;
- List<Integer> dpList = null;
- CompanyExtListVO com = null;
- CompanyUserExtListVO cu =null;
- if(Constants.equalsInteger(user.getType(),Constants.PlatType.admin)){
- //濡傛灉鏄钩鍙扮敤鎴�
- role.setType(Constants.ROLETYPE.plat);
- per.setType(Constants.PlatType.admin);
+ if(authenticationToken .getUpdateFlag() == 1){
+ //濡傛灉鏄洿鏂皊ession
+ return new SimpleAuthenticationInfo(authenticationToken.getUpdateUser(), authenticationToken.getPassword(), this.getName());
}else{
- if(authenticationToken.getCompanyId() == null){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇ヨ处鎴峰垹闄わ紒");
+ String username = authenticationToken.getPrincipal().toString();
+ boolean isDdLogin = authenticationToken.getDdLogin();
+ // 鏍规嵁鐢ㄦ埛鍚嶆煡璇㈢敤鎴峰璞�
+ SystemUser queryDto = new SystemUser();
+ queryDto.setUsername(username);
+ queryDto.setDeleted(Boolean.FALSE);
+ SystemUser user = systemUserService.findOne(queryDto);
+ if (user == null) {
+ return null;
}
- com = companyExtService.getModelById(authenticationToken.getCompanyId());
- if(com == null || Constants.equalsInteger( com.getDeleted(),Constants.ONE)){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヨ处鎴峰垹闄わ紒璇疯仈绯荤鐞嗗憳");
- }
- if(Constants.equalsInteger( com.getStatus(),Constants.ZERO) ){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氬凡绂佺敤锛�");
- }
- if(com.getOepnValidDate() != null && com.getOepnValidDate().before(new Date())){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氬凡杩囦娇鐢ㄦ湁鏁堟湡锛�");
- }
- //濡傛灉鏄紒涓氱敤鎴�
- QueryCompanyUserExtDTO c =new QueryCompanyUserExtDTO();
- c.setUserId(user.getId());
- c.setDeleted(Constants.ZERO);
- c.setCompanyId(authenticationToken.getCompanyId());
- cu = companyUserExtService.selectOne(c);
- if(cu == null){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴蜂笉瀛樺湪锛�");
- }
- if(Constants.equalsInteger(cu.getStatus(),Constants.ONE)){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴峰凡绂佺敤锛�");
- }
- rootDepart = departmentExtService.getModelById(c.getCompanyId(),cu.getRootDepartId());
- comDepart = departmentExtService.getModelById(c.getCompanyId(),cu.getComDepartId());
- depart = departmentExtService.getModelById(c.getCompanyId(),cu.getDepartmentId());
- if(rootDepart == null || comDepart == null || depart==null){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴疯处鎴峰紓甯革紒");
- }
- role.setCompanyId(authenticationToken.getCompanyId());
- role.setType(Constants.ROLETYPE.com);
- per.setType(Constants.PlatType.company);
- per.setRoleType(Constants.ROLETYPE.com);
- per.setCompanyId(authenticationToken.getCompanyId());
- SystemRole rt = new SystemRole();
- rt.setType(Constants.ROLETYPE.com);
- rt.setCompanyId(c.getCompanyId());
- //鏁版嵁閮ㄩ棬鏉冮檺闆嗗悎
- dpList =systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user,depart);
+ SystemRole role = new SystemRole();
+ SystemPermission per = new SystemPermission();
+ DepartmentExtListVO rootDepart = null,comDepart=null, depart = null;
+ List<Integer> dpList = null;
+ CompanyExtListVO com = null;
+ CompanyUserExtListVO cu =null;
+ if(Constants.equalsInteger(user.getType(),Constants.PlatType.admin)){
+ //濡傛灉鏄钩鍙扮敤鎴�
+ role.setType(Constants.ROLETYPE.plat);
+ per.setType(Constants.PlatType.admin);
+ }else{
+ if(authenticationToken.getCompanyId() == null){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇ヨ处鎴峰垹闄わ紒");
+ }
+ com = companyExtService.getModelById(authenticationToken.getCompanyId());
+ if(com == null || Constants.equalsInteger( com.getDeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヨ处鎴峰垹闄わ紒璇疯仈绯荤鐞嗗憳");
+ }
+ if(Constants.equalsInteger( com.getStatus(),Constants.ZERO) ){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氬凡绂佺敤锛�");
+ }
+ if(com.getOepnValidDate() != null && com.getOepnValidDate().before(new Date())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氬凡杩囦娇鐢ㄦ湁鏁堟湡锛�");
+ }
+ //濡傛灉鏄紒涓氱敤鎴�
+ QueryCompanyUserExtDTO c =new QueryCompanyUserExtDTO();
+ c.setUserId(user.getId());
+ c.setDeleted(Constants.ZERO);
+ c.setCompanyId(authenticationToken.getCompanyId());
+ cu = companyUserExtService.selectOne(c);
+ if(cu == null){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴蜂笉瀛樺湪锛�");
+ }
+ if(Constants.equalsInteger(cu.getStatus(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴峰凡绂佺敤锛�");
+ }
+ rootDepart = departmentExtService.getModelById(c.getCompanyId(),cu.getRootDepartId());
+ comDepart = departmentExtService.getModelById(c.getCompanyId(),cu.getComDepartId());
+ depart = departmentExtService.getModelById(c.getCompanyId(),cu.getDepartmentId());
+ if(rootDepart == null || comDepart == null || depart==null){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱敤鎴疯处鎴峰紓甯革紒");
+ }
+ role.setCompanyId(authenticationToken.getCompanyId());
+ role.setType(Constants.ROLETYPE.com);
+ per.setType(Constants.PlatType.company);
+ per.setRoleType(Constants.ROLETYPE.com);
+ per.setCompanyId(authenticationToken.getCompanyId());
+ SystemRole rt = new SystemRole();
+ rt.setType(Constants.ROLETYPE.com);
+ rt.setCompanyId(c.getCompanyId());
+ //鏁版嵁閮ㄩ棬鏉冮檺闆嗗悎
+ dpList =systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user,depart);
+ }
+ // 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
+ List<SystemRole> roles = systemRoleService.findByUserModel(user.getId(),role);
+ List<SystemPermission> permissions = systemPermissionService.findByUserModel(user.getId(),per);
+ LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,com,rootDepart,comDepart,depart,dpList,cu);
+ // 楠岃瘉鐢ㄦ埛
+ return new SimpleAuthenticationInfo(userInfo, user.getPassword(), this.getName());
}
- // 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
- List<SystemRole> roles = systemRoleService.findByUserModel(user.getId(),role);
- List<SystemPermission> permissions = systemPermissionService.findByUserModel(user.getId(),per);
- LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,com,rootDepart,comDepart,depart,dpList,cu);
- // 楠岃瘉鐢ㄦ埛
- return new SimpleAuthenticationInfo(userInfo, user.getPassword(), this.getName());
+
}
}
--
Gitblit v1.9.3