修改状态码机制,初步改造web-server中接口返回
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
export const STATUS_SUC = {code: 0, simStr: '成功'};
|
||||
export const STATUS_WRONG_PARMS = {code: 1, simStr: '参数错误'};
|
||||
export const STATUS_TOKEN_ERR = {code: 2, simStr: 'token失效'};
|
||||
export const STATUS_INTERNAL_ERR = {code: 3, simStr: '内部错误'};
|
||||
|
||||
export const SMS_IN_60S = {code: 100001, simStr: '60秒内只能发送一次'};
|
||||
export const SMS_CNT_LIMIT = {code: 100002, simStr: '今日短信条数已达上限'};
|
||||
export const SMS_INVALID = {code: 100003, simStr: '验证码无效'};
|
||||
|
||||
export const SERVER_NOT_FOUND = {code: 200001, simStr: '未找到服务器列表'};
|
||||
export const ROLE_NOT_FOUND = {code: 200002, simStr: '未找到角色'};
|
||||
export const STATUS = {
|
||||
// 接口或系统状态 0 - 9999
|
||||
SUCCESS: { code: 0, simStr: '成功' },
|
||||
WRONG_PARMS: { code: 1, simStr: '参数错误' },
|
||||
TOKEN_ERR: { code: 2, simStr: 'token失效' },
|
||||
INTERNAL_ERR: { code: 3, simStr: '内部错误' },
|
||||
// 账号相关状态 10001 - 19999
|
||||
SMS_IN_60S: { code: 10001, simStr: '60秒内只能发送一次' },
|
||||
SMS_CNT_LIMIT: { code: 10002, simStr: '今日短信条数已达上限' },
|
||||
SMS_INVALID: { code: 10003, simStr: '验证码无效' },
|
||||
SERVER_NOT_FOUND: { code: 10004, simStr: '未找到服务器列表' },
|
||||
ROLE_NOT_FOUND: { code: 10005, simStr: '未找到角色' },
|
||||
// 战斗相关状态 20001 - 29999
|
||||
TOWER_RESET_ERR: { code: 20001, simStr: '只能重置当前层' }
|
||||
// 养成相关状态 30001 - 39999
|
||||
// 社交相关状态 40001 - 49999
|
||||
// 运营模块相关状态 50001 - 59999
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { STATUS } from './../consts/statusCode';
|
||||
|
||||
import { getGamedata } from './gamedata';
|
||||
import { HeroModel } from '../db/Hero';
|
||||
@@ -179,4 +180,9 @@ export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
|
||||
}
|
||||
}
|
||||
return source.filter((_item, idx) => idxs.has(idx));
|
||||
}
|
||||
|
||||
export function resResult(status: {code: number, simStr: string}, data = null) {
|
||||
const { code, simStr } = status;
|
||||
return {code, msg: simStr, data};
|
||||
}
|
||||
Reference in New Issue
Block a user