后台:权限
This commit is contained in:
+91
-153
@@ -5,9 +5,8 @@ import { EquipModel } from '@db/Equip';
|
||||
import { PvpDefenseModel } from '@db/PvpDefense';
|
||||
|
||||
import { Service } from 'egg';
|
||||
import Counter from '@db/Counter';
|
||||
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, REDIS_KEY, WAR_TYPE } from '@consts';
|
||||
import { ITID, COUNTER } from '@consts';
|
||||
import { ITID } from '@consts';
|
||||
import { ItemModel } from '@db/Item';
|
||||
import { gameData, getExpByLv } from '@pubUtils/data';
|
||||
import { calPlayerCeAndSave, calculatetopLineup, calEquipSeids } from '@pubUtils/playerCe';
|
||||
@@ -60,21 +59,21 @@ export default class GMUsers extends Service {
|
||||
|
||||
}
|
||||
|
||||
public async createRole(uid: number, serverId: number, roleName: string) {
|
||||
console.log('enter Auth createRole');
|
||||
const ctx = this.ctx;
|
||||
// public async createRole(uid: number, serverId: number, roleName: string) {
|
||||
// console.log('enter Auth createRole');
|
||||
// const ctx = this.ctx;
|
||||
|
||||
const roleId = ctx.service.utils.genCode(10);
|
||||
const code = ctx.service.utils.genCode(6);
|
||||
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
||||
if (role) {
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} else {
|
||||
console.error('create role error');
|
||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
|
||||
}
|
||||
}
|
||||
// const roleId = ctx.service.utils.genCode(10);
|
||||
// const code = ctx.service.utils.genCode(6);
|
||||
// const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||
// const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
||||
// if (role) {
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// } else {
|
||||
// console.error('create role error');
|
||||
// return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public async addAuth(uid: number, auth: number) {
|
||||
// console.log('enter Auth addAuth');
|
||||
@@ -309,14 +308,6 @@ export default class GMUsers extends Service {
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||
}
|
||||
|
||||
public async getPvpDefense(roleId: string) {
|
||||
const { ctx } = this;
|
||||
let result = await PvpDefenseModel.findByRoleId(roleId);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
hasDefense: !!result, defense: result
|
||||
})
|
||||
}
|
||||
|
||||
// public async getHeroList(roleId: string) {
|
||||
// const {ctx} = this;
|
||||
// let herolist = await HeroModel.findByRole(roleId);
|
||||
@@ -340,59 +331,6 @@ export default class GMUsers extends Service {
|
||||
// })
|
||||
// }
|
||||
|
||||
// public async saveHeroToDefense(roleId: string, _roleName: string, hid: number) {
|
||||
// const { ctx } = this;
|
||||
// let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
// let role = await RoleModel.findByRoleId(roleId);
|
||||
// if (!hero || !role) {
|
||||
// return ctx.service.utils.resResult(STATUS.GM_HERO_NOT_FOUND);
|
||||
// }
|
||||
// let { lv, ce, attr: heroAttrs } = hero;
|
||||
// let { attr: roleAttrs } = role;
|
||||
|
||||
|
||||
// let dicHero = gameData.hero.get(hid);
|
||||
|
||||
// let attribute = new AttributeCal();
|
||||
// attribute.setByDbData(roleAttrs, heroAttrs);
|
||||
|
||||
// let heroInfo = {
|
||||
// actorId: dicHero.heroId,
|
||||
// actorName: dicHero.name,
|
||||
// attribute, lv,
|
||||
// ce
|
||||
// };
|
||||
|
||||
// let defense = await PvpDefenseModel.findByRoleId(roleId);
|
||||
// if (!defense) {
|
||||
// // defense = await PvpDefenseModel.createPvpDefense({roleId, roleName, heroes: [], defCe:ce});
|
||||
// } else {
|
||||
// defense = await PvpDefenseModel.addHeroToDefense(roleId, heroInfo, ce);
|
||||
// }
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
// defense
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// public async removeHeroFromDefense(roleId: string, hid: number) {
|
||||
// const { ctx } = this;
|
||||
|
||||
// let defense = await PvpDefenseModel.findByRoleId(roleId);
|
||||
// if (!defense) {
|
||||
// return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_NOT_FOUND);
|
||||
// }
|
||||
// let { heroes } = defense;
|
||||
// let curHero = heroes.find(cur => cur.actorId == hid);
|
||||
// if (!curHero) {
|
||||
// return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_HERO_NOT_FOUND);
|
||||
// }
|
||||
// defense = await PvpDefenseModel.removeHeroFromDefense(roleId, hid, curHero.ce);
|
||||
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||
// defense
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据类型等搜索玩家
|
||||
@@ -493,102 +431,102 @@ export default class GMUsers extends Service {
|
||||
}
|
||||
|
||||
|
||||
public async setItemCount(roleIdAndIds: string[], count: number) {
|
||||
console.log('enter Auth setItemCount');
|
||||
const ctx = this.ctx;
|
||||
let map = new Map<string, number[]>();
|
||||
for (let roleIdAndId of roleIdAndIds) {
|
||||
let [roleId, idStr] = roleIdAndId.split('|');
|
||||
if (isNaN(parseInt(idStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// public async setItemCount(roleIdAndIds: string[], count: number) {
|
||||
// console.log('enter Auth setItemCount');
|
||||
// const ctx = this.ctx;
|
||||
// let map = new Map<string, number[]>();
|
||||
// for (let roleIdAndId of roleIdAndIds) {
|
||||
// let [roleId, idStr] = roleIdAndId.split('|');
|
||||
// if (isNaN(parseInt(idStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let id = parseInt(idStr);
|
||||
let cur = map.get(roleId);
|
||||
if (!cur) {
|
||||
cur = new Array<number>();
|
||||
map.set(roleId, cur);
|
||||
}
|
||||
cur.push(id);
|
||||
}
|
||||
// let id = parseInt(idStr);
|
||||
// let cur = map.get(roleId);
|
||||
// if (!cur) {
|
||||
// cur = new Array<number>();
|
||||
// map.set(roleId, cur);
|
||||
// }
|
||||
// cur.push(id);
|
||||
// }
|
||||
|
||||
for (let [roleId, ids] of map) {
|
||||
await ItemModel.updateCountByRoleAndIds(roleId, ids, count);
|
||||
}
|
||||
// for (let [roleId, ids] of map) {
|
||||
// await ItemModel.updateCountByRoleAndIds(roleId, ids, count);
|
||||
// }
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
public async setHeroLv(roleIdAndHids: string[], _hlv: string) {
|
||||
// public async setHeroLv(roleIdAndHids: string[], _hlv: string) {
|
||||
|
||||
try {
|
||||
console.log('gm setHeroLv', roleIdAndHids, _hlv);
|
||||
const ctx = this.ctx;
|
||||
let hlv = parseInt(_hlv);
|
||||
if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// try {
|
||||
// console.log('gm setHeroLv', roleIdAndHids, _hlv);
|
||||
// const ctx = this.ctx;
|
||||
// let hlv = parseInt(_hlv);
|
||||
// if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
for (let roleIdAndHid of roleIdAndHids) {
|
||||
let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// for (let roleIdAndHid of roleIdAndHids) {
|
||||
// let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
// if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let hid = parseInt(hidStr);
|
||||
// let hid = parseInt(hidStr);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
console.log(hid, roleId, !!hero);
|
||||
if (!hero) continue;
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, { lv: hlv });
|
||||
}
|
||||
// let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
// console.log(hid, roleId, !!hero);
|
||||
// if (!hero) continue;
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, { lv: hlv });
|
||||
// }
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} catch (e) {
|
||||
console.error((<Error>e).stack)
|
||||
}
|
||||
}
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// } catch (e) {
|
||||
// console.error((<Error>e).stack)
|
||||
// }
|
||||
// }
|
||||
|
||||
public async setHeroParam(roleIdAndHids: string[], star: number, colorStar: number, quality: number) {
|
||||
try {
|
||||
const ctx = this.ctx;
|
||||
if (typeof star != 'number'||typeof colorStar != 'number'||typeof quality != 'number') return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// public async setHeroParam(roleIdAndHids: string[], star: number, colorStar: number, quality: number) {
|
||||
// try {
|
||||
// const ctx = this.ctx;
|
||||
// if (typeof star != 'number'||typeof colorStar != 'number'||typeof quality != 'number') return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
for (let roleIdAndHid of roleIdAndHids) {
|
||||
let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// for (let roleIdAndHid of roleIdAndHids) {
|
||||
// let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
// if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let hid = parseInt(hidStr);
|
||||
// let hid = parseInt(hidStr);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
console.log(hid, roleId, !!hero);
|
||||
if (!hero) continue;
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, { star, colorStar, quality });
|
||||
}
|
||||
// let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
// console.log(hid, roleId, !!hero);
|
||||
// if (!hero) continue;
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, { star, colorStar, quality });
|
||||
// }
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} catch (e) {
|
||||
console.error((<Error>e).stack)
|
||||
}
|
||||
}
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// } catch (e) {
|
||||
// console.error((<Error>e).stack)
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public async setHeroJob(roleIdAndHids: string[], job: number) {
|
||||
try {
|
||||
const ctx = this.ctx;
|
||||
if(!gameData.job.has(job)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// public async setHeroJob(roleIdAndHids: string[], job: number) {
|
||||
// try {
|
||||
// const ctx = this.ctx;
|
||||
// if(!gameData.job.has(job)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
for (let roleIdAndHid of roleIdAndHids) {
|
||||
let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
// for (let roleIdAndHid of roleIdAndHids) {
|
||||
// let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||
// if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let hid = parseInt(hidStr);
|
||||
// let hid = parseInt(hidStr);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
console.log(hid, roleId, !!hero);
|
||||
if (!hero) continue;
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, roleId, hero, { job });
|
||||
}
|
||||
// let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
// console.log(hid, roleId, !!hero);
|
||||
// if (!hero) continue;
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, roleId, hero, { job });
|
||||
// }
|
||||
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
} catch (e) {
|
||||
console.error((<Error>e).stack)
|
||||
}
|
||||
}
|
||||
// return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
// } catch (e) {
|
||||
// console.error((<Error>e).stack)
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据类型等搜索装备
|
||||
|
||||
Reference in New Issue
Block a user