Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.matching.controller;

import com.example.matching.dto.response.InternalMatchingResponse;
import com.example.matching.service.MatchingService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/internal/matchings")
public class InternalMatchingController {

private final MatchingService matchingService;

@GetMapping("/{matching-id}")
public ResponseEntity<InternalMatchingResponse> getMatching(
@PathVariable("matching-id") Long matchingId
) {
return ResponseEntity.ok(matchingService.getMatchingForInternal(matchingId));
}
Comment on lines +12 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: /internal/ 경로에 대한 보안 설정 확인
rg -n 'internal' --type java src/main/java/ -g '!**/controller/**' -C3
rg -n 'SecurityConfig|WebSecurityConfig|SecurityFilterChain' --type java src/main/java/ -C5

Repository: MomentLit/Matching

Length of output: 3498


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' src/main/java/com/example/matching/global/config/SecurityConfig.java
printf '\n---\n'
rg -n '/internal/|/internal\\*\\*|hasRole|hasAuthority|permitAll|authenticated|anyRequest' src/main/java/com/example/matching -C2
printf '\n---\n'
sed -n '1,220p' src/main/java/com/example/matching/controller/InternalMatchingController.java

Repository: MomentLit/Matching

Length of output: 4511


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,260p' src/main/java/com/example/matching/global/security/JwtFilter.java
printf '\n---\n'
rg -n 'EnableMethodSecurity|PreAuthorize|Secured|RolesAllowed' src/main/java/com/example/matching -C2

Repository: MomentLit/Matching

Length of output: 2323


/internal/matchings 인증 규칙 추가 필요
src/main/java/com/example/matching/global/config/SecurityConfig.java에서 /matchings/**authenticated()로 묶고 나머지는 permitAll()이라, 이 내부 엔드포인트는 애플리케이션 레벨에서 공개 상태입니다. hostId/sellerId가 포함된 응답이 나가므로 /internal/**에 대한 인증 규칙이나 @PreAuthorize를 추가하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/example/matching/controller/InternalMatchingController.java`
around lines 12 - 24, Update SecurityConfig to require authentication for the
/internal/** endpoint pattern, ensuring InternalMatchingController is not
covered by the catch-all permitAll rule. Preserve the existing /matchings/**
authentication rule and other public endpoint behavior.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.matching.dto.response;

import com.example.matching.entity.Matching;
import com.example.matching.entity.MatchingStatus;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.LocalDateTime;

public record InternalMatchingResponse(
@JsonProperty("matching_id")
Long matchingId,

@JsonProperty("space_id")
Long spaceId,

@JsonProperty("host_id")
String hostId,

@JsonProperty("seller_id")
String sellerId,

@JsonProperty("start_time")
LocalDateTime startTime,

@JsonProperty("end_time")
LocalDateTime endTime,

@JsonProperty("total_price")
Integer totalPrice,

MatchingStatus status,

@JsonProperty("created_at")
LocalDateTime createdAt,

@JsonProperty("updated_at")
LocalDateTime updatedAt
) {

public static InternalMatchingResponse from(Matching matching) {
return new InternalMatchingResponse(
matching.getId(),
matching.getSpaceId(),
matching.getHostId(),
matching.getSellerId(),
matching.getStartTime(),
matching.getEndTime(),
matching.getTotalPrice(),
matching.getStatus(),
matching.getCreatedAt(),
matching.getUpdatedAt()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.matching.client.SpaceClient;
import com.example.matching.client.dto.SpaceMatchingContextResponse;
import com.example.matching.dto.request.MatchingCreateRequest;
import com.example.matching.dto.response.InternalMatchingResponse;
import com.example.matching.dto.response.MatchingCreateResponse;
import com.example.matching.dto.response.MatchingListResponse;
import com.example.matching.dto.response.MatchingSearchResponse;
Expand Down Expand Up @@ -69,6 +70,11 @@ public MatchingListResponse getSentMatchings(String userId) {
return toListResponse(matchingRepository.findBySellerIdOrderByCreatedAtDesc(userId));
}

@Transactional(readOnly = true)
public InternalMatchingResponse getMatchingForInternal(Long matchingId) {
return InternalMatchingResponse.from(getMatching(matchingId));
}
Comment on lines +73 to +76

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: getMatchingForInternal 메서드에 대한 테스트 존재 여부 확인
rg -n 'getMatchingForInternal' --type java src/test/

Repository: MomentLit/Matching

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 테스트 파일/관련 메서드 위치와 현재 구현 확인
git ls-files 'src/test/**/*.java' 'src/main/**/*.java' | rg 'MatchingService|Matching'
printf '\n--- service snippet ---\n'
sed -n '1,180p' src/main/java/com/example/matching/service/MatchingService.java
printf '\n--- test snippets ---\n'
for f in $(git ls-files 'src/test/**/*.java' | rg 'MatchingService|Matching'); do
  echo "### $f"
  sed -n '1,240p' "$f"
done

Repository: MomentLit/Matching

Length of output: 15471


getMatchingForInternal 테스트 추가 필요
MatchingServiceTestgetMatchingForInternal의 정상 조회와 MatchingNotFoundException 케이스를 추가해 주세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/example/matching/service/MatchingService.java` around lines
73 - 76, Extend MatchingServiceTest with coverage for getMatchingForInternal:
verify it returns the expected InternalMatchingResponse for a valid matchingId
and throws MatchingNotFoundException when the matching record is absent, reusing
the existing test setup and fixtures.


@Transactional
public void approve(String userId, Long matchingId) {
Matching matching = getMatching(matchingId);
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ spring:

jwt:
secret: momentlit-matchings-service-jwt-secret-key-for-local-test-1234567890

space-service:
base-url: http://localhost:8082