Skip to content

Commit

Permalink
Merge pull request #30 from hyundai-fruitfruit/fix/review-res
Browse files Browse the repository at this point in the history
Fix/review res 응답 형식 변경
  • Loading branch information
sooyoungh authored Mar 11, 2024
2 parents 7dac915 + e5918ab commit 92bc202
Show file tree
Hide file tree
Showing 23 changed files with 396 additions and 39 deletions.
40 changes: 37 additions & 3 deletions src/main/java/com/hyundai/app/event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import java.util.List;

/**
* The type Event service.
*
* @author 엄상은
* @since 2024/02/18
* 사용자용 + 어드민용 이벤트 서비스
* @since 2024 /02/18 사용자용 + 어드민용 이벤트 서비스
*/
@Log4j
@RequiredArgsConstructor
Expand All @@ -35,6 +36,10 @@ public class EventService {
private final MemberCouponMapper memberCouponMapper;
private final CouponMapper couponMapper;

/**
* @author
* @since 2024 /02/ (설명)
*/
public List<EventDetailResDto> findCurrentEventByEventType(String memberId) {

List<EventDetailResDto> eventDetailResDtoList = eventMapper.findCurrentEventByEventType(memberId);
Expand All @@ -47,6 +52,10 @@ public List<EventDetailResDto> findCurrentEventByEventType(String memberId) {
return eventDetailResDtoList;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventListResDto findEventList(int storeId, int page, int size) {
IdWithCriteria idWithCriteria = IdWithCriteria.of(storeId, page, size);
List<EventDetailResDto> eventDetailResDtoList = eventMapper.findEventList(idWithCriteria);
Expand All @@ -61,13 +70,21 @@ public EventListResDto findEventList(int storeId, int page, int size) {
return eventListResDto;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventDetailResDto find(int storeId, int eventId) {
EventDetailResDto eventDetailResDto = findEventAndValidate(storeId, eventId);
List<EventActiveTimeZoneDto> eventActiveTimeZoneDto = findEventActiveTime(eventId);
eventDetailResDto.setActiveTimeList(eventActiveTimeZoneDto);
return eventDetailResDto;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventDetailResDto findEventAndValidate(int storeId, int eventId) {
EventDetailResDto eventDetailResDto = eventMapper.findById(eventId);
if (eventDetailResDto == null) {
Expand Down Expand Up @@ -97,6 +114,10 @@ private List<EventActiveTimeZoneDto> findEventActiveTime(int eventId) {
return eventActiveTimeZoneDto;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventDetailResDto save(int storeId, EventSaveReqDto eventSaveReqDto) {
int eventId = saveEvent(storeId, eventSaveReqDto);
saveEventActiveTime(eventId, eventSaveReqDto);
Expand All @@ -118,19 +139,31 @@ private void saveEventActiveTime(int eventId, EventSaveReqDto eventSaveReqDto) {
});
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventSaveReqDto update(int storeId, int eventId, EventSaveReqDto eventSaveReqDto) {
findEventAndValidate(storeId, eventId);
eventSaveReqDto.setId(eventId);
eventMapper.update(eventSaveReqDto);
return eventSaveReqDto;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public Void delete(int storeId, int eventId) {
findEventAndValidate(storeId, eventId);
eventMapper.delete(eventId);
return null;
}

/**
* @author
* @since 2024 /02/ (설명)
*/
public EventParticipateResDto participateEvent(String memberId, int eventId) {
EventDetailResDto eventDetailResDto = findAvailableEvent(eventId);
EventParticipateResDto eventVisitResDto = EventParticipateResDto.of(eventDetailResDto);
Expand Down Expand Up @@ -184,12 +217,13 @@ public EventDetailResDto getRandomSpotDetail(String eventType) {
return eventDetailResDto;
}



/**
* @author 최성혁
* @since 2024/02/27
* 특정 이벤트에 참여중인 회원 목록
*/

public List<MemberEventDetailsResDto> findEventParticipants(int eventId, int id) {
List<MemberEventDetailsResDto> participants = memberEventMapper.getMemberEventDetails(eventId);

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/hyundai/app/guide/GuideController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public class GuideController {
@Qualifier("hashtagServiceImpl")
private HashtagService hashtagService;

@Autowired
private GuideService guideService;

@GetMapping
@ApiOperation("전체 가이드 조회")
public ResponseEntity<List<GuideTypeResDto>> getGuideAll() {
List<GuideTypeResDto> guideTypeList = GuideType.getGuideResDtoAll();
List<GuideTypeResDto> guideTypeList = guideService.getGuideAll();
log.debug("전체 가이드 조회 : " + guideTypeList);
return new ResponseEntity<>(guideTypeList, HttpStatus.ACCEPTED);
}
Expand All @@ -44,7 +47,7 @@ public ResponseEntity<List<GuideTypeResDto>> getGuideAll() {
@ApiOperation("분류별 해시태그 조회 - 해당 분류의 모든 해시태그 조회하기 - 식당/쇼핑 매장")
public ResponseEntity<List<HashtagListResDto>> getGuideByCategory(@PathVariable("guideType") String guideType) {
log.debug("분류별 해시태그 조회 => guideType : " + guideType);
List<HashtagListResDto> hashtagListResDto = hashtagService.getHashtagAllByGuideType(guideType);
List<HashtagListResDto> hashtagListResDto = guideService.getHashtagCategoryAll(guideType);
return new ResponseEntity<>(hashtagListResDto, HttpStatus.ACCEPTED);
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/hyundai/app/guide/GuideMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hyundai.app.guide;

import com.hyundai.app.guide.domain.Guide;
import com.hyundai.app.guide.domain.HashtagCategory;

import java.util.List;

/**
* @author 황수영
* @since 2024/03/09
* (설명)
*/
public interface GuideMapper {

List<Guide> getGuideAll();
List<HashtagCategory> getHashtagCategoryAll();
}
66 changes: 66 additions & 0 deletions src/main/java/com/hyundai/app/guide/GuideService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.hyundai.app.guide;

import com.hyundai.app.guide.domain.Guide;
import com.hyundai.app.guide.domain.HashtagCategory;
import com.hyundai.app.guide.dto.GuideTypeResDto;
import com.hyundai.app.guide.dto.HashtagListResDto;
import com.hyundai.app.store.domain.Hashtag;
import com.hyundai.app.store.mapper.HashtagMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

/**
* @author 황수영
* @since 2024/03/09
* (설명)
*/
@Log4j
@Service
@RequiredArgsConstructor
public class GuideService {

private final GuideMapper guideMapper;
private final HashtagMapper hashtagMapper;

public List<GuideTypeResDto> getGuideAll() {
List<Guide> guideList = guideMapper.getGuideAll();
List<GuideTypeResDto> guideTypeList = GuideType.of(guideList);
log.debug("GuideService 전체 가이드 조회 : " + guideTypeList);
return guideTypeList;
}

/**
* @author 황수영
* @since 2024/02/26
* 분류별 해시태그 전체 조회
*/
public List<HashtagListResDto> getHashtagCategoryAll(String guideType) {
log.debug("분류별 해시태그 조회 분류 : " + guideType);
GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase());
log.debug("분류별 해시태그 조회 분류 : " + guideTypeEnum);

List<HashtagCategory> hashtagCategories = guideMapper.getHashtagCategoryAll();

// TODO: 캐싱 필요!
List<HashtagListResDto> result = new ArrayList<>();

for (String category : guideTypeEnum.getHashtagType()) {
List<Hashtag> hashtags = hashtagMapper.getHashtagByCategory(category);
String korean = hashtagCategories.stream()
.filter(h -> h.getTitle().equals(category))
.findFirst()
.map(HashtagCategory::getKorean)
.orElseThrow(NoSuchElementException::new);
// 한글로 변경
HashtagListResDto hashtagListResDto = new HashtagListResDto(korean, hashtags);
result.add(hashtagListResDto);
log.debug("분류별 해시태그 조회 => category : " + category + " : " + hashtagListResDto);
}
return result;
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/hyundai/app/guide/GuideType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hyundai.app.guide;

import com.hyundai.app.guide.domain.Guide;
import com.hyundai.app.guide.dto.GuideTypeResDto;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -24,11 +25,18 @@ public enum GuideType {

private final int id;
private final String korean;
private final List<String> category;
private final List<String> hashtagType;

public static List<GuideTypeResDto> getGuideResDtoAll() {
return Arrays.stream(GuideType.values())
.map(g -> new GuideTypeResDto(g, g.korean, g.category))
.map(g -> new GuideTypeResDto(g, g.korean, g.hashtagType))
.collect(Collectors.toList());
}

public static List<GuideTypeResDto> of(List<Guide> guides) {

return guides.stream()
.map(g -> new GuideTypeResDto(GuideType.valueOf(g.getGuideType()), g.getKorean(), GuideType.valueOf(g.getGuideType()).getHashtagType()))
.collect(Collectors.toList());
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/hyundai/app/guide/HashtagType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hyundai.app.guide;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* @author 황수영
* @since 2024/03/09
* (설명)
*/
@Getter
@AllArgsConstructor
public enum HashtagType {

FOOD(10000, "음식"),
ATMOSPHERE(10001, "분위기"),
ETC(10002, "가격");

private final int id;
private final String korean;
}
22 changes: 22 additions & 0 deletions src/main/java/com/hyundai/app/guide/domain/Guide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.hyundai.app.guide.domain;

import lombok.*;

import java.util.List;

/**
* @author 황수영
* @since 2024/03/09
* (설명)
*/
@Getter
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Guide {

private int id;
private String korean;
private String guideType;
}
18 changes: 18 additions & 0 deletions src/main/java/com/hyundai/app/guide/domain/HashtagCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.hyundai.app.guide.domain;

import lombok.*;

/**
* @author 황수영
* @since 2024/03/09
* (설명)
*/
@Getter
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class HashtagCategory {
private String title;
private String korean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
public class HashtagListResDto {

private String title;
// private String korean;
private List<Hashtag> hashtags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.hyundai.app.store.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
Expand All @@ -22,6 +23,7 @@
* @since 2024/02/13
* 매장 관련 기능 컨트롤러
*/
@Log4j
@Api("매장 관련 API")
@RestController
@RequestMapping("/api/v1/stores")
Expand Down Expand Up @@ -57,6 +59,7 @@ public ResponseEntity<Void> createReview(
@RequestPart(value = "imageList", required = false) List<MultipartFile> imageList,
@ApiIgnore @MemberId String memberId
) {
log.debug("매장 리뷰 작성 API" + reviewReqDto.toString());
storeService.createReview(storeId, memberId, reviewReqDto, imageList);
return new ResponseEntity<>(HttpStatus.ACCEPTED);
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/hyundai/app/store/domain/Hashtag.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ public class Hashtag {
private int id;
private String name;
private String category;

public static Hashtag from(int id) {
Hashtag hashtag = new Hashtag();
hashtag.id = id;
return hashtag;
}

}
23 changes: 23 additions & 0 deletions src/main/java/com/hyundai/app/store/domain/Image.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.hyundai.app.store.domain;

import lombok.*;

/**
* @author 황수영
* @since 2024/03/04
* (설명)
*/

@Getter
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Image {

private int id;
private String imgUrl;
private int storeId;
private String memberId;
private String reviewId;
}
Loading

0 comments on commit 92bc202

Please sign in to comment.