update 优化 notice 新增通知公告发送ws推送

This commit is contained in:
疯狂的狮子Li
2023-11-03 13:01:44 +08:00
parent 19fdec4ffb
commit e0510dc1e4

View File

@@ -2,12 +2,15 @@ package org.dromara.system.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.service.DictService;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.resource.api.RemoteMessageService;
import org.dromara.system.domain.bo.SysNoticeBo;
import org.dromara.system.domain.vo.SysNoticeVo;
import org.dromara.system.service.ISysNoticeService;
@@ -26,6 +29,10 @@ import org.springframework.web.bind.annotation.*;
public class SysNoticeController extends BaseController {
private final ISysNoticeService noticeService;
private final DictService dictService;
@DubboReference
private final RemoteMessageService remoteMessageService;
/**
* 获取通知公告列表
@@ -54,7 +61,13 @@ public class SysNoticeController extends BaseController {
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public R<Void> add(@Validated @RequestBody SysNoticeBo notice) {
return toAjax(noticeService.insertNotice(notice));
int rows = noticeService.insertNotice(notice);
if (rows <= 0) {
return R.fail();
}
String type = dictService.getDictLabel("sys_notice_type", notice.getNoticeType());
remoteMessageService.publishAll("[" + type + "] " + notice.getNoticeTitle());
return R.ok();
}
/**