业务线权限接口

This commit is contained in:
钱涛 2024-09-10 13:37:21 +08:00
parent a0fb036bce
commit 3614f89982
4 changed files with 43 additions and 17 deletions

View File

@ -12,9 +12,29 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class Permission {
/**
* 是否开启了分权
*/
private boolean isOpenDevolution;
/**
* 是否总管理员
*/
private boolean isChief;
/**
* 是否扣缴义务人管理员
*/
private boolean isAdminEnable;
/**
* 当前页面是否有权限
*/
private boolean able;
/**
* 权限项
*/
private List<String> opts;
}

View File

@ -65,7 +65,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
throw new SalaryRunTimeException("角色不存在!");
}
if(param.getId() == null){
if (param.getId() == null) {
AuthDataPO dataPO = AuthDataPO.builder()
.id(IdGenerator.generate())
.roleId(param.getRoleId())
@ -73,7 +73,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
.targetType(param.getTargetType().getValue())
.target(param.getTarget())
.targetName(param.getTargetName())
.sortedIndex(param.getSortedIndex())
.sortedIndex(param.getSortedIndex() == null ? 0 : param.getSortedIndex())
.creator((long) user.getUID())
.createTime(now)
.updateTime(now)
@ -81,7 +81,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build();
getAuthDataMapper().insertIgnoreNull(dataPO);
}else{
} else {
getAuthDataMapper().getById(param.getId());
AuthDataPO dataPO = AuthDataPO.builder()
.id(param.getId())
@ -89,7 +89,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
.targetType(param.getTargetType().getValue())
.target(param.getTarget())
.targetName(param.getTargetName())
.sortedIndex(param.getSortedIndex())
.sortedIndex(param.getSortedIndex() == null ? 0 : param.getSortedIndex())
.creator((long) user.getUID())
.updateTime(now)
.deleteType(0)
@ -101,7 +101,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
@Override
public void delete(List<Long> ids) {
if(CollectionUtil.isNotEmpty(ids)){
if (CollectionUtil.isNotEmpty(ids)) {
getAuthDataMapper().deleteByIds(ids);
}
}
@ -152,6 +152,6 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
@Override
public List<AuthRoleDataDTO> listRoleData(Long roleId) {
return getAuthRoleDataMapper().listRoleData(roleId);
return getAuthRoleDataMapper().listRoleData(roleId);
}
}

View File

@ -38,8 +38,8 @@ public class AuthOptServiceImpl extends Service implements AuthOptService {
Map<String, Set<String>> pageOpts = SalaryEntityUtil.group2Map(authOptPOS, AuthOptPO::getPage, AuthOptPO::getOpt);
XStream xStream = new XStream();
String resource = GCONST.getRootPath() + "WEB-INF" + File.separatorChar + "salaryoptconfig.xml";
File file = new File("H:\\code\\salary\\resource\\WEB-INF\\salaryoptconfig.xml");
// File file = new File(resource);
// File file = new File("H:\\code\\salary\\resource\\WEB-INF\\salaryoptconfig.xml");
File file = new File(resource);
xStream.addPermission(AnyTypePermission.ANY);
xStream.processAnnotations(AuthOptDTO.class);

View File

@ -277,27 +277,33 @@ public class AuthServiceImpl extends Service implements AuthService {
@Override
public Permission permission(String page) {
long uid = user.getUID();
boolean able = false;
List<String> opts = new ArrayList<>();
//获取是否开启分权模式
Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
//给总管理员赋值最大权限
Boolean isChief = getTaxAgentService(user).isChief(uid);
//给各管理员赋值对应的扣缴义务人权限
Boolean adminEnable = getTaxAgentService(user).isAdminEnable(uid);
boolean able = false;
//如果是管理员赋值管理权限返回
if (isChief || adminEnable) {
opts.add("admin");
return Permission.builder().able(true).opts(opts).build();
}
opts = getAuthMapper().getOptsByPage(uid, page);
if (CollectionUtil.isNotEmpty(opts)) {
able = true;
} else {
opts = getAuthMapper().getOptsByPage(uid, page);
able = CollectionUtil.isNotEmpty(opts);
}
return Permission.builder().able(able).opts(opts).build();
return Permission.builder()
.isOpenDevolution(isOpenDevolution)
.isChief(isChief)
.isAdminEnable(adminEnable)
.able(able)
.opts(opts)
.build();
}
}