| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | ExcelUtils.write(response, "供应商数据.xlsx", "供应商", SrmSupplierRespVO.class, BeanUtils.toBean(list, SrmSupplierRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入供应商模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<SrmSupplierImportExcelVO> list = Collections.singletonList( |
| | | SrmSupplierImportExcelVO.builder().code("SUP-001").name("示例供应商") |
| | | .shortName("示例").type("1").companyNature("").registeredCapital(null) |
| | | .businessLicenseNo("").taxNo("").legalPerson("").address("").website("") |
| | | .contactName("").contactMobile("").contactEmail("").bankName("").bankAccount("") |
| | | .status(0).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "供应商导入模板.xls", "供应商列表", SrmSupplierImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入供应商") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier:import')") |
| | | public CommonResult<SrmSupplierImportRespVO> importExcel(@Valid SrmSupplierImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<SrmSupplierImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), SrmSupplierImportExcelVO.class); |
| | | return success(supplierService.importSupplierList(list, importReqVO)); |
| | | } |
| | | |
| | | } |