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

✨ Feat: DTO 추가, ErrorStatus 추가 #2

Closed
wants to merge 3 commits into from
Closed
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
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.trendithon.timetris.domain.mainpage.domain;

import com.trendithon.timetris.domain.login.domain.User;
import com.trendithon.timetris.domain.mainpage.dto.CategoryCreateDTO;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -21,4 +22,15 @@ public class Category {
@JoinColumn(name = "userId")
private User user;

public Category(CategoryCreateDTO categoryCreateDTO, User user){
this.name = categoryCreateDTO.getName();
this.colorCode = categoryCreateDTO.getColorCode();
this.user = user;
}

public void updateCategory(String name, String colorCode){
this.name = name;
this.colorCode = colorCode;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.login.domain.User;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class CategoryCreateDTO {

private String name;
private String colorCode;
private User user;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.trendithon.timetris.domain.mainpage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class CategoryViewDTO {

private String name;
private String colorCode;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Category;
import com.trendithon.timetris.domain.mainpage.domain.UserDate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalTime;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class DoCreateDTO {

private String title;
private LocalTime startTime;
private LocalTime endTime;
private Category category;
private UserDate userDate;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Category;
import com.trendithon.timetris.domain.mainpage.domain.Date;
import com.trendithon.timetris.domain.mainpage.domain.Do;
import com.trendithon.timetris.domain.mainpage.domain.UserDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalTime;

@Getter
@Builder
@AllArgsConstructor @NoArgsConstructor
public class DoViewDTO {

private String title;
private LocalTime startTime;
private LocalTime endTime;
private Category category;

public static DoViewDTO of(Do does){
return DoViewDTO.builder()
.title(does.getTitle())
.startTime(does.getStartTime())
.endTime(does.getEndTime())
.category(does.getCategory())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Do;
import com.trendithon.timetris.domain.mainpage.domain.Plan;
import com.trendithon.timetris.domain.mainpage.domain.See;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class MainPageDTO {

List<PlanViewDTO> planViewDTOList;
List<DoViewDTO> doViewDTOList;
List<SeeViewDTO> seeViewDTO;

public static MainPageDTO from(List<Plan> planList, List<Do> doList, List<See> seeList){
List<PlanViewDTO> planViewDTOS = planList.stream()
.map(PlanViewDTO::of)
.toList();
List<DoViewDTO> doViewDTOS = doList.stream()
.map(DoViewDTO::of)
.toList();
List<SeeViewDTO> seeViewDTO1 = seeList.stream()
.map(SeeViewDTO::of)
.toList();

return new MainPageDTO(planViewDTOS, doViewDTOS, seeViewDTO1);

}

public static MainPageDTO from(List<Plan> planList, List<Do> doList){
List<PlanViewDTO> planViewDTOS = planList.stream()
.map(PlanViewDTO::of)
.toList();
List<DoViewDTO> doViewDTOS = doList.stream()
.map(DoViewDTO::of)
.toList();

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Category;
import com.trendithon.timetris.domain.mainpage.domain.UserDate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalTime;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class PlanCreateDTO {

private String title;
private LocalTime startTime;
private LocalTime endTime;
private boolean status;
private Category category;
private UserDate userDate;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Category;
import com.trendithon.timetris.domain.mainpage.domain.Plan;
import com.trendithon.timetris.domain.mainpage.domain.UserDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalTime;

@Getter
@Builder
@AllArgsConstructor @NoArgsConstructor
public class PlanViewDTO {

private String title;
private LocalTime startTime;
private LocalTime endTime;
private boolean status;
private Category category;

public static PlanViewDTO of(Plan plan){
return PlanViewDTO.builder()
.title(plan.getTitle())
.startTime(plan.getStartTime())
.endTime(plan.getEndTime())
.status(plan.isStatus())
.category(plan.getCategory())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.UserDate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor @NoArgsConstructor
public class SeeCreateDTO {

private String content;
private UserDate userDate;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.trendithon.timetris.domain.mainpage.dto;

import com.trendithon.timetris.domain.mainpage.domain.Date;
import com.trendithon.timetris.domain.mainpage.domain.See;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Optional;

@Getter
@Builder
@AllArgsConstructor @NoArgsConstructor
public class SeeViewDTO {

private String content;

public static SeeViewDTO of(See see){
return SeeViewDTO.builder()
.content(see.getContent())
.build();
}

}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public enum ErrorStatus {
INVALID_TYPE_ERROR(HttpStatus.BAD_REQUEST, "COMMON400", "올바르지 않은 타입입니다."),
ILLEGAL_ARGUMENT_ERROR(HttpStatus.BAD_REQUEST, "COMMON400", "필수 파라미터가 없습니다"),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON500", "서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요."),
INVALID_HTTP_METHOD(HttpStatus.METHOD_NOT_ALLOWED, "COMMON400", "잘못된 Http Method 요청입니다.");
INVALID_HTTP_METHOD(HttpStatus.METHOD_NOT_ALLOWED, "COMMON400", "잘못된 Http Method 요청입니다."),
NO_PERMISSION_ERROR(HttpStatus.BAD_REQUEST, "COMMOM400", "해당 유저에게 수정/삭제 권한이 없습니다."),
USER_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "COMMOM400", "해당 유저를 찾을 수 없습니다."),
CATEGORY_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "COMMOM400", "해당 카테고리를 찾을 수 없습니다."),
PLAN_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "COMMOM400", "해당 plan을 찾을 수 없습니다."),
DO_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "COMMOM400", "해당 do를 찾을 수 없습니다."),
SEE_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "COMMOM400", "해당 see를 찾을 수 없습니다."),;


private final HttpStatus httpStatus;
Expand Down
Loading