mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-14 10:57:19 +08:00
feat: 重构公告及消息,公告支持系统消息推送提醒、定时发布、置顶、记录读取状态
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.admin.controller.system;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.continew.admin.common.context.UserContextHolder;
|
||||
import top.continew.admin.system.model.query.MessageQuery;
|
||||
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||
import top.continew.admin.system.service.MessageService;
|
||||
import top.continew.admin.system.service.MessageUserService;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.req.IdsReq;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.log.annotation.Log;
|
||||
|
||||
/**
|
||||
* 消息管理 API
|
||||
*
|
||||
* @author Bull-BCLS
|
||||
* @since 2023/10/15 19:05
|
||||
*/
|
||||
@Tag(name = "消息管理 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/system/message")
|
||||
public class MessageController {
|
||||
|
||||
private final MessageService baseService;
|
||||
private final MessageUserService messageUserService;
|
||||
|
||||
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
||||
@GetMapping
|
||||
public PageResp<MessageResp> page(MessageQuery query, @Validated PageQuery pageQuery) {
|
||||
query.setUserId(UserContextHolder.getUserId());
|
||||
return baseService.page(query, pageQuery);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除数据", description = "删除数据")
|
||||
@DeleteMapping
|
||||
public void delete(@Validated @RequestBody IdsReq req) {
|
||||
baseService.delete(req.getIds());
|
||||
}
|
||||
|
||||
@Operation(summary = "标记已读", description = "将消息标记为已读状态")
|
||||
@PatchMapping("/read")
|
||||
public void read(@Validated @RequestBody IdsReq req) {
|
||||
messageUserService.readMessage(req.getIds());
|
||||
}
|
||||
|
||||
@Operation(summary = "全部已读", description = "将所有消息标记为已读状态")
|
||||
@PatchMapping("/readAll")
|
||||
public void readAll() {
|
||||
messageUserService.readMessage(null);
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "查询未读消息数量", description = "查询当前用户的未读消息数量")
|
||||
@Parameter(name = "isDetail", description = "是否查询详情", example = "true", in = ParameterIn.QUERY)
|
||||
@GetMapping("/unread")
|
||||
public MessageUnreadResp countUnread(@RequestParam(required = false) Boolean detail) {
|
||||
return messageUserService.countUnreadMessageByUserId(UserContextHolder.getUserId(), detail);
|
||||
}
|
||||
}
|
@@ -16,14 +16,16 @@
|
||||
|
||||
package top.continew.admin.controller.system;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.continew.admin.common.controller.BaseController;
|
||||
import top.continew.admin.system.enums.NoticeMethodEnum;
|
||||
import top.continew.admin.system.enums.NoticeScopeEnum;
|
||||
import top.continew.admin.system.model.query.NoticeQuery;
|
||||
import top.continew.admin.system.model.req.NoticeReq;
|
||||
import top.continew.admin.system.model.resp.NoticeDetailResp;
|
||||
import top.continew.admin.system.model.resp.NoticeResp;
|
||||
import top.continew.admin.system.model.resp.notice.NoticeDetailResp;
|
||||
import top.continew.admin.system.model.resp.notice.NoticeResp;
|
||||
import top.continew.admin.system.service.NoticeService;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudApi;
|
||||
@@ -31,7 +33,8 @@ import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告管理 API
|
||||
@@ -52,15 +55,18 @@ public class NoticeController extends BaseController<NoticeService, NoticeResp,
|
||||
return;
|
||||
}
|
||||
NoticeReq req = (NoticeReq)args[0];
|
||||
// 校验生效时间
|
||||
LocalDateTime effectiveTime = req.getEffectiveTime();
|
||||
LocalDateTime terminateTime = req.getTerminateTime();
|
||||
if (null != effectiveTime && null != terminateTime) {
|
||||
ValidationUtils.throwIf(terminateTime.isBefore(effectiveTime), "终止时间必须晚于生效时间");
|
||||
}
|
||||
// 校验通知范围
|
||||
if (NoticeScopeEnum.USER.equals(req.getNoticeScope())) {
|
||||
ValidationUtils.throwIfEmpty(req.getNoticeUsers(), "通知用户不能为空");
|
||||
}
|
||||
// 校验通知方式
|
||||
List<Integer> noticeMethods = req.getNoticeMethods();
|
||||
if (CollUtil.isNotEmpty(noticeMethods)) {
|
||||
List<Integer> validMethods = Arrays.stream(NoticeMethodEnum.values())
|
||||
.map(NoticeMethodEnum::getValue)
|
||||
.toList();
|
||||
noticeMethods.forEach(method -> ValidationUtils.throwIf(!validMethods
|
||||
.contains(method), "通知方式 [{}] 不正确", method));
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,19 +22,24 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.continew.admin.common.context.UserContextHolder;
|
||||
import top.continew.admin.system.enums.NoticeScopeEnum;
|
||||
import top.continew.admin.system.model.query.MessageQuery;
|
||||
import top.continew.admin.system.model.query.NoticeQuery;
|
||||
import top.continew.admin.system.model.resp.NoticeDetailResp;
|
||||
import top.continew.admin.system.model.resp.NoticeResp;
|
||||
import top.continew.admin.system.model.resp.message.MessageResp;
|
||||
import top.continew.admin.system.model.resp.message.MessageUnreadResp;
|
||||
import top.continew.admin.system.model.resp.notice.NoticeDetailResp;
|
||||
import top.continew.admin.system.model.resp.notice.NoticeResp;
|
||||
import top.continew.admin.system.model.resp.notice.NoticeUnreadResp;
|
||||
import top.continew.admin.system.service.MessageService;
|
||||
import top.continew.admin.system.service.NoticeService;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.req.IdsReq;
|
||||
import top.continew.starter.extension.crud.model.resp.BasePageResp;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.log.annotation.Log;
|
||||
|
||||
/**
|
||||
* 个人消息 API
|
||||
@@ -50,6 +55,40 @@ import top.continew.starter.extension.crud.model.resp.BasePageResp;
|
||||
public class UserMessageController {
|
||||
|
||||
private final NoticeService noticeService;
|
||||
private final MessageService messageService;
|
||||
|
||||
@Operation(summary = "分页查询消息列表", description = "分页查询消息列表")
|
||||
@GetMapping
|
||||
public PageResp<MessageResp> page(MessageQuery query, @Validated PageQuery pageQuery) {
|
||||
query.setUserId(UserContextHolder.getUserId());
|
||||
return messageService.page(query, pageQuery);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除消息", description = "删除消息")
|
||||
@DeleteMapping
|
||||
public void delete(@Validated @RequestBody IdsReq req) {
|
||||
messageService.delete(req.getIds());
|
||||
}
|
||||
|
||||
@Operation(summary = "消息标记为已读", description = "将消息标记为已读状态")
|
||||
@PatchMapping("/read")
|
||||
public void read(@Validated @RequestBody IdsReq req) {
|
||||
messageService.readMessage(req.getIds(), UserContextHolder.getUserId());
|
||||
}
|
||||
|
||||
@Operation(summary = "消息全部已读", description = "将所有消息标记为已读状态")
|
||||
@PatchMapping("/readAll")
|
||||
public void readAll() {
|
||||
messageService.readMessage(null, UserContextHolder.getUserId());
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "查询未读消息数量", description = "查询当前用户的未读消息数量")
|
||||
@Parameter(name = "isDetail", description = "是否查询详情", example = "true", in = ParameterIn.QUERY)
|
||||
@GetMapping("/unread")
|
||||
public MessageUnreadResp countUnreadMessage(@RequestParam(required = false) Boolean detail) {
|
||||
return messageService.countUnreadByUserId(UserContextHolder.getUserId(), detail);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询公告列表", description = "分页查询公告列表")
|
||||
@GetMapping("/notice")
|
||||
@@ -66,6 +105,14 @@ public class UserMessageController {
|
||||
CheckUtils.throwIf(detail == null || (NoticeScopeEnum.USER.equals(detail.getNoticeScope()) && !detail
|
||||
.getNoticeUsers()
|
||||
.contains(UserContextHolder.getUserId().toString())), "公告不存在或无权限访问");
|
||||
noticeService.readNotice(id, UserContextHolder.getUserId());
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "查询未读公告数量", description = "查询当前用户的未读公告数量")
|
||||
@GetMapping("/notice/unread")
|
||||
public NoticeUnreadResp countUnreadNotice() {
|
||||
return noticeService.countUnreadByUserId(UserContextHolder.getUserId());
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.admin.controller.schedule;
|
||||
package top.continew.admin.job;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
|
||||
@@ -53,8 +53,9 @@ public class DemoEnvironmentJob {
|
||||
private final DictMapper dictMapper;
|
||||
private final StorageMapper storageMapper;
|
||||
private final NoticeMapper noticeMapper;
|
||||
private final NoticeLogMapper noticeLogMapper;
|
||||
private final MessageMapper messageMapper;
|
||||
private final MessageUserMapper messageUserMapper;
|
||||
private final MessageLogMapper messageLogMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final UserRoleMapper userRoleMapper;
|
||||
private final UserSocialMapper userSocialMapper;
|
||||
@@ -109,7 +110,8 @@ public class DemoEnvironmentJob {
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().blockAttack(true).build());
|
||||
SnailJobLog.REMOTE.info("演示环境待清理数据项检测完成,开始执行清理。");
|
||||
// 清理关联数据
|
||||
messageUserMapper.lambdaUpdate().gt(MessageUserDO::getMessageId, MESSAGE_FLAG).remove();
|
||||
noticeLogMapper.lambdaUpdate().gt(NoticeLogDO::getNoticeId, DELETE_FLAG).remove();
|
||||
messageLogMapper.lambdaUpdate().gt(MessageLogDO::getMessageId, MESSAGE_FLAG).remove();
|
||||
userRoleMapper.lambdaUpdate().notIn(UserRoleDO::getRoleId, ROLE_FLAG).remove();
|
||||
userRoleMapper.lambdaUpdate().notIn(UserRoleDO::getUserId, USER_FLAG).remove();
|
||||
roleDeptMapper.lambdaUpdate().notIn(RoleDeptDO::getRoleId, ROLE_FLAG).remove();
|
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.admin.job;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
|
||||
import com.aizuda.snailjob.common.log.SnailJobLog;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.admin.schedule.annotation.ConditionalOnEnabledScheduleJob;
|
||||
import top.continew.admin.system.enums.NoticeMethodEnum;
|
||||
import top.continew.admin.system.enums.NoticeStatusEnum;
|
||||
import top.continew.admin.system.mapper.NoticeMapper;
|
||||
import top.continew.admin.system.model.entity.NoticeDO;
|
||||
import top.continew.admin.system.service.NoticeService;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告发布任务
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2025/5/11 22:19
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class NoticePublishJob {
|
||||
|
||||
/**
|
||||
* 定时发布公告(未启用 Snail Job 则使用它)
|
||||
*/
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "snail-job", name = PropertiesConstants.ENABLED, havingValue = "false")
|
||||
public static class Scheduler {
|
||||
|
||||
@Scheduled(cron = "0 * * * * ?")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void publishNoticeWithSchedule() {
|
||||
log.info("定时任务 [公告发布] 开始执行。");
|
||||
publishNotice();
|
||||
log.info("定时任务 [公告发布] 执行结束。");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时发布公告(启用 Snail Job 时)
|
||||
*/
|
||||
@Component
|
||||
@ConditionalOnEnabledScheduleJob
|
||||
public static class ScheduleJob {
|
||||
|
||||
@JobExecutor(name = "NoticePublishJob")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void publishNoticeWithScheduleJob() {
|
||||
SnailJobLog.REMOTE.info("定时任务 [公告发布] 开始执行。");
|
||||
publishNotice();
|
||||
SnailJobLog.REMOTE.info("定时任务 [公告发布] 执行结束。");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布公告
|
||||
*/
|
||||
private static void publishNotice() {
|
||||
NoticeMapper noticeMapper = SpringUtil.getBean(NoticeMapper.class);
|
||||
// 查询待发布公告
|
||||
List<NoticeDO> list = noticeMapper.lambdaQuery()
|
||||
.eq(NoticeDO::getStatus, NoticeStatusEnum.PENDING)
|
||||
.le(NoticeDO::getPublishTime, LocalDateTime.now())
|
||||
.list();
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
// 筛选需要发送消息的公告并发送
|
||||
List<NoticeDO> needSendMessageList = list.stream()
|
||||
.filter(notice -> CollUtil.isNotEmpty(notice.getNoticeMethods()))
|
||||
.filter(notice -> notice.getNoticeMethods().contains(NoticeMethodEnum.SYSTEM_MESSAGE.getValue()))
|
||||
.toList();
|
||||
if (CollUtil.isNotEmpty(needSendMessageList)) {
|
||||
// 发送消息
|
||||
NoticeService noticeService = SpringUtil.getBean(NoticeService.class);
|
||||
needSendMessageList.parallelStream().forEach(noticeService::publish);
|
||||
}
|
||||
// 更新状态
|
||||
noticeMapper.lambdaUpdate()
|
||||
.set(NoticeDO::getStatus, NoticeStatusEnum.PUBLISHED)
|
||||
.in(NoticeDO::getId, list.stream().map(NoticeDO::getId).toList())
|
||||
.update();
|
||||
}
|
||||
}
|
@@ -46,10 +46,11 @@ VALUES
|
||||
|
||||
(1090, '通知公告', 1000, 2, '/system/notice', 'SystemNotice', 'system/notice/index', NULL, 'notification', b'0', b'0', b'0', NULL, 5, 1, 1, NOW()),
|
||||
(1091, '列表', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:list', 1, 1, 1, NOW()),
|
||||
(1092, '公告详情', 1090, 2, '/system/notice/detail', 'SystemNoticeDetail', 'system/notice/detail/index', NULL, NULL, b'0', b'0', b'1', 'system:notice:get', 2, 1, 1, NOW()),
|
||||
(1093, '发布公告', 1090, 2, '/system/notice/add', 'SystemNoticeAdd', 'system/notice/add/index', NULL, NULL, b'0', b'0', b'1', 'system:notice:create', 3, 1, 1, NOW()),
|
||||
(1094, '修改', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:update', 4, 1, 1, NOW()),
|
||||
(1095, '删除', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:delete', 5, 1, 1, NOW()),
|
||||
(1092, '详情', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:get', 2, 1, 1, NOW()),
|
||||
(1093, '查看公告', 1090, 2, '/system/notice/view', 'SystemNoticeView', 'system/notice/view/index', NULL, NULL, b'0', b'0', b'1', 'system:notice:view', 3, 1, 1, NOW()),
|
||||
(1094, '发布公告', 1090, 2, '/system/notice/add', 'SystemNoticeAdd', 'system/notice/add/index', NULL, NULL, b'0', b'0', b'1', 'system:notice:create', 4, 1, 1, NOW()),
|
||||
(1095, '修改', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:update', 5, 1, 1, NOW()),
|
||||
(1096, '删除', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:delete', 6, 1, 1, NOW()),
|
||||
|
||||
(1110, '文件管理', 1000, 2, '/system/file', 'SystemFile', 'system/file/index', NULL, 'file', b'0', b'0', b'0', NULL, 6, 1, 1, NOW()),
|
||||
(1111, '列表', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:file:list', 1, 1, 1, NOW()),
|
||||
@@ -215,24 +216,21 @@ VALUES
|
||||
INSERT INTO `sys_dict`
|
||||
(`id`, `name`, `code`, `description`, `is_system`, `create_user`, `create_time`)
|
||||
VALUES
|
||||
(1, '公告类型', 'notice_type', NULL, b'1', 1, NOW()),
|
||||
(2, '消息类型', 'message_type', NULL, b'1', 1, NOW()),
|
||||
(3, '客户端类型', 'client_type', NULL, b'1', 1, NOW()),
|
||||
(4, '短信厂商', 'sms_supplier', NULL, b'1', 1, NOW());
|
||||
(1, '公告分类', 'notice_type', NULL, b'1', 1, NOW()),
|
||||
(2, '客户端类型', 'client_type', NULL, b'1', 1, NOW()),
|
||||
(3, '短信厂商', 'sms_supplier', NULL, b'1', 1, NOW());
|
||||
|
||||
INSERT INTO `sys_dict_item`
|
||||
(`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`)
|
||||
VALUES
|
||||
(1, '通知', '1', 'primary', 1, NULL, 1, 1, 1, NOW()),
|
||||
(2, '活动', '2', 'success', 2, NULL, 1, 1, 1, NOW()),
|
||||
(3, '安全消息', '1', 'warning', 1, NULL, 1, 2, 1, NOW()),
|
||||
(4, '活动消息', '2', 'success', 2, NULL, 1, 2, 1, NOW()),
|
||||
(5, '桌面端', 'PC', 'primary', 1, NULL, 1, 3, 1, NOW()),
|
||||
(6, '安卓', 'ANDROID', 'success', 2, NULL, 1, 3, 1, NOW()),
|
||||
(7, '小程序', 'XCX', 'warning', 3, NULL, 1, 3, 1, NOW()),
|
||||
(8, '阿里云', 'alibaba', 'warning', 1, NULL, 1, 4, 1, NOW()),
|
||||
(9, '腾讯云', 'tencent', 'primary', 2, NULL, 1, 4, 1, NOW()),
|
||||
(10, '容联云', 'cloopen', 'success', 3, NULL, 1, 4, 1, NOW());
|
||||
(1, '产品新闻', '1', 'primary', 1, NULL, 1, 1, 1, NOW()),
|
||||
(2, '企业动态', '2', 'success', 2, NULL, 1, 1, 1, NOW()),
|
||||
(3, '桌面端', 'PC', 'primary', 1, NULL, 1, 2, 1, NOW()),
|
||||
(4, '安卓', 'ANDROID', 'success', 2, NULL, 1, 2, 1, NOW()),
|
||||
(5, '小程序', 'XCX', 'warning', 3, NULL, 1, 2, 1, NOW()),
|
||||
(6, '阿里云', 'alibaba', 'warning', 1, NULL, 1, 3, 1, NOW()),
|
||||
(7, '腾讯云', 'tencent', 'primary', 2, NULL, 1, 3, 1, NOW()),
|
||||
(8, '容联云', 'cloopen', 'success', 3, NULL, 1, 3, 1, NOW());
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO `sys_user_role`
|
||||
|
@@ -218,31 +218,34 @@ CREATE TABLE IF NOT EXISTS `sys_log` (
|
||||
CREATE TABLE IF NOT EXISTS `sys_message` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`title` varchar(50) NOT NULL COMMENT '标题',
|
||||
`content` varchar(255) DEFAULT NULL COMMENT '内容',
|
||||
`type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '类型(1:系统消息)',
|
||||
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||
`content` text DEFAULT NULL COMMENT '内容',
|
||||
`type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '类型(1:系统消息;2:安全消息)',
|
||||
`path` varchar(255) DEFAULT NULL COMMENT '跳转路径',
|
||||
`scope` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '通知范围(1:所有人;2:指定用户)',
|
||||
`users` json DEFAULT NULL COMMENT '通知用户',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_message_user` (
|
||||
`message_id` bigint(20) NOT NULL COMMENT '消息ID',
|
||||
`user_id` bigint(11) NOT NULL COMMENT '用户ID',
|
||||
`is_read` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已读',
|
||||
`read_time` datetime DEFAULT NULL COMMENT '读取时间',
|
||||
CREATE TABLE IF NOT EXISTS `sys_message_log` (
|
||||
`message_id` bigint(20) NOT NULL COMMENT '消息ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`read_time` datetime DEFAULT NULL COMMENT '读取时间',
|
||||
PRIMARY KEY (`message_id`, `user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息和用户关联表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_notice` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`title` varchar(150) NOT NULL COMMENT '标题',
|
||||
`content` mediumtext NOT NULL COMMENT '内容',
|
||||
`type` varchar(30) NOT NULL COMMENT '类型',
|
||||
`effective_time` datetime DEFAULT NULL COMMENT '生效时间',
|
||||
`terminate_time` datetime DEFAULT NULL COMMENT '终止时间',
|
||||
`type` varchar(30) NOT NULL COMMENT '分类',
|
||||
`notice_scope` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '通知范围(1:所有人;2:指定用户)',
|
||||
`notice_users` json DEFAULT NULL COMMENT '通知用户',
|
||||
`sort` int NOT NULL DEFAULT 999 COMMENT '排序',
|
||||
`notice_methods` json DEFAULT NULL COMMENT '通知方式(1:登录弹窗;2:系统消息)',
|
||||
`is_timing` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否定时',
|
||||
`publish_time` datetime DEFAULT NULL COMMENT '发布时间',
|
||||
`is_top` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否置顶',
|
||||
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(1:草稿;2:待发布;3:已发布)',
|
||||
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
|
||||
@@ -252,6 +255,13 @@ CREATE TABLE IF NOT EXISTS `sys_notice` (
|
||||
INDEX `idx_update_user`(`update_user`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公告表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_notice_log` (
|
||||
`notice_id` bigint(20) NOT NULL COMMENT '公告ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`read_time` datetime DEFAULT NULL COMMENT '读取时间',
|
||||
PRIMARY KEY (`notice_id`, `user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公告日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_storage` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`name` varchar(100) NOT NULL COMMENT '名称',
|
||||
|
@@ -46,10 +46,11 @@ VALUES
|
||||
|
||||
(1090, '通知公告', 1000, 2, '/system/notice', 'SystemNotice', 'system/notice/index', NULL, 'notification', false, false, false, NULL, 5, 1, 1, NOW()),
|
||||
(1091, '列表', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:list', 1, 1, 1, NOW()),
|
||||
(1092, '公告详情', 1090, 2, '/system/notice/detail', 'SystemNoticeDetail', 'system/notice/detail/index', NULL, NULL, false, false, true, 'system:notice:get', 2, 1, 1, NOW()),
|
||||
(1093, '发布公告', 1090, 2, '/system/notice/add', 'SystemNoticeAdd', 'system/notice/add/index', NULL, NULL, false, false, true, 'system:notice:create', 3, 1, 1, NOW()),
|
||||
(1094, '修改', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:update', 4, 1, 1, NOW()),
|
||||
(1095, '删除', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:delete', 5, 1, 1, NOW()),
|
||||
(1092, '详情', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:get', 2, 1, 1, NOW()),
|
||||
(1093, '查看公告', 1090, 2, '/system/notice/view', 'SystemNoticeView', 'system/notice/view/index', NULL, NULL, false, false, true, 'system:notice:view', 3, 1, 1, NOW()),
|
||||
(1094, '发布公告', 1090, 2, '/system/notice/add', 'SystemNoticeAdd', 'system/notice/add/index', NULL, NULL, false, false, true, 'system:notice:create', 4, 1, 1, NOW()),
|
||||
(1095, '修改', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:update', 5, 1, 1, NOW()),
|
||||
(1096, '删除', 1090, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:notice:delete', 6, 1, 1, NOW()),
|
||||
|
||||
(1110, '文件管理', 1000, 2, '/system/file', 'SystemFile', 'system/file/index', NULL, 'file', false, false, false, NULL, 6, 1, 1, NOW()),
|
||||
(1111, '列表', 1110, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'system:file:list', 1, 1, 1, NOW()),
|
||||
@@ -215,24 +216,21 @@ VALUES
|
||||
INSERT INTO "sys_dict"
|
||||
("id", "name", "code", "description", "is_system", "create_user", "create_time")
|
||||
VALUES
|
||||
(1, '公告类型', 'notice_type', NULL, true, 1, NOW()),
|
||||
(2, '消息类型', 'message_type', NULL, true, 1, NOW()),
|
||||
(3, '客户端类型', 'client_type', NULL, true, 1, NOW()),
|
||||
(4, '短信厂商', 'sms_supplier', NULL, true, 1, NOW());
|
||||
(1, '公告分类', 'notice_type', NULL, true, 1, NOW()),
|
||||
(2, '客户端类型', 'client_type', NULL, true, 1, NOW()),
|
||||
(3, '短信厂商', 'sms_supplier', NULL, true, 1, NOW());
|
||||
|
||||
INSERT INTO "sys_dict_item"
|
||||
("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time")
|
||||
VALUES
|
||||
(1, '通知', '1', 'primary', 1, NULL, 1, 1, 1, NOW()),
|
||||
(2, '活动', '2', 'success', 2, NULL, 1, 1, 1, NOW()),
|
||||
(3, '安全消息', '1', 'warning', 1, NULL, 1, 2, 1, NOW()),
|
||||
(4, '活动消息', '2', 'success', 2, NULL, 1, 2, 1, NOW()),
|
||||
(5, '桌面端', 'PC', 'primary', 1, NULL, 1, 3, 1, NOW()),
|
||||
(6, '安卓', 'ANDROID', 'success', 2, NULL, 1, 3, 1, NOW()),
|
||||
(7, '小程序', 'XCX', 'warning', 3, NULL, 1, 3, 1, NOW()),
|
||||
(8, '阿里云', 'alibaba', 'warning', 1, NULL, 1, 4, 1, NOW()),
|
||||
(9, '腾讯云', 'tencent', 'primary', 2, NULL, 1, 4, 1, NOW()),
|
||||
(10, '容联云', 'cloopen', 'success', 3, NULL, 1, 4, 1, NOW());
|
||||
(1, '产品新闻', '1', 'primary', 1, NULL, 1, 1, 1, NOW()),
|
||||
(2, '企业动态', '2', 'success', 2, NULL, 1, 1, 1, NOW()),
|
||||
(3, '桌面端', 'PC', 'primary', 1, NULL, 1, 2, 1, NOW()),
|
||||
(4, '安卓', 'ANDROID', 'success', 2, NULL, 1, 2, 1, NOW()),
|
||||
(5, '小程序', 'XCX', 'warning', 3, NULL, 1, 2, 1, NOW()),
|
||||
(6, '阿里云', 'alibaba', 'warning', 1, NULL, 1, 3, 1, NOW()),
|
||||
(7, '腾讯云', 'tencent', 'primary', 2, NULL, 1, 3, 1, NOW()),
|
||||
(8, '容联云', 'cloopen', 'success', 3, NULL, 1, 3, 1, NOW());
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO "sys_user_role"
|
||||
|
@@ -360,43 +360,47 @@ COMMENT ON TABLE "sys_log" IS '系统日志表';
|
||||
CREATE TABLE IF NOT EXISTS "sys_message" (
|
||||
"id" int8 NOT NULL,
|
||||
"title" varchar(50) NOT NULL,
|
||||
"content" varchar(255) DEFAULT NULL,
|
||||
"content" text DEFAULT NULL,
|
||||
"type" int2 NOT NULL DEFAULT 1,
|
||||
"create_user" int8 DEFAULT NULL,
|
||||
"path" varchar(255) DEFAULT NULL,
|
||||
"scope" int2 NOT NULL DEFAULT 1,
|
||||
"users" json DEFAULT NULL,
|
||||
"create_time" timestamp NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
COMMENT ON COLUMN "sys_message"."id" IS 'ID';
|
||||
COMMENT ON COLUMN "sys_message"."title" IS '标题';
|
||||
COMMENT ON COLUMN "sys_message"."content" IS '内容';
|
||||
COMMENT ON COLUMN "sys_message"."type" IS '类型(1:系统消息)';
|
||||
COMMENT ON COLUMN "sys_message"."create_user" IS '创建人';
|
||||
COMMENT ON COLUMN "sys_message"."type" IS '类型(1:系统消息;2:安全消息)';
|
||||
COMMENT ON COLUMN "sys_message"."path" IS '跳转路径';
|
||||
COMMENT ON COLUMN "sys_message"."scope" IS '通知范围(1:所有人;2:指定用户)';
|
||||
COMMENT ON COLUMN "sys_message"."users" IS '通知用户';
|
||||
COMMENT ON COLUMN "sys_message"."create_time" IS '创建时间';
|
||||
COMMENT ON TABLE "sys_message" IS '消息表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "sys_message_user" (
|
||||
CREATE TABLE IF NOT EXISTS "sys_message_log" (
|
||||
"message_id" int8 NOT NULL,
|
||||
"user_id" int8 NOT NULL,
|
||||
"is_read" bool NOT NULL DEFAULT false,
|
||||
"read_time" timestamp DEFAULT NULL,
|
||||
PRIMARY KEY ("message_id", "user_id")
|
||||
);
|
||||
COMMENT ON COLUMN "sys_message_user"."message_id" IS '消息ID';
|
||||
COMMENT ON COLUMN "sys_message_user"."user_id" IS '用户ID';
|
||||
COMMENT ON COLUMN "sys_message_user"."is_read" IS '是否已读';
|
||||
COMMENT ON COLUMN "sys_message_user"."read_time" IS '读取时间';
|
||||
COMMENT ON TABLE "sys_message_user" IS '消息和用户关联表';
|
||||
COMMENT ON COLUMN "sys_message_log"."message_id" IS '消息ID';
|
||||
COMMENT ON COLUMN "sys_message_log"."user_id" IS '用户ID';
|
||||
COMMENT ON COLUMN "sys_message_log"."read_time" IS '读取时间';
|
||||
COMMENT ON TABLE "sys_message_log" IS '消息日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "sys_notice" (
|
||||
"id" int8 NOT NULL,
|
||||
"title" varchar(150) NOT NULL,
|
||||
"content" text NOT NULL,
|
||||
"type" varchar(30) NOT NULL,
|
||||
"effective_time" timestamp DEFAULT NULL,
|
||||
"terminate_time" timestamp DEFAULT NULL,
|
||||
"notice_scope" int2 NOT NULL DEFAULT 1,
|
||||
"notice_users" json DEFAULT NULL,
|
||||
"sort" int4 NOT NULL DEFAULT 999,
|
||||
"notice_methods" json DEFAULT NULL,
|
||||
"is_timing" bool NOT NULL DEFAULT false,
|
||||
"publish_time" timestamp DEFAULT NULL,
|
||||
"is_top" bool NOT NULL DEFAULT false,
|
||||
"status" int2 NOT NULL DEFAULT 1,
|
||||
"create_user" int8 NOT NULL,
|
||||
"create_time" timestamp NOT NULL,
|
||||
"update_user" int8 DEFAULT NULL,
|
||||
@@ -408,18 +412,31 @@ CREATE INDEX "idx_notice_update_user" ON "sys_notice" ("update_user");
|
||||
COMMENT ON COLUMN "sys_notice"."id" IS 'ID';
|
||||
COMMENT ON COLUMN "sys_notice"."title" IS '标题';
|
||||
COMMENT ON COLUMN "sys_notice"."content" IS '内容';
|
||||
COMMENT ON COLUMN "sys_notice"."type" IS '类型';
|
||||
COMMENT ON COLUMN "sys_notice"."effective_time" IS '生效时间';
|
||||
COMMENT ON COLUMN "sys_notice"."terminate_time" IS '终止时间';
|
||||
COMMENT ON COLUMN "sys_notice"."type" IS '分类';
|
||||
COMMENT ON COLUMN "sys_notice"."notice_scope" IS '通知范围(1:所有人;2:指定用户)';
|
||||
COMMENT ON COLUMN "sys_notice"."notice_users" IS '通知用户';
|
||||
COMMENT ON COLUMN "sys_notice"."sort" IS '排序';
|
||||
COMMENT ON COLUMN "sys_notice"."notice_methods" IS '通知方式(1:登录弹窗;2:系统消息)';
|
||||
COMMENT ON COLUMN "sys_notice"."is_timing" IS '是否定时';
|
||||
COMMENT ON COLUMN "sys_notice"."publish_time" IS '发布时间';
|
||||
COMMENT ON COLUMN "sys_notice"."is_top" IS '是否置顶';
|
||||
COMMENT ON COLUMN "sys_notice"."status" IS '状态(1:草稿;2:待发布;3:已发布)';
|
||||
COMMENT ON COLUMN "sys_notice"."create_user" IS '创建人';
|
||||
COMMENT ON COLUMN "sys_notice"."create_time" IS '创建时间';
|
||||
COMMENT ON COLUMN "sys_notice"."update_user" IS '修改人';
|
||||
COMMENT ON COLUMN "sys_notice"."update_time" IS '修改时间';
|
||||
COMMENT ON TABLE "sys_notice" IS '公告表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "sys_notice_log" (
|
||||
"notice_id" int8 NOT NULL,
|
||||
"user_id" int8 NOT NULL,
|
||||
"read_time" timestamp DEFAULT NULL,
|
||||
PRIMARY KEY ("notice_id", "user_id")
|
||||
);
|
||||
COMMENT ON COLUMN "sys_notice_log"."notice_id" IS '消息ID';
|
||||
COMMENT ON COLUMN "sys_notice_log"."user_id" IS '用户ID';
|
||||
COMMENT ON COLUMN "sys_notice_log"."read_time" IS '读取时间';
|
||||
COMMENT ON TABLE "sys_notice_log" IS '公告日志表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "sys_storage" (
|
||||
"id" int8 NOT NULL,
|
||||
"name" varchar(100) NOT NULL,
|
||||
|
Reference in New Issue
Block a user