1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 'use strict';
- const _ = require('lodash');
- const meta = require('./.user.js');
- const Controller = require('egg').Controller;
- const { CrudController } = require('naf-framework-mongoose/lib/controller');
- const TLSSigAPIv2 = require('tls-sig-api-v2');
- 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 gensign() {
- const api = new TLSSigAPIv2.Api(this.app.config.sdkappid, this.app.config.secretkey);
- const res = api.genSig(this.ctx.request.body.userid, 86400 * 180);
- console.log('sig ' + res);
- // sig = api.genSigWithUserbuf(this.ctx.request.body.userid, 86400 * 180, this.ctx.request.body.name);
- // console.log('sig with userbuf ' + sig);
- this.ctx.ok({ data: res });
- }
- }
- module.exports = CrudController(UserController, meta);
|