| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class, buildContactDetailList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入联系人模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<CrmContactImportExcelVO> list = Arrays.asList( |
| | | CrmContactImportExcelVO.builder().name("示例联系人").customerName("示例客户") |
| | | .mobile("13800138000").telephone("").email("").wechat("").post("").remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "联系人导入模板.xls", "联系人列表", CrmContactImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入联系人") |
| | | @PreAuthorize("@ss.hasPermission('crm:contact:import')") |
| | | public CommonResult<CrmContactImportRespVO> importExcel(@Valid CrmContactImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<CrmContactImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), CrmContactImportExcelVO.class); |
| | | return success(contactService.importContactList(list, importReqVO)); |
| | | } |
| | | |
| | | private List<CrmContactRespVO> buildContactDetailList(List<CrmContactDO> contactList) { |
| | | if (CollUtil.isEmpty(contactList)) { |
| | | return Collections.emptyList(); |