-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into develop
- Loading branch information
Showing
10 changed files
with
135 additions
and
23 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
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
2 changes: 2 additions & 0 deletions
2
...main/java/com/example/wineydomain/tastingNote/repository/TastingNoteCustomRepository.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,9 @@ | ||
package com.example.wineydomain.tastingNote.repository; | ||
|
||
import com.example.wineydomain.tastingNote.entity.TastingNote; | ||
import com.example.wineydomain.wine.entity.WineSummary; | ||
|
||
public interface TastingNoteCustomRepository { | ||
TastingNote getTastingNote(Long noteId, boolean deleted); | ||
|
||
} |
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
37 changes: 37 additions & 0 deletions
37
Winey-Domain/src/main/java/com/example/wineydomain/wine/entity/WineSummary.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,37 @@ | ||
package com.example.wineydomain.wine.entity; | ||
|
||
import lombok.*; | ||
|
||
import java.util.Optional; | ||
|
||
@NoArgsConstructor | ||
@Getter @Setter | ||
@AllArgsConstructor | ||
public class WineSummary { | ||
private Double avgPrice; | ||
private Integer avgSweetness; | ||
private Integer avgAcidity; | ||
private Integer avgBody; | ||
private Integer avgTannins; | ||
|
||
// 쿼리 결과를 위한 생성자 | ||
public WineSummary(Double avgPrice, Double avgSweetness, Double avgAcidity, Double avgBody, Double avgTannins) { | ||
this.avgPrice = roundToFirstDecimal(avgPrice); | ||
this.avgSweetness = roundOrDefault(avgSweetness); | ||
this.avgAcidity = roundOrDefault(avgAcidity); | ||
this.avgBody = roundOrDefault(avgBody); | ||
this.avgTannins = roundOrDefault(avgTannins); | ||
} | ||
|
||
private Double roundToFirstDecimal(Double value) { | ||
return Optional.ofNullable(value) | ||
.map(v -> Math.round(v * 10.0) / 10.0) | ||
.orElse(0.0); | ||
} | ||
|
||
private int roundOrDefault(Double value) { | ||
return Optional.ofNullable(value) | ||
.map(v -> (int) Math.round(v)) | ||
.orElse(0); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Winey-Domain/src/main/java/com/example/wineydomain/wine/exception/ReadWineErrorCode.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,44 @@ | ||
package com.example.wineydomain.wine.exception; | ||
|
||
import com.example.wineycommon.annotation.ExplainError; | ||
import com.example.wineycommon.exception.errorcode.BaseErrorCode; | ||
import com.example.wineycommon.exception.errorcode.ErrorReason; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
|
||
import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ReadWineErrorCode implements BaseErrorCode { | ||
/** | ||
* WXXX : Wine 관련 에러 | ||
*/ | ||
NOT_EXIST_WINE(BAD_REQUEST,"W001" , "해당 와인이 존재하지 않습니다."); | ||
|
||
|
||
private final HttpStatus httpStatus; | ||
private final String code; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorReason getErrorReason() { | ||
return ErrorReason.builder().message(message).code(code).isSuccess(false).build(); | ||
} | ||
|
||
@Override | ||
public String getExplainError() throws NoSuchFieldException { | ||
Field field = this.getClass().getField(this.name()); | ||
ExplainError annotation = field.getAnnotation(ExplainError.class); | ||
return Objects.nonNull(annotation) ? annotation.value() : this.getMessage(); | ||
} | ||
|
||
@Override | ||
public ErrorReason getErrorReasonHttpStatus(){ | ||
return ErrorReason.builder().message(message).code(code).isSuccess(false).httpStatus(httpStatus).build(); | ||
} | ||
} |