Skip to content
Merged
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
Expand Up @@ -55,11 +55,20 @@ public ApiResponse<String> deleteShow(@AuthenticationPrincipal(expression = "mem
}

@GetMapping("/{amateurShowId}")
@Operation(summary = "소극장 공연 조회 - 단건")
@Operation(summary = "승인된 소극장 공연 단건 조회 - 일반 사용자용")
public ApiResponse<AmateurShowResponseDTO.AmateurShowResult> getAmateurShow(@PathVariable Long amateurShowId){
return ApiResponse.onSuccess(amateurService.getAmateurShow(amateurShowId));
}

@PreAuthorize("hasRole('PERFORMER')")
@GetMapping("/created/{amateurShowId}")
@Operation(summary = "방금 등록한 공연 단건 조회(아직 미승인) - 등록자용")
public ApiResponse<AmateurShowResponseDTO.AmateurShowResult> getCreatedShow(
@AuthenticationPrincipal(expression = "member") Member member,
@PathVariable Long amateurShowId){
return ApiResponse.onSuccess(amateurService.getCreatedShow(member.getId(), amateurShowId));
}
Comment on lines +63 to +70
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n "getCreatedShow" --type=java -A 15

Repository: SeeATheater/CC_Backend

Length of output: 5440


Fix misleading error code in service layer.

The endpoint is properly secured with @PreAuthorize("hasRole('PERFORMER')") and correctly extracts the authenticated member. However, the service throws ErrorStatus.MEMBER_NOT_PERFORMER when the show isn't found for that member (line 461 in AmateurServiceImpl.java). This error code is semantically incorrect — the member is a performer (they passed the role check); the real issue is the show doesn't exist or isn't owned by that member. Use SHOW_NOT_FOUND or SHOW_NOT_OWNED_BY_MEMBER instead.

🤖 Prompt for AI Agents
In `@src/main/java/cc/backend/amateurShow/controller/AmateurController.java`
around lines 63 - 70, The service method handling getCreatedShow in
AmateurServiceImpl currently throws ErrorStatus.MEMBER_NOT_PERFORMER when a show
isn't found or isn't owned by the authenticated performer; change that to a
semantically correct status such as ErrorStatus.SHOW_NOT_FOUND or
ErrorStatus.SHOW_NOT_OWNED_BY_MEMBER in the code path that checks
ownership/fetch result (the branch that currently throws MEMBER_NOT_PERFORMER
around the getCreatedShow handling), and update any related exception
construction or messages so the controller AmateurController.getCreatedShow
receives the correct error code.


@GetMapping("/ranking")
@Operation(summary = "소극장 공연 랭킹 조회 API")
public ApiResponse<List<AmateurShowResponseDTO.AmateurShowList>> getShowRanking() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static AmateurShowResponseDTO.AmateurShowResult toResponseDTO(AmateurShow
//.place(amateurShow.getPlace())
.posterImageUrl(amateurShow.getPosterImageUrl())
.schedule(schedule)
.runtime(amateurShow.getRuntime())
.runtime(amateurShow.getRuntime() + "분")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Null runtime will produce the string "null분".

amateurShow.getRuntime() returns Integer (nullable). When null, the concatenation null + "분" yields "null분" instead of an empty or omitted value.

🐛 Proposed fix
-                .runtime(amateurShow.getRuntime() + "분")
+                .runtime(amateurShow.getRuntime() != null ? amateurShow.getRuntime() + "분" : null)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.runtime(amateurShow.getRuntime() + "분")
.runtime(amateurShow.getRuntime() != null ? amateurShow.getRuntime() + "분" : null)
🤖 Prompt for AI Agents
In `@src/main/java/cc/backend/amateurShow/converter/AmateurConverter.java` at line
274, The builder call in AmateurConverter that sets
.runtime(amateurShow.getRuntime() + "분") will produce "null분" when
amateurShow.getRuntime() is null; change it to conditionally format the value
(e.g., if amateurShow.getRuntime() == null then pass null or an empty string,
otherwise pass amateurShow.getRuntime() + "분") so the runtime field is
omitted/empty instead of "null분"; locate the .runtime(...) invocation in
AmateurConverter and replace the direct concatenation with a null-safe
conditional/ternary or use Optional to format only when getRuntime() is
non-null.

.account(amateurShow.getAccount())
.contact(amateurShow.getContact())
.hashtag(amateurShow.getHashtag())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AmateurEnrollRequestDTO {
@NotNull(message = "종료 날짜는 필수입니다")
private LocalDate end; // 공연 종료 날짜

private String runtime; // 러닝타임
private Integer runtime; // 러닝타임
private String bankName; // 은행명
private String account; // 계좌번호
private String depositor; // 입금자명
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AmateurUpdateRequestDTO {
//private String place; // 공연장 주소
private LocalDate start; // 공연 시작 날짜
private LocalDate end; // 공연 종료 날짜
private String runtime; // 러닝타임
private Integer runtime; // 러닝타임
private String bankName; // 은행명
private String account; // 계좌번호
private String depositor; // 입금자명
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AmateurShow extends BaseEntity {
private String depositor; // 입금자명

// 추가
private String runtime;
private Integer runtime;

private String hashtag;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Page<AmateurShow> findByNameOrPerformer(
Pageable pageable
);


Optional<AmateurShow> findByIdAndMemberId(Long id, Long memberId);

Slice<AmateurShow> findByMember_IdOrderByIdDesc(Long memberId, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ AmateurEnrollResponseDTO.AmateurEnrollResult enrollShow(Long memberId,
List<AmateurShowResponseDTO.AmateurShowList> getShowRanking();
List<AmateurShowResponseDTO.AmateurShowList> getRecentlyHotShow();
List<AmateurShowResponseDTO.AmateurShowList> getShowClosing();
AmateurShowResponseDTO.AmateurShowResult getCreatedShow(Long memberId, Long amateurId);


Slice<AmateurShowResponseDTO.MyShowAmateurShowList> getMyAmateurShow(Long memberId, AmateurShowStatus showStatus, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ public AmateurShowResponseDTO.AmateurShowResult getAmateurShow(Long amateurShowI
AmateurShow amateurShow = amateurShowRepository.findById(amateurShowId)
.orElseThrow(() -> new GeneralException(ErrorStatus.AMATEURSHOW_NOT_FOUND));

if(!amateurShow.getApprovalStatus().equals(ApprovalStatus.APPROVED)) {
throw new GeneralException((ErrorStatus.NOT_APPROVED_SHOW));
}

return AmateurConverter.toResponseDTO(amateurShow);
}

@Override
public AmateurShowResponseDTO.AmateurShowResult getCreatedShow(Long memberId, Long amateurShowId){
AmateurShow amateurShow =
amateurShowRepository.findByIdAndMemberId(amateurShowId, memberId)
.orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_PERFORMER));

return AmateurConverter.toResponseDTO(amateurShow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public enum ErrorStatus implements BaseErrorCode {
// AMATEURSHOW ERROR
AMATEURSHOW_NOT_FOUND(HttpStatus.NOT_FOUND, "AMATEURSHOW4000", "존재하지 않는 소극장 공연입니다."),
INVALID_DATE_RANGE(HttpStatus.NOT_ACCEPTABLE, "AMATEURSHOW4001", "공연 시작 날짜는 종료 날짜 이전이어햐 합니다."),
NOT_APPROVED_SHOW(HttpStatus.FORBIDDEN, "AMATEURSHOW4002", "승인되지 않은 소극장 공연입니다."),


// AMATEUR TICKET ERROR
AMATEUR_TICKET_NOT_FOUND(HttpStatus.NOT_FOUND, "AMATEURTICKET4000", "존재하지 않는 소극장 공연 티켓입니다."),
Expand Down