From 98b3bb213bff867611012dee5548c568fd64d55e Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 19 Sep 2022 16:25:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83):=20=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AC=AC=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=B8=A0=E9=81=93=E5=9C=A8=E6=9C=AA=E9=85=8D=E7=BD=AE=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E7=8A=B6=E6=80=81=E4=B9=9F=E8=83=BD=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/sys/MsgController.java | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/sys/MsgController.java b/backend/src/main/java/io/dataease/controller/sys/MsgController.java index 5cadd80227..e7f8cc5cf9 100644 --- a/backend/src/main/java/io/dataease/controller/sys/MsgController.java +++ b/backend/src/main/java/io/dataease/controller/sys/MsgController.java @@ -3,6 +3,7 @@ package io.dataease.controller.sys; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.auth.service.AuthUserService; import io.dataease.plugins.common.base.domain.SysMsgChannel; import io.dataease.plugins.common.base.domain.SysMsgSetting; import io.dataease.plugins.common.base.domain.SysMsgType; @@ -19,9 +20,11 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.ObjectUtils; import org.springframework.web.bind.annotation.*; + import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; + import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -34,17 +37,20 @@ public class MsgController { @Resource private SysMsgService sysMsgService; + @Resource + private AuthUserService authUserService; + @ApiOperation("分页查询") @PostMapping("/list/{goPage}/{pageSize}") @ApiImplicitParams({ - @ApiImplicitParam(paramType="path", name = "goPage", value = "页码", required = true, dataType = "Integer"), - @ApiImplicitParam(paramType="path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"), - @ApiImplicitParam(name = "msgRequest", value = "查询条件", required = true) + @ApiImplicitParam(paramType = "path", name = "goPage", value = "页码", required = true, dataType = "Integer"), + @ApiImplicitParam(paramType = "path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "msgRequest", value = "查询条件", required = true) }) public Pager> messages(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody MsgRequest msgRequest) { Long userId = AuthUtils.getUser().getUserId(); List typeIds = null; - if (ObjectUtils.isNotEmpty(msgRequest.getType())){ + if (ObjectUtils.isNotEmpty(msgRequest.getType())) { List sysMsgTypes = sysMsgService.queryMsgTypes(); typeIds = sysMsgTypes.stream().filter(sysMsgType -> msgRequest.getType() == sysMsgType.getPid()).map(SysMsgType::getMsgTypeId).collect(Collectors.toList()); } @@ -56,9 +62,10 @@ public class MsgController { @ApiOperation("查询未读数量") @PostMapping("/unReadCount") - public Long unReadCount() {; + public Long unReadCount() { + ; Long userId = null; - if(null == AuthUtils.getUser() || (userId = AuthUtils.getUser().getUserId()) == null) { + if (null == AuthUtils.getUser() || (userId = AuthUtils.getUser().getUserId()) == null) { throw new RuntimeException("缺少用户ID"); } return sysMsgService.queryCount(userId); @@ -66,7 +73,7 @@ public class MsgController { @ApiOperation("设置已读") @PostMapping("/setReaded/{msgId}") - @ApiImplicitParam(paramType="path", name = "msgId", value = "消息ID", required = true, dataType = "Long") + @ApiImplicitParam(paramType = "path", name = "msgId", value = "消息ID", required = true, dataType = "Long") public void setReaded(@PathVariable Long msgId) { sysMsgService.setReaded(msgId); } @@ -109,7 +116,21 @@ public class MsgController { @ApiOperation("查询渠道") @PostMapping("/channelList") public List channelList() { - return sysMsgService.channelList(); + List sysMsgChannels = sysMsgService.channelList(); + if (ObjectUtils.isEmpty(sysMsgChannels)) return sysMsgChannels; + return sysMsgChannels.stream().filter(channel -> { + Long msgChannelId = channel.getMsgChannelId(); + if (msgChannelId == 3L) { + return authUserService.supportWecom(); + } + if (msgChannelId == 4L) { + return authUserService.supportDingtalk(); + } + if (msgChannelId == 5L) { + return authUserService.supportLark(); + } + return true; + }).collect(Collectors.toList()); } @ApiOperation("查询订阅")