hid的初始seqId改为10000
This commit is contained in:
@@ -3,6 +3,7 @@ import { HeroModel } from '../../../db/Hero';
|
|||||||
import { EquipModel } from '../../../db/Equip';
|
import { EquipModel } from '../../../db/Equip';
|
||||||
import { calculateCE } from '../../../pubUtils/util';
|
import { calculateCE } from '../../../pubUtils/util';
|
||||||
import {Application, BackendSession, createTcpMailBox} from 'pinus';
|
import {Application, BackendSession, createTcpMailBox} from 'pinus';
|
||||||
|
import { COUNTER } from '../../../consts/consts';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new RoleHandler(app);
|
return new RoleHandler(app);
|
||||||
@@ -13,7 +14,7 @@ export class RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initEquips(roleId: string, roleName: string) {
|
async initEquips(roleId: string, roleName: string) {
|
||||||
const seqId = await CounterModel.getNewCounter('eid');
|
const seqId = await CounterModel.getNewCounter(COUNTER.EID);
|
||||||
const equipInfo = {
|
const equipInfo = {
|
||||||
roleId,
|
roleId,
|
||||||
roleName,
|
roleName,
|
||||||
@@ -27,7 +28,7 @@ export class RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initHeros(roleId: string, roleName: string) {
|
async initHeros(roleId: string, roleName: string) {
|
||||||
const seqId = await CounterModel.getNewCounter('hid');
|
const seqId = await CounterModel.getNewCounter(COUNTER.HID);
|
||||||
let ce = calculateCE({hid: 1, lv: 1});
|
let ce = calculateCE({hid: 1, lv: 1});
|
||||||
|
|
||||||
const heroInfo = {
|
const heroInfo = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GOOD_TYPE, ITID, CURRENCY, CURRENCY_TYPE } from './../consts/consts';
|
import { GOOD_TYPE, ITID, CURRENCY, CURRENCY_TYPE, COUNTER } from './../consts/consts';
|
||||||
import { EquipModel } from './../db/Equip';
|
import { EquipModel } from './../db/Equip';
|
||||||
import { CounterModel } from './../db/Counter';
|
import { CounterModel } from './../db/Counter';
|
||||||
import { decodeStr } from '../pubUtils/util';
|
import { decodeStr } from '../pubUtils/util';
|
||||||
@@ -58,7 +58,7 @@ async function rewardWeapons (roleId: string, roleName: string, dicGood: any, w
|
|||||||
let weaponsData = [];
|
let weaponsData = [];
|
||||||
let cnt = weapon.cnt;
|
let cnt = weapon.cnt;
|
||||||
while (cnt > 0) {
|
while (cnt > 0) {
|
||||||
const seqId = await CounterModel.getNewCounter('eid');
|
const seqId = await CounterModel.getNewCounter(COUNTER.EID);
|
||||||
const equipInfo = {
|
const equipInfo = {
|
||||||
roleId,
|
roleId,
|
||||||
roleName,
|
roleName,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import { Service } from 'egg';
|
|||||||
import Counter from '@db/Counter';
|
import Counter from '@db/Counter';
|
||||||
import { STATUS } from '@consts/statusCode';
|
import { STATUS } from '@consts/statusCode';
|
||||||
import { getGoodById } from '@pubUtils/gamedata';
|
import { getGoodById } from '@pubUtils/gamedata';
|
||||||
import { ITID } from '@consts/consts';
|
import { ITID, COUNTER } from '@consts/consts';
|
||||||
import Actor from '@pubUtils/actor';
|
import Actor from '@pubUtils/actor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +82,7 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
const roleId = ctx.service.utils.genCode(10);
|
const roleId = ctx.service.utils.genCode(10);
|
||||||
const code = ctx.service.utils.genCode(6);
|
const code = ctx.service.utils.genCode(6);
|
||||||
const seqId = await Counter.getNewCounter('role') || -1;
|
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
||||||
if (role) {
|
if (role) {
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||||
@@ -194,7 +194,7 @@ export default class GMUsers extends Service {
|
|||||||
for(let hid of hids) {
|
for(let hid of hids) {
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
if(hero) continue;
|
if(hero) continue;
|
||||||
const seqId = await CounterModel.getNewCounter('hid')||-1;
|
const seqId = await CounterModel.getNewCounter(COUNTER.HID)||-1;
|
||||||
let dicHero = ctx.service.utils.getHeroById(hid);
|
let dicHero = ctx.service.utils.getHeroById(hid);
|
||||||
if(!dicHero) continue;
|
if(!dicHero) continue;
|
||||||
const heroInfo = {
|
const heroInfo = {
|
||||||
@@ -243,7 +243,7 @@ export default class GMUsers extends Service {
|
|||||||
flag = 1, msg = "未找到装备" + eid;
|
flag = 1, msg = "未找到装备" + eid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const seqId = await CounterModel.getNewCounter('eid')||-1;
|
const seqId = await CounterModel.getNewCounter(COUNTER.EID)||-1;
|
||||||
const equipInfo = {
|
const equipInfo = {
|
||||||
roleId,
|
roleId,
|
||||||
roleName: role.roleName,
|
roleName: role.roleName,
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ export const ENCRYPT_KEY = 'fiqaxijabbantusmprc234fj';
|
|||||||
export const AUTH_SMS_CNT_PER_DAY = 8;
|
export const AUTH_SMS_CNT_PER_DAY = 8;
|
||||||
|
|
||||||
export const COUNTER = {
|
export const COUNTER = {
|
||||||
UID: 'uid',
|
UID: {name:'uid',def:1},
|
||||||
GMUID: 'gmuid',
|
GMUID: {name:'gmuid',def:1},
|
||||||
API: 'api',
|
API: {name:'api',def:1},
|
||||||
GM_GROUP: 'gmgroup'
|
GM_GROUP: {name:'gmgroup',def:1},
|
||||||
|
HID: {name:'hid',def:10000},
|
||||||
|
EID: {name:'eid',def:1},
|
||||||
|
ROLE: {name:'role',def:1}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ACTION_POIN = {
|
export const ACTION_POIN = {
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ export default class Counter extends BaseModel {
|
|||||||
@prop({ required: true, default: 1 })
|
@prop({ required: true, default: 1 })
|
||||||
seq: number;
|
seq: number;
|
||||||
|
|
||||||
public static async getNewCounter(name: string, lean = true) {
|
public static async getNewCounter(param:{name: string, def: number}, lean = true) {
|
||||||
const counter = await CounterModel.findOneAndUpdate({ name }, { $inc: { seq: 1 } }, { new: true, upsert: true }).lean(lean);
|
let {name, def:defaultVal} = param;
|
||||||
|
let counter = await CounterModel.findOneAndUpdate({ name }, { $inc: { seq: 1 } }, { new: true, upsert: true }).lean(lean);
|
||||||
|
if(!counter || (counter&&counter.seq == 1) && defaultVal != 1) {
|
||||||
|
counter = await CounterModel.findOneAndUpdate({ name }, { $set: { seq: defaultVal } }, { new: true, upsert: true }).lean(lean);
|
||||||
|
}
|
||||||
return counter?.seq;
|
return counter?.seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FIX_SMS_CODE_TELS } from '@consts/consts';
|
import { FIX_SMS_CODE_TELS, COUNTER } from '@consts/consts';
|
||||||
import { CounterModel } from '@db/Counter';
|
import { CounterModel } from '@db/Counter';
|
||||||
import { DEFAULT_HEROES } from '@consts/consts';
|
import { DEFAULT_HEROES } from '@consts/consts';
|
||||||
import { HeroModel } from '@db/Hero';
|
import { HeroModel } from '@db/Hero';
|
||||||
@@ -130,7 +130,7 @@ export default class Auth extends Service {
|
|||||||
const { uid } = ctx;
|
const { uid } = ctx;
|
||||||
const roleId = ctx.service.utils.genCode(10);
|
const roleId = ctx.service.utils.genCode(10);
|
||||||
const code = ctx.service.utils.genCode(6);
|
const code = ctx.service.utils.genCode(6);
|
||||||
const seqId = await Counter.getNewCounter('role') || -1;
|
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
||||||
if (role) {
|
if (role) {
|
||||||
for (let hid of DEFAULT_HEROES) {
|
for (let hid of DEFAULT_HEROES) {
|
||||||
@@ -138,7 +138,7 @@ export default class Auth extends Service {
|
|||||||
if(hero) {
|
if(hero) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const seqId = await CounterModel.getNewCounter('hid')||-1;
|
const seqId = await CounterModel.getNewCounter(COUNTER.HID)||-1;
|
||||||
let dicHero = getHeroInfoById(hid);
|
let dicHero = getHeroInfoById(hid);
|
||||||
if(!dicHero) {
|
if(!dicHero) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user