-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
343 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
backend/bang-ggood/src/main/java/com/bang_ggood/checklist/domain/Grade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
package com.bang_ggood.checklist.domain; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum Grade { | ||
|
||
GOOD(3), | ||
SOSO(2), | ||
BAD(1); | ||
|
||
private final int score; | ||
|
||
Grade(int score) { | ||
this.score = score; | ||
} | ||
|
||
public static int calculateMaxScore(int size) { | ||
return GOOD.score * size; | ||
} | ||
|
||
public static int getScore(String answer) { | ||
return Arrays.stream(values()) | ||
.filter(grade -> grade.name().equals(answer)) | ||
.findAny() | ||
.get() | ||
.score; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/bang-ggood/src/main/java/com/bang_ggood/checklist/dto/BadgeResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
import com.bang_ggood.category.domain.Badge; | ||
|
||
public record BadgeResponse(String shortName, String longName) { | ||
|
||
public static BadgeResponse from(Badge badge) { | ||
return new BadgeResponse(badge.getShortDescriptionWithEmoji(), badge.getLongDescriptionWithEmoji()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
backend/bang-ggood/src/main/java/com/bang_ggood/checklist/dto/CategoryScoreReadResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
public record CategoryScoreReadResponse( | ||
Integer categoryId, String categoryName, Integer score | ||
) { | ||
} |
29 changes: 29 additions & 0 deletions
29
...ang-ggood/src/main/java/com/bang_ggood/checklist/dto/ChecklistComparisonReadResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
import com.bang_ggood.checklist.domain.Checklist; | ||
import java.util.List; | ||
|
||
public record ChecklistComparisonReadResponse( | ||
Long checklistId, String roomName, String address, | ||
Integer floor, Integer deposit, Integer rent, | ||
Integer contractTerm, String station, Integer walkingTime, | ||
Integer optionCount, Integer score, | ||
List<CategoryScoreReadResponse> categories | ||
) { | ||
public static ChecklistComparisonReadResponse of(Checklist checklist, int checklistOptionCount, int checklistScore, List<CategoryScoreReadResponse> categoryScores) { | ||
return new ChecklistComparisonReadResponse( | ||
checklist.getId(), | ||
checklist.getRoomName(), | ||
checklist.getRoomAddress(), | ||
checklist.getRoomFloor(), | ||
checklist.getDeposit(), | ||
checklist.getRent(), | ||
checklist.getContractTerm(), | ||
checklist.getRoomStation(), | ||
checklist.getRoomWalkingTime(), | ||
checklistOptionCount, | ||
checklistScore, | ||
categoryScores | ||
); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ng-ggood/src/main/java/com/bang_ggood/checklist/dto/ChecklistsComparisonReadResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
import java.util.List; | ||
|
||
public record ChecklistsComparisonReadResponse(List<ChecklistComparisonReadResponse> checklists) { | ||
} |
22 changes: 22 additions & 0 deletions
22
...d/bang-ggood/src/main/java/com/bang_ggood/checklist/dto/UserChecklistPreviewResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
import com.bang_ggood.checklist.domain.Checklist; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public record UserChecklistPreviewResponse( | ||
Long checklistId, String roomName, String address, | ||
Integer deposit, Integer rent, LocalDateTime createdAt, | ||
List<BadgeResponse> badge) { | ||
|
||
public static UserChecklistPreviewResponse of(Checklist checklist, List<BadgeResponse> badges) { | ||
return new UserChecklistPreviewResponse( | ||
checklist.getId(), | ||
checklist.getRoomName(), | ||
checklist.getRoomAddress(), | ||
checklist.getDeposit(), | ||
checklist.getRent(), | ||
checklist.getCreatedAt(), | ||
badges); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
.../bang-ggood/src/main/java/com/bang_ggood/checklist/dto/UserChecklistsPreviewResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.bang_ggood.checklist.dto; | ||
|
||
import java.util.List; | ||
|
||
public record UserChecklistsPreviewResponse(List<UserChecklistPreviewResponse> checklists) { | ||
} |
3 changes: 3 additions & 0 deletions
3
...ng-ggood/src/main/java/com/bang_ggood/checklist/repository/ChecklistOptionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package com.bang_ggood.checklist.repository; | ||
|
||
import com.bang_ggood.checklist.domain.Checklist; | ||
import com.bang_ggood.checklist.domain.ChecklistOption; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ChecklistOptionRepository extends JpaRepository<ChecklistOption, Long> { | ||
|
||
Integer countByChecklist(Checklist checklist); | ||
} |
5 changes: 5 additions & 0 deletions
5
...end/bang-ggood/src/main/java/com/bang_ggood/checklist/repository/ChecklistRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.bang_ggood.checklist.repository; | ||
|
||
import com.bang_ggood.checklist.domain.Checklist; | ||
import com.bang_ggood.user.domain.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import java.util.List; | ||
|
||
public interface ChecklistRepository extends JpaRepository<Checklist, Long> { | ||
|
||
List<Checklist> findByUser(User user); | ||
List<Checklist> findByUserAndIdIn(User user, List<Long> checklistIds); | ||
} |
Oops, something went wrong.