Explorar el Código

修改系统消息接口

zs hace 2 años
padre
commit
0d083041e6

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