Skip to content

Commit

Permalink
Merge pull request #47 from jurumarble/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alsduq1117 authored Sep 10, 2023
2 parents 3c83415 + af0bc50 commit ee28a3f
Show file tree
Hide file tree
Showing 32 changed files with 733 additions and 261 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ dependencies {
//s3 추가
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

//redis 추가
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

}

// Querydsl 설정 추가
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TourAreaBasedListResponse getRestaurantList(@RequestParam("ServiceKey") String s
@GetMapping(value = "/searchKeyword1")
TourSearchKeyWordResponse getRestaurantListByKeyWord(@RequestParam("ServiceKey") String serviceKey,
@RequestParam("contentTypeId") int contentTypeId,
@RequestParam("areaCode") int areaCode,
@RequestParam(value = "areaCode", required = false) Integer areaCode,
@RequestParam("MobileOS") String mobileOS,
@RequestParam("MobileApp") String mobileApp,
@RequestParam("listYN") String listYN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class TourApiService {
private String cat2;


public String getTreatMenu(String contentId) {
public String getFirstMenu(String contentId) {
String decodedServiceKey = decodeServiceKey(serviceKey);
TourDetailIntroResponse introResponse = tourApiClient.getDetailIntro(
decodedServiceKey,
Expand All @@ -53,7 +53,7 @@ public String getTreatMenu(String contentId) {
mobileApp,
responseType);

return introResponse.getTreatMenu();
return introResponse.getFirstMenu();
}

public List<String> getDetailImages(String contentId) {
Expand Down Expand Up @@ -109,7 +109,7 @@ public List<RestaurantInfoDto> getRestaurantInfoByKeyWord(String keyWord, Intege
TourSearchKeyWordResponse restaurantList = tourApiClient.getRestaurantListByKeyWord(
decodedServiceKey,
contentTypeId,
areaCode,
Optional.ofNullable(areaCode).orElse(null),
mobileOS,
mobileApp,
listYN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class TourDetailIntroResponse {
@JsonProperty("response")
private TourDetailIntroResponse.Response response;

public String getTreatMenu() {
return response.getBody().getItems().getItem().get(0).getTreatmenu();
public String getFirstMenu() {
return response.getBody().getItems().getItem().get(0).getFirstmenu();
}

@Data
Expand All @@ -34,7 +34,7 @@ static class Items {

@Data
static class Item {
@JsonProperty("treatmenu")
private String treatmenu;
@JsonProperty("firstmenu")
private String firstmenu;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
import co.kr.jurumarble.comment.dto.request.GetCommentRequest;
import co.kr.jurumarble.comment.dto.request.UpdateCommentRequest;
import co.kr.jurumarble.comment.dto.request.UpdateRestaurantRequest;
import co.kr.jurumarble.comment.enums.CommentType;
import co.kr.jurumarble.comment.enums.Emotion;
import co.kr.jurumarble.comment.enums.Region;
import co.kr.jurumarble.comment.service.CommentService;
import co.kr.jurumarble.comment.service.GetCommentData;
import co.kr.jurumarble.comment.service.SearchRestaurantData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

import static co.kr.jurumarble.utils.ResponseUtils.wrapWithContent;

@RequestMapping("/api")
@RestController
Expand All @@ -29,90 +34,84 @@ public class CommentController {

private final CommentService commentService;

@Operation(summary = "댓글 생성", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'를, 요청 바디에 'parentId'(댓글의 부모 아이디. 대댓글일 경우 부모 댓글 아이디, 없으면 빈 문자열)와 'content'(댓글 내용)을 JSON 형식으로 보내주세요.")
@PostMapping("/votes/{voteId}/comments/create")
public ResponseEntity createComment(@PathVariable Long voteId, @RequestAttribute Long userId, @RequestBody @Valid CreateCommentRequest createCommentRequest) {

commentService.createComment(voteId, userId, createCommentRequest.toServiceRequest());

@Operation(summary = "댓글 생성", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'를, 요청 바디에 'parentId'(댓글의 부모 아이디. 대댓글일 경우 부모 댓글 아이디, 없으면 빈 문자열)와 'content'(댓글 내용)을 JSON 형식으로 보내주세요.")
@PostMapping("/{commentType}/{typeId}/comments/create")
public ResponseEntity createComment(@Valid @RequestBody CreateCommentRequest createCommentRequest, @PathVariable CommentType commentType, @PathVariable Long typeId, @RequestAttribute Long userId) {
commentService.createComment(commentType, typeId, userId, createCommentRequest.toServiceRequest());
return new ResponseEntity(HttpStatus.CREATED);
}


@Operation(summary = "댓글 조회", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'를, 요청 쿼리에 'age'(연령 필터 - 선택), 'mbti'(MBTI 필터 - 선택), 'gender'(성별 필터 - 선택), 'sortBy'(정렬 기준 - ByTime, ByPopularity), 'page'(페이지 번호)와 'size'(페이지 내의 데이터 수)를 JSON 형식으로 보내 주십시오.")
@GetMapping("/votes/{voteId}/comments")
public ResponseEntity<Slice<GetCommentData>> getComment(@PathVariable Long voteId, @ModelAttribute GetCommentRequest getCommentRequest) {

Slice<GetCommentData> getCommentResponses = commentService.getComments(voteId, getCommentRequest.toServiceRequest());

@Operation(summary = "댓글 조회", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'를, 'sortBy'(정렬 기준 - ByTime, ByPopularity), 'page'(페이지 번호)와 'size'(페이지 내의 데이터 수)를 JSON 형식으로 보내 주십시오.")
@GetMapping("/{commentType}/{typeId}/comments")
public ResponseEntity<Page<GetCommentData>> getComment(@ModelAttribute @Valid GetCommentRequest getCommentRequest, @PathVariable CommentType commentType, @PathVariable Long typeId) {
Page<GetCommentData> getCommentResponses = commentService.getComments(commentType, typeId, getCommentRequest.toServiceRequest());
return new ResponseEntity(getCommentResponses, HttpStatus.OK);
}

@Operation(summary = "맛보기 댓글 조회", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'를, 'sortBy'(정렬 기준 - ByTime, ByPopularity), 'page'(페이지 번호)와 'size'(페이지 내의 데이터 수)를 JSON 형식으로 보내 주십시오.")
@GetMapping("/{commentType}/{typeId}/comments/sample")
public ResponseEntity<Map<String, List<GetCommentData>>> getSampleComment(@PathVariable CommentType commentType, @PathVariable Long typeId) {
List<GetCommentData> getCommentResponses = commentService.getSampleComments(commentType, typeId);
return wrapWithContent(getCommentResponses);
}

@Operation(summary = "댓글 수정", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를, 요청 바디에 'content'(수정할 댓글 내용)을 JSON 형식으로 보내주세요.")
@PatchMapping("/votes/{voteId}/comments/{commentId}")
public ResponseEntity updateComment(@PathVariable Long voteId, @PathVariable Long commentId, @Valid @RequestBody UpdateCommentRequest updateCommentRequest, @RequestAttribute Long userId) {

commentService.updateComment(voteId, commentId, userId, updateCommentRequest.toServiceRequest());

@Operation(summary = "댓글 수정", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를, 요청 바디에 'content'(수정할 댓글 내용)을 JSON 형식으로 보내주세요.")
@PutMapping("/{commentType}/{typeId}/comments/{commentId}")
public ResponseEntity updateComment(@Valid @RequestBody UpdateCommentRequest updateCommentRequest, @PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.updateComment(commentType, typeId, commentId, userId, updateCommentRequest.toServiceRequest());
return new ResponseEntity(HttpStatus.OK);
}


@Operation(summary = "댓글 삭제", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를 전달하여 댓글을 삭제하는 기능.")
@DeleteMapping("/votes/{voteId}/comments/{commentId}")
public ResponseEntity deleteComment(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId) {

commentService.deleteComment(voteId, commentId, userId);

@Operation(summary = "댓글 삭제", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'를 전달하여 댓글을 삭제하는 기능.")
@DeleteMapping("/{commentType}/{typeId}/comments/{commentId}")
public ResponseEntity deleteComment(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.deleteComment(commentType, typeId, commentId, userId);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}

@Operation(summary = "댓글 좋아요", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를 전달하여 댓글을 좋아요하는 기능입니다.")
@PostMapping("/votes/{voteId}/comments/{commentId}/likers")
public ResponseEntity likeComment(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId) {

commentService.emoteComment(voteId, commentId, userId, Emotion.LIKE);

@Operation(summary = "댓글 좋아요", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를 전달하여 댓글을 좋아요하는 기능입니다.")
@PostMapping("/{commentType}/{typeId}/comments/{commentId}/likers")
public ResponseEntity likeComment(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.emoteComment(commentType, typeId, commentId, userId, Emotion.LIKE);
return new ResponseEntity(HttpStatus.OK);
}

@Operation(summary = "댓글 싫어요", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를 전달하여 댓글을 싫어요하는 기능입니다.")
@PostMapping("/votes/{voteId}/comments/{commentId}/haters")
public ResponseEntity hateComment(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId) {

commentService.emoteComment(voteId, commentId, userId, Emotion.HATE);


@Operation(summary = "댓글 싫어요", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를 전달하여 댓글을 싫어요하는 기능입니다.")
@PostMapping("/{commentType}/{typeId}/comments/{commentId}/haters")
public ResponseEntity hateComment(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.emoteComment(commentType, typeId, commentId, userId, Emotion.HATE);
return new ResponseEntity(HttpStatus.OK);
}

@Operation(summary = "식당 추가", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를 전달하며, 요청 바디에 업데이트할 음식점 정보를 JSON 형식으로 전달하여 댓글에 추가하는 기능입니다.")
@PutMapping("/votes/{voteId}/comments/{commentId}/restaurant")
public ResponseEntity addRestaurantToComment(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId, @RequestBody UpdateRestaurantRequest updateRestaurantRequest) {

commentService.addRestaurantToComment(voteId, commentId, userId, updateRestaurantRequest.toServiceRequest());

@Operation(summary = "음식점 추가", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를, 요청 바디에 업데이트할 음식점 정보를 JSON 형식으로 전달하여 댓글에 추가하는 기능입니다.")
@PostMapping("/{commentType}/{typeId}/comments/{commentId}/restaurant")
public ResponseEntity addRestaurantToComment(@Valid @RequestBody UpdateRestaurantRequest updateRestaurantRequest, @PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.addRestaurantToComment(commentType, typeId, commentId, userId, updateRestaurantRequest.toServiceRequest());
return new ResponseEntity(HttpStatus.OK);
}

@Operation(summary = "식당 검색", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId'와 'commentId'를 전달하며, 요청 쿼리에 'keyword'(검색 키워드 - 선택)과 'page'(요청 페이지 인덱스)를 전달하여 음식점을 검색하는 기능입니다.")
@GetMapping("/votes/{voteId}/comments/{commentId}/restaurant")
public ResponseEntity<List<SearchRestaurantData>> searchRestaurant(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(required = false) Integer areaCode, @RequestParam int page) {

List<SearchRestaurantData> searchRestaurantResponse = commentService.searchRestaurant(voteId, commentId, userId, keyword, areaCode, page);

@Operation(summary = "음식점 검색", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를, 요청 쿼리에 'keyword'(검색 키워드 - 선택)과 'page'(요청 페이지 인덱스, 1부터 시작)를 전달하여 음식점을 검색하는 기능입니다.")
@GetMapping("/{commentType}/{typeId}/comments/{commentId}/restaurant")
public ResponseEntity<List<SearchRestaurantData>> searchRestaurant(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(required = false) Region region, @RequestParam int page) {
List<SearchRestaurantData> searchRestaurantResponse = commentService.searchRestaurant(commentType, typeId, commentId, userId, keyword, region, page);
return new ResponseEntity(searchRestaurantResponse, HttpStatus.OK);
}

@Operation(summary = "식당 이미지 조회", description = "헤더에 토큰을 포함하고, URL 파라미터에 'voteId', 'commentId'와 'contentId'를 전달하여 특정 음식점의 이미지를 가져오는 기능입니다.")
@GetMapping("/votes/{voteId}/comments/{commentId}/restaurant/{contentId}")
public ResponseEntity<List<String>> getRestaurantImage(@PathVariable Long voteId, @PathVariable Long commentId, @RequestAttribute Long userId, @PathVariable String contentId) {

List<String> restaurantImage = commentService.getRestaurantImage(voteId, commentId, userId, contentId);

@Operation(summary = "음식점 이미지 조회", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id'와 commentId 를 전달하여 특정 음식점의 이미지를 가져오는 기능입니다.")
@GetMapping("/{commentType}/{typeId}/comments/{commentId}/restaurant/{contentId}")
public ResponseEntity<List<String>> getRestaurantImage(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId, @PathVariable String contentId) {
List<String> restaurantImage = commentService.getRestaurantImage(commentType, typeId, commentId, userId, contentId);
return new ResponseEntity(restaurantImage, HttpStatus.OK);
}

@Operation(summary = "음식점 삭제", description = "헤더에 토큰을 포함하고, URL 파라미터에 'type'(votes 또는 drinks)와 해당 타입'id 전달하여 음식점을 삭제하는 기능입니다.")
@DeleteMapping("/{commentType}/{typeId}/comments/{commentId}/restaurant")
public ResponseEntity<List<String>> deleteRestaurant(@PathVariable CommentType commentType, @PathVariable Long typeId, @PathVariable Long commentId, @RequestAttribute Long userId) {
commentService.deleteRestaurant(commentType, typeId, commentId, userId);
return new ResponseEntity(HttpStatus.OK);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.kr.jurumarble.comment.controller.converter;

import co.kr.jurumarble.comment.enums.CommentType;
import org.springframework.core.convert.converter.Converter;

public class StringToEnumConverter implements Converter<String, CommentType> {

@Override
public CommentType convert(String source) {
return CommentType.valueOf(source.toUpperCase());
}
}
10 changes: 9 additions & 1 deletion src/main/java/co/kr/jurumarble/comment/domain/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class Comment extends BaseTimeEntity {
@Column(name = "vote_id")
private Long voteId;

@Column(name = "drink_id")
private Long drinkId;

private String content;

@Enumerated(EnumType.STRING)
Expand Down Expand Up @@ -69,9 +72,10 @@ public class Comment extends BaseTimeEntity {
private Restaurant restaurant = new Restaurant();

@Builder
public Comment(User user, Long voteId, String content, AgeType age, MbtiType mbti, GenderType gender, Comment parent) {
public Comment(User user, Long voteId, Long drinkId, String content, AgeType age, MbtiType mbti, GenderType gender, Comment parent) {
this.user = user;
this.voteId = voteId;
this.drinkId = drinkId;
this.content = content;
this.age = age;
this.mbti = mbti;
Expand Down Expand Up @@ -112,4 +116,8 @@ public void updateRestaurant(UpdateRestaurantServiceRequest request) {
}
restaurant.updateRestaurant(request.getRestaurantName(), request.getRestaurantImage());
}

public void removeRestaurant() {
this.restaurant = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UpdateRestaurantRequest {
@NotNull
private String restaurantName;
private String restaurantImage;

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/co/kr/jurumarble/comment/enums/CommentType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package co.kr.jurumarble.comment.enums;

import co.kr.jurumarble.common.enums.EnumModel;

public enum CommentType implements EnumModel {
VOTES("투표"),
DRINKS("우리술");

private String value;

CommentType(String value) {
this.value = value;
}

@Override
public String getKey() {
return name();
}

@Override
public String getValue() {
return value;
}
}
Loading

0 comments on commit ee28a3f

Please sign in to comment.