diff --git a/build.gradle b/build.gradle index ce787c3b..3de4755b 100644 --- a/build.gradle +++ b/build.gradle @@ -97,15 +97,13 @@ sonar { property "sonar.coverage.jacoco.xmlReportPaths", "${layout.buildDirectory}/reports/jacoco/test/jacocoTestReport.xml" property "sonar.junit.reportPaths", "${layout.buildDirectory}/test-results/test" - property "sonar.exclusions", [ - "**/ddingdong/ddingdongBE/common/**", - "**/ddingdong/ddingdongBE/*Request*", - "**/ddingdong/ddingdongBE/*Response*", - "**/ddingdong/ddingdongBE/*Command*", - "**/ddingdong/ddingdongBE/*Query*", - "**/ddingdong/ddingdongBE/*Dto*" - ].join(',') + property "sonar.exclusions", """ + **/ddingdong/ddingdongBE/common/**, + """ + property "sonar.coverage.exclusions", + "**/common/**, **/controller/**, **/dto/**, **/service/General**Service" } + } jacocoTestReport { @@ -113,12 +111,14 @@ jacocoTestReport { afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { fileTree(dir: it, exclude: [ - "ddingdong/ddingdongBE/common/**", - "ddingdong/ddingdongBE/*Request*", - "ddingdong/ddingdongBE/*Response*", - "ddingdong/ddingdongBE/*Command*", - "ddingdong/ddingdongBE/*Query*", - "ddingdong/ddingdongBE/*Dto*" + "**/ddingdong/ddingdongBE/common/**", + "**/ddingdong/ddingdongBE/**/**Request**", + "**/ddingdong/ddingdongBE/**/**Response**", + "**/ddingdong/ddingdongBE/**/**Command**", + "**/ddingdong/ddingdongBE/**/**Query**", + "**/ddingdong/ddingdongBE/**/**Dto**", + "**/ddingdong/ddingdongBE/**/**Controller**", + "**/ddingdong/ddingdongBE/**/General*Service.class" ]) })) } diff --git a/src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java b/src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java index c775d361..b21da1be 100644 --- a/src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java +++ b/src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java @@ -46,7 +46,8 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthService authSer API_PREFIX + "/banners/**", API_PREFIX + "/documents/**", API_PREFIX + "/questions/**", - API_PREFIX + "/feeds/**") + API_PREFIX + "/feeds/**", + API_PREFIX + "/internal/**") .permitAll() .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**") .permitAll() diff --git a/src/main/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentService.java similarity index 96% rename from src/main/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImpl.java rename to src/main/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentService.java index 58a757db..5196e673 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentService.java @@ -13,7 +13,7 @@ @Service @Transactional(readOnly = true) @RequiredArgsConstructor -public class DocumentServiceImpl implements DocumentService { +public class GeneralDocumentService implements DocumentService { private final DocumentRepository documentRepository; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FacadeFeedService.java b/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FacadeFeedService.java index 0ed641f6..4993a6da 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FacadeFeedService.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FacadeFeedService.java @@ -19,25 +19,25 @@ @Transactional(readOnly = true) public class FacadeFeedService { - private final FeedService feedService; + private final GeneralFeedService generalFeedService; private final FileInformationService fileInformationService; public List getAllByClubId(Long clubId) { - List feeds = feedService.getAllByClubId(clubId); + List feeds = generalFeedService.getAllByClubId(clubId); return feeds.stream() .map(FeedListQuery::from) .toList(); } public List getNewestAll() { - List feeds = feedService.getNewestAll(); + List feeds = generalFeedService.getNewestAll(); return feeds.stream() .map(FeedListQuery::from) .toList(); } public FeedQuery getById(Long feedId) { - Feed feed = feedService.getById(feedId); + Feed feed = generalFeedService.getById(feedId); ClubProfileQuery clubProfileQuery = extractClubInfo(feed.getClub()); return FeedQuery.of(feed, clubProfileQuery); } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedService.java b/src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedService.java similarity index 96% rename from src/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedService.java rename to src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedService.java index a729b933..03b28828 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/feed/service/FeedService.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/feed/service/GeneralFeedService.java @@ -11,7 +11,7 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) -public class FeedService { +public class GeneralFeedService { private final FeedRepository feedRepository; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FixZoneServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/GeneralFixZoneService.java similarity index 95% rename from src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FixZoneServiceImpl.java rename to src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/GeneralFixZoneService.java index 34c3cdeb..14f7e2a4 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/FixZoneServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/fixzone/service/GeneralFixZoneService.java @@ -11,7 +11,7 @@ @Service @Transactional(readOnly = true) @RequiredArgsConstructor -public class FixZoneServiceImpl implements FixZoneService { +public class GeneralFixZoneService implements FixZoneService { private final FixZoneRepository fixZoneRepository; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeAdminNoticeServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeAdminNoticeServiceImpl.java index aaa5dd09..f71056df 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeAdminNoticeServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeAdminNoticeServiceImpl.java @@ -14,7 +14,7 @@ @Transactional(readOnly = true) public class FacadeAdminNoticeServiceImpl implements FacadeAdminNoticeService { - private final NoticeServiceImpl noticeService; + private final NoticeService noticeService; private final FileMetaDataService fileMetaDataService; @Transactional diff --git a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java index 13e32fc0..e450810a 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/FacadeNoticeServiceImpl.java @@ -20,7 +20,7 @@ @Transactional(readOnly = true) public class FacadeNoticeServiceImpl implements FacadeNoticeService { - private final NoticeServiceImpl noticeService; + private final NoticeService noticeService; private final FileMetaDataService fileMetaDataService; private final S3FileService s3FileService; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/NoticeServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/GeneralNoticeService.java similarity index 96% rename from src/main/java/ddingdong/ddingdongBE/domain/notice/service/NoticeServiceImpl.java rename to src/main/java/ddingdong/ddingdongBE/domain/notice/service/GeneralNoticeService.java index 3eaabb3d..3b463267 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/notice/service/NoticeServiceImpl.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/notice/service/GeneralNoticeService.java @@ -11,7 +11,7 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) -public class NoticeServiceImpl implements NoticeService { +public class GeneralNoticeService implements NoticeService { public static final int NOTICE_COUNT_FOR_PAGE = 10; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/VodProcessingJobController.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/VodProcessingJobController.java new file mode 100644 index 00000000..3004c5c9 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/VodProcessingJobController.java @@ -0,0 +1,24 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.controller; + +import ddingdong.ddingdongBE.domain.vodprocessing.controller.dto.request.CreatePendingVodProcessingJobRequest; +import ddingdong.ddingdongBE.domain.vodprocessing.service.FacadeVodProcessingJobService; +import io.swagger.v3.oas.annotations.Hidden; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Hidden +@RestController +@RequestMapping("/server/internal/trigger/vod-processing-job") +@RequiredArgsConstructor +public class VodProcessingJobController { + + private final FacadeVodProcessingJobService facadeVodProcessingJobService; + + @PostMapping() + public void createPending(CreatePendingVodProcessingJobRequest request) { + facadeVodProcessingJobService.create(request.toCommand()); + } + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/dto/request/CreatePendingVodProcessingJobRequest.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/dto/request/CreatePendingVodProcessingJobRequest.java new file mode 100644 index 00000000..4473e584 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/controller/dto/request/CreatePendingVodProcessingJobRequest.java @@ -0,0 +1,14 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.controller.dto.request; + +import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand; + +public record CreatePendingVodProcessingJobRequest( + String convertJobId, + String userId +) { + + public CreatePendingVodProcessingJobCommand toCommand() { + return new CreatePendingVodProcessingJobCommand(convertJobId, userId); + } + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/ConvertJobStatus.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/ConvertJobStatus.java new file mode 100644 index 00000000..415f7177 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/ConvertJobStatus.java @@ -0,0 +1,5 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.entity; + +public enum ConvertJobStatus { + PENDING +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodNotificationStatus.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodNotificationStatus.java new file mode 100644 index 00000000..2dbe601e --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodNotificationStatus.java @@ -0,0 +1,4 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.entity; + +public enum VodNotificationStatus { +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingJob.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingJob.java new file mode 100644 index 00000000..fa05c83a --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingJob.java @@ -0,0 +1,50 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.entity; + +import ddingdong.ddingdongBE.common.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class VodProcessingJob extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "notification_id") + private VodProcessingNotification vodProcessingNotification; + + @Column(nullable = false) + private String convertJobId; + + @Column(nullable = false) + private String userId; + + @Enumerated(EnumType.STRING) + private ConvertJobStatus convertJobStatus; + + @Builder + private VodProcessingJob(Long id, VodProcessingNotification vodProcessingNotification, String convertJobId, + String userId, ConvertJobStatus convertJobStatus) { + this.id = id; + this.vodProcessingNotification = vodProcessingNotification; + this.convertJobId = convertJobId; + this.userId = userId; + this.convertJobStatus = convertJobStatus; + } +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingNotification.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingNotification.java new file mode 100644 index 00000000..a03ebdde --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingNotification.java @@ -0,0 +1,36 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.entity; + +import ddingdong.ddingdongBE.common.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class VodProcessingNotification extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private LocalDateTime expiredAt; + + private LocalDateTime sentAt; + + @Column(nullable = false) + private int retryCount; + + @Enumerated(EnumType.STRING) + @Column(name = "notification_status", nullable = false) + private VodNotificationStatus vodNotificationStatus; + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/repository/VodProcessingJobRepository.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/repository/VodProcessingJobRepository.java new file mode 100644 index 00000000..a03a956d --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/repository/VodProcessingJobRepository.java @@ -0,0 +1,13 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.repository; + +import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface VodProcessingJobRepository extends JpaRepository { + + Optional findByConvertJobId(String convertJobId); + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobService.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobService.java new file mode 100644 index 00000000..ef900ba0 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobService.java @@ -0,0 +1,9 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service; + +import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand; + +public interface FacadeVodProcessingJobService { + + Long create(CreatePendingVodProcessingJobCommand command); + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobServiceImpl.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobServiceImpl.java new file mode 100644 index 00000000..c9f042e4 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobServiceImpl.java @@ -0,0 +1,20 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service; + +import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class FacadeVodProcessingJobServiceImpl implements FacadeVodProcessingJobService { + + private final VodProcessingJobService vodProcessingJobService; + + @Override + @Transactional + public Long create(CreatePendingVodProcessingJobCommand command) { + return vodProcessingJobService.save(command.toPendingVodProcessingJob()); + } +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/GeneralVodProcessingJobService.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/GeneralVodProcessingJobService.java new file mode 100644 index 00000000..b4466f52 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/GeneralVodProcessingJobService.java @@ -0,0 +1,37 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service; + +import ddingdong.ddingdongBE.common.exception.PersistenceException.ResourceNotFound; +import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob; +import ddingdong.ddingdongBE.domain.vodprocessing.repository.VodProcessingJobRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class GeneralVodProcessingJobService implements VodProcessingJobService { + + private final VodProcessingJobRepository vodProcessingJobRepository; + + @Override + @Transactional + public Long save(VodProcessingJob vodProcessingJob) { + VodProcessingJob saveVodProcessingJob = vodProcessingJobRepository.save(vodProcessingJob); + return saveVodProcessingJob.getId(); + } + + @Override + public VodProcessingJob getById(Long vodProcessingJobId) { + return vodProcessingJobRepository.findById(vodProcessingJobId) + .orElseThrow(() -> new ResourceNotFound( + "VodProcessingJob(vodProcessingJobId=" + vodProcessingJobId + ")를 찾을 수 없습니다.")); + } + + @Override + public VodProcessingJob getByConvertJobId(String convertJobId) { + return vodProcessingJobRepository.findByConvertJobId(convertJobId) + .orElseThrow(() -> new ResourceNotFound( + "VodProcessingJob(convertJobId=" + convertJobId + ")를 찾을 수 없습니다.")); + } +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/VodProcessingJobService.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/VodProcessingJobService.java new file mode 100644 index 00000000..141b5f34 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/VodProcessingJobService.java @@ -0,0 +1,13 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service; + +import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob; + +public interface VodProcessingJobService { + + Long save(VodProcessingJob vodProcessingJob); + + VodProcessingJob getById(Long vodProcessingJobId); + + VodProcessingJob getByConvertJobId(String convertJobId); + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/dto/command/CreatePendingVodProcessingJobCommand.java b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/dto/command/CreatePendingVodProcessingJobCommand.java new file mode 100644 index 00000000..631a922b --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/dto/command/CreatePendingVodProcessingJobCommand.java @@ -0,0 +1,19 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command; + +import ddingdong.ddingdongBE.domain.vodprocessing.entity.ConvertJobStatus; +import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob; + +public record CreatePendingVodProcessingJobCommand( + String convertJobId, + String userId +) { + + public VodProcessingJob toPendingVodProcessingJob() { + return VodProcessingJob.builder() + .convertJobId(convertJobId) + .userId(userId) + .convertJobStatus(ConvertJobStatus.PENDING) + .build(); + } + +} diff --git a/src/main/java/ddingdong/ddingdongBE/file/controller/S3FileController.java b/src/main/java/ddingdong/ddingdongBE/file/controller/S3FileController.java index 28a590b5..9b4f3d5e 100644 --- a/src/main/java/ddingdong/ddingdongBE/file/controller/S3FileController.java +++ b/src/main/java/ddingdong/ddingdongBE/file/controller/S3FileController.java @@ -24,7 +24,7 @@ public UploadUrlResponse getPreSignedUrl(PrincipalDetails principalDetails, Stri LocalDateTime now = LocalDateTime.now(); GeneratePreSignedUrlRequestQuery query = s3FileService.generatePresignedUrlRequest( - new GeneratePreSignedUrlRequestCommand(now, user.getAuthId(), fileName)); + new GeneratePreSignedUrlRequestCommand(now, user.getId(), fileName)); URL presingedUrl = s3FileService.getPresignedUrl(query.generatePresignedUrlRequest()); return UploadUrlResponse.of(query, presingedUrl); } diff --git a/src/main/java/ddingdong/ddingdongBE/file/service/S3FileService.java b/src/main/java/ddingdong/ddingdongBE/file/service/S3FileService.java index 4d6ba9e9..caccb066 100644 --- a/src/main/java/ddingdong/ddingdongBE/file/service/S3FileService.java +++ b/src/main/java/ddingdong/ddingdongBE/file/service/S3FileService.java @@ -92,6 +92,7 @@ public UploadedFileUrlAndNameQuery getUploadedFileUrlAndName(String key, String ); } + //TODO: video 피드 조회 시 수정 필요 public UploadedVideoUrlQuery getUploadedVideoUrl(String key) { String fileId = extractFileId(key); String region = amazonS3Client.getRegionName(); @@ -124,7 +125,7 @@ private String generateKey(ContentType contentType, GeneratePreSignedUrlRequestC serverProfile, contentType.getKeyMediaType(), formatDate(command.generatedAt()), - command.authId(), + command.userId(), uploadFileName.toString()); } diff --git a/src/main/java/ddingdong/ddingdongBE/file/service/dto/command/GeneratePreSignedUrlRequestCommand.java b/src/main/java/ddingdong/ddingdongBE/file/service/dto/command/GeneratePreSignedUrlRequestCommand.java index 9b69fd80..885bb1c8 100644 --- a/src/main/java/ddingdong/ddingdongBE/file/service/dto/command/GeneratePreSignedUrlRequestCommand.java +++ b/src/main/java/ddingdong/ddingdongBE/file/service/dto/command/GeneratePreSignedUrlRequestCommand.java @@ -4,7 +4,7 @@ public record GeneratePreSignedUrlRequestCommand( LocalDateTime generatedAt, - String authId, + Long userId, String fileName ) { diff --git a/src/main/resources/db/migration/V29__create_tables_vod_processing.sql b/src/main/resources/db/migration/V29__create_tables_vod_processing.sql new file mode 100644 index 00000000..c6c961ba --- /dev/null +++ b/src/main/resources/db/migration/V29__create_tables_vod_processing.sql @@ -0,0 +1,29 @@ +CREATE TABLE vod_processing_job +( + id BIGINT AUTO_INCREMENT NOT NULL, + created_at timestamp NULL, + updated_at timestamp NULL, + notification_id BIGINT NULL, + convert_job_id VARCHAR(255) NOT NULL, + user_id VARCHAR(255) NOT NULL, + convert_job_status VARCHAR(255) NULL, + CONSTRAINT PK_vod_processing_job PRIMARY KEY (id) +); + +CREATE TABLE vod_processing_notification +( + id BIGINT AUTO_INCREMENT NOT NULL, + created_at timestamp NULL, + updated_at timestamp NULL, + expired_at datetime NULL, + sent_at datetime NULL, + retry_count INT NOT NULL, + notification_status VARCHAR(255) NOT NULL, + CONSTRAINT PK_vod_processing_notification PRIMARY KEY (id) +); + +ALTER TABLE vod_processing_job + ADD CONSTRAINT UC_vod_processing_job_notification UNIQUE (notification_id); + +ALTER TABLE vod_processing_job + ADD CONSTRAINT FK_vod_processing_job_vod_processing_notification_id FOREIGN KEY (notification_id) REFERENCES vod_processing_notification (id); diff --git a/src/test/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImplTest.java b/src/test/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentServiceTest.java similarity index 85% rename from src/test/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImplTest.java rename to src/test/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentServiceTest.java index 70fb7684..34befa5a 100644 --- a/src/test/java/ddingdong/ddingdongBE/domain/documents/service/DocumentServiceImplTest.java +++ b/src/test/java/ddingdong/ddingdongBE/domain/documents/service/GeneralDocumentServiceTest.java @@ -12,13 +12,13 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class DocumentServiceImplTest extends TestContainerSupport { +class GeneralDocumentServiceTest extends TestContainerSupport { @Autowired private DocumentRepository documentRepository; @Autowired - private DocumentServiceImpl documentServiceImpl; + private GeneralDocumentService generalDocumentService; @DisplayName("document(자료)를 생성한다.") @@ -30,7 +30,7 @@ void create() { .build(); //when - Long createdDocumentId = documentServiceImpl.create(document); + Long createdDocumentId = generalDocumentService.create(document); //then Optional foundDocument = documentRepository.findById(createdDocumentId); diff --git a/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImplTest.java b/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminGeneralFixZoneServiceTest.java similarity index 97% rename from src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImplTest.java rename to src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminGeneralFixZoneServiceTest.java index 5b299771..f64e1dc3 100644 --- a/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminFixZoneServiceImplTest.java +++ b/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeAdminGeneralFixZoneServiceTest.java @@ -20,7 +20,7 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class FacadeAdminFixZoneServiceImplTest extends TestContainerSupport { +class FacadeAdminGeneralFixZoneServiceTest extends TestContainerSupport { @Autowired private FacadeAdminFixZoneService facadeAdminFixZoneService; diff --git a/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImplTest.java b/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralGeneralFixZoneServiceTest.java similarity index 99% rename from src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImplTest.java rename to src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralGeneralFixZoneServiceTest.java index 68a469e6..74fc72b5 100644 --- a/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralFixZoneServiceImplTest.java +++ b/src/test/java/ddingdong/ddingdongBE/domain/fixzone/service/FacadeCentralGeneralFixZoneServiceTest.java @@ -34,7 +34,7 @@ @Transactional @SpringBootTest -class FacadeCentralFixZoneServiceImplTest extends TestContainerSupport { +class FacadeCentralGeneralFixZoneServiceTest extends TestContainerSupport { @Autowired private FacadeCentralFixZoneService facadeCentralFixZoneService; diff --git a/src/test/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeGeneralVodProcessingJobServiceTest.java b/src/test/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeGeneralVodProcessingJobServiceTest.java new file mode 100644 index 00000000..2616e68b --- /dev/null +++ b/src/test/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeGeneralVodProcessingJobServiceTest.java @@ -0,0 +1,45 @@ +package ddingdong.ddingdongBE.domain.vodprocessing.service; + +import static org.assertj.core.api.Assertions.assertThat; + +import ddingdong.ddingdongBE.common.support.TestContainerSupport; +import ddingdong.ddingdongBE.domain.vodprocessing.entity.ConvertJobStatus; +import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob; +import ddingdong.ddingdongBE.domain.vodprocessing.repository.VodProcessingJobRepository; +import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand; +import java.util.Optional; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class FacadeGeneralVodProcessingJobServiceTest extends TestContainerSupport { + + @Autowired + private FacadeVodProcessingJobService facadeVodProcessingJobService; + @Autowired + private VodProcessingJobRepository vodProcessingJobRepository; + + @DisplayName("VodProcessingJob 생성: PENDING") + @Test + void createPendingVodProcessingJob() { + //given + String convertJobId = "testId"; + String userId = "testId"; + CreatePendingVodProcessingJobCommand command = new CreatePendingVodProcessingJobCommand( + convertJobId, userId); + + //when + Long createdPendingVodProcessingJobId = facadeVodProcessingJobService.create(command); + + //then + Optional result = vodProcessingJobRepository.findById(createdPendingVodProcessingJobId); + assertThat(result).isPresent(); + assertThat(result.get()) + .extracting(VodProcessingJob::getConvertJobId, VodProcessingJob::getUserId, + VodProcessingJob::getConvertJobStatus) + .containsExactly(convertJobId, userId, ConvertJobStatus.PENDING); + } + +} diff --git a/src/test/java/ddingdong/ddingdongBE/file/service/S3FileServiceTest.java b/src/test/java/ddingdong/ddingdongBE/file/service/S3FileServiceTest.java index 5f5ba6c6..a15d9a85 100644 --- a/src/test/java/ddingdong/ddingdongBE/file/service/S3FileServiceTest.java +++ b/src/test/java/ddingdong/ddingdongBE/file/service/S3FileServiceTest.java @@ -36,10 +36,10 @@ class S3FileServiceTest extends TestContainerSupport { void generatePreSignedUrlRequest() { //given LocalDateTime now = LocalDateTime.now(); - String authId = "test"; + Long userId = 1L; String fileName = "image.jpg"; GeneratePreSignedUrlRequestCommand command = - new GeneratePreSignedUrlRequestCommand(now, authId, fileName); + new GeneratePreSignedUrlRequestCommand(now, userId, fileName); //when GeneratePreSignedUrlRequestQuery query = s3FileService.generatePresignedUrlRequest(command); @@ -56,9 +56,9 @@ void generatePreSignedUrlRequest() { .isEqualTo("image/jpeg"); assertThat(request.getKey()) - .as("Key should contain correct date, authId, and fileId") + .as("Key should contain correct date, userId, and fileId") .contains(String.format("%s/%d-%d-%d/%s/", - "IMAGE", now.getYear(), now.getMonthValue(), now.getDayOfMonth(), authId)) + "IMAGE", now.getYear(), now.getMonthValue(), now.getDayOfMonth(), userId)) .contains(fileId.toString()); }); assertThat(Pattern.matches(UUID7_PATTERN.pattern(), fileId.toString())).isTrue(); @@ -75,9 +75,9 @@ void generatePreSignedUrlRequest() { void generateVIDEOPreSignedUrlRequest(String fileName) { //given LocalDateTime now = LocalDateTime.now(); - String authId = "test"; + Long userId = 1L; GeneratePreSignedUrlRequestCommand command = - new GeneratePreSignedUrlRequestCommand(now, authId, fileName); + new GeneratePreSignedUrlRequestCommand(now, userId, fileName); //when GeneratePreSignedUrlRequestQuery query = s3FileService.generatePresignedUrlRequest(command); @@ -91,9 +91,9 @@ void generateVIDEOPreSignedUrlRequest(String fileName) { .as("Content type should match the video's MIME type") .isEqualTo(expectedContentType(fileName)); assertThat(request.getKey()) - .as("Key should contain correct date, authId, and fileId") + .as("Key should contain correct date, userId, and fileId") .contains(String.format("%s/%d-%d-%d/%s/", - "VIDEO", now.getYear(), now.getMonthValue(), now.getDayOfMonth(), authId)) + "VIDEO", now.getYear(), now.getMonthValue(), now.getDayOfMonth(), userId)) .contains(id.toString()); assertThat(Pattern.matches(UUID7_PATTERN.pattern(), id.toString())).isTrue();