Skip to content

Commit 37acef8

Browse files
committed
Merge branch 'develop' into refactor/PRODUCT-186
# Conflicts: # src/main/java/eatda/service/store/CheerService.java # src/main/java/eatda/service/story/StoryService.java # src/test/java/eatda/controller/BaseControllerTest.java # src/test/java/eatda/controller/story/StoryControllerTest.java # src/test/java/eatda/document/BaseDocumentTest.java # src/test/java/eatda/document/story/StoryDocumentTest.java # src/test/java/eatda/service/BaseServiceTest.java
2 parents e0862f6 + 7800c55 commit 37acef8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+909
-169
lines changed

src/main/java/eatda/client/map/StoreSearchResult.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import eatda.domain.store.Store;
6+
import eatda.domain.store.StoreCategory;
7+
import java.util.Map;
58

69
@JsonIgnoreProperties(ignoreUnknown = true)
710
public record StoreSearchResult(
@@ -17,6 +20,17 @@ public record StoreSearchResult(
1720
@JsonProperty("x") double longitude
1821
) {
1922

23+
private static final Map<String, StoreCategory> PREFIX_TO_CATEGORY = Map.of(
24+
"음식점 > 한식", StoreCategory.KOREAN,
25+
"음식점 > 중식", StoreCategory.CHINESE,
26+
"음식점 > 일식", StoreCategory.JAPANESE,
27+
"음식점 > 양식", StoreCategory.WESTERN,
28+
"음식점 > 카페", StoreCategory.CAFE,
29+
"음식점 > 간식 > 제과,베이커리", StoreCategory.BAKERY,
30+
"음식점 > 술집", StoreCategory.PUB,
31+
"음식점 > 패스트푸드", StoreCategory.FAST_FOOD
32+
);
33+
2034
public boolean isFoodStore() {
2135
return "FD6".equals(categoryGroupCode);
2236
}
@@ -27,4 +41,31 @@ public boolean isInSeoul() {
2741
}
2842
return lotNumberAddress.trim().startsWith("서울");
2943
}
44+
45+
public StoreCategory getStoreCategory() {
46+
if (categoryName == null) {
47+
return StoreCategory.OTHER;
48+
}
49+
50+
return PREFIX_TO_CATEGORY.entrySet()
51+
.stream()
52+
.filter(entry -> categoryName.startsWith(entry.getKey()))
53+
.map(Map.Entry::getValue)
54+
.findFirst()
55+
.orElse(StoreCategory.OTHER);
56+
}
57+
58+
public Store toStore() {
59+
return Store.builder()
60+
.kakaoId(kakaoId)
61+
.category(getStoreCategory())
62+
.phoneNumber(phoneNumber)
63+
.name(name)
64+
.placeUrl(placeUrl)
65+
.roadAddress(roadAddress)
66+
.lotNumberAddress(lotNumberAddress)
67+
.latitude(latitude)
68+
.longitude(longitude)
69+
.build();
70+
}
3071
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package eatda.controller.article;
2+
3+
import eatda.service.article.ArticleService;
4+
import jakarta.validation.constraints.Max;
5+
import jakarta.validation.constraints.Min;
6+
import lombok.RequiredArgsConstructor;
7+
import org.springframework.http.HttpStatus;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.stereotype.Controller;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestParam;
12+
13+
@Controller
14+
@RequiredArgsConstructor
15+
public class ArticleController {
16+
17+
private final ArticleService articleService;
18+
19+
@GetMapping("/api/articles")
20+
public ResponseEntity<ArticlesResponse> getArticles(@RequestParam(defaultValue = "3") @Min(1) @Max(50) int size) {
21+
return ResponseEntity.status(HttpStatus.OK)
22+
.body(articleService.getAllArticles(size));
23+
}
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package eatda.controller.article;
2+
3+
public record ArticleResponse(
4+
String title,
5+
String subtitle,
6+
String articleUrl,
7+
String imageUrl
8+
) {
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package eatda.controller.article;
2+
3+
import java.util.List;
4+
5+
public record ArticlesResponse(
6+
List<ArticleResponse> articles
7+
) {
8+
}

src/main/java/eatda/controller/store/CheerController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
package eatda.controller.store;
22

3+
import eatda.controller.web.auth.LoginMember;
34
import eatda.service.store.CheerService;
45
import jakarta.validation.constraints.Max;
56
import jakarta.validation.constraints.Min;
67
import lombok.RequiredArgsConstructor;
8+
import org.springframework.http.HttpStatus;
79
import org.springframework.http.ResponseEntity;
810
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.PostMapping;
912
import org.springframework.web.bind.annotation.RequestParam;
13+
import org.springframework.web.bind.annotation.RequestPart;
1014
import org.springframework.web.bind.annotation.RestController;
15+
import org.springframework.web.multipart.MultipartFile;
1116

1217
@RestController
1318
@RequiredArgsConstructor
1419
public class CheerController {
1520

1621
private final CheerService cheerService;
1722

23+
@PostMapping("/api/cheer")
24+
public ResponseEntity<CheerResponse> registerCheer(@RequestPart("request") CheerRegisterRequest request,
25+
@RequestPart(value = "image", required = false) MultipartFile image,
26+
LoginMember member) {
27+
CheerResponse response = cheerService.registerCheer(request, image, member.id());
28+
return ResponseEntity.status(HttpStatus.CREATED)
29+
.body(response);
30+
}
31+
1832
@GetMapping("/api/cheer")
1933
public ResponseEntity<CheersResponse> getCheers(@RequestParam @Min(1) @Max(50) int size) {
2034
CheersResponse response = cheerService.getCheers(size);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package eatda.controller.store;
2+
3+
public record CheerRegisterRequest(
4+
String storeKakaoId,
5+
String storeName,
6+
String description
7+
) {
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package eatda.controller.store;
2+
3+
import eatda.domain.store.Cheer;
4+
import eatda.domain.store.Store;
5+
6+
public record CheerResponse(
7+
long storeId,
8+
long cheerId,
9+
String imageUrl,
10+
String cheerDescription
11+
) {
12+
13+
public CheerResponse(Cheer cheer, String imageUrl, Store store) {
14+
this(
15+
store.getId(),
16+
cheer.getId(),
17+
imageUrl,
18+
cheer.getDescription()
19+
);
20+
}
21+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package eatda.controller.story;
22

3+
import eatda.domain.store.StoreCategory;
4+
35
public record FilteredSearchResult(
46
String kakaoId,
57
String name,
68
String roadAddress,
79
String lotNumberAddress,
8-
String category
10+
StoreCategory category
911
) {
1012
}

src/main/java/eatda/controller/story/StoryController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class StoryController {
2222
private final StoryService storyService;
2323

2424
@PostMapping("/api/stories")
25-
public ResponseEntity<Void> registerStory(
25+
public ResponseEntity<StoryRegisterResponse> registerStory(
2626
@RequestPart("request") StoryRegisterRequest request,
2727
@RequestPart("image") MultipartFile image,
2828
LoginMember member
2929
) {
30-
storyService.registerStory(request, image, member.id());
31-
return ResponseEntity.status(HttpStatus.CREATED).build();
30+
return ResponseEntity.status(HttpStatus.CREATED)
31+
.body(storyService.registerStory(request, image, member.id()));
3232
}
3333

3434
@GetMapping("api/stories")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package eatda.controller.story;
2+
3+
public record StoryRegisterResponse(
4+
long storyId
5+
) {
6+
}

0 commit comments

Comments
 (0)