video func implemented
This commit is contained in:
1 parent
3bc534489d
commit
89b8687431
13 files changed
+504
-9
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { Injectable, NotFoundException, Logger } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Article, ArticleStatus } from './entities';
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
|
||||
@Injectable()
|
||||
export class ArticlesService {
|
||||
private readonly logger = new Logger(ArticlesService.name);
|
||||
|
||||
constructor(
|
||||
@InjectRepository(Article)
|
||||
private readonly articleRepository: Repository<Article>,
|
||||
@@ -125,4 +127,16 @@ export class ArticlesService {
|
||||
|
||||
return await this.articleRepository.save(article);
|
||||
}
|
||||
|
||||
async removeByStrapiId(strapiId: string): Promise<void> {
|
||||
const article = await this.articleRepository.findOne({ where: { strapiId } });
|
||||
|
||||
if (!article) {
|
||||
this.logger.warn(`Article with strapiId ${strapiId} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.articleRepository.remove(article);
|
||||
this.logger.log(`Successfully deleted article with strapiId: ${strapiId}`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user