diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/.dummy b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/.dummy deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Category.java b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Category.java index 758b154..a8382d7 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Category.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Category.java @@ -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; @@ -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; + } + } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java new file mode 100644 index 0000000..d4e34d4 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java @@ -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; + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java new file mode 100644 index 0000000..f260046 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java @@ -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; + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java new file mode 100644 index 0000000..d43aa75 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java @@ -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; + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java new file mode 100644 index 0000000..395f88c --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java @@ -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(); + } + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/MainPageDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/MainPageDTO.java new file mode 100644 index 0000000..3ff4ba6 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/MainPageDTO.java @@ -0,0 +1,36 @@ +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 planViewDTOList; + List doViewDTOList; + List seeViewDTO; + + public static MainPageDTO from(List planList, List doList, List seeList){ + List planViewDTOS = planList.stream() + .map(PlanViewDTO::of) + .toList(); + List doViewDTOS = doList.stream() + .map(DoViewDTO::of) + .toList(); + List seeViewDTO1 = seeList.stream() + .map(SeeViewDTO::of) + .toList(); + + return new MainPageDTO(planViewDTOS, doViewDTOS, seeViewDTO1); + + } + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java new file mode 100644 index 0000000..cc3d331 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java @@ -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; + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java new file mode 100644 index 0000000..5ea4c26 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java @@ -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(); + } + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java new file mode 100644 index 0000000..a7a5ce8 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java @@ -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; + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java new file mode 100644 index 0000000..e0c6f08 --- /dev/null +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java @@ -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(); + } + +} diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/exception/.dummy b/src/main/java/com/trendithon/timetris/domain/mainpage/exception/.dummy deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/com/trendithon/timetris/global/exception/enums/ErrorStatus.java b/src/main/java/com/trendithon/timetris/global/exception/enums/ErrorStatus.java index 6162450..10f3c48 100644 --- a/src/main/java/com/trendithon/timetris/global/exception/enums/ErrorStatus.java +++ b/src/main/java/com/trendithon/timetris/global/exception/enums/ErrorStatus.java @@ -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;