添加后台连接用的后端
This commit is contained in:
8
gm-server/app/controller/home.ts
Normal file
8
gm-server/app/controller/home.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Controller } from 'egg';
|
||||
|
||||
export default class HomeController extends Controller {
|
||||
public async index() {
|
||||
const { ctx } = this;
|
||||
ctx.body = await ctx.service.test.sayHi('egg');
|
||||
}
|
||||
}
|
||||
24
gm-server/app/controller/login.ts
Normal file
24
gm-server/app/controller/login.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Controller } from 'egg';
|
||||
|
||||
export default class LoginController extends Controller {
|
||||
|
||||
public async login() {
|
||||
const { ctx } = this;
|
||||
const {username, password} = ctx.request.body;
|
||||
ctx.body = await ctx.service.gmUser.login(username, password);
|
||||
}
|
||||
|
||||
public async currentUser() {
|
||||
const { ctx } = this;
|
||||
ctx.body = {
|
||||
"status": "ok",
|
||||
"data": ctx.user
|
||||
};
|
||||
}
|
||||
|
||||
public async createGmAccount() {
|
||||
const { ctx } = this;
|
||||
const {password, name, username, group} = ctx.request.body;
|
||||
ctx.body = await ctx.service.gmUser.createGmAccount(name, username, password, group);
|
||||
}
|
||||
}
|
||||
41
gm-server/app/controller/users.ts
Normal file
41
gm-server/app/controller/users.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Controller } from 'egg';
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public async createRole() {
|
||||
const { ctx } = this;
|
||||
const { uid, roleName } = ctx.request.body;
|
||||
const serverId = 1;
|
||||
ctx.body = await ctx.service.users.createRole(uid, serverId, roleName);
|
||||
}
|
||||
|
||||
public async getrolelist() {
|
||||
const { ctx } = this;
|
||||
const { field, value } = ctx.request.body;
|
||||
ctx.body = await ctx.service.users.getrolelist(field, value);
|
||||
}
|
||||
|
||||
public async createRoleData() {
|
||||
const { ctx } = this;
|
||||
console.log(ctx.request.body)
|
||||
const { hid, hlv, eid, elv, ecount, ehid, itemid, itemcount, selectedRowKeys: uids, optType } = ctx.request.body;
|
||||
if(optType == 'hero') {
|
||||
ctx.body = await ctx.service.users.createHero(uids, hid, hlv);
|
||||
} else if(optType == 'equip') {
|
||||
ctx.body = await ctx.service.users.createEquip(uids, eid, elv, ecount, ehid);
|
||||
} else if (optType == 'item') {
|
||||
ctx.body = await ctx.service.users.createItem(uids, itemid, itemcount);
|
||||
} else {
|
||||
ctx.body = {
|
||||
status: 'error',
|
||||
data: '参数错误'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user