Merge branch 'master' of gitlab.trgame.cn:zyztech/zyz_server

This commit is contained in:
mamengke01
2021-01-26 19:05:41 +08:00

View File

@@ -28,10 +28,7 @@ export default class UserGuildApply extends BaseModel {
// 创建申请或邀请
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
const applyCode = genCode(10);
const doc = new UserGuildApplyModel();
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();
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();
return result;
}