74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { Controller } from 'egg';
|
|
import { STATUS } from '@consts';
|
|
|
|
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 deleteRole() {
|
|
const { ctx } = this;
|
|
const { roleId } = ctx.request.body;
|
|
ctx.body = await ctx.service.users.deleteRole(roleId);
|
|
}
|
|
|
|
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;
|
|
const { hid, hlv, eid, elv, ecount, ehid, itemid, itemcount, count, lv, 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 if (optType == 'gold') {
|
|
ctx.body = await ctx.service.users.addGold(uids, count);
|
|
} else if (optType == 'lv') {
|
|
ctx.body = await ctx.service.users.levelUp(uids, lv);
|
|
} else {
|
|
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
|
}
|
|
}
|
|
|
|
|
|
public async getPveDefense() {
|
|
const { ctx } = this;
|
|
const { roleId } = ctx.request.body;
|
|
ctx.body = await ctx.service.users.getPvpDefense(roleId);
|
|
}
|
|
|
|
public async getHeroList() {
|
|
const { ctx } = this;
|
|
const { roleId } = ctx.request.body;
|
|
ctx.body = await ctx.service.users.getHeroList(roleId);
|
|
}
|
|
|
|
public async saveHeroToDefense() {
|
|
const { ctx } = this;
|
|
const { roleId, roleName, hid } = ctx.request.body;
|
|
ctx.body = await ctx.service.users.saveHeroToDefense(roleId, roleName, hid);
|
|
}
|
|
|
|
public async removeHeroFromDefense() {
|
|
const { ctx } = this;
|
|
const { roleId, hid } = ctx.request.body;
|
|
ctx.body = await ctx.service.users.removeHeroFromDefense(roleId, hid);
|
|
}
|
|
}
|