forked from JNU-econovation/jnu-wiki-be
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JNU-econovation/develop
- Loading branch information
Showing
7 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/main/java/com/timcooki/jnuwiki/domain/docs/entity/Docs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/timcooki/jnuwiki/domain/docsArchive/entity/DocsArchive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/timcooki/jnuwiki/domain/docsRequest/entity/DocsCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.timcooki.jnuwiki.domain.docsRequest.entity; | ||
|
||
public enum DocsCategory { | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/timcooki/jnuwiki/domain/docsRequest/entity/DocsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/timcooki/jnuwiki/domain/docsRequest/entity/DocsRequestType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/timcooki/jnuwiki/domain/member/entity/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/timcooki/jnuwiki/domain/member/entity/MemberRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |