| | |
| | | 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; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获取供应商详情") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier:query')") |
| | | public CommonResult<SrmSupplierRespVO> getSupplier(@RequestParam("id") Long id) { |
| | | SrmSupplierDO supplier = supplierService.getSupplier(id); |
| | | return success(BeanUtils.toBean(supplier, SrmSupplierRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "供应商分页查询") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier:query')") |
| | | public CommonResult<PageResult<SrmSupplierRespVO>> getSupplierPage(@Valid SrmSupplierPageReqVO pageReqVO) { |
| | | PageResult<SrmSupplierDO> pageResult = supplierService.getSupplierPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, SrmSupplierRespVO.class)); |
| | |
| | | return success(BeanUtils.toBean(list, SrmSupplierRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "获取供应商档案列表(不过滤准入状态)") |
| | | public CommonResult<List<SrmSupplierRespVO>> getSupplierAllList() { |
| | | List<SrmSupplierDO> list = supplierService.getSupplierAllList(); |
| | | return success(BeanUtils.toBean(list, SrmSupplierRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/export-excel") |
| | | @Operation(summary = "导出供应商 Excel") |
| | | @PreAuthorize("@ss.hasPermission('srm:supplier:export')") |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |