| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | */ |
| | | @Log(title = "产品", businessType = BusinessType.INSERT) |
| | | @PostMapping("/addOrEditProduct") |
| | | public AjaxResult addOrEditProduct(@RequestBody ProductDto productDto) { |
| | | return toAjax(productService.addOrEditProduct(productDto)); |
| | | public R<?> addOrEditProduct(@RequestBody ProductDto productDto) { |
| | | productService.addOrEditProduct(productDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Log(title = "产品规格型号", businessType = BusinessType.INSERT) |
| | | @PostMapping("/addOrEditProductModel") |
| | | public AjaxResult addOrEditProductModel(@RequestBody ProductModelDto productModelDto) { |
| | | return toAjax(productModelService.addOrEditProductModel(productModelDto)); |
| | | public R<?> addOrEditProductModel(@RequestBody ProductModelDto productModelDto) { |
| | | productModelService.addOrEditProductModel(productModelDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Log(title = "产品", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/delProduct") |
| | | public AjaxResult remove(@RequestBody Long[] ids) { |
| | | public R<?> remove(@RequestBody Long[] ids) { |
| | | if (ids == null || ids.length == 0) { |
| | | return AjaxResult.error("请传入要删除的ID"); |
| | | return R.fail("请传入要删除的ID"); |
| | | } |
| | | // 检查是否有销售商品记录关联该产品 |
| | | LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(SalesLedgerProduct::getProductId, ids); |
| | | List<SalesLedgerProduct> salesLedgerProductList = salesLedgerProductService.list(queryWrapper); |
| | | if (salesLedgerProductList.size() > 0) { |
| | | return AjaxResult.error("该产品存在销售/采购记录,不能删除"); |
| | | return R.fail("该产品存在销售/采购记录,不能删除"); |
| | | } |
| | | return toAjax(productService.delProductByIds(ids)); |
| | | productService.delProductByIds(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Log(title = "产品规格型号", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/delProductModel") |
| | | public AjaxResult delProductModel(@RequestBody Long[] ids) { |
| | | public R<?> delProductModel(@RequestBody Long[] ids) { |
| | | if (ids == null || ids.length == 0) { |
| | | return AjaxResult.error("请传入要删除的ID"); |
| | | return R.fail("请传入要删除的ID"); |
| | | } |
| | | // 检查是否有销售商品记录关联该产品规格型号 |
| | | LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(SalesLedgerProduct::getProductModelId, ids); |
| | | List<SalesLedgerProduct> salesLedgerProductList = salesLedgerProductService.list(queryWrapper); |
| | | if (salesLedgerProductList.size() > 0) { |
| | | return AjaxResult.error("该产品规格型号存在销售/采购记录,不能删除"); |
| | | return R.fail("该产品规格型号存在销售/采购记录,不能删除"); |
| | | } |
| | | return toAjax(productModelService.delProductModel(ids)); |
| | | productModelService.delProductModel(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/import") |
| | | @Log(title = "导入产品", businessType = BusinessType.IMPORT) |
| | | public AjaxResult importProductModel(@RequestParam("file") MultipartFile file, Integer productId) { |
| | | public R<?> importProductModel(@RequestParam("file") MultipartFile file, Integer productId) { |
| | | return productModelService.importProductModel(file, productId); |
| | | } |
| | | |