Prechádzať zdrojové kódy

Merge branch 'system-zyj' of uskycloud/usky-cloud into master

hanzhengyi 13 hodín pred
rodič
commit
bb738b6c2f

+ 3 - 2
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysConfigController.java

@@ -64,12 +64,12 @@ public class SysConfigController extends BaseController
     @PostMapping
     public ApiResult add(@Validated @RequestBody SysConfig config)
     {
+        config.setCreateBy(SecurityUtils.getUsername());
+        config.setTenantId(SecurityUtils.getTenantId());
         if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
         {
             return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
         }
-        config.setCreateBy(SecurityUtils.getUsername());
-        config.setTenantId(SecurityUtils.getTenantId());
         return toAjax(configService.insertConfig(config));
     }
 
@@ -80,6 +80,7 @@ public class SysConfigController extends BaseController
     @PutMapping
     public ApiResult edit(@Validated @RequestBody SysConfig config)
     {
+        config.setTenantId(SecurityUtils.getTenantId());
         if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
         {
             return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "修改参数'" + config.getConfigName() + "'失败,参数键名已存在");

+ 1 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysConfigMapper.java

@@ -38,7 +38,7 @@ public interface SysConfigMapper extends CrudMapper<SysConfig>
      * @param configKey 参数键名
      * @return 参数配置信息
      */
-    public SysConfig checkConfigKeyUnique(@Param("configKey") String configKey);
+    public SysConfig checkConfigKeyUnique(@Param("configKey") String configKey, @Param("tenantId") Integer tenantId);
 
     /**
      * 新增参数配置

+ 1 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysConfigServiceImpl.java

@@ -214,7 +214,7 @@ public class SysConfigServiceImpl extends AbstractCrudService<SysConfigMapper, S
     public String checkConfigKeyUnique(SysConfig config)
     {
         Long configId = Objects.isNull(config.getConfigId()) ? -1L : config.getConfigId();
-        SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
+        SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey(), config.getTenantId());
         if (Objects.nonNull(info) && info.getConfigId().longValue() != configId.longValue())
         {
             return UserConstants.NOT_UNIQUE;

+ 5 - 1
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysConfigMapper.xml

@@ -64,7 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
         <include refid="selectConfigVo"/>
-        where config_key = #{configKey} limit 1
+        where config_key = #{configKey}
+        <if test="tenantId != null and tenantId != '' and tenantId != 0">
+            AND tenant_id = #{tenantId}
+        </if>
+        limit 1
     </select>
     
     <insert id="insertConfig" parameterType="com.usky.system.domain.SysConfig">