浏览代码

新增数据权限过滤功能

oyq28 3 年之前
父节点
当前提交
486461d791

+ 14 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/classSchedule/service/impl/ScheduleUserDateServiceImpl.java

@@ -1,7 +1,9 @@
 package com.github.zuihou.business.classSchedule.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
+import com.github.zuihou.authority.service.auth.UserService;
 import com.github.zuihou.business.classSchedule.dao.ScheduleUserDateMapper;
 import com.github.zuihou.business.classSchedule.dto.ScheduleUserDateSaveDTO;
 import com.github.zuihou.business.classSchedule.entity.ScheduleUserDate;
@@ -12,6 +14,8 @@ import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -34,6 +38,8 @@ import static com.github.zuihou.utils.BizAssert.isFalse;
 @Service
 public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDateMapper, ScheduleUserDate> implements ScheduleUserDateService {
 
+    @Autowired
+    private UserService userService;
 
     @Override
     public  Map<String,Object>  pageList(Map<String, String> map) {
@@ -177,6 +183,14 @@ public class ScheduleUserDateServiceImpl extends SuperServiceImpl<ScheduleUserDa
         if(StrUtil.isNotEmpty(deptId)){
             sql += " and u.org_id = '"+deptId+"'";
         }
+        BaseContextHandler.setTenant("0000");
+        Long uid = BaseContextHandler.getUserId();
+        Map<String, Object> orgMap = userService.getDataScopeById(uid);
+        List<Long> orgIds = orgMap.containsKey("orgIds")? (List)orgMap.get("orgIds") : Lists.newArrayList();
+        if(CollectionUtil.isNotEmpty(orgIds)){
+            String strIds = CollectionUtil.join(orgIds, ",");
+            sql += " and u.org_id in ("+strIds+")";
+        }
         return sql;
     }