| | |
| | | return success(buildCustomerDetail(customer)); |
| | | } |
| | | |
| | | @GetMapping("/business-get") |
| | | @Operation(summary = "获得业务模块关联客户详情") |
| | | @PreAuthorize("isAuthenticated()") |
| | | public CommonResult<CrmCustomerRespVO> getBusinessCustomer(@RequestParam("id") Long id) { |
| | | CrmCustomerDO customer = customerService.getCustomerList(java.util.Collections.singleton(id)) |
| | | .stream().findFirst().orElse(null); |
| | | return success(buildCustomerDetail(customer)); |
| | | } |
| | | |
| | | public CrmCustomerRespVO buildCustomerDetail(CrmCustomerDO customer) { |
| | | if (customer == null) { |
| | | return null; |
| | |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | // 2. 拼接数据 |
| | | return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | | @GetMapping("/business-page") |
| | | @Operation(summary = "获得业务模块客户分页") |
| | | @PreAuthorize("isAuthenticated()") |
| | | public CommonResult<PageResult<CrmCustomerRespVO>> getBusinessCustomerPage( |
| | | @Valid CrmCustomerPageReqVO pageVO) { |
| | | PageResult<CrmCustomerDO> pageResult = customerService.getBusinessCustomerPage(pageVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入客户模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | // 示例客户:名称/手机/邮箱均使用占位值,避免照抄官方 demo 产生假数据 |
| | | List<CrmCustomerImportExcelVO> list = Arrays.asList( |
| | | CrmCustomerImportExcelVO.builder().name("超级管理员").industryId(1).level(1).source(1) |
| | | .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") |
| | | .areaId(null).detailAddress("").remark("").autoPoolEnabled(true).build(), |
| | | CrmCustomerImportExcelVO.builder().name("源码").industryId(1).level(1).source(1) |
| | | .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") |
| | | .areaId(null).detailAddress("").remark("").autoPoolEnabled(true).build() |
| | | CrmCustomerImportExcelVO.builder().name("示例客户A(请替换)").industryId(1).level(1).source(1) |
| | | .mobile("13800000001").telephone("").qq("").wechat("").email("customerA@example.com") |
| | | .areaId(null).detailAddress("").remark("示例数据,导入前请替换").autoPoolEnabled(true).build(), |
| | | CrmCustomerImportExcelVO.builder().name("示例客户B(请替换)").industryId(1).level(1).source(1) |
| | | .mobile("13800000002").telephone("").qq("").wechat("").email("customerB@example.com") |
| | | .areaId(null).detailAddress("").remark("示例数据,导入前请替换").autoPoolEnabled(true).build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); |
| | | ExcelUtils.writeTemplate(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |