Browse Source

字典管理管理添加租户概念(刷新缓存尚未更改)

jichaobo 2 years ago
parent
commit
9df2869a44

+ 1 - 0
service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysDictTypeController.java

@@ -54,6 +54,7 @@ public class SysDictTypeController extends BaseController
         {
             return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
         }
+        dict.setTenantId(SecurityUtils.getTenantId());
         dict.setCreateBy(SecurityUtils.getUsername());
         return toAjax(dictTypeService.insertDictType(dict));
     }

+ 13 - 0
service-system/service-system-biz/src/main/java/com/usky/system/domain/SysDictType.java

@@ -30,6 +30,19 @@ public class SysDictType extends BaseEntity
     /** 状态(0正常 1停用) */
     private String status;
 
+    /** 租户ID */
+    private Integer tenantId;
+
+    public Integer getTenantId()
+    {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId)
+    {
+        this.tenantId = tenantId;
+    }
+
     public Long getDictId()
     {
         return dictId;

+ 1 - 1
service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysDictTypeMapper.java

@@ -85,5 +85,5 @@ public interface SysDictTypeMapper extends CrudMapper<SysDictType>
      * @param dictType 字典类型
      * @return 结果
      */
-    public SysDictType checkDictTypeUnique(String dictType);
+    public SysDictType checkDictTypeUnique(String dictType,Integer tenantId);
 }

+ 3 - 1
service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysDictTypeServiceImpl.java

@@ -2,6 +2,7 @@ package com.usky.system.service.impl;
 
 
 
+import com.ruoyi.common.security.utils.SecurityUtils;
 import com.usky.common.core.exception.BusinessException;
 import com.usky.common.mvc.base.AbstractCrudService;
 import com.usky.system.domain.SysDictData;
@@ -52,6 +53,7 @@ public class SysDictTypeServiceImpl extends AbstractCrudService<SysDictTypeMappe
     @Override
     public List<SysDictType> selectDictTypeList(SysDictType dictType)
     {
+        dictType.setTenantId(SecurityUtils.getTenantId());
         return dictTypeMapper.selectDictTypeList(dictType);
     }
 
@@ -215,7 +217,7 @@ public class SysDictTypeServiceImpl extends AbstractCrudService<SysDictTypeMappe
     public String checkDictTypeUnique(SysDictType dict)
     {
         Long dictId = null == dict.getDictId() ? -1L : dict.getDictId();
-        SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
+        SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType(),SecurityUtils.getTenantId());
         if (Objects.nonNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
         {
             return UserConstants.NOT_UNIQUE;

+ 11 - 1
service-system/service-system-biz/src/main/resources/mapper/system/SysDictTypeMapper.xml

@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="createTime" column="create_time" />
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
+		<result property="tenantId" column="tenant_id" />
 	</resultMap>
 	
 	<sql id="selectDictTypeVo">
@@ -32,6 +33,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="dictType != null and dictType != ''">
 				AND dict_type like concat('%', #{dictType}, '%')
 			</if>
+			<if test="tenantId != null and tenantId != '' and tenantId !=0">
+				AND tenant_id = #{tenantId}
+			</if>
 			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
 				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
 			</if>
@@ -57,7 +61,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
 		<include refid="selectDictTypeVo"/>
-		where dict_type = #{dictType} limit 1
+		where dict_type = #{dictType}
+		<if test="tenantId != null and tenantId != '' and tenantId !=0">
+			AND tenant_id = #{tenantId}
+		</if>
+		limit 1
 	</select>
 	
 	<delete id="deleteDictTypeById" parameterType="Long">
@@ -91,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null">status,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
+			<if test="tenantId != null and tenantId != '' and tenantId !=0">tenant_id,</if>
  			create_time
  		)values(
  			<if test="dictName != null and dictName != ''">#{dictName},</if>
@@ -98,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null">#{status},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			<if test="tenantId != null and tenantId != '' and tenantId !=0">#{tenantId},</if>
  			sysdate()
  		)
 	</insert>