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.
 
 
 
 
 

127 lines
4.5 KiB

package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GovStaffRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.dto.result.ResiGovRoleListResultDTO;
import com.epmet.dto.result.RoleInfoResultDTO;
import com.epmet.service.GovStaffRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@RequestMapping("govstaffrole")
@RestController
public class GovStaffRoleController {
@Autowired
private GovStaffRoleService govStaffRoleService;
/**
* 根据客户ID查询该客户的角色列表
* @param customerId
* @return
*/
@PostMapping("rolesbycustomer/{customerId}")
public Result listGovStaffRolesByCustomer(@PathVariable("customerId") String customerId) {
List<GovStaffRoleResultDTO> roleEntities = govStaffRoleService.listRolesByCustomer(customerId);
return new Result().ok(roleEntities);
}
/**
* 查询角色模板列表
* @return
*/
@PostMapping("roletemplates")
public Result listGovStaffRoleTemplates() {
List<GovStaffRoleTemplateDTO> roleTemplates = govStaffRoleService.listRoleTemplates();
return new Result().ok(roleTemplates);
}
/**
* 使用id列表查询角色列表
* @param form
* @return
*/
@PostMapping("getbyids")
public Result<List<GovStaffRoleResultDTO>> getByIds(@RequestBody GovStaffRoleFormDTO form) {
List<GovStaffRoleResultDTO> roleDTOS = new ArrayList<>();
List<String> roleIdList = form.getRoleIdList();
if (!CollectionUtils.isEmpty(roleIdList)) {
roleDTOS = roleIdList.stream().map(roleId -> govStaffRoleService.getDTOById(roleId)).collect(Collectors.toList());
}
return new Result<List<GovStaffRoleResultDTO>>().ok(roleDTOS);
}
/**
* @param tokenDTO
* @return ResiGovRoleListResultDTO
* @author sun
* @Description 获取居民端、工作端人员角色列表
*/
@PostMapping("resigovrolelist")
public Result<ResiGovRoleListResultDTO> resiGovRoleList(@LoginUser TokenDto tokenDTO){
return new Result<ResiGovRoleListResultDTO>().ok(govStaffRoleService.resiGovRoleList());
}
/**
* 更新客户的指定角色
* @param form
* @return
*/
@PostMapping("update-role")
public Result updateRole(@RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.UpdateRoleGroup.class);
if (govStaffRoleService.updateRole(form.getRoleId(), form.getRoleName()) == 0) {
throw new RenException("修改角色信息失败");
}
return new Result();
}
/**
* 更新排序序号
* @param form
* @return
*/
@PostMapping("save-sortorder")
public Result saveSortOrder(@RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
List<String> roleIdList = form.getRoleIdList();
govStaffRoleService.saveSortOrder(roleIdList);
return new Result();
}
/**
* @Description 根据角色key查询具有该key的所有角色列表
* @return
* @author wxz
* @date 2020.11.17 16:20
*/
@PostMapping("list-roles-by-rolekey/{role-key}")
public Result<List<GovStaffRoleResultDTO>> listRolesByRoleKey(@PathVariable("role-key") String roleKey) {
List<GovStaffRoleResultDTO> roles = govStaffRoleService.listRolesByRoleKey(roleKey);
return new Result<List<GovStaffRoleResultDTO>>().ok(roles);
}
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.RoleInfoResultDTO>>
* @param customerId
* @author yinzuomei
* @description 获取当前客户下-工作端角色列表
* @Date 2021/3/29 15:37
**/
@GetMapping("querycustomergovrolelist/{customerId}")
Result<List<RoleInfoResultDTO>> queryCustomerGovRoleList(@PathVariable("customerId") String customerId){
return new Result<List<RoleInfoResultDTO>>().ok(govStaffRoleService.queryCustomerGovRoleList(customerId));
}
}