| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得商机状态") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('crm:business-status:query')") |
| | | public CommonResult<CrmBusinessStatusRespVO> getBusinessStatusType(@RequestParam("id") Long id) { |
| | | CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id); |
| | | if (statusType == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得商机状态分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:business-status:query')") |
| | | public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusPage(@Valid PageParam pageReqVO) { |
| | | // 1. 查询数据 |
| | | PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); |
| | |
| | | } |
| | | // 2. 拼接数据 |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(pageResult.getList(), statusType -> Long.parseLong(statusType.getCreator()))); |
| | | convertSet(pageResult.getList(), statusType -> NumberUtils.parseLong(statusType.getCreator()))); |
| | | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( |
| | | convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds, Collection::stream)); |
| | | return success(BeanUtils.toBean(pageResult, CrmBusinessStatusRespVO.class, statusTypeVO -> { |
| | | statusTypeVO.setCreator(userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())).getNickname()); |
| | | // 创建人可能已删除(如离职账号),显示“已删除用户”而不是抛 NPE 导致整页查询失败 |
| | | AdminUserRespDTO creator = userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())); |
| | | statusTypeVO.setCreator(creator != null ? creator.getNickname() : "已删除用户"); |
| | | statusTypeVO.setDeptNames(convertList(statusTypeVO.getDeptIds(), |
| | | deptId -> deptMap.containsKey(deptId) ? deptMap.get(deptId).getName() : null)); |
| | | })); |