Skip to content

Commit 119239b

Browse files
committed
fix: Study DTO
1 parent 8524131 commit 119239b

File tree

3 files changed

+179
-3
lines changed

3 files changed

+179
-3
lines changed

src/main/java/dcom/homepage/api/domain/study/Study.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dcom.homepage.api.domain.study;
22

3-
import com.fasterxml.jackson.annotation.JsonIgnore;
43
import dcom.homepage.api.domain.users.User;
5-
import io.swagger.models.auth.In;
64
import lombok.*;
75
import org.springframework.data.annotation.CreatedDate;
86
import org.springframework.data.annotation.LastModifiedDate;
@@ -22,7 +20,6 @@
2220
@EntityListeners(AuditingEntityListener.class)
2321
@Table(name = "study_group")
2422
public class Study {
25-
@JsonIgnore
2623
@Id
2724
@GeneratedValue(strategy = GenerationType.IDENTITY)
2825
private Integer id;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package dcom.homepage.api.domain.study.dto;
2+
3+
import dcom.homepage.api.domain.study.StudyType;
4+
import io.swagger.annotations.ApiModel;
5+
import io.swagger.annotations.ApiModelProperty;
6+
import lombok.*;
7+
8+
import javax.validation.constraints.NotEmpty;
9+
import javax.validation.constraints.Size;
10+
import java.util.Date;
11+
12+
public class StudyRequestDto {
13+
@ApiModel(value = "스터디 등록 정보")
14+
@Builder
15+
@Getter @Setter
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
public static class Make {
19+
@NotEmpty @Size(min = 4, max = 256, message = "길이는 4 ~ 256자를 허용 합니다.")
20+
@ApiModelProperty(value = "스터디 이름", required = true)
21+
private String name;
22+
23+
@NotEmpty
24+
@ApiModelProperty(value = "스터디 유형", required = true)
25+
private StudyType type;
26+
27+
@ApiModelProperty(value = "스터디 설명")
28+
private String description;
29+
30+
@ApiModelProperty(value = "스터디 시작 일자")
31+
private Date startDate;
32+
33+
@ApiModelProperty(value = "스터디 종료 일자")
34+
private Date endDate;
35+
36+
@ApiModelProperty(value = "스터디 주기, null 일시 주기 비활성화")
37+
private Integer cycle;
38+
}
39+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package dcom.homepage.api.domain.study.dto;
2+
3+
import dcom.homepage.api.domain.study.Study;
4+
import dcom.homepage.api.domain.study.StudyType;
5+
import dcom.homepage.api.domain.users.dto.UserResponseDto;
6+
import io.swagger.annotations.ApiModel;
7+
import io.swagger.annotations.ApiModelProperty;
8+
import lombok.AllArgsConstructor;
9+
import lombok.Builder;
10+
import lombok.Getter;
11+
import lombok.Setter;
12+
13+
import java.util.Date;
14+
import java.util.List;
15+
import java.util.stream.Collectors;
16+
17+
public class StudyResponseDto {
18+
@ApiModel(value = "리스트 용 스터디 정보")
19+
@Builder
20+
@Getter @Setter
21+
@AllArgsConstructor
22+
public static class SimpleInfo {
23+
@ApiModelProperty(value = "스터디 아이디")
24+
private Integer id;
25+
26+
@ApiModelProperty(value = "스터디 이름")
27+
private String name;
28+
29+
@ApiModelProperty(value = "스터디 유형")
30+
private StudyType type;
31+
32+
@ApiModelProperty(value = "스터디 설명")
33+
private String description;
34+
35+
@ApiModelProperty(value = "스터디 소유자")
36+
private UserResponseDto.SimpleProfile owner;
37+
38+
@ApiModelProperty(value = "스터디 생성 일자")
39+
private Date createdAt;
40+
41+
@ApiModelProperty(value = "스터디 시작 일자")
42+
private Date startDate;
43+
44+
@ApiModelProperty(value = "스터디 종료 일자")
45+
private Date endDate;
46+
47+
@ApiModelProperty(value = "스터디 주기")
48+
private Integer cycle;
49+
50+
public static SimpleInfo of(Study study) {
51+
return SimpleInfo.builder()
52+
.id(study.getId())
53+
.name(study.getName())
54+
.type(study.getType())
55+
.description(study.getDescription())
56+
.owner(UserResponseDto.SimpleProfile.of(study.getOwner()))
57+
.createdAt(study.getCreatedAt())
58+
.startDate(study.getStartDate())
59+
.endDate(study.getEndDate())
60+
.cycle(study.getCycle())
61+
.build();
62+
}
63+
}
64+
65+
@ApiModel(value = "전체 스터디 정보")
66+
@Builder
67+
@Getter @Setter
68+
@AllArgsConstructor
69+
public static class Info {
70+
@ApiModelProperty(value = "스터디 아이디")
71+
private Integer id;
72+
73+
@ApiModelProperty(value = "스터디 이름")
74+
private String name;
75+
76+
@ApiModelProperty(value = "스터디 유형")
77+
private StudyType type;
78+
79+
@ApiModelProperty(value = "스터디 설명")
80+
private String description;
81+
82+
@ApiModelProperty(value = "스터디 소유자")
83+
private UserResponseDto.SimpleProfile owner;
84+
85+
@ApiModelProperty(value = "스터디 관리자")
86+
private List<UserResponseDto.SimpleProfile> admin;
87+
88+
@ApiModelProperty(value = "스터디 참여 인원")
89+
private List<UserResponseDto.SimpleProfile> users;
90+
91+
@ApiModelProperty(value = "스터디 신청 유저")
92+
private List<UserResponseDto.SimpleProfile> pendingUsers;
93+
94+
@ApiModelProperty(value = "스터디 생성 일자")
95+
private Date createdAt;
96+
97+
@ApiModelProperty(value = "스터디 시작 일자")
98+
private Date startDate;
99+
100+
@ApiModelProperty(value = "스터 종료 일자")
101+
private Date endDate;
102+
103+
@ApiModelProperty(value = "스터디 휴식 시작 일자")
104+
private Date vacationStartDate;
105+
106+
@ApiModelProperty(value = "스터디 휴식 종료 일자")
107+
private Date vacationEndDate;
108+
109+
@ApiModelProperty(value = "스터디 주기")
110+
private Integer cycle;
111+
112+
public static Info of(Study study) {
113+
return Info.builder()
114+
.id(study.getId())
115+
.name(study.getName())
116+
.type(study.getType())
117+
.description(study.getDescription())
118+
.owner(UserResponseDto.SimpleProfile.of(study.getOwner()))
119+
.admin(study.getAdmin()
120+
.stream()
121+
.map(UserResponseDto.SimpleProfile::of)
122+
.collect(Collectors.toList()))
123+
.users(study.getUsers()
124+
.stream()
125+
.map(UserResponseDto.SimpleProfile::of)
126+
.collect(Collectors.toList()))
127+
.pendingUsers(study.getPendingUsers()
128+
.stream()
129+
.map(UserResponseDto.SimpleProfile::of)
130+
.collect(Collectors.toList()))
131+
.createdAt(study.getCreatedAt())
132+
.startDate(study.getStartDate())
133+
.endDate(study.getEndDate())
134+
.vacationStartDate(study.getVacationStartDate())
135+
.vacationEndDate(study.getVacationEndDate())
136+
.cycle(study.getCycle())
137+
.build();
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)