Files
ZYZ/gm-server/app/controller/users.ts
2021-10-29 16:36:23 +08:00

185 lines
5.9 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, serverId } = ctx.request.body;
ctx.body = await ctx.service.users.createRole(uid, serverId, roleName);
}
public async addAuth() {
const { ctx } = this;
const { uid, auth } = ctx.request.body;
ctx.body = await ctx.service.users.addAuth(uid, auth);
}
public async fixSms() {
const { ctx } = this;
const { tel } = ctx.request.body;
ctx.body = await ctx.service.users.fixSms(tel);
}
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, ecount, itemid, itemcount, count, lv, skinid, selectedRowKeys: uids, optType, ehid, war } = 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, 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 == 'coin') {
ctx.body = await ctx.service.users.addCoin(uids, count);
} else if (optType == 'lv') {
ctx.body = await ctx.service.users.levelUp(uids, lv);
} else if (optType == 'skin') {
ctx.body = await ctx.service.users.addSkin(uids, skinid);
} else if (optType == 'war') {
ctx.body = await ctx.service.users.setWarRecord(uids, war);
} 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 { field, value } = ctx.request.body;
ctx.body = await ctx.service.users.getHeroList(field, value);
}
public async deleteHero() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndHids } = ctx.request.body;
ctx.body = await ctx.service.users.deleteHero(roleIdAndHids);
}
public async setHeroLv() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndHids, lv } = ctx.request.body;
ctx.body = await ctx.service.users.setHeroLv(roleIdAndHids, lv);
}
public async setHeroParam() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndHids, star, colorStar, quality } = ctx.request.body;
ctx.body = await ctx.service.users.setHeroParam(roleIdAndHids, star, colorStar, quality);
}
public async setHeroJob() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndHids, job } = ctx.request.body;
ctx.body = await ctx.service.users.setHeroJob(roleIdAndHids, job);
}
// 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);
// }
public async getEquipList() {
const { ctx } = this;
const { field, value } = ctx.request.body;
ctx.body = await ctx.service.users.getEquipList(field, value);
}
public async getItemList() {
const { ctx } = this;
const { field, value } = ctx.request.body;
ctx.body = await ctx.service.users.getItemList(field, value);
}
public async deleteEquip() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndSeqIds } = ctx.request.body;
ctx.body = await ctx.service.users.deleteEquip(roleIdAndSeqIds);
}
public async deleteItem() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndIds } = ctx.request.body;
ctx.body = await ctx.service.users.deleteItem(roleIdAndIds);
}
public async setItemCount() {
const { ctx } = this;
const { selectedRowKeys: roleIdAndIds, count } = ctx.request.body;
ctx.body = await ctx.service.users.setItemCount(roleIdAndIds, count);
}
public async getGiftCodeList() {
const { ctx } = this;
const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
ctx.body = await ctx.service.users.getGiftCodeList(page, pageSize, sortField, sortOrder, form);
}
public async updateGiftCode() {
const { ctx } = this;
const { id, values } = ctx.request.body;
ctx.body = await ctx.service.users.updateGiftCode(id, values);
}
public async generateGiftCode() {
const { ctx } = this;
const { id, generateType, code, generateNum, codeLen } = ctx.request.body;
if(generateType == 1) {
if(!generateNum) {
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return
}
} else if (generateType == 2) {
if(!code) {
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return
}
} else {
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
return
}
ctx.body = await ctx.service.users.generateGiftCode(id, generateType, code, generateNum, codeLen);
}
public async getGiftCodeDetails() {
const { ctx } = this;
const { id } = ctx.params;
ctx.body = await ctx.service.users.getGiftCodeDetails(parseInt(id));
return
}
}