初始连接添加军团信息

This commit is contained in:
luying
2021-02-04 15:20:44 +08:00
parent aaeaf87324
commit 86c8cbc2f1
5 changed files with 40 additions and 13 deletions

View File

@@ -1,16 +1,18 @@
export enum ROLE_SELECT {
// 初始登录数据
ENTRY = 'serverId userInfo.uid userInfo.tel ce topFiveCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild',
// 玩家列表显示基础数据
SHOW_SIMPLE = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName',
SHOW_FRIEND_APPLY_LIST = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName friendCnt recFrdApplyCnt',
HANDLE_APPLY = 'roleId friendCnt lv',
ATTR = 'globalCeAttr',
GET_LV = 'lv',
GET_ROLE_ID = 'roleId'
};
export enum HERO_SELECT {
ENTRY = '-ceAttr',
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins ceAttr'
}
@@ -20,4 +22,12 @@ export enum EQUIP_SELECT {
export enum FRIEND {
SEND_PRESENT = 'friendValue friendLv'
}
export enum USER_GUILD_SELECT {
ENTRY = 'guildCode auth'
}
export enum GUILD_SELECT {
ENTRY = 'guildCode lv memberCnt'
}

View File

@@ -145,12 +145,12 @@ export default class Hero extends BaseModel {
@prop({ required: true, type: EPlace, default: getInitialEplace(), _id: false })
ePlace: EPlace[]; // 武将装备引用数组
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = []) {
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = [], select?: string, getters = false) {
let sortParam = {};
for(let {field, sortBy} of sort) {
sortParam[field] = sortBy;
}
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).lean();
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).select(select).lean({ getters });
return heros;
}

View File

@@ -116,7 +116,7 @@ export default class Role extends BaseModel {
ce: number; // 总战力
@prop({ required: true, default: new CeAttrRole(), _id: false })
globalCeAttr: CeAttrRole; // 总战力
@prop({ required: true, default: 0 })
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
topFiveCe: number; // 最强5人战力
@prop({ required: true, type: TopHero, default: [], _id: false })
topFive: Array<TopHero>; // 总战力
@@ -230,8 +230,8 @@ export default class Role extends BaseModel {
return role;
}
public static async findByUid(uid: number, serverId: number, lean = true) {
const role: RoleType = await RoleModel.findOneAndUpdate({ 'userInfo.uid': uid, serverId }, { loginTime: nowSeconds() }, { new: true }).lean(lean);
public static async findByUid(uid: number, serverId: number, select?: string, getters = false) {
const role: RoleType = await RoleModel.findOneAndUpdate({ 'userInfo.uid': uid, serverId }, { loginTime: nowSeconds() }, { new: true }).select(select).lean({ getters });
return role;
}

View File

@@ -105,7 +105,7 @@ export class GuildListInfo extends GuildMainInfo {
constructor(guild: GuildType) {
super(guild);
let leader = <RoleType>guild.leader;
this.leader = leader.roleName;
if(leader) this.leader = leader.roleName;
}
setApply(hasApply: boolean) {