diff --git a/be/issue-tracker/src/main/java/com/issuetracker/comment/domain/Comment.java b/be/issue-tracker/src/main/java/com/issuetracker/comment/domain/Comment.java new file mode 100644 index 000000000..8648b058b --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/comment/domain/Comment.java @@ -0,0 +1,21 @@ +package com.issuetracker.comment.domain; + +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class Comment { + @Id + @Setter + private Long id; + private final String content; + private final LocalDateTime createDate; + private final boolean isWriter; + private final Long issueId; + private final String memberId; + private final Long fileId; +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/comment/repository/CommentRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/comment/repository/CommentRepository.java new file mode 100644 index 000000000..b796423ce --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/comment/repository/CommentRepository.java @@ -0,0 +1,7 @@ +package com.issuetracker.comment.repository; + +import com.issuetracker.comment.domain.Comment; +import org.springframework.data.repository.CrudRepository; + +public interface CommentRepository extends CrudRepository { +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/file/Repository/FileRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/file/Repository/FileRepository.java new file mode 100644 index 000000000..ae4cb1b59 --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/file/Repository/FileRepository.java @@ -0,0 +1,7 @@ +package com.issuetracker.file.Repository; + +import com.issuetracker.file.domain.File; +import org.springframework.data.repository.CrudRepository; + +public interface FileRepository extends CrudRepository { +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/file/domain/File.java b/be/issue-tracker/src/main/java/com/issuetracker/file/domain/File.java new file mode 100644 index 000000000..fe8696b88 --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/file/domain/File.java @@ -0,0 +1,16 @@ +package com.issuetracker.file.domain; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class File { + @Id + @Setter + private Long id; + private final String uploadName; + private final String storeName; +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/Issue.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/Issue.java new file mode 100644 index 000000000..cb2363a80 --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/Issue.java @@ -0,0 +1,22 @@ +package com.issuetracker.issue.domain; + +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class Issue { + @Id + @Setter + private Long id; + private final String title; + private final String content; + private final LocalDateTime createDate; + private final boolean isClosed; + private final String memberId; + private final Long milestoneId; + private final Long fileId; +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueAssignee.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueAssignee.java new file mode 100644 index 000000000..357e7cd1c --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueAssignee.java @@ -0,0 +1,13 @@ +package com.issuetracker.issue.domain; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class IssueAssignee { + @Id + private final Long issueId; + private final String memberId; +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueLabel.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueLabel.java new file mode 100644 index 000000000..870471e1e --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/domain/IssueLabel.java @@ -0,0 +1,13 @@ +package com.issuetracker.issue.domain; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class IssueLabel { + @Id + private final Long issueId; + private final Long labelId; +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueAssigneeRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueAssigneeRepository.java new file mode 100644 index 000000000..c32ccedfa --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueAssigneeRepository.java @@ -0,0 +1,20 @@ +package com.issuetracker.issue.repository; + +import com.issuetracker.issue.domain.IssueAssignee; +import java.util.Optional; +import org.springframework.data.jdbc.repository.query.Modifying; +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.CrudRepository; + +public interface IssueAssigneeRepository extends CrudRepository { + @Modifying + @Query("INSERT INTO issue_assignee (issue_id, member_id) VALUES (:issueId, :memberId)") + void insert(Long issueId, String memberId); + + @Query("SELECT issue_id, member_id FROM issue_assignee WHERE issue_id = :issueId AND member_id = :memberId") + Optional findById(Long issueId, String memberId); + + @Modifying + @Query("DELETE FROM issue_assignee WHERE issue_id = :issueId AND member_id = :memberId") + void deleteById(Long issueId, String memberId); +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueLabelRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueLabelRepository.java new file mode 100644 index 000000000..b4ea87233 --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueLabelRepository.java @@ -0,0 +1,20 @@ +package com.issuetracker.issue.repository; + +import com.issuetracker.issue.domain.IssueLabel; +import java.util.Optional; +import org.springframework.data.jdbc.repository.query.Modifying; +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.CrudRepository; + +public interface IssueLabelRepository extends CrudRepository { + @Modifying + @Query("INSERT INTO issue_label (issue_id, label_id) VALUES (:issueId, :labelId)") + void insert(Long issueId, Long labelId); + + @Query("SELECT issue_id, label_id FROM issue_label WHERE issue_id = :issueId AND label_id = :labelId") + Optional findById(Long issueId, Long labelId); + + @Modifying + @Query("DELETE FROM issue_label WHERE issue_id = :issueId AND label_id = :labelId") + void deleteById(Long issueId, Long labelId); +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueRepository.java new file mode 100644 index 000000000..982604033 --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/issue/repository/IssueRepository.java @@ -0,0 +1,7 @@ +package com.issuetracker.issue.repository; + +import com.issuetracker.issue.domain.Issue; +import org.springframework.data.repository.CrudRepository; + +public interface IssueRepository extends CrudRepository { +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/milestone/Repository/MilestoneRepository.java b/be/issue-tracker/src/main/java/com/issuetracker/milestone/Repository/MilestoneRepository.java new file mode 100644 index 000000000..8e7c3833f --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/milestone/Repository/MilestoneRepository.java @@ -0,0 +1,7 @@ +package com.issuetracker.milestone.Repository; + +import com.issuetracker.milestone.domain.Milestone; +import org.springframework.data.repository.CrudRepository; + +public interface MilestoneRepository extends CrudRepository { +} diff --git a/be/issue-tracker/src/main/java/com/issuetracker/milestone/domain/Milestone.java b/be/issue-tracker/src/main/java/com/issuetracker/milestone/domain/Milestone.java new file mode 100644 index 000000000..e29b5f62a --- /dev/null +++ b/be/issue-tracker/src/main/java/com/issuetracker/milestone/domain/Milestone.java @@ -0,0 +1,19 @@ +package com.issuetracker.milestone.domain; + +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import org.springframework.data.annotation.Id; + +@RequiredArgsConstructor +@Getter +public class Milestone { + @Setter + @Id + private Long id; + private final String name; + private final String description; + private final LocalDateTime dueDate; + private final boolean isClosed; +} diff --git a/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueAssigneeRepositoryTest.java b/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueAssigneeRepositoryTest.java new file mode 100644 index 000000000..83096cabd --- /dev/null +++ b/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueAssigneeRepositoryTest.java @@ -0,0 +1,33 @@ +package com.issuetracker.issue.repository; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.issuetracker.issue.domain.IssueAssignee; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest +@Transactional +class IssueAssigneeRepositoryTest { + @Autowired + IssueAssigneeRepository issueAssigneeRepository; + + @BeforeEach + void setUp() { + issueAssigneeRepository.deleteAll(); + } + + @Test + void crud() { + issueAssigneeRepository.insert(1L, "sangchu"); + IssueAssignee find = issueAssigneeRepository.findById(1L, "sangchu").get(); + assertThat(find.getIssueId()).isEqualTo(1L); + assertThat(find.getMemberId()).isEqualTo("sangchu"); + + issueAssigneeRepository.deleteById(1L, "sangchu"); + assertThat(issueAssigneeRepository.count()).isEqualTo(0); + } +} \ No newline at end of file diff --git a/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueLabelRepositoryTest.java b/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueLabelRepositoryTest.java new file mode 100644 index 000000000..c1701cdd0 --- /dev/null +++ b/be/issue-tracker/src/test/java/com/issuetracker/issue/repository/IssueLabelRepositoryTest.java @@ -0,0 +1,34 @@ +package com.issuetracker.issue.repository; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.issuetracker.issue.domain.IssueLabel; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest +@Transactional +class IssueLabelRepositoryTest { + @Autowired + IssueLabelRepository issueLabelRepository; + + @BeforeEach + void setUp() { + issueLabelRepository.deleteAll(); + } + + @Test + void crud() { + issueLabelRepository.insert(1L, 4L); + IssueLabel find = issueLabelRepository.findById(1L, 4L).get(); + + assertThat(find.getIssueId()).isEqualTo(1L); + assertThat(find.getLabelId()).isEqualTo(4L); + + issueLabelRepository.deleteById(1L, 4L); + assertThat(issueLabelRepository.count()).isEqualTo(0); + } +} \ No newline at end of file diff --git a/be/issue-tracker/src/test/java/com/issuetracker/member/repository/MemberRepositoryTest.java b/be/issue-tracker/src/test/java/com/issuetracker/member/repository/MemberRepositoryTest.java index 912c73b51..720c162c8 100644 --- a/be/issue-tracker/src/test/java/com/issuetracker/member/repository/MemberRepositoryTest.java +++ b/be/issue-tracker/src/test/java/com/issuetracker/member/repository/MemberRepositoryTest.java @@ -26,10 +26,10 @@ void setUp() { void insert() { Member member = new Member("sangchu", "123", "상추", "sangchu@gmail.com"); - Member saved = memberRepository.insert(member); + memberRepository.insert(member); Member find = memberRepository.findById("sangchu").get(); - assertThat(find).isEqualTo(saved); + assertThat(find).isEqualTo(member); } @Test