From 3809d9ac23c550ccb1281783b73fd993abbd540a Mon Sep 17 00:00:00 2001 From: imenuuu Date: Sat, 5 Oct 2024 01:09:45 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=ED=85=8C=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=ED=8C=85=20=EB=85=B8=ED=8A=B8=20sparkling=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tastingNote/convertor/TastingNoteConvertor.java | 9 +++++++++ .../wineyapi/tastingNote/dto/TastingNoteRequest.java | 6 ++++++ .../wineyapi/tastingNote/dto/TastingNoteResponse.java | 4 ++++ .../wineydomain/tastingNote/entity/QTastingNote.java | 2 ++ .../wineydomain/tastingNote/entity/TastingNote.java | 3 +++ 5 files changed, 24 insertions(+) diff --git a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/convertor/TastingNoteConvertor.java b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/convertor/TastingNoteConvertor.java index f28e364..c095886 100644 --- a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/convertor/TastingNoteConvertor.java +++ b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/convertor/TastingNoteConvertor.java @@ -35,6 +35,7 @@ public TastingNoteResponse.TasteAnalysisDTO TasteAnalysis(List tast int alcoholSum = 0; int bodySum = 0; int tanninSum = 0; + int sparklingSum = 0; int finishSum = 0; int totalPrice = 0; @@ -88,6 +89,7 @@ public TastingNoteResponse.TasteAnalysisDTO TasteAnalysis(List tast alcoholSum += tastingNote.getAlcohol(); bodySum += tastingNote.getBody(); tanninSum += tastingNote.getTannins(); + sparklingSum += tastingNote.getSparkling() != null ? tastingNote.getSparkling() : 0; finishSum += tastingNote.getFinish(); totalPrice += tastingNote.getPrice() != null ? tastingNote.getPrice() : 0; @@ -189,6 +191,7 @@ public int compare(Map.Entry entry1, Map.Entry .alcohol(calculateAvg(alcoholSum, totalWineCnt)) .body(calculateAvg(bodySum, totalWineCnt)) .tannin(calculateAvg(tanninSum, totalWineCnt)) + .sparkling(calculateAvg(sparklingSum, totalWineCnt)) .finish(calculateAvg(finishSum, totalWineCnt)) .build()) .build(); @@ -238,6 +241,7 @@ public TastingNote CreateTastingNote(TastingNoteRequest.CreateTastingNoteDTO req .vintage(request.getVintage()) .tannins(request.getTannin()) .finish(request.getFinish()) + .sparkling(request.getSparkling()) .price(request.getPrice() != null ? request.getPrice() : 0) .memo(request.getMemo()) .buyAgain(request.getBuyAgain()) @@ -353,6 +357,7 @@ private TastingNoteResponse.MyWineTaste MyWineTaste(TastingNote tastingNote) { .alcohol(tastingNote.getAlcohol()) .body(tastingNote.getBody()) .tannin(tastingNote.getTannins()) + .sparkling(tastingNote.getSparkling() != null ? Double.valueOf(tastingNote.getSparkling()) : 0) .finish(tastingNote.getFinish()) .build(); } @@ -424,6 +429,10 @@ public void updateTastingNote(TastingNote tastingNote, TastingNoteRequest.Update tastingNote.setAlcohol(request.getAlcohol()); tastingNote.setTannins(request.getTannin()); tastingNote.setFinish(request.getFinish()); + if (request.getSparkling() != null){ + tastingNote.setSparkling(request.getSparkling()); + } + tastingNote.setSparkling(request.getSparkling()); tastingNote.setColor(request.getColor()); tastingNote.setVintage(request.getVintage()); Boolean isPublic = request.getIsPublic(); diff --git a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteRequest.java b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteRequest.java index 53d3f12..a6a530b 100644 --- a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteRequest.java +++ b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteRequest.java @@ -69,6 +69,9 @@ public static class CreateTastingNoteDTO { @Schema(name="finish",description = "여운", required = true) private Integer finish; + @Schema(name = "sparkling", description = "탄산감", required = false) + private Integer sparkling; + @NotNull(message = "느낌을 입력해주세요") @Schema(name ="memo",description = "느낌", required = true) private String memo; @@ -142,6 +145,9 @@ public static class UpdateTastingNoteDTO { @Schema(name="tannin",description = "탄닌", required = true) private Integer tannin; + @Schema(name = "sparkling", description = "탄산감", required = false) + private Integer sparkling; + @Min(value = 1 ,message = "1이상을 입력해주세요") @Max(value = 5 ,message = "5이하를 입력해주세요") @Schema(name="finish",description = "여운", required = true) diff --git a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteResponse.java b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteResponse.java index d01c3d1..2068a81 100644 --- a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteResponse.java +++ b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/dto/TastingNoteResponse.java @@ -154,6 +154,8 @@ public static class MyWineTaste{ private double tannin; + private Double sparkling; + private double finish; } @@ -227,6 +229,8 @@ public static class Taste{ private double tannin; + private Double sparkling; + private double finish; } diff --git a/Winey-Domain/src/main/generated/com/example/wineydomain/tastingNote/entity/QTastingNote.java b/Winey-Domain/src/main/generated/com/example/wineydomain/tastingNote/entity/QTastingNote.java index c146618..0372d4c 100644 --- a/Winey-Domain/src/main/generated/com/example/wineydomain/tastingNote/entity/QTastingNote.java +++ b/Winey-Domain/src/main/generated/com/example/wineydomain/tastingNote/entity/QTastingNote.java @@ -53,6 +53,8 @@ public class QTastingNote extends EntityPathBase { public final ListPath smellKeywordTastingNote = this.createList("smellKeywordTastingNote", SmellKeywordTastingNote.class, QSmellKeywordTastingNote.class, PathInits.DIRECT2); + public final NumberPath sparkling = createNumber("sparkling", Integer.class); + public final NumberPath starRating = createNumber("starRating", Integer.class); public final NumberPath sweetness = createNumber("sweetness", Integer.class); diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/TastingNote.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/TastingNote.java index c9df52a..fa185f9 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/TastingNote.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/TastingNote.java @@ -84,6 +84,9 @@ public class TastingNote extends BaseEntity { @Column(name = "tannins") private Integer tannins; + @Column(name ="sparkling") + private Integer sparkling; + /** * 여운 */