From c1c3137524030b749f0654aa9dbb4533a8b476df Mon Sep 17 00:00:00 2001 From: bayuzhen Date: Fri, 30 Aug 2024 20:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=BF=90=E6=8E=A7=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IndexDataController.java | 6 ++++-- .../bocloud/sms/interfaces/IndexService.java | 2 +- .../bocloud/sms/service/IndexServiceImpl.java | 21 +++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java index 8f30234..1126fc5 100644 --- a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java +++ b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/IndexDataController.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -72,8 +73,9 @@ public class IndexDataController { */ @GetMapping("/userAppList") @Operation(summary = "当前用户首页数据展示模块的数据查询") - public GeneralResult userAppList(@Value(Common.REQ_CONTEXT) RequestContext requestContext) { - return indexService.userAppList(requestContext); + public GeneralResult userAppList(@Value(Common.REQ_CONTEXT) RequestContext requestContext, + @RequestParam(value = "trxToken", required = false) String trxToken) { + return indexService.userAppList(requestContext, trxToken); } /** diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java index fbb8879..a1a32c5 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/IndexService.java @@ -14,7 +14,7 @@ public interface IndexService { GeneralResult userDataStatic(RequestContext requestContext); - GeneralResult userAppList(RequestContext requestContext); + GeneralResult userAppList(RequestContext requestContext, String trxToken); GeneralResult sevenDayWarnTrend(RequestContext requestContext); diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java index e397aff..8aa37cd 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/IndexServiceImpl.java @@ -7,7 +7,9 @@ import com.bocloud.sms.entity.User; import com.bocloud.sms.enums.WarnInfo; import com.bocloud.sms.enums.YkInfo; import com.bocloud.sms.interfaces.IndexService; +import com.bocloud.sms.model.AppPerm; import com.bocloud.sms.repository.UserRepository; +import com.bocloud.sms.service.utils.QxUtils; import com.bocloud.sms.utils.WarnUtil; import com.bocloud.sms.utils.YkUtil; import com.megatron.common.model.GeneralResult; @@ -32,6 +34,8 @@ public class IndexServiceImpl implements IndexService { private UserRepository userRepository; @Autowired private WarnUtil warnUtil; + @Autowired + private QxUtils qxUtils; @Override public GeneralResult doneWorkOrder(Pager pager, RequestContext requestContext) { @@ -114,7 +118,7 @@ public class IndexServiceImpl implements IndexService { } @Override - public GeneralResult userAppList(RequestContext requestContext) { + public GeneralResult userAppList(RequestContext requestContext, String trxToken) { try { //获取所有的appList @@ -127,9 +131,18 @@ public class IndexServiceImpl implements IndexService { JSONObject allAppJson = JSONObject.parseObject(result, JSONObject.class); List allAppList = JSONObject.parseObject(allAppJson.getString("list"), List.class); log.info("allAppList:{}", JSON.toJSONString(allAppList)); - List userAppList = getUserAppList(requestContext); - log.info("userAppList:{}", JSON.toJSONString(userAppList)); - List appIdList = userAppList.stream().map(jsonObject -> jsonObject.getString("appId")).collect(Collectors.toList()); + +// List userAppList = getUserAppList(requestContext); +// log.info("userAppList:{}", JSON.toJSONString(userAppList)); +// List appIdList = userAppList.stream().map(jsonObject -> jsonObject.getString("appId")).collect(Collectors.toList()); + + // 调用权限系统接口 + User user = userRepository.query(requestContext.getTarget()); + log.info("user:{}", JSON.toJSONString(user)); + List permList = JSONArray.parseArray(qxUtils.queryApp(trxToken, user.getUserId()), AppPerm.class); + List appIdList = permList.stream() + .map(AppPerm::getId) + .collect(Collectors.toList()); log.info("appIdList:{}", JSON.toJSONString(appIdList)); for (JSONObject data : allAppList) { if (appIdList.contains(data.getString("appId"))) {