|
|
|
package com.epmet.controller;
|
|
|
|
|
|
|
|
import com.epmet.commons.mybatis.entity.DataScope;
|
|
|
|
import com.epmet.commons.tools.annotation.RequirePermission;
|
|
|
|
import com.epmet.commons.tools.enums.RequirePermissionEnum;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
|
|
import com.epmet.dto.GovStaffRoleDTO;
|
|
|
|
import com.epmet.dto.form.CommonUserFormDTO;
|
|
|
|
import com.epmet.dto.form.RolesUsersListFormDTO;
|
|
|
|
import com.epmet.dto.form.StaffRoleFormDTO;
|
|
|
|
import com.epmet.dto.result.GovStaffRoleResultDTO;
|
|
|
|
import com.epmet.dto.result.StaffRolesResultDTO;
|
|
|
|
import com.epmet.entity.GovStaffRoleEntity;
|
|
|
|
import com.epmet.service.GovStaffRoleService;
|
|
|
|
import com.epmet.service.StaffRoleService;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return
|
|
|
|
* 工作人员相关api
|
|
|
|
* @Author wxz
|
|
|
|
* @Description
|
|
|
|
* @Date 2020/4/22 22:44
|
|
|
|
**/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("staffrole")
|
|
|
|
public class StaffRoleController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private GovStaffRoleService govStaffRoleService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private StaffRoleService staffRoleService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询工作人员具有的角色列表
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("staffroles")
|
|
|
|
public Result<List<GovStaffRoleDTO>> getRolesOfStaff(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
|
|
|
|
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetRolesOfStaff.class);
|
|
|
|
String staffId = staffRoleFormDTO.getStaffId();
|
|
|
|
String orgId = staffRoleFormDTO.getOrgId();
|
|
|
|
List<GovStaffRoleEntity> staffRoleEntities = govStaffRoleService.listRolesByStaffId(staffId, orgId);
|
|
|
|
List<GovStaffRoleDTO> staffRoleDTOS = new ArrayList<>();
|
|
|
|
staffRoleEntities.forEach(role -> {
|
|
|
|
GovStaffRoleDTO dto = new GovStaffRoleDTO();
|
|
|
|
BeanUtils.copyProperties(role, dto);
|
|
|
|
staffRoleDTOS.add(dto);
|
|
|
|
});
|
|
|
|
return new Result<List<GovStaffRoleDTO>>().ok(staffRoleDTOS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询拥有指定角色的用户列表
|
|
|
|
* @param staffRoleFormDTO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("staffsinrole")
|
|
|
|
//@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_LIST)
|
|
|
|
public Result<List<GovStaffRoleResultDTO>> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
|
|
|
|
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class);
|
|
|
|
String roleKey = staffRoleFormDTO.getRoleKey();
|
|
|
|
String orgId = staffRoleFormDTO.getOrgId();
|
|
|
|
List<GovStaffRoleResultDTO> staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId , DataScope.getDefault());
|
|
|
|
return new Result<List<GovStaffRoleResultDTO>>().ok(staffRoleDTOS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description 查询一个员工在指定客户下的角色
|
|
|
|
* @Param CommonUserFormDTO
|
|
|
|
* @return Result<StaffRolesResultDTO>
|
|
|
|
* @Author wangc
|
|
|
|
* @Date 2020.04.26 13:06
|
|
|
|
**/
|
|
|
|
@PostMapping("getcustomerstaffroles")
|
|
|
|
//@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_LIST)
|
|
|
|
public Result<StaffRolesResultDTO> getCustomerStaffRoles(@RequestBody CommonUserFormDTO commonUserFormDTO){
|
|
|
|
ValidatorUtils.validateEntity(commonUserFormDTO);
|
|
|
|
return staffRoleService.getStaffRoles(commonUserFormDTO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description 查找具有特定角色的人员Id(可用)
|
|
|
|
* @param rolesUsersListFormDTO
|
|
|
|
* @author wangc
|
|
|
|
* @date 2020.04.29 23:49
|
|
|
|
**/
|
|
|
|
@PostMapping("specificrolesstaffs")
|
|
|
|
public Result<List<String>> specificRolesStaffs(@RequestBody RolesUsersListFormDTO rolesUsersListFormDTO){
|
|
|
|
return staffRoleService.getSpecificRolesStaffs(rolesUsersListFormDTO);
|
|
|
|
}
|
|
|
|
}
|