Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -21,7 +21,7 @@ public class Comment extends BaseEntity {
private String content;

@Column(nullable = false)
private LocalDateTime date = LocalDateTime.now();
private LocalDateTime date;

//외래키 이름은 postId로 저장되도록 함.
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Service
Expand All @@ -29,6 +28,7 @@ public Comment addComment(Member member, long postId, String content) {
.content(content)
.post(post)
.member(member)
.date(LocalDateTime.now())
.build();
commentRepository.save(newComment);
return newComment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public MemberResponseDTO.MyPageResponse getMyPageInfo(Member member) {

LocalDateTime now = LocalDateTime.now();

LocalDateTime firstDayOfMonth = now.withDayOfMonth(1);
LocalDateTime lastDayOfMonth = now;
LocalDateTime startOfMonth = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime endOfMonth = now.withHour(23).withMinute(59).withSecond(59).withNano(999999999);

int blackCount = calendarRepository.countByMemberAndColorAndDateBetween(member, Color.BLACK, firstDayOfMonth, lastDayOfMonth);
int blackCount = calendarRepository.countByMemberAndColorAndDateBetween(member, Color.BLACK, startOfMonth, endOfMonth);

int totalCount = calendarRepository.countByMemberAndDateBetween(member, firstDayOfMonth, lastDayOfMonth);
int totalCount = calendarRepository.countByMemberAndDateBetween(member, startOfMonth, endOfMonth);

float rating = totalCount == 0 ? 0 : ((float) blackCount / totalCount) * 100;

Expand Down
Loading