patentchat.js 902 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const { ObjectId } = require('mongoose').Types;
  5. const _ = require('lodash');
  6. const assert = require('assert');
  7. // 专利资讯服务聊天表
  8. class PatentchatService extends CrudService {
  9. constructor(ctx) {
  10. super(ctx, 'patentchat');
  11. this.model = this.ctx.model.Patent.Patentchat;
  12. }
  13. async query({ id }) {
  14. assert(id, '缺少用户信息');
  15. const data = await this.model.find({ $or: [{ sender_id: id }, { receiver_id: id }] }).sort({ 'meta.createdAt': -1 });
  16. return data;
  17. }
  18. async count({ id }) {
  19. assert(id, '缺少用户信息');
  20. const data = await this.model.count({ $or: [{ sender_id: id }, { receiver_id: id }] });
  21. return data;
  22. }
  23. async getChatList({ id }) {
  24. }
  25. }
  26. module.exports = PatentchatService;