collects.js 599 B

1234567891011121314151617181920
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. // 我的收藏
  7. class CollectsService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'collects');
  10. this.model = this.ctx.model.Collects;
  11. }
  12. async secollects({ user_id, video_id }) {
  13. const data = await this.model.findOne({ user_id, video_id });
  14. if (data) return { id: data._id, is: true };
  15. return { is: false };
  16. }
  17. }
  18. module.exports = CollectsService;