From 0d0ac7a4635dff1efdc3eaea5c7e0a5378106e07 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Thu, 6 Jun 2024 10:20:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=A9=E6=96=99=E5=8C=85?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sqx/modules/material/entity/Material.java | 2 ++ .../service/impl/MaterialServiceImpl.java | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sqx/modules/material/entity/Material.java b/src/main/java/com/sqx/modules/material/entity/Material.java index c108f67..2102b56 100644 --- a/src/main/java/com/sqx/modules/material/entity/Material.java +++ b/src/main/java/com/sqx/modules/material/entity/Material.java @@ -1,6 +1,7 @@ package com.sqx.modules.material.entity; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -12,6 +13,7 @@ import java.util.Date; /** * 物料包表 */ +@TableName(value ="material") @Data public class Material implements Serializable { private String id; diff --git a/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java b/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java index e2e09e2..121a6d9 100644 --- a/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java +++ b/src/main/java/com/sqx/modules/material/service/impl/MaterialServiceImpl.java @@ -82,7 +82,7 @@ public class MaterialServiceImpl extends ServiceImpl i materialQueryWrapper.eq("goods_id", material.getGoodsId()); // 根据查询封装器查询物料按摩信息 Material materials = baseMapper.selectOne(materialQueryWrapper); - if(!materials.getId().equals(material.getId()) ){ + if(materials!=null && !materials.getId().equals(material.getId()) ){ return Result.error("当前商品已绑定物料包,请重新选择!"); } return Result.success().put("data",materialMapper.insertIgnoreNull(material)); @@ -106,14 +106,14 @@ public class MaterialServiceImpl extends ServiceImpl i */ public Result updateIgnoreNull(Material material) { material.setUpdateTime(new Date()); - QueryWrapper materialQueryWrapper = new QueryWrapper(); - // 设置查询条件,根据物料ID查询物料按摩信息 - materialQueryWrapper.eq("goods_id", material.getGoodsId()); - // 根据查询封装器查询物料按摩信息 - Material materials = baseMapper.selectOne(materialQueryWrapper); - if(ObjectUtil.isNotEmpty(materials) && !materials.getId().equals(material.getId()) ){ - return Result.error("当前商品已绑定物料包,请重新选择!"); - } +// QueryWrapper materialQueryWrapper = new QueryWrapper(); +// // 设置查询条件,根据物料ID查询物料按摩信息 +// materialQueryWrapper.eq("goods_id", material.getGoodsId()); +// // 根据查询封装器查询物料按摩信息 +// Material materials = baseMapper.selectOne(materialQueryWrapper); +// if(ObjectUtil.isNotEmpty(materials) && !materials.getId().equals(material.getId()) ){ +// return Result.error("当前商品已绑定物料包,请重新选择!"); +// } return Result.success().put("data",materialMapper.updateIgnoreNull(material)); }