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