liuyu hace 5 años
padre
commit
3461ab5df6
Se han modificado 2 ficheros con 11 adiciones y 13 borrados
  1. 8 10
      app/controller/home.js
  2. 3 3
      config/config.default.js

+ 8 - 10
app/controller/home.js

@@ -13,25 +13,23 @@ class HomeController extends Controller {
   async sendmq() {
     const { ctx, app } = this;
     console.log(msgValue.MsgValues.EXCHANGE_CROP_REG);
-    await this.service.rabbitmq.sendQueueMsg(ctx.query.exchange,ctx.query.routekey, new Buffer(JSON.stringify(ctx.query.msg)), (data) => 
-    {    
-       console.log(data);
-       
+    await this.service.rabbitmq.sendQueueMsg(ctx.query.exchange, ctx.query.routekey, new Buffer(JSON.stringify(ctx.query.msg)), data => {
+      console.log(data);
+
     });
     ctx.body = '发送成功';
   }
 
   async receivemq() {
     const { ctx, app } = this;
-    await this.service.rabbitmq.receiveQueueMsg(ctx.query.exchange,ctx.query.routekey,(msg) => 
-    {    
-       console.log(msg);
- 
+    await this.service.rabbitmq.receiveQueueMsg(ctx.query.exchange, ctx.query.routekey, msg => {
+      console.log(msg);
+
       // 插入待办事项到数据库中。
-      await this.service.message.create({producerid: '1', consumerid: '2',type: '1', content: '2222'});  
+      this.service.message.create({ producerid: msg.producerid, consumerid: msg.consumerid, type: msg.type, content: msg.content, remark: msg.remark });
 
     });
-    ctx.body = "接收成功";
+    ctx.body = '接收成功';
   }
 }
 

+ 3 - 3
config/config.default.js

@@ -51,11 +51,11 @@ module.exports = appInfo => {
   //   },
   // };
   config.mongoose = {
-    url: 'mongodb://10.16.5.15:27017/smart',
+    url: 'mongodb://localhost:27017/smart',
     options: {
       user: 'demo',
-      pass: 'demo2019',
-      authSource: 'demo',
+      pass: 'demo',
+      authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,
       useUnifiedTopology: true,