优化:减少初始以及合成武将时返回的数据
This commit is contained in:
@@ -18,14 +18,22 @@ export enum ROLE_SELECT {
|
||||
};
|
||||
|
||||
export enum HERO_SELECT {
|
||||
ENTRY = '-_id -attr',
|
||||
ENTRY = '-_id -attr -__v',
|
||||
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr ePlace skinId',
|
||||
// 排行榜中lineup字段
|
||||
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce updatedAt skinId'
|
||||
}
|
||||
|
||||
export enum EQUIP_SELECT {
|
||||
HERO_DETAIL = 'id name ePlaceId quality holes randSe randRange randMain'
|
||||
export enum JEWEL_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -name -previewRandSe -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum ITEM_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -itemName -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum SKIN_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -skinName -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum FRIEND_SELECT {
|
||||
@@ -33,7 +41,7 @@ export enum FRIEND_SELECT {
|
||||
}
|
||||
|
||||
export enum USER_GUILD_SELECT {
|
||||
ENTRY = 'guildCode auth'
|
||||
ENTRY = '-_id -_v guildCode auth'
|
||||
}
|
||||
|
||||
export enum GUILD_SELECT {
|
||||
|
||||
@@ -25,8 +25,8 @@ export default class Item extends BaseModel {
|
||||
count: number; // 道具数量
|
||||
|
||||
|
||||
public static async findbyRole(roleId: string, lean = true) {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select(select).lean();
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ export default class Jewel extends BaseModel {
|
||||
@prop({ required: false, type: RandSe, default: [], _id: false })
|
||||
previewRandSe: RandSe[]; // 强化随机属性预览
|
||||
|
||||
public static async findbyRole(roleId: string, lean = true) {
|
||||
const jewels: JewelType[] = await JewelModel.find({ roleId }).lean(lean);
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const jewels: JewelType[] = await JewelModel.find({ roleId }).select(select).lean();
|
||||
return jewels;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ export default class Skin extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
hid: number; // 原始武将id
|
||||
|
||||
public static async findbyRole(roleId: string) {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinId skinName hid').lean();
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }).select(select).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
interface QuenchAddParam {
|
||||
id: number; // 属性id
|
||||
value: number; // 增加的值
|
||||
}
|
||||
|
||||
export class QuenchLogParam {
|
||||
times: number; // 第几次
|
||||
isCriticle: boolean; // 是否暴击
|
||||
add: QuenchAddParam[];
|
||||
|
||||
constructor(isCriticle: boolean, add: Map<number, number>) {
|
||||
this.isCriticle = isCriticle;
|
||||
|
||||
let arr: QuenchAddParam[] = [];
|
||||
for(let [id, value] of add) {
|
||||
arr.push({ id, value });
|
||||
}
|
||||
this.add = arr;
|
||||
}
|
||||
|
||||
setTimes(times: number) {
|
||||
this.times = times;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
|
||||
import { JewelType, RandSe } from '../../db/Jewel';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
export interface CreateHeroParam extends HeroUpdate {
|
||||
hid: number;
|
||||
@@ -34,7 +35,6 @@ class HeroSKinParam {
|
||||
// 传给客户端的武将数据
|
||||
export class HeroParam {
|
||||
hid: number; // 武将 id
|
||||
hName: string; // 武将名
|
||||
seqId: number; // 武将表自增 id
|
||||
|
||||
exp: number; // 经验值
|
||||
@@ -69,7 +69,6 @@ export class HeroParam {
|
||||
constructor(hero: HeroType) {
|
||||
this.seqId = hero.seqId;
|
||||
this.hid = hero.hid;
|
||||
this.hName = hero.hName;
|
||||
this.exp = hero.exp;
|
||||
this.lv = hero.lv;
|
||||
this.ce = hero.ce;
|
||||
@@ -99,4 +98,31 @@ export class HeroParam {
|
||||
}
|
||||
this.ePlace = hero.ePlace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class JewelParam {
|
||||
seqId: number; // 唯一id
|
||||
id: number; // 装备id
|
||||
name: string; // 装备名
|
||||
hid: number; // 装备此装备的武将
|
||||
ePlaceId: number; // 装备在哪个位置
|
||||
|
||||
randSe: RandSe[];
|
||||
count: number;
|
||||
inc: number;
|
||||
reason: number;
|
||||
|
||||
constructor(jewel: JewelType, isPush?: boolean, reason?: number) {
|
||||
this.seqId = jewel.seqId;
|
||||
this.id = jewel.id;
|
||||
this.name = jewel.name;
|
||||
this.hid = jewel.hid;
|
||||
this.ePlaceId = jewel.ePlaceId;
|
||||
this.randSe = jewel.randSe;
|
||||
if(isPush) {
|
||||
this.count = 1;
|
||||
this.inc = 1;
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user