Skip to content

Commit

Permalink
[release] v.1.2.1 (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: 5uhwann <[email protected]>
  • Loading branch information
KoSeonJe and 5uhwann authored Jan 28, 2025
1 parent 6c12b96 commit fbb6da7
Show file tree
Hide file tree
Showing 15 changed files with 323 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/codeowners
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @wonjunYou @5uhwann @KoSeonJe
* @wonjunYou @5uhwann @KoSeonJe @Seooooo24
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ddingdong.ddingdongBE.domain.club.entity.Club;
import java.util.Optional;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -10,4 +11,6 @@ public interface ClubRepository extends JpaRepository<Club, Long> {

Optional<Club> findByUserId(Long userId);

@EntityGraph(attributePaths = {"clubMembers"})
Optional<Club> findEntityGraphByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ public interface ClubService {

void delete(Long clubId);



Club getByUserIdWithFetch(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import ddingdong.ddingdongBE.domain.club.repository.ClubRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
@Slf4j
public class GeneralClubService implements ClubService {

private final ClubRepository clubRepository;
Expand All @@ -34,6 +36,11 @@ public Club getByUserId(Long userId) {
.orElseThrow(() -> new ResourceNotFound("Club(userId=" + userId + ")를 찾을 수 없습니다."));
}

@Override
public Club getByUserIdWithFetch(Long userId) {
return clubRepository.findEntityGraphByUserId(userId)
.orElseThrow(() -> new ResourceNotFound("Club(userId=" + userId + ")를 찾을 수 없습니다.")); }

@Override
public List<Club> findAll() {
return clubRepository.findAll();
Expand All @@ -51,5 +58,4 @@ public void delete(Long clubId) {
Club club = getById(clubId);
clubRepository.delete(club);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
@Slf4j
public class FacadeCentralClubMemberServiceImpl implements FacadeCentralClubMemberService {

private final ClubService clubService;
Expand All @@ -32,7 +34,7 @@ public byte[] getClubMemberListFile(Long userId) {

@Override
public AllClubMemberInfoQuery getAllMyClubMember(Long userId) {
Club club = clubService.getByUserId(userId);
Club club = clubService.getByUserIdWithFetch(userId);
return AllClubMemberInfoQuery.of(club.getName(), club.getClubMembers());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@
public interface FeedRepository extends JpaRepository<Feed, Long> {

@Query(value = """
select *
from feed f
where (:currentCursorId = -1 or id < :currentCursorId)
and f.club_id = :clubId
and deleted_at is null
order by f.id DESC
limit :size
""", nativeQuery = true)
select *
from feed f
where (:currentCursorId = -1 or id < :currentCursorId)
and f.club_id = :clubId
and deleted_at is null
and (
f.feed_type != 'VIDEO'
or exists (
select 1
from (
select id
from file_meta_data
where entity_id = f.id
and domain_type = 'FEED_VIDEO'
) filtered_fm
join vod_processing_job vpj
on filtered_fm.id = vpj.file_meta_data_id
where vpj.convert_job_status = 'COMPLETE'
)
)
order by f.id DESC
limit :size
""", nativeQuery = true)
Slice<Feed> findPageByClubIdOrderById(
@Param("clubId") Long clubId,
@Param("size") int size,
Expand All @@ -29,6 +44,21 @@ Slice<Feed> findPageByClubIdOrderById(
(select max(id)
from feed
where deleted_at is null
and (
f.feed_type != 'VIDEO'
or exists (
select 1
from (
select id
from file_meta_data
where entity_id = f.id
and domain_type = 'FEED_VIDEO'
) filtered_fm
join vod_processing_job vpj
on filtered_fm.id = vpj.file_meta_data_id
where vpj.convert_job_status = 'COMPLETE'
)
)
GROUP BY club_id)
and (:currentCursorId = -1 or id < :currentCursorId)
ORDER BY id DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import ddingdong.ddingdongBE.common.exception.PersistenceException.ResourceNotFound;
import ddingdong.ddingdongBE.domain.feed.entity.Feed;
import ddingdong.ddingdongBE.domain.feed.repository.FeedRepository;
import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob;
import ddingdong.ddingdongBE.domain.vodprocessing.service.VodProcessingJobService;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
Expand All @@ -22,7 +19,6 @@
public class GeneralFeedService implements FeedService {

private final FeedRepository feedRepository;
private final VodProcessingJobService vodProcessingJobService;

@Override
public Slice<Feed> getFeedPageByClubId(Long clubId, int size, Long currentCursorId) {
Expand Down Expand Up @@ -61,9 +57,7 @@ public void delete(Feed feed) {
}

private Slice<Feed> buildSlice(Slice<Feed> originalSlice, int size) {
List<Feed> content = new ArrayList<>(originalSlice.getContent()).stream()
.filter(this::isComplete)
.collect(Collectors.toList());
List<Feed> content = new ArrayList<>(originalSlice.getContent());
if (content.isEmpty()) {
return null;
}
Expand All @@ -76,16 +70,4 @@ private Slice<Feed> buildSlice(Slice<Feed> originalSlice, int size) {

return new SliceImpl<>(content, PageRequest.of(originalSlice.getNumber(), size), hasNext);
}

private boolean isComplete(Feed feed) {
if (feed.isImage()) {
return true;
}

VodProcessingJob vodProcessingJob = vodProcessingJobService.findByVideoFeedId(feed.getId());
if (vodProcessingJob == null) {
return false;
}
return vodProcessingJob.isCompleted();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public record AdminScoreHistoryListResponse(

public static AdminScoreHistoryListResponse from(AdminClubScoreHistoryListQuery query) {
return new AdminScoreHistoryListResponse(
query.club().getScore().getValue(),
query.clubTotalScore(),
query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public record ClubScoreHistoryListResponse(

public static ClubScoreHistoryListResponse from(ClubScoreHistoryListQuery query) {
return new ClubScoreHistoryListResponse(
query.club().getScore().getValue(),
query.clubTotalScore(),
query.scoreHistories().stream()
.map(ScoreHistoryResponse::from)
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Long create(CreateScoreHistoryCommand command) {
public AdminClubScoreHistoryListQuery findAllByClubId(Long clubId) {
Club club = clubService.getById(clubId);
List<ScoreHistory> scoreHistories = scoreHistoryService.findAllByClubId(clubId);
return AdminClubScoreHistoryListQuery.of(club, scoreHistories);
return AdminClubScoreHistoryListQuery.of(club.getScore().getValue(), scoreHistories);
}

private BigDecimal roundToThirdPoint(BigDecimal value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.club.service.ClubService;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.AdminClubScoreHistoryListQuery;
import ddingdong.ddingdongBE.domain.scorehistory.service.dto.query.ClubScoreHistoryListQuery;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +21,6 @@ public class FacadeClubScoreHistoryServiceImpl implements FacadeClubScoreHistory
public ClubScoreHistoryListQuery findMyScoreHistories(Long userId) {
Club club = clubService.getByUserId(userId);
List<ScoreHistory> scoreHistories = scoreHistoryService.findAllByClubId(club.getId());
return ClubScoreHistoryListQuery.of(club, scoreHistories);
return ClubScoreHistoryListQuery.of(club.getScore().getValue(), scoreHistories);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package ddingdong.ddingdongBE.domain.scorehistory.service.dto.query;

import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import java.math.BigDecimal;
import java.util.List;

public record AdminClubScoreHistoryListQuery(
Club club,
BigDecimal clubTotalScore,
List<ScoreHistory> scoreHistories
) {

public static AdminClubScoreHistoryListQuery of(Club club, List<ScoreHistory> scoreHistories) {
return new AdminClubScoreHistoryListQuery(club, scoreHistories);
public static AdminClubScoreHistoryListQuery of(BigDecimal clubTotalScore, List<ScoreHistory> scoreHistories) {
return new AdminClubScoreHistoryListQuery(clubTotalScore, scoreHistories);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package ddingdong.ddingdongBE.domain.scorehistory.service.dto.query;

import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.scorehistory.entity.ScoreHistory;
import java.math.BigDecimal;
import java.util.List;

public record ClubScoreHistoryListQuery(
Club club,
BigDecimal clubTotalScore,
List<ScoreHistory> scoreHistories
) {

public static ClubScoreHistoryListQuery of(Club club, List<ScoreHistory> scoreHistories) {
return new ClubScoreHistoryListQuery(club, scoreHistories);
public static ClubScoreHistoryListQuery of(BigDecimal clubTotalScore, List<ScoreHistory> scoreHistories) {
return new ClubScoreHistoryListQuery(clubTotalScore, scoreHistories);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import ddingdong.ddingdongBE.file.service.dto.command.GeneratePreSignedUrlRequestCommand;
import ddingdong.ddingdongBE.file.service.dto.query.GeneratePreSignedUrlRequestQuery;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -22,9 +24,10 @@ public class S3FileController implements S3FileAPi {
public UploadUrlResponse getPreSignedUrl(PrincipalDetails principalDetails, String fileName) {
User user = principalDetails.getUser();
LocalDateTime now = LocalDateTime.now();
String decodedFileName = URLDecoder.decode(fileName, StandardCharsets.UTF_8);
GeneratePreSignedUrlRequestQuery query =
s3FileService.generatePresignedUrlRequest(
new GeneratePreSignedUrlRequestCommand(now, user.getId(), fileName));
new GeneratePreSignedUrlRequestCommand(now, user.getId(), decodedFileName));
URL presingedUrl = s3FileService.getPresignedUrl(query.generatePresignedUrlRequest());
return UploadUrlResponse.of(query, presingedUrl);
}
Expand Down
Loading

0 comments on commit fbb6da7

Please sign in to comment.