From 2100145b0a7fd4932dbb1757db4369e91f9e96eb Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Thu, 18 Nov 2021 22:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=9F=E6=88=B7=E3=80=81?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=20ID=20=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/biz/impl/ItemServiceImpl.java | 13 ++++++++++--- .../service/biz/impl/TenantServiceImpl.java | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ItemServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ItemServiceImpl.java index 90c1a56b..1ae40ff2 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ItemServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ItemServiceImpl.java @@ -1,5 +1,6 @@ package cn.hippo4j.config.service.biz.impl; +import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.config.enums.DelEnum; import cn.hippo4j.config.mapper.ItemInfoMapper; import cn.hippo4j.config.model.ItemInfo; @@ -7,16 +8,16 @@ import cn.hippo4j.config.model.biz.item.ItemQueryReqDTO; import cn.hippo4j.config.model.biz.item.ItemRespDTO; import cn.hippo4j.config.model.biz.item.ItemSaveReqDTO; import cn.hippo4j.config.model.biz.item.ItemUpdateReqDTO; +import cn.hippo4j.config.model.biz.threadpool.ThreadPoolRespDTO; import cn.hippo4j.config.service.biz.ItemService; +import cn.hippo4j.config.service.biz.ThreadPoolService; +import cn.hippo4j.config.toolkit.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; -import cn.hippo4j.config.model.biz.threadpool.ThreadPoolRespDTO; -import cn.hippo4j.config.service.biz.ThreadPoolService; -import cn.hippo4j.config.toolkit.BeanUtil; import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -73,6 +74,12 @@ public class ItemServiceImpl implements ItemService { @Override public void saveItem(ItemSaveReqDTO reqDTO) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(ItemInfo.class) + .eq(ItemInfo::getItemId, reqDTO.getItemId()); + + ItemInfo existItemInfo = itemInfoMapper.selectOne(queryWrapper); + Assert.isNull(existItemInfo, "项目 ID 不允许重复."); + ItemInfo itemInfo = BeanUtil.convert(reqDTO, ItemInfo.class); int insertResult = itemInfoMapper.insert(itemInfo); diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/TenantServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/TenantServiceImpl.java index 1b5db829..2d446ffc 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/TenantServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/TenantServiceImpl.java @@ -1,24 +1,25 @@ package cn.hippo4j.config.service.biz.impl; +import cn.hippo4j.common.toolkit.Assert; import cn.hippo4j.config.enums.DelEnum; import cn.hippo4j.config.mapper.TenantInfoMapper; import cn.hippo4j.config.model.TenantInfo; import cn.hippo4j.config.model.biz.item.ItemQueryReqDTO; import cn.hippo4j.config.model.biz.item.ItemRespDTO; import cn.hippo4j.config.model.biz.tenant.TenantQueryReqDTO; +import cn.hippo4j.config.model.biz.tenant.TenantRespDTO; import cn.hippo4j.config.model.biz.tenant.TenantSaveReqDTO; +import cn.hippo4j.config.model.biz.tenant.TenantUpdateReqDTO; import cn.hippo4j.config.service.biz.ItemService; +import cn.hippo4j.config.service.biz.TenantService; +import cn.hippo4j.config.toolkit.BeanUtil; +import cn.hippo4j.tools.logrecord.annotation.LogRecord; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; -import cn.hippo4j.config.model.biz.tenant.TenantRespDTO; -import cn.hippo4j.config.model.biz.tenant.TenantUpdateReqDTO; -import cn.hippo4j.config.service.biz.TenantService; -import cn.hippo4j.config.toolkit.BeanUtil; -import cn.hippo4j.tools.logrecord.annotation.LogRecord; import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -67,6 +68,12 @@ public class TenantServiceImpl implements TenantService { @Override public void saveTenant(TenantSaveReqDTO reqDTO) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(TenantInfo.class) + .eq(TenantInfo::getTenantId, reqDTO.getTenantId()); + + TenantInfo existTenantInfo = tenantInfoMapper.selectOne(queryWrapper); + Assert.isNull(existTenantInfo, "租户 ID 不允许重复."); + TenantInfo tenantInfo = BeanUtil.convert(reqDTO, TenantInfo.class); int insertResult = tenantInfoMapper.insert(tenantInfo);