import { Provide } from '@midwayjs/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Equal, Repository } from 'typeorm';
import { Collection } from '../../entity/platform/collection.entity';
import { BaseService } from '../../frame/BaseService';
@Provide()
export class CollectionService extends BaseService<Collection> {
  @InjectEntityModel(Collection)
  model: Repository<Collection>;
  // 取消收藏
  async cancel(data) {
    const { user, source } = data;
    const d = await this.model.findOne({ where: { user: Equal(user), source: Equal(source) } });
    // await this.model.deleteOne({ user, source });
    await this.model.delete(d.id);
  }
}
