diff --git a/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java b/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java new file mode 100644 index 000000000..638e2cdd2 --- /dev/null +++ b/src/com/engine/salary/entity/auth/param/AuthRoleListQueryParam.java @@ -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; + +} \ No newline at end of file diff --git a/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml b/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml index a6fdafbd5..ed6c47fa9 100644 --- a/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml +++ b/src/com/engine/salary/mapper/auth/AuthResourceMapper.xml @@ -233,7 +233,7 @@ - UPDATE hrsa_auth_limit + UPDATE hrsa_auth_resource SET delete_type = 1 WHERE delete_type = 0 AND role_id=#{roleId} diff --git a/src/com/engine/salary/service/auth/AuthDataService.java b/src/com/engine/salary/service/auth/AuthDataService.java index 85f92916b..4f9da2efd 100644 --- a/src/com/engine/salary/service/auth/AuthDataService.java +++ b/src/com/engine/salary/service/auth/AuthDataService.java @@ -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 listRoleData(Long roleId); } diff --git a/src/com/engine/salary/service/auth/AuthDataServiceImpl.java b/src/com/engine/salary/service/auth/AuthDataServiceImpl.java index ff199b885..d48303e62 100644 --- a/src/com/engine/salary/service/auth/AuthDataServiceImpl.java +++ b/src/com/engine/salary/service/auth/AuthDataServiceImpl.java @@ -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 listRoleData(Long roleId) { + return getAuthRoleDataMapper().listRoleData(roleId); } } diff --git a/src/com/engine/salary/service/auth/AuthRoleService.java b/src/com/engine/salary/service/auth/AuthRoleService.java index 93177a63e..98a43b0fa 100644 --- a/src/com/engine/salary/service/auth/AuthRoleService.java +++ b/src/com/engine/salary/service/auth/AuthRoleService.java @@ -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 roleList(); + PageInfo roleList(AuthRoleListQueryParam param); /** * 添加角色 diff --git a/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java index 962eeb8ec..ebe6bf81f 100644 --- a/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java +++ b/src/com/engine/salary/service/auth/AuthRoleServiceImpl.java @@ -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 roleList() { + public PageInfo roleList(AuthRoleListQueryParam param) { List authRolePOS = getAuthRoleMapper().listSome(AuthRolePO.builder().build()); + int total = authRolePOS.size(); - authRolePOS.forEach(po->{ - Long roleId = po.getId(); - getAuthMemberService(user).listRoleEmp(roleId); + List collect = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authRolePOS) + .stream().map(po -> { + Long roleId = po.getId(); + List authRoleEmpDTOS = getAuthMemberService(user).listRoleEmp(roleId); + List authOptPOS = getAuthOptService(user).listOpts(roleId); + List 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 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 taxAgents = param.getTaxAgentIds(); List 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()) diff --git a/src/com/engine/salary/web/AuthController.java b/src/com/engine/salary/web/AuthController.java index 83dc41666..0c95482e7 100644 --- a/src/com/engine/salary/web/AuthController.java +++ b/src/com/engine/salary/web/AuthController.java @@ -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>(user).run(getAuthWrapper(user)::roleList, param); + } + @POST @Path("/role/save") @Produces(MediaType.APPLICATION_JSON) diff --git a/src/com/engine/salary/wrapper/AuthWrapper.java b/src/com/engine/salary/wrapper/AuthWrapper.java index bad7efcd7..d75e86efb 100644 --- a/src/com/engine/salary/wrapper/AuthWrapper.java +++ b/src/com/engine/salary/wrapper/AuthWrapper.java @@ -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 roleList(AuthRoleListQueryParam param) { + ValidUtil.doValidator(param); + return getAuthRoleService(user).roleList(param); + } + public Long saveRole(AuthRoleSaveParam param) { ValidUtil.doValidator(param); return getAuthRoleService(user).saveRole(param);