12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- '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);
- let sig = api.genSig(this.ctx.request.body.userid, 86400 * 180);
- console.log('sig ' + sig);
- sig = api.genSigWithUserbuf(this.ctx.request.body.userid, 86400 * 180, this.ctx.request.body.name);
- console.log('sig with userbuf ' + sig);
- }
- }
- module.exports = CrudController(UserController, meta);
|