保存业务线

This commit is contained in:
钱涛 2024-09-02 10:22:42 +08:00
parent 9d4362b46e
commit fdb1f76e01
8 changed files with 70 additions and 29 deletions

View File

@ -0,0 +1,17 @@
package com.engine.salary.entity.auth.param;
import com.engine.salary.common.BaseQueryParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AuthRoleListQueryParam extends BaseQueryParam {
private String name;
}

View File

@ -233,7 +233,7 @@
<delete id="deleteByRoleId">
UPDATE hrsa_auth_limit
UPDATE hrsa_auth_resource
SET delete_type = 1
WHERE delete_type = 0
AND role_id=#{roleId}

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.auth;
import com.engine.salary.entity.auth.dto.AuthRoleDataDTO;
import com.engine.salary.entity.auth.param.AuthDataSaveParam;
import com.engine.salary.entity.auth.param.AuthSyncParam;
import com.engine.salary.entity.auth.po.AuthDataPO;
@ -44,5 +45,5 @@ public interface AuthDataService {
void deleteByRoleId(Long roleId);
void listRoleData(Long roleId);
List<AuthRoleDataDTO> listRoleData(Long roleId);
}

View File

@ -3,6 +3,7 @@ package com.engine.salary.service.auth;
import cn.hutool.core.collection.CollectionUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.auth.dto.AuthRoleDataDTO;
import com.engine.salary.entity.auth.param.AuthDataSaveParam;
import com.engine.salary.entity.auth.param.AuthSyncParam;
import com.engine.salary.entity.auth.po.AuthDataPO;
@ -150,7 +151,7 @@ public class AuthDataServiceImpl extends Service implements AuthDataService {
}
@Override
public void listRoleData(Long roleId) {
getAuthRoleDataMapper().listRoleData(roleId);
public List<AuthRoleDataDTO> listRoleData(Long roleId) {
return getAuthRoleDataMapper().listRoleData(roleId);
}
}

View File

@ -1,7 +1,8 @@
package com.engine.salary.service.auth;
import com.engine.salary.entity.auth.dto.AuthRoleDTO;
import com.engine.salary.entity.auth.param.AuthRoleListQueryParam;
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
import com.engine.salary.entity.auth.po.AuthRolePO;
import com.engine.salary.util.page.PageInfo;
import java.util.List;
@ -16,7 +17,7 @@ import java.util.List;
**/
public interface AuthRoleService {
PageInfo<AuthRolePO> roleList();
PageInfo<AuthRoleDTO> roleList(AuthRoleListQueryParam param);
/**
* 添加角色

View File

@ -5,7 +5,11 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.auth.dto.AuthRoleDTO;
import com.engine.salary.entity.auth.dto.AuthRoleDataDTO;
import com.engine.salary.entity.auth.dto.AuthRoleEmpDTO;
import com.engine.salary.entity.auth.param.AuthRoleListQueryParam;
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
import com.engine.salary.entity.auth.po.AuthOptPO;
import com.engine.salary.entity.auth.po.AuthResourcePO;
import com.engine.salary.entity.auth.po.AuthRolePO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
@ -17,11 +21,13 @@ import com.engine.salary.mapper.auth.AuthRoleMapper;
import com.engine.salary.util.db.IdGenerator;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import weaver.hrm.User;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@ -47,29 +53,29 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@Override
public PageInfo<AuthRolePO> roleList() {
public PageInfo<AuthRoleDTO> roleList(AuthRoleListQueryParam param) {
List<AuthRolePO> authRolePOS = getAuthRoleMapper().listSome(AuthRolePO.builder().build());
int total = authRolePOS.size();
authRolePOS.forEach(po->{
Long roleId = po.getId();
getAuthMemberService(user).listRoleEmp(roleId);
List<AuthRoleDTO> collect = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authRolePOS)
.stream().map(po -> {
Long roleId = po.getId();
List<AuthRoleEmpDTO> authRoleEmpDTOS = getAuthMemberService(user).listRoleEmp(roleId);
List<AuthOptPO> authOptPOS = getAuthOptService(user).listOpts(roleId);
List<AuthRoleDataDTO> authRoleDataDTOS = getAuthDataService(user).listRoleData(roleId);
getAuthOptService(user).listOpts(roleId);
return AuthRoleDTO.builder().id(roleId)
.name(po.getName())
.members(authRoleEmpDTOS.size())
.opts(authOptPOS.size())
.datas(authRoleDataDTOS.size())
.resources(0)
.build();
getAuthDataService(user).listRoleData(roleId);
AuthRoleDTO.builder().id(roleId)
.name(po.getName())
.members(0)
.datas(0)
.resources(0)
.opts(0)
.build();
});
return ;
}).collect(Collectors.toList());
PageInfo<AuthRoleDTO> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), collect, AuthRoleDTO.class);
pageInfo.setTotal(total);
return pageInfo;
}
@Override
@ -132,8 +138,8 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
List<TaxAgentPO> taxAgents = param.getTaxAgentIds();
List<SalarySobPO> sobs = param.getSobIds();
if(CollectionUtil.isNotEmpty(taxAgents)){
taxAgents.forEach(tax-> {
if (CollectionUtil.isNotEmpty(taxAgents)) {
taxAgents.forEach(tax -> {
AuthResourcePO resourcePO = AuthResourcePO.builder()
.id(IdGenerator.generate())
.roleId(po.getId())
@ -149,8 +155,8 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
getAuthResourceMapper().insertIgnoreNull(resourcePO);
});
}
if(CollectionUtil.isNotEmpty(sobs)){
sobs.forEach(sob-> {
if (CollectionUtil.isNotEmpty(sobs)) {
sobs.forEach(sob -> {
AuthResourcePO resourcePO = AuthResourcePO.builder()
.id(IdGenerator.generate())
.roleId(po.getId())

View File

@ -4,6 +4,7 @@ import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.auth.dto.AuthDataDTO;
import com.engine.salary.entity.auth.dto.AuthMemberDTO;
import com.engine.salary.entity.auth.dto.AuthOptDTO;
import com.engine.salary.entity.auth.dto.AuthRoleDTO;
import com.engine.salary.entity.auth.param.*;
import com.engine.salary.entity.auth.vo.Permission;
import com.engine.salary.util.ResponseResult;
@ -36,6 +37,14 @@ public class AuthController {
return ServiceUtil.getService(AuthWrapper.class, user);
}
@POST
@Path("/role/list")
@Produces(MediaType.APPLICATION_JSON)
public String roleList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthRoleListQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<AuthRoleListQueryParam, PageInfo<AuthRoleDTO>>(user).run(getAuthWrapper(user)::roleList, param);
}
@POST
@Path("/role/save")
@Produces(MediaType.APPLICATION_JSON)

View File

@ -5,6 +5,7 @@ import com.engine.core.impl.Service;
import com.engine.salary.entity.auth.dto.AuthDataDTO;
import com.engine.salary.entity.auth.dto.AuthMemberDTO;
import com.engine.salary.entity.auth.dto.AuthOptDTO;
import com.engine.salary.entity.auth.dto.AuthRoleDTO;
import com.engine.salary.entity.auth.param.*;
import com.engine.salary.entity.auth.po.AuthDataPO;
import com.engine.salary.entity.auth.po.AuthMemberPO;
@ -47,6 +48,11 @@ public class AuthWrapper extends Service {
return ServiceUtil.getService(AuthDataServiceImpl.class, user);
}
public PageInfo<AuthRoleDTO> roleList(AuthRoleListQueryParam param) {
ValidUtil.doValidator(param);
return getAuthRoleService(user).roleList(param);
}
public Long saveRole(AuthRoleSaveParam param) {
ValidUtil.doValidator(param);
return getAuthRoleService(user).saveRole(param);