Skip to content

Commit

Permalink
[DEV-56] Vod Processing Job 생성 API 구현 (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Jan 3, 2025
1 parent 1c8f104 commit 7d0a54d
Show file tree
Hide file tree
Showing 30 changed files with 361 additions and 41 deletions.
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,28 @@ 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 {
dependsOn test
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"
])
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class DocumentServiceImpl implements DocumentService {
public class GeneralDocumentService implements DocumentService {

private final DocumentRepository documentRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
@Transactional(readOnly = true)
public class FacadeFeedService {

private final FeedService feedService;
private final GeneralFeedService generalFeedService;
private final FileInformationService fileInformationService;

public List<FeedListQuery> getAllByClubId(Long clubId) {
List<Feed> feeds = feedService.getAllByClubId(clubId);
List<Feed> feeds = generalFeedService.getAllByClubId(clubId);
return feeds.stream()
.map(FeedListQuery::from)
.toList();
}

public List<FeedListQuery> getNewestAll() {
List<Feed> feeds = feedService.getNewestAll();
List<Feed> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class FeedService {
public class GeneralFeedService {

private final FeedRepository feedRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class FixZoneServiceImpl implements FixZoneService {
public class GeneralFixZoneService implements FixZoneService {

private final FixZoneRepository fixZoneRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
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());
}

}
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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ddingdong.ddingdongBE.domain.vodprocessing.entity;

public enum ConvertJobStatus {
PENDING
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ddingdong.ddingdongBE.domain.vodprocessing.entity;

public enum VodNotificationStatus {
}
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;
}
}
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;

}
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);

}
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);

}
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());
}
}
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 + ")를 찾을 수 없습니다."));
}
}
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);

}
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();
}

}
Loading

0 comments on commit 7d0a54d

Please sign in to comment.