-
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 pull request #80 from everymeals/feature/store-get-detail
[feature/store-get-detail] 주변 식당 리뷰 조회 기능을 개발
- Loading branch information
Showing
17 changed files
with
414 additions
and
4 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
12 changes: 12 additions & 0 deletions
12
src/main/java/everymeal/server/global/util/swagger/ApiErrorCodeExample.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,12 @@ | ||
package everymeal.server.global.util.swagger; | ||
|
||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.METHOD) | ||
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) | ||
public @interface ApiErrorCodeExample { | ||
Class<? extends BaseExceptionList> value(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/everymeal/server/global/util/swagger/BaseExceptionList.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,11 @@ | ||
package everymeal.server.global.util.swagger; | ||
|
||
|
||
import everymeal.server.global.exception.ApplicationException; | ||
|
||
public interface BaseExceptionList { | ||
|
||
public ApplicationException getErrorReason(); | ||
|
||
String getExplainError() throws NoSuchFieldException; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/everymeal/server/global/util/swagger/ExampleHolder.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,14 @@ | ||
package everymeal.server.global.util.swagger; | ||
|
||
|
||
import io.swagger.v3.oas.models.examples.Example; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ExampleHolder { | ||
private Example holder; | ||
private String name; | ||
private String code; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/everymeal/server/global/util/swagger/ExplainError.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,17 @@ | ||
package everymeal.server.global.util.swagger; | ||
|
||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Component | ||
public @interface ExplainError { | ||
String value() default ""; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/everymeal/server/global/util/swagger/UserExceptionList.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,32 @@ | ||
package everymeal.server.global.util.swagger; | ||
|
||
|
||
import everymeal.server.global.exception.ApplicationException; | ||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum UserExceptionList implements BaseExceptionList { | ||
USER_NOTFOUND("USR0001", HttpStatus.NOT_FOUND, "등록된 유저가 아닙니다."), | ||
; | ||
|
||
public final String CODE; | ||
public final HttpStatus httpStatus; | ||
public final String MESSAGE; | ||
|
||
@Override | ||
public ApplicationException getErrorReason() { | ||
return new ApplicationException(getCODE(), getHttpStatus(), getMESSAGE()); | ||
} | ||
|
||
@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(); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/main/java/everymeal/server/store/controller/dto/response/StoreGetReviewRes.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,41 @@ | ||
package everymeal.server.store.controller.dto.response; | ||
|
||
|
||
import everymeal.server.global.util.aws.S3Util; | ||
import java.time.LocalDateTime; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public record StoreGetReviewRes( | ||
Integer reviewIdx, | ||
String content, | ||
Integer grade, | ||
LocalDateTime createdAt, | ||
String nickName, | ||
String profileImageUrl, | ||
Integer recommendedCount, | ||
List<String> images) { | ||
|
||
public static List<StoreGetReviewRes> of(List<Map<String, Object>> storeReview) { | ||
return storeReview.stream() | ||
.map( | ||
review -> { | ||
List<String> images = null; | ||
if (review.get("images") != null) { | ||
images = Arrays.asList(((String) review.get("images")).split(",")); | ||
images.replaceAll(S3Util::getImgUrl); | ||
} | ||
return new StoreGetReviewRes( | ||
(Integer) review.get("reviewIdx"), | ||
(String) review.get("content"), | ||
(Integer) review.get("grade"), | ||
(LocalDateTime) review.get("createdAt"), | ||
(String) review.get("nickName"), | ||
(String) review.get("profileImageUrl"), | ||
(Integer) review.get("recommendedCount"), | ||
images); | ||
}) | ||
.toList(); | ||
} | ||
} |
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
Oops, something went wrong.