日照智慧社区接口服务
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.
 
 
 
 
 

151 lines
5.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.form.UpGovRoleFormDTO;
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 formDTO
* @return
*/
@PostMapping("update-role")
public Result updateRole(@LoginUser TokenDto tokenDTO, @RequestBody UpGovRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UpGovRoleFormDTO.Update.class);
formDTO.setUserId(tokenDTO.getUserId());
govStaffRoleService.updateCustomerRole(formDTO);
return new Result();
}
/**
* 更新排序序号
* @param form
* @return
*/
@PostMapping("save-sortorder")
public Result saveSortOrder(@LoginUser TokenDto tokenDTO, @RequestBody GovStaffRoleFormDTO form) {
ValidatorUtils.validateEntity(form, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
govStaffRoleService.saveSortOrder(tokenDTO.getUserId(), form.getRoleIdList());
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));
}
/**
* @param formDTO
* @Description 默认权限保存排序
* @Author sun
**/
@PostMapping("savedefaultsort")
public Result saveDefaultSort(@LoginUser TokenDto tokenDTO, @RequestBody GovStaffRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GovStaffRoleFormDTO.SaveRoleOrderGroup.class);
govStaffRoleService.saveDefaultSort(tokenDTO.getUserId(), formDTO.getRoleIdList());
return new Result();
}
/**
* @param formDTO
* @Description 修改角色名称或职责描述
* @Author sun
**/
@PostMapping("updatedefaultrole")
public Result updateDefaultRole(@LoginUser TokenDto tokenDTO, @RequestBody UpGovRoleFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UpGovRoleFormDTO.Update.class);
formDTO.setUserId(tokenDTO.getUserId());
govStaffRoleService.updateDefaultRole(formDTO);
return new Result();
}
}