package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.RoleDTO; import com.epmet.dto.form.GovStaffRoleFormDTO; import com.epmet.dto.form.IssueInitiatorFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; import com.epmet.dto.result.GovStaffRoleTemplateDTO; import com.epmet.dto.result.IssueInitiatorResultDTO; import com.epmet.dto.result.ResiGovRoleListResultDTO; import com.epmet.entity.GovStaffRoleEntity; 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 roleEntities = govStaffRoleService.listRolesByCustomer(customerId); return new Result().ok(roleEntities); } /** * 查询角色模板列表 * @return */ @PostMapping("roletemplates") public Result listGovStaffRoleTemplates() { List roleTemplates = govStaffRoleService.listRoleTemplates(); return new Result().ok(roleTemplates); } /** * 使用id列表查询角色列表 * @param form * @return */ @PostMapping("getbyids") public Result> getByIds(@RequestBody GovStaffRoleFormDTO form) { List roleDTOS = new ArrayList<>(); List roleIdList = form.getRoleIdList(); if (!CollectionUtils.isEmpty(roleIdList)) { roleDTOS = roleIdList.stream().map(roleId -> govStaffRoleService.getDTOById(roleId)).collect(Collectors.toList()); } return new Result>().ok(roleDTOS); } /** * @param tokenDTO * @return ResiGovRoleListResultDTO * @author sun * @Description 获取居民端、工作端人员角色列表 */ @PostMapping("resigovrolelist") public Result resiGovRoleList(@LoginUser TokenDto tokenDTO){ return new Result().ok(govStaffRoleService.resiGovRoleList()); } }