lrf 1 éve
commit
5b916a37d4
100 módosított fájl, 4700 hozzáadás és 0 törlés
  1. 11 0
      .editorconfig
  2. 11 0
      .eslintrc.json
  3. 16 0
      .gitignore
  4. 4 0
      .prettierrc.js
  5. 29 0
      README.md
  6. 29 0
      README.zh-CN.md
  7. 2 0
      bootstrap.js
  8. 17 0
      ecosystem.config.js
  9. 6 0
      jest.config.js
  10. 59 0
      package.json
  11. 9 0
      src/config/config.default.ts
  12. 32 0
      src/config/config.prod.ts
  13. 7 0
      src/config/config.unittest.ts
  14. 42 0
      src/configuration.ts
  15. 77 0
      src/controller/core/achieve.controller.ts
  16. 77 0
      src/controller/core/demand.controller.ts
  17. 77 0
      src/controller/core/service.controller.ts
  18. 77 0
      src/controller/core/trade/auction.controller.ts
  19. 68 0
      src/controller/core/trade/listing.controller.ts
  20. 68 0
      src/controller/core/trade/negotiate.controller.ts
  21. 13 0
      src/controller/home.controller.ts
  22. 68 0
      src/controller/service/linkItem.controller.ts
  23. 68 0
      src/controller/service/notice.controller.ts
  24. 68 0
      src/controller/service/policy.controller.ts
  25. 68 0
      src/controller/service/trends.controller.ts
  26. 68 0
      src/controller/service/video.controller.ts
  27. 68 0
      src/controller/system/dictData.controller.ts
  28. 68 0
      src/controller/system/dictType.controller.ts
  29. 21 0
      src/controller/system/init.controller.ts
  30. 62 0
      src/controller/system/menus.controller.ts
  31. 93 0
      src/controller/system/role.controller.ts
  32. 81 0
      src/controller/user/admin.controller.ts
  33. 89 0
      src/controller/user/login.controller.ts
  34. 70 0
      src/controller/user/research.controller.ts
  35. 70 0
      src/controller/user/selfUser.controller.ts
  36. 41 0
      src/controller/user/token.controller.ts
  37. 70 0
      src/controller/user/unit.controller.ts
  38. 37 0
      src/decorator/verifyToken.decorator.ts
  39. 35 0
      src/entity/core/achieve.entity.ts
  40. 27 0
      src/entity/core/demand.entity.ts
  41. 25 0
      src/entity/core/service.entity.ts
  42. 25 0
      src/entity/core/trade/auction.entity.ts
  43. 27 0
      src/entity/core/trade/listing.entity.ts
  44. 29 0
      src/entity/core/trade/negotiate.entity.ts
  45. 15 0
      src/entity/service/linkItem.entity.ts
  46. 17 0
      src/entity/service/notice.entity.ts
  47. 21 0
      src/entity/service/policy.entity.ts
  48. 21 0
      src/entity/service/trends.entity.ts
  49. 17 0
      src/entity/service/video.entity.ts
  50. 17 0
      src/entity/system/dictData.entity.ts
  51. 15 0
      src/entity/system/dictType.entity.ts
  52. 25 0
      src/entity/system/menus.entity.ts
  53. 17 0
      src/entity/system/role.entity.ts
  54. 31 0
      src/entity/user/admin.entity.ts
  55. 41 0
      src/entity/user/research.entity.ts
  56. 35 0
      src/entity/user/selfUser.entity.ts
  57. 41 0
      src/entity/user/unit.entity.ts
  58. 13 0
      src/filter/default.filter.ts
  59. 10 0
      src/filter/notfound.filter.ts
  60. 6 0
      src/interface.ts
  61. 130 0
      src/interface/core/achieve.interface.ts
  62. 112 0
      src/interface/core/demand.interface.ts
  63. 109 0
      src/interface/core/service.interface.ts
  64. 107 0
      src/interface/core/trade/auction.interface.ts
  65. 112 0
      src/interface/core/trade/listing.interface.ts
  66. 119 0
      src/interface/core/trade/negotiate.interface.ts
  67. 78 0
      src/interface/service/linkItem.interface.ts
  68. 83 0
      src/interface/service/notice.interface.ts
  69. 93 0
      src/interface/service/policy.interface.ts
  70. 97 0
      src/interface/service/trends.interface.ts
  71. 85 0
      src/interface/service/video.interface.ts
  72. 85 0
      src/interface/system/dictData.interface.ts
  73. 80 0
      src/interface/system/dictType.interface.ts
  74. 107 0
      src/interface/system/menus.interface.ts
  75. 85 0
      src/interface/system/role.interface.ts
  76. 91 0
      src/interface/user/admin.interface.ts
  77. 42 0
      src/interface/user/login.interface.ts
  78. 115 0
      src/interface/user/research.interface.ts
  79. 102 0
      src/interface/user/selfUser.interface.ts
  80. 117 0
      src/interface/user/unit.interface.ts
  81. 33 0
      src/middleware/checkToken.middleware.ts
  82. 27 0
      src/middleware/report.middleware.ts
  83. 12 0
      src/service/core/achieve.service.ts
  84. 32 0
      src/service/core/coreUtil.service.ts
  85. 11 0
      src/service/core/demand.service.ts
  86. 11 0
      src/service/core/service.service.ts
  87. 11 0
      src/service/core/trade/auction.service.ts
  88. 19 0
      src/service/core/trade/listing.service.ts
  89. 11 0
      src/service/core/trade/negotiate.service.ts
  90. 11 0
      src/service/service/linkItem.service.ts
  91. 11 0
      src/service/service/notice.service.ts
  92. 11 0
      src/service/service/policy.service.ts
  93. 11 0
      src/service/service/trends.service.ts
  94. 11 0
      src/service/service/video.service.ts
  95. 11 0
      src/service/system/dictData.service.ts
  96. 11 0
      src/service/system/dictType.service.ts
  97. 54 0
      src/service/system/init.service.ts
  98. 38 0
      src/service/system/menus.service.ts
  99. 64 0
      src/service/system/role.service.ts
  100. 0 0
      src/service/user/admin.service.ts

+ 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

+ 11 - 0
.eslintrc.json

@@ -0,0 +1,11 @@
+{
+  "extends": "./node_modules/mwts/",
+  "ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
+  "env": {
+    "jest": true
+  },
+  "rules": {
+    "prettier/prettier": 0,
+    "max-len": ["warn", { "code": 250 }]
+  }
+}

+ 16 - 0
.gitignore

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

+ 4 - 0
.prettierrc.js

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

+ 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();

+ 17 - 0
ecosystem.config.js

@@ -0,0 +1,17 @@
+'use strict';
+
+const app = 'zdlyjszy';
+module.exports = {
+  apps: [{
+    name: app, // 应用名称
+    script: './bootstrap.js', // 实际启动脚本
+    out: `./logs/${app}.log`,
+    error: `./logs/${app}.err`,
+    watch: [ // 监控变化的目录,一旦变化,自动重启
+      'app', 'config',
+    ],
+    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/'],
+};

+ 59 - 0
package.json

@@ -0,0 +1,59 @@
+{
+  "name": "service",
+  "version": "1.0.0",
+  "description": "",
+  "private": true,
+  "dependencies": {
+    "@midwayjs/bootstrap": "^3.12.0",
+    "@midwayjs/core": "^3.12.0",
+    "@midwayjs/decorator": "^3.12.0",
+    "@midwayjs/info": "^3.12.0",
+    "@midwayjs/jwt": "^3.13.7",
+    "@midwayjs/koa": "^3.12.0",
+    "@midwayjs/logger": "^2.14.0",
+    "@midwayjs/swagger": "^3.13.7",
+    "@midwayjs/typegoose": "^3.0.0",
+    "@midwayjs/validate": "^3.13.7",
+    "@typegoose/typegoose": "^9.0.0",
+    "free-midway-component": "^1.0.50",
+    "lodash": "^4.17.21",
+    "mongoose": "^6.0.7"
+  },
+  "devDependencies": {
+    "@midwayjs/cli": "^2.0.0",
+    "@midwayjs/mock": "^3.12.0",
+    "@types/jest": "^29.2.0",
+    "@types/koa": "^2.13.4",
+    "@types/lodash": "^4.14.202",
+    "@types/node": "14",
+    "cross-env": "^6.0.0",
+    "jest": "^29.2.2",
+    "mwts": "^1.3.0",
+    "swagger-ui-dist": "^5.10.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 TS_NODE_TYPE_CHECK=false TS_NODE_TRANSPILE_ONLY=true 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"
+}

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

@@ -0,0 +1,9 @@
+import { MidwayConfig } from '@midwayjs/core';
+
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1702860978682_3888',
+  koa: {
+    port: 7001,
+  },
+} as MidwayConfig;

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

@@ -0,0 +1,32 @@
+import { MidwayConfig } from '@midwayjs/core';
+const ip = 'host.docker.internal';
+const project = 'zdlyjszy';
+export default {
+  // use for cookie sign key, should change to your own and keep security
+  keys: '1697684406848_4978',
+  koa: {
+    port: 8700,
+    globalPrefix: '/zdlyjszy/api',
+  },
+  jwt: {
+    secret: 'Ziyouyanfa!@#',
+    expiresIn: '2d',
+  },
+  mongoose: {
+    dataSource: {
+      default: {
+        uri: `mongodb://${ip}:27017/${project}`,
+        options: {
+          user: 'admin',
+          pass: 'admin',
+          authSource: 'admin',
+          useNewUrlParser: true,
+        },
+        entities: ['./entity'],
+      },
+    },
+  },
+  upload: {
+    whitelist: null,
+  },
+} 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;

+ 42 - 0
src/configuration.ts

@@ -0,0 +1,42 @@
+import {
+  Configuration,
+  App,
+  Inject,
+  MidwayDecoratorService,
+} from '@midwayjs/core';
+import * as koa from '@midwayjs/koa';
+import * as validate from '@midwayjs/validate';
+import * as info from '@midwayjs/info';
+import { join } from 'path';
+import * as FreeFrame from 'free-midway-component';
+import * as jwt from '@midwayjs/jwt';
+import { VerifyTokenInit } from './decorator/verifyToken.decorator';
+import { CheckTokenMiddleware } from './middleware/checkToken.middleware';
+import * as swagger from '@midwayjs/swagger';
+@Configuration({
+  imports: [
+    FreeFrame,
+    validate,
+    jwt,
+    {
+      component: info,
+      enabledEnvironment: ['local'],
+    },
+    {
+      component: swagger,
+      enabledEnvironment: ['local'],
+    },
+  ],
+  importConfigs: [join(__dirname, './config')],
+})
+export class MainConfiguration {
+  @App('koa')
+  app: koa.Application;
+  @Inject()
+  decoratorService: MidwayDecoratorService;
+  async onReady() {
+    this.app.getMiddleware().insertFirst(CheckTokenMiddleware);
+    // 注解
+    VerifyTokenInit(this.decoratorService);
+  }
+}

+ 77 - 0
src/controller/core/achieve.controller.ts

@@ -0,0 +1,77 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { AchieveService } from '../../service/core/achieve.service';
+import { CDTO_achieve, CVO_achieve, FVO_achieve, QDTO_achieve, QVO_achieve, UDTO_achieve, UVAO_achieve } from '../../interface/core/achieve.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { CoreUtilService } from '../../service/core/coreUtil.service';
+@ApiTags(['成果表'])
+@Controller('/achieve')
+export class AchieveController extends BaseController {
+  @Inject()
+  service: AchieveService;
+  @Inject()
+  coreUtilService: CoreUtilService;
+
+  @Post('/getOwner')
+  async getOwner(@Body('owner') owner: string) {
+    const data = await this.coreUtilService.getOwner(owner);
+    return data;
+  }
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_achieve })
+  async create(@Body() data: CDTO_achieve) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_achieve(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_achieve })
+  async query(@Query() filter: QDTO_achieve, @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_achieve(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_achieve })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_achieve(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_achieve })
+  async update(@Param('id') id: string, @Body() body: UDTO_achieve) {
+    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.');
+  }
+}

+ 77 - 0
src/controller/core/demand.controller.ts

@@ -0,0 +1,77 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { DemandService } from '../../service/core/demand.service';
+import { CDTO_demand, CVO_demand, FVO_demand, QDTO_demand, QVO_demand, UDTO_demand, UVAO_demand } from '../../interface/core/demand.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { CoreUtilService } from '../../service/core/coreUtil.service';
+@ApiTags(['需求信息表'])
+@Controller('/demand')
+export class DemandController extends BaseController {
+  @Inject()
+  service: DemandService;
+  @Inject()
+  coreUtilService: CoreUtilService;
+
+  @Post('/getOwner')
+  async getOwner(@Body('owner') owner: string) {
+    const data = await this.coreUtilService.getOwner(owner);
+    return data;
+  }
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_demand })
+  async create(@Body() data: CDTO_demand) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_demand(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_demand })
+  async query(@Query() filter: QDTO_demand, @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_demand(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_demand })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_demand(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_demand })
+  async update(@Param('id') id: string, @Body() body: UDTO_demand) {
+    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.');
+  }
+}

+ 77 - 0
src/controller/core/service.controller.ts

@@ -0,0 +1,77 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ServiceService } from '../../service/core/service.service';
+import { CDTO_service, CVO_service, FVO_service, QDTO_service, QVO_service, UDTO_service, UVAO_service } from '../../interface/core/service.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { CoreUtilService } from '../../service/core/coreUtil.service';
+@ApiTags(['服务内容'])
+@Controller('/service')
+export class ServiceController extends BaseController {
+  @Inject()
+  service: ServiceService;
+  @Inject()
+  coreUtilService: CoreUtilService;
+
+  @Post('/getOwner')
+  async getOwner(@Body('owner') owner: string) {
+    const data = await this.coreUtilService.getOwner(owner);
+    return data;
+  }
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_service })
+  async create(@Body() data: CDTO_service) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_service(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_service })
+  async query(@Query() filter: QDTO_service, @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_service(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_service })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_service(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_service })
+  async update(@Param('id') id: string, @Body() body: UDTO_service) {
+    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.');
+  }
+}

+ 77 - 0
src/controller/core/trade/auction.controller.ts

@@ -0,0 +1,77 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { AuctionService } from '../../../service/core/trade/auction.service';
+import { CDTO_auction, CVO_auction, FVO_auction, QDTO_auction, QVO_auction, UDTO_auction, UVAO_auction } from '../../../interface/core/trade/auction.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { ListingService } from '../../../service/core/trade/listing.service';
+@ApiTags(['拍卖'])
+@Controller('/auction')
+export class AuctionController extends BaseController {
+  @Inject()
+  service: AuctionService;
+  @Inject()
+  listingService: ListingService;
+
+  @Post('/getListingList')
+  async getListingList(@Body('ids') ids: Array<string>) {
+    const list = await this.listingService.getListByIds(ids);
+    return list;
+  }
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_auction })
+  async create(@Body() data: CDTO_auction) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_auction(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_auction })
+  async query(@Query() filter: QDTO_auction, @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_auction(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_auction })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_auction(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_auction })
+  async update(@Param('id') id: string, @Body() body: UDTO_auction) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/core/trade/listing.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ListingService } from '../../../service/core/trade/listing.service';
+import { CDTO_listing, CVO_listing, FVO_listing, QDTO_listing, QVO_listing, UDTO_listing, UVAO_listing } from '../../../interface/core/trade/listing.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['挂牌交易'])
+@Controller('/listing')
+export class ListingController extends BaseController {
+  @Inject()
+  service: ListingService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_listing })
+  async create(@Body() data: CDTO_listing) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_listing(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_listing })
+  async query(@Query() filter: QDTO_listing, @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_listing(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_listing })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_listing(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_listing })
+  async update(@Param('id') id: string, @Body() body: UDTO_listing) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/core/trade/negotiate.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { NegotiateService } from '../../../service/core/trade/negotiate.service';
+import { CDTO_negotiate, CVO_negotiate, FVO_negotiate, QDTO_negotiate, QVO_negotiate, UDTO_negotiate, UVAO_negotiate } from '../../../interface/core/trade/negotiate.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['协商定价'])
+@Controller('/negotiate')
+export class NegotiateController extends BaseController {
+  @Inject()
+  service: NegotiateService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_negotiate })
+  async create(@Body() data: CDTO_negotiate) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_negotiate(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_negotiate })
+  async query(@Query() filter: QDTO_negotiate, @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_negotiate(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_negotiate })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_negotiate(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_negotiate })
+  async update(@Param('id') id: string, @Body() body: UDTO_negotiate) {
+    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.');
+  }
+}

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

@@ -0,0 +1,13 @@
+import { Controller, Get, Inject } from '@midwayjs/core';
+import { UtilService } from '../service/util.service';
+
+@Controller('/')
+export class HomeController {
+  @Inject()
+  utilService:UtilService;
+  @Get('/')
+  async home(): Promise<string> {
+    await this.utilService.util();
+    return 'Hello Midwayjs!';
+  }
+}

+ 68 - 0
src/controller/service/linkItem.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { LinkItemService } from '../../service/service/linkItem.service';
+import { CDTO_linkItem, CVO_linkItem, FVO_linkItem, QDTO_linkItem, QVO_linkItem, UDTO_linkItem, UVAO_linkItem } from '../../interface/service/linkItem.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['办事事项'])
+@Controller('/linkItem')
+export class LinkItemController extends BaseController {
+  @Inject()
+  service: LinkItemService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_linkItem })
+  async create(@Body() data: CDTO_linkItem) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_linkItem(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_linkItem })
+  async query(@Query() filter: QDTO_linkItem, @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_linkItem(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_linkItem })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_linkItem(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_linkItem })
+  async update(@Param('id') id: string, @Body() body: UDTO_linkItem) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/service/notice.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { NoticeService } from '../../service/service/notice.service';
+import { CDTO_notice, CVO_notice, FVO_notice, QDTO_notice, QVO_notice, UDTO_notice, UVAO_notice } from '../../interface/service/notice.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['通知公告'])
+@Controller('/notice')
+export class NoticeController extends BaseController {
+  @Inject()
+  service: NoticeService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_notice })
+  async create(@Body() data: CDTO_notice) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_notice(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_notice })
+  async query(@Query() filter: QDTO_notice, @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_notice(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_notice })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_notice(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_notice })
+  async update(@Param('id') id: string, @Body() body: UDTO_notice) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/service/policy.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { PolicyService } from '../../service/service/policy.service';
+import { CDTO_policy, CVO_policy, FVO_policy, QDTO_policy, QVO_policy, UDTO_policy, UVAO_policy } from '../../interface/service/policy.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['政策法规'])
+@Controller('/policy')
+export class PolicyController extends BaseController {
+  @Inject()
+  service: PolicyService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_policy })
+  async create(@Body() data: CDTO_policy) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_policy(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_policy })
+  async query(@Query() filter: QDTO_policy, @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_policy(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_policy })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_policy(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_policy })
+  async update(@Param('id') id: string, @Body() body: UDTO_policy) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/service/trends.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { TrendsService } from '../../service/service/trends.service';
+import { CDTO_trends, CVO_trends, FVO_trends, QDTO_trends, QVO_trends, UDTO_trends, UVAO_trends } from '../../interface/service/trends.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['行业动态'])
+@Controller('/trends')
+export class TrendsController extends BaseController {
+  @Inject()
+  service: TrendsService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_trends })
+  async create(@Body() data: CDTO_trends) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_trends(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_trends })
+  async query(@Query() filter: QDTO_trends, @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_trends(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_trends })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_trends(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_trends })
+  async update(@Param('id') id: string, @Body() body: UDTO_trends) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/service/video.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { VideoService } from '../../service/service/video.service';
+import { CDTO_video, CVO_video, FVO_video, QDTO_video, QVO_video, UDTO_video, UVAO_video } from '../../interface/service/video.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['视频管理'])
+@Controller('/video')
+export class VideoController extends BaseController {
+  @Inject()
+  service: VideoService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_video })
+  async create(@Body() data: CDTO_video) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_video(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_video })
+  async query(@Query() filter: QDTO_video, @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_video(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_video })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_video(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_video })
+  async update(@Param('id') id: string, @Body() body: UDTO_video) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/system/dictData.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { DictDataService } from '../../service/system/dictData.service';
+import { CDTO_dictData, CVO_dictData, FVO_dictData, QDTO_dictData, QVO_dictData, UDTO_dictData, UVAO_dictData } from '../../interface/system/dictData.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['字典数据表'])
+@Controller('/dictData')
+export class DictDataController extends BaseController {
+  @Inject()
+  service: DictDataService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_dictData })
+  async create(@Body() data: CDTO_dictData) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_dictData(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_dictData })
+  async query(@Query() filter: QDTO_dictData, @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_dictData(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_dictData })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_dictData(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_dictData })
+  async update(@Param('id') id: string, @Body() body: UDTO_dictData) {
+    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.');
+  }
+}

+ 68 - 0
src/controller/system/dictType.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { DictTypeService } from '../../service/system/dictType.service';
+import { CDTO_dictType, CVO_dictType, FVO_dictType, QDTO_dictType, QVO_dictType, UDTO_dictType, UVAO_dictType } from '../../interface/system/dictType.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['字典类型表'])
+@Controller('/dictType')
+export class DictTypeController extends BaseController {
+  @Inject()
+  service: DictTypeService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_dictType })
+  async create(@Body() data: CDTO_dictType) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_dictType(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_dictType })
+  async query(@Query() filter: QDTO_dictType, @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_dictType(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_dictType })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_dictType(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_dictType })
+  async update(@Param('id') id: string, @Body() body: UDTO_dictType) {
+    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.');
+  }
+}

+ 21 - 0
src/controller/system/init.controller.ts

@@ -0,0 +1,21 @@
+import { Controller, Inject, Post } from '@midwayjs/decorator';
+import { Context } from '@midwayjs/koa';
+import { InitService } from '../../service/system/init.service';
+@Controller('/init')
+export class InitController {
+  @Inject()
+  ctx: Context;
+
+  @Inject()
+  service: InitService;
+
+  @Post('/')
+  async index() {
+    const result = await this.service.adminUser();
+    if (!result) return 'ok';
+    // 未初始化,则执行初始化程序
+    await this.service.initRole()
+    await this.service.initMenus()
+    await this.service.initRoleMenu(result)
+  }
+}

+ 62 - 0
src/controller/system/menus.controller.ts

@@ -0,0 +1,62 @@
+import { Body, Controller, Del, Get, Inject, Param, Post } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { MenusService } from '../../service/system/menus.service';
+import { CDTO_menus, CVO_menus, FVO_menus, QVO_menus, UDTO_menus, UVAO_menus } from '../../interface/system/menus.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['菜单表'])
+@Controller('/menus')
+export class MenusController extends BaseController {
+  @Inject()
+  service: MenusService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_menus })
+  async create(@Body() data: CDTO_menus) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_menus(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_menus })
+  async query() {
+    const list = await this.service.queryMenu();
+    return list;
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_menus })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_menus(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_menus })
+  async update(@Param('id') id: string, @Body() body: UDTO_menus) {
+    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.');
+  }
+}

+ 93 - 0
src/controller/system/role.controller.ts

@@ -0,0 +1,93 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController, FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+import { RoleService } from '../../service/system/role.service';
+import { CDTO_role, CVO_role, FVO_role, QDTO_role, QVO_role, UDTO_role, UVAO_role } from '../../interface/system/role.interface';
+import { ApiResponse, ApiTags, ApiQuery, ApiOperation } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import get = require('lodash/get');
+import { verifyToken } from '../../decorator/verifyToken.decorator';
+import { MenusService } from '../../service/system/menus.service';
+@ApiTags(['角色表'])
+@Controller('/role')
+export class RoleController extends BaseController {
+  @Inject()
+  service: RoleService;
+
+  @Inject()
+  menusService: MenusService;
+
+  // @Get('/um')
+  // @verifyToken()
+  // @ApiOperation({ description: '获取用户的菜单' })
+  // async userMenu() {
+  //   const user = this.ctx.user;
+  //   if (!user) throw new ServiceError('用户未登录', FrameworkErrorEnum.NOT_LOGIN);
+  //   const roleInfo = await this.service.findOne({
+  //     code: get(user, 'role'),
+  //     is_use: '0',
+  //   });
+  //   const menus = await this.service.getMenuByRoles(get(roleInfo, 'menu', []));
+  //   return menus;
+  // }
+
+  @Post('/')
+  @verifyToken()
+  @Validate()
+  @ApiResponse({ type: CVO_role })
+  async create(@Body() data: CDTO_role) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_role(dbData);
+    return result;
+  }
+  @Get('/')
+  @verifyToken()
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_role })
+  async query(@Query() filter: QDTO_role, @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_role(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @verifyToken()
+  @ApiResponse({ type: FVO_role })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_role(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @verifyToken()
+  @Validate()
+  @ApiResponse({ type: UVAO_role })
+  async update(@Param('id') id: string, @Body() body: UDTO_role) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @verifyToken()
+  @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.');
+  }
+}

+ 81 - 0
src/controller/user/admin.controller.ts

@@ -0,0 +1,81 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController, FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+import { AdminService } from '../../service/user/admin.service';
+import { CDTO_admin, CVO_admin, FVO_admin, QDTO_admin, QVO_admin, UDTO_admin, UVAO_admin } from '../../interface/user/admin.interface';
+import { ApiResponse, ApiTags, ApiQuery, ApiOperation } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+import { Context } from '@midwayjs/koa';
+import get = require('lodash/get');
+@ApiTags(['管理员表'])
+@Controller('/admin')
+export class AdminController extends BaseController {
+  @Inject()
+  service: AdminService;
+  @Inject()
+  ctx: Context;
+  @Post('/initSuper')
+  @ApiOperation({ summary: '初始化超级管理员' })
+  async initSuper() {
+    const dbCode = get(this.ctx, 'request.headers.dbcode');
+    if (!dbCode) throw new ServiceError(FrameworkErrorEnum.BAD_PARAMS, '缺少参数,无法使用初始化管理员');
+    if (dbCode !== 'zdlyjszy') throw new ServiceError(FrameworkErrorEnum.BAD_PARAMS, '缺少标识,无法使用初始化管理员');
+    await this.service.initSuper();
+    return 'ok';
+  }
+  @Post('/')
+  @Validate()
+  @ApiOperation({ summary: '创建' })
+  @ApiResponse({ type: CVO_admin })
+  async create(@Body() data: CDTO_admin) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_admin(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_admin })
+  async query(@Query() filter: QDTO_admin, @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_admin(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_admin })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_admin(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_admin })
+  async update(@Param('id') id: string, @Body() body: UDTO_admin) {
+    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/user/login.controller.ts

@@ -0,0 +1,89 @@
+import { Body, Config, Controller, Inject, Param, Post, Get } from '@midwayjs/core';
+import { ApiTags } from '@midwayjs/swagger';
+import { LoginDTO, LoginType, LoginVO, UPwdDTO } from '../../interface/user/login.interface';
+import { LoginService } from '../../service/user/login.service';
+import { JwtService } from '@midwayjs/jwt';
+import { Context } from '@midwayjs/koa';
+const assert = require('assert');
+import get = require('lodash/get');
+import { UtilService } from '../../service/util.service';
+// import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+
+@ApiTags(['登录服务'])
+@Controller('/login')
+export class LoginController {
+  @Inject()
+  loginService: LoginService;
+  @Inject()
+  jwtService: JwtService;
+  @Inject()
+  utilService: UtilService;
+  @Config('jwt.secret')
+  jwtSecret;
+  @Config('jwt.expiresIn')
+  jwtExpiresIn;
+  @Inject()
+  ctx: Context;
+  /**
+   * 账密登录
+   * @param data 用户名和密码
+   * @param type 用户类型
+   */
+  @Post('/:type')
+  async toLogin(@Body() data: LoginDTO, @Param('type') type: string) {
+    const user = await this.loginService.loginByAccount(data, LoginType[type]);
+    if (user) user.role = type;
+    let vo = new LoginVO(user);
+    vo = JSON.parse(JSON.stringify(vo));
+    const token = await this.jwtService.sign(vo, this.jwtSecret, {
+      expiresIn: this.jwtExpiresIn,
+    });
+    return token;
+  }
+
+  /**
+   * TODO:微信小程序登录
+   * @param openid 微信小程序openid
+   */
+  // @Post('/wxapp/:openid')
+  // async wxAppLogin(@Param('openid') openid: string) {
+  //   if (!openid) throw new ServiceError('缺少微信凭证!', FrameworkErrorEnum.BAD_PARAMS);
+  //   const user = await this.loginService.wxAppLogin(openid);
+  //   let vo = new LoginVO(user);
+  //   vo = JSON.parse(JSON.stringify(vo));
+  //   const token = await this.jwtService.sign(vo, this.jwtSecret, {
+  //     expiresIn: this.jwtExpiresIn,
+  //   });
+  //   return token;
+  // }
+  /**
+   * 修改密码
+   * @param data 修改密码所需数据
+   * @param type 账户类型
+   */
+  @Post('/updatePwd/:type')
+  async updatePwd(@Body() data: UPwdDTO, @Param('type') type: string) {
+    // 随机密码
+    data.password = this.utilService.randomStr();
+    await this.loginService.updatePwd(data, LoginType[type]);
+    return 'ok';
+  }
+
+  @Post('/resetPwd/:type')
+  async resetPwd(@Body('_id') _id: string, @Param('type') type: string) {
+    // 随机密码
+    const data = new UPwdDTO();
+    data._id = _id;
+    data.password = this.utilService.randomStr();
+    await this.loginService.updatePwd(data, LoginType[type]);
+    return data.password;
+  }
+
+  @Get('/analysis')
+  async analysisToken() {
+    const token = get(this.ctx, 'request.header.token');
+    assert(token, '缺少token信息');
+    const result = await this.jwtService.decodeSync(token);
+    return result;
+  }
+}

+ 70 - 0
src/controller/user/research.controller.ts

@@ -0,0 +1,70 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { ResearchService } from '../../service/user/research.service';
+import { CDTO_research, CVO_research, FVO_research, QDTO_research, QVO_research, UDTO_research, UVAO_research } from '../../interface/user/research.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['科研单位表'])
+@Controller('/research')
+export class ResearchController extends BaseController {
+  @Inject()
+  service: ResearchService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_research })
+  async create(@Body() data: CDTO_research) {
+    await this.service.checkIsExist(data);
+    const dbData = await this.service.create(data);
+    const result = new CVO_research(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_research })
+  async query(@Query() filter: QDTO_research, @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_research(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_research })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_research(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_research })
+  async update(@Param('id') id: string, @Body() body: UDTO_research) {
+    await this.service.checkIsExist(body);
+    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.');
+  }
+}

+ 70 - 0
src/controller/user/selfUser.controller.ts

@@ -0,0 +1,70 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { SelfUserService } from '../../service/user/selfUser.service';
+import { CDTO_selfUser, CVO_selfUser, FVO_selfUser, QDTO_selfUser, QVO_selfUser, UDTO_selfUser, UVAO_selfUser } from '../../interface/user/selfUser.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['个人用户表'])
+@Controller('/selfUser')
+export class SelfUserController extends BaseController {
+  @Inject()
+  service: SelfUserService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_selfUser })
+  async create(@Body() data: CDTO_selfUser) {
+    await this.service.checkIsExist(data);
+    const dbData = await this.service.create(data);
+    const result = new CVO_selfUser(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_selfUser })
+  async query(@Query() filter: QDTO_selfUser, @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_selfUser(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_selfUser })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_selfUser(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_selfUser })
+  async update(@Param('id') id: string, @Body() body: UDTO_selfUser) {
+    await this.service.checkIsExist(body);
+    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.');
+  }
+}

+ 41 - 0
src/controller/user/token.controller.ts

@@ -0,0 +1,41 @@
+import { Controller, Get, Inject } from '@midwayjs/decorator';
+import { Context } from '@midwayjs/koa';
+import { ApiResponse, ApiTags } from '@midwayjs/swagger';
+// import { TokenService } from '../service/token.service';
+const assert = require('assert');
+import { JwtService } from '@midwayjs/jwt';
+import get = require('lodash/get');
+import { RoleService } from '../../service/system/role.service';
+@ApiTags(['工具'])
+@Controller('/token')
+export class TokenController {
+  // @Inject()
+  // service: TokenService;
+
+  @Inject()
+  jwtService: JwtService;
+
+  @Inject()
+  roleService: RoleService;
+
+  @Inject()
+  ctx: Context;
+
+  @Get('/tokenView')
+  @ApiResponse({})
+  async tokenView() {
+    const token = get(this.ctx, 'request.header.token');
+    assert(token, '缺少token信息');
+    const result: any = await this.jwtService.decode(token);
+    const menus = await this.roleService.getUserMenus();
+    result.menus = menus;
+    return result;
+  }
+
+  // @Get('/app')
+  // async appLogin(fiiter) {
+  //   const { config, js_code } = fiiter.query;
+  //   const result: any = await this.service.appLogin(config, js_code);
+  //   return result;
+  // }
+}

+ 70 - 0
src/controller/user/unit.controller.ts

@@ -0,0 +1,70 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { UnitService } from '../../service/user/unit.service';
+import { CDTO_unit, CVO_unit, FVO_unit, QDTO_unit, QVO_unit, UDTO_unit, UVAO_unit } from '../../interface/user/unit.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['企业用户表'])
+@Controller('/unit')
+export class UnitController extends BaseController {
+  @Inject()
+  service: UnitService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_unit })
+  async create(@Body() data: CDTO_unit) {
+    await this.service.checkIsExist(data);
+    const dbData = await this.service.create(data);
+    const result = new CVO_unit(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_unit })
+  async query(@Query() filter: QDTO_unit, @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_unit(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_unit })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_unit(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_unit })
+  async update(@Param('id') id: string, @Body() body: UDTO_unit) {
+    await this.service.checkIsExist(body);
+    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.');
+  }
+}

+ 37 - 0
src/decorator/verifyToken.decorator.ts

@@ -0,0 +1,37 @@
+import {
+  JoinPoint,
+  MidwayDecoratorService,
+  REQUEST_OBJ_CTX_KEY,
+  createCustomMethodDecorator,
+} from '@midwayjs/core';
+import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+export const VERIFYTOKEN_KEY = 'decorator:verify_token';
+/**
+ *
+ * 只检测是否有token,此装饰器不做具体用token处理什么.
+ */
+export function verifyToken() {
+  return createCustomMethodDecorator(VERIFYTOKEN_KEY, {});
+}
+/**
+ * 验证token装饰器实现
+ * @param decoratorService 装饰器服务
+ */
+export function VerifyTokenInit(decoratorService: MidwayDecoratorService) {
+  decoratorService.registerMethodHandler(VERIFYTOKEN_KEY, options => {
+    return {
+      around: async (joinPoint: JoinPoint) => {
+        const instance = joinPoint.target;
+        const ctx = instance[REQUEST_OBJ_CTX_KEY];
+        const user = ctx.user;
+        if (!user)
+          throw new ServiceError(
+            '未检测到登录信息,无法访问接口!',
+            FrameworkErrorEnum.NOT_LOGIN
+          );
+        const result = await joinPoint.proceed(...joinPoint.args);
+        return result;
+      },
+    };
+  });
+}

+ 35 - 0
src/entity/core/achieve.entity.ts

@@ -0,0 +1,35 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'achieve' },
+})
+export class Achieve extends BaseModel {
+  @prop({ required: false, index: true, zh: '所属人' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '成果名称' })
+  name: string;
+  @prop({ required: false, index: false, zh: '行业分类', remark: '字典' })
+  industry: string;
+  @prop({ required: false, index: false, zh: '成果属性', remark: '字典' })
+  attr: string;
+  @prop({ required: false, index: false, zh: '出让方式', remark: '字典' })
+  way: string;
+  @prop({ required: false, index: false, zh: '成熟度', remark: '字典' })
+  maturity: string;
+  @prop({ required: false, index: false, zh: '技术分类', remark: '字典' })
+  tech: string;
+  @prop({ required: false, index: false, zh: '成果地区', remark: '字典' })
+  area: string;
+  @prop({ required: false, index: false, zh: '发布时间' })
+  time: string;
+  @prop({ required: false, index: false, zh: '交易金额' })
+  money: string;
+  @prop({ required: false, index: false, zh: '公开信息', remark: '字段:对应显示方式' })
+  public_info: object;
+  @prop({ required: false, index: false, zh: '附件' })
+  files: Array<any>;
+  @prop({ required: false, index: false, zh: '成果描述' })
+  desc: string;
+  @prop({ required: false, index: false, zh: '状态', remark: '字典', default: '0' })
+  status: string;
+}

+ 27 - 0
src/entity/core/demand.entity.ts

@@ -0,0 +1,27 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'demand' },
+})
+export class Demand extends BaseModel {
+  @prop({ required: false, index: true, zh: '所属人', remark: '个人/企业' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '需求标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '需求领域', remark: '字典' })
+  industry_sector: string;
+  @prop({ required: false, index: false, zh: '需求紧急度', remark: '字典' })
+  urgency: string;
+  @prop({ required: false, index: false, zh: '合作方式', remark: '字典' })
+  way: string;
+  @prop({ required: false, index: false, zh: '需求开始时间', remark: '' })
+  start_time: string;
+  @prop({ required: false, index: false, zh: '需求结束时间' })
+  end_time: string;
+  @prop({ required: false, index: false, zh: '地区', remark: '字典' })
+  area: string;
+  @prop({ required: false, index: false, zh: '需求详情' })
+  desc: string;
+  @prop({ required: false, index: true, zh: '需求状态', default: '0' })
+  status: string;
+}

+ 25 - 0
src/entity/core/service.entity.ts

@@ -0,0 +1,25 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'service' },
+})
+export class Service extends BaseModel {
+  @prop({ required: false, index: true, zh: '服务提供人' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '服务标题' })
+  title: string;
+  @prop({ required: false, index: true, zh: '服务类型', remark: '字典' })
+  type: string;
+  @prop({ required: false, index: false, zh: '标签' })
+  tags: Array<any>;
+  @prop({ required: false, index: false, zh: '服务方式', remark: '字典' })
+  way: string;
+  @prop({ required: false, index: false, zh: '服务地区', remark: '字典' })
+  area: string;
+  @prop({ required: false, index: false, zh: '价格' })
+  money: string;
+  @prop({ required: false, index: false, zh: '描述' })
+  desc: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0', remark: '字典' })
+  status: string;
+}

+ 25 - 0
src/entity/core/trade/auction.entity.ts

@@ -0,0 +1,25 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'auction' },
+})
+export class Auction extends BaseModel {
+  @prop({ required: false, index: true, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: true, zh: '服务机构' })
+  org: string;
+  @prop({ required: false, index: false, zh: '项目编号' })
+  code: string;
+  @prop({ required: false, index: false, zh: '开始时间' })
+  start_time: string;
+  @prop({ required: false, index: false, zh: '结束时间' })
+  end_time: string;
+  @prop({ required: false, index: false, zh: '公告说明' })
+  desc: string;
+  @prop({ required: false, index: false, zh: '挂牌交易(自选成果形成)' })
+  listing: Array<any>;
+  @prop({ required: false, index: false, zh: '公告备注' })
+  remark: string;
+  @prop({ required: false, index: true, zh: '状态', remark: '字典', default: '0' })
+  status: string;
+}

+ 27 - 0
src/entity/core/trade/listing.entity.ts

@@ -0,0 +1,27 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'listing' },
+})
+export class Listing extends BaseModel {
+  @prop({ required: false, index: true, zh: '申请人' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '公告标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '服务机构' })
+  org: string;
+  @prop({ required: false, index: false, zh: '项目编号' })
+  code: string;
+  @prop({ required: false, index: false, zh: '公告开始时间' })
+  start_time: string;
+  @prop({ required: false, index: false, zh: '公告结束时间' })
+  end_time: string;
+  @prop({ required: false, index: false, zh: '关联成果', ref: 'Achieve', remark: '挂牌只有1个' })
+  achieve: string;
+  @prop({ required: false, index: false, zh: '挂牌价' })
+  money: string;
+  @prop({ required: false, index: false, zh: '公告备注' })
+  remark: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 29 - 0
src/entity/core/trade/negotiate.entity.ts

@@ -0,0 +1,29 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'negotiate' },
+})
+export class Negotiate extends BaseModel {
+  @prop({ required: false, index: true, zh: '所属人' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '专利号' })
+  no: string;
+  @prop({ required: false, index: false, zh: '联系邮箱' })
+  email: string;
+  @prop({ required: false, index: false, zh: '受让方是否是成果完成人或者其利害关系人', remark: '字典', default: '0' })
+  has_connect: string;
+  @prop({ required: false, index: false, zh: '出让方式', remark: '字典' })
+  way: string;
+  @prop({ required: false, index: false, zh: '公示备注' })
+  public_remark: string;
+  @prop({ required: false, index: true, zh: '交易成果', remark: '只有一个', ref: 'Achieve' })
+  achieve: string;
+  @prop({ required: false, index: false, zh: '拟定价格' })
+  money: string;
+  @prop({ required: false, index: false, zh: '公告开始时间' })
+  start_time: string;
+  @prop({ required: false, index: false, zh: '公告结束时间' })
+  end_time: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 15 - 0
src/entity/service/linkItem.entity.ts

@@ -0,0 +1,15 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'linkItem' },
+})
+export class LinkItem extends BaseModel {
+  @prop({ required: false, index: false, zh: '事项名称' })
+  title: string;
+  @prop({ required: false, index: false, zh: '图标' })
+  icon: Array<any>;
+  @prop({ required: false, index: false, zh: '跳转至', remark: '非路由 就写 全地址' })
+  to: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 17 - 0
src/entity/service/notice.entity.ts

@@ -0,0 +1,17 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'notice' },
+})
+export class Notice extends BaseModel {
+  @prop({ required: false, index: true, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '内容' })
+  content: string;
+  @prop({ required: false, index: false, zh: '发布时间' })
+  time: string;
+  @prop({ required: false, index: false, zh: '来源' })
+  source: string;
+  @prop({ required: false, index: false, zh: '状态', default: '0' })
+  status: string;
+}

+ 21 - 0
src/entity/service/policy.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'policy' },
+})
+export class Policy extends BaseModel {
+  @prop({ required: false, index: true, zh: '发布人' })
+  owner: string;
+  @prop({ required: false, index: false, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '内容' })
+  content: string;
+  @prop({ required: false, index: false, zh: '发布时间', remark: '默认当前时间' })
+  time: string;
+  @prop({ required: false, index: false, zh: '标题图片' })
+  files: Array<any>;
+  @prop({ required: false, index: false, zh: '来源' })
+  source: string;
+  @prop({ required: false, index: false, zh: '状态', default: '0' })
+  status: string;
+}

+ 21 - 0
src/entity/service/trends.entity.ts

@@ -0,0 +1,21 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'trends' },
+})
+export class Trends extends BaseModel {
+  @prop({ required: false, index: true, zh: '发布人' })
+  owner: string;
+  @prop({ required: false, index: true, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '内容' })
+  content: string;
+  @prop({ required: false, index: false, zh: '发布时间' })
+  time: string;
+  @prop({ required: false, index: false, zh: '标题图片' })
+  files: Array<any>;
+  @prop({ required: false, index: false, zh: '来源' })
+  source: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 17 - 0
src/entity/service/video.entity.ts

@@ -0,0 +1,17 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'video' },
+})
+export class Video extends BaseModel {
+  @prop({ required: false, index: true, zh: '发布人' })
+  owner: string;
+  @prop({ required: false, index: false, zh: '标题' })
+  title: string;
+  @prop({ required: false, index: false, zh: '发布时间' })
+  time: string;
+  @prop({ required: false, index: false, zh: '发布内容' })
+  files: Array<any>;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 17 - 0
src/entity/system/dictData.entity.ts

@@ -0,0 +1,17 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'dictData' },
+})
+export class DictData extends BaseModel {
+  @prop({ required: false, index: true, zh: '字典类型编码' })
+  code: string;
+  @prop({ required: false, index: false, zh: '数据显示值' })
+  label: string;
+  @prop({ required: false, index: false, zh: '数据选择值' })
+  value: string;
+  @prop({ required: false, index: false, zh: '排序' })
+  sort: number;
+  @prop({ required: false, index: true, zh: '是否使用', default: '0' })
+  is_use: string;
+}

+ 15 - 0
src/entity/system/dictType.entity.ts

@@ -0,0 +1,15 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'dictType' },
+})
+export class DictType extends BaseModel {
+  @prop({ required: false, index: false, zh: '字典名称' })
+  title: string;
+  @prop({ required: false, index: true, zh: '编码' })
+  code: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+  @prop({ required: false, index: true, zh: '是否使用' })
+  is_use: string;
+}

+ 25 - 0
src/entity/system/menus.entity.ts

@@ -0,0 +1,25 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'menus' },
+})
+export class Menus extends BaseModel {
+  @prop({ required: false, index: false, zh: '菜单名称' })
+  name: string;
+  @prop({ required: false, index: true, zh: '父级菜单' })
+  parent_id: string;
+  @prop({ required: false, index: false, zh: '显示顺序' })
+  order_num: number;
+  @prop({ required: false, index: false, zh: '路由地址' })
+  path: string;
+  @prop({ required: false, index: false, zh: '组件地址' })
+  component: string;
+  @prop({ required: false, index: true, zh: '菜单类型' })
+  type: string;
+  @prop({ required: false, index: false, zh: '图标' })
+  icon: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+  @prop({ required: false, index: true, zh: '是否启用', default: '0' })
+  is_use: string;
+}

+ 17 - 0
src/entity/system/role.entity.ts

@@ -0,0 +1,17 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'role' },
+})
+export class Role extends BaseModel {
+  @prop({ required: false, index: false, zh: '角色名称' })
+  name: string;
+  @prop({ required: false, index: true, zh: '角色编码' })
+  code: string;
+  @prop({ required: false, index: false, zh: '菜单' })
+  menu: object;
+  @prop({ required: false, index: false, zh: '简介' })
+  brief: string;
+  @prop({ required: false, index: true, zh: '是否使用', default: '0' })
+  is_use: string;
+}

+ 31 - 0
src/entity/user/admin.entity.ts

@@ -0,0 +1,31 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+import { isString } from 'lodash';
+@modelOptions({
+  schemaOptions: { collection: 'admin' },
+})
+export class Admin extends BaseModel {
+  @prop({ required: true, index: true, zh: '账号' })
+  account: string;
+  @prop({ required: false, index: false, zh: '名称' })
+  nick_name: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: object;
+  @prop({ required: false, index: false, zh: '是否是超级管理员', default: '1' })
+  is_super: string;
+  @prop({ required: false, index: false, zh: '菜单' })
+  menus: Array<any>;
+  @prop({ required: false, index: false, zh: '是否启用', default: '0' })
+  is_use: string;
+}

+ 41 - 0
src/entity/user/research.entity.ts

@@ -0,0 +1,41 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+import { isString } from 'lodash';
+@modelOptions({
+  schemaOptions: { collection: 'research' },
+})
+export class Research extends BaseModel {
+  @prop({ required: false, index: true, zh: '账户' })
+  account: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: object;
+  @prop({ required: false, index: false, zh: '科研单位名称' })
+  unit_name: string;
+  @prop({ required: false, index: false, zh: '科研领域' })
+  fields: Array<any>;
+  @prop({ required: false, index: false, zh: '简介' })
+  brief: string;
+  @prop({ required: false, index: false, zh: '单位人数' })
+  worker_num: string;
+  @prop({ required: false, index: false, zh: '联系人' })
+  contact: string;
+  @prop({ required: false, index: false, zh: '联系人电话' })
+  tel: string;
+  @prop({ required: false, index: false, zh: '单位相册' })
+  files: Array<any>;
+  @prop({ required: false, index: false, zh: '联系邮箱' })
+  email: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 35 - 0
src/entity/user/selfUser.entity.ts

@@ -0,0 +1,35 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+import { isString } from 'lodash';
+@modelOptions({
+  schemaOptions: { collection: 'selfUser' },
+})
+export class SelfUser extends BaseModel {
+  @prop({ required: false, index: true, zh: '账户' })
+  account: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: object;
+  @prop({ required: false, index: false, zh: '用户名' })
+  nick_name: string;
+  @prop({ required: false, index: false, zh: '工作单位' })
+  unit: string;
+  @prop({ required: false, index: false, zh: '联系电话' })
+  tel: string;
+  @prop({ required: false, index: true, zh: '身份证号' })
+  id_card: string;
+  @prop({ required: false, index: false, zh: '联系邮箱' })
+  email: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: string;
+}

+ 41 - 0
src/entity/user/unit.entity.ts

@@ -0,0 +1,41 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+import { isString } from 'lodash';
+@modelOptions({
+  schemaOptions: { collection: 'unit' },
+})
+export class Unit extends BaseModel {
+  @prop({ required: false, index: true, zh: '账户' })
+  account: string;
+  @prop({
+    required: false,
+    index: false,
+    zh: '密码',
+    select: false,
+    set: (val: string | object) => {
+      if (isString(val)) {
+        return { secret: val };
+      }
+      return val;
+    },
+  })
+  password: object;
+  @prop({ required: false, index: false, zh: '企业名称' })
+  unit_name: string;
+  @prop({ required: false, index: true, zh: '统一社会信用代码' })
+  unit_code: string;
+  @prop({ required: false, index: false, zh: '法人' })
+  legal_person: string;
+  @prop({ required: false, index: false, zh: '法人身份证号' })
+  legal_card: string;
+  @prop({ required: false, index: false, zh: '法人联系电话' })
+  legal_tel: string;
+  @prop({ required: false, index: false, zh: '联系邮箱' })
+  email: string;
+  @prop({ required: false, index: false, zh: '营业执照' })
+  files: Array<any>;
+  @prop({ required: false, index: false, zh: '简介' })
+  brief: string;
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
+  status: 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;
+}

+ 130 - 0
src/interface/core/achieve.interface.ts

@@ -0,0 +1,130 @@
+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_achieve {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '成果名称' })
+  'name': string = undefined;
+  @ApiProperty({ description: '行业分类' })
+  'industry': string = undefined;
+  @ApiProperty({ description: '成果属性' })
+  'attr': string = undefined;
+  @ApiProperty({ description: '出让方式' })
+  'way': string = undefined;
+  @ApiProperty({ description: '成熟度' })
+  'maturity': string = undefined;
+  @ApiProperty({ description: '技术分类' })
+  'tech': string = undefined;
+  @ApiProperty({ description: '成果地区' })
+  'area': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  'time': string = undefined;
+  @ApiProperty({ description: '交易金额' })
+  'money': string = undefined;
+  @ApiProperty({ description: '公开信息' })
+  'public_info': object = undefined;
+  @ApiProperty({ description: '附件' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '成果描述' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_achieve extends SearchBase {
+  constructor() {
+    const like_prop = ['name'];
+    const props = ['owner', 'name', 'industry', 'attr', 'way', 'maturity', 'tech', 'area', 'money', 'status', 'industry[]'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '成果名称' })
+  'name': string = undefined;
+}
+
+export class QVO_achieve extends FVO_achieve {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_achieve {
+  @ApiProperty({ description: '所属人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '成果名称' })
+  @Rule(RuleType['string']().empty(''))
+  'name': string = undefined;
+  @ApiProperty({ description: '行业分类' })
+  @Rule(RuleType['string']().empty(''))
+  'industry': string = undefined;
+  @ApiProperty({ description: '成果属性' })
+  @Rule(RuleType['string']().empty(''))
+  'attr': string = undefined;
+  @ApiProperty({ description: '出让方式' })
+  @Rule(RuleType['string']().empty(''))
+  'way': string = undefined;
+  @ApiProperty({ description: '成熟度' })
+  @Rule(RuleType['string']().empty(''))
+  'maturity': string = undefined;
+  @ApiProperty({ description: '技术分类' })
+  @Rule(RuleType['string']().empty(''))
+  'tech': string = undefined;
+  @ApiProperty({ description: '成果地区' })
+  @Rule(RuleType['string']().empty(''))
+  'area': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  @Rule(RuleType['string']().empty(''))
+  'time': string = undefined;
+  @ApiProperty({ description: '交易金额' })
+  @Rule(RuleType['string']().empty(''))
+  'money': string = undefined;
+  @ApiProperty({ description: '公开信息' })
+  @Rule(RuleType['object']().empty(''))
+  'public_info': object = undefined;
+  @ApiProperty({ description: '附件' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '成果描述' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_achieve extends FVO_achieve {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_achieve extends CDTO_achieve {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_achieve extends FVO_achieve {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 112 - 0
src/interface/core/demand.interface.ts

@@ -0,0 +1,112 @@
+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_demand {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '需求标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '行业领域' })
+  'industry_sector': string = undefined;
+  @ApiProperty({ description: '需求紧急度' })
+  'urgency': string = undefined;
+  @ApiProperty({ description: '合作方式' })
+  'way': string = undefined;
+  @ApiProperty({ description: '需求开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '需求结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '地区' })
+  'area': string = undefined;
+  @ApiProperty({ description: '需求详情' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_demand extends SearchBase {
+  constructor() {
+    const like_prop = ['title'];
+    const props = ['owner', 'title', 'status', 'industry_sector', 'industry_sector[]', 'urgency', 'urgency[]', 'way', 'way[]', 'start_time@start', 'end_time@end', 'area', 'area[]'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '需求标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_demand extends FVO_demand {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_demand {
+  @ApiProperty({ description: '所属人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '需求标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '行业领域' })
+  @Rule(RuleType['string']().empty(''))
+  'industry_sector': string = undefined;
+  @ApiProperty({ description: '需求紧急度' })
+  @Rule(RuleType['string']().empty(''))
+  'urgency': string = undefined;
+  @ApiProperty({ description: '合作方式' })
+  @Rule(RuleType['string']().empty(''))
+  'way': string = undefined;
+  @ApiProperty({ description: '需求开始时间' })
+  @Rule(RuleType['string']().empty(''))
+  'start_time': string = undefined;
+  @ApiProperty({ description: '需求结束时间' })
+  @Rule(RuleType['string']().empty(''))
+  'end_time': string = undefined;
+  @ApiProperty({ description: '地区' })
+  @Rule(RuleType['string']().empty(''))
+  'area': string = undefined;
+  @ApiProperty({ description: '需求详情' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_demand extends FVO_demand {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_demand extends CDTO_demand {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_demand extends FVO_demand {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 109 - 0
src/interface/core/service.interface.ts

@@ -0,0 +1,109 @@
+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_service {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '服务标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '服务类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '标签' })
+  'tags': Array<any> = undefined;
+  @ApiProperty({ description: '服务方式' })
+  'way': string = undefined;
+  @ApiProperty({ description: '服务地区' })
+  'area': string = undefined;
+  @ApiProperty({ description: '价格' })
+  'money': string = undefined;
+  @ApiProperty({ description: '描述' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_service extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner', 'title', 'type', 'type[]', 'way', 'way[]', 'area', 'area[]', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '服务标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '服务类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_service extends FVO_service {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_service {
+  @ApiProperty({ description: '所属人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '服务标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '服务类型' })
+  @Rule(RuleType['string']().empty(''))
+  'type': string = undefined;
+  @ApiProperty({ description: '标签' })
+  @Rule(RuleType['array']().empty(''))
+  'tags': Array<any> = undefined;
+  @ApiProperty({ description: '服务方式' })
+  @Rule(RuleType['string']().empty(''))
+  'way': string = undefined;
+  @ApiProperty({ description: '服务地区' })
+  @Rule(RuleType['string']().empty(''))
+  'area': string = undefined;
+  @ApiProperty({ description: '价格' })
+  @Rule(RuleType['string']().empty(''))
+  'money': string = undefined;
+  @ApiProperty({ description: '描述' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_service extends FVO_service {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_service extends CDTO_service {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_service extends FVO_service {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 107 - 0
src/interface/core/trade/auction.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_auction {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '服务机构' })
+  'org': string = undefined;
+  @ApiProperty({ description: '项目编号' })
+  'code': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '公告说明' })
+  'desc': string = undefined;
+  @ApiProperty({ description: '挂牌交易' })
+  'listing': Array<any> = undefined;
+  @ApiProperty({ description: '公告备注' })
+  'remark': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_auction extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['title', 'org', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '服务机构' })
+  'org': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_auction extends FVO_auction {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_auction {
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '服务机构' })
+  @Rule(RuleType['string']().empty(''))
+  'org': string = undefined;
+  @ApiProperty({ description: '项目编号' })
+  @Rule(RuleType['string']().empty(''))
+  'code': string = undefined;
+  @ApiProperty({ description: '开始时间' })
+  @Rule(RuleType['string']().empty(''))
+  'start_time': string = undefined;
+  @ApiProperty({ description: '结束时间' })
+  @Rule(RuleType['string']().empty(''))
+  'end_time': string = undefined;
+  @ApiProperty({ description: '公告说明' })
+  @Rule(RuleType['string']().empty(''))
+  'desc': string = undefined;
+  @ApiProperty({ description: '挂牌交易' })
+  @Rule(RuleType['array']().empty(''))
+  'listing': Array<any> = undefined;
+  @ApiProperty({ description: '公告备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_auction extends FVO_auction {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_auction extends CDTO_auction {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_auction extends FVO_auction {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 112 - 0
src/interface/core/trade/listing.interface.ts

@@ -0,0 +1,112 @@
+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_listing {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '申请人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '公告标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '服务机构' })
+  'org': string = undefined;
+  @ApiProperty({ description: '项目编号' })
+  'code': string = undefined;
+  @ApiProperty({ description: '公告开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '公告结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '关联成果' })
+  'achieve': string = undefined;
+  @ApiProperty({ description: '挂牌价' })
+  'money': string = undefined;
+  @ApiProperty({ description: '公告备注' })
+  'remark': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_listing extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner', 'title', 'status', 'status[]'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '申请人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '公告标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_listing extends FVO_listing {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_listing {
+  @ApiProperty({ description: '申请人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '公告标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '服务机构' })
+  @Rule(RuleType['string']().empty(''))
+  'org': string = undefined;
+  @ApiProperty({ description: '项目编号' })
+  @Rule(RuleType['string']().empty(''))
+  'code': string = undefined;
+  @ApiProperty({ description: '公告开始时间' })
+  @Rule(RuleType['string']().empty(''))
+  'start_time': string = undefined;
+  @ApiProperty({ description: '公告结束时间' })
+  @Rule(RuleType['string']().empty(''))
+  'end_time': string = undefined;
+  @ApiProperty({ description: '关联成果' })
+  @Rule(RuleType['string']().empty(''))
+  'achieve': string = undefined;
+  @ApiProperty({ description: '挂牌价' })
+  @Rule(RuleType['string']().empty(''))
+  'money': string = undefined;
+  @ApiProperty({ description: '公告备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_listing extends FVO_listing {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_listing extends CDTO_listing {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_listing extends FVO_listing {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 119 - 0
src/interface/core/trade/negotiate.interface.ts

@@ -0,0 +1,119 @@
+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_negotiate {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '专利号' })
+  'no': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  'email': string = undefined;
+  @ApiProperty({ description: '受让方是否是成果完成人或者其利害关系人' })
+  'has_connect': string = undefined;
+  @ApiProperty({ description: '出让方式' })
+  'way': string = undefined;
+  @ApiProperty({ description: '公示备注' })
+  'public_remark': string = undefined;
+  @ApiProperty({ description: '关联成果' })
+  'achieve': string = undefined;
+  @ApiProperty({ description: '拟定价格' })
+  'money': string = undefined;
+  @ApiProperty({ description: '公告开始时间' })
+  'start_time': string = undefined;
+  @ApiProperty({ description: '公告结束时间' })
+  'end_time': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_negotiate extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner', 'no', 'achieve', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '所属人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '专利号' })
+  'no': string = undefined;
+  @ApiProperty({ description: '关联成果' })
+  'achieve': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_negotiate extends FVO_negotiate {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_negotiate {
+  @ApiProperty({ description: '所属人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '专利号' })
+  @Rule(RuleType['string']().empty(''))
+  'no': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  @Rule(RuleType['string']().empty(''))
+  'email': string = undefined;
+  @ApiProperty({ description: '受让方是否是成果完成人或者其利害关系人' })
+  @Rule(RuleType['string']().empty(''))
+  'has_connect': string = undefined;
+  @ApiProperty({ description: '出让方式' })
+  @Rule(RuleType['string']().empty(''))
+  'way': string = undefined;
+  @ApiProperty({ description: '公示备注' })
+  @Rule(RuleType['string']().empty(''))
+  'public_remark': string = undefined;
+  @ApiProperty({ description: '关联成果' })
+  @Rule(RuleType['string']().empty(''))
+  'achieve': string = undefined;
+  @ApiProperty({ description: '拟定价格' })
+  @Rule(RuleType['string']().empty(''))
+  'money': string = undefined;
+  @ApiProperty({ description: '公告开始时间' })
+  @Rule(RuleType['string']().empty(''))
+  'start_time': string = undefined;
+  @ApiProperty({ description: '公告结束时间' })
+  @Rule(RuleType['string']().empty(''))
+  'end_time': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_negotiate extends FVO_negotiate {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_negotiate extends CDTO_negotiate {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_negotiate extends FVO_negotiate {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 78 - 0
src/interface/service/linkItem.interface.ts

@@ -0,0 +1,78 @@
+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_linkItem {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '事项名称' })
+  'title': string = undefined;
+  @ApiProperty({ description: '图标' })
+  'icon': Array<any> = undefined;
+  @ApiProperty({ description: '跳转至' })
+  'to': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_linkItem extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_linkItem extends FVO_linkItem {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_linkItem {
+  @ApiProperty({ description: '事项名称' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '图标' })
+  @Rule(RuleType['array']().empty(''))
+  'icon': Array<any> = undefined;
+  @ApiProperty({ description: '跳转至' })
+  @Rule(RuleType['string']().empty(''))
+  'to': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_linkItem extends FVO_linkItem {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_linkItem extends CDTO_linkItem {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_linkItem extends FVO_linkItem {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 83 - 0
src/interface/service/notice.interface.ts

@@ -0,0 +1,83 @@
+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_notice {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  'time': string = undefined;
+  @ApiProperty({ description: '来源' })
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_notice extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['title'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+}
+
+export class QVO_notice extends FVO_notice {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_notice {
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  @Rule(RuleType['string']().empty(''))
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  @Rule(RuleType['string']().empty(''))
+  'time': string = undefined;
+  @ApiProperty({ description: '来源' })
+  @Rule(RuleType['string']().empty(''))
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_notice extends FVO_notice {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_notice extends CDTO_notice {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_notice extends FVO_notice {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 93 - 0
src/interface/service/policy.interface.ts

@@ -0,0 +1,93 @@
+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_policy {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  'time': string = undefined;
+  @ApiProperty({ description: '标题图片' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '来源' })
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_policy extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+}
+
+export class QVO_policy extends FVO_policy {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_policy {
+  @ApiProperty({ description: '发布人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  @Rule(RuleType['string']().empty(''))
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  @Rule(RuleType['string']().empty(''))
+  'time': string = undefined;
+  @ApiProperty({ description: '标题图片' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '来源' })
+  @Rule(RuleType['string']().empty(''))
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_policy extends FVO_policy {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_policy extends CDTO_policy {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_policy extends FVO_policy {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 97 - 0
src/interface/service/trends.interface.ts

@@ -0,0 +1,97 @@
+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_trends {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  'time': string = undefined;
+  @ApiProperty({ description: '标题图片' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '来源' })
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_trends extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner', 'title', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_trends extends FVO_trends {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_trends {
+  @ApiProperty({ description: '发布人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '内容' })
+  @Rule(RuleType['string']().empty(''))
+  'content': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  @Rule(RuleType['string']().empty(''))
+  'time': string = undefined;
+  @ApiProperty({ description: '标题图片' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '来源' })
+  @Rule(RuleType['string']().empty(''))
+  'source': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_trends extends FVO_trends {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_trends extends CDTO_trends {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_trends extends FVO_trends {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 85 - 0
src/interface/service/video.interface.ts

@@ -0,0 +1,85 @@
+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_video {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  'title': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  'time': string = undefined;
+  @ApiProperty({ description: '发布内容' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_video extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['owner', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '发布人' })
+  'owner': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_video extends FVO_video {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_video {
+  @ApiProperty({ description: '发布人' })
+  @Rule(RuleType['string']().empty(''))
+  'owner': string = undefined;
+  @ApiProperty({ description: '标题' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '发布时间' })
+  @Rule(RuleType['string']().empty(''))
+  'time': string = undefined;
+  @ApiProperty({ description: '发布内容' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_video extends FVO_video {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_video extends CDTO_video {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_video extends FVO_video {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 85 - 0
src/interface/system/dictData.interface.ts

@@ -0,0 +1,85 @@
+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_dictData {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '字典类型编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '数据显示值' })
+  'label': string = undefined;
+  @ApiProperty({ description: '数据选择值' })
+  'value': string = undefined;
+  @ApiProperty({ description: '排序' })
+  'sort': number = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_dictData extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['code', 'is_use'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '字典类型编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QVO_dictData extends FVO_dictData {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_dictData {
+  @ApiProperty({ description: '字典类型编码' })
+  @Rule(RuleType['string']().empty(''))
+  'code': string = undefined;
+  @ApiProperty({ description: '数据显示值' })
+  @Rule(RuleType['string']().empty(''))
+  'label': string = undefined;
+  @ApiProperty({ description: '数据选择值' })
+  @Rule(RuleType['string']().empty(''))
+  'value': string = undefined;
+  @ApiProperty({ description: '排序' })
+  @Rule(RuleType['number']().empty(''))
+  'sort': number = undefined;
+  @ApiProperty({ description: '是否使用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_dictData extends FVO_dictData {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_dictData extends CDTO_dictData {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_dictData extends FVO_dictData {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 80 - 0
src/interface/system/dictType.interface.ts

@@ -0,0 +1,80 @@
+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_dictType {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '字典类型名称' })
+  'title': string = undefined;
+  @ApiProperty({ description: '编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_dictType extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['code', 'is_use'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QVO_dictType extends FVO_dictType {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_dictType {
+  @ApiProperty({ description: '字典类型名称' })
+  @Rule(RuleType['string']().empty(''))
+  'title': string = undefined;
+  @ApiProperty({ description: '编码' })
+  @Rule(RuleType['string']().empty(''))
+  'code': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_dictType extends FVO_dictType {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_dictType extends CDTO_dictType {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_dictType extends FVO_dictType {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 107 - 0
src/interface/system/menus.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_menus {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '菜单名称' })
+  'name': string = undefined;
+  @ApiProperty({ description: '父级菜单' })
+  'parent_id': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  'order_num': number = undefined;
+  @ApiProperty({ description: '路由地址' })
+  'path': string = undefined;
+  @ApiProperty({ description: '组件地址' })
+  'component': string = undefined;
+  @ApiProperty({ description: '菜单类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '图标' })
+  'icon': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_menus extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['parent_id', 'type', 'is_use'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '父级菜单' })
+  'parent_id': string = undefined;
+  @ApiProperty({ description: '菜单类型' })
+  'type': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  'is_use': string = undefined;
+}
+
+export class QVO_menus extends FVO_menus {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_menus {
+  @ApiProperty({ description: '菜单名称' })
+  @Rule(RuleType['string']().empty(''))
+  'name': string = undefined;
+  @ApiProperty({ description: '父级菜单' })
+  @Rule(RuleType['string']().empty(''))
+  'parent_id': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  @Rule(RuleType['number']().empty(''))
+  'order_num': number = undefined;
+  @ApiProperty({ description: '路由地址' })
+  @Rule(RuleType['string']().empty(''))
+  'path': string = undefined;
+  @ApiProperty({ description: '组件地址' })
+  @Rule(RuleType['string']().empty(''))
+  'component': string = undefined;
+  @ApiProperty({ description: '菜单类型' })
+  @Rule(RuleType['string']().empty(''))
+  'type': string = undefined;
+  @ApiProperty({ description: '图标' })
+  @Rule(RuleType['string']().empty(''))
+  'icon': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+  @ApiProperty({ description: '是否启用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_menus extends FVO_menus {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_menus extends CDTO_menus {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_menus extends FVO_menus {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 85 - 0
src/interface/system/role.interface.ts

@@ -0,0 +1,85 @@
+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_role {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '角色名称' })
+  'name': string = undefined;
+  @ApiProperty({ description: '角色编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '菜单' })
+  'menu': object = undefined;
+  @ApiProperty({ description: '简介' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_role extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['code', 'is_use'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '角色编码' })
+  'code': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  'is_use': string = undefined;
+}
+
+export class QVO_role extends FVO_role {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_role {
+  @ApiProperty({ description: '角色名称' })
+  @Rule(RuleType['string']().empty(''))
+  'name': string = undefined;
+  @ApiProperty({ description: '角色编码' })
+  @Rule(RuleType['string']().empty(''))
+  'code': string = undefined;
+  @ApiProperty({ description: '菜单' })
+  @Rule(RuleType['object']().empty())
+  'menu': object = undefined;
+  @ApiProperty({ description: '简介' })
+  @Rule(RuleType['string']().empty(''))
+  'brief': string = undefined;
+  @ApiProperty({ description: '是否使用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_role extends FVO_role {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_role extends CDTO_role {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_role extends FVO_role {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 91 - 0
src/interface/user/admin.interface.ts

@@ -0,0 +1,91 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { FrameworkErrorEnum, SearchBase, ServiceError } 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_admin {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '账号' })
+  'account': string = undefined;
+  @ApiProperty({ description: '名称' })
+  'nick_name': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '是否是超级管理员' })
+  'is_super': string = undefined;
+  @ApiProperty({ description: '菜单' })
+  'menus': Array<any> = undefined;
+  @ApiProperty({ description: '是否启用' })
+  'is_use': string = undefined;
+}
+
+export class QDTO_admin extends SearchBase {
+  constructor() {
+    const like_prop = ['account'];
+    const props = ['account'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '账号' })
+  'account': string = undefined;
+}
+
+export class QVO_admin extends FVO_admin {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_admin {
+  @ApiProperty({ description: '账号' })
+  @Rule(RuleType['string']().required().error(new ServiceError('缺少账号', FrameworkErrorEnum.NEED_BODY)))
+  'account': string = undefined;
+  @ApiProperty({ description: '名称' })
+  @Rule(RuleType['string']().empty(''))
+  'nick_name': string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+  @ApiProperty({ description: '是否是超级管理员' })
+  @Rule(RuleType['string']().empty(''))
+  'is_super': string = undefined;
+  @ApiProperty({ description: '菜单' })
+  @Rule(RuleType['array']().empty(''))
+  'menus': Array<any> = undefined;
+  @ApiProperty({ description: '是否启用' })
+  @Rule(RuleType['string']().empty(''))
+  'is_use': string = undefined;
+}
+
+export class CVO_admin extends FVO_admin {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_admin extends CDTO_admin {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+  @ApiProperty({ description: '账号' })
+  @Rule(RuleType['string']().empty(''))
+  'account': string = undefined;
+}
+
+export class UVAO_admin extends FVO_admin {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 42 - 0
src/interface/user/login.interface.ts

@@ -0,0 +1,42 @@
+import { ApiProperty } from '@midwayjs/swagger';
+import { Rule, RuleType } from '@midwayjs/validate';
+import { get } from 'lodash';
+export enum LoginType {
+  SelfUser = 'SelfUser',
+  Admin = 'Admin',
+  Unit = 'Unit',
+  Research = 'Research',
+}
+
+export class LoginDTO {
+  @ApiProperty({ description: '账号' })
+  @Rule(RuleType['string']().required())
+  account: string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().required())
+  password: string = undefined;
+}
+
+export class UPwdDTO {
+  @ApiProperty({ description: '用户数据id' })
+  @Rule(RuleType['string']().required())
+  _id: string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().required())
+  password: string = undefined;
+}
+
+export class LoginVO {
+  constructor(data: object) {
+    this._id = get(data, '_id');
+    this.nick_name = get(data, 'nick_name');
+    this.openid = get(data, 'openid');
+    this.role = get(data, 'role');
+    this.is_super = get(data, 'is_super');
+  }
+  _id: string;
+  nick_name: string;
+  openid: string;
+  role: string;
+  is_super: number;
+}

+ 115 - 0
src/interface/user/research.interface.ts

@@ -0,0 +1,115 @@
+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_research {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '科研单位名称' })
+  'unit_name': string = undefined;
+  @ApiProperty({ description: '科研领域' })
+  'fields': Array<any> = undefined;
+  @ApiProperty({ description: '简介' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '单位人数' })
+  'worker_num': string = undefined;
+  @ApiProperty({ description: '联系人' })
+  'contact': string = undefined;
+  @ApiProperty({ description: '联系人电话' })
+  'tel': string = undefined;
+  @ApiProperty({ description: '单位相册' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  'email': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_research extends SearchBase {
+  constructor() {
+    const like_prop = ['account'];
+    const props = ['account', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_research extends FVO_research {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_research {
+  @ApiProperty({ description: '账户' })
+  @Rule(RuleType['string']().empty(''))
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+  @ApiProperty({ description: '科研单位名称' })
+  @Rule(RuleType['string']().empty(''))
+  'unit_name': string = undefined;
+  @ApiProperty({ description: '科研领域' })
+  @Rule(RuleType['array']().empty(''))
+  'fields': Array<any> = undefined;
+  @ApiProperty({ description: '简介' })
+  @Rule(RuleType['string']().empty(''))
+  'brief': string = undefined;
+  @ApiProperty({ description: '单位人数' })
+  @Rule(RuleType['string']().empty(''))
+  'worker_num': string = undefined;
+  @ApiProperty({ description: '联系人' })
+  @Rule(RuleType['string']().empty(''))
+  'contact': string = undefined;
+  @ApiProperty({ description: '联系人电话' })
+  @Rule(RuleType['string']().empty(''))
+  'tel': string = undefined;
+  @ApiProperty({ description: '单位相册' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  @Rule(RuleType['string']().empty(''))
+  'email': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_research extends FVO_research {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_research extends CDTO_research {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_research extends FVO_research {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 102 - 0
src/interface/user/selfUser.interface.ts

@@ -0,0 +1,102 @@
+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_selfUser {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '用户名' })
+  'nick_name': string = undefined;
+  @ApiProperty({ description: '工作单位' })
+  'unit': string = undefined;
+  @ApiProperty({ description: '联系电话' })
+  'tel': string = undefined;
+  @ApiProperty({ description: '身份证号' })
+  'id_card': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  'email': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_selfUser extends SearchBase {
+  constructor() {
+    const like_prop = ['account'];
+    const props = ['account', 'id_card', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '身份证号' })
+  'id_card': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_selfUser extends FVO_selfUser {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_selfUser {
+  @ApiProperty({ description: '账户' })
+  @Rule(RuleType['string']().empty(''))
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+  @ApiProperty({ description: '用户名' })
+  @Rule(RuleType['string']().empty(''))
+  'nick_name': string = undefined;
+  @ApiProperty({ description: '工作单位' })
+  @Rule(RuleType['string']().empty(''))
+  'unit': string = undefined;
+  @ApiProperty({ description: '联系电话' })
+  @Rule(RuleType['string']().empty(''))
+  'tel': string = undefined;
+  @ApiProperty({ description: '身份证号' })
+  @Rule(RuleType['string']().empty(''))
+  'id_card': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  @Rule(RuleType['string']().empty(''))
+  'email': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_selfUser extends FVO_selfUser {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_selfUser extends CDTO_selfUser {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_selfUser extends FVO_selfUser {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 117 - 0
src/interface/user/unit.interface.ts

@@ -0,0 +1,117 @@
+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_unit {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  'password': string = undefined;
+  @ApiProperty({ description: '企业名称' })
+  'unit_name': string = undefined;
+  @ApiProperty({ description: '统一社会信用代码' })
+  'unit_code': string = undefined;
+  @ApiProperty({ description: '法人' })
+  'legal_person': string = undefined;
+  @ApiProperty({ description: '法人联系电话' })
+  'legal_tel': string = undefined;
+  @ApiProperty({ description: '法人身份证号' })
+  'legal_card': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  'email': string = undefined;
+  @ApiProperty({ description: '营业执照' })
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '简介' })
+  'brief': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QDTO_unit extends SearchBase {
+  constructor() {
+    const like_prop = ['account'];
+    const props = ['account', 'unit_code', 'status'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '账户' })
+  'account': string = undefined;
+  @ApiProperty({ description: '统一社会信用代码' })
+  'unit_code': string = undefined;
+  @ApiProperty({ description: '状态' })
+  'status': string = undefined;
+}
+
+export class QVO_unit extends FVO_unit {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_unit {
+  @ApiProperty({ description: '账户' })
+  @Rule(RuleType['string']().empty(''))
+  'account': string = undefined;
+  @ApiProperty({ description: '密码' })
+  @Rule(RuleType['string']().empty(''))
+  'password': string = undefined;
+  @ApiProperty({ description: '企业名称' })
+  @Rule(RuleType['string']().empty(''))
+  'unit_name': string = undefined;
+  @ApiProperty({ description: '统一社会信用代码' })
+  @Rule(RuleType['string']().empty(''))
+  'unit_code': string = undefined;
+  @ApiProperty({ description: '法人' })
+  @Rule(RuleType['string']().empty(''))
+  'legal_person': string = undefined;
+  @ApiProperty({ description: '法人联系电话' })
+  @Rule(RuleType['string']().empty(''))
+  'legal_tel': string = undefined;
+  @ApiProperty({ description: '法人身份证号' })
+  @Rule(RuleType['string']().empty(''))
+  'legal_card': string = undefined;
+  @ApiProperty({ description: '联系邮箱' })
+  @Rule(RuleType['string']().empty(''))
+  'email': string = undefined;
+  @ApiProperty({ description: '营业执照' })
+  @Rule(RuleType['array']().empty(''))
+  'files': Array<any> = undefined;
+  @ApiProperty({ description: '简介' })
+  @Rule(RuleType['string']().empty(''))
+  'brief': string = undefined;
+  @ApiProperty({ description: '状态' })
+  @Rule(RuleType['string']().empty(''))
+  'status': string = undefined;
+}
+
+export class CVO_unit extends FVO_unit {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_unit extends CDTO_unit {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_unit extends FVO_unit {
+  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';
+  }
+}

+ 12 - 0
src/service/core/achieve.service.ts

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

+ 32 - 0
src/service/core/coreUtil.service.ts

@@ -0,0 +1,32 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+import { Demand } from '../../entity/core/demand.entity';
+import { Unit } from '../../entity/user/unit.entity';
+import { SelfUser } from '../../entity/user/selfUser.entity';
+import get = require('lodash/get');
+import { Research } from '../../entity/user/research.entity';
+
+@Provide()
+export class CoreUtilService {
+  @InjectEntityModel(Demand)
+  model: ReturnModelType<typeof Demand>;
+  @InjectEntityModel(Unit)
+  unitModel: ReturnModelType<typeof Unit>;
+  @InjectEntityModel(SelfUser)
+  selfUserModel: ReturnModelType<typeof SelfUser>;
+  @InjectEntityModel(Research)
+  researchModel: ReturnModelType<typeof Research>;
+  async getOwner(ownerId: string) {
+    let data = await this.selfUserModel.findById(ownerId).lean();
+    if (data) return get(data, 'nick_name');
+    else {
+      data = await this.unitModel.findById(ownerId).lean();
+      if (!data) data = await this.researchModel.findById(ownerId).lean();
+      const name = get(data, 'unit_name');
+      if (!name) throw new ServiceError('为找到所属人信息!', FrameworkErrorEnum.NOT_FOUND_DATA);
+      return name;
+    }
+  }
+}

+ 11 - 0
src/service/core/demand.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 { Demand } from '../../entity/core/demand.entity';
+type modelType = ReturnModelType<typeof Demand>;
+@Provide()
+export class DemandService extends BaseService<modelType> {
+  @InjectEntityModel(Demand)
+  model: modelType;
+}

+ 11 - 0
src/service/core/service.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 { Service } from '../../entity/core/service.entity';
+type modelType = ReturnModelType<typeof Service>;
+@Provide()
+export class ServiceService extends BaseService<modelType> {
+  @InjectEntityModel(Service)
+  model: modelType;
+}

+ 11 - 0
src/service/core/trade/auction.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 { Auction } from '../../../entity/core/trade/auction.entity';
+type modelType = ReturnModelType<typeof Auction>;
+@Provide()
+export class AuctionService extends BaseService<modelType> {
+  @InjectEntityModel(Auction)
+  model: modelType;
+}

+ 19 - 0
src/service/core/trade/listing.service.ts

@@ -0,0 +1,19 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { Listing } from '../../../entity/core/trade/listing.entity';
+import { Types } from 'mongoose';
+const ObjectId = Types.ObjectId;
+type modelType = ReturnModelType<typeof Listing>;
+@Provide()
+export class ListingService extends BaseService<modelType> {
+  @InjectEntityModel(Listing)
+  model: modelType;
+
+  async getListByIds(ids: Array<string>) {
+    const nids = ids.map(i => i && new ObjectId(i));
+    const list = await this.model.find({ _id: nids }).populate('achieve').lean();
+    return list;
+  }
+}

+ 11 - 0
src/service/core/trade/negotiate.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 { Negotiate } from '../../../entity/core/trade/negotiate.entity';
+type modelType = ReturnModelType<typeof Negotiate>;
+@Provide()
+export class NegotiateService extends BaseService<modelType> {
+  @InjectEntityModel(Negotiate)
+  model: modelType;
+}

+ 11 - 0
src/service/service/linkItem.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 { LinkItem } from '../../entity/service/linkItem.entity';
+type modelType = ReturnModelType<typeof LinkItem>;
+@Provide()
+export class LinkItemService extends BaseService<modelType> {
+  @InjectEntityModel(LinkItem)
+  model: modelType;
+}

+ 11 - 0
src/service/service/notice.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 { Notice } from '../../entity/service/notice.entity';
+type modelType = ReturnModelType<typeof Notice>;
+@Provide()
+export class NoticeService extends BaseService<modelType> {
+  @InjectEntityModel(Notice)
+  model: modelType;
+}

+ 11 - 0
src/service/service/policy.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 { Policy } from '../../entity/service/policy.entity';
+type modelType = ReturnModelType<typeof Policy>;
+@Provide()
+export class PolicyService extends BaseService<modelType> {
+  @InjectEntityModel(Policy)
+  model: modelType;
+}

+ 11 - 0
src/service/service/trends.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 { Trends } from '../../entity/service/trends.entity';
+type modelType = ReturnModelType<typeof Trends>;
+@Provide()
+export class TrendsService extends BaseService<modelType> {
+  @InjectEntityModel(Trends)
+  model: modelType;
+}

+ 11 - 0
src/service/service/video.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 { Video } from '../../entity/service/video.entity';
+type modelType = ReturnModelType<typeof Video>;
+@Provide()
+export class VideoService extends BaseService<modelType> {
+  @InjectEntityModel(Video)
+  model: modelType;
+}

+ 11 - 0
src/service/system/dictData.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 { DictData } from '../../entity/system/dictData.entity';
+type modelType = ReturnModelType<typeof DictData>;
+@Provide()
+export class DictDataService extends BaseService<modelType> {
+  @InjectEntityModel(DictData)
+  model: modelType;
+}

+ 11 - 0
src/service/system/dictType.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 { DictType } from '../../entity/system/dictType.entity';
+type modelType = ReturnModelType<typeof DictType>;
+@Provide()
+export class DictTypeService extends BaseService<modelType> {
+  @InjectEntityModel(DictType)
+  model: modelType;
+}

+ 54 - 0
src/service/system/init.service.ts

@@ -0,0 +1,54 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { Admin } from '../../entity/user/admin.entity';
+import { Role } from '../../entity/system/role.entity';
+import { Menus } from '../../entity/system/menus.entity';
+
+@Provide()
+export class InitService {
+  @InjectEntityModel(Admin)
+  adminModel: ReturnModelType<typeof Admin>;
+  @InjectEntityModel(Role)
+  roleModel: ReturnModelType<typeof Role>;
+  @InjectEntityModel(Menus)
+  menusModel: ReturnModelType<typeof Menus>;
+
+  async adminUser() {
+    const num = await this.adminModel.count({ is_super: '1' });
+    if (num > 0) return false;
+    const data = {
+      account: 'admin',
+      password: '1qaz2wsx',
+      nick_name: '系统管理员',
+      is_super: '0',
+    };
+    const adminUser = await this.adminModel.create(data);
+    return adminUser;
+  }
+
+  async initRole() {
+    const datas = [
+      { name: '管理员', code: 'admin' },
+      { name: '个人用户', code: 'selfUser' },
+      { name: '企业用户', code: 'unit' },
+      { name: '科研单位', code: 'research' },
+    ];
+    await this.roleModel.insertMany(datas);
+  }
+  async initMenus() {
+    const datas = [
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+      { name: '', order_num: 2, path: '', component: '', type: '' },
+    ];
+  }
+  async initRoleMenu(admin: Admin) {}
+
+  async initDict(){
+    
+  }
+}

+ 38 - 0
src/service/system/menus.service.ts

@@ -0,0 +1,38 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { Menus } from '../../entity/system/menus.entity';
+import orderBy = require('lodash/orderBy');
+import { Types } from 'mongoose';
+const ObjectId = Types.ObjectId;
+type modelType = ReturnModelType<typeof Menus>;
+@Provide()
+export class MenusService extends BaseService<modelType> {
+  @InjectEntityModel(Menus)
+  model: modelType;
+
+  async queryMenu(): Promise<Array<object>> {
+    const data = await this.model.find({}, { meta: 0, __v: 0 }).sort({ order_num: 1 }).lean();
+    let treeMenu = data.filter(f => !f.parent_id);
+    treeMenu = this.treeMenu(data, treeMenu);
+    return treeMenu;
+  }
+
+  treeMenu(allMenus, nowMenu) {
+    for (const nm of nowMenu) {
+      const { _id, parent_id } = nm;
+      // 查下下级其是否有目录
+      let children = allMenus.filter(f => new ObjectId(f.parent_id).equals(_id));
+      children = this.treeMenu(allMenus, children);
+      if (children.length > 0) nm.children = children;
+      // 换父级组件的名称
+      if (parent_id) {
+        const r = allMenus.find(f => new ObjectId(f._id).equals(parent_id));
+        if (r) nm.parent_name = r.name;
+      }
+    }
+    nowMenu = orderBy(nowMenu, ['order_num'], ['asc']);
+    return nowMenu;
+  }
+}

+ 64 - 0
src/service/system/role.service.ts

@@ -0,0 +1,64 @@
+import { Inject, Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService, FrameworkErrorEnum, ServiceError } from 'free-midway-component';
+import { Role } from '../../entity/system/role.entity';
+import { Menus } from '../../entity/system/menus.entity';
+import { MenusService } from './menus.service';
+import flattenDeep = require('lodash/flattenDeep');
+import uniq = require('lodash/uniq');
+import get = require('lodash/get');
+type modelType = ReturnModelType<typeof Role>;
+@Provide()
+export class RoleService extends BaseService<modelType> {
+  @InjectEntityModel(Role)
+  model: modelType;
+
+  @InjectEntityModel(Menus)
+  menusModel: ReturnModelType<typeof Menus>;
+
+  @Inject()
+  menusService: MenusService;
+
+  async getUserMenus() {
+    const user = this.ctx.user;
+    if (user.role === 'Admin' && user.is_super === 0) return await this.menusService.queryMenu();
+    const role = await this.model.findOne({ code: user.role, is_use: '0' }).lean();
+    if (!role) throw new ServiceError('当前角色下的用户无法使用!', FrameworkErrorEnum.SERVICE_FAULT);
+    const menu = get(role, 'menu', {});
+    const mode = get(menu, 'mode');
+    if (mode !== 'select') return await this.menusService.queryMenu();
+    let routerPaths = Object.keys(menu);
+    routerPaths = routerPaths.filter(f => f !== 'mode');
+    const pageMenus = await this.menusModel.find({ path: routerPaths, is_use: '0' }, { _id: 1, parent_id: 1 }, { sort: { order_num: 1 } }).lean();
+    const menuIds = pageMenus.map(i => i._id);
+    let parentIds = pageMenus.filter(i => i.parent_id);
+    while (parentIds.length > 0) {
+      const mid = await this.menusModel.find({ _id: parentIds, is_use: '0' }, { _id: 1, parent_id: 1 }).lean();
+      if (mid.length <= 0) break;
+      menuIds.push(mid.map(i => i._id));
+      parentIds = mid.filter(i => i.parent_id);
+    }
+    const rmenus = await this.menusModel.find({ _id: menuIds, is_use: '0' }, {}, { sort: { order_num: 1 } }).lean();
+    let treeMenu = rmenus.filter(f => !f.parent_id);
+    treeMenu = this.menusService.treeMenu(rmenus, treeMenu);
+    return treeMenu;
+  }
+
+  /**
+   * 根据角色id数组,整理菜单
+   * @param roleIdList 角色id数组
+   */
+  async getMenuByRoles(roleIdList) {
+    let menus = [];
+    // 第一步,整理所有菜单至一维数组
+    for (const r of roleIdList) {
+      menus.push(...flattenDeep(r));
+    }
+    menus = uniq(menus);
+    const allMenu = await this.menusModel.find({ _id: menus, is_use: '0' }, { meta: 0, __v: 0 }).sort({ order_num: 1 }).lean();
+    let treeMenu = allMenu.filter(f => !f.parent_id);
+    treeMenu = this.menusService.treeMenu(allMenu, treeMenu);
+    return treeMenu;
+  }
+}

+ 0 - 0
src/service/user/admin.service.ts


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott