lrf402788946 il y a 4 ans
Parent
commit
445b1985ec
1 fichiers modifiés avec 6 ajouts et 21 suppressions
  1. 6 21
      app/controller/weixin.js

+ 6 - 21
app/controller/weixin.js

@@ -1,26 +1,12 @@
 'use strict';
-
-const assert = require('assert');
-const _ = require('lodash');
-const uuid = require('uuid');
-const urljoin = require('url-join');
 const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-/**
- * 微信认证,获得openid和用户信息,生成微信Jwt
- */
 class WeixinController extends Controller {
-  /**
-   * 认证流程
-   * 1. 缓存原始请求地址,生成state和认证回调地址
-   * 2. 通过wxapi认证,获得认证code
-   * 3. 通过code获得openid,通过openid,查询绑定用户,创建jwt
-   * 4. jwt写入redis,返回认证code
-   * 5. 通过code获取jwt
-   */
-  // GET 请求认证
-  // response_type:
-  //       code - url带上code参数重定向到原始地址
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.weixin;
+  }
   async auth() {
     await this.ctx.service.auth(this.ctx.query);
   }
@@ -28,5 +14,4 @@ class WeixinController extends Controller {
     await this.ctx.service.authBack(this.ctx.query);
   }
 }
-
-module.exports = WeixinController;
+module.exports = CrudController(WeixinController, {});