chat.js 791 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
  4. //
  5. class ChatController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.mq = this.ctx.mq;
  9. this.redis = this.app.redis;
  10. }
  11. async online() {
  12. const query = this.ctx.query;
  13. const { person } = query;
  14. console.log(person);
  15. if (this.mq) {
  16. console.log('mq ojbk!');
  17. }
  18. if (this.redis) {
  19. console.log('redis ojbk!');
  20. const p = await this.redis.get(person);
  21. // if(p) await this.redis.set(person,'')
  22. }
  23. this.ctx.ok();
  24. }
  25. async send() {
  26. const body = this.ctx.request.body;
  27. console.log(body);
  28. this.ctx.ok();
  29. }
  30. }
  31. module.exports = CrudController(ChatController, {});