Skip to content

Commit

Permalink
Merge pull request #1 from JNU-econovation/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jminkkk authored Jul 4, 2023
2 parents bed9352 + d51f06f commit f7e9d41
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/main/java/com/timcooki/jnuwiki/domain/docs/entity/Docs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.timcooki.jnuwiki.domain.docs.entity;


import com.timcooki.jnuwiki.domain.docsRequest.entity.DocsCategory;
import com.timcooki.jnuwiki.domain.member.entity.Member;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.time.LocalDate;

@Entity
@Getter
@RequiredArgsConstructor
@Table(name = "DOCS")
public class Docs {

@Id
@GeneratedValue
@Column(name = "docs_id")
private Long docsId;

@Column(name = "docs_name", nullable = false)
private String docsName;

@Column(name = "docs_location", nullable = false)
private String docsLocation;

@Column(name = "docs_content")
private String docsContent;

@ManyToOne
@JoinColumn(name = "member_id")
private Member createdBy;

@CreatedDate
@Column(name = "created_at")
private LocalDate createdAt;

@LastModifiedDate
@Column(name = "modified_at")
private LocalDate modifiedAt;

@Column(name = "docs_category", nullable = false)
@Enumerated(EnumType.STRING)
private DocsCategory docsCategory;

@Builder
public Docs(String docsName, String docsLocation, Member createdBy, DocsCategory docsCategory) {
this.docsName = docsName;
this.docsLocation = docsLocation;
this.createdBy = createdBy;
this.docsCategory = docsCategory;
}

public void updateBasicInfo(String docsName, String docsLocation, DocsCategory docsCategory) {
this.docsName = docsName;
this.docsLocation = docsLocation;
this.docsCategory = docsCategory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.timcooki.jnuwiki.domain.docsArchive.entity;


import com.timcooki.jnuwiki.domain.docsRequest.entity.DocsCategory;
import com.timcooki.jnuwiki.domain.member.entity.Member;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.time.LocalDate;

@Entity
@Getter
@RequiredArgsConstructor
@Table(name = "DOCS_ARCHIVE")
public class DocsArchive {

@Id
@GeneratedValue
@Column(name = "docs_archive_id")
private Long docsArchiveId;

@Column(name = "docs_archive_name", nullable = false)
private String docsArchiveName;

@Column(name = "docs_archive_location", nullable = false)
private String docsArchiveLocation;

@Column(name = "docs_archive_content")
private String docsArchiveContent;

@Column(name = "docs_archive_category", nullable = false)
@Enumerated(EnumType.STRING)
private DocsCategory docsArchiveCategory;

@ManyToOne
@JoinColumn(name = "member_id")
private Member createdBy;

@CreatedDate
@Column(name = "created_at")
private LocalDate createdAt;


@Builder
public DocsArchive(String docsArchiveName, String docsArchiveLocation, String docsArchiveContent, Member createdBy, DocsCategory docsArchiveCategory) {
this.docsArchiveName = docsArchiveName;
this.docsArchiveLocation = docsArchiveLocation;
this.docsArchiveContent = docsArchiveContent;
this.createdBy = createdBy;
this.docsArchiveCategory = docsArchiveCategory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.timcooki.jnuwiki.domain.docsRequest.entity;

public enum DocsCategory {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.timcooki.jnuwiki.domain.docsRequest.entity;


import com.timcooki.jnuwiki.domain.docs.entity.Docs;
import com.timcooki.jnuwiki.domain.member.entity.Member;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.time.LocalDateTime;


@Entity
@Getter
@RequiredArgsConstructor
@Table(name = "DOCS_REQUEST")
public class DocsRequest {

@Id
@GeneratedValue
@Column(name = "docs_request_id")
private Long docsRequestId;

@Column(name = "docs_request_type", nullable = false)
@Enumerated(EnumType.STRING)
private DocsRequestType docsRequestType;

@Column(name = "docs_category", nullable = false)
@Enumerated(EnumType.STRING)
private DocsCategory docsCategory;

@Column(name = "docs_name", nullable = false)
private String docsName;

@Column(name = "docs_location", nullable = false)
private String docsLocation;

@ManyToOne
// TODO : join column 에 createdBy 적용 가능 확인
@JoinColumn(name = "member_id", nullable = false)
private Member docsRequestedBy;

@CreatedDate
@Column(name = "requested_at")
private LocalDateTime docsRequestAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "docs_id")
private Docs docs;

@Builder
public DocsRequest(Long requestId, DocsRequestType docsRequestType, DocsCategory docsCategory, String docsName, String docsLocation, Member docsRequestedBy, Docs docs) {
this.docsRequestType = docsRequestType;
this.docsCategory = docsCategory;
this.docsName = docsName;
this.docsLocation = docsLocation;
this.docsRequestedBy = docsRequestedBy;
this.docs = docs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.timcooki.jnuwiki.domain.docsRequest.entity;

public enum DocsRequestType {
CREATED,
MODIFIED;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.timcooki.jnuwiki.domain.member.entity;

import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.time.LocalDate;

@Entity
@Getter
@RequiredArgsConstructor
@Table(name = "MEMBER")
public class Member {

@Id
@GeneratedValue
@Column(name = "member_id")
private Long memberId;

@Column(name = "member_email", nullable = false, unique = true)
private String email;

@Column(name = "member_password", nullable = false)
private String password;

@Column(name = "member_nickname", nullable = false, unique = true)
private String nickName;

@CreatedDate
@Column(name = "member_join_date")
private LocalDate createdAt;

@Column(name = "member_role")
@Enumerated(EnumType.STRING)
private MemberRole role;


public boolean canEdit() {
// 수정 가능한지 - 현재가 15일 이후면 가
if (LocalDate.now().isAfter(createdAt.plusDays(15))) {
return true;
}

else return false;
}

@Builder
public Member(String email, String password, String nickName, MemberRole role) {
this.email = email;
this.password = password;
this.nickName = nickName;
this.role = role;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.timcooki.jnuwiki.domain.member.entity;

public enum MemberRole {
USER, ADMIN
}

0 comments on commit f7e9d41

Please sign in to comment.