Browse Source

1.

新增:查询角色下的用户列表
master
wxz 5 years ago
parent
commit
61bec2dc5b
  1. 22
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java
  2. 19
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  3. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  4. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java
  5. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java
  6. 13
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

22
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;
}

19
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<List<GovStaffRoleDTO>> getRolesOfStaff(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
ValidatorUtils.validateEntity(staffRoleFormDTO);
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetRolesOfStaff.class);
String staffId = staffRoleFormDTO.getStaffId();
String orgId = staffRoleFormDTO.getOrgId();
List<GovStaffRoleEntity> staffRoleEntities = govStaffRoleService.listRolesByStaffId(staffId, orgId);
@ -50,4 +49,18 @@ public class StaffRoleController {
return new Result<List<GovStaffRoleDTO>>().ok(staffRoleDTOS);
}
/**
* 查询拥有指定角色的用户列表
* @param staffRoleFormDTO
* @return
*/
@PostMapping("staffsinrole")
public Result<List<GovStaffRoleDTO>> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class);
String roleKey = staffRoleFormDTO.getRoleKey();
String orgId = staffRoleFormDTO.getOrgId();
List<GovStaffRoleDTO> roleDTOS = govStaffRoleService.listStaffsInRole(roleKey, orgId);
return new Result<List<GovStaffRoleDTO>>().ok(roleDTOS);
}
}

15
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<GovStaffRoleEntity> {
/**
* 根据staffId查询具有的角色列表
* @param staffId
* @param orgId
* @return
*/
List<GovStaffRoleEntity> listRolesByStaffId(@Param("staffId") String staffId, @Param("orgId") String orgId);
/**
* 查询具有某角色的staff列表
* @param roleKey
* @param orgId
* @return
*/
List<GovStaffRoleDTO> listStaffsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId);
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java

@ -99,4 +99,12 @@ public interface GovStaffRoleService extends BaseService<GovStaffRoleEntity> {
* @return
*/
List<GovStaffRoleEntity> listRolesByStaffId(String staffId, String orgId);
/**
* 查询具有某角色的staff列表
* @param roleKey
* @param orgId
* @return
*/
List<GovStaffRoleDTO> listStaffsInRole(String roleKey, String orgId);
}

11
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

@ -111,4 +111,15 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
return baseDao.listRolesByStaffId(staffId, orgId);
}
/**
* 查询具有某角色的staff列表
* @param roleKey
* @param orgId
* @return
*/
@Override
public List<GovStaffRoleDTO> listStaffsInRole(String roleKey, String orgId) {
return baseDao.listStaffsByRoleKeyAndOrgId(roleKey, orgId);
}
}

13
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -17,6 +17,7 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!--根据staffId查询具有的角色列表-->
<select id="listRolesByStaffId" resultType="com.epmet.entity.GovStaffRoleEntity">
SELECT
r.*
@ -28,5 +29,17 @@
AND sr.ORG_ID = #{orgId}
</select>
<!--查询具有某角色的staff列表-->
<select id="listStaffsByRoleKeyAndOrgId" resultType="com.epmet.dto.GovStaffRoleDTO">
SELECT
r.*
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )
WHERE
r.ROLE_KEY = #{roleKey}
AND sr.ORG_ID = #{orgId}
</select>
</mapper>
Loading…
Cancel
Save