Skip to content

Commit

Permalink
Merge pull request #3 from Timetris-Trendithon/mainpage
Browse files Browse the repository at this point in the history
โœจ Feat: DTO ์ถ”๊ฐ€, ErrorStatus enum ์ถ”๊ฐ€
  • Loading branch information
jiinkyung authored Feb 17, 2024
2 parents ad9fbee + 86af4ee commit 8822193
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 1 deletion.
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,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<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);

}

}
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

0 comments on commit 8822193

Please sign in to comment.