后台:账号管理

This commit is contained in:
luying
2021-11-25 16:11:46 +08:00
parent cc819c48a7
commit e7566b8af5
7 changed files with 63 additions and 67 deletions

View File

@@ -16,6 +16,11 @@ export default class FooBoot implements IBoot {
// this is the last chance to modify the config.
await this.connectDB(this.app)
await this.connectGMDB(this.app);
this.app.config.realEnv = this.app.config.env;
if(this.app.config.env == 'local') {
this.app.config.realEnv = 'development';
}
}
configDidLoad() {

View File

@@ -5,8 +5,8 @@ export default class UserController extends Controller {
public async getuserlist() {
const { ctx } = this;
const { field, value } = ctx.request.body;
ctx.body = await ctx.service.users.getuserlist(field, value);
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
ctx.body = await ctx.service.users.getuserlist(page, pageSize, sortField, sortOrder, form);
}
public async createRole() {

View File

@@ -210,9 +210,7 @@ export default class Game extends Service {
const total = await NoticeModel.countByCondition( form )
return ctx.service.utils.resResult(STATUS.SUCCESS, {
list: list.map(cur => {
let env = this.app.config.env;
if(env == 'local') env = 'development';
return { ...cur, showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime(), env}
return { ...cur, showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime(), env: this.app.config.realEnv }
}), total
});
}

View File

@@ -21,6 +21,7 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil';
import { RScriptRecordModel } from '@db/RScriptRecord';
import { DicWar } from '@pubUtils/dictionary/DicWar';
import { SkinModel } from '@db/Skin';
import { SearchUserParam } from '@domain/backEndField/search';
// import { resResult } from '@pubUtils/util';
@@ -34,49 +35,22 @@ export default class GMUsers extends Service {
/**
* 根据类型等搜索玩家
*/
public async getuserlist(field: string = 'all', value: string = '') {
public async getuserlist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchUserParam) {
const { ctx } = this;
let arr = new Array(), flag = 0;
if (value == '') field = 'all';
let valueArr = value.split(',');
for (let i of valueArr) {
if (field == 'uid') {
let d = parseInt(i);
if (isNaN(d)) {
flag = 1; break;
} else {
arr.push(d);
}
} else if (field == 'username' || field == 'tel') {
arr.push(i);
} else if (field == 'all') {
break;
} else {
flag = 1; break;
}
const users = await UserModel.findByCondition(page, pageSize, sortField, sortOrder, form);
const total = await UserModel.countByCondition( form )
let list = [];
for (let user of users) {
let role = await RoleModel.findAllByUid(user.uid);
let sms = await smsModel.findByTel(user.tel);
list.push({ ...user, role, isFixed: sms ? sms.isFixed : false, code: sms ? sms.code : "", env: ctx.app.config.realEnv });
}
if (flag) {
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
let users = await UserModel.findUserByField(field, valueArr);
if (users) {
let list = new Array();
for (let user of users) {
let role = await RoleModel.findAllByUid(user.uid);
let sms = await smsModel.findByTel(user.tel);
list.push({ ...user, role, isFixed: sms ? sms.isFixed : false, code: sms ? sms.code : "" });
}
return ctx.service.utils.resResult(STATUS.SUCCESS, { list })
} else {
console.error('userlist not found');
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
}
}
public async createRole(uid: number, serverId: number, roleName: string) {
@@ -602,7 +576,7 @@ export default class GMUsers extends Service {
return ctx.service.utils.resResult(STATUS.SUCCESS);
} catch (e) {
console.error(e.stack)
console.error((<Error>e).stack)
}
}
@@ -625,7 +599,7 @@ export default class GMUsers extends Service {
return ctx.service.utils.resResult(STATUS.SUCCESS);
} catch (e) {
console.error(e.stack)
console.error((<Error>e).stack)
}
}
@@ -649,7 +623,7 @@ export default class GMUsers extends Service {
return ctx.service.utils.resResult(STATUS.SUCCESS);
} catch (e) {
console.error(e.stack)
console.error((<Error>e).stack)
}
}