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-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-07-29 13:28:46 +08:00
|
|
|
import com.engine.salary.entity.auth.param.AuthMemberQueryParam;
|
2024-07-26 11:35:17 +08:00
|
|
|
import com.engine.salary.entity.auth.param.AuthMemberSaveParam;
|
2024-07-29 16:00:27 +08:00
|
|
|
import com.engine.salary.entity.auth.param.AuthOptSaveParam;
|
2024-07-26 11:35:17 +08:00
|
|
|
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
|
2024-07-29 13:28:46 +08:00
|
|
|
import com.engine.salary.entity.auth.po.AuthMemberPO;
|
|
|
|
|
import com.engine.salary.enums.auth.TargetTypeEnum;
|
2024-07-29 16:00:27 +08:00
|
|
|
import com.engine.salary.service.auth.*;
|
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 {
|
|
|
|
|
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-26 11:35:17 +08:00
|
|
|
public Long saveRole(AuthRoleSaveParam param) {
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
return getAuthRoleService(user).saveRole(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteRole(Long id) {
|
|
|
|
|
getAuthRoleService(user).deleteRole(id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 13:28:46 +08:00
|
|
|
public PageInfo<AuthMemberDTO> memberList(AuthMemberQueryParam param) {
|
|
|
|
|
List<AuthMemberPO> authMemberPOS = getAuthMemberService(user).memberList(param.getRoleId());
|
|
|
|
|
List<AuthMemberDTO> dtos = authMemberPOS.stream().map(po -> AuthMemberDTO.builder()
|
|
|
|
|
.id(po.getId())
|
|
|
|
|
.targetType(TargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
|
|
|
|
.targetName(po.getTargetName())
|
|
|
|
|
.build())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), dtos, AuthMemberDTO.class);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-26 11:35:17 +08:00
|
|
|
public Long saveMember(AuthMemberSaveParam param) {
|
|
|
|
|
ValidUtil.doValidator(param);
|
|
|
|
|
return getAuthMemberService(user).saveMember(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteMember(Long id) {
|
|
|
|
|
getAuthMemberService(user).deleteMember(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void syncMember(Long roleId) {
|
|
|
|
|
getAuthMemberService(user).syncMember(roleId);
|
|
|
|
|
}
|
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-26 11:35:17 +08:00
|
|
|
}
|