|
@@ -11,10 +11,7 @@ import com.dragoninfo.dcuc.auth.audit.enums.AuthResultEnum;
|
|
|
import com.dragoninfo.dcuc.auth.audit.service.log.LogInfoFillService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.async.StaffAssignAuthEventCenterBus;
|
|
|
import com.dragoninfo.dcuc.auth.auth.bpo.StaffAssignAuthInfoBPO;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.dto.AppDataSensitiveLevelDTO;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.dto.StaffAssignDTO;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.dto.StaffRoleOperateDTO;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.dto.UserRoleAuthInfoDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.*;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.OrgQuotaAuthInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.RoleInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.StaffAssignAuthInfo;
|
|
@@ -23,6 +20,7 @@ import com.dragoninfo.dcuc.auth.auth.service.IOrgQuotaAuthService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IRoleInfoService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IStaffAssignAuthInfoService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IStaffAssignAuthLogService;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.StaffRoleAuthApiVo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.entity.AuthOrgInfo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.entity.AuthUserInfo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.service.IAuthOrgInfoService;
|
|
@@ -40,6 +38,7 @@ import com.dragonsoft.duceap.core.context.ContextUtils;
|
|
|
import com.dragonsoft.duceap.core.persistent.factory.PersistentFactory;
|
|
|
import com.dragonsoft.duceap.core.search.Searchable;
|
|
|
import com.dragonsoft.duceap.core.search.enums.SearchOperator;
|
|
|
+import com.dragonsoft.duceap.core.search.filter.Condition;
|
|
|
import com.dragonsoft.duceap.web.utils.RequestUtils;
|
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
|
import org.hibernate.criterion.Projections;
|
|
@@ -48,13 +47,17 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import sun.security.krb5.internal.PAData;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
@@ -698,4 +701,102 @@ public class StaffAssignAuthInfoService implements IStaffAssignAuthInfoService {
|
|
|
return staffAssignAuthInfoBPO.getAllRoleIds(userId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<StaffRoleAuthApiVo> apiStaffRoleAuthResult(SearchDTO searchDTO) {
|
|
|
+ Searchable searchable = Searchable.toSearchable(searchDTO);
|
|
|
+ Pageable page = searchable.getPage();
|
|
|
+ String appId = searchable.getSearchFilter("appId", SearchOperator.eq).getValue().toString();
|
|
|
+ List<RoleInfo> roleInfos = roleInfoService.getRolesByAppId(appId);
|
|
|
+ Stream<RoleInfo> stream = roleInfos.stream();
|
|
|
+ Condition roleCodeEq = searchable.getSearchFilter("roleCode", SearchOperator.eq);
|
|
|
+ if(null != roleCodeEq) {
|
|
|
+ String roleCode = roleCodeEq.getValue().toString();
|
|
|
+ stream = stream.filter(e -> e.getCode().equals(roleCode));
|
|
|
+ }
|
|
|
+ Condition roleCodeIn = searchable.getSearchFilter("roleCode", SearchOperator.in);
|
|
|
+ if(null != roleCodeIn) {
|
|
|
+ String[] value = (String[]) roleCodeIn.getValue();
|
|
|
+ Set<String> set = Stream.of(value).collect(Collectors.toSet());
|
|
|
+ stream = stream.filter(e->set.contains(e.getCode()));
|
|
|
+ }
|
|
|
+ if(stream.count() == 0) {
|
|
|
+ return Page.empty();
|
|
|
+ }
|
|
|
+ Searchable pageSearch = Searchable.newSearchable();
|
|
|
+ pageSearch.setPage(page);
|
|
|
+ List<String> roleIds = stream.map(RoleInfo::getId).collect(Collectors.toList());
|
|
|
+ pageSearch.addSearchFilter("roleId", SearchOperator.in, roleIds);
|
|
|
+ Condition orgCodeEq = searchable.getSearchFilter("orgCode", SearchOperator.eq);
|
|
|
+ List<AuthOrgInfo> orgInfos = null;
|
|
|
+ if(null != orgCodeEq) {
|
|
|
+ String orgCode = orgCodeEq.getValue().toString();
|
|
|
+ AuthOrgInfo orgInfo = authOrgInfoService.getByOrgCode(orgCode);
|
|
|
+ if(null == orgInfo) {
|
|
|
+ return Page.empty();
|
|
|
+ }
|
|
|
+ orgInfos = new ArrayList<>();
|
|
|
+ orgInfos.add(orgInfo);
|
|
|
+ String orgId = orgInfo.getId();
|
|
|
+ pageSearch.addSearchFilter("staffOrgId", SearchOperator.eq, orgId);
|
|
|
+ }
|
|
|
+ List<AuthUserInfo> userInfos = null;
|
|
|
+ Condition userNameLike = searchable.getSearchFilter("userName", SearchOperator.like);
|
|
|
+ if(null != userNameLike) {
|
|
|
+ String userName = userNameLike.getValue().toString();
|
|
|
+ userInfos = authUserInfoService.findByNameLike(userName);
|
|
|
+ if(CollectionUtils.isEmpty(userInfos)) {
|
|
|
+ return Page.empty();
|
|
|
+ }
|
|
|
+ List<String> userIds = userInfos.stream().map(AuthUserInfo::getId).collect(Collectors.toList());
|
|
|
+ pageSearch.addSearchFilter("staffId", SearchOperator.in ,userIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageSearch.addSearchFilter("appId", SearchOperator.eq, appId);
|
|
|
+ Condition postStatusEq = searchable.getSearchFilter("postStatus", SearchOperator.eq);
|
|
|
+ if(null != postStatusEq) {
|
|
|
+ pageSearch.addSearchFilter("postStatus", SearchOperator.eq, postStatusEq.getValue());
|
|
|
+ }
|
|
|
+ Condition postStatusIn = searchable.getSearchFilter("postStatus", SearchOperator.in);
|
|
|
+ if(null != postStatusIn) {
|
|
|
+ pageSearch.addSearchFilter("postStatus", SearchOperator.in, postStatusIn.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<StaffRoleAuthApiDTO> dtoPage = staffAssignAuthInfoBPO.apiStaffRoleAuthResult(pageSearch);
|
|
|
+ if(null == userInfos) {
|
|
|
+ List<String> userIds = dtoPage.getContent().stream().map(StaffRoleAuthApiDTO::getStaffId).distinct().collect(Collectors.toList());
|
|
|
+ userInfos = authUserInfoService.findByIds(userIds);
|
|
|
+ }
|
|
|
+ if(null == orgInfos) {
|
|
|
+ List<String> orgIds = dtoPage.getContent().stream().map(StaffRoleAuthApiDTO::getStaffOrgId).distinct().collect(Collectors.toList());
|
|
|
+ orgInfos = authOrgInfoService.getByIds(orgIds);
|
|
|
+ }
|
|
|
+ Map<String, RoleInfo> roleInfoMap = stream.collect(Collectors.toMap(RoleInfo::getId, e -> e, (old, last) -> last));
|
|
|
+ Map<String, AuthUserInfo> userInfoMap = userInfos.stream().collect(Collectors.toMap(AuthUserInfo::getId, e -> e, (old, last) -> last));
|
|
|
+ Map<String, AuthOrgInfo> orgInfoMap = orgInfos.stream().collect(Collectors.toMap(AuthOrgInfo::getId, e -> e, (old, last) -> last));
|
|
|
+ List<StaffRoleAuthApiVo> vos = dtoPage.stream()
|
|
|
+ .map(e -> getStaffRoleAuthApiVo(roleInfoMap, userInfoMap, orgInfoMap, e))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return new PageImpl<>(vos,page, dtoPage.getTotalElements());
|
|
|
+ }
|
|
|
+
|
|
|
+ private StaffRoleAuthApiVo getStaffRoleAuthApiVo(Map<String, RoleInfo> roleInfoMap, Map<String, AuthUserInfo> userInfoMap, Map<String, AuthOrgInfo> orgInfoMap, StaffRoleAuthApiDTO e) {
|
|
|
+ StaffRoleAuthApiVo apiVo = new StaffRoleAuthApiVo();
|
|
|
+ String staffId = e.getStaffId();
|
|
|
+ String staffOrgId = e.getStaffOrgId();
|
|
|
+ String roleId = e.getRoleId();
|
|
|
+ AuthUserInfo userInfo = userInfoMap.get(staffId);
|
|
|
+ AuthOrgInfo authOrgInfo = orgInfoMap.get(staffOrgId);
|
|
|
+ RoleInfo roleInfo = roleInfoMap.get(roleId);
|
|
|
+ apiVo.setName(userInfo.getName());
|
|
|
+ apiVo.setIdcard(userInfo.getIdcard());
|
|
|
+ apiVo.setOrgName(authOrgInfo.getFullName());
|
|
|
+ apiVo.setUserType(userInfo.getUserType());
|
|
|
+ apiVo.setOrgCode(authOrgInfo.getCode());
|
|
|
+ apiVo.setPostStatus(e.getRelStatus());
|
|
|
+ apiVo.setPostName(e.getRelName());
|
|
|
+ apiVo.setRoleCode(roleInfo.getCode());
|
|
|
+ apiVo.setRoleName(roleInfo.getName());
|
|
|
+ return apiVo;
|
|
|
+ }
|
|
|
+
|
|
|
}
|