Skip to content

Commit

Permalink
[feature/Inhabas#241] 프로젝트 게시판 구현 (빌드 확인 필요)
Browse files Browse the repository at this point in the history
  • Loading branch information
skytin1004 committed Mar 13, 2024
1 parent 40170eb commit a0f1c83
Show file tree
Hide file tree
Showing 32 changed files with 861 additions and 252 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.inhabas.api.domain.contest.domain.valueObject;
package com.inhabas.api.domain.contest.domain;

public enum ContestType {
CONTEST("contest", 18),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Optional;

import com.inhabas.api.domain.contest.domain.ContestBoard;
import com.inhabas.api.domain.contest.domain.valueObject.ContestType;
import com.inhabas.api.domain.contest.domain.ContestType;
import com.inhabas.api.domain.contest.domain.valueObject.OrderBy;
import com.inhabas.api.domain.contest.dto.ContestBoardDto;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import lombok.RequiredArgsConstructor;

import com.inhabas.api.domain.contest.domain.ContestBoard;
import com.inhabas.api.domain.contest.domain.ContestType;
import com.inhabas.api.domain.contest.domain.QContestBoard;
import com.inhabas.api.domain.contest.domain.valueObject.ContestType;
import com.inhabas.api.domain.contest.domain.valueObject.OrderBy;
import com.inhabas.api.domain.contest.dto.ContestBoardDto;
import com.inhabas.api.global.util.ClassifiedFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import com.inhabas.api.domain.contest.domain.valueObject.ContestType;
import com.inhabas.api.domain.contest.domain.ContestType;
import com.inhabas.api.domain.contest.domain.valueObject.OrderBy;
import com.inhabas.api.domain.contest.dto.ContestBoardDetailDto;
import com.inhabas.api.domain.contest.dto.ContestBoardDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.inhabas.api.domain.board.exception.S3UploadFailedException;
import com.inhabas.api.domain.contest.domain.ContestBoard;
import com.inhabas.api.domain.contest.domain.ContestField;
import com.inhabas.api.domain.contest.domain.valueObject.ContestType;
import com.inhabas.api.domain.contest.domain.ContestType;
import com.inhabas.api.domain.contest.domain.valueObject.OrderBy;
import com.inhabas.api.domain.contest.dto.ContestBoardDetailDto;
import com.inhabas.api.domain.contest.dto.ContestBoardDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public enum MenuType {
BUDGET_SUPPORT(DEACTIVATED, DEACTIVATED, DEACTIVATED, ADMIN, ADMIN),
// 회계 내역
BUDGET_ACCOUNT(DEACTIVATED, SECRETARY, DEACTIVATED, ADMIN, ADMIN),
// 알파테스터, 베타테스터
TESTER(DEACTIVATED, BASIC, DEACTIVATED, DEACTIVATED, DEACTIVATED),
// 알파테스터, 베타테스터 등등의 프로젝트 게시판
PROJECT(DEACTIVATED, BASIC, DEACTIVATED, DEACTIVATED, DEACTIVATED),
// 공모전, 대외활동
CONTEST(ANONYMOUS, BASIC, ANONYMOUS, DEACTIVATED, BASIC),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.inhabas.api.domain.project.domain;

public enum PinOption {
DISABLED(0),
TEMPORARY(1),
PERMANENT(2);

private final Integer option;

PinOption(Integer option) {
this.option = option;
}

public Integer getOption() {
return option;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.inhabas.api.domain.project.domain;

import java.time.LocalDateTime;
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.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.AccessLevel;
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.file.domain.BoardFile;
import com.inhabas.api.domain.menu.domain.Menu;

@Entity
@Table(name = "NORMAL_BOARD")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorValue("PROJECT")
public class ProjectBoard extends BaseBoard {

@Embedded private Content content;

@Column private Boolean isPinned = false;

@Column(columnDefinition = "DATETIME(0)")
private LocalDateTime datePinExpiration;

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

/* constructor */

public ProjectBoard(
String title, Menu menu, String content, Boolean isPinned, LocalDateTime datePinExpiration) {
super(title, menu);
this.content = new Content(content);
this.isPinned = isPinned;
this.datePinExpiration = datePinExpiration;
}

/* getter */

public Boolean getPinned() {
return isPinned;
}

public LocalDateTime getDatePinExpiration() {
return datePinExpiration;
}

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

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

/* relation method */

public void updateText(String title, String content) {
this.title = new Title(title);
this.content = new Content(content);
}

public void updatePinned(Boolean isPinned, LocalDateTime datePinExpiration) {
this.isPinned = isPinned;
this.datePinExpiration = datePinExpiration;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.inhabas.api.domain.project;
package com.inhabas.api.domain.project.domain;

public enum ProjectBoardType {
ALPHA("alpha", 16),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.inhabas.api.domain.project.dto;

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 ProjectBoardDetailDto {

@NotNull @Positive private Long id;

@NotBlank private String title;

@NotBlank private String content;
@NotNull private Long writerId;

@NotBlank private String writerName;

@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 datePinExpiration;

@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;

@NotNull private List<FileDownloadDto> images;

@NotNull private List<FileDownloadDto> otherFiles;

@NotNull private Boolean isPinned;

@Builder
public ProjectBoardDetailDto(
Long id,
String title,
String content,
Long writerId,
String writerName,
LocalDateTime datePinExpiration,
LocalDateTime dateCreated,
LocalDateTime dateUpdated,
List<FileDownloadDto> images,
List<FileDownloadDto> otherFiles,
Boolean isPinned) {
this.id = id;
this.title = title;
this.content = content;
this.writerId = writerId;
this.writerName = writerName;
this.datePinExpiration = datePinExpiration;
this.dateCreated = dateCreated;
this.dateUpdated = dateUpdated;
this.images = images;
this.otherFiles = otherFiles;
this.isPinned = isPinned;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.inhabas.api.domain.project.dto;

import java.time.LocalDateTime;

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 io.swagger.v3.oas.annotations.media.Schema;

@Getter
@NoArgsConstructor
public class ProjectBoardDto {
@NotNull @Positive private Long id;

@NotBlank private String title;

@NotNull private Long writerId;

@NotBlank private String writerName;

@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 datePinExpiration;

@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;

@NotNull private Boolean isPinned;

@Builder
public ProjectBoardDto(
Long id,
String title,
Long writerId,
String writerName,
LocalDateTime datePinExpiration,
LocalDateTime dateCreated,
LocalDateTime dateUpdated,
Boolean isPinned) {
this.id = id;
this.title = title;
this.writerId = writerId;
this.writerName = writerName;
this.datePinExpiration = datePinExpiration;
this.dateCreated = dateCreated;
this.dateUpdated = dateUpdated;
this.isPinned = isPinned;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.inhabas.api.domain.project.dto;

import java.util.List;

import javax.validation.constraints.NotBlank;

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

import org.springframework.web.multipart.MultipartFile;

@Getter
@NoArgsConstructor
public class SaveProjectBoardDto {

@NotBlank private String title;

@NotBlank private String content;

private List<MultipartFile> files;

private Integer pinOption;

@Builder
public SaveProjectBoardDto(
String title, String content, List<MultipartFile> files, Integer pinOption) {
this.title = title;
this.content = content;
this.files = files;
this.pinOption = pinOption;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.springframework.data.jpa.repository.JpaRepository;

import com.inhabas.api.domain.normalBoard.domain.NormalBoard;
import com.inhabas.api.domain.project.domain.ProjectBoard;

public interface ProjectBoardRepository
extends JpaRepository<NormalBoard, Long>, ProjectBoardRepositoryCustom {}
extends JpaRepository<ProjectBoard, Long>, ProjectBoardRepositoryCustom {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
import java.util.List;
import java.util.Optional;

import com.inhabas.api.domain.normalBoard.domain.NormalBoard;
import com.inhabas.api.domain.normalBoard.dto.NormalBoardDto;
import com.inhabas.api.domain.project.ProjectBoardType;
import com.inhabas.api.domain.project.domain.ProjectBoard;
import com.inhabas.api.domain.project.domain.ProjectBoardType;
import com.inhabas.api.domain.project.dto.ProjectBoardDto;

public interface ProjectBoardRepositoryCustom {

List<NormalBoardDto> findAllByTypeAndIsPinned(ProjectBoardType projectBoardType);
List<ProjectBoardDto> findAllByTypeAndIsPinned(ProjectBoardType projectBoardType);

List<NormalBoardDto> findAllByMemberIdAndTypeAndSearch(
List<ProjectBoardDto> findAllByMemberIdAndTypeAndSearch(
Long memberId, ProjectBoardType projectBoardType, String search);

List<NormalBoardDto> findAllByTypeAndSearch(ProjectBoardType projectBoardType, String search);
List<ProjectBoardDto> findAllByTypeAndSearch(ProjectBoardType projectBoardType, String search);

Optional<NormalBoard> findByMemberIdAndTypeAndId(
Optional<ProjectBoard> findByMemberIdAndTypeAndId(
Long memberId, ProjectBoardType projectBoardType, Long boardId);

Optional<NormalBoard> findByTypeAndId(ProjectBoardType projectBoardType, Long boardId);
Optional<ProjectBoard> findByTypeAndId(ProjectBoardType projectBoardType, Long boardId);
}
Loading

0 comments on commit a0f1c83

Please sign in to comment.