Skip to content

Commit dbc43a7

Browse files
authored
Merge: UX 개선에 따른 도메인 규칙 수정
Refactor: UX 개선에 따른 도메인 규칙 수정
2 parents 51e2f4d + ce2a69b commit dbc43a7

72 files changed

Lines changed: 1437 additions & 1681 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Docsa는 문서의 변경 사항을 기록(commit) 단위로 추적하고, 버
4343

4444

4545
## 👩‍💻 팀 이장님 소개
46-
<table align="center"> <thead> <tr> <th style="text-align:center;">팀원</th> <th style="text-align:center;">역할</th> <th style="text-align:left;">담당 업무</th> </tr> </thead> <tbody> <tr> <td align="center"> <a href="https://github.com/sleepyhoon"> <img src="https://avatars.githubusercontent.com/u/101882530?v=4" width="60"><br/> <sub><b>한승훈</b></sub> </a> </td> <td align="center"><b>PO</b></td> <td> - 프론트 개발자님과 소통<br> - 프로젝트 일정 관리<br> - 저장 관련 API 구현 </td> </tr> <tr> <td align="center"> <a href="https://github.com/heets-blue"> <img src="https://avatars.githubusercontent.com/u/89324994?v=4" width="60"><br/> <sub><b>배문성</b></sub> </a> </td> <td align="center"><b>BE 팀장</b></td> <td> - 문서 관련 API 구현<br> - 이종간 트랜잭션 삭제 로직 설계 및 구현 <br> - CI/CD 및 인프라 구축</td> </tr> <tr> <td align="center"> <a href="https://github.com/Jeongmin39"> <img src="https://avatars.githubusercontent.com/u/80705450?v=4" width="60"><br/> <sub><b>한정민</b></sub> </a> </td> <td align="center"><b>AWS 관리자</b></td> <td> - 인증 및 사용자 관련 API 구현<br> - AWS 인프라 운영<br> - Docker 기반 배포<br> - 모니터링 시스템 구축 </td> </tr> <tr> <td align="center"> <a href="https://github.com/2ternal"> <img src="https://avatars.githubusercontent.com/u/26919446?v=4" width="60"><br/> <sub><b>권우철</b></sub> </a> </td> <td align="center"><b>BE 팀원</b></td> <td> - 기록(커밋) 관련 API 구현<br> - 병합기능(머지) API 구현<br> - 이종간 트랜잭션 삭제 로직 설계 </td> </tr> <tr> <td align="center"> <a href="https://github.com/ky1nonly"> <img src="https://avatars.githubusercontent.com/u/117032989?v=4" width="60"><br/> <sub><b>이예원</b></sub> </a> </td> <td align="center"><b>BE 팀원</b></td> <td> - 버전(브랜치) 관련 API 구현<br> - 그래프 조회 API 구현 </td> </tr> </tbody> </table>
46+
<table align="center"> <thead> <tr> <th style="text-align:center;">팀원</th> <th style="text-align:center;">역할</th> <th style="text-align:left;">담당 업무</th> </tr> </thead> <tbody> <tr> <td align="center"> <a href="https://github.com/sleepyhoon"> <img src="https://avatars.githubusercontent.com/u/101882530?v=4" width="60"><br/> <sub><b>한승훈</b></sub> </a> </td> <td align="center"><b>PO</b></td> <td> - 프론트 개발자님과 소통<br> - 프로젝트 일정 관리<br> - 저장 관련 API 구현 </td> </tr> <tr> <td align="center"> <a href="https://github.com/heets-blue"> <img src="https://avatars.githubusercontent.com/u/89324994?v=4" width="60"><br/> <sub><b>배문성</b></sub> </a> </td> <td align="center"><b>BE 팀장</b></td> <td> - 문서 관련 API 구현<br> - Outbox 기반 이종간 정합성 삭제/보상 구조 설계 및 생성 경로 Orchestrator 패턴 리펙토링 <br> - CI/CD 및 인프라 구축</td> </tr> <tr> <td align="center"> <a href="https://github.com/Jeongmin39"> <img src="https://avatars.githubusercontent.com/u/80705450?v=4" width="60"><br/> <sub><b>한정민</b></sub> </a> </td> <td align="center"><b>AWS 관리자</b></td> <td> - 인증 및 사용자 관련 API 구현<br> - AWS 인프라 운영<br> - Docker 기반 배포<br> - 모니터링 시스템 구축 </td> </tr> <tr> <td align="center"> <a href="https://github.com/2ternal"> <img src="https://avatars.githubusercontent.com/u/26919446?v=4" width="60"><br/> <sub><b>권우철</b></sub> </a> </td> <td align="center"><b>BE 팀원</b></td> <td> - 기록(커밋) 관련 API 구현<br> - 병합기능(머지) API 구현<br> - 이종간 트랜잭션 삭제 로직 설계 </td> </tr> <tr> <td align="center"> <a href="https://github.com/ky1nonly"> <img src="https://avatars.githubusercontent.com/u/117032989?v=4" width="60"><br/> <sub><b>이예원</b></sub> </a> </td> <td align="center"><b>BE 팀원</b></td> <td> - 버전(브랜치) 관련 API 구현<br> - 그래프 조회 API 구현 </td> </tr> </tbody> </table>
4747

4848
<div align="center">
4949

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'io.EJangs'
8-
version = '0.0.1'
8+
version = '1.0.0'
99

1010
java {
1111
toolchain {

src/main/java/io/ejangs/docsa/domain/block/app/BlockService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import io.ejangs.docsa.domain.block.dao.mongodb.BlockRepository;
44
import io.ejangs.docsa.domain.block.document.Block;
5-
import io.ejangs.docsa.domain.block.dto.response.BlockDto;
65
import io.ejangs.docsa.domain.block.util.BlockMapper;
76
import java.util.List;
7+
import java.util.Map;
88
import lombok.RequiredArgsConstructor;
99
import org.springframework.stereotype.Service;
1010

@@ -14,8 +14,8 @@ public class BlockService {
1414

1515
private final BlockRepository blockRepository;
1616

17-
public List<Block> saveBlocks(List<BlockDto> blockDtos) {
18-
List<Block> blocks = BlockMapper.toDocument(blockDtos);
17+
public List<Block> saveBlocks(List<Map<String, Object>> blockDataList) {
18+
List<Block> blocks = BlockMapper.toDocument(blockDataList);
1919
return blockRepository.saveAll(blocks);
2020
}
2121

src/main/java/io/ejangs/docsa/domain/block/dto/response/BlockDto.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/main/java/io/ejangs/docsa/domain/block/util/BlockMapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package io.ejangs.docsa.domain.block.util;
22

33
import io.ejangs.docsa.domain.block.document.Block;
4-
import io.ejangs.docsa.domain.block.dto.response.BlockDto;
54
import java.util.List;
5+
import java.util.Map;
66
import java.util.stream.Collectors;
77

88
public class BlockMapper {
99

10-
public static Block toDocument(BlockDto block) {
10+
public static Block toDocument(Map<String, Object> block) {
1111
return Block.builder()
12-
.content(block.data())
12+
.content(block)
1313
.build();
1414
}
1515

16-
public static List<Block> toDocument(List<BlockDto> blocks) {
16+
public static List<Block> toDocument(List<Map<String, Object>> blocks) {
1717
return blocks.stream()
1818
.map(BlockMapper::toDocument)
1919
.collect(Collectors.toList());

src/main/java/io/ejangs/docsa/domain/branch/api/BranchController.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.ejangs.docsa.domain.branch.dto.request.BranchRenameRequest;
66
import io.ejangs.docsa.domain.branch.dto.response.BranchCreateResponse;
77
import io.ejangs.docsa.domain.branch.dto.response.BranchRenameResponse;
8-
import io.ejangs.docsa.domain.branch.swagger.CreateBranchOrSaveDocs;
8+
import io.ejangs.docsa.domain.branch.swagger.CreateBranchDocs;
99
import io.ejangs.docsa.domain.branch.swagger.DeleteBranchDocs;
1010
import io.ejangs.docsa.domain.branch.swagger.RenameBranchDocs;
1111
import io.ejangs.docsa.domain.user.security.CustomUserDetails;
@@ -25,17 +25,15 @@ public class BranchController {
2525

2626
private final BranchService branchService;
2727

28-
// 브랜치에 이어서 새로운 저장 생성 or 새로운 브랜치 + 저장 생성
2928
@PostMapping
30-
@CreateBranchOrSaveDocs
31-
public ResponseEntity<BranchCreateResponse> createBranchOrSave(
29+
@CreateBranchDocs
30+
public ResponseEntity<BranchCreateResponse> createBranch(
3231
@AuthenticationPrincipal CustomUserDetails userDetails,
3332
@PathVariable Long documentId, @Valid @RequestBody BranchCreateRequest request) {
3433
return ResponseEntity.status(HttpStatus.CREATED)
35-
.body(branchService.createBranchOrSave(documentId, request, userDetails.getId()));
34+
.body(branchService.createBranch(documentId, request, userDetails.getId()));
3635
}
3736

38-
// 브랜치 이름 수정
3937
@PatchMapping("/{branchId}")
4038
@RenameBranchDocs
4139
public ResponseEntity<BranchRenameResponse> renameBranch(
@@ -47,7 +45,6 @@ public ResponseEntity<BranchRenameResponse> renameBranch(
4745
userDetails.getId()));
4846
}
4947

50-
// 브랜치 삭제
5148
@DeleteMapping("/{branchId}")
5249
@DeleteBranchDocs
5350
public ResponseEntity<Void> deleteBranch(@AuthenticationPrincipal CustomUserDetails userDetails,

src/main/java/io/ejangs/docsa/domain/branch/app/BranchQueryService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void checkBranchInDocOwnedByUser(Long documentId, Long branchId, Long use
6262
}
6363
}
6464

65-
public boolean checkFromOrRootCommitInBranch(Commit commit) {
66-
return branchRepository.existsByRootCommitIdOrFromCommitId(commit.getId());
65+
public boolean checkFromCommitOrMergeCommitInBranch(Commit commit) {
66+
return branchRepository.existsByFromOrMergeTargetCommitId(commit.getId());
6767
}
6868

6969
public void checkDuplicatedWithBranchName(Long docId, String branchName) {

src/main/java/io/ejangs/docsa/domain/branch/app/BranchService.java

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.ejangs.docsa.domain.branch.app;
22

3-
import io.ejangs.docsa.domain.branch.app.create.BranchCreateContext;
3+
import io.ejangs.docsa.domain.branch.dto.BranchCreateContext;
44
import io.ejangs.docsa.domain.branch.app.create.BranchCreateOrchestrator;
55
import io.ejangs.docsa.domain.branch.dto.request.BranchCreateRequest;
66
import io.ejangs.docsa.domain.branch.dto.response.BranchCreateResponse;
@@ -45,18 +45,12 @@ public class BranchService {
4545
private final BranchCreateOrchestrator branchCreateOrchestrator;
4646
private final MongoDeleteOutboxFactory mongoDeleteOutboxFactory;
4747

48-
/**
49-
* '이어서 작업하기' 로직으로, 브랜치를 생성하고 저장을 추가하거나 기존 브랜치에 저장을 추가합니다.
50-
* <p>
51-
* fromCommitId가 존재하면 기존 커밋에서 브랜치를 만들거나 저장(save)을 추가하는 상황입니다. fromCommitId가 null이면 최초 브랜치 생성으로,
52-
* 이 경우는 doc 도메인에서 처리합니다.
53-
*/
54-
public BranchCreateResponse createBranchOrSave(Long documentId, BranchCreateRequest request,
48+
public BranchCreateResponse createBranch(Long documentId, BranchCreateRequest request,
5549
Long userId) {
5650

5751
BranchCreateContext context = prepareBranchCreateContext(documentId, request, userId);
5852

59-
return branchCreateOrchestrator.createBranchOrSave(context);
53+
return branchCreateOrchestrator.create(context);
6054
}
6155

6256
private BranchCreateContext prepareBranchCreateContext(Long documentId,
@@ -72,29 +66,15 @@ private BranchCreateContext prepareBranchCreateContext(Long documentId,
7266
throw new CustomException(DocErrorCode.COMMIT_NOT_IN_DOCUMENT);
7367
}
7468

75-
boolean isLeaf = fromBranch.getLeafCommit() != null
76-
&& fromBranch.getLeafCommit().getId().equals(fromCommitId);
69+
branchQueryService.checkDuplicatedWithBranchName(documentId, request.name());
7770

78-
boolean isRoot = fromBranch.getRootCommit() != null
79-
&& fromBranch.getRootCommit().getId().equals(fromCommitId);
80-
boolean hasSave = fromBranch.getSave() != null;
81-
82-
boolean createNewBranch =
83-
!isLeaf || !fromBranch.getName().equals(request.name()) || (isLeaf && isRoot
84-
&& hasSave);
85-
86-
if (createNewBranch) {
87-
branchQueryService.checkDuplicatedWithBranchName(documentId, request.name());
88-
}
8971

9072
return new BranchCreateContext(
9173
fromBranch.getDoc(),
9274
fromBranch,
9375
fromCommit,
9476
request.name(),
95-
fromCommit.getCommitMongoId(),
96-
isLeaf,
97-
createNewBranch
77+
fromCommit.getCommitMongoId()
9878
);
9979
}
10080

src/main/java/io/ejangs/docsa/domain/branch/app/create/BranchCreateMySqlTxService.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.ejangs.docsa.domain.branch.app.create;
22

33
import io.ejangs.docsa.domain.branch.app.BranchQueryService;
4+
import io.ejangs.docsa.domain.branch.dto.BranchCreateContext;
45
import io.ejangs.docsa.domain.branch.dto.response.BranchCreateResponse;
56
import io.ejangs.docsa.domain.branch.entity.Branch;
67
import io.ejangs.docsa.domain.branch.util.BranchMapper;
@@ -19,16 +20,13 @@ public class BranchCreateMySqlTxService {
1920
private final SaveQueryService saveQueryService;
2021

2122
@Transactional(rollbackFor = Exception.class)
22-
public BranchCreateResponse createBranchOrSave(BranchCreateContext context, String saveContentId) {
23-
Branch targetBranch = context.fromBranch();
23+
public BranchCreateResponse createMySqlPart(BranchCreateContext context, String saveContentId) {
2424

25-
if (context.createNewBranch()) {
26-
targetBranch = branchQueryService.createBranch(context.doc(), context.branchName(), context.fromCommit());
27-
}
25+
Branch newBranch = branchQueryService.createBranch(context.doc(), context.branchName(), context.fromCommit());
2826

29-
Save save = saveQueryService.createSave(targetBranch, saveContentId);
27+
Save save = saveQueryService.createSave(newBranch, saveContentId);
3028
RenewUpdatedAtHelper.touch(save);
3129

32-
return BranchMapper.toBranchCreateResponse(targetBranch, save);
30+
return BranchMapper.toBranchCreateResponse(newBranch, save);
3331
}
3432
}

src/main/java/io/ejangs/docsa/domain/branch/app/create/BranchCreateOrchestrator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package io.ejangs.docsa.domain.branch.app.create;
22

3+
import io.ejangs.docsa.domain.branch.dto.BranchCreateContext;
34
import io.ejangs.docsa.domain.branch.dto.response.BranchCreateResponse;
5+
import io.ejangs.docsa.global.exception.CustomException;
6+
import io.ejangs.docsa.global.exception.errorcode.BranchErrorCode;
47
import io.ejangs.docsa.global.mongo.outbox.dto.MongoIdsDto;
58
import io.ejangs.docsa.global.mongo.outbox.entity.MongoDeleteOutbox.DomainType;
69
import io.ejangs.docsa.global.mongo.outbox.entity.MongoDeleteOutbox.OriginType;
@@ -20,12 +23,12 @@ public class BranchCreateOrchestrator {
2023
private final BranchCreateMySqlTxService branchCreateMySqlTxService;
2124
private final MongoDeleteOutboxFactory mongoDeleteOutboxFactory;
2225

23-
public BranchCreateResponse createBranchOrSave(BranchCreateContext context) {
26+
public BranchCreateResponse create(BranchCreateContext context) {
2427
String saveContentId = branchCreateMongoTxService.createSaveContentFromCommit(
2528
context.fromCommitMongoId());
2629

2730
try {
28-
return branchCreateMySqlTxService.createBranchOrSave(context, saveContentId);
31+
return branchCreateMySqlTxService.createMySqlPart(context, saveContentId);
2932
} catch (Exception e) {
3033
log.warn("[SAGA] 브랜치/저장 생성 실패 -> Mongo 삭제 Outbox 기록.", e);
3134
MongoIdsDto compensateTarget = new MongoIdsDto(List.of(saveContentId), null, null);
@@ -36,7 +39,7 @@ public BranchCreateResponse createBranchOrSave(BranchCreateContext context) {
3639
saveContentId,
3740
compensateTarget
3841
);
39-
throw e;
42+
throw new CustomException(BranchErrorCode.FAIL_CREATE_BRANCH);
4043
}
4144
}
4245
}

0 commit comments

Comments
 (0)