فهرست منبع

分组管理数据隔离逻辑修改

jichaobo 3 سال پیش
والد
کامیت
34aa06733a

+ 1 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/SiteMapper.java

@@ -49,7 +49,7 @@ public interface SiteMapper extends CrudMapper<Site> {
                                     @Param("tenantId") Integer tenantId);
 
     List<GroupingList> GroupingListOne(@Param("name") String name,
-                                       @Param("creator") String creator,
+                                       @Param("userId") Integer userId,
                                        @Param("tenantId") Integer tenantId);
 
     List<GroupingList> GroupingListTwo(@Param("creator") String creator);

+ 28 - 18
fiveep-persistence/src/main/resources/mapper/mysql/SiteMapper.xml

@@ -185,24 +185,34 @@
     </select>
 
     <select id="GroupingListOne" resultType="com.bizmatics.model.GroupingList">
-        select
-        a.id,
-        a.grouping_name
-        from site_grouping as a
-        join site as b on a.id = b.grouping_id
-        <where>
-            <if test="name != null and name != ''">
-                and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
-            </if>
-            <if test="creator != null and creator != ''">
-                and a.creator = #{creator}
-            </if>
-            <if test="tenantId != null and tenantId != 0 and tenantId !=''">
-                and a.tenant_id = #{tenantId}
-            </if>
-            group by a.id
-            order by a.id desc
-        </where>
+        SELECT
+        *
+        FROM
+        (
+        SELECT
+        g.*, COUNT(s.id) AS sl
+        FROM
+        site_grouping AS g
+        LEFT JOIN site AS s ON g.id = s.grouping_id
+        JOIN user_site AS us ON us.site_id = s.id
+        WHERE
+        s. ENABLE = 1
+        <if test="tenantId != null and tenantId != 0 and tenantId !=''">
+            and g.tenant_id = #{tenantId}
+        </if>
+        <if test="userId != null and userId != '' and userId != 0">
+            and us.user_id = #{userId}
+        </if>
+        <if test="name != null and name != ''">
+            and s.site_name like CONCAT(CONCAT('%', #{name}), '%')
+        </if>
+        GROUP BY
+        g.id
+        ) AS a
+        WHERE
+        a.sl > 0
+        group by a.id
+        order by a.id desc;
     </select>
 
     <select id="GroupingListTwo" resultType="com.bizmatics.model.GroupingList">

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/SiteServiceImpl.java

@@ -272,7 +272,7 @@ public class SiteServiceImpl extends AbstractCrudService<SiteMapper, Site> imple
             List<GroupingList> grouping_list_one = null;
             List<GroupingList> grouping_list_two = null;
             site_list = baseMapper.Sitelist(userId, name,tenantDaya.get(0).getTenantId());
-            grouping_list_one = baseMapper.GroupingListOne(name, null,tenantDaya.get(0).getTenantId());
+            grouping_list_one = baseMapper.GroupingListOne(name, userId,tenantDaya.get(0).getTenantId());
             grouping_list_two = baseMapper.GroupingListTwo(user.getUserName());
 //            合并list
             grouping_list = Stream.of(grouping_list_one, grouping_list_two).flatMap(Collection::stream).collect(Collectors.toList());