lrf 7 months ago
parent
commit
0913556669

+ 27 - 12
package-lock.json

@@ -629,10 +629,11 @@
       "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ=="
     },
     "node_modules/@elastic/transport": {
-      "version": "8.6.0",
-      "resolved": "https://registry.npmmirror.com/@elastic/transport/-/transport-8.6.0.tgz",
-      "integrity": "sha512-/Ucpztrc+urZK8yCtFBUu2LePYJNnukgZSUUApUzGH/SxejqkH526Nph7aru8I0vZwdW5wqgCHSOIq3J7tIxGg==",
+      "version": "8.7.0",
+      "resolved": "https://registry.npmmirror.com/@elastic/transport/-/transport-8.7.0.tgz",
+      "integrity": "sha512-IqXT7a8DZPJtqP2qmX1I2QKmxYyN27kvSW4g6pInESE1SuGwZDp2FxHJ6W2kwmYOJwQdAt+2aWwzXO5jHo9l4A==",
       "dependencies": {
+        "@opentelemetry/api": "1.x",
         "debug": "^4.3.4",
         "hpagent": "^1.0.0",
         "ms": "^2.1.3",
@@ -1538,6 +1539,14 @@
         "node": ">= 8"
       }
     },
+    "node_modules/@opentelemetry/api": {
+      "version": "1.9.0",
+      "resolved": "https://registry.npmmirror.com/@opentelemetry/api/-/api-1.9.0.tgz",
+      "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",
+      "engines": {
+        "node": ">=8.0.0"
+      }
+    },
     "node_modules/@pkgjs/parseargs": {
       "version": "0.11.0",
       "resolved": "https://registry.npmmirror.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@@ -9096,9 +9105,9 @@
       }
     },
     "node_modules/undici": {
-      "version": "6.19.1",
-      "resolved": "https://registry.npmmirror.com/undici/-/undici-6.19.1.tgz",
-      "integrity": "sha512-m9QbEf5+YWXYycRHQtE22hTmRv2R6IDpBVR9UuHKvrDZJxrpgqnKkdV5inOdFskVxz3DmcKhDY/B1sE+ShhopQ==",
+      "version": "6.19.7",
+      "resolved": "https://registry.npmmirror.com/undici/-/undici-6.19.7.tgz",
+      "integrity": "sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==",
       "engines": {
         "node": ">=18.17"
       }
@@ -9970,10 +9979,11 @@
       }
     },
     "@elastic/transport": {
-      "version": "8.6.0",
-      "resolved": "https://registry.npmmirror.com/@elastic/transport/-/transport-8.6.0.tgz",
-      "integrity": "sha512-/Ucpztrc+urZK8yCtFBUu2LePYJNnukgZSUUApUzGH/SxejqkH526Nph7aru8I0vZwdW5wqgCHSOIq3J7tIxGg==",
+      "version": "8.7.0",
+      "resolved": "https://registry.npmmirror.com/@elastic/transport/-/transport-8.7.0.tgz",
+      "integrity": "sha512-IqXT7a8DZPJtqP2qmX1I2QKmxYyN27kvSW4g6pInESE1SuGwZDp2FxHJ6W2kwmYOJwQdAt+2aWwzXO5jHo9l4A==",
       "requires": {
+        "@opentelemetry/api": "1.x",
         "debug": "^4.3.4",
         "hpagent": "^1.0.0",
         "ms": "^2.1.3",
@@ -10679,6 +10689,11 @@
         "fastq": "^1.6.0"
       }
     },
+    "@opentelemetry/api": {
+      "version": "1.9.0",
+      "resolved": "https://registry.npmmirror.com/@opentelemetry/api/-/api-1.9.0.tgz",
+      "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg=="
+    },
     "@pkgjs/parseargs": {
       "version": "0.11.0",
       "resolved": "https://registry.npmmirror.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@@ -16293,9 +16308,9 @@
       "dev": true
     },
     "undici": {
-      "version": "6.19.1",
-      "resolved": "https://registry.npmmirror.com/undici/-/undici-6.19.1.tgz",
-      "integrity": "sha512-m9QbEf5+YWXYycRHQtE22hTmRv2R6IDpBVR9UuHKvrDZJxrpgqnKkdV5inOdFskVxz3DmcKhDY/B1sE+ShhopQ=="
+      "version": "6.19.7",
+      "resolved": "https://registry.npmmirror.com/undici/-/undici-6.19.7.tgz",
+      "integrity": "sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A=="
     },
     "unique-string": {
       "version": "2.0.0",

+ 3 - 1
src/config/config.self.ts

@@ -1,4 +1,5 @@
 import { MidwayConfig } from '@midwayjs/core';
+import { DbSubscriber } from '../event/dbSubscriber';
 /**数据库ip */
 const ip = 'localhost'; //localhost
 /**数据库名 */
@@ -52,8 +53,9 @@ export default {
         port: 54321,
         entities: ['./entity'],
         type: 'postgres',
-        synchronize: true, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
+        synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
         logging: false,
+        subscribers: [DbSubscriber],
       },
       logs: {
         database: logsDB,

+ 4 - 4
src/controller/home.controller.ts

@@ -1,4 +1,4 @@
-import { Controller, Get, Inject, Query } from '@midwayjs/core';
+import { Config, Controller, Get, Inject, Query } from '@midwayjs/core';
 import { InitTwoService } from '../service/initData/initTwo.service';
 import { InitRegionService } from '../service/initData/initRegion.service';
 import { InitOneService } from '../service/initData/initOne.service';
@@ -7,7 +7,7 @@ import { InitThreeService } from '../service/initData/initThree.service';
 import { DataDealService } from '../service/initData/dataDeal.service';
 import { TestsService } from '../service/tests.service';
 import { Opera } from '../frame/dbOpera';
-
+import { Client, estypes } from '@elastic/elasticsearch';
 @Controller('/')
 export class HomeController {
   @Inject()
@@ -26,8 +26,8 @@ export class HomeController {
   testService: TestsService;
   @Get('/')
   async home(@Query() query: object): Promise<any> {
-    await this.dataDealService.initUserMenus();
-    await this.dataDealService.initRoleMenus();
+    // await this.dataDealService.initUserMenus();
+    // await this.dataDealService.initRoleMenus();
     // await this.oneService.addTags();
     // await this.oneService.addImportDataTags();
     // await this.twoService.addTags();

+ 1 - 1
src/entity/platform/support.entity.ts

@@ -1,6 +1,6 @@
 import { Entity, Column } from 'typeorm';
 import { BaseModel } from '../../frame/BaseModel';
-// 中试平台
+// 服务
 @Entity('support')
 export class Support extends BaseModel {
   @Column({ type: 'integer', nullable: true, comment: '平台用户id' })

+ 1 - 1
src/frame/BaseServiceV2.ts

@@ -244,7 +244,7 @@ export abstract class BaseServiceV2 {
     // 整理成object
     for (const c of columns) columnsObject[c.propertyName] = c.type.toString();
     const updateData = {};
-    const notDealColumn = ['id', 'created_time', 'update_time', 'data_owner', '__v'];
+    const notDealColumn = ['created_time', 'update_time', 'data_owner', '__v'];
     for (const column in columnsObject) {
       if (notDealColumn.includes(column)) continue;
       const val = data[column];

+ 26 - 0
src/service/elasticsearch/es.service.ts

@@ -0,0 +1,26 @@
+import { Client } from "@elastic/elasticsearch";
+import { Config, Init, Provide } from "@midwayjs/core";
+
+
+
+@Provide()
+export class ESService {
+  @Config('elasticsearch')
+  esConfig: object;
+  /**es连接实例 */
+  esClient: Client;
+  @Init()
+  async initClient() {
+    const esClient = new Client(this.esConfig);
+    this.esClient = esClient;
+  }
+  /**
+   * 1.索引(es中的表)建立:根据编写的文件生成
+   * 2.初始化数据,通过接口触发
+   * 3.对指定表进行的数据修改做同步
+   */
+
+  async initIndex() {
+    
+  }
+}

+ 9 - 0
src/service/elasticsearch/indices.js

@@ -0,0 +1,9 @@
+export const indices = {
+  achievement: {},
+  demand: {},
+  footplate: {},
+  match: {},
+  project: {},
+  supply: {},
+  support: {},
+};

+ 0 - 1
tsconfig.json

@@ -9,7 +9,6 @@
     "inlineSourceMap":true,
     "noImplicitThis": true,
     "noUnusedLocals": false,
-    "noUnusedParameters":false,
     "stripInternal": true,
     "skipLibCheck": true,
     "pretty": true,