Pārlūkot izejas kodu

Merge branch 'master' of http://49.233.37.222:3000/wjm/mec-cloud_IntelligentManufacturing_CRM

lph 1 gadu atpakaļ
vecāks
revīzija
32028d7ba1

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java

@@ -42,6 +42,9 @@ public class SysPostController extends BaseController
     public TableDataInfo list(SysPost post)
     {
         startPage();
+        if(getLoginUser().isTenantAdmin()){
+            post.setTenantId(getTenantId());
+        }
         List<SysPost> list = postService.selectPostList(post);
         return getDataTable(list);
     }
@@ -74,6 +77,7 @@ public class SysPostController extends BaseController
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysPost post)
     {
+        post.setTenantId(getTenantId());
         if (!postService.checkPostNameUnique(post))
         {
             return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -108,7 +108,7 @@ public class SysUserController extends BaseController
         AjaxResult ajax = AjaxResult.success();
         List<SysRole> roles = roleService.selectRoleAll();
         ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin() && r.getTenantId() == getTenantId()).collect(Collectors.toList()));
-        ajax.put("posts", postService.selectPostAll());
+        ajax.put("posts", postService.selectPostAll().stream().filter(p -> p.getTenantId() == getTenantId()).collect(Collectors.toList()));
         if (StringUtils.isNotNull(userId))
         {
             SysUser sysUser = userService.selectUserById(userId);

+ 13 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java

@@ -41,6 +41,9 @@ public class SysPost extends BaseEntity
     /** 用户是否存在此岗位标识 默认不存在 */
     private boolean flag = false;
 
+    /** 租户ID */
+    private Long tenantId;
+
     public Long getPostId()
     {
         return postId;
@@ -105,7 +108,15 @@ public class SysPost extends BaseEntity
     {
         this.flag = flag;
     }
-    
+
+    public Long getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Long tenantId) {
+        this.tenantId = tenantId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -119,6 +130,7 @@ public class SysPost extends BaseEntity
             .append("updateBy", getUpdateBy())
             .append("updateTime", getUpdateTime())
             .append("remark", getRemark())
+            .append("tenantId",getTenantId())
             .toString();
     }
 }

+ 3 - 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
 
 import java.util.List;
 import com.ruoyi.system.domain.SysPost;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 岗位信息 数据层
@@ -87,7 +88,7 @@ public interface SysPostMapper
      * @param postName 岗位名称
      * @return 结果
      */
-    public SysPost checkPostNameUnique(String postName);
+    public SysPost checkPostNameUnique(@Param("postName") String postName,@Param("tenantId") Long tenantId);
 
     /**
      * 校验岗位编码
@@ -95,5 +96,5 @@ public interface SysPostMapper
      * @param postCode 岗位编码
      * @return 结果
      */
-    public SysPost checkPostCodeUnique(String postCode);
+    public SysPost checkPostCodeUnique(@Param("postCode") String postCode,@Param("tenantId") Long tenantId);
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java

@@ -72,7 +72,7 @@ public interface SysRoleMapper {
      * @param roleKey 角色权限
      * @return 角色信息
      */
-    public SysRole checkRoleKeyUnique(String roleKey);
+    public SysRole checkRoleKeyUnique(@Param("roleKey") String roleKey, @Param("tenantId") String tenantId);
 
     /**
      * 修改角色信息

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java

@@ -82,7 +82,7 @@ public class SysPostServiceImpl implements ISysPostService
     public boolean checkPostNameUnique(SysPost post)
     {
         Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
-        SysPost info = postMapper.checkPostNameUnique(post.getPostName());
+        SysPost info = postMapper.checkPostNameUnique(post.getPostName(),post.getTenantId());
         if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
         {
             return UserConstants.NOT_UNIQUE;
@@ -100,7 +100,7 @@ public class SysPostServiceImpl implements ISysPostService
     public boolean checkPostCodeUnique(SysPost post)
     {
         Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
-        SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
+        SysPost info = postMapper.checkPostCodeUnique(post.getPostCode(),post.getTenantId());
         if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
         {
             return UserConstants.NOT_UNIQUE;

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

@@ -153,7 +153,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
     @Override
     public boolean checkRoleKeyUnique(SysRole role) {
         Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
-        SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
+        SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey(), role.getTenantId().toString());
         if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }

+ 12 - 5
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml

@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="updateBy"      column="update_by"     />
 		<result property="updateTime"    column="update_time"   />
 		<result property="remark"        column="remark"        />
+		<result property="tenantId"      column="tenant_id"/>
 	</resultMap>
 	
 	<sql id="selectPostVo">
-        select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark 
+        select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark ,tenant_id
 		from sys_post
     </sql>
 	
@@ -34,6 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="postName != null and postName != ''">
 				AND post_name like concat('%', #{postName}, '%')
 			</if>
+			<if test="tenantId != null">
+				AND tenant_id = #{tenantId}
+			</if>
 		</where>
 	</select>
 	
@@ -62,14 +66,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where u.user_name = #{userName}
 	</select>
 	
-	<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
+	<select id="checkPostNameUnique" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
-		 where post_name=#{postName} limit 1
+		 where post_name= #{postName} and tenant_id = #{tenantId} limit 1
 	</select>
 	
-	<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
+	<select id="checkPostCodeUnique" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
-		 where post_code=#{postCode} limit 1
+		 where post_code= #{postCode} and tenant_id = #{tenantId} limit 1
 	</select>
 	
 	<update id="updatePost" parameterType="SysPost">
@@ -79,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="postName != null and postName != ''">post_name = #{postName},</if>
  			<if test="postSort != null">post_sort = #{postSort},</if>
  			<if test="status != null and status != ''">status = #{status},</if>
+ 		    <if test="tenantId != null">tenant_id = #{tenantId},</if>
  			<if test="remark != null">remark = #{remark},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			update_time = sysdate()
@@ -93,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="postName != null and postName != ''">post_name,</if>
  			<if test="postSort != null">post_sort,</if>
  			<if test="status != null and status != ''">status,</if>
+ 			<if test="tenantId != null">tenant_id,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			create_time
@@ -102,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="postName != null and postName != ''">#{postName},</if>
  			<if test="postSort != null">#{postSort},</if>
  			<if test="status != null and status != ''">#{status},</if>
+ 		    <if test="tenantId != null">#{tenantId},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			sysdate()

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	
 	<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
 		<include refid="selectRoleVo"/>
-		 where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
+		 where r.role_key=#{roleKey} and r.del_flag = '0' and r.tenant_id = #{tenantId} limit 1
 	</select>
 	
  	<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">

+ 6 - 0
ruoyi-system/src/main/resources/sql/initialize_sys_tenant_menu.sql

@@ -3,6 +3,7 @@
 101
 102
 103
+104
 1000
 1001
 1002
@@ -19,6 +20,11 @@
 1017
 1018
 1019
+1020
+1021
+1022
+1023
+1024
 1073
 1078
 1082