likes.js 584 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 LikesService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'likes');
  10. this.model = this.ctx.model.Likes;
  11. }
  12. async selikes({ 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 = LikesService;