Skip to content

[FEATURE] 유저 삭제 시 업체 삭제 등 - #45

Open
Jin4041 wants to merge 49 commits into
developfrom
feature/#44-company-delete-user
Open

Jin4041 wants to merge 49 commits into
developfrom
feature/#44-company-delete-user

Conversation

@Jin4041

@Jin4041 Jin4041 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

📌 PR 제목

[FEATURE] 유저 삭제 시 업체 삭제 등 (#44)


✨ 작업 내용

유저 삭제 시 업체 삭제 추가 및 기타 추가사항 추가


🔍 상세 내용

구체적인 작업 내용을 작성해주세요.

  • Company: 유저 삭제 시 업체 삭제 추가
  • User: 요청 api 경로 수정
  • Product: 주문 조회 중 선점 과정에서 재고보다 주문량이 많은 경우 예외 추가

🔗 관련 이슈

Closes #44

✅ 체크리스트

  • 코드가 정상적으로 동작합니다.
  • 테스트를 완료했습니다.
  • 코드 스타일을 준수했습니다.

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 사용자 ID를 기반으로 회사와 관련 제품을 삭제할 수 있는 새로운 기능이 추가되었습니다.
  • 버그 수정

    • 제품 삭제 시 소유권 검증이 강화되었습니다.
    • 재고 부족 시 오류 처리 방식이 개선되었습니다.

Jin4041 and others added 30 commits April 1, 2026 15:51
chore: 공통 설정 사항 적용
refactor: Product, BaseEntity - getter 추가
chore: domain 계층 폴더 세분화
…ication/mapper/ProductMapper.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…ication/mapper/ProductMapper.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…in/model/BaseEntity.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…v_product

# Conflicts:
#	product-service/src/main/java/com/shipflow/productservice/domain/model/BaseEntity.java
…astructure/persistence/ProductRepositoryImpl.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
chore: redis 설정 추가
…ication/mapper/ProductMapper.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Jin4041 and others added 19 commits April 3, 2026 17:37
# Conflicts:
#	product-service/src/test/java/com/shipflow/productservice/application/service/ProductServiceTest.java
# Conflicts:
#	product-service/src/main/java/com/shipflow/productservice/application/service/ProductService.java
#	product-service/src/main/java/com/shipflow/productservice/presentation/controller/ProductInternalController.java
#	product-service/src/test/java/com/shipflow/productservice/application/service/ProductServiceTest.java
refactor: 재고 조회 중 주문량이 재고보다 많을 시 예외 발생
@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

사용자 삭제 시 관련 업체 및 제품을 함께 삭제하는 기능이 추가되었습니다. ProductFeignClient의 메서드 이름이 정규화되었으며(deleteProductByCompanyIddeleteProductsByCompanyId, deleteProductsByCompanyIdsdeleteProductsByCompanyIdList), CompanyService에 사용자 ID 기반 삭제 메서드가 추가되었습니다. CompanyInternalController에 새로운 내부 HTTP DELETE 엔드포인트(/internal/companies/user/{userId})가 생성되었으며, ProductService의 재고 초과 처리 로직이 에러 응답 반환에서 예외 발생으로 변경되었습니다.

Sequence Diagram

sequenceDiagram
    participant UserService as User Service
    participant CompanyController as Company Controller
    participant CompanyService as Company Service
    participant CompanyRepo as Company Repository
    participant ProductClient as Product Feign Client
    participant ProductService as Product Service

    UserService->>CompanyController: DELETE /internal/companies/user/{userId}
    CompanyController->>CompanyService: deleteProductByUser(userId)
    CompanyService->>CompanyRepo: findByManagerId(userId)
    CompanyRepo-->>CompanyService: Company
    CompanyService->>CompanyService: company.delete(userId)
    CompanyService->>CompanyRepo: save(company)
    CompanyRepo-->>CompanyService: Saved Company
    CompanyService->>ProductClient: deleteProductsByCompanyId(companyId)
    ProductClient->>ProductService: DELETE /internal/companies/{companyId}/products/deactivate
    ProductService-->>ProductClient: Success
    ProductClient-->>CompanyService: Success
    CompanyService-->>CompanyController: Void
    CompanyController-->>UserService: 200 OK
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • afterrest
  • kim-jun-won
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive ProductFeignClient와 CompanyFeignClient의 메서드명 변경이 이슈의 범위에 명시적으로 포함되지 않았습니다. 메서드명 변경(deleteProductByCompanyId→deleteProductsByCompanyId, deleteProductsByCompanyIds→deleteProductsByCompanyIdList, API 경로 변경)이 이슈 #44의 범위에 포함되는지 명확히 해주세요.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경사항인 '유저 삭제 시 업체 삭제'를 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 작업 내용, 상세 내용, 관련 이슈가 포함되어 있습니다.
Linked Issues check ✅ Passed 모든 이슈 요구사항이 충족되었습니다: CompanyService.deleteByUser 메서드 추가 및 ProductService.getStockInfoAndOccupy 예외 처리 개선이 구현되었습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#44-company-delete-user

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jin4041 Jin4041 changed the title Feature/#44 company delete user [FEATURE] 유저 삭제 시 업체 삭제 등 Apr 6, 2026
@Jin4041 Jin4041 added ✨ Feature 기능 추가 🔨 Refactor 코드 리팩토링 📬 API 서버 API 통신 labels Apr 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@company-service/src/main/java/com/shipflow/companyservice/application/service/CompanyService.java`:
- Around line 149-154: The remote product deletion is currently executed inside
the `@Transactional` method deleteProductByUser after company.delete and before
transaction commit, risking inconsistent state if the local commit fails; change
deleteProductByUser to only perform the company soft-delete and save (keep
CompanyService.deleteProductByUser calling company.delete(...) and
companyRepository.save(...)), then publish a lightweight event carrying
companyId (e.g., CompanyDeletedEvent) via ApplicationEventPublisher; implement a
separate listener method (or outbox processor) that invokes
productFeignClient.deleteProductsByCompanyId(companyId) annotated with
`@TransactionalEventListener`(phase = AFTER_COMMIT) (or use an outbox consumer) so
the remote call happens only after the local transaction successfully commits.

In
`@user-service/src/main/java/com/shipflow/userservice/infrastructure/client/CompanyFeignClient.java`:
- Around line 11-12: The Feign client method deleteManager in CompanyFeignClient
uses ClientApiResponse<Void> but the server endpoint
CompanyInternalController.deleteByUser returns void (no response body), causing
deserialization errors; update the Feign method signature to return void (or
ResponseEntity<Void>) to match the controller, and ensure the
`@DeleteMapping`("/internal/companies/user/{userId}") method parameter remains
annotated with `@PathVariable` UUID userId so the mapping stays correct.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f87236ae-7979-405e-864c-35f3c9522be5

📥 Commits

Reviewing files that changed from the base of the PR and between ae3056d and bcd7796.

📒 Files selected for processing (5)
  • company-service/src/main/java/com/shipflow/companyservice/application/client/ProductFeignClient.java
  • company-service/src/main/java/com/shipflow/companyservice/application/service/CompanyService.java
  • company-service/src/main/java/com/shipflow/companyservice/presentation/controller/CompanyInternalController.java
  • product-service/src/main/java/com/shipflow/productservice/application/service/ProductService.java
  • user-service/src/main/java/com/shipflow/userservice/infrastructure/client/CompanyFeignClient.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📬 API 서버 API 통신 ✨ Feature 기능 추가 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 유저 삭제 시 업체 삭제 등

2 participants