mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-16 20:57:11 +08:00
feat: 新增 WebSocket 消息通知 (#67)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.admin.webapi.system;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
@@ -23,8 +24,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.continew.admin.common.enums.MessageTypeEnum;
|
||||
import top.continew.admin.common.util.NoticeMsgUtils;
|
||||
import top.continew.admin.common.util.WsUtils;
|
||||
import top.continew.admin.common.util.helper.LoginHelper;
|
||||
import top.continew.admin.system.model.query.MessageQuery;
|
||||
import top.continew.admin.system.model.req.MessageReq;
|
||||
import top.continew.admin.system.model.resp.MessageResp;
|
||||
import top.continew.admin.system.model.resp.MessageUnreadResp;
|
||||
import top.continew.admin.system.service.MessageService;
|
||||
@@ -34,6 +39,7 @@ import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.web.model.R;
|
||||
import top.continew.starter.log.core.annotation.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -81,4 +87,17 @@ public class MessageController {
|
||||
public R<MessageUnreadResp> countUnreadMessage(@RequestParam(required = false) Boolean detail) {
|
||||
return R.ok(messageUserService.countUnreadMessageByUserId(LoginHelper.getUserId(), detail));
|
||||
}
|
||||
|
||||
@GetMapping("/testSend")
|
||||
public R<Object> testSend(String msg) {
|
||||
List<Long> userIdList = new ArrayList<>();
|
||||
userIdList.add(LoginHelper.getUserId());
|
||||
MessageReq req = new MessageReq();
|
||||
req.setTitle(msg);
|
||||
req.setContent(msg);
|
||||
req.setType(MessageTypeEnum.SYSTEM);
|
||||
baseService.add(req, userIdList);
|
||||
WsUtils.sendToUser(LoginHelper.getUserId().toString(), NoticeMsgUtils.conversion(msg, IdUtil.fastSimpleUUID()));
|
||||
return R.ok();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user