diff --git a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/BucketController.java b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/BucketController.java index 680cc0744..bd4962ed0 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/BucketController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/BucketController.java @@ -65,7 +65,7 @@ public ResponseEntity getMemberItemsForModify( BucketGetMemberItemResponse response = BucketGetMemberItemResponse.from( bucketService.getMemberItemsForModify( bucketId, - Hobby.fromName(hobbyName), + Hobby.from(hobbyName), cursorRequest.toParameters() ) ); @@ -102,7 +102,7 @@ public ResponseEntity getBucketsByCursor( BucketGetByCursorResponse response = BucketGetByCursorResponse.from( bucketService.getBucketsByCursor( nickname, - Hobby.fromName(hobby), + Hobby.from(hobby), request.toParameters() )); diff --git a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketCreateRequest.java b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketCreateRequest.java index 2379bee11..757f6aff9 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketCreateRequest.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketCreateRequest.java @@ -33,7 +33,7 @@ public record BucketCreateRequest( ) { public BucketInfo toInfo() { - Hobby hobby = Hobby.fromHobbyValue(hobbyValue); + Hobby hobby = Hobby.from(hobbyValue); return new BucketInfo(hobby, name, budget); } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketUpdateRequest.java b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketUpdateRequest.java index d90931b0d..328ba946f 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketUpdateRequest.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/request/BucketUpdateRequest.java @@ -33,7 +33,7 @@ public record BucketUpdateRequest( ) { public BucketInfo toInfo() { - Hobby hobby = Hobby.fromHobbyValue(hobbyValue); + Hobby hobby = Hobby.from(hobbyValue); return new BucketInfo(hobby, name, budget); } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/response/BucketGetResponse.java b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/response/BucketGetResponse.java index 40a797874..5ac3e381e 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/response/BucketGetResponse.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/bucket/api/dto/response/BucketGetResponse.java @@ -23,7 +23,7 @@ public record BucketGetResponse( ) { public static BucketGetResponse from(final BucketGetServiceResponse response) { return BucketGetResponse.builder() - .hobby(response.hobby().getHobbyValue()) + .hobby(response.hobby().getName()) .name(response.name()) .budget(response.budget()) .totalPrice(response.totalPrice()) diff --git a/lime-api/src/main/java/com/programmers/lime/domains/feed/api/FeedController.java b/lime-api/src/main/java/com/programmers/lime/domains/feed/api/FeedController.java index 406396463..3b9574733 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/feed/api/FeedController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/feed/api/FeedController.java @@ -91,7 +91,7 @@ public ResponseEntity getFeedByCursor( @RequestParam(required = false) final String sortCondition, @ModelAttribute @Valid final CursorRequest request ) { - Hobby hobby = Hobby.fromName(hobbyName); + Hobby hobby = Hobby.from(hobbyName); CursorSummary cursorSummary = feedService.getFeedByCursor( hobby, diff --git a/lime-api/src/main/java/com/programmers/lime/domains/hobby/HobbyController.java b/lime-api/src/main/java/com/programmers/lime/domains/hobby/HobbyController.java index 22ce28564..b0095dda6 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/hobby/HobbyController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/hobby/HobbyController.java @@ -23,7 +23,7 @@ public class HobbyController { @Operation(summary = "취미 목록 조회", description = "취미 목록 조회 결과를 반환 합니다.") @GetMapping public ResponseEntity getHobby() { - HobbyGetResponse response = hobbyService.getHobbies(); + final HobbyGetResponse response = hobbyService.getHobbies(); return ResponseEntity.ok(response); } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyGetResponse.java b/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyGetResponse.java index e9d1dfcf0..b22bd754f 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyGetResponse.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyGetResponse.java @@ -2,7 +2,5 @@ import java.util.List; -public record HobbyGetResponse( - List hobbies -) { +public record HobbyGetResponse(List hobbies) { } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyItem.java b/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyItem.java deleted file mode 100644 index e73a8184f..000000000 --- a/lime-api/src/main/java/com/programmers/lime/domains/hobby/api/dto/response/HobbyItem.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.programmers.lime.domains.hobby.api.dto.response; - -public record HobbyItem( - String name, - String value -) { -} diff --git a/lime-api/src/main/java/com/programmers/lime/domains/hobby/application/HobbyService.java b/lime-api/src/main/java/com/programmers/lime/domains/hobby/application/HobbyService.java index 602f4d8e6..326ef9f49 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/hobby/application/HobbyService.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/hobby/application/HobbyService.java @@ -1,28 +1,14 @@ package com.programmers.lime.domains.hobby.application; -import java.util.List; - import org.springframework.stereotype.Service; import com.programmers.lime.common.model.Hobby; import com.programmers.lime.domains.hobby.api.dto.response.HobbyGetResponse; -import com.programmers.lime.domains.hobby.api.dto.response.HobbyItem; @Service public class HobbyService { public HobbyGetResponse getHobbies() { - List hobbies = List.of(Hobby.values()); - - List hobbyItems = hobbies.stream().map( - hobby -> new HobbyItem( - hobby.getName(), - hobby.getHobbyValue() - ) - ).toList(); - - return new HobbyGetResponse( - hobbyItems - ); + return new HobbyGetResponse(Hobby.getHobbies()); } } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/InventoryController.java b/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/InventoryController.java index ada815044..94ccb9402 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/InventoryController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/InventoryController.java @@ -39,7 +39,7 @@ public class InventoryController { @PostMapping("/inventories") public ResponseEntity createInventory( @RequestBody @Valid final InventoryCreateRequest request) { - Hobby hobby = Hobby.fromHobbyValue(request.hobbyValue()); + Hobby hobby = Hobby.from(request.hobbyValue()); Long inventoryId = inventoryService.createInventory(hobby, request.toRegistry()); return ResponseEntity.ok(new InventoryCreateResponse(inventoryId)); @@ -90,7 +90,7 @@ public ResponseEntity getReviewedItemsForModif InventoryGetReviewedItemResponse response = InventoryGetReviewedItemResponse.from( inventoryService.getReviewedItemsForModify( inventoryId, - Hobby.fromName(hobbyName), + Hobby.from(hobbyName), cursorRequest.toParameters() ) ); diff --git a/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/dto/response/InventoryGetResponse.java b/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/dto/response/InventoryGetResponse.java index 2e517ad06..34fca6c4d 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/dto/response/InventoryGetResponse.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/inventory/api/dto/response/InventoryGetResponse.java @@ -17,7 +17,7 @@ public record InventoryGetResponse( public static InventoryGetResponse from(final InventoryGetServiceResponse serviceResponse) { return InventoryGetResponse.builder() .memberId(serviceResponse.memberId()) - .hobby(serviceResponse.hobby().getHobbyValue()) + .hobby(serviceResponse.hobby().getName()) .itemCount(serviceResponse.itemCount()) .inventoryItemInfos(serviceResponse.inventoryItemInfos()) .build(); diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java index f91c4b912..8331fe406 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java @@ -113,7 +113,7 @@ public ResponseEntity getMemberItemsByCursor( @RequestParam(required = false) final String hobbyName, @ModelAttribute("request") @Valid final CursorRequest request ) { - Hobby hobby = Hobby.fromName(hobbyName); + Hobby hobby = Hobby.from(hobbyName); MemberItemGetServiceResponse serviceResponse = itemService.getMemberItemsByCursor( hobby, request.toParameters() diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java b/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java index 522cc1e73..2ad7ed2c0 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java @@ -17,7 +17,7 @@ public record ItemEnrollRequest( ) { public ItemEnrollServiceRequest toEnrollItemServiceRequest() { - Hobby hobby = Hobby.fromHobbyValue(hobbyValue); + Hobby hobby = Hobby.from(hobbyValue); return new ItemEnrollServiceRequest(hobby, itemUrl); } diff --git a/lime-api/src/main/java/com/programmers/lime/domains/vote/api/VoteController.java b/lime-api/src/main/java/com/programmers/lime/domains/vote/api/VoteController.java index 6481a02e7..511ce2697 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/vote/api/VoteController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/vote/api/VoteController.java @@ -98,7 +98,7 @@ public ResponseEntity getVotesByCursor( @ModelAttribute @Valid final CursorRequest request ) { final CursorSummary cursorSummary = voteService.getVotesByCursor( - Hobby.fromName(hobby), + Hobby.from(hobby), VoteStatusCondition.from(statusCondition), VoteSortCondition.from(sortCondition), request.toParameters() @@ -114,7 +114,8 @@ public ResponseEntity getVotesByKeyword( @RequestParam final String keyword, @ModelAttribute @Valid final CursorRequest request ) { - final VoteGetByKeywordServiceResponse serviceResponse = voteService.getVotesByKeyword(keyword, request.toParameters()); + final VoteGetByKeywordServiceResponse serviceResponse = voteService.getVotesByKeyword(keyword, + request.toParameters()); final VoteGetByKeywordResponse response = VoteGetByKeywordResponse.from(serviceResponse); return ResponseEntity.ok(response); diff --git a/lime-api/src/main/java/com/programmers/lime/domains/vote/api/dto/request/VoteCreateRequest.java b/lime-api/src/main/java/com/programmers/lime/domains/vote/api/dto/request/VoteCreateRequest.java index db9ab63be..7acd0d901 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/vote/api/dto/request/VoteCreateRequest.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/vote/api/dto/request/VoteCreateRequest.java @@ -30,7 +30,7 @@ public record VoteCreateRequest( ) { public VoteCreateServiceRequest toCreateVoteServiceRequest() { return VoteCreateServiceRequest.builder() - .hobby(Hobby.fromHobbyValue(hobby)) + .hobby(Hobby.from(hobby)) .content(content) .item1Id(item1Id) .item2Id(item2Id) diff --git a/lime-domain/src/main/java/com/programmers/lime/common/model/Hobby.java b/lime-domain/src/main/java/com/programmers/lime/common/model/Hobby.java index 77b5da19b..f76bbbfaa 100644 --- a/lime-domain/src/main/java/com/programmers/lime/common/model/Hobby.java +++ b/lime-domain/src/main/java/com/programmers/lime/common/model/Hobby.java @@ -1,6 +1,7 @@ package com.programmers.lime.common.model; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; @@ -16,48 +17,46 @@ @Getter @RequiredArgsConstructor public enum Hobby { - - BASKETBALL("농구", "basketball"), - BASEBALL("야구", "baseball"), - SOCCER("축구", "soccer"), - CYCLE("사이클", "cycle"), - KEYBOARD("키보드", "keyboard"), - SWIMMING("수영", "swimming"); + // Sports + BASKETBALL("농구"), + BADMINTON("배드민턴"), + CLIMBING("클라이밍"), + WORK_OUT("헬스"), + BASEBALL("야구"), + + // Lifestyle + COOKING("요리"), + GAME("게임"), + DESKTERIOR("데스크테리어"), + PAINTING("그림"), + MUSIC("음악"), + ; private static final Map HOBBY_NAME_MAP; - private static final Map HOBBY_VALUE_MAP; - static { HOBBY_NAME_MAP = Collections.unmodifiableMap(Stream.of(values()) .collect(Collectors.toMap(Hobby::getName, Function.identity()))); - - HOBBY_VALUE_MAP = Collections.unmodifiableMap(Stream.of(values()) - .collect(Collectors.toMap(Hobby::getHobbyValue, Function.identity()))); } - private final String hobbyValue; private final String name; - public static Hobby fromName(final String name) { - + public static Hobby from(final String name) { if (Objects.isNull(name)) { return null; } - String nameLowerCase = name.toLowerCase(); - if (HOBBY_NAME_MAP.containsKey(nameLowerCase)) { - return HOBBY_NAME_MAP.get(nameLowerCase); + if (HOBBY_NAME_MAP.containsKey(name)) { + return HOBBY_NAME_MAP.get(name); } throw new BusinessException(ErrorCode.HOBBY_BAD_PARAMETER); } - public static Hobby fromHobbyValue(final String hobbyValue) { - if (HOBBY_VALUE_MAP.containsKey(hobbyValue)) { - return HOBBY_VALUE_MAP.get(hobbyValue); - } - - throw new BusinessException(ErrorCode.HOBBY_BAD_PARAMETER); + public static List getHobbies() { + return HOBBY_NAME_MAP.values() + .stream() + .map(Hobby::getName) + .toList(); } } diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/bucket/model/BucketProfile.java b/lime-domain/src/main/java/com/programmers/lime/domains/bucket/model/BucketProfile.java index 72b20440f..5ff43f67c 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/bucket/model/BucketProfile.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/bucket/model/BucketProfile.java @@ -15,7 +15,7 @@ public static BucketProfile of( ) { return new BucketProfile( bucket.getId(), - bucket.getHobby().getHobbyValue(), + bucket.getHobby().getName(), itemImages); } } diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/feed/model/FeedInfo.java b/lime-domain/src/main/java/com/programmers/lime/domains/feed/model/FeedInfo.java index fc2422e56..ef5b3dd87 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/feed/model/FeedInfo.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/feed/model/FeedInfo.java @@ -26,7 +26,7 @@ public static FeedInfo of( ) { return FeedInfo.builder() .id(feed.getId()) - .hobby(feed.getHobby().getHobbyValue()) + .hobby(feed.getHobby().getName()) .content(feed.getFeedContent()) .bucketName(feed.getName()) .bucketBudget(feed.getBudget()) diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryInfoSummary.java b/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryInfoSummary.java index 4dce982f5..ce228c0b7 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryInfoSummary.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryInfoSummary.java @@ -20,7 +20,7 @@ public InventoryInfoSummary( int inventoryTotalPrice, List itemImages ) { - this.hobby = hobby.getHobbyValue(); + this.hobby = hobby.getName(); this.inventoryId = inventoryId; this.inventoryTotalPrice = inventoryTotalPrice; this.itemImages = itemImages; diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryProfile.java b/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryProfile.java index 45f6311a6..1515d32e7 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryProfile.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/inventory/model/InventoryProfile.java @@ -15,7 +15,7 @@ public static InventoryProfile of( ) { return new InventoryProfile( inventory.getId(), - inventory.getHobby().getHobbyValue(), + inventory.getHobby().getName(), itemImages ); }