customer.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. // 客服调度相关
  5. class CustomerController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.service = this.ctx.service.customer;
  9. }
  10. // 客服登陆/续时
  11. async customerLog() {
  12. await this.service.customerLog(this.ctx.query);
  13. this.ctx.ok();
  14. }
  15. // 客户咨询
  16. async clientApply() {
  17. const data = await this.service.clientApply(this.ctx.query);
  18. this.ctx.ok({ data });
  19. }
  20. // 客户续时
  21. async clientContinue() {
  22. const data = await this.service.clientContinue(this.ctx.query);
  23. this.ctx.ok({ data });
  24. }
  25. // 结束服务
  26. async serverEnd() {
  27. const data = await this.service.serverEnd(this.ctx.query);
  28. this.ctx.ok({ data });
  29. }
  30. // 对话
  31. async chat() {
  32. const data = await this.service.chat(this.ctx.request.body);
  33. this.ctx.ok({ data });
  34. }
  35. // 获取客服正在服务的客户列表
  36. async getRecord() {
  37. const data = await this.service.getRecord(this.ctx.query);
  38. this.ctx.ok({ data });
  39. }
  40. }
  41. module.exports = CrudController(CustomerController, {});