| | |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.ProductDto; |
| | |
| | | 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.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | private IProductService productService; |
| | | |
| | | private IProductModelService productModelService; |
| | | |
| | | |
| | | @Autowired |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | /** |
| | | * 查询产品 |
| | | */ |
| | |
| | | if (ids == null || ids.length == 0) { |
| | | return AjaxResult.error("请传入要删除的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 toAjax(productService.delProductByIds(ids)); |
| | | } |
| | | |
| | |
| | | if (ids == null || ids.length == 0) { |
| | | return AjaxResult.error("请传入要删除的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 toAjax(productModelService.delProductModel(ids)); |
| | | } |
| | | |
| | |
| | | public IPage<ProductModel> selectModelListPage(Page page, ProductDto productDto) { |
| | | return productModelService.modelListPage(page, productDto); |
| | | } |
| | | |
| | | @ApiOperation("分页查询所有产品型号") |
| | | @GetMapping("/pageModel") |
| | | public IPage<ProductModel> listPageProductModel(Page<ProductModel> page, ProductModel productModel) { |
| | | return productService.listPageProductModel(page, productModel); |
| | | } |
| | | |
| | | /** |
| | | * 导入产品 |
| | | */ |
| | | @Log(title = "导入产品",businessType = BusinessType.IMPORT) |
| | | @PostMapping("import") |
| | | public AjaxResult importProduct(MultipartFile file) { |
| | | return AjaxResult.success(productModelService.importProduct(file)); |
| | | } |
| | | } |