| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得商机") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<CrmBusinessRespVO> getBusiness(@RequestParam("id") Long id) { |
| | | CrmBusinessDO business = businessService.getBusiness(id); |
| | | return success(buildBusinessDetail(business)); |
| | |
| | | |
| | | @GetMapping("/simple-all-list") |
| | | @Operation(summary = "获得商机的精简列表") |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<List<CrmBusinessRespVO>> getSimpleContactList() { |
| | | CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); |
| | | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| | |
| | | @GetMapping("/list-by-customer") |
| | | @Operation(summary = "获得商机列表,基于指定客户") |
| | | @Parameter(name = "customerId", description = "客户编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<List<CrmBusinessRespVO>> getBusinessListByCustomer(@RequestParam("customerId") Long customerId) { |
| | | List<CrmBusinessDO> list = businessService.getBusinessListByCustomerId(customerId); |
| | | return success(convertList(list, business -> // 只返回 id、name 字段 |
| | |
| | | @GetMapping("/list-by-contact") |
| | | @Operation(summary = "获得商机列表,基于指定联系人") |
| | | @Parameter(name = "contactId", description = "联系人编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<List<CrmBusinessRespVO>> getBusinessListByContact(@RequestParam("contactId") Long contactId) { |
| | | List<CrmBusinessDO> list = businessService.getBusinessListByContact(contactId); |
| | | return success(buildBusinessDetailList(list)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得商机分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { |
| | | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); |
| | | return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | |
| | | @GetMapping("/page-by-contact") |
| | | @Operation(summary = "获得联系人的商机分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| | | public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) { |
| | | PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByContact(pageReqVO); |
| | | return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | buildBusinessDetailList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入商机模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<CrmBusinessImportExcelVO> list = Arrays.asList( |
| | | CrmBusinessImportExcelVO.builder().name("示例商机").customerName("示例客户") |
| | | .dealTime(null).totalProductPrice(null).discountPercent(null).totalPrice(null).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "商机导入模板.xls", "商机列表", CrmBusinessImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入商机") |
| | | @PreAuthorize("@ss.hasPermission('crm:business:import')") |
| | | public CommonResult<CrmBusinessImportRespVO> importExcel(@Valid CrmBusinessImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<CrmBusinessImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), CrmBusinessImportExcelVO.class); |
| | | return success(businessService.importBusinessList(list, importReqVO)); |
| | | } |
| | | |
| | | public List<CrmBusinessRespVO> buildBusinessDetailList(List<CrmBusinessDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |