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("查询订阅")