新增消息提醒资源接口

This commit is contained in:
wanggeng 2021-11-01 11:24:14 +08:00
parent d27caef780
commit 9d64a329a7
3 changed files with 61 additions and 3 deletions

View File

@ -0,0 +1,47 @@
package ink.wgink.module.instantmessage.controller.resources;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.instantmessage.pojo.vos.NoticeSendVO;
import ink.wgink.module.instantmessage.service.IMessageService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: MessageController
* @Description: 消息
* @Author: wanggeng
* @Date: 2021/1/14 3:25 下午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "消息接口")
@RestController
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/websocket/message")
public class WebSocketMessageResourceController extends DefaultBaseController {
@Autowired
private IMessageService messageService;
@ApiOperation(value = "通知消息", notes = "通知消息接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", required = true),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("notice")
@CheckRequestBodyAnnotation
public SuccessResult notice(@RequestBody NoticeSendVO noticeSendVO) throws Exception {
messageService.notice(noticeSendVO);
return new SuccessResult();
}
}

View File

@ -14,13 +14,15 @@ import io.swagger.annotations.ApiModelProperty;
@ApiModel
public class NoticeSendVO {
@ApiModelProperty(name = "noticeTitle", value = "通知标题")
@ApiModelProperty(name = "noticeTitle", value = "通知标题", required = true)
@CheckEmptyAnnotation(name = "通知标题")
private String noticeTitle;
@ApiModelProperty(name = "noticeMsg", value = "通知内容")
@ApiModelProperty(name = "noticeMsg", value = "通知内容", required = true)
@CheckEmptyAnnotation(name = "通知内容")
private String noticeMsg;
@ApiModelProperty(name = "noticeUserIds", value = "通知用户ID列表")
@ApiModelProperty(name = "noticeTarget", value = "通知目标")
private String noticeTarget;
@ApiModelProperty(name = "noticeUserIds", value = "通知用户ID列表下划线分割", required = true)
@CheckEmptyAnnotation(name = "通知用户ID列表")
private String noticeUserIds;
@ -40,6 +42,14 @@ public class NoticeSendVO {
this.noticeMsg = noticeMsg;
}
public String getNoticeTarget() {
return noticeTarget == null ? "" : noticeTarget.trim();
}
public void setNoticeTarget(String noticeTarget) {
this.noticeTarget = noticeTarget;
}
public String getNoticeUserIds() {
return noticeUserIds == null ? "" : noticeUserIds.trim();
}

View File

@ -58,6 +58,7 @@ public class MessageServiceImpl extends DefaultBaseService implements IMessageSe
notice.setMsg(noticeSendVO.getNoticeMsg());
notice.setServiceId("IM_NOTICE:" + UUIDUtil.getUUID());
notice.setSystem("IM");
notice.setTarget(noticeSendVO.getNoticeTarget());
notice.setUserIds(Arrays.asList(noticeSendVO.getNoticeUserIds().split("\\_")));
List<NoticeVO.Notice> notices = new ArrayList<>();