-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-56] Vod Processing Job 생성 API 구현 (#195)
- Loading branch information
Showing
30 changed files
with
361 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ava/ddingdong/ddingdongBE/domain/vodprocessing/controller/VodProcessingJobController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...gBE/domain/vodprocessing/controller/dto/request/CreatePendingVodProcessingJobRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/ConvertJobStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ddingdong.ddingdongBE.domain.vodprocessing.entity; | ||
|
||
public enum ConvertJobStatus { | ||
PENDING | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodNotificationStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ddingdong.ddingdongBE.domain.vodprocessing.entity; | ||
|
||
public enum VodNotificationStatus { | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ain/java/ddingdong/ddingdongBE/domain/vodprocessing/entity/VodProcessingNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ava/ddingdong/ddingdongBE/domain/vodprocessing/repository/VodProcessingJobRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<VodProcessingJob, Long> { | ||
|
||
Optional<VodProcessingJob> findByConvertJobId(String convertJobId); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...ava/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...va/ddingdong/ddingdongBE/domain/vodprocessing/service/GeneralVodProcessingJobService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 + ")를 찾을 수 없습니다.")); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/VodProcessingJobService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...dongBE/domain/vodprocessing/service/dto/command/CreatePendingVodProcessingJobCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
Oops, something went wrong.