增加站内信发送接口
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled

This commit is contained in:
lxd 2024-12-05 17:33:02 +08:00
parent ad0397c41e
commit da9daa81a3

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.warning;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.dal.mysql.warning.WarningMapper;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -43,6 +45,9 @@ import javax.validation.Valid;
@Validated
public class WarningController {
// 0. 注入 NotifyMessageSendApi Bean
@Resource
private NotifyMessageSendApi notifySendApi;
@Resource
private WarningService warningService;
@ -107,6 +112,21 @@ public class WarningController {
return success(true);
}
@GetMapping("/sendMessage")
@Operation(summary = "发送站内信给某个用户")
public CommonResult<Boolean> sendMessage(@RequestParam("userid") String userid,@RequestParam("name") String name)
{
// 1. 准备参数
Long userId = Long.valueOf(userid); // 示例中写死你可以改成你业务中的 userId
String templateCode = "A001"; // 站内信模版记得在站内信管理中配置噢
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("name", name);
// 2. 发送站内信
notifySendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId).setTemplateCode(templateCode).setTemplateParams(templateParams));
return success(true);
}
@DeleteMapping("/delete")