package com.wms_admin.server.controller;
|
|
|
import com.wms_admin.server.entity.ProductModel;
|
import com.wms_admin.server.service.ProductModelService;
|
import com.wms_admin.utils.Result;
|
import io.swagger.annotations.*;
|
import lombok.NonNull;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.ObjectUtils;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* <p>
|
* 前端控制器
|
* </p>
|
*
|
* @author 江苏鵷雏网络科技有限公司
|
* @since 2023-06-07
|
*/
|
@Api(tags = "添加库存型号")
|
@RestController
|
@RequestMapping("/product-model")
|
public class ProductModelController {
|
|
@Autowired
|
private ProductModelService service;
|
|
@PostMapping("/add")
|
@ApiOperation("库存型号添加接口")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "productCode",value = "型号编码", dataTypeClass = String.class,required = true),
|
@ApiImplicitParam(name = "productModel",value = "型号名称", dataTypeClass = String.class,required = true),
|
@ApiImplicitParam(name = "productNameId",value = "库存名称id", dataTypeClass = String.class,required = true)
|
})
|
public Result<?> AddProductModel(String productCode,
|
String productModel,
|
Integer productNameId){
|
if (ObjectUtils.isEmpty(productCode)){
|
return Result.fail("添加失败,请输入编码!");
|
}
|
if (ObjectUtils.isEmpty(productModel)){
|
return Result.fail("添加失败,请输入型号!");
|
}
|
if (ObjectUtils.isEmpty(productNameId)){
|
return Result.fail("添加失败,请选择名称!");
|
}
|
Integer integer = service.AddProductModel(productCode, productModel, productNameId);
|
if (integer == 1){
|
return Result.success("添加【"+ productModel +"】成功!");
|
}
|
return Result.fail("添加【"+ productModel +"】失败,可能已经存在!");
|
}
|
|
|
@GetMapping("/selectAll")
|
@ApiOperation("查询库存名称ID查询对应型号")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "productNameId",value = "库存名称id", dataTypeClass = String.class,required = true),
|
})
|
public Result<?> SelectIdAllProductModel(Integer productNameId){
|
List<ProductModel> productModels = service.SelectIdAllProductModel(productNameId);
|
Map<String, Object> map = new HashMap<>();
|
map.put("models", productModels);
|
return Result.success(map);
|
}
|
|
@PostMapping("/update")
|
@ApiOperation("根据型号的主键ID,更新对应型号")
|
public Result<?> UpdateIdProductModel(ProductModel productModel){
|
System.out.println(productModel);
|
Integer integer = service.UpdateIdProductModel(productModel);
|
if (integer == 1){
|
return Result.success("更新【"+ productModel.getProductModel() +"】成功!");
|
}
|
return Result.fail("更新【"+ productModel.getProductModel() +"】失败,可能已经存在!");
|
}
|
|
@DeleteMapping("/delete")
|
@ApiOperation("根据型号主键ID删除对应型号")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "productModel",value = "型号", dataTypeClass = String.class,required = true),
|
@ApiImplicitParam(name = "id",value = "型号主键ID", dataTypeClass = String.class,required = true)
|
})
|
public Result<?> DeleteIdProductModel(String productModel, String id){
|
Integer integer = service.DeleteIdProductModel(id);
|
if (integer == 1){
|
return Result.success("删除【"+ productModel +"】成功!");
|
}
|
return Result.fail("删除【"+ productModel +"】失败");
|
}
|
|
@GetMapping("/selectId")
|
@ApiOperation("新:根据模型Id查询对应信息")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "productModelId",value = "型号id", dataTypeClass = String.class,required = true),
|
})
|
public Result<?> selectIdProductModel(Integer productModelId){
|
Map<String, Object> productModels = service.selectIdProductModel(productModelId);
|
return Result.success(productModels);
|
}
|
}
|