package com.ruoyi.basic.controller;
|
|
import com.ruoyi.basic.dto.ProductDto;
|
import com.ruoyi.basic.dto.ProductModelDto;
|
import com.ruoyi.basic.dto.ProductTreeDto;
|
import com.ruoyi.basic.pojo.ProductModel;
|
import com.ruoyi.basic.service.IProductModelService;
|
import com.ruoyi.basic.service.IProductService;
|
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 lombok.AllArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/basic/product")
|
public class ProductController extends BaseController {
|
|
private IProductService productService;
|
|
private IProductModelService productModelService;
|
|
|
/**
|
* 查询产品
|
*/
|
@GetMapping("/list")
|
public List<ProductTreeDto> selectProductList(ProductDto productDto) {
|
return productService.selectProductList(productDto);
|
}
|
|
/**
|
* 根据id查询产品规格
|
*/
|
@GetMapping("/modelList")
|
public List<ProductModel> selectModelList(ProductDto productDto) {
|
return productModelService.selectModelList(productDto);
|
}
|
|
/**
|
* 新增更新产品
|
*/
|
@Log(title = "产品", businessType = BusinessType.INSERT)
|
@PostMapping("/addOrEditProduct")
|
public AjaxResult addOrEditProduct(@RequestBody ProductDto productDto) {
|
return toAjax(productService.addOrEditProduct(productDto));
|
}
|
|
/**
|
* 新增更新产品规格型号
|
*/
|
@Log(title = "产品规格型号", businessType = BusinessType.INSERT)
|
@PostMapping("/addOrEditProductModel")
|
public AjaxResult addOrEditProductModel(@RequestBody ProductModelDto productModelDto) {
|
return toAjax(productModelService.addOrEditProductModel(productModelDto));
|
}
|
|
/**
|
* 删除
|
*/
|
@Log(title = "产品", businessType = BusinessType.DELETE)
|
@DeleteMapping("/delProduct")
|
public AjaxResult remove(@RequestBody Long[] ids) {
|
if (ids == null || ids.length == 0) {
|
return AjaxResult.error("请传入要删除的ID");
|
}
|
return toAjax(productService.delProductByIds(ids));
|
}
|
|
/**
|
* 删除产品规格型号
|
*/
|
@Log(title = "产品规格型号", businessType = BusinessType.DELETE)
|
@DeleteMapping("/delProductModel")
|
public AjaxResult delProductModel(@RequestBody Long[] ids) {
|
if (ids == null || ids.length == 0) {
|
return AjaxResult.error("请传入要删除的ID");
|
}
|
return toAjax(productModelService.delProductModel(ids));
|
}
|
}
|