'use strict';

const _ = require('lodash');
const meta = require('./.user.js');
const Controller = require('egg').Controller;
const { CrudController } = require('naf-framework-mongoose/lib/controller');

// 管理
class UserController extends Controller {

  constructor(ctx) {
    super(ctx);
    this.service = this.ctx.service.user;
  }

  async uppasswd() {
    const res = await this.service.uppasswd(this.ctx.request.body);
    this.ctx.ok({ data: res });
  }

  async querymenus() {
    const res = await this.service.querymenus(this.ctx.query);
    this.ctx.ok({ data: res });
  }

  async updatebyuid() {
    const res = await this.service.updatebyuid(this.ctx.params, this.ctx.request.body);
    this.ctx.ok({ data: res });
  }

  async bind() {
    const res = await this.service.bind(this.ctx.request.body);
    this.ctx.ok({ data: res });
  }

  async finduserlist() {
    const res = await this.service.finduserlist(this.ctx.query);
    this.ctx.ok({ ...res });
  }
}

module.exports = CrudController(UserController, meta);