|
|
@@ -135,10 +135,28 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
throw new RuntimeException("品牌名称错误或品牌不存在");
|
|
|
}
|
|
|
}
|
|
|
+ Integer count = baseMapper.selectCount(Wrappers.<PjGoodsDesc>lambdaQuery()
|
|
|
+ .eq(PjGoodsDesc::getCode, goodsDesc.getCode())
|
|
|
+ .eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ Integer countName = baseMapper.selectCount(Wrappers.<PjGoodsDesc>lambdaQuery()
|
|
|
+ .eq(PjGoodsDesc::getCname, goodsDesc.getCname())
|
|
|
+ .eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+
|
|
|
if (ObjectUtils.isNull(goodsDesc.getCnameInt())) {
|
|
|
goodsDesc.setCnameInt(getCnameInt(goodsDesc.getCname()));
|
|
|
}
|
|
|
if (goodsDesc.getId() == null) {
|
|
|
+ if (count > 0) {
|
|
|
+ throw new ServiceException("编码已存在");
|
|
|
+ }
|
|
|
+ if (countName > 0) {
|
|
|
+ throw new ServiceException("名称已存在");
|
|
|
+ }
|
|
|
goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
goodsDesc.setCreateTime(new Date());
|
|
|
goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
@@ -151,6 +169,12 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, PjGoodsDe
|
|
|
goodsDesc.setEnableOrNot(1);
|
|
|
baseMapper.insert(goodsDesc);
|
|
|
} else {
|
|
|
+ if (count > 1) {
|
|
|
+ throw new ServiceException("编码已存在");
|
|
|
+ }
|
|
|
+ if (countName > 1) {
|
|
|
+ throw new ServiceException("名称已存在");
|
|
|
+ }
|
|
|
goodsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
goodsDesc.setUpdateTime(new Date());
|
|
|
goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|