瀏覽代碼

getallscene

lyhzzz 3 月之前
父節點
當前提交
8366e076d3

+ 30 - 4
src/main/java/com/fdkankan/manage/controller/inner/InnerAPIController.java

@@ -45,6 +45,8 @@ public class InnerAPIController extends BaseController {
     IJySceneAuthService jySceneAuthService;
     @Autowired
     ManageConfig manageConfig;
+    @Autowired
+    ISysUserService sysUserService;
 
     @PostMapping("/getByRyId")
     public ResultData getByRyId(@RequestBody UserParam param){
@@ -213,17 +215,41 @@ public class InnerAPIController extends BaseController {
         if(jyUser == null){
             throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
         }
+        SysUser sysUser = sysUserService.getById(jyUser.getSysUserId());
+        if(sysUser == null){
+            throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
+        }
+
         AllShareParam allShareParam = new AllShareParam();
-        allShareParam.getUserIds().add(jyUser.getId());
+        if(jyUser.getPlatformId() !=null   && (sysUser.getRoleId() == 45L || sysUser.getRoleId() == 48L)){
+            allShareParam.setPlatformId(jyUser.getPlatformId());
+        }else {
+            allShareParam.setUserId(jyUser.getId());
+        }
+
         //设置全局公开场景
         if(!manageConfig.getNumList().isEmpty()){
-            param.getAuthNumList().addAll(manageConfig.getNumList());
+            allShareParam.getNumList().addAll(manageConfig.getNumList());
         }
 
         //获取分享主用户
         List<JyUserShare> jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId());
-        if(!jyUserShares.isEmpty()){
-            jyUserShares.forEach(e -> allShareParam.getUserIds().add(e.getMainJyUserId()));
+        List<Integer> mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList());
+        HashMap<Integer,Long> roleMap = new HashMap<>();
+        if(!mainUserIds.isEmpty()){
+            List<JyUser> jyUsers = jyUserService.listByIds(mainUserIds);
+            Set<Long> sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet());
+            HashMap<Long, SysUser> byIds = sysUserService.getByIds(sysIds);
+            jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId()));
+
+            for (JyUser user : jyUsers) {
+                Long roleId = roleMap.get(user.getId());
+                if(user.getPlatformId() != null && (roleId == 45L || roleId == 48L)){
+                    allShareParam.getOtherPlatformIds().add(user.getPlatformId());
+                }else {
+                    allShareParam.getOtherUserIds().add(user.getId());
+                }
+            }
         }
         //获取本平台公开场景
         List<String> openNums = jySceneAuthService.getNumListByPlatform(jyUser.getPlatformId(),1);

+ 5 - 1
src/main/java/com/fdkankan/manage/vo/request/AllShareParam.java

@@ -8,7 +8,11 @@ import java.util.List;
 @Data
 public class AllShareParam extends RequestBase {
 
-    private List<Integer> userIds = new ArrayList<>();
+    private Integer userId;
+    private Integer platformId;
+    private List<Integer> otherUserIds = new ArrayList<>();
+    private List<Integer> otherPlatformIds = new ArrayList<>();
+
 
     private List<String> numList = new ArrayList<>();
 }

+ 19 - 11
src/main/resources/mapper/manage/ScenePlusMapper.xml

@@ -89,26 +89,34 @@
         left join  t_scene_plus_ext e on s.id = e.plus_id
         left join jy_user ju on s.user_id = ju.user_id
         where s.rec_status = 'A' and (s.scene_source not in (4,5) or ( s.scene_source in (4,5) and e.is_obj =1))
+          <if test="param.userId != null">
+              and ( ju.id = #{param.userId}
+          </if>
+        <if test="param.platformId != null">
+            and ( ju.platform_id = #{param.platformId}
+        </if>
 
-        <if test="param.userIds != null and param.userIds.size >0 and param.numList != null and param.numList.size >0">
-            and (ju.id in
-            <foreach collection="param.userIds" item="userId" open="(" separator="," close=")">
+        <if test="param.otherUserIds != null and param.otherUserIds.size >0">
+            or ju.id in
+            <foreach collection="param.otherUserIds" item="userId" open="(" separator="," close=")">
                 #{userId}
             </foreach>
+        </if>
+        <if test="param.otherPlatformIds != null and param.otherPlatformIds.size >0">
+            or ju.platform_id in
+            <foreach collection="param.otherPlatformIds" item="platformId" open="(" separator="," close=")">
+                #{platformId}
+            </foreach>
+        </if>
+
+        <if test="param.numList != null and param.numList.size >0">
             or s.num in
             <foreach collection="param.numList" item="num" open="(" separator="," close=")">
                 #{num}
             </foreach>
-            )
         </if>
 
-        <if test="param.userIds != null and param.userIds.size >0 and param.numList != null and param.numList.size ==0">
-            and ju.id in
-            <foreach collection="param.userIds" item="userId" open="(" separator="," close=")">
-                #{userId}
-            </foreach>
-
-        </if>
+        )
         order by s.create_time desc ,s.id desc
 
     </select>