Merge branch 'master' of gitlab.trgame.cn:zyztech/zyz_server
This commit is contained in:
@@ -28,10 +28,7 @@ export default class UserGuildApply extends BaseModel {
|
|||||||
// 创建申请或邀请
|
// 创建申请或邀请
|
||||||
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
|
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
|
||||||
const applyCode = genCode(10);
|
const applyCode = genCode(10);
|
||||||
const doc = new UserGuildApplyModel();
|
const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate({ roleId: role.roleId, guildCode: guild.code, type }, { $set: { roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id }, $setOnInsert: { applyCode }}, { upsert: true, new: true }).lean();
|
||||||
const update = Object.assign(doc.toJSON(), { applyCode, roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id, type });
|
|
||||||
delete update._id;
|
|
||||||
const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate({ applyCode }, update, { upsert: true, new: true }).lean();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user