refactor: 重构项目支持TypeORM数据库持久化
新增数据库实体类与服务实现,将内存存储扩展为支持数据库的完整实现,包括: 1. 新增Drama和Episode实体类,添加多个业务字段 2. 重构DramasService实现数据库CRUD与业务逻辑 3. 升级相关服务类为异步方法适配数据库操作 4. 更新测试用例适配异步接口变更 5. 完善分页、数据转换等辅助工具方法
This commit is contained in:
@@ -54,8 +54,10 @@ export class MediaService {
|
||||
return job;
|
||||
}
|
||||
|
||||
createDirectUploadTask(dto: CreateDirectUploadTaskDto): MediaUploadJobRecord {
|
||||
this.dramasService.getEpisodeOrThrow(dto.episodeId);
|
||||
async createDirectUploadTask(
|
||||
dto: CreateDirectUploadTaskDto,
|
||||
): Promise<MediaUploadJobRecord> {
|
||||
await this.dramasService.getEpisodeOrThrow(dto.episodeId);
|
||||
const now = new Date().toISOString();
|
||||
const jobId = randomUUID();
|
||||
const upload = this.bytePlusMediaProvider.createDirectUpload({
|
||||
@@ -87,7 +89,7 @@ export class MediaService {
|
||||
return job;
|
||||
}
|
||||
|
||||
completeDirectUploadTask(jobId: string): MediaUploadJobRecord {
|
||||
async completeDirectUploadTask(jobId: string): Promise<MediaUploadJobRecord> {
|
||||
const job = this.getUploadJobOrThrow(jobId);
|
||||
if (!job.objectKey || !job.episodeId) {
|
||||
throw new NotFoundException('Upload task not found');
|
||||
@@ -116,7 +118,7 @@ export class MediaService {
|
||||
updatedAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
this.dramasService.attachEpisodeMedia({
|
||||
await this.dramasService.attachEpisodeMedia({
|
||||
episodeId: job.episodeId,
|
||||
byteplusVid: completed.byteplusVid,
|
||||
videoUrl: completed.videoUrl,
|
||||
@@ -132,7 +134,7 @@ export class MediaService {
|
||||
return job;
|
||||
}
|
||||
|
||||
retryReview(jobId: string): MediaUploadJobRecord {
|
||||
async retryReview(jobId: string): Promise<MediaUploadJobRecord> {
|
||||
const job = this.getUploadJobOrThrow(jobId);
|
||||
if (!job.byteplusVid || !job.episodeId) {
|
||||
throw new NotFoundException('Upload task not found');
|
||||
@@ -143,7 +145,7 @@ export class MediaService {
|
||||
job.reviewStatus = review.reviewStatus;
|
||||
job.reviewMessage = review.reviewMessage;
|
||||
job.updatedAt = new Date().toISOString();
|
||||
this.dramasService.updateEpisodeReviewStatus(
|
||||
await this.dramasService.updateEpisodeReviewStatus(
|
||||
job.episodeId,
|
||||
review.reviewStatus,
|
||||
review.reviewMessage,
|
||||
@@ -151,7 +153,7 @@ export class MediaService {
|
||||
return job;
|
||||
}
|
||||
|
||||
syncReviewStatuses() {
|
||||
async syncReviewStatuses() {
|
||||
const reviewingJobs = this.uploadJobs.filter(
|
||||
(job) =>
|
||||
job.byteplusVid &&
|
||||
@@ -167,7 +169,7 @@ export class MediaService {
|
||||
job.reviewStatus = review.reviewStatus;
|
||||
job.reviewMessage = review.reviewMessage;
|
||||
job.updatedAt = new Date().toISOString();
|
||||
this.dramasService.updateEpisodeReviewStatus(
|
||||
await this.dramasService.updateEpisodeReviewStatus(
|
||||
job.episodeId as number,
|
||||
review.reviewStatus,
|
||||
review.reviewMessage,
|
||||
|
||||
Reference in New Issue
Block a user