This commit is contained in:
lightings 2023-05-17 14:20:01 +08:00
parent 88fbae767d
commit b7cd139ed1
2 changed files with 63 additions and 3 deletions

View File

@ -111,7 +111,7 @@ class GuildDao {
async getGuildInfo(gId) { async getGuildInfo(gId) {
const guild = await this.getGuild(gId); const guild = await this.getGuild(gId);
if (guild) { if (guild) {
const countmember = await this.countGuildMembers(gId); const countmember = await this.countGuildMembers(gId);
guild.countmember = countmember; guild.countmember = countmember;
return guild; return guild;
} }
@ -171,7 +171,7 @@ class GuildDao {
} }
async kick(uId, mId) { async kick(uId, mId) {
const ql = "SELECT * FROM t_guild_members WHERE uid=?"; const ql = "SELECT * FROM t_guild_members WHERE uid=? AND apply=2";
const rl = await query_guild(ql, [uId]); const rl = await query_guild(ql, [uId]);
if (rl && rl.length > 0) { if (rl && rl.length > 0) {
const qfm = "SELECT * FROM t_guild_members WHERE uid=? AND apply=2"; const qfm = "SELECT * FROM t_guild_members WHERE uid=? AND apply=2";
@ -304,6 +304,12 @@ class GuildDao {
return false; return false;
} }
async deleteGuildMember(gId, uId) {
const q = "DELETE FROM t_guild_members WHERE guild_idx=? AND uid=?";
const r = await query_guild(q, [gId, uId]);
return r != null;
}
async getMemberInfo(guildId, uid) { async getMemberInfo(guildId, uid) {
const query = const query =
"SELECT * FROM t_guild_members WHERE guild_idx = ? AND uid = ? AND apply = 2"; "SELECT * FROM t_guild_members WHERE guild_idx = ? AND uid = ? AND apply = 2";

View File

@ -232,7 +232,7 @@ class ChatHandler {
* @apiParam {String} from 发送者信息 * @apiParam {String} from 发送者信息
* @apiParam {String} content 聊天内容 * @apiParam {String} content 聊天内容
* @apiParam {String} contentType 内容类型 * @apiParam {String} contentType 内容类型
* @apiParam {String} type 聊天类型 [ world | team ] * @apiParam {String} type 聊天类型 [ world | team | private ]
* *
* @apiSuccessExample {json} Success-Response: * @apiSuccessExample {json} Success-Response:
* { * {
@ -325,4 +325,58 @@ class ChatHandler {
msg: "User not team member", msg: "User not team member",
}); });
} }
/** @api {post} chat.chatHandler.privateChat privateChat
* @apiGroup Chat
*
* @apiParam {String} content 聊天内容
* @apiParam {String} contentType 内容类型
* @apiParam {String} targetuid 目标用户ID
*
* @apiSuccess {Number} code 状态码
*
* @apiSuccessExample {json} Success-Response:
* {
* "code": 200
* }
*
* @apiErrorExample {json} Error-Response:
* {
* "code": 500,
* "msg": "Failed to private chat."
* }
*
*
*/
async privateChat(msg, session, next) {
const { uid } = session;
const userInfo = session.get("userInfo");
const senderInfo = {
username: userInfo.name,
account_id: userInfo.account_id,
head_frame: userInfo.head_frame,
head_id: userInfo.head_id,
};
const content = msg.content;
const contentType = msg.contentType;
const targetuid = msg.targetuid;
const channelId = `privateChannel_${targetuid}`;
this.gcs.add(channelId, session.uid, session.get("sid"), function () {});
this.gcs.pushMessage(
"connector",
"onChat",
{
code: Code.OK,
route: "onChat",
from: senderInfo,
content: content,
contentType: contentType,
type: "private",
},
channelId
);
next(null, { code: 200 });
}
} }