zs 2 лет назад
Сommit
bbbc457dee
40 измененных файлов с 1574 добавлено и 0 удалено
  1. 11 0
      .editorconfig
  2. 7 0
      .eslintrc.json
  3. 15 0
      .gitignore
  4. 3 0
      .prettierrc.js
  5. 29 0
      README.md
  6. 29 0
      README.zh-CN.md
  7. 2 0
      bootstrap.js
  8. 20 0
      ecosystem.config.js
  9. 6 0
      jest.config.js
  10. 65 0
      package.json
  11. 19 0
      src/config/config.default.ts
  12. 39 0
      src/config/config.local.ts
  13. 43 0
      src/config/config.prod.ts
  14. 7 0
      src/config/config.unittest.ts
  15. 51 0
      src/configuration.ts
  16. 89 0
      src/controller/achieveExpert.controller.ts
  17. 89 0
      src/controller/certFile.controller.ts
  18. 89 0
      src/controller/examLogs.controller.ts
  19. 89 0
      src/controller/expertExam.controller.ts
  20. 9 0
      src/controller/home.controller.ts
  21. 51 0
      src/entity/achieveExpert.entity.ts
  22. 21 0
      src/entity/certFile.entity.ts
  23. 27 0
      src/entity/examLogs.entity.ts
  24. 36 0
      src/entity/expertExam.entity.ts
  25. 13 0
      src/filter/default.filter.ts
  26. 10 0
      src/filter/notfound.filter.ts
  27. 6 0
      src/interface.ts
  28. 171 0
      src/interface/achieveExpert.interface.ts
  29. 107 0
      src/interface/certFile.interface.ts
  30. 131 0
      src/interface/examLogs.interface.ts
  31. 120 0
      src/interface/expertExam.interface.ts
  32. 33 0
      src/middleware/checkToken.middleware.ts
  33. 27 0
      src/middleware/report.middleware.ts
  34. 11 0
      src/service/achieveExpert.service.ts
  35. 11 0
      src/service/certFile.service.ts
  36. 11 0
      src/service/examLogs.service.ts
  37. 11 0
      src/service/expertExam.service.ts
  38. 20 0
      test/controller/api.test.ts
  39. 21 0
      test/controller/home.test.ts
  40. 25 0
      tsconfig.json

+ 11 - 0
.editorconfig

@@ -0,0 +1,11 @@
+# 🎨 editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 7 - 0
.eslintrc.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./node_modules/mwts/",
+  "ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
+  "env": {
+    "jest": true
+  }
+}

+ 15 - 0
.gitignore

@@ -0,0 +1,15 @@
+logs/
+npm-debug.log
+yarn-error.log
+node_modules/
+package-lock.json
+yarn.lock
+coverage/
+dist/
+.idea/
+run/
+.DS_Store
+*.sw*
+*.un~
+.tsbuildinfo
+.tsbuildinfo.*

+ 3 - 0
.prettierrc.js

@@ -0,0 +1,3 @@
+module.exports = {
+  ...require('mwts/.prettierrc.json')
+}

+ 29 - 0
README.md

@@ -0,0 +1,29 @@
+# my_midway_project
+
+## QuickStart
+
+<!-- add docs here for user -->
+
+see [midway docs][midway] for more detail.
+
+### Development
+
+```bash
+$ npm i
+$ npm run dev
+$ open http://localhost:7001/
+```
+
+### Deploy
+
+```bash
+$ npm start
+```
+
+### npm scripts
+
+- Use `npm run lint` to check code style.
+- Use `npm test` to run unit test.
+
+
+[midway]: https://midwayjs.org

+ 29 - 0
README.zh-CN.md

@@ -0,0 +1,29 @@
+# my_midway_project
+
+## 快速入门
+
+<!-- 在此次添加使用文档 -->
+
+如需进一步了解,参见 [midway 文档][midway]。
+
+### 本地开发
+
+```bash
+$ npm i
+$ npm run dev
+$ open http://localhost:7001/
+```
+
+### 部署
+
+```bash
+$ npm start
+```
+
+### 内置指令
+
+- 使用 `npm run lint` 来做代码风格检查。
+- 使用 `npm test` 来执行单元测试。
+
+
+[midway]: https://midwayjs.org

+ 2 - 0
bootstrap.js

@@ -0,0 +1,2 @@
+const { Bootstrap } = require('@midwayjs/bootstrap');
+Bootstrap.run();

+ 20 - 0
ecosystem.config.js

@@ -0,0 +1,20 @@
+'use strict';
+// 开发服务设置
+const app = '中科在线成果评价系统vue3-服务';
+module.exports = {
+  apps: [
+    {
+      name: app, // 应用名称
+      script: './bootstrap.js', // 实际启动脚本
+      out: `./logs/${app}.log`,
+      error: `./logs/${app}.err`,
+      watch: [
+        // 监控变化的目录,一旦变化,自动重启
+        'dist',
+      ],
+      env: {
+        NODE_ENV: 'production', // 环境参数,当前指定为生产环境
+      },
+    },
+  ],
+};

+ 6 - 0
jest.config.js

@@ -0,0 +1,6 @@
+module.exports = {
+  preset: 'ts-jest',
+  testEnvironment: 'node',
+  testPathIgnorePatterns: ['<rootDir>/test/fixtures'],
+  coveragePathIgnorePatterns: ['<rootDir>/test/'],
+};

+ 65 - 0
package.json

@@ -0,0 +1,65 @@
+{
+  "name": "my-midway-project",
+  "version": "1.0.0",
+  "description": "",
+  "private": true,
+  "dependencies": {
+    "@midwayjs/axios": "^3.11.5",
+    "@midwayjs/bootstrap": "^3.0.0",
+    "@midwayjs/core": "^3.0.0",
+    "@midwayjs/decorator": "^3.0.0",
+    "@midwayjs/info": "^3.0.0",
+    "@midwayjs/jwt": "^3.11.5",
+    "@midwayjs/koa": "^3.0.0",
+    "@midwayjs/logger": "^2.14.0",
+    "@midwayjs/redis": "^3.11.5",
+    "@midwayjs/swagger": "^3.11.5",
+    "@midwayjs/typegoose": "^3.11.5",
+    "@midwayjs/validate": "^3.0.0",
+    "@typegoose/typegoose": "^11.0.3",
+    "amqplib": "^0.10.3",
+    "exceljs": "^4.3.0",
+    "free-midway-component": "^1.0.35",
+    "moment": "^2.29.4",
+    "mongoose": "^7.1.0",
+    "swagger-ui-dist": "^4.18.3"
+  },
+  "devDependencies": {
+    "@midwayjs/cli": "^2.0.0",
+    "@midwayjs/mock": "^3.0.0",
+    "@types/amqplib": "^0.10.1",
+    "@types/jest": "^29.2.0",
+    "@types/jsonwebtoken": "^9.0.2",
+    "@types/koa": "^2.13.4",
+    "@types/lodash": "^4.14.194",
+    "@types/node": "14",
+    "cross-env": "^6.0.0",
+    "jest": "^29.2.2",
+    "mwts": "^1.0.5",
+    "ts-jest": "^29.0.3",
+    "typescript": "~4.8.0"
+  },
+  "engines": {
+    "node": ">=12.0.0"
+  },
+  "scripts": {
+    "start": "NODE_ENV=production node ./bootstrap.js",
+    "dev": "cross-env NODE_ENV=local midway-bin dev --ts",
+    "test": "midway-bin test --ts",
+    "cov": "midway-bin cov --ts",
+    "lint": "mwts check",
+    "lint:fix": "mwts fix",
+    "ci": "npm run cov",
+    "build": "midway-bin build -c"
+  },
+  "midway-bin-clean": [
+    ".vscode/.tsbuildinfo",
+    "dist"
+  ],
+  "repository": {
+    "type": "git",
+    "url": ""
+  },
+  "author": "anonymous",
+  "license": "MIT"
+}

+ 19 - 0
src/config/config.default.ts

@@ -0,0 +1,19 @@
+import { MidwayConfig } from '@midwayjs/core';
+
+const project = 'zkzx';
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1672292154640_555',
+  koa: {
+    port: 12003,
+  },
+  jwt: {
+    secret: 'Ziyouyanfa!@#',
+    expiresIn: '2d',
+  },
+  redis_timeout: 300, //s
+  emailConfig: project,
+  axios: {
+    clients: {},
+  },
+} as MidwayConfig;

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

@@ -0,0 +1,39 @@
+import { MidwayConfig } from '@midwayjs/core';
+const ip = '127.0.0.1';
+const project = 'zkzx';
+const mongodb = 'zkzx_v2_achieve';
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1672292154640_555',
+  koa: {
+    globalPrefix: `/${project}/v2/achieve/api`,
+  },
+  swagger: {
+    swaggerPath: `/dev/${project}/v2/achieve/api/doc`,
+  },
+  mongoose: {
+    dataSource: {
+      default: {
+        uri: `mongodb://${ip}:27017/${mongodb}`,
+        options: {
+          user: 'admin',
+          pass: 'admin',
+          authSource: 'admin',
+          useNewUrlParser: true,
+        },
+        entities: ['./entity'],
+      },
+    },
+  },
+  // redis: {
+  //   client: {
+  //     port: 6379, // Redis port
+  //     host: '120.48.146.1', // Redis host
+  //     password: '123456',
+  //     db: 4,
+  //   },
+  // },
+  axios: {
+    clients: {},
+  },
+} as MidwayConfig;

+ 43 - 0
src/config/config.prod.ts

@@ -0,0 +1,43 @@
+import { MidwayConfig } from '@midwayjs/core';
+const ip = '127.0.0.1';
+const project = 'zkzx';
+const mongodb = 'zkzx_v2_achieve';
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1672292154640_555',
+  koa: {
+    globalPrefix: `/${project}/v2/achieve/api`,
+  },
+  swagger: {
+    swaggerPath: `/dev/${project}/v2/achieve/api/doc`,
+  },
+  mongoose: {
+    dataSource: {
+      default: {
+        uri: `mongodb://${ip}:27017/${mongodb}`,
+        options: {
+          user: 'admin',
+          pass: 'admin',
+          authSource: 'admin',
+          useNewUrlParser: true,
+        },
+        entities: ['./entity'],
+      },
+    },
+  },
+  // redis: {
+  //   client: {
+  //     port: 6379, // Redis port
+  //     host: '120.48.146.1', // Redis host
+  //     password: '123456',
+  //     db: 4,
+  //   },
+  // },
+  axios: {
+    clients: {
+      // email: {
+      //   baseURL: 'http://127.0.0.1:14002/semail/api',
+      // },
+    },
+  },
+} as MidwayConfig;

+ 7 - 0
src/config/config.unittest.ts

@@ -0,0 +1,7 @@
+import { MidwayConfig } from '@midwayjs/core';
+
+export default {
+  koa: {
+    port: null,
+  },
+} as MidwayConfig;

+ 51 - 0
src/configuration.ts

@@ -0,0 +1,51 @@
+import { Configuration, App } from '@midwayjs/core';
+// import * as rabbitmq from '@midwayjs/rabbitmq';
+import * as koa from '@midwayjs/koa';
+import * as validate from '@midwayjs/validate';
+import * as info from '@midwayjs/info';
+import * as swagger from '@midwayjs/swagger';
+import * as jwt from '@midwayjs/jwt';
+import * as redis from '@midwayjs/redis';
+import * as axios from '@midwayjs/axios';
+// import { IMidwayContainer } from '@midwayjs/core';
+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 === 200) return response.data;
+//   else {
+//     console.log(JSON.stringify(response));
+//     throw new ServiceError('请求失败', FrameworkErrorEnum.SERVICE_FAULT);
+//   }
+// };
+// const axiosError = error => {
+//   return Promise.reject(error);
+// };
+@Configuration({
+  imports: [
+    FreeFrame,
+    validate,
+    jwt,
+    redis,
+    axios,
+    swagger,
+    // rabbitmq,
+    {
+      component: info,
+      enabledEnvironment: ['local'],
+    },
+  ],
+  importConfigs: [join(__dirname, './config')],
+})
+export class ContainerLifeCycle {
+  @App()
+  app: koa.Application;
+
+  async onReady() {
+    this.app.getMiddleware().insertFirst(CheckTokenMiddleware);
+  }
+}

+ 89 - 0
src/controller/achieveExpert.controller.ts

@@ -0,0 +1,89 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { AchieveExpertService } from '../service/achieveExpert.service';
+import {
+  CDTO_achieveExpert,
+  CVO_achieveExpert,
+  FVO_achieveExpert,
+  QDTO_achieveExpert,
+  QVO_achieveExpert,
+  UDTO_achieveExpert,
+  UVAO_achieveExpert,
+} from '../interface/achieveExpert.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['会审专家表'])
+@Controller('/achieveExpert')
+export class AchieveExpertController extends BaseController {
+  @Inject()
+  service: AchieveExpertService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_achieveExpert })
+  async create(@Body() data: CDTO_achieveExpert) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_achieveExpert(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_achieveExpert })
+  async query(
+    @Query() filter: QDTO_achieveExpert,
+    @Query('skip') skip: number,
+    @Query('limit') limit: number
+  ) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_achieveExpert(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_achieveExpert })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_achieveExpert(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_achieveExpert })
+  async update(@Param('id') id: string, @Body() body: UDTO_achieveExpert) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 89 - 0
src/controller/certFile.controller.ts

@@ -0,0 +1,89 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { CertFileService } from '../service/certFile.service';
+import {
+  CDTO_certFile,
+  CVO_certFile,
+  FVO_certFile,
+  QDTO_certFile,
+  QVO_certFile,
+  UDTO_certFile,
+  UVAO_certFile,
+} from '../interface/certFile.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['证书单独上传'])
+@Controller('/certFile')
+export class CertFileController extends BaseController {
+  @Inject()
+  service: CertFileService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_certFile })
+  async create(@Body() data: CDTO_certFile) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_certFile(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_certFile })
+  async query(
+    @Query() filter: QDTO_certFile,
+    @Query('skip') skip: number,
+    @Query('limit') limit: number
+  ) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_certFile(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_certFile })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_certFile(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_certFile })
+  async update(@Param('id') id: string, @Body() body: UDTO_certFile) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 89 - 0
src/controller/examLogs.controller.ts

@@ -0,0 +1,89 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ExamLogsService } from '../service/examLogs.service';
+import {
+  CDTO_examLogs,
+  CVO_examLogs,
+  FVO_examLogs,
+  QDTO_examLogs,
+  QVO_examLogs,
+  UDTO_examLogs,
+  UVAO_examLogs,
+} from '../interface/examLogs.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['审核记录表'])
+@Controller('/examLogs')
+export class ExamLogsController extends BaseController {
+  @Inject()
+  service: ExamLogsService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_examLogs })
+  async create(@Body() data: CDTO_examLogs) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_examLogs(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_examLogs })
+  async query(
+    @Query() filter: QDTO_examLogs,
+    @Query('skip') skip: number,
+    @Query('limit') limit: number
+  ) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_examLogs(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_examLogs })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_examLogs(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_examLogs })
+  async update(@Param('id') id: string, @Body() body: UDTO_examLogs) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 89 - 0
src/controller/expertExam.controller.ts

@@ -0,0 +1,89 @@
+import {
+  Body,
+  Controller,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ExpertExamService } from '../service/expertExam.service';
+import {
+  CDTO_expertExam,
+  CVO_expertExam,
+  FVO_expertExam,
+  QDTO_expertExam,
+  QVO_expertExam,
+  UDTO_expertExam,
+  UVAO_expertExam,
+} from '../interface/expertExam.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['专家评分会审表'])
+@Controller('/expertExam')
+export class ExpertExamController extends BaseController {
+  @Inject()
+  service: ExpertExamService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_expertExam })
+  async create(@Body() data: CDTO_expertExam) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_expertExam(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_expertExam })
+  async query(
+    @Query() filter: QDTO_expertExam,
+    @Query('skip') skip: number,
+    @Query('limit') limit: number
+  ) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_expertExam(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_expertExam })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_expertExam(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_expertExam })
+  async update(@Param('id') id: string, @Body() body: UDTO_expertExam) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 9 - 0
src/controller/home.controller.ts

@@ -0,0 +1,9 @@
+import { Controller, Get } from '@midwayjs/core';
+
+@Controller('/')
+export class HomeController {
+  @Get('/')
+  async home(): Promise<string> {
+    return 'Hello Midwayjs!';
+  }
+}

+ 51 - 0
src/entity/achieveExpert.entity.ts

@@ -0,0 +1,51 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+import isString = require('lodash/isString');
+@modelOptions({
+  schemaOptions: { collection: 'achieveExpert' },
+})
+export class AchieveExpert extends BaseModel {
+  @prop({ required: false, index: true, zh: '用户类型', default: '11' })
+  type: string;
+  @prop({ required: false, index: true, zh: '角色' })
+  role: Array<any>;
+  @prop({ required: false, index: true, zh: '专家id' })
+  expert_id: string;
+  @prop({ required: false, index: true, zh: '专家姓名' })
+  expert_name: string;
+  @prop({ required: false, index: true, zh: '账号' })
+  acount: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: {
+    secret: string;
+  };
+  @prop({ required: false, index: true, zh: '手机号' })
+  phone: string;
+  @prop({ required: false, index: true, zh: '工作单位' })
+  company: string;
+  @prop({ required: false, index: true, zh: '评价专家组职务' })
+  group_zw: string;
+  @prop({ required: false, index: true, zh: '所学专业' })
+  major: string;
+  @prop({ required: false, index: true, zh: '现从事专业' })
+  on_major: string;
+  @prop({ required: false, index: true, zh: '职务' })
+  zw: string;
+  @prop({ required: false, index: true, zh: '职称' })
+  zc: string;
+  @prop({ required: false, index: true, zh: '状态', default: '1' })
+  status: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+}

+ 21 - 0
src/entity/certFile.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'certFile' },
+})
+export class CertFile extends BaseModel {
+  @prop({ required: false, index: true, zh: '申请id' })
+  user_id: string;
+  @prop({ required: false, index: true, zh: '申请人姓名' })
+  user_name: string;
+  @prop({ required: false, index: true, zh: '成果申请id' })
+  apply_id: string;
+  @prop({ required: false, index: true, zh: '成果申请名称' })
+  apply_name: string;
+  @prop({ required: false, index: false, zh: '证书资料' })
+  cert_file: Array<any>;
+  @prop({ required: false, index: true, zh: '上传时间' })
+  create_time: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+}

+ 27 - 0
src/entity/examLogs.entity.ts

@@ -0,0 +1,27 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'examLogs' },
+})
+export class ExamLogs extends BaseModel {
+  @prop({ required: false, index: true, zh: '审核人id' })
+  exam_id: string;
+  @prop({ required: false, index: true, zh: '审核人姓名' })
+  exam_name: string;
+  @prop({ required: false, index: true, zh: '审核人手机号' })
+  exam_phone: string;
+  @prop({ required: false, index: true, zh: '成果申请id' })
+  apply_id: string;
+  @prop({ required: false, index: true, zh: '成果申请名称' })
+  apply_name: string;
+  @prop({ required: false, index: true, zh: '审核步骤' })
+  step: string;
+  @prop({ required: false, index: true, zh: '审核状态' })
+  status: string;
+  @prop({ required: false, index: false, zh: '审核意见' })
+  desc: string;
+  @prop({ required: false, index: true, zh: '审核时间' })
+  create_time: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+}

+ 36 - 0
src/entity/expertExam.entity.ts

@@ -0,0 +1,36 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'expertExam' },
+})
+export class ExpertExam extends BaseModel {
+  @prop({ required: false, index: true, zh: '专家id' })
+  achieveexpert_id: string;
+  @prop({ required: false, index: true, zh: '专家姓名' })
+  expert_name: string;
+  @prop({ required: false, index: true, zh: '成果申请id' })
+  apply_id: string;
+  @prop({ required: false, index: true, zh: '成果申请名称' })
+  apply_name: string;
+  @prop({
+    required: false,
+    index: true,
+    zh: '工作类型',
+    remark: '字典表:achieve_expertexam_type',
+  })
+  type: string;
+  @prop({ required: false, index: false, zh: '分数' })
+  score: string;
+  @prop({ required: false, index: false, zh: '意见' })
+  desc: string;
+  @prop({
+    required: false,
+    index: true,
+    zh: '是否评分',
+    remark: '字典表:common_isno',
+    default: '1',
+  })
+  is_score: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+}

+ 13 - 0
src/filter/default.filter.ts

@@ -0,0 +1,13 @@
+import { Catch } from '@midwayjs/core';
+import { Context } from '@midwayjs/koa';
+
+@Catch()
+export class DefaultErrorFilter {
+  async catch(err: Error, ctx: Context) {
+    // 所有的未分类错误会到这里
+    return {
+      success: false,
+      message: err.message,
+    };
+  }
+}

+ 10 - 0
src/filter/notfound.filter.ts

@@ -0,0 +1,10 @@
+import { Catch, httpError, MidwayHttpError } from '@midwayjs/core';
+import { Context } from '@midwayjs/koa';
+
+@Catch(httpError.NotFoundError)
+export class NotFoundFilter {
+  async catch(err: MidwayHttpError, ctx: Context) {
+    // 404 错误会到这里
+    ctx.redirect('/404.html');
+  }
+}

+ 6 - 0
src/interface.ts

@@ -0,0 +1,6 @@
+/**
+ * @description User-Service parameters
+ */
+export interface IUserOptions {
+  uid: number;
+}

+ 171 - 0
src/interface/achieveExpert.interface.ts

@@ -0,0 +1,171 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_achieveExpert {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '角色' })
+  'role': Array<any> = undefined;
+  @ApiProperty({ description: '专家id' })
+  'expert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '账号' })
+  'acount': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '工作单位' })
+  'company': string = undefined;
+  @ApiProperty({ description: '评价专家组职务' })
+  'group_zw': string = undefined;
+  @ApiProperty({ description: '所学专业' })
+  'major': string = undefined;
+  @ApiProperty({ description: '现从事专业' })
+  'on_major': string = undefined;
+  @ApiProperty({ description: '职务' })
+  'zw': string = undefined;
+  @ApiProperty({ description: '职称' })
+  'zc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+}
+
+export class QDTO_achieveExpert extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = [
+      'type',
+      'role',
+      'expert_id',
+      'expert_name',
+      'acount',
+      'phone',
+      'company',
+      'group_zw',
+      'major',
+      'on_major',
+      'zw',
+      'zc',
+      'status',
+    ];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '用户类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '角色' })
+  'role': Array<any> = undefined;
+  @ApiProperty({ description: '专家id' })
+  'expert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '账号' })
+  'acount': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '工作单位' })
+  'company': string = undefined;
+  @ApiProperty({ description: '评价专家组职务' })
+  'group_zw': string = undefined;
+  @ApiProperty({ description: '所学专业' })
+  'major': string = undefined;
+  @ApiProperty({ description: '现从事专业' })
+  'on_major': string = undefined;
+  @ApiProperty({ description: '职务' })
+  'zw': string = undefined;
+  @ApiProperty({ description: '职称' })
+  'zc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_achieveExpert extends FVO_achieveExpert {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_achieveExpert {
+  @ApiProperty({ description: '用户类型' })
+  @Rule(RuleType['string']().empty(''))
+  'type': string = undefined;
+  @ApiProperty({ description: '角色' })
+  @Rule(RuleType['array']().empty(''))
+  'role': Array<any> = undefined;
+  @ApiProperty({ description: '专家id' })
+  @Rule(RuleType['string']().empty(''))
+  'expert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  @Rule(RuleType['string']().empty(''))
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '账号' })
+  @Rule(RuleType['string']().empty(''))
+  'acount': string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+  @ApiProperty({ description: '手机号' })
+  @Rule(RuleType['string']().empty(''))
+  'phone': string = undefined;
+  @ApiProperty({ description: '工作单位' })
+  @Rule(RuleType['string']().empty(''))
+  'company': string = undefined;
+  @ApiProperty({ description: '评价专家组职务' })
+  @Rule(RuleType['string']().empty(''))
+  'group_zw': string = undefined;
+  @ApiProperty({ description: '所学专业' })
+  @Rule(RuleType['string']().empty(''))
+  'major': string = undefined;
+  @ApiProperty({ description: '现从事专业' })
+  @Rule(RuleType['string']().empty(''))
+  'on_major': string = undefined;
+  @ApiProperty({ description: '职务' })
+  @Rule(RuleType['string']().empty(''))
+  'zw': string = undefined;
+  @ApiProperty({ description: '职称' })
+  @Rule(RuleType['string']().empty(''))
+  'zc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+}
+
+export class CVO_achieveExpert extends FVO_achieveExpert {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_achieveExpert extends CDTO_achieveExpert {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_achieveExpert extends FVO_achieveExpert {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 107 - 0
src/interface/certFile.interface.ts

@@ -0,0 +1,107 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_certFile {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '申请id' })
+  'user_id': string = undefined;
+  @ApiProperty({ description: '申请人姓名' })
+  'user_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '证书资料' })
+  'cert_file': Array<any> = undefined;
+  @ApiProperty({ description: '上传时间' })
+  'create_time': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+}
+
+export class QDTO_certFile extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = [
+      'user_id',
+      'user_name',
+      'apply_id',
+      'apply_name',
+      'create_time',
+    ];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '申请id' })
+  'user_id': string = undefined;
+  @ApiProperty({ description: '申请人姓名' })
+  'user_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '上传时间' })
+  'create_time': string = undefined;
+}
+
+export class QVO_certFile extends FVO_certFile {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_certFile {
+  @ApiProperty({ description: '申请id' })
+  @Rule(RuleType['string']().empty(''))
+  'user_id': string = undefined;
+  @ApiProperty({ description: '申请人姓名' })
+  @Rule(RuleType['string']().empty(''))
+  'user_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '证书资料' })
+  @Rule(RuleType['array']().empty(''))
+  'cert_file': Array<any> = undefined;
+  @ApiProperty({ description: '上传时间' })
+  @Rule(RuleType['string']().empty(''))
+  'create_time': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+}
+
+export class CVO_certFile extends FVO_certFile {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_certFile extends CDTO_certFile {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_certFile extends FVO_certFile {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 131 - 0
src/interface/examLogs.interface.ts

@@ -0,0 +1,131 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_examLogs {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '审核人id' })
+  'exam_id': string = undefined;
+  @ApiProperty({ description: '审核人姓名' })
+  'exam_name': string = undefined;
+  @ApiProperty({ description: '审核人手机号' })
+  'exam_phone': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '审核步骤' })
+  'step': string = undefined;
+  @ApiProperty({ description: '审核状态' })
+  'status': string = undefined;
+  @ApiProperty({ description: '审核意见' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '审核时间' })
+  'create_time': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+}
+
+export class QDTO_examLogs extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = [
+      'exam_id',
+      'exam_name',
+      'exam_phone',
+      'apply_id',
+      'apply_name',
+      'step',
+      'status',
+      'create_time',
+    ];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '审核人id' })
+  'exam_id': string = undefined;
+  @ApiProperty({ description: '审核人姓名' })
+  'exam_name': string = undefined;
+  @ApiProperty({ description: '审核人手机号' })
+  'exam_phone': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '审核步骤' })
+  'step': string = undefined;
+  @ApiProperty({ description: '审核状态' })
+  'status': string = undefined;
+  @ApiProperty({ description: '审核时间' })
+  'create_time': string = undefined;
+}
+
+export class QVO_examLogs extends FVO_examLogs {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_examLogs {
+  @ApiProperty({ description: '审核人id' })
+  @Rule(RuleType['string']().empty(''))
+  'exam_id': string = undefined;
+  @ApiProperty({ description: '审核人姓名' })
+  @Rule(RuleType['string']().empty(''))
+  'exam_name': string = undefined;
+  @ApiProperty({ description: '审核人手机号' })
+  @Rule(RuleType['string']().empty(''))
+  'exam_phone': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '审核步骤' })
+  @Rule(RuleType['string']().empty(''))
+  'step': string = undefined;
+  @ApiProperty({ description: '审核状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+  @ApiProperty({ description: '审核意见' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '审核时间' })
+  @Rule(RuleType['string']().empty(''))
+  'create_time': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+}
+
+export class CVO_examLogs extends FVO_examLogs {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_examLogs extends CDTO_examLogs {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_examLogs extends FVO_examLogs {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 120 - 0
src/interface/expertExam.interface.ts

@@ -0,0 +1,120 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_expertExam {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '专家id' })
+  'achieveexpert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '工作类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '分数' })
+  'score': string = undefined;
+  @ApiProperty({ description: '意见' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '是否评分' })
+  'is_score': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+}
+
+export class QDTO_expertExam extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = [
+      'achieveexpert_id',
+      'expert_name',
+      'apply_id',
+      'apply_name',
+      'type',
+      'is_score',
+    ];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '专家id' })
+  'achieveexpert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '工作类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '是否评分' })
+  'is_score': string = undefined;
+}
+
+export class QVO_expertExam extends FVO_expertExam {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_expertExam {
+  @ApiProperty({ description: '专家id' })
+  @Rule(RuleType['string']().empty(''))
+  'achieveexpert_id': string = undefined;
+  @ApiProperty({ description: '专家姓名' })
+  @Rule(RuleType['string']().empty(''))
+  'expert_name': string = undefined;
+  @ApiProperty({ description: '成果申请id' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_id': string = undefined;
+  @ApiProperty({ description: '成果申请名称' })
+  @Rule(RuleType['string']().empty(''))
+  'apply_name': string = undefined;
+  @ApiProperty({ description: '工作类型' })
+  @Rule(RuleType['string']().empty(''))
+  'type': string = undefined;
+  @ApiProperty({ description: '分数' })
+  @Rule(RuleType['string']().empty(''))
+  'score': string = undefined;
+  @ApiProperty({ description: '意见' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '是否评分' })
+  @Rule(RuleType['string']().empty(''))
+  'is_score': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+}
+
+export class CVO_expertExam extends FVO_expertExam {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_expertExam extends CDTO_expertExam {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_expertExam extends FVO_expertExam {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

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

@@ -0,0 +1,33 @@
+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';
+  }
+}

+ 27 - 0
src/middleware/report.middleware.ts

@@ -0,0 +1,27 @@
+import { Middleware, IMiddleware } from '@midwayjs/core';
+import { NextFunction, Context } from '@midwayjs/koa';
+
+@Middleware()
+export class ReportMiddleware implements IMiddleware<Context, NextFunction> {
+  resolve() {
+    return async (ctx: Context, next: NextFunction) => {
+      // 控制器前执行的逻辑
+      const startTime = Date.now();
+      // 执行下一个 Web 中间件,最后执行到控制器
+      // 这里可以拿到下一个中间件或者控制器的返回值
+      const result = await next();
+      // 控制器之后执行的逻辑
+      ctx.logger.info(
+        `Report in "src/middleware/report.middleware.ts", rt = ${
+          Date.now() - startTime
+        }ms`
+      );
+      // 返回给上一个中间件的结果
+      return result;
+    };
+  }
+
+  static getName(): string {
+    return 'report';
+  }
+}

+ 11 - 0
src/service/achieveExpert.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { AchieveExpert } from '../entity/achieveExpert.entity';
+type modelType = ReturnModelType<typeof AchieveExpert>;
+@Provide()
+export class AchieveExpertService extends BaseService<modelType> {
+  @InjectEntityModel(AchieveExpert)
+  model: modelType;
+}

+ 11 - 0
src/service/certFile.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { CertFile } from '../entity/certFile.entity';
+type modelType = ReturnModelType<typeof CertFile>;
+@Provide()
+export class CertFileService extends BaseService<modelType> {
+  @InjectEntityModel(CertFile)
+  model: modelType;
+}

+ 11 - 0
src/service/examLogs.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { ExamLogs } from '../entity/examLogs.entity';
+type modelType = ReturnModelType<typeof ExamLogs>;
+@Provide()
+export class ExamLogsService extends BaseService<modelType> {
+  @InjectEntityModel(ExamLogs)
+  model: modelType;
+}

+ 11 - 0
src/service/expertExam.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { ExpertExam } from '../entity/expertExam.entity';
+type modelType = ReturnModelType<typeof ExpertExam>;
+@Provide()
+export class ExpertExamService extends BaseService<modelType> {
+  @InjectEntityModel(ExpertExam)
+  model: modelType;
+}

+ 20 - 0
test/controller/api.test.ts

@@ -0,0 +1,20 @@
+import { createApp, close, createHttpRequest } from '@midwayjs/mock';
+import { Framework } from '@midwayjs/koa';
+
+describe('test/controller/home.test.ts', () => {
+
+  it('should POST /api/get_user', async () => {
+    // create app
+    const app = await createApp<Framework>();
+
+    // make request
+    const result = await createHttpRequest(app).get('/api/get_user').query({ uid: 123 });
+
+    // use expect by jest
+    expect(result.status).toBe(200);
+    expect(result.body.message).toBe('OK');
+
+    // close app
+    await close(app);
+  });
+});

+ 21 - 0
test/controller/home.test.ts

@@ -0,0 +1,21 @@
+import { createApp, close, createHttpRequest } from '@midwayjs/mock';
+import { Framework } from '@midwayjs/koa';
+
+describe('test/controller/home.test.ts', () => {
+
+  it('should GET /', async () => {
+    // create app
+    const app = await createApp<Framework>();
+
+    // make request
+    const result = await createHttpRequest(app).get('/');
+
+    // use expect by jest
+    expect(result.status).toBe(200);
+    expect(result.text).toBe('Hello Midwayjs!');
+
+    // close app
+    await close(app);
+  });
+
+});

+ 25 - 0
tsconfig.json

@@ -0,0 +1,25 @@
+{
+  "compileOnSave": true,
+  "compilerOptions": {
+    "target": "es2018",
+    "module": "commonjs",
+    "moduleResolution": "node",
+    "experimentalDecorators": true,
+    "emitDecoratorMetadata": true,
+    "inlineSourceMap":true,
+    "noImplicitThis": true,
+    "noUnusedLocals": true,
+    "stripInternal": true,
+    "skipLibCheck": true,
+    "pretty": true,
+    "declaration": true,
+    "forceConsistentCasingInFileNames": true,
+    "typeRoots": [ "./typings", "./node_modules/@types"],
+    "outDir": "dist"
+  },
+  "exclude": [
+    "dist",
+    "node_modules",
+    "test"
+  ]
+}