iotkit-parent/iot-module/iot-message-notify/消息中心文档.md

61 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 消息中心
## 用户通道配置
1. 用户通过接口获取系统已经支持的通道列表
2. 选择某个通道配置对应的参数
1. 企业微信:先添加消息机器人 再获取token
2. 飞书:先添加消息机器人 再获取token
3. 邮箱配置host 发件人 收件人
3. 保存通道配置
4. 通过接口启用通道
1. 修改已经保存的通道的状态为启用
2. 订阅已经启用的通道
## 设备发送消息
1. 消息中心接收消息
2. 根据设备deviceId获取设备归属人userId
3. 根据归属人userId获取已经订阅的通道
## SQL
~~~mysql
CREATE TABLE channel_type
(
id bigint PRIMARY KEY AUTO_INCREMENT COMMENT 'ID',
title varchar(128) NOT NULL COMMENT '标题',
createTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updateTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'
) COMMENT '通道类型';
INSERT INTO channel_type(title, createTime, updateTime)
VALUES ('邮箱', current_timestamp(), current_timestamp());
INSERT INTO channel_type(title, createTime, updateTime)
VALUES ('飞书', current_timestamp(), current_timestamp());
INSERT INTO channel_type(title, createTime, updateTime)
VALUES ('短信', current_timestamp(), current_timestamp());
INSERT INTO channel_type(title, createTime, updateTime)
VALUES ('钉钉', current_timestamp(), current_timestamp());
INSERT INTO channel_type(title, createTime, updateTime)
VALUES ('企业微信', current_timestamp(), current_timestamp());
CREATE TABLE channel
(
id bigint PRIMARY KEY AUTO_INCREMENT COMMENT 'ID',
title varchar(128) COMMENT '标题',
channelType bigint NOT NULL COMMENT '渠道类型',
configParam text NOT NULL COMMENT '配置参数',
userId bigint COMMENT '配置归属',
createTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updateTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'
) COMMENT '通道';
CREATE TABLE message
(
id bigint PRIMARY KEY AUTO_INCREMENT COMMENT 'ID',
mac varchar(128) COMMENT '设备MAC',
deviceId varchar(128) COMMENT '设备ID',
content text NOT NULL COMMENT '消息内容',
createTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updateTime timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'
) COMMENT '消息';
~~~