聊天:加入玩家发起的群聊和测试用例

This commit is contained in:
liangtongchuan
2021-03-05 21:23:28 +08:00
parent d43fd51e9a
commit 5842723458
10 changed files with 195 additions and 23 deletions
+8
View File
@@ -11,6 +11,14 @@ export const MSG_TYPE = {
IMG: 2
}
export const CHANNEL_PREFIX = {
SYS: 'sys',
WORLD: 'new_world',
GUILD: 'new_guild',
}
export const ON_MSG_ROUTE = 'onMessage';
export const ON_GROUP_MSG_ROUTE = 'onGroupMessage';
export const ON_ADD_CHANNEL_ROUTE = 'onAddChannel';
export const DEFAULT_MSG_PER_PAGE = 10;
+1
View File
@@ -225,6 +225,7 @@ export const REDIS_KEY = {
GUILD_ACTIVE_RANK: "guildActiveRank", // 公会周活跃排行榜
DB_GAME: 'db_game', // 服务器列表
ONLINE_USERS: 'onlineUsers', // 在线用户情况
CHANNEL_SERVERS: 'chat:channelServers', // 渠道对应的 chat 服务器 Id
}
// 各排行榜对应hash的key
+15
View File
@@ -39,6 +39,21 @@ export default class GroupMessage extends BaseModel {
@prop({ required: true, default: '' })
content: string; // 消息内容
public static async createMsg(data: GroupMessageParam) {
const result = await GroupMessageModel.findOneAndUpdate({ msgCode: data.msgCode }, {...data}, {upsert: true, new: true}).lean();
return result;
}
public static async findOneMsg(query: GroupMessageParam) {
const result = await GroupMessageModel.findOne(query).lean();
return result;
}
public static async getMsgs(roomId: string, fromSeqId: number, count: number) {
const result = await GroupMessageModel.find({ roomId, seqId: { $lt: fromSeqId } }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
}