import { Controller } from 'egg';

export default class UserController extends Controller {

  public async getuserlist() {
    const { ctx } = this;
    const { page, pageSize, sortField, sortOrder, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getuserlist(page, pageSize, sortField, sortOrder, form);
  }

  // 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 { page, pageSize, sortField, sortOrder, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getrolelist(page, pageSize, sortField, sortOrder, form);
  }

  public async getpaystatic() {
    const { ctx } = this;
    const { page = 1, pageSize = 10, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getpaystatic(page, pageSize, form);
  }

  public async setWar() {
    const { ctx } = this;
    const { roleId, warId } = ctx.request.body;
    ctx.body = await ctx.service.users.setWarRecord(roleId, warId);
  }

  public async setCreateTime() {
    const { ctx } = this;
    const { roleId, day } = ctx.request.body;
    ctx.body = await ctx.service.users.setCreateTime(roleId, day);
  }

  public async getHeroList() {
    const { ctx } = this;
    const { page, pageSize, sortField, sortOrder, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getHeroList(page, pageSize, sortField, sortOrder, form);
  }

  // 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 getItemList() {
    const { ctx } = this;
    const { page, pageSize, sortField, sortOrder, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getItemList(page, pageSize, sortField, sortOrder, form);
  }

  public async getGuildList() {
    const { ctx } = this;
    const { page, pageSize, sortField, sortOrder, form  } = ctx.request.body;
    ctx.body = await ctx.service.users.getGuildList(page, pageSize, sortField, sortOrder, form);
  }

  public async getMembersByGuildCode() {
    const { ctx } = this;
    const { code  } = ctx.request.body;
    ctx.body = await ctx.service.users.getMembersByGuildCode(code);
  }

  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 createAndGenerateGift() {
    const { ctx } = this;
    const params = ctx.request.body;
    ctx.body = await ctx.service.users.createAndGenerateGift(params, params.generateCnt);
  }

  public async updateGiftCode() {
    const { ctx } = this;
    const params = ctx.request.body;
    ctx.body = await ctx.service.users.updateGiftCode(params.id, params.values);
  }

  public async generateGiftCode() {
    const { ctx } = this;
    const params = ctx.request.body;
    ctx.body = await ctx.service.users.generateGiftCode(params.id, params.count);
  }

  public async cancelGiftCode() {
    const { ctx } = this;
    const params = ctx.request.body;
    ctx.body = await ctx.service.users.cancelGiftCode(params.id, !!params.isEnable);
  }

  public async getGiftCodeDetailList() {
    const { ctx } = this;
    const { page, pageSize, sortField, sortOrder, form } = ctx.request.body;
    ctx.body = await ctx.service.users.getGiftCodeDetailList(page, pageSize, sortField, sortOrder, form);
  }

  public async getGiftCodeDetailFile() {
    const { ctx } = this;
    const { id, fileType } = ctx.params;
    ctx.body = await ctx.service.users.getGiftCodeDetailFile(parseInt(id), fileType);
    return
  }
}
