import { Inject, Provide } from '@midwayjs/core'; import { InjectEntityModel } from '@midwayjs/typeorm'; import { Equal, Repository } from 'typeorm'; import { Collection } from '../../entity/platform/collection.entity'; import { BaseServiceV2 } from '../../frame/BaseServiceV2'; import { MatchService } from '../platform/match.service'; import { AchievementService } from '../platform/achievement.service'; import { SupplyService } from '../platform/supply.service'; import { SupportService } from '../platform/support.service'; import { ProjectService } from '../platform/project.service'; import { FootplateService } from '../platform/footplate.service'; import { NewsService } from '../platform/news.service'; import { ExpertService } from '../../service/users/expert.service'; import { DemandService } from '../platform/demand.service'; import { CompanyService } from '../../service/users/company.service'; import { IncubatorService } from '../users/incubator.service'; @Provide() export class CollectionService extends BaseServiceV2 { getQueryColumnsOpera(): object { return {}; } @InjectEntityModel(Collection) model: Repository; @Inject() match: MatchService; @Inject() achievement: AchievementService; @Inject() supply: SupplyService; @Inject() support: SupportService; @Inject() project: ProjectService; @Inject() footplate: FootplateService; @Inject() news: NewsService; @Inject() expert: ExpertService; @Inject() demand: DemandService; @Inject() company: CompanyService; @Inject() incubator: IncubatorService; // 转化来源数据名称 async fillScource(data) { const { type, source } = data; const dataRes = await this[type].fetch({ id: source }); if (dataRes) data = { ...data, source_name: dataRes.name || dataRes.title, status: '1' }; else data = { ...data, source_name: '已失效', status: '-1' }; return data; } // 取消收藏 async cancel(data) { const { user, source, type } = data; const d = await this.model.findOne({ where: { user: Equal(user), source: Equal(source), type: Equal(type) } }); await this.model.delete(d.id); } }