You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
231 lines
8.9 KiB
231 lines
8.9 KiB
package com.epmet.controller;
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import com.epmet.commons.mybatis.entity.DataScope;
|
|
import com.epmet.commons.tools.page.PageData;
|
|
import com.epmet.commons.tools.utils.Result;
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup;
|
|
import com.epmet.dto.GovStaffRoleDTO;
|
|
import com.epmet.dto.StaffRoleDTO;
|
|
import com.epmet.dto.form.*;
|
|
import com.epmet.dto.result.*;
|
|
import com.epmet.entity.GovStaffRoleEntity;
|
|
import com.epmet.service.GovStaffRoleService;
|
|
import com.epmet.service.StaffRoleService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.*;
|
|
|
|
/**
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* 一次性查询多个机构下,指定角色的用户列表
|
|
* @param staffRoleFormDTO
|
|
* @return
|
|
*/
|
|
@PostMapping("staffsinroleoforgs")
|
|
public Result<Map<String, List<GovStaffRoleResultDTO>>> getStaffsInRoleOfOrgs(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
|
|
HashMap<String, List<GovStaffRoleResultDTO>> resultMap = new HashMap<>();
|
|
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRoleOrOrgs.class);
|
|
List<String> orgIds = staffRoleFormDTO.getOrgIds();
|
|
if (!CollectionUtil.isEmpty(orgIds)) {
|
|
for (String orgId : orgIds) {
|
|
List<GovStaffRoleResultDTO> staffRole = staffRoleService.listStaffsInRole(staffRoleFormDTO.getRoleKey(), orgId, DataScope.getDefault());
|
|
resultMap.put(orgId, staffRole);
|
|
}
|
|
}
|
|
return new Result<Map<String, List<GovStaffRoleResultDTO>>>().ok(resultMap);
|
|
}
|
|
|
|
/**
|
|
* @return Result<StaffRolesResultDTO>
|
|
* @Description 查询一个员工在指定客户下的角色
|
|
* @Param CommonUserFormDTO
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* @param rolesUsersListFormDTO
|
|
* @Description 查找具有特定角色的人员Id(可用)
|
|
* @author wangc
|
|
* @date 2020.04.29 23:49
|
|
**/
|
|
@PostMapping("specificrolesstaffs")
|
|
public Result<List<String>> specificRolesStaffs(@RequestBody RolesUsersListFormDTO rolesUsersListFormDTO) {
|
|
return staffRoleService.getSpecificRolesStaffs(rolesUsersListFormDTO);
|
|
}
|
|
|
|
/**
|
|
* 为客户初始化政府端工作人员角色
|
|
* @param customerId
|
|
* @return
|
|
*/
|
|
@PostMapping("initrolesforcustomer/{customerId}")
|
|
public Result initGovStaffRolesForCustomer(@PathVariable String customerId) {
|
|
govStaffRoleService.initGovStaffRolesForCustomer(customerId);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* 根据客户ID和角色key查询角色信息
|
|
* @param form
|
|
* @return
|
|
*/
|
|
@PostMapping("roleofcustomer")
|
|
public Result<GovStaffRoleDTO> getRoleOfCustomer(@RequestBody CustomerRoleFormDTO form) {
|
|
ValidatorUtils.validateEntity(form, CustomerRoleFormDTO.GetRoleByCustomerAndKey.class);
|
|
GovStaffRoleDTO role = govStaffRoleService.getRoleByCustomerIdAndRoleKey(form.getCustomerId(), form.getRoleKey());
|
|
return new Result<GovStaffRoleDTO>().ok(role);
|
|
}
|
|
|
|
/**
|
|
* @Description 根据客户Id和staffId查询一个员工在指定客户下的角色列表
|
|
* @Author sun
|
|
**/
|
|
@PostMapping("getcustomerstaffrolelist")
|
|
public Result<List<CustomerStaffRoleListResultDTO>> getCustomerStaffRoleList(@RequestBody CustomerStaffRoleListFormDTO formDTO) {
|
|
ValidatorUtils.validateEntity(formDTO);
|
|
return new Result<List<CustomerStaffRoleListResultDTO>>().ok(staffRoleService.getCustomerStaffRoleList(formDTO));
|
|
}
|
|
|
|
/**
|
|
* 根据staffId查询人员拥有的所有角色信息
|
|
* @author zhaoqifeng
|
|
* @date 2020/6/2 16:11
|
|
* @param staffId
|
|
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerStaffRoleResultDTO>>
|
|
*/
|
|
@PostMapping("staffroles/{staffId}")
|
|
public Result<List<CustomerStaffRoleResultDTO>> getStaffRoles(@PathVariable String staffId) {
|
|
return new Result<List<CustomerStaffRoleResultDTO>>().ok(staffRoleService.getStaffRoles(staffId));
|
|
}
|
|
|
|
/**
|
|
* 更改角色所属组织
|
|
* @author zhaoqifeng
|
|
* @date 2020/8/31 10:29
|
|
* @param formDTO
|
|
* @return com.epmet.commons.tools.utils.Result
|
|
*/
|
|
@PostMapping("changeroleorg")
|
|
public Result changeRoleOrg(@RequestBody StaffRoleDTO formDTO) {
|
|
staffRoleService.changeRoleOrg(formDTO);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* @Description 查询网格员角色
|
|
* @Param forms
|
|
* @author zxc
|
|
* @date 2021/6/8 4:42 下午
|
|
*/
|
|
@PostMapping("staffgridrole")
|
|
public Result<List<GridStaffResultDTO>> staffGridRole(@RequestBody List<GridStaffResultDTO> forms){
|
|
return new Result<List<GridStaffResultDTO>>().ok(staffRoleService.staffGridRole(forms));
|
|
}
|
|
|
|
/**
|
|
* 根据角色,查询里面的人,去重
|
|
*
|
|
* @param formDTO
|
|
* @return com.epmet.commons.tools.utils.Result<java.util.Set<java.lang.String>>
|
|
* @author yinzuomei
|
|
* @date 2021/8/19 11:14 上午
|
|
*/
|
|
@PostMapping("queryRoleStaffIds")
|
|
Result<Set<String>> queryRoleStaffIds(@RequestBody RoleStaffIdFormDTO formDTO){
|
|
ValidatorUtils.validateEntity(formDTO,RoleStaffIdFormDTO.AddUserInternalGroup.class);
|
|
return new Result<Set<String>>().ok(staffRoleService.queryRoleStaffIds(formDTO));
|
|
}
|
|
|
|
/**
|
|
* desc: 根据角色、用户名、手机号 组织获取网格下的工作人员 精确匹配
|
|
*
|
|
* @param formDTO
|
|
* @return com.epmet.commons.tools.utils.Result<java.util.Set<java.lang.String>>
|
|
* @author LiuJanJun
|
|
* @date 2022/1/17 2:26 下午
|
|
*/
|
|
@PostMapping("getGridStaffList")
|
|
Result<PageData<CustomerGridStaffResultDTO>> getGridStaffList(@RequestHeader(value = "customerId",required = false) String customerId, @RequestBody GridStaffFormDTO formDTO){
|
|
//tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
if (StringUtils.isBlank(formDTO.getCustomerId())){
|
|
formDTO.setCustomerId(customerId);
|
|
}
|
|
ValidatorUtils.validateEntity(formDTO, DefaultGroup.class);
|
|
|
|
return new Result<PageData<CustomerGridStaffResultDTO>>().ok(staffRoleService.getGridStaffList(formDTO));
|
|
}
|
|
|
|
/**
|
|
* Desc: 查询是否是超级管理员
|
|
* @param userId
|
|
* @author zxc
|
|
* @date 2022/7/13 11:03
|
|
*/
|
|
@PostMapping("getIsRootManager")
|
|
public Result<Boolean> getIsRootManager(@RequestParam("userId") String userId){
|
|
return new Result<Boolean>().ok(staffRoleService.getIsRootManager(userId));
|
|
}
|
|
}
|
|
|