|
@@ -0,0 +1,101 @@
|
|
|
+package cn.iocoder.yudao.module.supplier.controller.admin.product;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.SupplierPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.SupplierRespVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.SupplierSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
|
|
|
+import cn.iocoder.yudao.module.supplier.service.product.SupplierService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 供应商主数据")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/supplier/base/")
|
|
|
+@Validated
|
|
|
+public class SupplierController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SupplierService supplierService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建供应商主数据")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:create')")
|
|
|
+ public CommonResult<Long> create(@Valid @RequestBody SupplierSaveReqVO createReqVO) {
|
|
|
+ return success(supplierService.create(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新供应商主数据")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:update')")
|
|
|
+ public CommonResult<Boolean> update(@Valid @RequestBody SupplierSaveReqVO updateReqVO) {
|
|
|
+ supplierService.update(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除供应商主数据")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:delete')")
|
|
|
+ public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
|
|
|
+ supplierService.delete(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得供应商主数据")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:query')")
|
|
|
+ public CommonResult<SupplierRespVO> get(@RequestParam("id") Long id) {
|
|
|
+ SupplierDO supplierDO = supplierService.get(id);
|
|
|
+ return success(BeanUtils.toBean(supplierDO, SupplierRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得供应商主数据分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:query')")
|
|
|
+ public CommonResult<PageResult<SupplierRespVO>> getPage(@Valid SupplierPageReqVO pageReqVO) {
|
|
|
+ PageResult<SupplierDO> pageResult = supplierService.getPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, SupplierRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出供应商主数据 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportExcel(@Valid SupplierPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<SupplierDO> list = supplierService.getPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "供应商主数据.xls", "数据", SupplierRespVO.class,
|
|
|
+ BeanUtils.toBean(list, SupplierRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("all")
|
|
|
+ @Operation(summary = "获取所有供应商信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('supplier:base:all')")
|
|
|
+ public CommonResult<List<SupplierRespVO>> getAll() {
|
|
|
+ List<SupplierDO> all = supplierService.getAll();
|
|
|
+ return success(BeanUtils.toBean(all, SupplierRespVO.class));
|
|
|
+ }
|
|
|
+}
|