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

[feature/Inhabas#228] 공모전 게시판 API 구현 #230

Merged
merged 50 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
165e2d9
[feature/Inhabas#228] VO 일부 수정 및 컬럼,테이블 이름 수정
skytin1004 Jan 30, 2024
39e7d7f
[feature/Inhabas#228] VO 구현 및 DTO 변수 일부 수정
skytin1004 Jan 31, 2024
d55f23f
[feature/Inhabas#228] VO 구현
skytin1004 Feb 1, 2024
e4ef474
[feature/Inhabas#228] DTO, Service 구현
skytin1004 Feb 2, 2024
29356e2
[feature/Inhabas#228] Service 오타 수정
skytin1004 Feb 5, 2024
e4efb66
[feature/Inhabas#228] Service 오타 수정
skytin1004 Feb 5, 2024
4acbd63
[feature/Inhabas#228] 공모전 게시판 검색 기능 추가
skytin1004 Feb 5, 2024
08272f7
[feature/Inhabas#228] 공모전 게시판 검색 기능 추가
skytin1004 Feb 5, 2024
cb8ac5c
[feature/Inhabas#228] 공모전 게시판 검색 repositoryImpl로직 변경 및 serviceImpl 구현
skytin1004 Feb 6, 2024
889dc40
[feature/Inhabas#228] 공모전 게시판 검색 관련 DTO 수정, association 추가
skytin1004 Feb 6, 2024
83a7e95
[feature/Inhabas#228] 공모전 게시판 DTO D-Day 추가
skytin1004 Feb 6, 2024
2abf0b4
Merge branch 'InhaBas:master' into contest-board
skytin1004 Feb 7, 2024
cbea217
[feature/Inhabas#228] 공모전 게시판 파일 URI 저장방식 갱신, ContestType에 따른 게시판 분리 …
skytin1004 Feb 7, 2024
f722f29
[feature/Inhabas#228] ContestType 컨버터 구현, Controller 수정
skytin1004 Feb 8, 2024
e78ab14
[feature/Inhabas#228] Controller response 정리
skytin1004 Feb 8, 2024
a956460
[feature/Inhabas#228] Controller 오타 수정
skytin1004 Feb 8, 2024
69200ae
[feature/Inhabas#228] 불필요한 코드 삭제
skytin1004 Feb 13, 2024
b8ee27e
[feature/Inhabas#228] Image파일 보장
skytin1004 Feb 13, 2024
462c90d
[feature/Inhabas#228] 예외 처리 ErrorCode 사용
skytin1004 Feb 13, 2024
9fdc3a8
[feature/Inhabas#228] 세부 필터링 구현
skytin1004 Feb 15, 2024
bc22526
[feature/Inhabas#228] 공모전 정렬 기능 수정
skytin1004 Feb 15, 2024
1ee68ca
[feature/Inhabas#228] spotlessApply
skytin1004 Feb 15, 2024
c6115ca
[feature/Inhabas#228] 공모전 게시판 구현 완료
skytin1004 Feb 16, 2024
5e822d3
[feature/Inhabas#228] 공모전 게시판 구현 완료 - 리펙토링
skytin1004 Feb 16, 2024
78ff80e
[feature/Inhabas#228] 타입 문제 해결
skytin1004 Feb 16, 2024
a5cbe27
[feature/Inhabas#228] 썸네일, 이미지, 기타 파일 분류 완료
skytin1004 Feb 16, 2024
f72de2b
[feature/Inhabas#228] 분류 기능 리펙토링
skytin1004 Feb 16, 2024
f72cbcc
[feature/Inhabas#228] domain 테스트 파일 생성
skytin1004 Feb 17, 2024
0911dd2
[feature/Inhabas#228] 테이블 수정에 따른 컬럼 이름 및 조건 수정
skytin1004 Feb 17, 2024
04ef87d
[feature/Inhabas#228] contest 유틸 클래스 global 이동 및 리펙토링
skytin1004 Feb 19, 2024
38792c3
[feature/Inhabas#228] 공모전 게시판 정렬 기능 구현 완료
skytin1004 Feb 19, 2024
cfca94a
[feature/Inhabas#228] 공모전 게시판 정렬 기능 controller 리펙토링
skytin1004 Feb 19, 2024
7256e24
[feature/Inhabas#228] 공모전 게시판 도메인 테스트 코드 구현
skytin1004 Feb 19, 2024
7b2f41d
Merge branch 'master' of https://github.com/skytin1004/Inhabas.com-ap…
skytin1004 Feb 20, 2024
6950a35
[feature/Inhabas#234] 충돌 해결
skytin1004 Feb 21, 2024
d27c6c7
[feature/Inhabas#234] 충돌 해결
skytin1004 Feb 21, 2024
b43e0fe
Merge branch 'master' of https://github.com/skytin1004/Inhabas.com-ap…
skytin1004 Feb 21, 2024
db74a33
[feature/Inhabas#234] 충돌 해결
skytin1004 Feb 21, 2024
1426dd5
[feature/Inhabas#234] 최근 커밋 반영ㅇ
skytin1004 Feb 21, 2024
9747ad1
[feature/Inhabas#234] 서비스 테스트 코드 구현 및 리펙토링
skytin1004 Feb 22, 2024
51c8209
[feature/Inhabas#234] 서비스 및 레포지토리 테스트 코드 오류 해결중..
skytin1004 Feb 22, 2024
4effd25
[feature/Inhabas#234] service, repository 테스트 구현 완료ㅛ
skytin1004 Feb 23, 2024
f7e27d8
[feature/Inhabas#234] controller 테스트 구현 완료
skytin1004 Feb 24, 2024
9c97aa4
[feature/Inhabas#234] 공모전 게시판 config 구현
skytin1004 Feb 24, 2024
277c02a
[feature/Inhabas#234] requestPart 개선
skytin1004 Feb 24, 2024
5d7c35b
[feature/Inhabas#234] requestPart 문제 해결, 모든 테스트 구현
skytin1004 Feb 26, 2024
e9067db
[feature/Inhabas#234] spotleaaApply
skytin1004 Feb 26, 2024
3158f12
[feature/Inhabas#234] 리뷰 반영
skytin1004 Feb 26, 2024
240b1d9
[feature/Inhabas#234] 리뷰 반영
skytin1004 Feb 26, 2024
0b305dc
[feature/Inhabas#234] 리펙토링, 공모전 게시판 구현
skytin1004 Mar 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public GroupedOpenApi getBoardApi() {
.build();
}

@Bean
public GroupedOpenApi getContestApi() {

return GroupedOpenApi.builder()
.group("공모전 게시판 관련")
.pathsToMatch("/contest/**", "/**/**/**/comment/**", "/**/**/**/comments")
.build();
}

@Bean
@Profile("local")
public OpenAPI localOpenAPI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.inhabas.api.web.converter.ContestOrderByConverter;
import com.inhabas.api.web.converter.ContestTypeConverter;
import com.inhabas.api.web.converter.MenuIdConverter;
import com.inhabas.api.web.converter.NormalBoardTypeConverter;
import io.swagger.v3.core.jackson.ModelResolver;

@Configuration
public class WebConfig {
public class WebConfig implements WebMvcConfigurer {

// 커스텀 컨버터를 Spring 변환 서비스에 등록
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new ContestOrderByConverter.StringToOrderByConverter());
registry.addConverter(new ContestOrderByConverter.OrderByToStringConverter());
registry.addConverter(new ContestTypeConverter.StringToContestTypeConverter());
registry.addConverter(new ContestTypeConverter.ContestTypeToStringConverter());
registry.addConverter(new NormalBoardTypeConverter.NormalTypeToStringConverter());
registry.addConverter(new NormalBoardTypeConverter.StringToNormalTypeConverter());
registry.addConverter(new MenuIdConverter.StringToMenuIdConverter());
registry.addConverter(new MenuIdConverter.MenuIdToStringConverter());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum 형태인 ContestType을 url에서 소문자로 사용하기 위해 Custom 컨버터를 사용했습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에 만들어져 있던 Menu 컨버터도 같이 등록했습니다.


@Bean
public ModelResolver modelResolver(ObjectMapper objectMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class WebSecurityConfig {
};
private static final String[] AUTH_WHITELIST_NORMAL_BOARD = {"/board/count"};

private static final String[] AUTH_WHITELIST_CONTEST_BOARD = {"/contest/count"};

@Order(1)
@EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true)
@EnableWebSecurity
Expand All @@ -87,6 +89,7 @@ public void configure(WebSecurity web) throws Exception {
.antMatchers(HttpMethod.GET, AUTH_WHITELIST_SIGNUP)
.antMatchers(HttpMethod.GET, AUTH_WHITELIST_CLUB)
.antMatchers(HttpMethod.GET, AUTH_WHITELIST_NORMAL_BOARD)
.antMatchers(HttpMethod.GET, AUTH_WHITELIST_CONTEST_BOARD)
.antMatchers(AUTH_WHITELIST_SWAGGER)
.antMatchers(AUTH_WHITELIST_STATIC)
.antMatchers(AUTH_WHITELIST_PATH);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,88 @@
package com.inhabas.api.domain.contest.domain;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.inhabas.api.domain.board.domain.BaseBoard;
import com.inhabas.api.domain.board.domain.valueObject.Content;
import com.inhabas.api.domain.board.domain.valueObject.Title;
import com.inhabas.api.domain.comment.domain.Comment;
import com.inhabas.api.domain.contest.domain.valueObject.Association;
import com.inhabas.api.domain.contest.domain.valueObject.Topic;
import com.inhabas.api.domain.normalBoard.domain.NormalBoard;
import com.inhabas.api.domain.file.domain.BoardFile;
import com.inhabas.api.domain.menu.domain.Menu;

@Entity
@Table(name = "contest_board")
@Table(name = "CONTEST_BOARD")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ContestBoard extends NormalBoard {
@EntityListeners(AuditingEntityListener.class)
skytin1004 marked this conversation as resolved.
Show resolved Hide resolved
@DiscriminatorValue("CONTEST")
public class ContestBoard extends BaseBoard {

@ManyToOne
@JoinColumn(name = "CONTEST_FIELD_ID", foreignKey = @ForeignKey(name = "FK_CONTEST_FIELD_OF_ID"))
private ContestField contestField;

@Embedded private Topic topic;

@Embedded private Association association;

@Column private LocalDate start;
@Embedded private Content content;

@Column(name = "DATE_CONTEST_START", nullable = false)
private LocalDate dateContestStart;

@Column(name = "DATE_CONTEST_END", nullable = false)
private LocalDate dateContestEnd;
skytin1004 marked this conversation as resolved.
Show resolved Hide resolved
skytin1004 marked this conversation as resolved.
Show resolved Hide resolved

@Column private LocalDate deadline;
@OneToMany(mappedBy = "parentBoard", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> comments = new ArrayList<>();

/* constructor */
@Builder
public ContestBoard(
Menu menu,
ContestField contestField,
String title,
String content,
String association,
String topic,
LocalDate dateContestStart,
LocalDate dateContestEnd) {

super(title, menu);
this.contestField = contestField;
this.title = new Title(title);
this.content = new Content(content);
this.association = new Association(association);
this.topic = new Topic(topic);
this.dateContestStart = dateContestStart;
this.dateContestEnd = dateContestEnd;
}

/* Getter */
/* getter */
public String getAssociation() {
return association.getValue();
}
Expand All @@ -40,32 +91,46 @@ public String getTopic() {
return topic.getValue();
}

/* Constructor */
public String getContent() {
return content.getValue();
}

@Builder
public ContestBoard(
public List<BoardFile> getFiles() {
return Collections.unmodifiableList(files);
}

/* relation method */

// 첨부파일 수정
public void updateFiles(List<BoardFile> files) {

if (this.files != null) {
this.files.clear();
} else {
this.files = new ArrayList<>();
}

for (BoardFile file : files) {
addFile(file);
}
}

// 공모전 정보 수정
public void updateContest(
ContestField contestField,
String title,
String contents,
String content,
String association,
String topic,
LocalDate start,
LocalDate deadline) {
LocalDate dateContestStart,
LocalDate dateContestEnd) {

this.contestField = contestField;
this.title = new Title(title);
// this.content = new Content(contents);
this.content = new Content(content);
this.association = new Association(association);
this.topic = new Topic(topic);
this.start = start;
this.deadline = deadline;
this.dateContestStart = dateContestStart;
this.dateContestEnd = dateContestEnd;
}

// public void modify(String title, String contents, String association, String topic,
// LocalDate start, LocalDate deadline, StudentId loginMember) {
//
// super.modify(title, contents, loginMember);
// this.association = new Association(association);
// this.topic = new Topic(topic);
// this.start = start;
// this.deadline = deadline;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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.Builder;
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")
private Long id;

@Embedded private ContestFieldName name;

@Builder
public ContestField(String name) {
this.name = new ContestFieldName(name);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공모전 세부 분야의 데이터를 저장하는 ContestField 테이블 생성

id: 1 = 빅데이터
id: 2 = IT
id: 999 = 기타 공모전

이렇게 구성하려고 합니다.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import javax.persistence.Embeddable;
import javax.persistence.Transient;

import com.inhabas.api.auth.domain.error.businessException.InvalidInputException;

@Embeddable
public class Association {

@Column(name = "association", length = 100, nullable = false)
@Column(name = "ASSOCIATION", length = 100, nullable = false)
private String value;

@Transient private final int MAX_LENGTH = 100;
Expand All @@ -18,7 +20,7 @@ public Association() {}

public Association(String value) {
if (validate(value)) this.value = value;
else throw new IllegalArgumentException();
else throw new InvalidInputException();
}

private boolean validate(Object value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.inhabas.api.domain.contest.domain.valueObject;

import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Transient;

import com.inhabas.api.auth.domain.error.businessException.InvalidInputException;

@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 InvalidInputException();
}

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,22 @@
package com.inhabas.api.domain.contest.domain.valueObject;

public enum ContestType {
CONTEST("contest", 18),
ACTIVITY("activity", 19);

private final String boardType;
private final int menuId;

ContestType(String boardType, int menuId) {
this.boardType = boardType;
this.menuId = menuId;
}

public String getBoardType() {
return boardType;
}

public int getMenuId() {
return menuId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.inhabas.api.domain.contest.domain.valueObject;

import com.inhabas.api.domain.contest.domain.QContestBoard;
import com.querydsl.core.types.OrderSpecifier;

public enum OrderBy {
DATE_CONTEST_END {
public OrderSpecifier<?> getOrderBy(QContestBoard contestBoard) {
return contestBoard.dateContestEnd.desc();
}
},

DATE_CREATED {
public OrderSpecifier<?> getOrderBy(QContestBoard contestBoard) {
return contestBoard.dateCreated.desc();
}
};

public abstract OrderSpecifier<?> getOrderBy(QContestBoard contestBoard);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
import javax.persistence.Embeddable;
import javax.persistence.Transient;

import com.inhabas.api.auth.domain.error.businessException.InvalidInputException;

@Embeddable
public class Topic {
@Column(name = "topic", length = 500, nullable = false)
@Column(name = "TOPIC", length = 100, nullable = false)
private String value;

@Transient private final int MAX_LENGTH = 500;
@Transient private final int MAX_LENGTH = 100;

public Topic() {}

public Topic(String value) {
if (validate(value)) this.value = value;
else throw new IllegalArgumentException();
else throw new InvalidInputException();
}

private boolean validate(Object value) {
Expand Down
Loading
Loading