-
Notifications
You must be signed in to change notification settings - Fork 13
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
[feature/Inhabas#228] 공모전 게시판 API 구현 #230
Changes from 29 commits
165e2d9
39e7d7f
d55f23f
e4ef474
29356e2
e4efb66
4acbd63
08272f7
cb8ac5c
889dc40
83a7e95
2abf0b4
cbea217
f722f29
e78ab14
a956460
69200ae
b8ee27e
462c90d
9fdc3a8
bc22526
1ee68ca
c6115ca
5e822d3
78ff80e
a5cbe27
f72de2b
f72cbcc
0911dd2
04ef87d
38792c3
cfca94a
7256e24
7b2f41d
6950a35
d27c6c7
b43e0fe
db74a33
1426dd5
9747ad1
51c8209
4effd25
f7e27d8
9c97aa4
277c02a
5d7c35b
e9067db
3158f12
240b1d9
0b305dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.inhabas.api.domain.contest.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EntityListeners; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import com.inhabas.api.domain.BaseEntity; | ||
import com.inhabas.api.domain.contest.domain.valueObject.ContestFieldName; | ||
|
||
@Entity | ||
@Table(name = "CONTEST_FIELD") | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class ContestField extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ID") | ||
protected Long id; | ||
|
||
public ContestField(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
@Embedded private ContestFieldName name; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 공모전 세부 분야의 데이터를 저장하는 ContestField 테이블 생성 id: 1 = 빅데이터 이렇게 구성하려고 합니다. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.inhabas.api.domain.contest.domain.valueObject; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import javax.persistence.Transient; | ||
|
||
@Embeddable | ||
public class ContestFieldName { | ||
|
||
@Column(name = "NAME", length = 15, nullable = false) | ||
private String value; | ||
|
||
@Transient private final int MAX_LENGTH = 15; | ||
|
||
public ContestFieldName() {} | ||
|
||
public ContestFieldName(String value) { | ||
if (validate(value)) this.value = value; | ||
else throw new IllegalArgumentException(); | ||
} | ||
|
||
private boolean validate(Object value) { | ||
if (Objects.isNull(value)) return false; | ||
if (!(value instanceof String)) return false; | ||
|
||
String o = (String) value; | ||
if (o.isBlank()) return false; | ||
return o.length() < MAX_LENGTH; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.inhabas.api.domain.contest.domain.valueObject; | ||
|
||
public enum ContestType { | ||
CONTEST, // 공모전 | ||
ACTIVITY // 대외활동 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.inhabas.api.domain.contest.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Positive; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.inhabas.api.domain.file.dto.FileDownloadDto; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
// 공모전 게시판 단일 조회 | ||
@Getter | ||
@NoArgsConstructor | ||
public class ContestBoardDetailDto { | ||
|
||
@NotNull @Positive private Long id; | ||
|
||
@NotNull private Long contestField; | ||
|
||
@NotBlank private String title; | ||
|
||
@NotBlank private String content; | ||
|
||
@NotBlank private String writerName; | ||
|
||
@NotBlank private String association; | ||
|
||
@NotBlank private String topic; | ||
|
||
@NotNull private FileDownloadDto thumbnail; | ||
|
||
private List<FileDownloadDto> images; | ||
|
||
private List<FileDownloadDto> otherFiles; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") | ||
private LocalDate dateContestStart; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") | ||
private LocalDate dateContestEnd; | ||
|
||
@NotNull | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateCreated; | ||
|
||
@NotNull | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateUpdated; | ||
|
||
@Builder | ||
public ContestBoardDetailDto( | ||
Long id, | ||
Long contestField, | ||
String title, | ||
String content, | ||
String writerName, | ||
String association, | ||
String topic, | ||
LocalDate dateContestStart, | ||
LocalDate dateContestEnd, | ||
LocalDateTime dateCreated, | ||
LocalDateTime dateUpdated, | ||
FileDownloadDto thumbnail, | ||
List<FileDownloadDto> images, | ||
List<FileDownloadDto> otherFiles) { | ||
this.id = id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 공모전 게시판 단일 조회에서 단순히 첨부파일을 썸네일, 이미지, 기타 파일로 분류(위치 이동함 - 아래 댓글 참고) |
||
this.contestField = contestField; | ||
this.title = title; | ||
this.content = content; | ||
this.writerName = writerName; | ||
this.association = association; | ||
this.topic = topic; | ||
this.dateContestStart = dateContestStart; | ||
this.dateContestEnd = dateContestEnd; | ||
this.dateCreated = dateCreated; | ||
this.dateUpdated = dateUpdated; | ||
this.thumbnail = thumbnail; | ||
this.images = images; | ||
this.otherFiles = otherFiles; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum 형태인 ContestType을 url에서 소문자로 사용하기 위해 Custom 컨버터를 사용했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존에 만들어져 있던 Menu 컨버터도 같이 등록했습니다.