2024-07-26 11:35:17 +08:00
|
|
|
package com.engine.salary.wrapper;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.core.impl.Service;
|
2024-07-30 17:45:02 +08:00
|
|
|
import com.engine.salary.entity.auth.dto.AuthDataDTO;
|
2024-07-29 13:28:46 +08:00
|
|
|
import com.engine.salary.entity.auth.dto.AuthMemberDTO;
|
2024-07-29 16:00:27 +08:00
|
|
|
import com.engine.salary.entity.auth.dto.AuthOptDTO;
|
2024-09-02 10:22:42 +08:00
|
|
|
import com.engine.salary.entity.auth.dto.AuthRoleDTO;
|
2024-07-30 17:45:02 +08:00
|
|
|
import com.engine.salary.entity.auth.param.*;
|
|
|
|
|
import com.engine.salary.entity.auth.po.AuthDataPO;
|
2024-07-29 13:28:46 +08:00
|
|
|
import com.engine.salary.entity.auth.po.AuthMemberPO;
|
2024-08-30 10:49:46 +08:00
|
|
|
import com.engine.salary.entity.auth.vo.Permission;
|
2024-08-22 15:37:50 +08:00
|
|
|
import com.engine.salary.enums.auth.DataLinkEnum;
|
2024-07-30 17:45:02 +08:00
|
|
|
import com.engine.salary.enums.auth.DataTargetTypeEnum;
|
|
|
|
|
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
2024-08-01 10:56:29 +08:00
|
|
|
import com.engine.salary.mapper.auth.AuthMapper;
|
2024-07-29 16:00:27 +08:00
|
|
|
import com.engine.salary.service.auth.*;
|
2024-08-01 10:56:29 +08:00
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2024-07-29 13:28:46 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2024-07-26 11:35:17 +08:00
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
2024-07-29 13:28:46 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
2024-07-26 11:35:17 +08:00
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class AuthWrapper extends Service {
|
2024-08-30 10:49:46 +08:00
|
|
|
|
|
|
|
|
public AuthService getAuthService(User user) {
|
|
|
|
|
return ServiceUtil.getService(AuthServiceImpl.class, user);
|
|
|
|
|
}
|
2024-07-26 11:35:17 +08:00
|
|
|
private AuthRoleService getAuthRoleService(User user) {
|
|
|
|
|
return ServiceUtil.getService(AuthRoleServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AuthMemberService getAuthMemberService(User user) {
|
|
|
|
|
return ServiceUtil.getService(AuthMemberServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 16:00:27 +08:00
|
|
|
private AuthOptService getAuthOptService(User user) {
|
|
|
|
|
return ServiceUtil.getService(AuthOptServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-30 17:45:02 +08:00
|
|
|
private AuthDataService getAuthDataService(User user) {
|
|
|
|
|
return ServiceUtil.getService(AuthDataServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-02 10:22:42 +08:00
|
|
|
public PageInfo<AuthRoleDTO> roleList(AuthRoleListQueryParam param) {
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
return getAuthRoleService(user).roleList(param);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-09 19:10:40 +08:00
|
|
|
public AuthRoleDTO getRole(Long id) {
|
|
|
|
|
return getAuthRoleService(user).getRole(id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-26 11:35:17 +08:00
|
|
|
public Long saveRole(AuthRoleSaveParam param) {
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
return getAuthRoleService(user).saveRole(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-06 10:46:33 +08:00
|
|
|
public void deleteRole(List<Long> ids) {
|
|
|
|
|
getAuthRoleService(user).deleteRole(ids);
|
2024-07-26 11:35:17 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-29 13:28:46 +08:00
|
|
|
public PageInfo<AuthMemberDTO> memberList(AuthMemberQueryParam param) {
|
2024-07-30 17:45:02 +08:00
|
|
|
List<AuthMemberPO> authMemberPOS = getAuthMemberService(user).list(param.getRoleId());
|
|
|
|
|
int total = authMemberPOS.size();
|
|
|
|
|
authMemberPOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authMemberPOS);
|
|
|
|
|
List<AuthMemberDTO> dtos = authMemberPOS.stream()
|
|
|
|
|
.map(po -> AuthMemberDTO.builder()
|
|
|
|
|
.id(po.getId())
|
|
|
|
|
.targetTypeName(MemberTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
|
|
|
|
.targetType(MemberTargetTypeEnum.parseByValue(po.getTargetType()))
|
|
|
|
|
.targetName(po.getTargetName())
|
|
|
|
|
.target(po.getTarget())
|
|
|
|
|
.build())
|
2024-07-29 13:28:46 +08:00
|
|
|
.collect(Collectors.toList());
|
2024-08-22 15:37:50 +08:00
|
|
|
PageInfo<AuthMemberDTO> authMemberDTOPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthMemberDTO.class);
|
|
|
|
|
authMemberDTOPageInfo.setList(dtos);
|
2024-07-30 17:45:02 +08:00
|
|
|
authMemberDTOPageInfo.setTotal(total);
|
|
|
|
|
return authMemberDTOPageInfo;
|
2024-07-29 13:28:46 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-08 10:01:41 +08:00
|
|
|
public void saveMember(List<AuthMemberSaveParam> param) {
|
2024-08-19 11:33:15 +08:00
|
|
|
|
|
|
|
|
param.forEach(ValidUtil::modify);
|
|
|
|
|
|
2024-08-08 10:01:41 +08:00
|
|
|
getAuthMemberService(user).save(param);
|
2024-07-26 11:35:17 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 10:46:33 +08:00
|
|
|
public void deleteMember(List<Long> ids) {
|
|
|
|
|
getAuthMemberService(user).delete(ids);
|
2024-07-26 11:35:17 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-06 10:46:33 +08:00
|
|
|
public void syncMember(AuthSyncParam param) {
|
|
|
|
|
getAuthMemberService(user).sync(param);
|
2024-07-26 11:35:17 +08:00
|
|
|
}
|
2024-07-29 13:28:46 +08:00
|
|
|
|
2024-07-29 16:00:27 +08:00
|
|
|
public AuthOptDTO optTree(Long roleId) {
|
|
|
|
|
return getAuthOptService(user).optTree(roleId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveOpt(AuthOptSaveParam opt) {
|
|
|
|
|
getAuthOptService(user).save(opt);
|
|
|
|
|
}
|
2024-07-30 17:45:02 +08:00
|
|
|
|
|
|
|
|
public PageInfo<AuthDataDTO> dataList(AuthDataQueryParam param) {
|
|
|
|
|
List<AuthDataPO> list = getAuthDataService(user).list(param.getRoleId());
|
|
|
|
|
int total = list.size();
|
|
|
|
|
list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), list);
|
|
|
|
|
List<AuthDataDTO> dtos = list.stream().map(po -> AuthDataDTO.builder()
|
|
|
|
|
.id(po.getId())
|
2024-08-22 15:37:50 +08:00
|
|
|
.link(DataLinkEnum.parseByValue(po.getLink()))
|
|
|
|
|
.linkName(DataLinkEnum.parseByValue(po.getLink()).getDefaultLabel())
|
2024-07-30 17:45:02 +08:00
|
|
|
.targetTypeName(DataTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
|
|
|
|
.targetType(DataTargetTypeEnum.parseByValue(po.getTargetType()))
|
|
|
|
|
.targetName(po.getTargetName())
|
|
|
|
|
.target(po.getTarget())
|
2024-08-22 15:37:50 +08:00
|
|
|
.sortedIndex(po.getSortedIndex())
|
2024-07-30 17:45:02 +08:00
|
|
|
.build())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
2024-08-22 15:37:50 +08:00
|
|
|
PageInfo<AuthDataDTO> page = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthDataDTO.class);
|
|
|
|
|
page.setList(dtos);
|
2024-07-30 17:45:02 +08:00
|
|
|
page.setTotal(total);
|
|
|
|
|
return page;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 10:01:41 +08:00
|
|
|
public void saveData(List<AuthDataSaveParam> params) {
|
2024-08-22 15:37:50 +08:00
|
|
|
params.forEach(ValidUtil::modify);
|
|
|
|
|
|
2024-08-08 10:01:41 +08:00
|
|
|
getAuthDataService(user).save(params);
|
2024-07-30 17:45:02 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-19 15:29:45 +08:00
|
|
|
public void deleteData(List<Long> ids) {
|
|
|
|
|
getAuthDataService(user).delete(ids);
|
|
|
|
|
}
|
2024-07-30 17:45:02 +08:00
|
|
|
|
2024-08-06 10:46:33 +08:00
|
|
|
public void syncData(AuthSyncParam param) {
|
|
|
|
|
getAuthDataService(user).sync(param);
|
2024-07-30 17:45:02 +08:00
|
|
|
}
|
2024-08-01 10:56:29 +08:00
|
|
|
|
|
|
|
|
private AuthMapper getAuthMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(AuthMapper.class);
|
|
|
|
|
}
|
2024-08-01 16:19:23 +08:00
|
|
|
|
|
|
|
|
public Object auth(String page) {
|
2024-09-05 17:31:01 +08:00
|
|
|
return getAuthMapper().getTaxEmpOptAuth((long) user.getUID(), page);
|
2024-08-01 10:56:29 +08:00
|
|
|
}
|
2024-08-30 10:49:46 +08:00
|
|
|
|
|
|
|
|
public Permission permission(String page) {
|
|
|
|
|
return getAuthService(user).permission(page);
|
|
|
|
|
}
|
2024-07-26 11:35:17 +08:00
|
|
|
}
|