-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#33 조직 조회 API 추가 #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
58c482f
67fc0c1
ede17d3
d4bb469
a365d32
1f666db
befe198
4e2ddd9
f28a530
54b0483
23a87a3
2005842
f031b8e
752821a
9e67466
d8e9c40
63db05c
731cfdc
99b20cb
f7ec6a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Service | ||
|
|
@@ -59,9 +60,43 @@ public OrgResponse.Create createOrganization(Long userId, OrgRequest.Create requ | |
| return OrgConverter.toCreatedResponse(organization); | ||
| } | ||
|
|
||
| public OrgResponse.Read getOrganization(Long userId) { | ||
| //TODO | ||
| return null; | ||
| //로그인한 회원이 속한 조직 모두 조회 메서드 | ||
| public OrgResponse.MyOrganizations getMyOrganizations(Long userId) { | ||
| //회원 id 로 OrgMember 모두 조회 -> DB 조회에서 OrgStatus.ACTIVE 인 Organization 만 포함하는 OrgMember 만 조회해 온다. | ||
| List<OrgMember> orgMembers = orgMemberRepository.findOrgMemberByUserId(userId); | ||
|
|
||
| //각 OrgMember 에 Organization 추출 | ||
| List<Organization> organizations = new ArrayList<>(); | ||
|
|
||
| for (OrgMember orgMember : orgMembers) { | ||
| organizations.add(orgMember.getOrganization()); | ||
| } | ||
|
|
||
| //각각의 Organization Entity 를 DTO 로 변환 | ||
| List<OrgResponse.SimpleInfo> infos = new ArrayList<>(); | ||
|
|
||
| for (Organization organization : organizations) { | ||
| OrgResponse.SimpleInfo info = OrgConverter.toOrgSimpleInfo(organization, userId); | ||
| infos.add(info); | ||
| } | ||
|
|
||
| //마지막 반환 DTO 로 변환 | ||
| return OrgConverter.toMyOrganizations(infos); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| //하나의 조직에 대한 세부 사항(ID, 이름, 설명, logoUrl, createdAt) | ||
| public OrgResponse.OrgDetail getOrganizationDetail(Long orgId) { | ||
| //해당 조직 id 로 Organization 조회 | ||
| Organization organization = orgRepository.findById(orgId) | ||
| .orElseThrow(() -> new OrgHandler(OrgErrorCode.ORG_NOT_FOUND)); | ||
|
|
||
| //Soft Delete 된 조직이면 예외처리 | ||
| if (organization.getStatus() == OrgStatus.DELETED) { | ||
| throw new OrgHandler(OrgErrorCode.ORG_SOFT_DELETED); | ||
| } | ||
|
|
||
| //DTO 로 변환 | ||
| return OrgConverter.toOrgDetail(organization); | ||
| } | ||
|
Comment on lines
+77
to
89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 조직 비공개 여부에 따라 멤버십 접근 제어 검토 필요 현재 구현은 삭제된 조직 여부(소프트 딜리트)만 확인하고, 요청한 사용자가 해당 조직의 멤버인지는 검증하지 않습니다. 즉, 인증된 사용자라면 조직 비공개 조직이나 B2B 테넌트 격리가 요구사항에 있다면 아래와 같은 멤버십 검증 로직을 추가하는 것을 권장합니다: // 예시: orgMemberRepository를 통해 멤버십 확인
boolean isMember = orgMemberRepository.existsByOrganizationIdAndUserId(orgId, currentUserId);
if (!isMember) {
throw new OrgHandler(OrgErrorCode.ORG_FORBIDDEN);
}요구사항상 조직 상세 정보가 인증된 사용자 누구에게나 공개되는 것이라면 현재 구현도 문제없습니다. 의도된 설계인지 확인 부탁드립니다. 🤖 Prompt for AI Agents🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find OrgService interface and OrgServiceImpl, then examine structure
echo "=== Finding OrgService interface (excluding Impl) ==="
fd -e java "OrgService\.java"
echo ""
echo "=== Finding OrgServiceImpl ==="
fd -e java "OrgServiceImpl\.java"
echo ""
echo "=== Finding OrgController ==="
fd -e java "OrgController\.java"Repository: WhereYouAd/WhereYouAd-Backend Length of output: 470 🏁 Script executed: #!/bin/bash
# Examine the three key files
echo "=== OrgService.java (interface) ==="
cat -n src/main/java/com/whereyouad/WhereYouAd/domains/organization/domain/service/OrgService.java
echo ""
echo "=== OrgServiceImpl.java (class-level annotations + methods) ==="
head -100 src/main/java/com/whereyouad/WhereYouAd/domains/organization/domain/service/OrgServiceImpl.java
echo ""
echo "=== OrgController.java (injection check) ==="
head -50 src/main/java/com/whereyouad/WhereYouAd/domains/organization/presentation/OrgController.javaRepository: WhereYouAd/WhereYouAd-Backend Length of output: 7754 🏁 Script executed: #!/bin/bash
# Verify the exact class-level `@Transactional` annotation in OrgServiceImpl
echo "=== Class-level `@Transactional` in OrgServiceImpl ==="
sed -n '20,28p' src/main/java/com/whereyouad/WhereYouAd/domains/organization/domain/service/OrgServiceImpl.java
echo ""
echo "=== Check getOrganizationDetail method signature (lines 75-90) ==="
sed -n '75,90p' src/main/java/com/whereyouad/WhereYouAd/domains/organization/domain/service/OrgServiceImpl.javaRepository: WhereYouAd/WhereYouAd-Backend Length of output: 945 순수 조회 메서드에 이 메서드는 Organization을 조회하고 상태를 확인한 후 DTO로 변환하는 순수 읽기 작업입니다. 현재는 클래스 레벨의 readOnly = true를 추가하면:
♻️ 개선 제안+ `@Transactional`(readOnly = true)
public OrgResponse.OrgDetail getOrganizationDetail(Long orgId) {현재 코드는 OrgService 인터페이스에 메서드가 잘 선언되어 있고(12번 줄), OrgController도 인터페이스 타입으로 주입받기 때문에 정상 작동합니다. 좋은 DI 패턴이네요. 👍 🤖 Prompt for AI Agents |
||
|
|
||
| //조직 정보 수정 메서드 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,11 @@ public enum OrgErrorCode implements BaseErrorCode { | |||||||||
| ORG_NOT_FOUND(HttpStatus.NOT_FOUND, "ORG_404_1", "해당 id 의 조직이 존재하지 않습니다."), | ||||||||||
|
|
||||||||||
| //409 | ||||||||||
| ORG_ALREADY_ACTIVE(HttpStatus.CONFLICT, "ORG_409_1", "해당 조직은 이미 활성화 상태 입니다.") | ||||||||||
| ORG_ALREADY_ACTIVE(HttpStatus.CONFLICT, "ORG_409_1", "해당 조직은 이미 활성화 상태 입니다."), | ||||||||||
|
|
||||||||||
|
|
||||||||||
| //410 | ||||||||||
| ORG_SOFT_DELETED(HttpStatus.GONE, "ORG_410_1", "해당 조직은 삭제된 조직입니다.(Soft Delete)"), | ||||||||||
|
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 410 Gone 사용은 의미론적으로 정확합니다! 👍 메시지 문자열에 공백 하나가 빠졌습니다. 소프트 딜리트된 리소스에 ✏️ 메시지 수정 제안-ORG_SOFT_DELETED(HttpStatus.GONE, "ORG_410_1", "해당 조직은 삭제된 조직입니다.(Soft Delete)"),
+ORG_SOFT_DELETED(HttpStatus.GONE, "ORG_410_1", "해당 조직은 삭제된 조직입니다. (Soft Delete)"),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| ; | ||||||||||
| private final HttpStatus httpStatus; | ||||||||||
| private final String code; | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| package com.whereyouad.WhereYouAd.domains.organization.persistence.repository; | ||
|
|
||
| import com.whereyouad.WhereYouAd.domains.organization.persistence.entity.Organization; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface OrgRepository extends JpaRepository<Organization, Long> { | ||
|
|
||
| //검색하려는 문자열이 포함된 name 을 가진 조직을 추출 | ||
| @Query("select o from Organization o where o.name like concat('%', :name, '%') AND o.status = 'ACTIVE'") | ||
| Page<Organization> findOrganizationsByName(@Param(value = "name") String name, Pageable pageable); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.