Skip to content

Commit

Permalink
✨ Feature/#16 - 온기 우편함 조회 API 구현 (#89)
Browse files Browse the repository at this point in the history
* ✨ feature/#16 : 5.2 온기 우편함 조회 response dto 정의

Signed-off-by: EunJiJung <[email protected]>

* ♻️ refactor/#16 : 온기우편함 response dto에 onjungtype 추가

Signed-off-by: EunJiJung <[email protected]>

* ✨ feature/#16 : onjung type enum 추가

Signed-off-by: EunJiJung <[email protected]>

* ✨ feature/#16 : 5.2 온기 우편함 조회 http 메서드 정의

Signed-off-by: EunJiJung <[email protected]>

* 🐞 bugfix/#16 : datetime util 네이밍 변경

Signed-off-by: EunJiJung <[email protected]>

* 🐞 bugfix/#16 : EventDto 매핑 에러 픽스

Signed-off-by: EunJiJung <[email protected]>

* 🔨 merge/#16 : merge dev

Signed-off-by: EunJiJung <[email protected]>

* ♻️ refactor/#16 : onjung list 조회 service 변경

Signed-off-by: EunJiJung <[email protected]>

* ♻️ refactor/#16 : 사용하지 않는 jpa 제거

Signed-off-by: EunJiJung <[email protected]>

* ♻️ refactor/#16 : donation, receipt, share 날짜가 포함된 이벤트 기간의 event 가져오기로 변경

Signed-off-by: EunJiJung <[email protected]>

* 🐞 bugfix/#16 : 온기우편함 조회 api 버그 픽스

Signed-off-by: EunJiJung <[email protected]>

---------

Signed-off-by: EunJiJung <[email protected]>
  • Loading branch information
bianbbc87 authored Nov 23, 2024
1 parent fc38784 commit a46e837
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 13 deletions.
7 changes: 7 additions & 0 deletions http/Event/EventControllerHttpRequest.http
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 5.2 온기 우편함 조회
// @no-log
GET {{host_url}}/api/v1/onjungs/events/overviews?
page={{event.API_5_2.page}}&
size={{event.API_5_2.size}}
Authorization: Bearer {{access_token}}

### 5.3 나의 식권 조회
// @no-log
GET {{host_url}}/api/v1/tickets?
Expand Down
8 changes: 7 additions & 1 deletion http/onjung/OnjungControllerHttpRequest.http
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ Authorization: Bearer {{access_token}}
Content-Type: application/json

{
"event_id": {{onjung.API_4_7.event_id}},
"donation_amount": {{onjung.API_4_7.donation_amount}}
}

### 4.8 나의 온기 조회하기
### 4.8 함께한 식당 조회하기
// @no-log
GET {{host_url}}/api/v1/users/onjungs/overviews
Authorization: Bearer {{access_token}}

### 4.9 나의 온기 조회하기
// @no-log
GET {{host_url}}/api/v1/users/onjungs/briefs
Authorization: Bearer {{access_token}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.daon.onjung.account.domain.Store;
import com.daon.onjung.account.domain.type.EOnjungTag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -66,4 +64,5 @@ List<Store> findStoresByEarliestEventOrdered(
// store id와 일치하는 share의 count에 100을 곱한 금액
@Query("SELECT SUM(s.count * 100) FROM Share s WHERE s.store.id = :storeId")
Integer sumShareAmountByStoreId(@Param("storeId") Long storeId);

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.daon.onjung.company.application.dto.response;

import com.daon.onjung.core.dto.SelfValidating;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Getter;

import java.util.List;

@Getter
public class ReadCompanyBriefResponseDto {
public class ReadCompanyBriefResponseDto extends SelfValidating<ReadCompanyBriefResponseDto> {

@JsonProperty("company_images")
private final List<String> companyImages;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/daon/onjung/core/utility/DateTimeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,24 @@ public static String convertLocalDateTimeToCustomDateTime(LocalDateTime dateTime
* @return String
*/
public static String convertLocalDateToDotSeparatedDateTime(LocalDate date) {
if (date == null) {
return null; // 온기 우편함 조회 null 처리
}

return date.format(DotSeparatedDateFormatter);
}

/**
* 나의 온기 우편함 조회 시간 포맷팅: "yyyy.MM.dd"
*
* @param startDate LocalDateTime
* @param endDate LocalDateTime
* @return String
*/
public static String convertLocalDatesToDotSeparatedDatePeriod(LocalDate startDate, LocalDate endDate) {
return startDate.format(DotSeparatedDateFormatter) + " - " + endDate.format(DotSeparatedDateFormatter);
}


/**
* String을 LocalDate 형식으로 변환 (yyyy. MM. dd)
Expand Down Expand Up @@ -243,3 +258,4 @@ public static String formatDateString(String dateString) {
throw new IllegalArgumentException("Unrecognized date format: " + dateString);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.daon.onjung.core.annotation.security.AccountID;
import com.daon.onjung.core.dto.ResponseDto;
import com.daon.onjung.event.application.dto.response.ReadOnjungEventOverviewResponseDto;
import com.daon.onjung.event.application.dto.response.ReadTicketBriefResponseDto;
import com.daon.onjung.event.application.dto.response.ReadTicketCountResponseDto;
import com.daon.onjung.event.application.dto.response.ReadTicketResponseDto;
import com.daon.onjung.event.application.usecase.ReadOnjungEventOverviewUseCase;
import com.daon.onjung.event.application.usecase.ReadTicketBriefUseCase;
import com.daon.onjung.event.application.usecase.ReadTicketCountUseCase;
import com.daon.onjung.event.application.usecase.ReadTicketUseCase;
Expand All @@ -21,6 +23,25 @@ public class TicketQueryV1Controller {
private final ReadTicketUseCase readTicketUseCase;
private final ReadTicketBriefUseCase readTicketBriefUseCase;
private final ReadTicketCountUseCase readTicketCountUseCase;
private final ReadOnjungEventOverviewUseCase readOnjungEventOverviewUseCase;

/**
* 5.2 온기 우편함 조회하기
*/
@GetMapping("/onjungs/events/overviews")
public ResponseDto<ReadOnjungEventOverviewResponseDto> readOnjungEventOverview(
@RequestParam(value = "page") Integer page,
@RequestParam(value = "size") Integer size,
@AccountID UUID accountId
) {
return ResponseDto.ok(
readOnjungEventOverviewUseCase.execute(
page,
size,
accountId
)
);
}

/**
* 5.3 나의 식권 조회하기
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package com.daon.onjung.event.application.dto.response;

import com.daon.onjung.account.domain.type.EOnjungTag;
import com.daon.onjung.event.domain.type.EStatus;
import com.daon.onjung.onjung.domain.type.EOnjungType;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Getter;

import java.util.List;

@Getter
public class ReadOnjungEventOverviewResponseDto {

@NotNull(message = "has_next는 null일 수 없습니다.")
@JsonProperty("has_next")
private final Boolean hasNext;

@JsonProperty("event_list")
private final List<EventDto> eventDtos;

@Builder
public ReadOnjungEventOverviewResponseDto(
Boolean hasNext,
List<EventDto> eventDtos
) {
this.hasNext = hasNext;
this.eventDtos = eventDtos;
}

public static ReadOnjungEventOverviewResponseDto fromPage(
List<EventDto> eventDtos,
boolean hasNext
) {

return ReadOnjungEventOverviewResponseDto.builder()
.hasNext(hasNext)
.eventDtos(eventDtos)
.build();
}


@Getter
public static class EventDto {

@JsonProperty("store_info")
private final StoreInfoDto storeInfo;

@NotNull(message = "onjung_type은 null일 수 없습니다.")
@JsonProperty("onjung_type")
private final EOnjungType onjungType;

@NotNull(message = "status는 null일 수 없습니다.")
@JsonProperty("status")
private final EStatus status;

@JsonProperty("event_period")
private final String eventPeriod;

@JsonProperty("store_delivery_date")
private final String storeDeliveryDate;

@JsonProperty("ticket_issue_date")
private final String ticketIssueDate;

@JsonProperty("report_date")
private final String reportDate;

@Builder
public EventDto(
StoreInfoDto storeInfo,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
String storeDeliveryDate,
String ticketIssueDate,
String reportDate
) {
this.storeInfo = storeInfo;
this.onjungType = onjungType;
this.status = status;
this.eventPeriod = eventPeriod;
this.storeDeliveryDate = storeDeliveryDate;
this.ticketIssueDate = ticketIssueDate;
this.reportDate = reportDate;
}

public static EventDto fromEntity(
StoreInfoDto storeInfo,
EOnjungType onjungType,
EStatus status,
String eventPeriod,
String storeDeliveryDate,
String ticketIssueDate,
String reportDate
) {

return EventDto.builder()
.storeInfo(storeInfo)
.onjungType(onjungType)
.status(status)
.eventPeriod(eventPeriod)
.storeDeliveryDate(storeDeliveryDate)
.ticketIssueDate(ticketIssueDate)
.reportDate(reportDate)
.build();
}


@Getter
public static class StoreInfoDto {

@NotNull(message = "logo_img_url은 null일 수 없습니다.")
@JsonProperty("logo_img_url")
private final String logoImgUrl;

@NotNull(message = "title은 null일 수 없습니다.")
@JsonProperty("title")
private final String title;

@NotNull(message = "name는 null일 수 없습니다.")
@JsonProperty("name")
private final String name;

@Builder
public StoreInfoDto(
String logoImgUrl,
String title,
String name
) {
this.logoImgUrl = logoImgUrl;
this.title = title;
this.name = name;
}

public static StoreInfoDto fromEntity(
String logoImgUrl,
String title,
String name
) {

return StoreInfoDto.builder()
.logoImgUrl(logoImgUrl)
.title(title)
.name(name)
.build();
}
}
}
}
Loading

0 comments on commit a46e837

Please sign in to comment.