Skip to content

Commit

Permalink
Merge pull request #129 from 9uttery/fix/integration-error-#128
Browse files Browse the repository at this point in the history
[Fix] 연동 중 에러 수정
  • Loading branch information
mingeun0507 authored Feb 21, 2024
2 parents ca858e5 + 6061784 commit cf43eab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void finish(final Satisfaction satisfaction) {
}

public void rate(final Satisfaction satisfaction) {
this.finishInfo = FinishInfo.createFinished(satisfaction);
this.finishInfo = FinishInfo.updateSatisfaction(this.finishInfo, satisfaction);
}

public void cancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public static FinishInfo createFinished(Satisfaction satisfaction) {
return new FinishInfo(true, LocalDateTime.now(), satisfaction);
}

public static FinishInfo updateSatisfaction(FinishInfo finishInfo, Satisfaction satisfaction) {
return new FinishInfo(finishInfo.isFinished, finishInfo.finishedAt, satisfaction);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@

@Schema(description = "가장 많이 기록된 소확행 정보")
public record MostAchievedJoyInfo(
@Schema(description = "소확행 ID", example = "1")
Long joyId,
@Schema(description = "소확행 아이콘 번호", example = "1")
Integer joyIconNum,
@Schema(description = "소확행 내용", example = "붕어방 먹기")
String contents,
@Schema(description = "내가 기록한 소확행 여부", example = "true")
Boolean isCreatedByMe,
@Schema(description = "소확행 기록 횟수", example = "10")
Integer achieveCount,
@Schema(description = "많이 기록된 소확행 순위", example = "1")
Integer rank
) {
public static MostAchievedJoyInfo fromProjection(MostAchievedJoyInfoProjection projection) {
return new MostAchievedJoyInfo(
projection.getJoyId(),
projection.getJoyIconNum(),
projection.getContents(),
projection.getIsCreatedByMe() != 0,
projection.getAchieveCount(),
projection.getAchieveRank()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.guttery.madii.domain.joy.application.dto;

public interface MostAchievedJoyInfoProjection {
Long getJoyId();
Integer getJoyIconNum();

String getContents();

Integer getIsCreatedByMe();
Integer getAchieveCount();

Integer getAchieveRank();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
public interface JoyRepository extends JpaRepository<Joy, Long> {
String getMostAchievedJoyQuery =
"SELECT " +
" joyId, " +
" joyIconNum, " +
" contents, " +
" isCreatedByMe, " +
" achieveCount, " +
" achieveRank " +
"FROM ( " +
" SELECT " +
" j.joy_icon_num AS joyIconNum, " +
" j.contents AS contents, " +
" COUNT(a.achievement_id) AS achieveCount, " +
" DENSE_RANK() OVER (ORDER BY COUNT(a.achievement_id) DESC) AS achieveRank " +
" j.joy_id AS joyId, " +
" j.joy_icon_num AS joyIconNum, " +
" j.contents AS contents, " +
" IF(j.creator_id = :userId, true, false) AS isCreatedByMe, " +
" COUNT(a.achievement_id) AS achieveCount, " +
" DENSE_RANK() OVER (ORDER BY COUNT(a.achievement_id) DESC) AS achieveRank " +
" FROM " +
" t_joy j " +
" LEFT JOIN " +
Expand Down

0 comments on commit cf43eab

Please sign in to comment.