Create Library module. Moved book controller to library controller. Added series addition to library while adding all known volumes in background. Fixed Google search context.
This commit is contained in:
@ -2,23 +2,56 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { SeriesEntity } from './entities/series.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { PinoLogger } from 'nestjs-pino';
|
||||
import { CreateSeriesDto } from './dto/create-series.dto';
|
||||
import { DeleteSeriesDto } from './dto/delete-series.dto';
|
||||
import { SeriesDto } from './dto/series.dto';
|
||||
import { SeriesSubscriptionEntity } from './entities/series-subscription.entity';
|
||||
import { UUID } from 'crypto';
|
||||
import { SeriesSubscriptionDto } from './dto/series-subscription.dto';
|
||||
|
||||
@Injectable()
|
||||
export class SeriesService {
|
||||
constructor(
|
||||
@InjectRepository(SeriesEntity)
|
||||
private seriesRepository: Repository<SeriesEntity>,
|
||||
private logger: PinoLogger,
|
||||
@InjectRepository(SeriesSubscriptionEntity)
|
||||
private seriesSubscriptionRepository: Repository<SeriesSubscriptionEntity>,
|
||||
) { }
|
||||
|
||||
|
||||
async deleteSeries(series: DeleteSeriesDto) {
|
||||
async addSeries(series: CreateSeriesDto) {
|
||||
return await this.seriesRepository.insert(series);
|
||||
}
|
||||
|
||||
async addSeriesSubscription(series: SeriesSubscriptionDto) {
|
||||
return await this.seriesSubscriptionRepository.insert(series);
|
||||
}
|
||||
|
||||
async deleteSeries(series: SeriesDto) {
|
||||
return await this.seriesRepository.delete(series);
|
||||
}
|
||||
|
||||
async deleteSeriesSubscription(subscription: SeriesSubscriptionDto) {
|
||||
return await this.seriesSubscriptionRepository.delete(subscription);
|
||||
}
|
||||
|
||||
async getSeries(series: SeriesDto) {
|
||||
return await this.seriesRepository.findOne({
|
||||
where: series
|
||||
})
|
||||
}
|
||||
|
||||
async getAllSeries() {
|
||||
return await this.seriesRepository.find()
|
||||
}
|
||||
|
||||
async getSeriesSubscribedBy(userId: UUID) {
|
||||
return await this.seriesSubscriptionRepository.find({
|
||||
where: {
|
||||
userId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async updateSeries(series: CreateSeriesDto) {
|
||||
return await this.seriesRepository.upsert(series, ['provider', 'providerSeriesId']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user