From 035125090d2946bab9cc52e073c71a65f7f51131 Mon Sep 17 00:00:00 2001 From: kimday0326 Date: Fri, 31 May 2024 15:52:44 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20PR=20=EA=B8=B0=EB=8A=A5=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/file/application/FileService.java | 7 +- .../khu/gitbox/domain/file/entity/File.java | 252 ++++++++++-------- .../dto/response/FileGetResponse.java | 2 + .../application/PullRequestService.java | 50 ++-- .../pullRequest/entity/PullRequest.java | 47 ++-- .../entity/PullRequestComment.java | 44 +-- .../presentation/PullRequestController.java | 13 +- ...a => PullRequestCommentCreateRequest.java} | 13 +- .../presentation/dto/PullRequestDto.java | 17 +- src/main/resources/db/data.sql | 72 +++-- 10 files changed, 294 insertions(+), 223 deletions(-) rename src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/{PullRequestCommentDto.java => PullRequestCommentCreateRequest.java} (50%) diff --git a/src/main/java/com/khu/gitbox/domain/file/application/FileService.java b/src/main/java/com/khu/gitbox/domain/file/application/FileService.java index 525927b..cbe9a3f 100644 --- a/src/main/java/com/khu/gitbox/domain/file/application/FileService.java +++ b/src/main/java/com/khu/gitbox/domain/file/application/FileService.java @@ -78,7 +78,7 @@ public FileGetResponse uploadFile(FileCreateRequest request, MultipartFile multi return FileGetResponse.of(fileRepository.save(savedFile)); } - // 새로운 버전 파일 업로드 (+ PR 생성) + // 새로운 버전 파일 업로드 & PR 생성 public FileGetResponse uploadNewVersionFile( Long parentFileId, PullRequestCreateRequest request, @@ -119,6 +119,9 @@ public FileGetResponse uploadNewVersionFile( .build(); pullRequestRepository.save(pullRequest); + // 파일 PR ID 설정 + savedFile.updatePullRequestId(pullRequest.getId()); + // 워크스페이스 용량 업데이트 final Workspace workspace = workspaceService.findWorkspaceById(parentFile.getWorkspaceId()); workspace.increaseUsedStorage(savedFile.getSize()); @@ -166,7 +169,7 @@ public void deleteFileTree(Long fileId) { }); } - private File findFileById(Long fileId) { + public File findFileById(Long fileId) { return fileRepository.findById(fileId) .orElseThrow(() -> new CustomException(HttpStatus.NOT_FOUND, "파일을 찾을 수 없습니다.")); } diff --git a/src/main/java/com/khu/gitbox/domain/file/entity/File.java b/src/main/java/com/khu/gitbox/domain/file/entity/File.java index 9da4765..87ffcdb 100644 --- a/src/main/java/com/khu/gitbox/domain/file/entity/File.java +++ b/src/main/java/com/khu/gitbox/domain/file/entity/File.java @@ -1,125 +1,157 @@ package com.khu.gitbox.domain.file.entity; +import org.springframework.http.HttpStatus; + import com.khu.gitbox.common.BaseEntity; import com.khu.gitbox.common.exception.CustomException; -import jakarta.persistence.*; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.http.HttpStatus; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @Table(name = "file") public class File extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "name", nullable = false) - private String name; - - @Column(name = "size", nullable = false) - private Long size; - - @Column(name = "url", nullable = false) - private String url; - - @Enumerated(EnumType.STRING) - @Column(name = "tag") - private FileTag tag; - - @Enumerated(EnumType.STRING) - @Column(name = "type", nullable = false) - private FileType type; - - @Enumerated(EnumType.STRING) - @Column(name = "status", nullable = false) - private FileStatus status; - - @Column(name = "version", nullable = false) - private Long version; - - @Column(name = "is_latest", nullable = false) - private boolean isLatest; - - @Column(name = "is_deleted", nullable = false) - private boolean isDeleted; - - @Column(name = "writer_id", nullable = false) - private Long writerId; - - @Column(name = "workspace_id", nullable = false) - private Long workspaceId; - - @Column(name = "folder_id", nullable = false) - private Long folderId; - - @Column(name = "parent_file_id") - private Long parentFileId; - - @Column(name = "root_file_id") - private Long rootFileId; - - @Builder - File( - String name, - Long size, - String url, - FileType type, - FileStatus status, - Long version, - boolean isLatest, - Long writerId, - Long workspaceId, - Long folderId, - Long parentFileId, - Long rootFileId - ) { - this.name = name; - this.size = size; - this.url = url; - this.type = type; - this.status = status; - this.version = version; - this.isLatest = isLatest; - this.writerId = writerId; - this.workspaceId = workspaceId; - this.folderId = folderId; - this.parentFileId = parentFileId; - this.rootFileId = rootFileId; - } - - public void updateRootFileId(Long id) { - this.rootFileId = id; - } - - public void updateFile(String name, FileTag tag) { - this.name = name; - this.tag = tag; - } - - public void updateStatus(FileStatus status) { - this.status = status; - } - - public void updateTag(FileTag tag) { - this.tag = tag; - } - - public void delete() { - if (this.isDeleted) { - throw new CustomException(HttpStatus.BAD_REQUEST, "이미 삭제된 파일입니다."); - } - this.isDeleted = true; - } - - public void restore() { - if (!this.isDeleted) { - throw new CustomException(HttpStatus.BAD_REQUEST, "이미 복원된 파일입니다."); - } - this.isDeleted = false; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name", nullable = false) + private String name; + + @Column(name = "size", nullable = false) + private Long size; + + @Column(name = "url", nullable = false) + private String url; + + @Enumerated(EnumType.STRING) + @Column(name = "tag") + private FileTag tag; + + @Enumerated(EnumType.STRING) + @Column(name = "type", nullable = false) + private FileType type; + + @Enumerated(EnumType.STRING) + @Column(name = "status", nullable = false) + private FileStatus status; + + @Column(name = "version", nullable = false) + private Long version; + + @Column(name = "is_latest", nullable = false) + private boolean isLatest; + + @Column(name = "is_deleted", nullable = false) + private boolean isDeleted; + + @Column(name = "writer_id", nullable = false) + private Long writerId; + + @Column(name = "workspace_id", nullable = false) + private Long workspaceId; + + @Column(name = "folder_id", nullable = false) + private Long folderId; + + @Column(name = "parent_file_id") + private Long parentFileId; + + @Column(name = "root_file_id") + private Long rootFileId; + + @Column(name = "pull_request_id") + private Long pullRequestId; + + @Builder + File( + String name, + Long size, + String url, + FileType type, + FileStatus status, + Long version, + boolean isLatest, + Long writerId, + Long workspaceId, + Long folderId, + Long parentFileId, + Long rootFileId + ) { + this.name = name; + this.size = size; + this.url = url; + this.type = type; + this.status = status; + this.version = version; + this.isLatest = isLatest; + this.writerId = writerId; + this.workspaceId = workspaceId; + this.folderId = folderId; + this.parentFileId = parentFileId; + this.rootFileId = rootFileId; + } + + public void updateRootFileId(Long id) { + this.rootFileId = id; + } + + public void updateFile(String name, FileTag tag) { + this.name = name; + this.tag = tag; + } + + public void approve(File parentFile) { + if (this.status != FileStatus.PENDING) { + throw new CustomException(HttpStatus.BAD_REQUEST, "승인할 수 없는 파일입니다."); + } + parentFile.isLatest = false; + this.isLatest = true; + this.status = FileStatus.APPROVED; + } + + public void reject(File parentFile) { + if (this.status != FileStatus.PENDING) { + throw new CustomException(HttpStatus.BAD_REQUEST, "반려할 수 없는 파일입니다."); + } + parentFile.initPullRequestId(); + this.status = FileStatus.REJECTED; + } + + public void initPullRequestId() { + this.pullRequestId = null; + } + + public void updatePullRequestId(Long pullRequestId) { + if (this.pullRequestId != null) { + throw new CustomException(HttpStatus.BAD_REQUEST, "이미 PR이 존재하는 파일입니다."); + } + this.pullRequestId = pullRequestId; + } + + public void delete() { + if (this.isDeleted) { + throw new CustomException(HttpStatus.BAD_REQUEST, "이미 삭제된 파일입니다."); + } + this.isDeleted = true; + } + + public void restore() { + if (!this.isDeleted) { + throw new CustomException(HttpStatus.BAD_REQUEST, "이미 복원된 파일입니다."); + } + this.isDeleted = false; + } } diff --git a/src/main/java/com/khu/gitbox/domain/file/presentation/dto/response/FileGetResponse.java b/src/main/java/com/khu/gitbox/domain/file/presentation/dto/response/FileGetResponse.java index 7a9eef7..625c422 100644 --- a/src/main/java/com/khu/gitbox/domain/file/presentation/dto/response/FileGetResponse.java +++ b/src/main/java/com/khu/gitbox/domain/file/presentation/dto/response/FileGetResponse.java @@ -22,6 +22,7 @@ public record FileGetResponse( Long folderId, Long parentFileId, Long rootFileId, + Long pullRequestId, LocalDateTime createdAt, LocalDateTime updatedAt ) { @@ -41,6 +42,7 @@ public static FileGetResponse of(File file) { file.getFolderId(), file.getParentFileId(), file.getRootFileId(), + file.getPullRequestId(), file.getCreatedAt(), file.getUpdatedAt() ); diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/application/PullRequestService.java b/src/main/java/com/khu/gitbox/domain/pullRequest/application/PullRequestService.java index 15577d0..84c6270 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/application/PullRequestService.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/application/PullRequestService.java @@ -4,45 +4,46 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.khu.gitbox.common.exception.CustomException; +import com.khu.gitbox.domain.file.application.FileService; import com.khu.gitbox.domain.file.entity.File; -import com.khu.gitbox.domain.file.entity.FileStatus; -import com.khu.gitbox.domain.file.infrastructure.FileRepository; import com.khu.gitbox.domain.member.entity.Member; import com.khu.gitbox.domain.member.infrastructure.MemberRepository; import com.khu.gitbox.domain.pullRequest.entity.PullRequest; import com.khu.gitbox.domain.pullRequest.entity.PullRequestComment; import com.khu.gitbox.domain.pullRequest.infrastructure.PullRequestCommentRepository; import com.khu.gitbox.domain.pullRequest.infrastructure.PullRequestRepository; -import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestCommentDto; +import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestCommentCreateRequest; import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestDto; import com.khu.gitbox.domain.workspace.entity.WorkspaceMember; import com.khu.gitbox.domain.workspace.infrastructure.WorkspaceMemberRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Service +@Transactional @RequiredArgsConstructor public class PullRequestService { private final PullRequestRepository pullRequestRepository; private final PullRequestCommentRepository pullRequestCommentRepository; private final MemberRepository memberRepository; - private final FileRepository fileRepository; private final WorkspaceMemberRepository workspaceMemberRepository; + private final FileService fileService; public PullRequestDto infoPullRequest(Long fileId) { - PullRequest pullRequest = pullRequestRepository.findByFileId(fileId).orElseThrow(() -> { throw new CustomException(HttpStatus.NOT_FOUND, "pull-request가 존재하지 않습니다. 해당 파일을 다시 확인해주세요"); }); + Member writer = memberRepository.findById(pullRequest.getWriterId()).orElseThrow(() -> { throw new CustomException(HttpStatus.NOT_FOUND, "작성자가 존재하지 않습니다."); }); - File file = fileRepository.findById(fileId).orElseThrow(() -> { - throw new CustomException(HttpStatus.NOT_FOUND, "찾는 파일이 존재하지 않습니다."); - }); + File file = fileService.findFileById(fileId); List commentList = pullRequestCommentRepository.findAllByPullRequestId(pullRequest.getId()) .orElseThrow(() -> { @@ -57,23 +58,26 @@ public PullRequestDto infoPullRequest(Long fileId) { .build(); if (!commentList.isEmpty()) { - pullRequestDto.setCommentDtoList(commentList); + pullRequestDto.setComments(commentList); } - return pullRequestDto; - } - public void isApprovedPullRequest(PullRequestCommentDto pullRequestCommentDto, Long reviewerId, Long fileId) { + public void isApprovedPullRequest(PullRequestCommentCreateRequest pullRequestCommentCreateRequest, Long reviewerId, + Long fileId) { + File file = fileService.findFileById(fileId); - PullRequest pullRequest = pullRequestRepository.findByFileId(fileId).orElseThrow(() -> { - throw new CustomException(HttpStatus.BAD_REQUEST, "현재 보낸 파일(fileId)을 찾을 수 없습니다."); - }); + if (file.getWriterId().equals(reviewerId)) { + throw new CustomException(HttpStatus.BAD_REQUEST, "본인이 작성한 파일에 대한 pull-request는 승인할 수 없습니다."); + } + + PullRequest pullRequest = pullRequestRepository.findByFileId(fileId) + .orElseThrow(() -> new CustomException(HttpStatus.BAD_REQUEST, "현재 보낸 파일(fileId)을 찾을 수 없습니다.")); // comment 내용 저장 PullRequestComment pullRequestComment = new PullRequestComment( - pullRequestCommentDto.getComment(), - pullRequestCommentDto.getIsApproved(), + pullRequestCommentCreateRequest.getComment(), + pullRequestCommentCreateRequest.getIsApproved(), reviewerId, pullRequest.getId() ); @@ -82,12 +86,11 @@ public void isApprovedPullRequest(PullRequestCommentDto pullRequestCommentDto, L List responsers = pullRequestCommentRepository.findAllByPullRequestId( pullRequest.getId()).get(); - File file = fileRepository.findById(fileId).get(); List members = workspaceMemberRepository.findByWorkspaceId(file.getWorkspaceId()); if (members.size() - 1 == responsers.size()) { - + log.info("모든 멤버가 리뷰를 완료했습니다."); int trueCount = 0; int falseCount = 0; @@ -97,15 +100,14 @@ public void isApprovedPullRequest(PullRequestCommentDto pullRequestCommentDto, L else falseCount++; } + log.info("trueCount : {}", trueCount); + File parentFile = fileService.findFileById(file.getParentFileId()); if (trueCount > falseCount) { - file.updateStatus(FileStatus.APPROVED); + file.approve(parentFile); } else { - file.updateStatus(FileStatus.REJECTED); + file.reject(parentFile); } - - fileRepository.save(file); } } - } diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequest.java b/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequest.java index 3bd4f59..995c856 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequest.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequest.java @@ -1,7 +1,13 @@ package com.khu.gitbox.domain.pullRequest.entity; import com.khu.gitbox.common.BaseEntity; -import jakarta.persistence.*; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -12,27 +18,30 @@ @Entity @Table(name = "pull_request") public class PullRequest extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "title", nullable = false) + private String title; - @Column(name = "title", nullable = false) - private String title; + @Column(name = "message", nullable = false) + private String message; - @Column(name = "message", nullable = false) - private String message; + @Column(name = "writer_id", nullable = false) // 연관관계 + private Long writerId; - @Column(name = "writer_id", nullable = false) // 연관관계 - private Long writerId; + @Column(name = "parent_file_id") + private Long parentFileId; - @Column(name = "file_id", nullable = false) // 연관관계 - private Long fileId; + @Column(name = "file_id", nullable = false) // 연관관계 + private Long fileId; - @Builder - public PullRequest(String title, String message, Long writerId, Long fileId) { - this.title = title; - this.message = message; - this.writerId = writerId; - this.fileId = fileId; - } + @Builder + public PullRequest(String title, String message, Long writerId, Long fileId) { + this.title = title; + this.message = message; + this.writerId = writerId; + this.fileId = fileId; + } } diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequestComment.java b/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequestComment.java index 168f122..45e664c 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequestComment.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/entity/PullRequestComment.java @@ -1,7 +1,13 @@ package com.khu.gitbox.domain.pullRequest.entity; import com.khu.gitbox.common.BaseEntity; -import jakarta.persistence.*; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -12,27 +18,27 @@ @Entity @Table(name = "pull_request_comment") public class PullRequestComment extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - @Column(name = "comment") - private String comment; + @Column(name = "comment") + private String comment; - @Column(name = "is_approved", nullable = false) - private Boolean isApproved; + @Column(name = "is_approved", nullable = false) + private Boolean isApproved; - @Column(name = "reviewr_id", nullable = false) - private Long reviewerId; + @Column(name = "reviewer_id", nullable = false) + private Long reviewerId; - @Column(name = "pull_request_id", nullable = false) - private Long pullRequestId; + @Column(name = "pull_request_id", nullable = false) + private Long pullRequestId; - @Builder - public PullRequestComment(String comment, Boolean isApproved, Long reviewerId, Long pullRequestId) { - this.comment = comment; - this.isApproved = isApproved; - this.reviewerId = reviewerId; - this.pullRequestId = pullRequestId; - } + @Builder + public PullRequestComment(String comment, Boolean isApproved, Long reviewerId, Long pullRequestId) { + this.comment = comment; + this.isApproved = isApproved; + this.reviewerId = reviewerId; + this.pullRequestId = pullRequestId; + } } diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/PullRequestController.java b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/PullRequestController.java index d851eab..7a44be3 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/PullRequestController.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/PullRequestController.java @@ -10,7 +10,7 @@ import com.khu.gitbox.auth.provider.JwtTokenProvider; import com.khu.gitbox.common.response.ApiResponse; import com.khu.gitbox.domain.pullRequest.application.PullRequestService; -import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestCommentDto; +import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestCommentCreateRequest; import com.khu.gitbox.domain.pullRequest.presentation.dto.PullRequestDto; import com.khu.gitbox.util.SecurityContextUtil; @@ -32,15 +32,14 @@ public ApiResponse infoPullRequest(@PathVariable Long fileId) { } @PostMapping("/pr") - public ApiResponse checkPullRequestComment( - @RequestBody PullRequestCommentDto pullRequestCommentDto, + public ApiResponse createPullRequestComment( + @RequestBody PullRequestCommentCreateRequest pullRequestCommentCreateRequest, @PathVariable Long fileId) { - Long memberId = SecurityContextUtil.getCurrentMemberId(); + Long reviewerId = SecurityContextUtil.getCurrentMemberId(); + pullRequestService.isApprovedPullRequest(pullRequestCommentCreateRequest, reviewerId, fileId); - pullRequestService.isApprovedPullRequest(pullRequestCommentDto, memberId, fileId); - - return ApiResponse.created(pullRequestCommentDto.getIsApproved()); + return ApiResponse.created(pullRequestCommentCreateRequest.getIsApproved()); } } diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentDto.java b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentCreateRequest.java similarity index 50% rename from src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentDto.java rename to src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentCreateRequest.java index 7f273b7..dad0b84 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentDto.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestCommentCreateRequest.java @@ -1,5 +1,7 @@ package com.khu.gitbox.domain.pullRequest.presentation.dto; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -9,8 +11,9 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class PullRequestCommentDto { - private String comment; - private Boolean isApproved; - private Long reviewerId; -} \ No newline at end of file +public class PullRequestCommentCreateRequest { + @NotBlank + private String comment; + @NotNull + private Boolean isApproved; +} diff --git a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestDto.java b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestDto.java index f9862c5..97e29b0 100644 --- a/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestDto.java +++ b/src/main/java/com/khu/gitbox/domain/pullRequest/presentation/dto/PullRequestDto.java @@ -1,24 +1,23 @@ package com.khu.gitbox.domain.pullRequest.presentation.dto; +import java.util.List; + import com.khu.gitbox.domain.pullRequest.entity.PullRequestComment; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; - @Data @Builder @NoArgsConstructor @AllArgsConstructor public class PullRequestDto { - private String title; - private String message; - private String writer; - private String fileUrl; - - private List commentDtoList; - + private String title; + private String message; + private String writer; + private String fileUrl; + private List comments; } diff --git a/src/main/resources/db/data.sql b/src/main/resources/db/data.sql index de2320c..3cd16df 100644 --- a/src/main/resources/db/data.sql +++ b/src/main/resources/db/data.sql @@ -1,33 +1,49 @@ -INSERT INTO gitbox.member (created_at, id, updated_at, email, name, password, profile_image, role) -VALUES ('2024-05-20 09:27:28.554885', 1, '2024-05-20 09:27:28.554885', 'string@naver.com', 'string', - '$2a$10$HRBOgQzOVHK.X/BPOj9lDuEowNiPFbrZbqYponQTEP70/5f3YiC.6', null, 'USER'); -INSERT INTO gitbox.member (created_at, id, updated_at, email, name, password, profile_image, role) -VALUES ('2024-05-20 09:28:34.696628', 2, '2024-05-20 09:28:34.696628', 'string1@naver.com', 'string1', - '$2a$10$xKErMpZhE/9dpXDkGn2Q.OYjpWKJHrDleia.CzPl4ChnigVSS0JOy', null, 'USER'); +INSERT INTO gitbox.member (created_at, updated_at, email, name, password, profile_image, role) +VALUES ('2024-05-31 14:53:10.064056', '2024-05-31 14:53:10.064056', 'string@naver.com', 'string', + '$2a$10$Fqu6VJK47VbBhrtatHHg8OImUhm.A1il23PwejpU4IS9LM/ADgncO', null, 'USER'); +INSERT INTO gitbox.member (created_at, updated_at, email, name, password, profile_image, role) +VALUES ('2024-05-31 14:54:30.576054', '2024-05-31 14:54:30.576054', 'string1@naver.com', 'string1', + '$2a$10$G/hAil1Elo4dq86y6Eklvus//w/0VLKoD0CGeEdkbswq3RPxNoQSq', null, 'USER'); -INSERT INTO gitbox.workspace (created_at, id, max_storage, owner_id, root_folder_id, updated_at, used_storage, name) -VALUES ('2024-05-20 09:28:06.306780', 1, 1000000000, 1, 1, '2024-05-20 09:46:39.482480', 12252, 'workspace1'); -INSERT INTO gitbox.workspace_member (id, member_id, workspace_id) -VALUES (1, 1, 1); -INSERT INTO gitbox.workspace_member (id, member_id, workspace_id) -VALUES (3, 2, 1); +INSERT INTO gitbox.workspace (created_at, max_storage, owner_id, root_folder_id, updated_at, used_storage, name) +VALUES ('2024-05-31 14:54:47.664823', 1000000000, 1, 1, '2024-05-31 14:59:49.870526', 5910742, 'workspace1'); +INSERT INTO gitbox.workspace (created_at, max_storage, owner_id, root_folder_id, updated_at, used_storage, name) +VALUES ('2024-05-31 14:54:53.038571', 1000000000, 1, 2, '2024-05-31 14:54:53.109172', 0, 'workspace2'); -INSERT INTO gitbox.folder (created_at, id, parent_folder_id, updated_at, workspace_id, name) -VALUES ('2024-05-20 09:28:06.323471', 1, null, '2024-05-20 09:28:06.323471', 1, 'home'); -INSERT INTO gitbox.folder (created_at, id, parent_folder_id, updated_at, workspace_id, name) -VALUES ('2024-05-20 09:31:37.473576', 2, 1, '2024-05-20 09:34:10.245099', 1, 'picture'); +INSERT INTO gitbox.workspace_member (member_id, workspace_id) +VALUES (2, 1); +INSERT INTO gitbox.workspace_member (member_id, workspace_id) +VALUES (1, 1); +INSERT INTO gitbox.workspace_member (member_id, workspace_id) +VALUES (2, 2); +INSERT INTO gitbox.workspace_member (member_id, workspace_id) +VALUES (1, 2); -INSERT INTO gitbox.file (is_latest, created_at, folder_id, id, parent_file_id, root_file_id, size, updated_at, version, - workspace_id, writer_id, name, url, status, type, tag, is_deleted) -VALUES (true, '2024-05-20 09:35:28.381074', 1, 1, null, 1, 4084, '2024-05-20 09:35:28.395005', 1, 1, 1, - 'test-image.png', 'https://gitbox-file-bucket.s3.ap-northeast-2.amazonaws.com/test-image.png', 'APPROVED', - 'PNG', 'RED', false); -INSERT INTO gitbox.file (is_latest, created_at, folder_id, id, parent_file_id, root_file_id, size, updated_at, version, - workspace_id, writer_id, name, url, status, type, tag, is_deleted) -VALUES (false, '2024-05-20 09:46:39.424304', 1, 3, 1, 1, 4084, '2024-05-20 09:46:39.424304', 2, 1, 1, - 'test-image 2.png', 'https://gitbox-file-bucket.s3.ap-northeast-2.amazonaws.com/test-image%202.png', 'PENDING', - 'PNG', 'BLUE', false); +INSERT INTO gitbox.folder (created_at, parent_folder_id, updated_at, workspace_id, name) +VALUES ('2024-05-31 14:54:47.738147', null, '2024-05-31 14:54:47.738147', 1, 'home'); +INSERT INTO gitbox.folder (created_at, parent_folder_id, updated_at, workspace_id, name) +VALUES ('2024-05-31 14:54:53.097527', null, '2024-05-31 14:54:53.097527', 2, 'home'); +INSERT INTO gitbox.folder (created_at, parent_folder_id, updated_at, workspace_id, name) +VALUES ('2024-05-31 14:56:21.741918', 1, '2024-05-31 14:56:21.741918', 1, 'second folder'); -INSERT INTO gitbox.pull_request (created_at, file_id, id, updated_at, writer_id, message, title) -VALUES ('2024-05-20 09:46:39.435614', 3, 1, '2024-05-20 09:46:39.435614', 1, 'PR 코멘트', '새로운 PR'); +INSERT INTO gitbox.file (is_deleted, is_latest, created_at, folder_id, parent_file_id, pull_request_id, root_file_id, + size, updated_at, version, workspace_id, writer_id, name, url, status, tag, type) +VALUES (false, true, '2024-05-31 14:58:06.197759', 1, null, null, 1, 2955371, '2024-05-31 14:58:06.221400', 1, 1, 1, + 'temp-image.jpeg', 'https://gitbox-file-bucket.s3.ap-northeast-2.amazonaws.com/temp-image.jpeg_30bc7', + 'APPROVED', null, 'JPEG'); +INSERT INTO gitbox.file (is_deleted, is_latest, created_at, folder_id, parent_file_id, pull_request_id, root_file_id, + size, updated_at, version, workspace_id, writer_id, name, url, status, tag, type) +VALUES (false, false, '2024-05-31 14:59:49.801787', 1, 1, 1, 1, 2955371, '2024-05-31 15:01:12.329042', 2, 1, 1, + '새로운 버전 파일', 'https://gitbox-file-bucket.s3.ap-northeast-2.amazonaws.com/temp-image-2.jpeg_c1cbc', 'PENDING', + 'RED', 'JPEG'); +INSERT INTO gitbox.pull_request (created_at, file_id, parent_file_id, updated_at, writer_id, message, title) +VALUES ('2024-05-31 14:59:49.821650', 2, null, '2024-05-31 14:59:49.821650', 1, '확인부탁드려요.', '새로운 파일 버전입니다.'); + +INSERT INTO gitbox.action_history (created_at, file_id, member_id, updated_at, workspace_id, file_name, member_name, + action) +VALUES ('2024-05-31 14:58:06.210129', 1, 1, '2024-05-31 14:58:06.210129', 1, 'temp-image.jpeg', 'string', 'UPLOAD'); +INSERT INTO gitbox.action_history (created_at, file_id, member_id, updated_at, workspace_id, file_name, member_name, + action) +VALUES ('2024-05-31 14:59:49.856268', 2, 1, '2024-05-31 14:59:49.856268', 1, 'temp-image-2.jpeg', 'string', + 'PULL_REQUEST');