瀏覽代碼

期刊关联

zs 6 月之前
父節點
當前提交
26522ab2c1
共有 2 個文件被更改,包括 17 次插入1 次删除
  1. 1 0
      src/controller/platform/journal.controller.ts
  2. 16 1
      src/service/platform/journal.service.ts

+ 1 - 0
src/controller/platform/journal.controller.ts

@@ -51,6 +51,7 @@ export class JournalController implements BaseController {
   async update(@Param('id') id: number, @Body() data: object) {
     if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
     const result = await this.service.update({ id }, data);
+    await this.service.Notesupdate({ id }, data);
     return result;
   }
 

+ 16 - 1
src/service/platform/journal.service.ts

@@ -1,10 +1,25 @@
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Repository } from 'typeorm';
+import { Repository, Equal } from 'typeorm';
 import { Journal } from '../../entity/platform/journal.entity';
 import { BaseServiceV2 } from '../../frame/BaseServiceV2';
+import { get } from 'lodash';
+import { Notes } from '../../entity/platform/notes.entity';
 @Provide()
 export class JournalService extends BaseServiceV2 {
   @InjectEntityModel(Journal)
   model: Repository<Journal>;
+
+  @InjectEntityModel(Notes)
+  nModel: Repository<Notes>;
+
+  // 禁用产研行研 同时禁用下属期刊
+  async Notesupdate({ id }, data) {
+    if (get(data, 'is_use')) {
+      const result = await this.nModel.find({ where: { journal: Equal(id) } });
+      for (const val of result) {
+        await this.nModel.update({ id: get(val, 'id') }, { is_use: get(data, 'is_use'), status: '1' });
+      }
+    }
+  }
 }