diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java index ac116b4a4f..02ffc22867 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java @@ -7,12 +7,28 @@ import javax.validation.constraints.NotBlank; @Data public class StaffRoleFormDTO { - @NotBlank(message = "工作人员ID不能为空") + /**===========校验分组开始============*/ + + // 查询工作人员角色列表group + public interface GetRolesOfStaff {} + + // 查询某角色下的人员列表group + public interface GetStaffsInRole {} + + /**===========校验分组结束============*/ + + @NotBlank(message = "工作人员ID不能为空", groups = {GetRolesOfStaff.class}) private String staffId; /** - * 机构id,可以是agencyId,DeptId,GridId + * 组织id,可以是agencyId,DeptId,GridId */ - @NotBlank(message = "工作人员所属组织ID不能为空") + @NotBlank(message = "工作人员所属组织ID不能为空", groups = {GetRolesOfStaff.class, GetStaffsInRole.class}) private String orgId; + + /** + * 角色key + */ + @NotBlank(message = "角色Key不能为空", groups = {GetStaffsInRole.class}) + private String roleKey; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java index 8e6fcba4ac..73a94b7740 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -3,7 +3,6 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.GovStaffRoleDTO; -import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.service.GovStaffRoleService; @@ -32,12 +31,12 @@ public class StaffRoleController { private GovStaffRoleService govStaffRoleService; /** - * 根据工作人员查询工作人员具有的角色列表 + * 查询工作人员具有的角色列表 * @return */ @PostMapping("staffroles") public Result> getRolesOfStaff(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { - ValidatorUtils.validateEntity(staffRoleFormDTO); + ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetRolesOfStaff.class); String staffId = staffRoleFormDTO.getStaffId(); String orgId = staffRoleFormDTO.getOrgId(); List staffRoleEntities = govStaffRoleService.listRolesByStaffId(staffId, orgId); @@ -50,4 +49,18 @@ public class StaffRoleController { return new Result>().ok(staffRoleDTOS); } + /** + * 查询拥有指定角色的用户列表 + * @param staffRoleFormDTO + * @return + */ + @PostMapping("staffsinrole") + public Result> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { + ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class); + String roleKey = staffRoleFormDTO.getRoleKey(); + String orgId = staffRoleFormDTO.getOrgId(); + List roleDTOS = govStaffRoleService.listStaffsInRole(roleKey, orgId); + return new Result>().ok(roleDTOS); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java index 8967f79733..fa244dce1c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.GovStaffRoleDTO; import com.epmet.entity.GovStaffRoleEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -33,5 +34,19 @@ import java.util.List; @Mapper public interface GovStaffRoleDao extends BaseDao { + /** + * 根据staffId查询具有的角色列表 + * @param staffId + * @param orgId + * @return + */ List listRolesByStaffId(@Param("staffId") String staffId, @Param("orgId") String orgId); + + /** + * 查询具有某角色的staff列表 + * @param roleKey + * @param orgId + * @return + */ + List listStaffsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java index 942a001921..8de688b50b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java @@ -99,4 +99,12 @@ public interface GovStaffRoleService extends BaseService { * @return */ List listRolesByStaffId(String staffId, String orgId); + + /** + * 查询具有某角色的staff列表 + * @param roleKey + * @param orgId + * @return + */ + List listStaffsInRole(String roleKey, String orgId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java index fac6d94901..b0249006aa 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java @@ -111,4 +111,15 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl listStaffsInRole(String roleKey, String orgId) { + return baseDao.listStaffsByRoleKeyAndOrgId(roleKey, orgId); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml index 95949edd10..e2b1d6fe7e 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml @@ -17,6 +17,7 @@ + + + + \ No newline at end of file