zs 1 vuosi sitten
vanhempi
commit
627b8b840b

+ 0 - 12
src/config/config.local.ts

@@ -25,18 +25,6 @@ export default {
       },
     },
   },
-  axios: {
-    clients: {
-      file: {
-        baseURL: 'https://www.ccwit.net',
-        //表明返回服务器返回的数据类型
-        responseType: 'arraybuffer',
-        headers: {
-          'Content-Type': 'application/json; application/octet-stream',
-        },
-      },
-    },
-  },
   export: {
     root_path: 'D:\\temp',
     file_type: 'friendSchool',

+ 0 - 6
src/configuration.ts

@@ -11,8 +11,6 @@ import { join } from 'path';
 // freemidway组件项目
 import * as FreeFrame from 'free-midway-component';
 // import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
-// 控制器执行前函数
-import { CheckTokenMiddleware } from './middleware/checkToken.middleware';
 // 请求成功,失败提示
 // const axiosResponse = response => {
 //   if (response.status === 0) return response.data;
@@ -42,8 +40,4 @@ import { CheckTokenMiddleware } from './middleware/checkToken.middleware';
 export class ContainerLifeCycle {
   @App()
   app: koa.Application;
-
-  async onReady() {
-    this.app.getMiddleware().insertFirst(CheckTokenMiddleware);
-  }
 }

+ 0 - 33
src/middleware/checkToken.middleware.ts

@@ -1,33 +0,0 @@
-import { IMiddleware } from '@midwayjs/core';
-import { Middleware, Inject } from '@midwayjs/decorator';
-import { NextFunction, Context } from '@midwayjs/koa';
-import get = require('lodash/get');
-import { JwtService } from '@midwayjs/jwt';
-
-@Middleware()
-export class CheckTokenMiddleware
-  implements IMiddleware<Context, NextFunction>
-{
-  @Inject()
-  jwtService: JwtService;
-  resolve() {
-    return async (ctx: Context, next: NextFunction) => {
-      const token: any = get(ctx.request, 'header.token');
-      if (token) {
-        const data = this.jwtService.decodeSync(token);
-        if (data) ctx.user = data;
-      }
-      // 添加管理员身份
-      const adminToken: any = get(ctx.request, 'header.admin-token');
-      if (adminToken) {
-        const data = this.jwtService.decodeSync(adminToken);
-        if (data) ctx.admin = data;
-      }
-      await next();
-    };
-  }
-
-  static getName(): string {
-    return 'checkToken';
-  }
-}

+ 1 - 5
src/service/file.service.ts

@@ -1,9 +1,8 @@
 import { Provide, Inject } from '@midwayjs/decorator';
-import { Config, InjectClient } from '@midwayjs/core';
+import { Config } from '@midwayjs/core';
 import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
 import * as fs from 'node:fs';
 import * as Path from 'node:path';
-import { HttpServiceFactory, HttpService } from '@midwayjs/axios';
 const moment = require('moment');
 const sharp = require('sharp');
 const sep = Path.sep;
@@ -15,9 +14,6 @@ export class FileService {
   @Config('export.file_type')
   file_type;
 
-  @InjectClient(HttpServiceFactory, 'Axios')
-  Axios: HttpService;
-
   @Inject()
   ctx;