From 9b57a30012434bfa8064ddfd28a5730c914c5f70 Mon Sep 17 00:00:00 2001 From: swa07016 Date: Tue, 5 Nov 2024 01:10:54 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=ED=96=A5=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tastingNote/entity/SmellKeyword.java | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java index d61e2d5..923cf1f 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java @@ -1,10 +1,7 @@ package com.example.wineydomain.tastingNote.entity; -import java.util.Arrays; - import com.example.wineydomain.common.model.BaseEntity; import com.fasterxml.jackson.annotation.JsonCreator; - import lombok.*; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -21,23 +18,43 @@ public enum SmellKeyword { PEACHPLUM("FRUIT","PEACHPLUM","복숭아/자두"), TROPICALFRUIT("FRUIT","TROPICALFRUIT","열대과일"), FLOWER("NATURAL", "FLOWER","꽃향"), + ACACIA("NATURAL", "ACACIA", "아카시아"), + ROSE("NATURAL", "ROSE", "장미"), + LAVENDER("NATURAL", "LAVENDER", "라벤더"), GRASSWOOD("NATURAL", "GRASSWOOD","풀/나무"), - NATURAL("NATURAL","NATURAL","자연향"), + PINE("NATURAL", "PINE", "솔향"), + PEPPER("NATURAL", "PEPPER", "피망"), + ONION("NATURAL", "ONION", "양파"), + CORN("NATURAL", "CORN", "옥수수"), HERB("NATURAL","HERB","허브향"), + MUSHROOM("NATURAL", "MUSHROOM", "버섯"), + MOSS("NATURAL", "MOSS", "이끼"), OAK("OAK","OAK","오크향"), SPICE("OAK","SPICE","향신료"), + PEPPERSPICE("OAK","PEPPERSPICE","후추"), + CINNAMON("OAK", "CINNAMON", "계피"), NUTS("OAK","NUTS","견과류"), VANILLA("OAK","VANILLA","바닐라"), + CARAMEL("OAK", "CARAMEL", "캐러멜"), CHOCOLATE("OAK","CHOCOLATE","초콜릿"), + TOAST("OAK", "TOAST", "토스트"), + COFFEE("OAK", "COFFEE", "커피"), + COCONUT("OAK", "COCONUT", "코코넛"), + SMOKE("OAK", "SMOKE", "연기"), FLINT("OTHER","FLINT","부싯돌"), BREAD("OTHER", "BREAD","빵"), RUBBER("OTHER","RUBBER","고무"), - EARTHASH("OTHER","EARTHASH","흙/재"), - MEDICINE("OTHER", "MEDICINE","약품"); - - private final String type; - - private final String value; - - private final String name; + SWEAT("OTHER", "SWEAT", "땀"), + LEATHER("OTHER", "LEATHER", "가죽"), + VINEGAR("OTHER", "VINEGAR", "식초"), + REMOVER("OTHER", "REMOVER", "리무버"), + CIGARETTE("OTHER", "CIGARETTE", "담배"), + HONEY("OTHER", "HONEY", "꿀"), + BUTTER("OTHER", "BUTTER", "버터"), + MEDICINE("OTHER", "MEDICINE","약품"), + EARTHASH("OTHER","EARTHASH","흙/재"); + + private final String type; + private final String value; + private final String name; } From 0cb11cb4d6a7a788aed730c91884dc0811fca845 Mon Sep 17 00:00:00 2001 From: SeongHoon Jeong Date: Tue, 5 Nov 2024 16:44:08 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20SmellKeyword=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wineydomain/tastingNote/entity/SmellKeyword.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java index 923cf1f..6bf3060 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java @@ -13,9 +13,12 @@ public enum SmellKeyword { FRUIT("FRUIT","FRUIT","과일향"), BERRY("FRUIT","BERRY", "베리류"), - LEMONANDLIME("FRUIT","LEMONANDLIME","레몬/라임"), - APPLEPEAR("FRUIT","APPLEPEAR","사과/배"), - PEACHPLUM("FRUIT","PEACHPLUM","복숭아/자두"), + LEMON("FRUIT","LEMON","레몬"), + LIME("FRUIT","LIME","라임"), + APPLE("FRUIT","APPLE","사과"), + PEAR("FRUIT","PEAR","배"), + PEACH("FRUIT","PEACH","복숭아"), + PLUM("FRUIT","PLUM","자두"), TROPICALFRUIT("FRUIT","TROPICALFRUIT","열대과일"), FLOWER("NATURAL", "FLOWER","꽃향"), ACACIA("NATURAL", "ACACIA", "아카시아"), From 8d97b123807ecb8d6669e0fc62c6d9f2bc6aae5d Mon Sep 17 00:00:00 2001 From: imenuuu Date: Wed, 6 Nov 2024 20:40:55 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refactor=20:=20=ED=96=A5=20=ED=82=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EC=A7=81=EC=A0=91=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convertor/TastingNoteConvertor.java | 30 +++++++++++++++---- .../tastingNote/dto/TastingNoteRequest.java | 10 +++++++ .../service/TastingNoteServiceImpl.java | 23 ++++++++++++-- .../tastingNote/entity/SmellKeyword.java | 9 ++++++ .../entity/SmellKeywordTastingNote.java | 6 ++-- .../SmellKeywordTastingNoteRepository.java | 4 +-- 6 files changed, 69 insertions(+), 13 deletions(-) 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 42409a7..52fffb6 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 @@ -101,8 +101,15 @@ public TastingNoteResponse.TasteAnalysisDTO TasteAnalysis(List tast } wineCountByType.put(wine.getType().getValue(), wineCountByType.getOrDefault(wine.getType().getValue() ,0)+1); for(SmellKeywordTastingNote smellKeywordTastingNote : tastingNote.getSmellKeywordTastingNote()) { - wineCountBySmell.put(smellKeywordTastingNote.getSmellKeyword().getName(), wineCountBySmell.getOrDefault(smellKeywordTastingNote.getSmellKeyword().getName(), 0) + 1); + wineCountBySmell.put( + smellKeywordTastingNote.getDirectYN().equals("N") ? + SmellKeyword.findByValue(smellKeywordTastingNote.getSmellKeyword()).getName() : smellKeywordTastingNote.getSmellKeyword(), + wineCountBySmell.getOrDefault(smellKeywordTastingNote.getDirectYN().equals("N") ? + SmellKeyword.findByValue(smellKeywordTastingNote.getSmellKeyword()).getName() : smellKeywordTastingNote.getSmellKeyword(), + 0) + + 1); } + System.out.println("wineCountBySmell = " + wineCountBySmell); } List> sortCountry = new ArrayList<>(wineCountByCountry.entrySet()); @@ -251,10 +258,11 @@ public TastingNote CreateTastingNote(TastingNoteRequest.CreateTastingNoteDTO req .build(); } - public SmellKeywordTastingNote SmellKeyword(SmellKeyword smellKeyword, TastingNote tastingNote) { + public SmellKeywordTastingNote toSmellKeyword(SmellKeyword smellKeyword, TastingNote tastingNote) { return SmellKeywordTastingNote.builder() - .smellKeyword(smellKeyword) + .smellKeyword(smellKeyword.getValue()) .tastingNote(tastingNote) + .directYN("N") .build(); } @@ -367,9 +375,11 @@ private List SmellKeywordList(List smellKeyword List smellKeywordList = new ArrayList<>(); for(SmellKeywordTastingNote smellKeywordTastingNote : smellKeywordTastingNotes){ - System.out.println(smellKeywordTastingNote.getId()); - System.out.println(smellKeywordTastingNote.getSmellKeyword()); - smellKeywordList.add(smellKeywordTastingNote.getSmellKeyword().getName()); + if(smellKeywordTastingNote.getDirectYN().equals("Y")){ + smellKeywordList.add(smellKeywordTastingNote.getSmellKeyword()); + }else { + smellKeywordList.add(SmellKeyword.findByValue(smellKeywordTastingNote.getSmellKeyword()).getValue()); + } } return smellKeywordList; @@ -439,4 +449,12 @@ public void updateTastingNote(TastingNote tastingNote, TastingNoteRequest.Update Boolean isPublic = request.getIsPublic(); if(isPublic != null) tastingNote.setIsPublic(request.getIsPublic()); } + + public SmellKeywordTastingNote toDirectSmellKeyword(String smellKeyword, TastingNote tastingNote) { + return SmellKeywordTastingNote.builder() + .smellKeyword(smellKeyword) + .tastingNote(tastingNote) + .directYN("Y") + .build(); + } } 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 a6a530b..c69b7c2 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 @@ -90,9 +90,13 @@ public static class CreateTastingNoteDTO { @Schema(name = "isPublic", description = "공개여부", required = false) private Boolean isPublic = Boolean.FALSE; + private List directKeywordList; + + public Boolean getBuyAgain() { return buyAgain; } + } @Getter @@ -172,6 +176,12 @@ public static class UpdateTastingNoteDTO { @Schema(name = "deleteSmellKeywordList 삭제사항 있을 경우 작성해주세요",description = "향 키워드 리스트", required = false) private List deleteSmellKeywordList; + @Schema(name = "directKeywordList 추가사항 있을 경우 작성해주세요",description = "직접 입력한 키워드 리스트", required = false) + private List directKeywordList; + + @Schema(name = "deleteDirectKeywordList 삭제사항 있을 경우 작성해주세요",description = "직접 입력한 키워드 리스트", required = false) + private List deleteDirectKeywordList; + @Schema(name = "deleteImgLists 삭제사항 있을 경우 작성해주세요",description = "테이스팅 노트 이미지 리스트", required = false) private List deleteImgList; diff --git a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/service/TastingNoteServiceImpl.java b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/service/TastingNoteServiceImpl.java index 028ccd4..f3732ca 100644 --- a/Winey-API/src/main/java/com/example/wineyapi/tastingNote/service/TastingNoteServiceImpl.java +++ b/Winey-API/src/main/java/com/example/wineyapi/tastingNote/service/TastingNoteServiceImpl.java @@ -35,6 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static com.example.wineydomain.tastingNote.exception.GetTastingNoteErrorCode.*; import static com.example.wineydomain.tastingNote.exception.UploadTastingNoteErrorCode.NOT_FOUNT_WINE; @@ -115,14 +116,25 @@ public void updateTastingNote(User user, TastingNoteRequest.UpdateTastingNoteDTO } private void updateTastingNoteSmellKeyword(TastingNoteRequest.UpdateTastingNoteDTO request, TastingNote tastingNote) { - if(request.getDeleteSmellKeywordList() != null) smellKeywordTastingNoteRepository.deleteByTastingNoteAndSmellKeywordIn(tastingNote, request.getDeleteSmellKeywordList()); + if(request.getDeleteSmellKeywordList() != null) smellKeywordTastingNoteRepository.deleteByTastingNoteAndSmellKeywordIn(tastingNote, request.getDeleteSmellKeywordList().stream().map(SmellKeyword::getValue).collect( + Collectors.toList())); if(request.getSmellKeywordList() != null) updateSmellKeyword(request, tastingNote); + if (request.getDirectKeywordList() != null) updateDirectKeyword(request, tastingNote); + if (request.getDeleteDirectKeywordList() != null) smellKeywordTastingNoteRepository.deleteByTastingNoteAndSmellKeywordIn(tastingNote, request.getDeleteDirectKeywordList()); + } + + private void updateDirectKeyword(TastingNoteRequest.UpdateTastingNoteDTO request, TastingNote tastingNote) { + List smellKeywordTastingNoteList = new ArrayList<>(); + for(String smellKeyword : request.getDirectKeywordList()){ + smellKeywordTastingNoteList.add(tastingNoteConvertor.toDirectSmellKeyword(smellKeyword, tastingNote)); + } + smellKeywordTastingNoteRepository.saveAll(smellKeywordTastingNoteList); } private void updateSmellKeyword(TastingNoteRequest.UpdateTastingNoteDTO request, TastingNote tastingNote) { List smellKeywordTastingNoteList = new ArrayList<>(); for(SmellKeyword smellKeyword : request.getSmellKeywordList()){ - smellKeywordTastingNoteList.add(tastingNoteConvertor.SmellKeyword(smellKeyword, tastingNote)); + smellKeywordTastingNoteList.add(tastingNoteConvertor.toSmellKeyword(smellKeyword, tastingNote)); } smellKeywordTastingNoteRepository.saveAll(smellKeywordTastingNoteList); } @@ -162,7 +174,12 @@ public TastingNoteResponse.CreateTastingNoteDTO createTastingNote(User user, Tas if(request.getSmellKeywordList() != null) { for (SmellKeyword smellKeyword : request.getSmellKeywordList()) { - smellKeywordTastingNoteRepository.save(tastingNoteConvertor.SmellKeyword(smellKeyword, tastingNote)); + smellKeywordTastingNoteRepository.save(tastingNoteConvertor.toSmellKeyword(smellKeyword, tastingNote)); + } + } + if (request.getDirectKeywordList() !=null ){ + for (String smellKeyword : request.getDirectKeywordList()) { + smellKeywordTastingNoteRepository.save(tastingNoteConvertor.toDirectSmellKeyword(smellKeyword, tastingNote)); } } diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java index 6bf3060..4ff0f16 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeyword.java @@ -60,4 +60,13 @@ public enum SmellKeyword { private final String type; private final String value; private final String name; + + public static SmellKeyword findByValue(String value) { + for (SmellKeyword keyword : SmellKeyword.values()) { + if (keyword.getValue().equals(value)) { + return keyword; + } + } + return null; + } } diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeywordTastingNote.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeywordTastingNote.java index 0101676..089057b 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeywordTastingNote.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/entity/SmellKeywordTastingNote.java @@ -15,6 +15,7 @@ @NoArgsConstructor @DynamicUpdate @DynamicInsert +@ToString public class SmellKeywordTastingNote { @Id @@ -22,10 +23,11 @@ public class SmellKeywordTastingNote { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Enumerated(EnumType.STRING) - private SmellKeyword smellKeyword; + private String smellKeyword; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "tastingNoteId", nullable = false) private TastingNote tastingNote; + + private String directYN; } diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/SmellKeywordTastingNoteRepository.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/SmellKeywordTastingNoteRepository.java index 4b96959..2e67ac4 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/SmellKeywordTastingNoteRepository.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/SmellKeywordTastingNoteRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface SmellKeywordTastingNoteRepository extends JpaRepository { - void deleteByTastingNoteAndSmellKeyword(TastingNote tastingNote, SmellKeyword smellKeyword); + void deleteByTastingNoteAndSmellKeyword(TastingNote tastingNote, String smellKeyword); - void deleteByTastingNoteAndSmellKeywordIn(TastingNote tastingNote, List deleteSmellKeywordList); + void deleteByTastingNoteAndSmellKeywordIn(TastingNote tastingNote, List deleteSmellKeywordList); } From 0701ecdc9c7bc51eb1bf70ce08fcb7bef6948874 Mon Sep 17 00:00:00 2001 From: imenuuu Date: Wed, 6 Nov 2024 20:49:29 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor=20:=20=ED=96=A5=20=ED=82=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EC=A7=81=EC=A0=91=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convertor/TastingNoteConvertor.java | 21 ++++++++++++++----- .../tastingNote/dto/TastingNoteResponse.java | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) 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 52fffb6..23677ed 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 @@ -325,7 +325,8 @@ public TastingNoteResponse.TastingNoteDTO toTastingNote(TastingNote tastingNote, .varietal(wine.getVarietal()) .price(tastingNote.getPrice()) .officialAlcohol(tastingNote.getOfficialAlcohol()) - .smellKeywordList(SmellKeywordList(smellKeywordTastingNotes)) + .smellKeywordList(toSmellKeywordList(smellKeywordTastingNotes)) + .directKeywordList(toDirectKeywordList(smellKeywordTastingNotes)) .myWineTaste(MyWineTaste(tastingNote)) .defaultWineTaste(DefaultWineTaste(wine)) .tastingNoteImage(toTastingNoteImageRes(tastingNoteImages)) @@ -337,6 +338,18 @@ public TastingNoteResponse.TastingNoteDTO toTastingNote(TastingNote tastingNote, .build(); } + private List toDirectKeywordList(List smellKeywordTastingNotes) { + List directKeywordList = new ArrayList<>(); + + for(SmellKeywordTastingNote smellKeywordTastingNote : smellKeywordTastingNotes){ + if(smellKeywordTastingNote.getDirectYN().equals("Y")){ + directKeywordList.add(smellKeywordTastingNote.getSmellKeyword()); + } + } + + return directKeywordList; + } + private List toTastingNoteImageRes(List tastingNoteImages) { List tastingNoteImageList = new ArrayList<>(); @@ -371,13 +384,11 @@ private TastingNoteResponse.MyWineTaste MyWineTaste(TastingNote tastingNote) { .build(); } - private List SmellKeywordList(List smellKeywordTastingNotes) { + private List toSmellKeywordList(List smellKeywordTastingNotes) { List smellKeywordList = new ArrayList<>(); for(SmellKeywordTastingNote smellKeywordTastingNote : smellKeywordTastingNotes){ - if(smellKeywordTastingNote.getDirectYN().equals("Y")){ - smellKeywordList.add(smellKeywordTastingNote.getSmellKeyword()); - }else { + if(smellKeywordTastingNote.getDirectYN().equals("N")){ smellKeywordList.add(SmellKeyword.findByValue(smellKeywordTastingNote.getSmellKeyword()).getValue()); } } 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 dceae36..cbffc31 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 @@ -116,6 +116,8 @@ public static class TastingNoteDTO { private List smellKeywordList; + private List directKeywordList; + @Schema(description = "내가 느낀 와인의 맛") private MyWineTaste myWineTaste; From 97828cdca99465c2a886f0fb6e75428b6e6bc734 Mon Sep 17 00:00:00 2001 From: imenuuu Date: Wed, 6 Nov 2024 23:58:16 +0900 Subject: [PATCH 5/7] =?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=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wineyapi/tastingNote/convertor/TastingNoteConvertor.java | 1 + .../example/wineyapi/tastingNote/dto/TastingNoteResponse.java | 2 ++ 2 files changed, 3 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 23677ed..169bc46 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 @@ -301,6 +301,7 @@ private TastingNoteResponse.TastingNoteListDTO toTastingNoteListDTO(TastingNote .tastingNoteNo(tastingNoteNo.get(result.getId())) .userNickname(result.getUser() != null ? result.getUser().getNickName() : "알 수 없음") .noteDate(result.getCreatedAt().toLocalDate().toString()) + .thumbnail(result.getTastingNoteImages().size() > 0 ? result.getTastingNoteImages().get(0).getUrl() : null) .build(); } 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 cbffc31..34509c6 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 @@ -38,6 +38,8 @@ public static class TastingNoteListDTO { private String userNickname; @Schema(description = "노트 생성 날짜") private String noteDate; + @Schema(description = "썸네일") + private String thumbnail; } @NoArgsConstructor From 4f686f4122a8fa6eabc5aa0c991a81d8a1e58281 Mon Sep 17 00:00:00 2001 From: imenuuu Date: Thu, 7 Nov 2024 23:14:23 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor=20:=20korName=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convertor/TastingNoteConvertor.java | 15 ++++++++++++++- .../tastingNote/dto/TastingNoteResponse.java | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 169bc46..a9ada15 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 @@ -301,7 +301,7 @@ private TastingNoteResponse.TastingNoteListDTO toTastingNoteListDTO(TastingNote .tastingNoteNo(tastingNoteNo.get(result.getId())) .userNickname(result.getUser() != null ? result.getUser().getNickName() : "알 수 없음") .noteDate(result.getCreatedAt().toLocalDate().toString()) - .thumbnail(result.getTastingNoteImages().size() > 0 ? result.getTastingNoteImages().get(0).getUrl() : null) + .thumbnail(!result.getTastingNoteImages().isEmpty() ? result.getTastingNoteImages().get(0).getUrl() : null) .build(); } @@ -327,6 +327,7 @@ public TastingNoteResponse.TastingNoteDTO toTastingNote(TastingNote tastingNote, .price(tastingNote.getPrice()) .officialAlcohol(tastingNote.getOfficialAlcohol()) .smellKeywordList(toSmellKeywordList(smellKeywordTastingNotes)) + .korSmellKeywordList(toKorSmellKeywordList(smellKeywordTastingNotes)) .directKeywordList(toDirectKeywordList(smellKeywordTastingNotes)) .myWineTaste(MyWineTaste(tastingNote)) .defaultWineTaste(DefaultWineTaste(wine)) @@ -397,6 +398,18 @@ private List toSmellKeywordList(List smellKeywo return smellKeywordList; } + private List toKorSmellKeywordList(List smellKeywordTastingNotes) { + List smellKeywordList = new ArrayList<>(); + + for(SmellKeywordTastingNote smellKeywordTastingNote : smellKeywordTastingNotes){ + if(smellKeywordTastingNote.getDirectYN().equals("N")){ + smellKeywordList.add(SmellKeyword.findByValue(smellKeywordTastingNote.getSmellKeyword()).getName()); + } + } + + return smellKeywordList; + } + public TastingNoteResponse.NoteFilterDTO NoteFilter(List tastingNotes) { Map wineCountByType = new HashMap<>(); Map wineCountByCountry = new HashMap<>(); 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 34509c6..765c743 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 @@ -118,6 +118,9 @@ public static class TastingNoteDTO { private List smellKeywordList; + @Schema(description = "한국어 향 리스트") + private List korSmellKeywordList; + private List directKeywordList; @Schema(description = "내가 느낀 와인의 맛") From 82539066bad8d7b312b4ee1dc68981c18ac14ce8 Mon Sep 17 00:00:00 2001 From: imenuuu Date: Thu, 7 Nov 2024 23:16:46 +0900 Subject: [PATCH 7/7] =?UTF-8?q?refactor=20:=20=EB=B3=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EB=85=B8=ED=8A=B8=20X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tastingNote/repository/TastingNoteRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/TastingNoteRepositoryImpl.java b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/TastingNoteRepositoryImpl.java index 3c43168..fd4cc17 100644 --- a/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/TastingNoteRepositoryImpl.java +++ b/Winey-Domain/src/main/java/com/example/wineydomain/tastingNote/repository/TastingNoteRepositoryImpl.java @@ -94,7 +94,7 @@ public Page findTastingNotesByWine(Wine wine, User user, Integer pa .and(qTastingNote.isDeleted.eq(false)) .and(qTastingNote.isPublic.eq(true) .or(qTastingNote.user.eq(user)) - ) + ).and(qTastingNote.user.ne(user)) ) .orderBy(qTastingNote.id.desc());