GM后台修改status code

This commit is contained in:
luying
2020-10-17 16:39:17 +08:00
parent 76a6259fbc
commit 81bce4f57b
10 changed files with 134 additions and 321 deletions

View File

@@ -94,7 +94,7 @@ export class EntryHandler {
let channel = channelService.getChannel(roleId, true); let channel = channelService.getChannel(roleId, true);
channel.leave(roleId, sid); channel.leave(roleId, sid);
this.app.rpc.battle.eventBattleRemote.kick.route(session)(session.uid, this.app.get('serverId')); this.app.rpc.battle.eventBattleRemote.kick.route(session)(roleId, this.app.get('serverId'));
this.app.rpc.chat.chatRemote.kick.route(session, true)(session.uid, this.app.get('serverId'), session.get('rid')); // this.app.rpc.chat.chatRemote.kick.route(session, true)(session.uid, this.app.get('serverId'), session.get('rid'));
} }
} }

View File

@@ -244,7 +244,8 @@ function randomQuestion(num: number) {
let {id, question, a1, a2, a3, a4, correct} = questions[index]; let {id, question, a1, a2, a3, a4, correct} = questions[index];
if(rid.includes(id)) continue; if(rid.includes(id)) continue;
rid.push(id); rid.push(id);
result.push({id, question, answer: [a1, a2, a3, a4], correct}); let answer = [a1, a2, a3, a4].filter(cur => cur);
result.push({id, question, answer, correct});
num--; num--;
} }
return result; return result;

View File

@@ -1,4 +1,5 @@
import { Controller } from 'egg'; import { Controller } from 'egg';
import { STATUS } from '@consts/statusCode';
export default class LoginController extends Controller { export default class LoginController extends Controller {
@@ -10,10 +11,9 @@ export default class LoginController extends Controller {
public async currentUser() { public async currentUser() {
const { ctx } = this; const { ctx } = this;
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok", "user": ctx.user
"data": ctx.user });
};
} }
public async changeMyPass() { public async changeMyPass() {
@@ -24,9 +24,8 @@ export default class LoginController extends Controller {
public async getMenu() { public async getMenu() {
const { ctx } = this; const { ctx } = this;
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok", "list": [
"data": [
{ {
path: '/test', path: '/test',
authority: ['admin'], authority: ['admin'],
@@ -42,8 +41,6 @@ export default class LoginController extends Controller {
], ],
} }
] ]
} });
} }
} }

View File

@@ -1,5 +1,6 @@
import { Controller } from 'egg'; import { Controller } from 'egg';
import { Stream } from 'stream'; import { Stream } from 'stream';
import { STATUS } from '@consts/statusCode';
const fs = require('fs'); const fs = require('fs');
const unzip = require("unzip-stream"); const unzip = require("unzip-stream");
const temp = require('temp'); const temp = require('temp');
@@ -125,24 +126,15 @@ export default class UploadController extends Controller {
fs.renameSync(dirPath, hotUpdateAddr); fs.renameSync(dirPath, hotUpdateAddr);
temp.cleanupSync(); temp.cleanupSync();
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "ok"
}
} catch (err) { } catch (err) {
console.log(err) console.log(err)
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.GM_UPLOAD_FORMAT_ERR, null, err.message);
"status": "error",
"data": err.message
}
} }
} else { } else {
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.GM_UPLOAD_FORMAT_ERR);
"status": "error",
"data": "格式错误"
}
} }
} }
@@ -191,24 +183,16 @@ export default class UploadController extends Controller {
} }
temp.cleanupSync(); temp.cleanupSync();
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok",
"data": "上传成功",
"files": JSON.stringify(files) "files": JSON.stringify(files)
} });
} catch (err) { } catch (err) {
console.log(err) console.log(err)
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": err.message
}
} }
} else { } else {
return ctx.body = { return ctx.body = ctx.service.utils.resResult(STATUS.GM_UPLOAD_FORMAT_ERR);
"status": "error",
"data": "格式错误"
}
} }
} }

View File

@@ -1,4 +1,5 @@
import { Controller } from 'egg'; import { Controller } from 'egg';
import { STATUS } from '@consts/statusCode';
export default class UserController extends Controller { export default class UserController extends Controller {
@@ -32,10 +33,7 @@ export default class UserController extends Controller {
} else if (optType == 'item') { } else if (optType == 'item') {
ctx.body = await ctx.service.users.createItem(uids, itemid, itemcount); ctx.body = await ctx.service.users.createItem(uids, itemid, itemcount);
} else { } else {
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
status: 'error',
data: '参数错误'
}
} }
} }
} }

View File

@@ -3,34 +3,26 @@ import { GMUserGroupModel } from '@db/GMUserGroup'
import { GMGroupModel } from '@db/GMGroup' import { GMGroupModel } from '@db/GMGroup'
import { GMRecordModel } from '@db/GMRecord' import { GMRecordModel } from '@db/GMRecord'
import { ApiModel } from '@db/Api'; import { ApiModel } from '@db/Api';
import { STATUS } from '@consts/statusCode';
module.exports = () => { module.exports = () => {
return async function tokenParser(ctx, next) { return async function tokenParser(ctx, next) {
if (!ctx.request.headers || !ctx.request.headers.token) { if (!ctx.request.headers || !ctx.request.headers.token) {
console.error('token not found'); console.error('token not found');
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
"status": "error",
"data": "账号未登录"
};
return; return;
} }
const user = await GMUserModel.getGmAccountByToken(ctx.request.headers.token); const user = await GMUserModel.getGmAccountByToken(ctx.request.headers.token);
if (!user) { if (!user) {
console.error('token invalid'); console.error('token invalid');
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.TOKEN_ERR);
"status": "error",
"data": "账号未登录"
};
return; return;
} }
const url = ctx.request.url; const url = ctx.request.url;
let apiResult = await ApiModel.getApi(url); let apiResult = await ApiModel.getApi(url);
if(!apiResult) { if(!apiResult) {
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.GM_MISS_API);
"status": "error",
"data": "未找到该接口"
};
return; return;
} }
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1); let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1);
@@ -45,10 +37,7 @@ module.exports = () => {
} }
} }
if(flag != 1) { if(flag != 1) {
ctx.body = { ctx.body = ctx.service.utils.resResult(STATUS.GM_NO_AUTHORITY_GET);
"status": "error",
"data": "您没有权限访问该接口"
};
return; return;
} }
ctx.user = user; ctx.user = user;

View File

@@ -3,6 +3,7 @@ import { GMGroupModel } from '@db/GMGroup';
import { GMUserGroupModel } from '@db/GMUserGroup'; import { GMUserGroupModel } from '@db/GMUserGroup';
import { ApiModel } from '@db/Api'; import { ApiModel } from '@db/Api';
import { Service } from 'egg'; import { Service } from 'egg';
import { STATUS } from '@consts/statusCode';
/** /**
* Test Service * Test Service
@@ -17,7 +18,9 @@ export default class GMUsers extends Service {
let token = ctx.service.utils.genCode(256); let token = ctx.service.utils.genCode(256);
let user = await GMUserModel.login(username, password, token); let user = await GMUserModel.login(username, password, token);
if(user) { if(!user) {
return ctx.service.utils.resResult(STATUS.GM_ERR_PASSWORD);
}
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1); let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1);
let group = new Array(); let group = new Array();
for(let userGroup of userGroups) { for(let userGroup of userGroups) {
@@ -25,16 +28,9 @@ export default class GMUsers extends Service {
if(g) group.push(g.group); if(g) group.push(g.group);
} }
return { return ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok", ...user, group, token
"data": {...user, group, token} });
}
} else {
return {
"status": "error",
"data": "账号或密码错误"
}
}
} }
/** /**
@@ -43,24 +39,13 @@ export default class GMUsers extends Service {
public async changeMyPass(uid: number, password: string) { public async changeMyPass(uid: number, password: string) {
const {ctx} = this; const {ctx} = this;
let user = ctx.user; let user = ctx.user;
if(uid != user.uid) { if(uid != user.uid) return ctx.service.utils.resResult(STATUS.GM_NO_AUTHORITY_POST);
return {
"status": "error",
"data": "不可修改其他人的密码"
}
}
let result = await GMUserModel.changePass(uid, password); let result = await GMUserModel.changePass(uid, password);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "修改成功"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "修改失败"
}
} }
} }
@@ -87,16 +72,13 @@ export default class GMUsers extends Service {
result.push({...user, group:groupArr, groupStr: groupStrArr.length?groupStrArr.join():'暂无'}); result.push({...user, group:groupArr, groupStr: groupStrArr.length?groupStrArr.join():'暂无'});
} }
return { return this.ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok", gmlist: result
"data": result });
}
} else { } else {
return { return this.ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "获取失败"
}
} }
} }
/** /**
@@ -108,16 +90,10 @@ export default class GMUsers extends Service {
let user = await GMUserModel.getGmAccountByUsername(username); let user = await GMUserModel.getGmAccountByUsername(username);
if(user) { if(user) {
return { return ctx.service.utils.resResult(STATUS.GM_DUPLICATE_GM_ACCOUNT)
"status": "error",
"data": "该账号已使用"
}
} else { } else {
user = await GMUserModel.createGmAccount(username, password, name, token); user = await GMUserModel.createGmAccount(username, password, name, token);
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "创建成功"
};
} }
} }
@@ -125,19 +101,15 @@ export default class GMUsers extends Service {
* 后台Api列表 * 后台Api列表
*/ */
public async getApiList() { public async getApiList() {
// const {ctx} = this; const {ctx} = this;
let list = await ApiModel.getAllApi(); let list = await ApiModel.getAllApi();
if(list) { if(list) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS, {
"status": "ok", list
"data": list });
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "获取失败"
}
} }
} }
@@ -145,25 +117,16 @@ export default class GMUsers extends Service {
* 创建Api * 创建Api
*/ */
public async saveApi(api:string, name:string) { public async saveApi(api:string, name:string) {
// const {ctx} = this; const {ctx} = this;
let result = await ApiModel.getApi(api); let result = await ApiModel.getApi(api);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.GM_DUPLICATE_API);
"status": "error",
"data": "该接口已存在"
}
} else { } else {
let result = await ApiModel.createApi(api, name); let result = await ApiModel.createApi(api, name);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "创建成功"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "创建失败"
}
} }
} }
} }
@@ -173,19 +136,13 @@ export default class GMUsers extends Service {
* 后台用户组列表 * 后台用户组列表
*/ */
public async getGroupList() { public async getGroupList() {
// const {ctx} = this; const {ctx} = this;
let list = await GMGroupModel.getAllGroup(); let list = await GMGroupModel.getAllGroup();
if(list) { if(list) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS, { list });
"status": "ok",
"data": list
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "获取失败"
}
} }
} }
@@ -193,25 +150,16 @@ export default class GMUsers extends Service {
* 创建用户组 * 创建用户组
*/ */
public async createGmGroup(group:string, name:string, desc: string) { public async createGmGroup(group:string, name:string, desc: string) {
// const {ctx} = this; const {ctx} = this;
let result = await GMGroupModel.getGroup(group); let result = await GMGroupModel.getGroup(group);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.GM_DUPLICATE_GROUP);
"status": "error",
"data": "该用户组已存在"
}
} else { } else {
let result = await GMGroupModel.createGroup(group, name, desc); let result = await GMGroupModel.createGroup(group, name, desc);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "创建成功"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "创建失败"
}
} }
} }
} }
@@ -220,19 +168,13 @@ export default class GMUsers extends Service {
* 修改用户组 * 修改用户组
*/ */
public async saveGmGroup(groupId: number, group:string, name:string, desc: string) { public async saveGmGroup(groupId: number, group:string, name:string, desc: string) {
// const {ctx} = this; const {ctx} = this;
let result = await GMGroupModel.editGroup(groupId, group, name, desc); let result = await GMGroupModel.editGroup(groupId, group, name, desc);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "创建成功"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "创建失败"
}
} }
} }
@@ -240,18 +182,12 @@ export default class GMUsers extends Service {
* 用户组添加接口 * 用户组添加接口
*/ */
public async saveGmApiToGroup(apiId: number, apis: Array<number>) { public async saveGmApiToGroup(apiId: number, apis: Array<number>) {
// const {ctx} = this; const {ctx} = this;
let result = await GMGroupModel.saveApiToGroup(apiId, apis); let result = await GMGroupModel.saveApiToGroup(apiId, apis);
if(result) { if(result) {
return { return ctx.service.utils.resResult(STATUS.SUCCESS);
"status": "ok",
"data": "保存成功"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "保存失败"
}
} }
} }
@@ -282,15 +218,9 @@ export default class GMUsers extends Service {
} }
if(flag) { if(flag) {
return { return this.ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"status": "error",
"data": "保存失败"
}
}
return {
"status": "ok",
"data": "保存成功"
} }
return this.ctx.service.utils.resResult(STATUS.SUCCESS);
} }
} }

View File

@@ -1,30 +1,7 @@
import { Service } from 'egg'; import { Service } from 'egg';
import * as pubUtils from '../pubUtils/util';
import * as pubGamedata from '../pubUtils/gamedata'
const csprng = require('csprng'); const csprng = require('csprng');
const fs = require('fs');
const path = require('path');
var gamedata = {};
function initData () {
fs.readdirSync(__dirname + '/../resource/jsons')
.filter(function(file) {
return (file.indexOf(".") !== 0) && (file !== "index.js");
})
//筛选有文件名且不是index进行遍历
.forEach(function(file) {
var name = file.split('.')[0];
try {
gamedata[name] = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../resource/jsons/" + file))
);
} catch(e) {
console.error('【文件缺少】:' + file);
gamedata[name] = [];
}
});
}
initData();
/** /**
* Utils Service * Utils Service
@@ -39,84 +16,31 @@ export default class Utils extends Service {
return `${csprng(len, radix)}`; return `${csprng(len, radix)}`;
} }
public genCode(len) { public genCode(len: number) {
const chars = '123456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijklmnopqrstuvwxyz'; return pubUtils.genCode(len)
const charArr = chars.split('');
let code = '';
for (let i = 0; i < len; i++) {
code += charArr[Math.floor(Math.random() * charArr.length)];
}
return code;
} }
/** public getGamedata(key: string) {
* 生成指定长度的随机数 return pubGamedata.getGamedata(key);
* @param len 随机数长度
*/
public generateNum(len: number) {
let code = '';
for (let i = 0; i < len; i++) {
code += parseInt(`${Math.random() * 10}`);
}
return code;
} }
public exceptionResult(status) { public getHeroById(hid: number) {
const { code, simStr } = status; return pubGamedata.getHeroInfoById(hid);
return { status: code, data: simStr }; }
public getWarById(warid: number) {
return pubGamedata.getWarById(warid);
} }
public getGamedata(key) { public getGoodById(gid: number) {
return gamedata[key]; return pubGamedata.getGoodById(gid);
}
public getHeroById(hid) {
let heros = gamedata['dic_zyz_hero']||[];
return heros.find(cur => {
return cur.heroId == hid;
});
}
public getWarById(warid) {
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event']; // 关卡相关的表
let result;
for(let filename of wars) {
let warInfo = gamedata[filename]||[];
for(let war of warInfo) {
if(war.war_id == warid) {
result = war; break;
}
}
if(result) break;
}
return result||[];
}
public getGoodById(gid) {
console.log(gid)
let goodsInfo = gamedata['goods']||[];
return goodsInfo.find(cur => {
return cur.good_id == gid
});
} }
public calculateCE(heroInfo: {hid: number, lv: number }) { public calculateCE(heroInfo: {hid: number, lv: number }) {
return pubUtils.calculateCE(heroInfo)
let { hid, lv } = heroInfo; }
// 假设所有属性和等级的关系是简单的线性关系
let dicHero = this.getGamedata('dic_zyz_hero');
let curDicHero = dicHero.find(cur => cur.heroId == hid);
let { atk, matk, def, mdef, agi, luk, atk_up, matk_up, def_up, mdef_up, agi_up, luk_up } = curDicHero;
atk += lv * atk_up;
matk += lv * matk_up;
def += lv * def_up;
mdef += lv * mdef_up;
agi += lv * agi_up;
luk += lv * luk_up;
// 假设战力为所有属性的简单加法 public resResult(status: {code: number, simStr: string}, data?, customMsg?: string) {
return pubUtils.resResult(status, data, customMsg);
let ce = atk + matk + def + mdef + agi + luk;
return ce;
} }
} }

View File

@@ -7,6 +7,7 @@ import { CounterModel } from '@db/Counter';
import { Service } from 'egg'; import { Service } from 'egg';
import Counter from '@db/Counter'; import Counter from '@db/Counter';
import { STATUS } from '@consts/statusCode';
/** /**
* Test Service * Test Service
@@ -17,7 +18,7 @@ export default class GMUsers extends Service {
* 根据类型等搜索玩家 * 根据类型等搜索玩家
*/ */
public async getuserlist(field, value) { public async getuserlist(field, value) {
// const {ctx} = this; const {ctx} = this;
let arr = new Array(), flag = 0; let arr = new Array(), flag = 0;
value = value.split(','); value = value.split(',');
@@ -39,10 +40,7 @@ export default class GMUsers extends Service {
} }
if(flag) { if(flag) {
return { return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
"status": "error",
"data": "参数错误"
}
} }
let users = await UserModel.findUserByField(field, value); let users = await UserModel.findUserByField(field, value);
@@ -54,15 +52,10 @@ export default class GMUsers extends Service {
list.push({...user, hasRole: role?true: false, role}); list.push({...user, hasRole: role?true: false, role});
} }
return { return ctx.service.utils.resResult(STATUS.SUCCESS, {list})
"status": "ok",
"data": list
}
} else { } else {
return { console.error('userlist not found');
"status": "error", return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"data": "未找到玩家"
}
} }
} }
@@ -75,12 +68,11 @@ export default class GMUsers extends Service {
const seqId = await Counter.getNewCounter('role') || -1; const seqId = await Counter.getNewCounter('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 { status: "ok", data: { roleId: role.roleId } }; return ctx.service.utils.resResult(STATUS.SUCCESS);
} else {
console.error('create role error');
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
} }
return {
"status": "error",
"data": "创建失败"
};
} }
@@ -88,7 +80,7 @@ export default class GMUsers extends Service {
* 根据类型等搜索玩家 * 根据类型等搜索玩家
*/ */
public async getrolelist(field, value) { public async getrolelist(field, value) {
// const {ctx} = this; const {ctx} = this;
let arr = new Array(), flag = 0; let arr = new Array(), flag = 0;
value = value.split(','); value = value.split(',');
@@ -114,10 +106,7 @@ export default class GMUsers extends Service {
} }
if(flag) { if(flag) {
return { return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
"status": "error",
"data": "参数错误"
}
} }
let roles = await RoleModel.findRoleByField(field, value); let roles = await RoleModel.findRoleByField(field, value);
@@ -135,21 +124,19 @@ export default class GMUsers extends Service {
key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount
}); });
} }
return { return ctx.service.utils.resResult(STATUS.SUCCESS, { list: result });
"status": "ok",
"data": result
}
} else { } else {
return { console.error('role list not found');
"status": "error", return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
"data": "未找到玩家"
}
} }
} }
public async createHero(uids: Array<string>, hid: number, hlv: number) { public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
const {ctx} = this; const {ctx} = this;
console.log('gm createHero', uids, hid, hlv); console.log('gm createHero', uids, _hid, _hlv);
let hid = parseInt(_hid);
let hlv = parseInt(_hlv);
if(isNaN(hid) || isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let flag = 0, msg = '创建失败'; let flag = 0, msg = '创建失败';
for(let roleId of uids) { for(let roleId of uids) {
@@ -184,21 +171,20 @@ export default class GMUsers extends Service {
} }
if (flag) { if (flag) {
return { return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
"status": "error",
"data": msg
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
"status": "ok",
"data": uids
};
} }
} }
public async createEquip(uids: Array<string>, eid: number, elv: number, ecount: number, ehid: number) { public async createEquip(uids: Array<string>, _eid: string, _elv: string, _ecount: string, _ehid: string) {
const {ctx} = this; const {ctx} = this;
console.log('gm createEquip'); console.log('gm createEquip', uids, _eid, _elv, _ecount, _ehid);
let eid = parseInt(_eid);
let elv = parseInt(_elv);
let ecount = parseInt(_ecount);
let ehid = parseInt(_ehid);
if(isNaN(eid) || isNaN(elv) || isNaN(ecount) || isNaN(ehid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let flag = 0, msg = '创建失败'; let flag = 0, msg = '创建失败';
for(let roleId of uids) { for(let roleId of uids) {
@@ -232,19 +218,19 @@ export default class GMUsers extends Service {
} }
if (flag) { if (flag) {
return { return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
"status": "error",
"data": msg
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
"status": "ok",
"data": uids
};
} }
} }
public async createItem(uids: Array<string>, itemid: number, itemcount: number) { public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
const {ctx} = this;
console.log('gm createItem', uids, _itemid, _itemcount);
let itemid = parseInt(_itemid);
let itemcount = parseInt(_itemcount);
if(isNaN(itemid) || isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
console.log('gm createEquip'); console.log('gm createEquip');
let flag = 0; let flag = 0;
@@ -273,15 +259,9 @@ export default class GMUsers extends Service {
} }
if (flag) { if (flag) {
return { return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR);
"status": "error",
"data": "创建失败"
}
} else { } else {
return { return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
"status": "ok",
"data": uids
};
} }
} }
} }

View File

@@ -64,4 +64,14 @@ export const STATUS = {
// 养成相关状态 30000 - 39999 // 养成相关状态 30000 - 39999
// 社交相关状态 40000 - 49999 // 社交相关状态 40000 - 49999
// 运营模块相关状态 50000 - 59999 // 运营模块相关状态 50000 - 59999
// GM后台相关状态 60000 - 69999
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
GM_NO_AUTHORITY_GET: { code: 60003, simStr: '您没有权限访问该接口' },
GM_NO_AUTHORITY_POST: { code: 60004, simStr: '您没有权限进行该操作' },
GM_UPLOAD_FORMAT_ERR: { code: 60005, simStr: '文件格式错误' },
GM_DUPLICATE_GM_ACCOUNT: { code: 60006, simStr: '该账号已使用' },
GM_DUPLICATE_API: { code: 60007, simStr: '该接口已存在' },
GM_DUPLICATE_GROUP: { code: 60008, simStr: '该用户组已存在' },
GM_CREATE_ERROR: { code: 60009, simStr: '创建失败' }
} }