Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b3037cb
사용자 정보 API 필드 이름 통일 및 put preferType 추가
JaehoonJung0430 Feb 19, 2025
074bb57
사용자 정보 API 필드 이름 통일 및 put preferType 추가
JaehoonJung0430 Feb 19, 2025
b9d643a
feat : 컬렉션 상세 페이지 내부 에피소드 정보 수정
MODUGGAGI Feb 19, 2025
db61dbd
Merge pull request #199 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 19, 2025
dc2e779
Merge pull request #200 from TeamLearningFlow/develop
MODUGGAGI Feb 19, 2025
7312cbb
feat : 구글 로그인 수정
MODUGGAGI Feb 19, 2025
fdc316c
Merge pull request #201 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 19, 2025
dc3e0f1
Merge pull request #202 from TeamLearningFlow/develop
MODUGGAGI Feb 19, 2025
54527cb
feat : 구글 로그인 수정
MODUGGAGI Feb 19, 2025
3a331b2
Merge pull request #203 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 19, 2025
0a1bb3e
Merge pull request #204 from TeamLearningFlow/develop
MODUGGAGI Feb 19, 2025
5b80030
/resources/{episodeId}/save-progress api response에 isCompleted추가
LJYeon12 Feb 19, 2025
7d987cc
Merge pull request #206 from TeamLearningFlow/feat/205/save-progress-…
LJYeon12 Feb 19, 2025
9b3e6a7
Merge pull request #207 from TeamLearningFlow/develop
LJYeon12 Feb 19, 2025
b6f1a3c
update_at 미반영 문제 해결
LJYeon12 Feb 19, 2025
ba12b25
Merge pull request #209 from TeamLearningFlow/bug/208/save-progress-u…
LJYeon12 Feb 19, 2025
66bdd38
Merge pull request #210 from TeamLearningFlow/develop
LJYeon12 Feb 19, 2025
0213fea
jdbc 시간 한국 시간으로 변경
LJYeon12 Feb 19, 2025
84076bf
Merge pull request #211 from TeamLearningFlow/bug/208/save-progress-u…
LJYeon12 Feb 19, 2025
9861e17
Merge pull request #212 from TeamLearningFlow/develop
LJYeon12 Feb 19, 2025
0628e98
feat : RefreshToken 유효기간 삭제
MODUGGAGI Feb 20, 2025
9eb5388
feat : 각 에피소드의 completed 필드 가져오는 로직 변경
MODUGGAGI Feb 20, 2025
90f5fec
feat : 진도율 계산 로직 수정
MODUGGAGI Feb 20, 2025
abccdbe
Merge pull request #214 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 20, 2025
a3d3511
Merge pull request #215 from TeamLearningFlow/develop
MODUGGAGI Feb 20, 2025
31176e5
수강 완료 변경
LJYeon12 Feb 20, 2025
fc4d9d2
Merge pull request #216 from TeamLearningFlow/213-feat-컬렉션-수강-완료-변경
LJYeon12 Feb 20, 2025
d32b032
Merge pull request #217 from TeamLearningFlow/develop
LJYeon12 Feb 20, 2025
49c613b
feat : 오류 수정
MODUGGAGI Feb 20, 2025
84aad46
Merge pull request #218 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 20, 2025
19a1e8e
Merge pull request #219 from TeamLearningFlow/develop
MODUGGAGI Feb 20, 2025
97b8655
feat : 오류 수정
MODUGGAGI Feb 20, 2025
9f5e187
Merge pull request #220 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 20, 2025
ca617f5
Merge pull request #221 from TeamLearningFlow/develop
MODUGGAGI Feb 20, 2025
d9362f8
feat : 마이페이지 최근 학습 컬렉션 조회시 정렬 기준 UpdatedAt 기준으로 내림차순 정렬로 변경
MODUGGAGI Feb 20, 2025
d2a8fb6
Merge pull request #222 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 20, 2025
5189d5c
Merge pull request #223 from TeamLearningFlow/develop
MODUGGAGI Feb 20, 2025
67f7879
feat : 마이페이지 resource 수정
MODUGGAGI Feb 20, 2025
d9ae624
Merge pull request #224 from TeamLearningFlow/feat/191/modify
MODUGGAGI Feb 20, 2025
96f967f
Merge pull request #225 from TeamLearningFlow/develop
MODUGGAGI Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public enum ErrorStatus implements BaseErrorCode {
// Resource 에러
RESOURCE_NOT_FOUND(HttpStatus.NOT_FOUND, "RESOURCE4001", "존재하지 않는 리소스 입니다."),

USER_COLLECTION_NOT_FOUND(HttpStatus.NOT_FOUND, "USER COLLECTION4001", "존재하지 않는 리소스 입니다."),

// User Progress
USER_PROGRESS_NOT_FOUND(HttpStatus.NOT_FOUND, "USER-PROGRESS4001", "진도 값이 null 인 상태입니다.");
private final HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static CollectionResponseDTO.CollectionPreviewDTO toCollectionPreviewDTO(
.likesCount(collection.getBookmarkCount()) //북마크 -> 좋아요로 이름만 변경
.isLiked(currentUser != null && currentUser.hasBookmarked(collection.getId())) //북마크 -> 좋아요로 이름만 변경
.progressRatePercentage(learningInfo.getProgressRate())
.progressRatio(calculateProgressRatio(collection, learningInfo))
.progressRatio(learningInfo.getProgressRatio())
.learningStatus(learningInfo.getLearningStatus())
.startDate(learningInfo.getStartDate())
.completedDate(learningInfo.getCompletedDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public static List<ResourceResponseDTO.episodeInformation> episodeInformationLis
return episodeInformationList;
}

public static ResourceResponseDTO.ProgressResponseDTO toSaveProgressResponse(ResourceRequestDTO.ProgressRequestDTO request) {
public static ResourceResponseDTO.ProgressResponseDTO toSaveProgressResponse(ResourceRequestDTO.ProgressRequestDTO request, Boolean isCompleted) {
return ResourceResponseDTO.ProgressResponseDTO.builder()
.progress(request.getProgress())
.resourceType(request.getResourceType())
.isCompleted(isCompleted)
.build();
}

Expand All @@ -76,6 +77,26 @@ public static ResourceResponseDTO.changeEpisodeIsCompleteDTO toChangeEpisodeIsCo
.build();
}

public static ResourceResponseDTO.SearchResultResourceDTO convertToResourceDTO(
CollectionEpisode episode,
UserEpisodeProgress userProgress, // added: 사용자 진도 정보 추가
Integer currentEpisodeNumber // added: 현재 학습 중인 에피소드 번호 추가
) {
return ResourceResponseDTO.SearchResultResourceDTO.builder()
.episodeId(episode.getId())
.episodeName(episode.getEpisodeName())
.url(episode.getResource().getUrl())
.resourceSource(extractResourceSource(episode.getResource().getUrl()))
.episodeNumber(episode.getEpisodeNumber())
// added: today 값 설정 - 다음 학습할 에피소드인지 확인
.today(episode.getEpisodeNumber().equals(currentEpisodeNumber + 1))
// added: completed 값 설정 - 현재 에피소드보다 번호가 작으면 완료된 것
.completed(userProgress != null && userProgress.getIsComplete())
// added: progress 값 설정 - 해당 에피소드의 진도율
.progress(userProgress != null ? userProgress.getCurrentProgress() : null)
.build();
}

public static ResourceResponseDTO.SearchResultResourceDTO convertToResourceDTO(
CollectionEpisode episode,
UserEpisodeProgress progress
Expand All @@ -101,18 +122,27 @@ public static ResourceResponseDTO.RecentlyWatchedEpisodeDTO convertToRecentlyWat
UserEpisodeProgress userEpisodeProgress
) {
return ResourceResponseDTO.RecentlyWatchedEpisodeDTO.builder()
.resourceId(getResourceId(userCollection))
.episodeId(getEpisodeId(userCollection))
.collectionId(userCollection.getCollection().getId())
.collectionTitle(userCollection.getCollection().getTitle())
.resourceSource(extractResourceSource(getResourceUrl(userCollection)))
.episodeNumber(userCollection.getUserCollectionStatus())
.episodeName(getEpisodeName(userCollection))
.progressRatio(calculateProgressRatio(userCollection))
.currentProgress(userEpisodeProgress.getCurrentProgress())
.totalProgress(userEpisodeProgress.getTotalProgress())
.currentProgress(userEpisodeProgress != null ? userEpisodeProgress.getCurrentProgress() : 0)
.totalProgress(userEpisodeProgress != null ? userEpisodeProgress.getTotalProgress() : 0)
.build();
}

private static Long getEpisodeId(UserCollection userCollection) {
// added: episodeId를 찾는 메소드 추가
return userCollection.getCollection().getEpisodes().stream()
.filter(episode -> episode.getEpisodeNumber().equals(userCollection.getUserCollectionStatus()))
.findFirst()
.map(CollectionEpisode::getId)
.orElse(null);
}

public static List<ResourceResponseDTO.SearchResultResourceDTO> convertToResourceDTOWithToday(
List<CollectionEpisode> episodes,
int nextEpisodeNumber,
Expand All @@ -131,6 +161,29 @@ public static List<ResourceResponseDTO.SearchResultResourceDTO> convertToResourc
.toList();
}

public static ResourceResponseDTO.RecentlyWatchedEpisodeDTO convertToRecentlyWatchedEpisodeDTO(
UserCollection userCollection,
UserEpisodeProgress userEpisodeProgress,
CollectionEpisode currentEpisode, // added: 파라미터 추가
int totalEpisodes, // added: 파라미터 추가
double progressPercentage // added: 파라미터 추가
) {
return ResourceResponseDTO.RecentlyWatchedEpisodeDTO.builder()
.episodeId(currentEpisode.getId())
.collectionId(userCollection.getCollection().getId())
.collectionTitle(userCollection.getCollection().getTitle())
.resourceSource(extractResourceSource(currentEpisode.getResource().getUrl()))
.episodeNumber(userCollection.getUserCollectionStatus())
.episodeName(currentEpisode.getEpisodeName())
.progressRatio(String.format("%d / %d회차 (%.0f%%)",
userCollection.getUserCollectionStatus(),
totalEpisodes,
progressPercentage))
.currentProgress(userEpisodeProgress != null ? userEpisodeProgress.getCurrentProgress() : 0)
.totalProgress(userEpisodeProgress != null ? userEpisodeProgress.getTotalProgress() : 0)
.build();
}

public static String extractResourceSource(String url) {

String lowerCaseUrl = url.toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ public void updateUserCollection(Integer userCollectionStatus) {
this.userCollectionStatus = userCollectionStatus;
this.completedTime = LocalDate.now();
}
public void CompleteUserCollection(){
this.status = UserCollectionStatus.COMPLETED;
this.completedTime = LocalDate.now();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public interface UserCollectionRepository extends JpaRepository<UserCollection, Long> {
Optional<UserCollection> findByUserAndCollection(User user, Collection collection);
List<UserCollection> findByUserAndStatusOrderByCompletedTimeDesc(User user, UserCollectionStatus status);
List<UserCollection> findByUserAndStatusOrderByUpdatedAtDesc(User user, UserCollectionStatus status);
Optional<UserCollection> findFirstByUserAndStatusOrderByUpdatedAtDesc(User user, UserCollectionStatus status);

@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
.build();
response.setHeader(HttpHeaders.SET_COOKIE, cookie.toString());


response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Expose-Headers", "Authorization, Refresh-Token");



// ⭐️ 팝업 창을 닫고 부모 창에 메시지 전달하는 스크립트 (프론트엔드 도메인 사용)
String redirectScript = "<script>" +
" window.opener.postMessage({" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@ConfigurationProperties(prefix = "custom.jwt")
public class JwtProperties {
private long accessTokenValidityInSeconds = 3600; // 1시간
private long refreshTokenValidityInSeconds = 604800; // 1주일
//private long refreshTokenValidityInSeconds = 604800; // 1주일
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public String createRefreshToken(Authentication authentication) {
User user = principalDetails.getUser();

Date now = new Date();
Date validity = new Date(now.getTime() + jwtProperties.getRefreshTokenValidityInSeconds() * 1000);
//Date validity = new Date(now.getTime() + jwtProperties.getRefreshTokenValidityInSeconds() * 1000);

return Jwts.builder()
.subject(user.getEmail())
.issuedAt(now)
.expiration(validity)
//.expiration(validity)
.signWith(jwtSecretKey)
.compact();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

Expand All @@ -16,11 +17,13 @@ public class AuthTokenCleanupScheduler {
private final PasswordResetTokenRepository tokenRepository;

@Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행
@Transactional
public void cleanupExpiredTokens() {
tokenRepository.deleteByExpiryDateBefore(LocalDateTime.now());
}

@Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행
@Transactional
public void cleanupExpiredEmailVerificationTokens() {
emailVerificationTokenRepository.deleteByExpiryDateBefore(LocalDateTime.now());
}
Expand Down
Loading