소스 검색

修改系统消息接口

zs 2 년 전
부모
커밋
0d083041e6
5개의 변경된 파일10개의 추가작업 그리고 19개의 파일을 삭제
  1. 4 4
      src/config/config.local.ts
  2. 1 1
      src/config/config.prod.ts
  3. 0 0
      src/entityBasic/unitStudioApply.entity.ts
  4. 0 0
      src/entityBasic/userStudioApply.entity.ts
  5. 5 14
      src/service/message.service.ts

+ 4 - 4
src/config/config.local.ts

@@ -14,9 +14,9 @@ export default {
       default: {
         uri: `mongodb://${ip}:27017/${project}`,
         options: {
-          // user: 'admin',
-          // pass: 'admin',
-          // authSource: 'admin',
+          user: 'admin',
+          pass: 'admin',
+          authSource: 'admin',
           useNewUrlParser: true,
         },
         entities: ['./entity'],
@@ -29,7 +29,7 @@ export default {
           authSource: 'admin',
           useNewUrlParser: true,
         },
-        entities: ['./entity/basic'],
+        entities: ['./entityBasic'],
       },
     },
   },

+ 1 - 1
src/config/config.prod.ts

@@ -29,7 +29,7 @@ export default {
           authSource: 'admin',
           useNewUrlParser: true,
         },
-        entities: ['./entity/basic'],
+        entities: ['./entityBasic'],
       },
     },
   },

src/entity/basic/unitStudioApply.entity.ts → src/entityBasic/unitStudioApply.entity.ts


src/entity/basic/userStudioApply.entity.ts → src/entityBasic/userStudioApply.entity.ts


+ 5 - 14
src/service/message.service.ts

@@ -1,23 +1,14 @@
 import { Provide } from '@midwayjs/decorator';
 import { InjectEntityModel } from '@midwayjs/typegoose';
-import { getModelForClass, ReturnModelType } from '@typegoose/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
 import { BaseService } from 'free-midway-component';
 import { Message } from '../entity/message.entity';
-import { UnitStudioApply } from '../entity/basic/unitStudioApply.entity';
-import { UserStudioApply } from '../entity/basic/userStudioApply.entity';
+import { UnitStudioApply } from '../entityBasic/unitStudioApply.entity';
+import { UserStudioApply } from '../entityBasic/userStudioApply.entity';
 import _ = require('lodash');
 type modelType = ReturnModelType<typeof Message>;
 @Provide()
 export class MessageService extends BaseService<modelType> {
-  constructor(ctx) {
-    super();
-    if (!this.ctx && ctx) {
-      this.ctx = ctx;
-      if (!this.cModel) this.cModel = getModelForClass(UnitStudioApply);
-      if (!this.sModel) this.sModel = getModelForClass(UserStudioApply);
-      if (!this.model) this.model = getModelForClass(Message);
-    }
-  }
   @InjectEntityModel(Message)
   model: modelType;
 
@@ -50,8 +41,8 @@ export class MessageService extends BaseService<modelType> {
     const list = [];
     for (const val of e) {
       let data = {};
-      if (type === '1') data = _.pick(val, ['id', 'company', 'phone']);
-      else if (type === '2') data = _.pick(val, ['id', 'name', 'phone']);
+      if (type === '1') data = _.pick(val, ['_id', 'company', 'phone']);
+      else if (type === '2') data = _.pick(val, ['_id', 'name', 'phone']);
       list.push(data);
     }
     return list;