Skip to content

Conversation

@handagyeong
Copy link

#️⃣연관된 이슈

📝작업 내용

  • 오늘의 심리지식 조회
  • 심리지식 북마크
  • 심리지식 북마크 삭제
  • 북마크한 심리지식 목록 조회
  • 물병 표시 여부 조회

📝 기타 참고사항

  • /psychology/daily/status 로 화면 물병 표시 여부 조회하는 api를 추가했습니다!

# Conflicts:
#	src/main/java/com/example/egobook_be/domain/user/entity/User.java
#	src/main/java/com/example/egobook_be/domain/user/entity/UserStatus.java
#	src/main/java/com/example/egobook_be/domain/user/repository/UserRepository.java
#	src/main/java/com/example/egobook_be/global/config/SecurityConfig.java
Comment on lines +53 to +64
if (candidates.isEmpty()) candidates = psychologyKnowledgeRepository.findAll();

// 3. 오늘 지식 확정 및 DB 저장
long seed = userId + LocalDate.now().toEpochDay();
PsychologyKnowledge picked = candidates.get(new Random(seed).nextInt(candidates.size()));

// 조회 기록 남기기
UserKnowledge newHistory = new UserKnowledge(user, picked);
newHistory.setBookmarked(false); // 처음엔 조회만 한 상태
userKnowledgeRepository.save(newHistory);

return createResponse(user, picked, false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순 DB 저장이 아닌, 유저 ID와 날짜를 조합한 seed 기반 랜덤을 사용해 하루 동안 결과가 일관되게 유지되는 점 좋은 것 같습니다!
다만 모든 심리 지식을 조회한 이후 리셋되어 (candidates.isEmpty())가 실행되는 흐름에서, 기존 조회 기록을 삭제하거나 별도의 처리가 없다면 그 다음 날부터도 viewedIds가 항상 전체를 포함하게 되어 매일 전체 랜덤으로 동작하게 되는 구조가 아닐지 우려됩니다. 이 경우 기존 조회 데이터를 찾아 시각을 업데이트하는 등의 처리가 선택지가 될 수도 있을 것 같습니다! 또한 리셋 이후 북마크(유리병) 여부와 상관없이 다시 오늘의 심리 지식으로 노출될 수 있는 상태가 맞는지도 궁금합니다.

Comment on lines +41 to +48
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;

// 데이터가 처음 저장될 때 현재 시간을 자동으로 넣어주는 마법의 메서드야!
@PrePersist
protected void onCreate() {
this.createdAt = LocalDateTime.now();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통으로 사용 중인 BaseTimeEntity를 상속받아 사용하는 방식도 일관성을 위해 고려해볼 수 있을 것 같습니다!

@nahjjun nahjjun assigned nahjjun and handagyeong and unassigned nahjjun Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants