mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
refactor: 补充消息类型字典初始数据
This commit is contained in:
@@ -32,9 +32,9 @@ import top.continew.starter.data.mybatis.plus.base.IBaseEnum;
|
||||
public enum MessageTypeEnum implements IBaseEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 系统消息
|
||||
* 安全消息
|
||||
*/
|
||||
SYSTEM(1, "系统消息", UiConstants.COLOR_PRIMARY),;
|
||||
SECURITY(1, "安全消息", UiConstants.COLOR_PRIMARY),;
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
@@ -55,6 +55,7 @@ import top.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||
import top.continew.starter.core.util.validate.CheckUtils;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.util.TreeUtils;
|
||||
import top.continew.starter.messaging.websocket.util.WebSocketUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -139,7 +140,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
userSocial.setUserId(userId);
|
||||
userSocial.setSource(source);
|
||||
userSocial.setOpenId(openId);
|
||||
this.sendSystemMsg(user);
|
||||
this.sendSecurityMsg(user);
|
||||
} else {
|
||||
user = BeanUtil.copyProperties(userService.getById(userSocial.getUserId()), UserDO.class);
|
||||
}
|
||||
@@ -243,16 +244,17 @@ public class LoginServiceImpl implements LoginService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
* 发送安全消息
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
private void sendSystemMsg(UserDO user) {
|
||||
private void sendSecurityMsg(UserDO user) {
|
||||
MessageReq req = new MessageReq();
|
||||
MessageTemplateEnum socialRegister = MessageTemplateEnum.SOCIAL_REGISTER;
|
||||
req.setTitle(socialRegister.getTitle().formatted(projectProperties.getName()));
|
||||
req.setContent(socialRegister.getContent().formatted(user.getNickname()));
|
||||
req.setType(MessageTypeEnum.SYSTEM);
|
||||
req.setType(MessageTypeEnum.SECURITY);
|
||||
messageService.add(req, CollUtil.toList(user.getId()));
|
||||
WebSocketUtils.sendMessage(user.getId().toString(), "1");
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.continew.admin.webapi.system;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
@@ -24,10 +23,8 @@ 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.enums.MessageTypeEnum;
|
||||
import top.continew.admin.common.util.helper.LoginHelper;
|
||||
import top.continew.admin.system.model.query.MessageQuery;
|
||||
import top.continew.admin.system.model.req.MessageReq;
|
||||
import top.continew.admin.system.model.resp.MessageResp;
|
||||
import top.continew.admin.system.model.resp.MessageUnreadResp;
|
||||
import top.continew.admin.system.service.MessageService;
|
||||
@@ -35,10 +32,8 @@ import top.continew.admin.system.service.MessageUserService;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.log.core.annotation.Log;
|
||||
import top.continew.starter.messaging.websocket.util.WebSocketUtils;
|
||||
import top.continew.starter.web.model.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -86,17 +81,4 @@ public class MessageController {
|
||||
public R<MessageUnreadResp> countUnreadMessage(@RequestParam(required = false) Boolean detail) {
|
||||
return R.ok(messageUserService.countUnreadMessageByUserId(LoginHelper.getUserId(), detail));
|
||||
}
|
||||
|
||||
@GetMapping("/testSend")
|
||||
public R<Object> testSend(String msg) {
|
||||
List<Long> userIdList = new ArrayList<>();
|
||||
userIdList.add(LoginHelper.getUserId());
|
||||
MessageReq req = new MessageReq();
|
||||
req.setTitle(msg);
|
||||
req.setContent(msg);
|
||||
req.setType(MessageTypeEnum.SYSTEM);
|
||||
baseService.add(req, userIdList);
|
||||
WebSocketUtils.sendMessage(Convert.toStr(LoginHelper.getUserId()), msg);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
@@ -135,13 +135,16 @@ VALUES
|
||||
INSERT INTO `sys_dict`
|
||||
(`id`, `name`, `code`, `description`, `is_system`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||
VALUES
|
||||
(547889614262632491, '公告类型', 'notice_type', NULL, b'1', 1, NOW(), NULL, NULL);
|
||||
(1, '公告类型', 'notice_type', NULL, b'1', 1, NOW(), NULL, NULL),
|
||||
(2, '消息类型', 'message_type', NULL, b'1', 1, NOW(), NULL, NULL);
|
||||
|
||||
INSERT INTO `sys_dict_item`
|
||||
(`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||
VALUES
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL);
|
||||
(1, '通知', '1', 'blue', 1, NULL, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(2, '活动', '2', 'orangered', 2, NULL, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(3, '安全消息', '1', 'blue', 1, NULL, 1, 2, 1, NOW(), NULL, NULL),
|
||||
(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW(), NULL, NULL);
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO `sys_user_role`
|
||||
@@ -168,5 +171,5 @@ INSERT INTO `sys_role_dept` (`role_id`, `dept_id`) VALUES (547888897925840928, 5
|
||||
INSERT INTO `sys_storage`
|
||||
(`id`, `name`, `code`, `type`, `access_key`, `secret_key`, `endpoint`, `bucket_name`, `domain`, `description`, `is_default`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||
VALUES
|
||||
(547890346239983671, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', b'1', 1, 1, 1, NOW(), NULL, NULL),
|
||||
(547890366586552377, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL);
|
||||
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', b'1', 1, 1, 1, NOW(), NULL, NULL),
|
||||
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL);
|
@@ -135,13 +135,16 @@ VALUES
|
||||
INSERT INTO "sys_dict"
|
||||
("id", "name", "code", "description", "is_system", "create_user", "create_time", "update_user", "update_time")
|
||||
VALUES
|
||||
(547889614262632491, '公告类型', 'notice_type', NULL, true, 1, NOW(), NULL, NULL);
|
||||
(1, '公告类型', 'notice_type', NULL, true, 1, NOW(), NULL, NULL),
|
||||
(2, '消息类型', 'message_type', NULL, true, 1, NOW(), NULL, NULL);
|
||||
|
||||
INSERT INTO "sys_dict_item"
|
||||
("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time", "update_user", "update_time")
|
||||
VALUES
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL);
|
||||
(1, '通知', '1', 'blue', 1, NULL, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(2, '活动', '2', 'orangered', 2, NULL, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(3, '安全消息', '1', 'blue', 1, NULL, 1, 2, 1, NOW(), NULL, NULL),
|
||||
(4, '活动消息', '2', 'orangered', 2, NULL, 1, 2, 1, NOW(), NULL, NULL);
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO "sys_user_role"
|
||||
@@ -168,5 +171,5 @@ INSERT INTO "sys_role_dept" ("role_id", "dept_id") VALUES (547888897925840928, 5
|
||||
INSERT INTO "sys_storage"
|
||||
("id", "name", "code", "type", "access_key", "secret_key", "endpoint", "bucket_name", "domain", "description", "is_default", "sort", "status", "create_user", "create_time", "update_user", "update_time")
|
||||
VALUES
|
||||
(547890346239983671, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', true, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(547890366586552377, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', false, 2, 2, 1, NOW(), NULL, NULL);
|
||||
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', true, 1, 1, 1, NOW(), NULL, NULL),
|
||||
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.continew.top/file', '本地存储', false, 2, 2, 1, NOW(), NULL, NULL);
|
||||
|
Reference in New Issue
Block a user