军团:邀请被邀请
This commit is contained in:
@@ -134,6 +134,7 @@ export const STATUS = {
|
||||
GUILD_QUIT_ERROR: { code: 20907, simStr: '退出公会失败' },
|
||||
GUILD_KICK_ERROR: { code: 20908, simStr: '未找到该成员或该成员已退出' },
|
||||
GUILD_QUIT_TIME: { code: 20909, simStr: '退出军团1小时后才可以申请' },
|
||||
GUILD_INVITE_NOT_FOUND: { code: 20910, simStr: '该邀请未找到' },
|
||||
|
||||
// 通用 30000 - 30099
|
||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from './generalField';
|
||||
import { PvpEnemies, PvpOtherHeroes } from './generalField';
|
||||
|
||||
export class HeroScores {
|
||||
@prop({ required: true })
|
||||
|
||||
+3
-2
@@ -413,9 +413,10 @@ export default class Role extends BaseModel {
|
||||
}
|
||||
|
||||
// 获取未加入公会且登录时间在三天内的人
|
||||
public static async getInviteList(time: number) {
|
||||
const result = await RoleModel.find({ loginTime: { $gt: time }, hasGuild: false })
|
||||
public static async getInviteList(time: number, serverId: number) {
|
||||
const result = await RoleModel.find({ loginTime: { $gt: time }, hasGuild: false, serverId })
|
||||
.select('roleId roleName ce headHid sHid lv title job loginTime')
|
||||
.sort({loginTime: -1, lv: -1, ce: -1})
|
||||
.limit(100).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||
import Role, { RoleType } from './Role';
|
||||
import Guild from './Guild';
|
||||
import { GUILD_AUTH, USER_GUILD_STATUS, GUILD_JOB } from '../consts';
|
||||
import { GUILD } from '../pubUtils/dicParam';
|
||||
|
||||
class ActiveRecord {
|
||||
@prop({ required: true })
|
||||
|
||||
@@ -2,7 +2,7 @@ import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||
import Role, { RoleType } from './Role';
|
||||
import Guild, { GuildType } from './Guild';
|
||||
import { GUILD_AUTH, USER_GUILD_STATUS, GUILD_JOB, GUILD_APPLY_STATUS, GUILD_APPLY_TYPE, GUILD_PER_PAGE, GUILD_STATUS } from '../consts';
|
||||
import { GUILD_APPLY_TYPE, GUILD_PER_PAGE } from '../consts';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
@index({ roleId: 1 })
|
||||
@@ -25,6 +25,7 @@ export default class UserGuildApply extends BaseModel {
|
||||
@prop({ required: true, enum: GUILD_APPLY_TYPE, select: false})
|
||||
type: number;
|
||||
|
||||
// 创建申请或邀请
|
||||
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
|
||||
const applyCode = genCode(10);
|
||||
const doc = new UserGuildApplyModel();
|
||||
@@ -35,36 +36,43 @@ export default class UserGuildApply extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 删除玩家发出的所有申请
|
||||
public static async deleteApply(roleId: string) {
|
||||
const result = await UserGuildApplyModel.deleteMany({ roleId, type: GUILD_APPLY_TYPE.APPLY });
|
||||
return result;
|
||||
}
|
||||
|
||||
// 删除公会收到的所有申请
|
||||
public static async deleteApplyByGuild(guildCode: string) {
|
||||
const result = await UserGuildApplyModel.deleteMany({ guildCode, type: GUILD_APPLY_TYPE.APPLY });
|
||||
return result;
|
||||
}
|
||||
|
||||
// 根据唯一code批量删除
|
||||
public static async deleteApplyByApplyCode(applyCodeList: string[]) {
|
||||
const result = await UserGuildApplyModel.deleteMany({ applyCode: { $in: applyCodeList}, type: GUILD_APPLY_TYPE.APPLY });
|
||||
return result;
|
||||
}
|
||||
|
||||
// 根绝唯一code查询申请或邀请
|
||||
public static async findByCode(applyCode: string) {
|
||||
const userGuildApply: UserGuildApplyType = await UserGuildApplyModel.findOne({ applyCode }).lean();
|
||||
return userGuildApply;
|
||||
}
|
||||
|
||||
// 查询用户的申请列表
|
||||
public static async findApplyByRole(roleId: string) {
|
||||
const userGuildApply: UserGuildApplyType[] = await UserGuildApplyModel.find({ roleId, type: GUILD_APPLY_TYPE.APPLY }).lean();
|
||||
return userGuildApply;
|
||||
}
|
||||
|
||||
// 根据唯一code查询申请或邀请
|
||||
public static async getListByApplyCode(applyCodeList: string[]) {
|
||||
const userGuildApply: UserGuildApplyType[] = await UserGuildApplyModel.find({ applyCode: { $in: applyCodeList}, type: GUILD_APPLY_TYPE.APPLY }).lean();
|
||||
return userGuildApply;
|
||||
}
|
||||
|
||||
// 查询公会收到的申请
|
||||
public static async getListByGuild(code: string, lastApplyCode: string) {
|
||||
let condition = { guildCode: code, type: GUILD_APPLY_TYPE.APPLY };
|
||||
if(lastApplyCode) {
|
||||
@@ -78,6 +86,30 @@ export default class UserGuildApply extends BaseModel {
|
||||
.limit(GUILD_PER_PAGE).lean();
|
||||
return list
|
||||
}
|
||||
|
||||
// 查询玩家的邀请列表
|
||||
public static async getListByRole(roleId: string, lastApplyCode: string) {
|
||||
let condition = { roleId, type: GUILD_APPLY_TYPE.INVITE };
|
||||
if(lastApplyCode) {
|
||||
const lastApply = await this.findByCode(lastApplyCode);
|
||||
condition["createdAt"] = { $lt: lastApply.createdAt };
|
||||
}
|
||||
const list: UserGuildApplyType[] = await UserGuildApplyModel.find(condition)
|
||||
.sort({ createdAt: -1 })
|
||||
.select('applyCode guild')
|
||||
.populate({
|
||||
path: 'guild',
|
||||
select: 'code icon name lv memberCnt leader ceLimit',
|
||||
model: 'Guild',
|
||||
populate: {
|
||||
path: 'leader',
|
||||
select: 'roleName',
|
||||
model: 'Role'
|
||||
}
|
||||
})
|
||||
.limit(GUILD_PER_PAGE).lean();
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
export const UserGuildApplyModel = getModelForClass(UserGuildApply);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 一些通用的interface定义
|
||||
|
||||
import { reduceCe } from "./util";
|
||||
import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from "../db/generalField";
|
||||
import { PvpEnemies, PvpOtherHeroes } from "../db/generalField";
|
||||
import { GuildType } from "../db/Guild";
|
||||
import { RoleType } from "../db/Role";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user