user.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. const _ = require('lodash');
  3. const meta = require('./.user.js');
  4. const Controller = require('egg').Controller;
  5. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  6. const TLSSigAPIv2 = require('tls-sig-api-v2');
  7. class UserController extends Controller {
  8. constructor(ctx) {
  9. super(ctx);
  10. this.service = this.ctx.service.user;
  11. }
  12. async uppasswd() {
  13. const res = await this.service.uppasswd(this.ctx.request.body);
  14. this.ctx.ok({ data: res });
  15. }
  16. async querymenus() {
  17. const res = await this.service.querymenus(this.ctx.query);
  18. this.ctx.ok({ data: res });
  19. }
  20. async updatebyuid() {
  21. const res = await this.service.updatebyuid(this.ctx.params, this.ctx.request.body);
  22. this.ctx.ok({ data: res });
  23. }
  24. async bind() {
  25. const res = await this.service.bind(this.ctx.request.body);
  26. this.ctx.ok({ data: res });
  27. }
  28. async gensign() {
  29. const api = new TLSSigAPIv2.Api(this.app.config.sdkappid, this.app.config.secretkey);
  30. const res = api.genSig(this.ctx.request.body.userid, 86400 * 180);
  31. console.log('sig ' + res);
  32. // sig = api.genSigWithUserbuf(this.ctx.request.body.userid, 86400 * 180, this.ctx.request.body.name);
  33. // console.log('sig with userbuf ' + sig);
  34. this.ctx.ok({ data: res });
  35. }
  36. }
  37. module.exports = CrudController(UserController, meta);