Quellcode durchsuchen

批量查询canshow

lyhzzz vor 3 Jahren
Ursprung
Commit
7b90f00bac

+ 14 - 7
platform-common/src/main/java/com/platform/controller/ZfbController.java

@@ -1,11 +1,14 @@
 package com.platform.controller;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.platform.entity.Result;
 import com.platform.entity.SysUserBrand;
 import com.platform.service.custom.MySysUserBrandService;
 import com.platform.service.impl.ZhiHouseService;
 import com.platform.vos.TbUser;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.bytedeco.javacpp.presets.opencv_core;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
@@ -44,14 +47,18 @@ public class ZfbController {
         return Result.success();
     }
     @PostMapping("/getCanShow")
-    public Result getCanShow(@RequestBody HashMap<String,Long> param) {
-        Long userId = param.get("userId");
-        Integer brandId = Math.toIntExact(param.get("brandId"));
-        SysUserBrand userBrandById = mySysUserBrandService.getUserBrandById(userId, brandId);
-        if(userBrandById == null){
-            return Result.failure("暂无数据");
+    public Result getCanShow(@RequestBody JSONObject param) {
+        Object userIds = param.get("userIds");
+        List<Integer> jsonArray = (List<Integer>) userIds;
+        Integer brandId = (Integer) param.get("brandId");
+        HashMap<Long,Integer> resultMap = new HashMap<>();
+        for (Integer userId : jsonArray) {
+            SysUserBrand userBrand = mySysUserBrandService.getUserBrandById(Long.valueOf(userId), brandId);
+            if(userBrand!=null){
+                resultMap.put(userBrand.getUserId(),userBrand.getCanShow());
+            }
         }
-        return Result.success(userBrandById.getCanShow());
+        return Result.success(resultMap);
     }