Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] feat: DTO 코드 컨벤션 적용 (#148) #433

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions backend/src/main/java/com/festago/dto/EntryCodeResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import com.festago.domain.EntryCode;

public record EntryCodeResponse(String code, Long period) {
public record EntryCodeResponse(
String code,
Long period) {

public static EntryCodeResponse of(EntryCode entryCode) {
return new EntryCodeResponse(entryCode.getCode(), entryCode.getPeriod());
return new EntryCodeResponse(
entryCode.getCode(),
entryCode.getPeriod());
}
}
4 changes: 3 additions & 1 deletion backend/src/main/java/com/festago/dto/ErrorResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.festago.exception.ErrorCode;
import com.festago.exception.FestaGoException;

public record ErrorResponse(ErrorCode errorCode, String message) {
public record ErrorResponse(
ErrorCode errorCode,
String message) {

public static ErrorResponse from(FestaGoException festaGoException) {
return ErrorResponse.from(festaGoException.getErrorCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import java.time.LocalDate;
import java.util.Objects;

public record FestivalCreateRequest(String name, LocalDate startDate, LocalDate endDate, String thumbnail) {
public record FestivalCreateRequest(
String name,
LocalDate startDate,
LocalDate endDate,
String thumbnail) {

public Festival toEntity() {
if (Objects.isNull(thumbnail) || thumbnail.isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import java.time.LocalDate;
import java.util.List;

public record FestivalDetailResponse(Long id,
String name,
LocalDate startDate,
LocalDate endDate,
String thumbnail,
List<FestivalDetailStageResponse> stages) {
public record FestivalDetailResponse(
Long id,
String name,
LocalDate startDate,
LocalDate endDate,
String thumbnail,
List<FestivalDetailStageResponse> stages) {

public static FestivalDetailResponse of(Festival festival, List<Stage> stages) {
List<FestivalDetailStageResponse> stageResponses = stages.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import java.time.LocalDateTime;
import java.util.List;

public record FestivalDetailStageResponse(Long id,
LocalDateTime startTime,
LocalDateTime ticketOpenTime,
String lineUp,
List<FestivalDetailTicketResponse> tickets) {
public record FestivalDetailStageResponse(
Long id,
LocalDateTime startTime,
LocalDateTime ticketOpenTime,
String lineUp,
List<FestivalDetailTicketResponse> tickets) {

public static FestivalDetailStageResponse from(Stage stage) {
List<FestivalDetailTicketResponse> tickets = stage.getTickets().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.festago.domain.TicketAmount;
import com.festago.domain.TicketType;

public record FestivalDetailTicketResponse(Long id,
TicketType ticketType,
Integer totalAmount,
Integer remainAmount) {
public record FestivalDetailTicketResponse(
Long id,
TicketType ticketType,
Integer totalAmount,
Integer remainAmount) {

public static FestivalDetailTicketResponse from(Ticket ticket) {
TicketAmount ticketAmount = ticket.getTicketAmount();
Expand Down
7 changes: 6 additions & 1 deletion backend/src/main/java/com/festago/dto/FestivalResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import com.festago.domain.Festival;
import java.time.LocalDate;

public record FestivalResponse(Long id, String name, LocalDate startDate, LocalDate endDate, String thumbnail) {
public record FestivalResponse(
Long id,
String name,
LocalDate startDate,
LocalDate endDate,
String thumbnail) {

public static FestivalResponse from(Festival festival) {
return new FestivalResponse(
Expand Down
3 changes: 2 additions & 1 deletion backend/src/main/java/com/festago/dto/FestivalsResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.festago.domain.Festival;
import java.util.List;

public record FestivalsResponse(List<FestivalResponse> festivals) {
public record FestivalsResponse(
List<FestivalResponse> festivals) {

public static FestivalsResponse from(List<Festival> festivals) {
return festivals.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import com.festago.domain.Festival;

public record MemberTicketFestivalResponse(Long id, String name, String thumbnail) {
public record MemberTicketFestivalResponse(
Long id,
String name,
String thumbnail) {

public static MemberTicketFestivalResponse from(Festival festival) {
return new MemberTicketFestivalResponse(festival.getId(), festival.getName(), festival.getThumbnail());
return new MemberTicketFestivalResponse(
festival.getId(),
festival.getName(),
festival.getThumbnail());
}
}
15 changes: 8 additions & 7 deletions backend/src/main/java/com/festago/dto/MemberTicketResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import com.festago.domain.Stage;
import java.time.LocalDateTime;

public record MemberTicketResponse(Long id,
Integer number,
LocalDateTime entryTime,
EntryState state,
LocalDateTime reservedAt,
StageResponse stage,
MemberTicketFestivalResponse festival) {
public record MemberTicketResponse(
Long id,
Integer number,
LocalDateTime entryTime,
EntryState state,
LocalDateTime reservedAt,
StageResponse stage,
MemberTicketFestivalResponse festival) {

private static final MemberTicketResponse EMPTY = new MemberTicketResponse(-1L, null, null, null, null, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.festago.domain.MemberTicket;
import java.util.List;

public record MemberTicketsResponse(List<MemberTicketResponse> memberTickets) {
public record MemberTicketsResponse(
List<MemberTicketResponse> memberTickets) {

public static MemberTicketsResponse from(List<MemberTicket> memberTickets) {
return memberTickets.stream()
Expand Down
9 changes: 5 additions & 4 deletions backend/src/main/java/com/festago/dto/StageCreateRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import java.time.LocalDateTime;

public record StageCreateRequest(LocalDateTime startTime,
String lineUp,
LocalDateTime ticketOpenTime,
Long festivalId) {
public record StageCreateRequest(
LocalDateTime startTime,
String lineUp,
LocalDateTime ticketOpenTime,
Long festivalId) {

}
4 changes: 3 additions & 1 deletion backend/src/main/java/com/festago/dto/StageResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.festago.domain.Stage;
import java.time.LocalDateTime;

public record StageResponse(Long id, LocalDateTime startTime) {
public record StageResponse(
Long id,
LocalDateTime startTime) {

public static StageResponse from(Stage stage) {
return new StageResponse(stage.getId(), stage.getStartTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.festago.domain.TicketAmount;
import com.festago.domain.TicketType;

public record StageTicketResponse(Long id,
TicketType ticketType,
Integer totalAmount,
Integer remainAmount) {
public record StageTicketResponse(
Long id,
TicketType ticketType,
Integer totalAmount,
Integer remainAmount) {

public static StageTicketResponse from(Ticket ticket) {
TicketAmount ticketAmount = ticket.getTicketAmount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.festago.domain.Ticket;
import java.util.List;

public record StageTicketsResponse(List<StageTicketResponse> tickets) {
public record StageTicketsResponse(
List<StageTicketResponse> tickets) {

public static StageTicketsResponse from(List<Ticket> tickets) {
return tickets.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.festago.domain.TicketType;
import java.time.LocalDateTime;

public record TicketCreateRequest(Long stageId, TicketType ticketType, Integer amount, LocalDateTime entryTime) {
public record TicketCreateRequest(
Long stageId,
TicketType ticketType,
Integer amount,
LocalDateTime entryTime) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import com.festago.domain.Ticket;

public record TicketCreateResponse(Long id) {
public record TicketCreateResponse(
Long id) {

public static TicketCreateResponse from(Ticket ticket) {
return new TicketCreateResponse(ticket.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.festago.dto;

public record TicketValidationRequest(String code) {
public record TicketValidationRequest(
String code) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.festago.domain.EntryState;
import com.festago.domain.MemberTicket;

public record TicketValidationResponse(EntryState updatedState) {
public record TicketValidationResponse(
EntryState updatedState) {

public static TicketValidationResponse from(MemberTicket memberTicket) {
return new TicketValidationResponse(memberTicket.getEntryState());
Expand Down
3 changes: 2 additions & 1 deletion backend/src/main/java/com/festago/dto/TicketingRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.festago.dto;

public record TicketingRequest(Long ticketId) {
public record TicketingRequest(
Long ticketId) {

}
7 changes: 4 additions & 3 deletions backend/src/main/java/com/festago/dto/TicketingResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import com.festago.domain.MemberTicket;
import java.time.LocalDateTime;

public record TicketingResponse(Long id,
Integer number,
LocalDateTime entryTime) {
public record TicketingResponse(
Long id,
Integer number,
LocalDateTime entryTime) {

public static TicketingResponse from(MemberTicket memberTicket) {
return new TicketingResponse(
Expand Down