V3.2.16
date:2024-01-03 (仅授权版更新)下载地址
1、添加websocket服务
2、添加站内通知、私信及新消息弹窗通知
从v3.2.15升级到此版本,覆盖文件,执行以下sql语句,无需安装任何依赖。
数据库有字段更新,请进入数据库执行以下脚本更新:
如果是使用mysql执行以下语句,注意需登录到mysql后命令行运行,不能直接导入。
CREATE TABLE `sys_notice`(
`id` bigint(20) NOT NULL auto_increment COMMENT 'ID' ,
`title` varchar(64) COLLATE utf8_general_ci NOT NULL COMMENT '标题' ,
`type` bigint(20) NOT NULL COMMENT '类型' ,
`tag` int(11) NULL COMMENT '标签' ,
`content` longtext COLLATE utf8_general_ci NOT NULL COMMENT '内容' ,
`remark` varchar(255) COLLATE utf8_general_ci NULL COMMENT '备注' ,
`sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序' ,
`status` tinyint(1) NULL DEFAULT 1 COMMENT '状态' ,
`created_by` bigint(20) NULL COMMENT '发送人' ,
`updated_by` bigint(20) NULL DEFAULT 0 COMMENT '修改人' ,
`created_at` datetime NULL COMMENT '创建时间' ,
`updated_at` datetime NULL COMMENT '更新时间' ,
`deleted_at` datetime NULL COMMENT '删除时间' ,
`receiver` json NULL COMMENT '接收者(私信)' ,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8' COLLATE='utf8_general_ci' COMMENT='通知公告';
CREATE TABLE `sys_notice_read`(
`id` bigint(20) NOT NULL auto_increment COMMENT 'id' ,
`notice_id` bigint(20) NOT NULL COMMENT '信息id' ,
`user_id` bigint(20) NOT NULL COMMENT '用户id' ,
`clicks` int(11) NULL COMMENT '点击次数' ,
`updated_at` datetime NULL COMMENT '更新时间' ,
`created_at` datetime NULL COMMENT '阅读时间' ,
PRIMARY KEY (`id`) ,
UNIQUE KEY `notice_id`(`notice_id`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8' COLLATE='utf8_general_ci' COMMENT='已读记录';
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (0, 'api/v1/system/sysNotice', '通知公告', 'iconfont icon-fuwenbenkuang', '', '', 0, 0, 0, '/system/sysNotice', 'layout/routerView/parent', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, '2023-11-09 15:40:55');
-- 菜单父目录ID
SELECT @pId := LAST_INSERT_ID();
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@pId, 'api/v1/system/sysNotice/list', '通知公告管理', 'ele-Fold', '', '', 1, 0, 0, '/system/sysNotice/list', 'system/sysNotice/list/index', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, '2023-11-09 15:41:13');
-- 按钮父目录ID
SELECT @parentId := LAST_INSERT_ID();
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@parentId, 'api/v1/system/sysNotice/get', '通知公告查询', '', '', '通知公告查询', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@parentId, 'api/v1/system/sysNotice/add', '通知公告添加', '', '', '通知公告添加', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@parentId, 'api/v1/system/sysNotice/edit', '通知公告修改', '', '', '通知公告修改', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@parentId, 'api/v1/system/sysNotice/delete', '通知公告删除', '', '', '通知公告删除', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` (`pid`, `name`, `title`, `icon`, `condition`, `remark`, `menu_type`, `weigh`, `is_hide`, `path`, `component`, `is_link`, `module_type`, `model_id`, `is_iframe`, `is_cached`, `redirect`, `is_affix`, `link_url`, `created_at`, `updated_at`) VALUES (@pId, 'api/v1/system/sysNotice/show', '通知公告展示', 'iconfont icon-tongzhi', '', '', 0, 0, 0, '/system/sysNotice/show', 'system/sysNotice/show/index', 0, '', 0, 0, 1, '', 0, '', '2023-12-25 10:34:32', '2023-12-25 10:34:32');
INSERT INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES ('系统公告标签', 'notice_tag', 1, 31, 0, '', '2023-12-28 15:48:03', '2023-12-28 15:48:03');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '无标签', '0', 'notice_tag', '', '', 0, 1, 31, 31, '', '2023-12-28 15:48:45', '2023-12-28 15:52:14');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '提醒', '1', 'notice_tag', '', '', 0, 1, 31, 31, '', '2023-12-28 15:48:54', '2023-12-28 15:52:24');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '一般', '2', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:35', '2023-12-28 15:52:35');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '次要', '3', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:44', '2023-12-28 15:52:44');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '重要', '4', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:53', '2023-12-28 15:52:53');
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `update_by`, `remark`, `created_at`, `updated_at`) VALUES (0, '紧急', '5', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:53:01', '2023-12-28 15:53:01');
如果使用pg执行以下语句,注意需登录到pg后命令行运行,不能直接导入。
-- 创建sys_notice_id_seq序列
CREATE SEQUENCE sys_notice_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;
COMMENT ON SEQUENCE sys_notice_id_seq IS '通知公告ID序列';
-- 创建sys_notice表
CREATE TABLE sys_notice (
id bigint NOT NULL PRIMARY KEY DEFAULT nextval('sys_notice_id_seq'::regclass),
title varchar(64) COLLATE "C" NOT NULL,
type bigint NOT NULL,
tag int NULL,
content text COLLATE "C" NOT NULL,
remark varchar(255) COLLATE "C" NULL,
sort int NOT NULL DEFAULT 0,
status smallint NULL DEFAULT 1,
created_by bigint NULL,
updated_by bigint NULL DEFAULT 0,
created_at timestamp NULL,
updated_at timestamp NULL,
deleted_at timestamp NULL,
receiver json NULL
);
COMMENT ON TABLE sys_notice IS '通知公告';
COMMENT ON COLUMN sys_notice.title IS '标题';
COMMENT ON COLUMN sys_notice.type IS '类型';
COMMENT ON COLUMN sys_notice.tag IS '标签';
COMMENT ON COLUMN sys_notice.content IS '内容';
COMMENT ON COLUMN sys_notice.remark IS '备注';
COMMENT ON COLUMN sys_notice.sort IS '排序';
COMMENT ON COLUMN sys_notice.status IS '状态';
COMMENT ON COLUMN sys_notice.created_by IS '发送人';
COMMENT ON COLUMN sys_notice.updated_by IS '修改人';
COMMENT ON COLUMN sys_notice.created_at IS '创建时间';
COMMENT ON COLUMN sys_notice.updated_at IS '更新时间';
COMMENT ON COLUMN sys_notice.deleted_at IS '删除时间';
COMMENT ON COLUMN sys_notice.receiver IS '接收者(私信)';
-- 创建sys_notice_read_id_seq序列
CREATE SEQUENCE sys_notice_read_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;
COMMENT ON SEQUENCE sys_notice_read_id_seq IS '已读记录ID序列';
-- 创建sys_notice_read表
CREATE TABLE sys_notice_read (
id bigint NOT NULL PRIMARY KEY DEFAULT nextval('sys_notice_read_id_seq'::regclass),
notice_id bigint NOT NULL,
user_id bigint NOT NULL,
clicks int NULL,
updated_at timestamp NULL,
created_at timestamp NULL,
UNIQUE (notice_id, user_id)
);
COMMENT ON TABLE sys_notice_read IS '已读记录';
COMMENT ON COLUMN sys_notice_read.notice_id IS '信息id';
COMMENT ON COLUMN sys_notice_read.user_id IS '用户id';
COMMENT ON COLUMN sys_notice_read.clicks IS '点击次数';
COMMENT ON COLUMN sys_notice_read.updated_at IS '更新时间';
COMMENT ON COLUMN sys_notice_read.created_at IS '阅读时间';
-- 定义一个变量用于存储返回的id
DO $$
DECLARE pId INTEGER;
DECLARE parentId INTEGER;
BEGIN
-- 插入数据并将返回的id存储在pId变量中
INSERT INTO sys_auth_rule (pid, name, title, icon, condition, remark, menu_type, weigh, is_hide, path, component, is_link, module_type, model_id, is_iframe, is_cached, redirect, is_affix, link_url, created_at, updated_at)
VALUES (0, 'api/v1/system/sysNotice', '通知公告', 'iconfont icon-fuwenbenkuang', '', '', 0, 0, 0, '/system/sysNotice', 'layout/routerView/parent', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, '2023-11-09 15:40:55')
RETURNING id INTO pId;
-- 在这里可以使用pId变量进行其他操作
INSERT INTO sys_auth_rule (pid, name, title, icon, condition, remark, menu_type, weigh, is_hide, path, component, is_link, module_type, model_id, is_iframe, is_cached, redirect, is_affix, link_url, created_at, updated_at) VALUES
(pId,'api/v1/system/sysNotice/list', '通知公告管理', 'ele-Fold', '', '', 1, 0, 0, '/system/sysNotice/list', 'system/sysNotice/list/index', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, '2023-11-09 15:41:13')
RETURNING id INTO parentId;
INSERT INTO "sys_auth_rule" ("pid", "name", "title", "icon", "condition", "remark", "menu_type", "weigh", "is_hide", "path", "component", "is_link", "module_type", "model_id", "is_iframe", "is_cached", "redirect", "is_affix", "link_url", "created_at", "updated_at") VALUES (parentId, 'api/v1/system/sysNotice/get', '通知公告查询', '', '', '通知公告查询', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" ("pid", "name", "title", "icon", "condition", "remark", "menu_type", "weigh", "is_hide", "path", "component", "is_link", "module_type", "model_id", "is_iframe", "is_cached", "redirect", "is_affix", "link_url", "created_at", "updated_at") VALUES (parentId, 'api/v1/system/sysNotice/add', '通知公告添加', '', '', '通知公告添加', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" ("pid", "name", "title", "icon", "condition", "remark", "menu_type", "weigh", "is_hide", "path", "component", "is_link", "module_type", "model_id", "is_iframe", "is_cached", "redirect", "is_affix", "link_url", "created_at", "updated_at") VALUES (parentId, 'api/v1/system/sysNotice/edit', '通知公告修改', '', '', '通知公告修改', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" ("pid", "name", "title", "icon", "condition", "remark", "menu_type", "weigh", "is_hide", "path", "component", "is_link", "module_type", "model_id", "is_iframe", "is_cached", "redirect", "is_affix", "link_url", "created_at", "updated_at") VALUES (parentId, 'api/v1/system/sysNotice/delete', '通知公告删除', '', '', '通知公告删除', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" ("pid", "name", "title", "icon", "condition", "remark", "menu_type", "weigh", "is_hide", "path", "component", "is_link", "module_type", "model_id", "is_iframe", "is_cached", "redirect", "is_affix", "link_url", "created_at", "updated_at") VALUES (pId, 'api/v1/system/sysNotice/show', '通知公告扎展示', 'iconfont icon-tongzhi', '', '', 0, 0, 0, '/system/sysNotice/show', 'system/sysNotice/show/index', 0, '', 0, 0, 1, '', 0, '', '2023-12-25 10:34:32', '2023-12-25 10:34:32');
END $$;
INSERT INTO "sys_dict_type" ("dict_name", "dict_type", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES ('系统公告标签', 'notice_tag', 1, 31, 0, '', '2023-12-28 15:48:03', '2023-12-28 15:48:03');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '无标签', '0', 'notice_tag', '', '', 0, 1, 31, 31, '', '2023-12-28 15:48:45', '2023-12-28 15:52:14');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '提醒', '1', 'notice_tag', '', '', 0, 1, 31, 31, '', '2023-12-28 15:48:54', '2023-12-28 15:52:24');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '一般', '2', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:35', '2023-12-28 15:52:35');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '次要', '3', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:44', '2023-12-28 15:52:44');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '重要', '4', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:52:53', '2023-12-28 15:52:53');
INSERT INTO "sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "update_by", "remark", "created_at", "updated_at") VALUES (0, '紧急', '5', 'notice_tag', '', '', 0, 1, 31, 0, '', '2023-12-28 15:53:01', '2023-12-28 15:53:01');
websocket服务使用方法,只需要在注册消息路由中绑定对应消息事件名称及方法,例如绑定一个ping事件:
发送websocket消息给某人:
libWebsocket.SendToUser(userId, response)
发送websocket消息给所有人:
libWebsocket.SendToAll(response)
作者:管理员 创建时间:2024-01-03 09:34
最后编辑:管理员 更新时间:2024-12-03 15:05
最后编辑:管理员 更新时间:2024-12-03 15:05