futian.liu
2023-12-13 494fbb222f0ec270f764f84f13987984fad09b82
consum-base/src/main/java/com/consum/base/controller/BaseGoodsModelsController.java
@@ -1,5 +1,14 @@
package com.consum.base.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.consum.base.BaseController;
import com.consum.base.core.utils.CommonUtil;
import com.consum.base.service.BaseGoodsModelsService;
@@ -8,14 +17,8 @@
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.web.ResponseValue;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Description 规格型号
@@ -60,22 +63,25 @@
        CommonUtil.copyProperties(models, param2);
        models = param2;
        if (models.getGoodsTemplatesId() == null || StringUtils.isEmpty(models.getModelName()) || StringUtils.isEmpty(models.getUnit()) || models.getStates() == null) {
        if (models.getGoodsTemplatesId() == null || StringUtils.isEmpty(models.getModelName())
            || StringUtils.isEmpty(models.getUnit()) || models.getStates() == null) {
            return ResponseValue.error("参数错误");
        }
        //判断同一物品模板id下的 规格型号名称是否重复
        // 判断同一物品模板id下的 规格型号名称是否重复
        BaseGoodsModels baseGoodsModels = this.baseGoodsModelsService.getByModelNameAndGoodsTemplatesId(models);
        if (baseGoodsModels != null) {
            return ResponseValue.error("规格型号名称已存在");
        }
        int result = this.baseGoodsModelsService.add(models);
        if (result > 0) return ResponseValue.success(1);
        if (result > 0)
            return ResponseValue.success();
        return ResponseValue.error("新增失败!");
    }
    /**
     * 修改状态
     *
     * @author 卢庆阳
     * @date 2023/10/25
     */
@@ -114,31 +120,19 @@
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("删除失败!");
    }
    /**
     * @Description  根据物品id查询规格型号
     * @Author 卢庆阳
     * @Date 2023/10/30
     */
    @GetMapping("/selectByGoodsTemplatesId")
    public ResponseValue queryByGoodsTemplatesId(Long goodsTemplatesId) {
        List<BaseGoodsModels> list = this.baseGoodsModelsService.queryByGoodsTemplatesId(goodsTemplatesId);
        return ResponseValue.success(list);
    }
    @GetMapping("query/goodsModel")
    public ResponseValue queryGoodsModelByGoodsTemplatesId(Long goodsTemplatesId) {
        BaseGoodsModels baseGoodsModels = new BaseGoodsModels();
        baseGoodsModels.setGoodsTemplatesId(goodsTemplatesId);
        List<BaseGoodsModels> result = this.baseGoodsModelsService.select(baseGoodsModels);
        List<BaseGoodsModels> result = baseGoodsModelsService.select(baseGoodsModels);
        return ResponseValue.success(result);
    }
    @GetMapping("queryGoodsModelInfo")
    public ResponseValue queryGoodsModelInfo(Long baseGoodsModelsId) {
        if (baseGoodsModelsId== null){
        if (baseGoodsModelsId == null) {
            return ResponseValue.error("参数不能为空!");
        }
        return ResponseValue.success(baseGoodsModelsService.queryGoodsModelInfo(baseGoodsModelsId));
    }
}