Skip to content

Conversation

@Todom2
Copy link
Contributor

@Todom2 Todom2 commented Feb 4, 2026

개요

PR 유형

어떤 변경 사항이 있나요?

  • 새로운 기능 추가
  • 프로젝트 세팅 추가
  • 버그 수정
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

🧩 작업 내용

  • DTO Record 작업 및 API 문서와 동기화 진행
  • 32, 33 번 API DTO는 추후 작성 예정(우선순위 후위)
  • Item 테이블의 Status와 Condition 분리
    Status 컬럼은 관리자나 서비스가 아이템을 '활성화' , '비활성화' 하기 위한 상태로 정의했고,
    Condition 컬럼은 실제 사용자가 아이템을 대여하거나 반납했을때 아이템의 상태를 '보관중', '대여중'으로 상태 추적을 위해 정의했습니다.
  • RentalHistory 테이블의 Status와 is_overdue 분리
    Status 컬럼은 해당 대여내역이 '대여'인지, '반납'인지 여부를 관리하기 위해 동작하도록 정의했습니다.
    is_overdue 컬럼은 만약 해당 대여내역이 가지고 있는 due_date 가 현재보다 지나, 연체가 된 상황일 경우 true가 되는 컬럼으로 해당 대여내역이 연체된 건인지, 아닌 건인지 판단하기 위해 사용됩니다.

📸 스크린샷(선택)

📣 To Reviewers

  • Reviewers : 팀 선택
  • Labels : 작업 유형, 자기 자신

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 관리자용 항목/카테고리/어시스트 생성 및 일괄 업데이트 요청 지원
    • 항목 상태(Condition) 및 카테고리 설명 표시 추가
    • 대여 연장·반납·신고 요청과 대여 이력 상세 응답 추가
    • 사용자 상세·패널티 정보 및 역할/상태 업데이트 기능 강화
  • Bug Fixes

    • 패널티 관련 명칭 및 열거형 정정으로 용어 정확성 개선

새로운 컬럼 추가입니다.
Api No.18 까지, 16번,17번 제외하고 Dto 추가

새로운 컬럼 추가입니다.
Api 32번,33번 제외하고 Dto 추가
Items, RentalHistory 에 있는 Status, Condition ENUM을 더 자연스럽게 개선했습니다.
gitignore에 gradle과 .idea를 추가했습니다.
@Todom2 Todom2 requested a review from fprtmjinho February 4, 2026 13:00
@Todom2 Todom2 added documentation Improvements or additions to documentation feature 새로운기능구현 labels Feb 4, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

여러 도메인에서 요청/응답용 DTO 레코드들이 대거 추가되었고, 일부 엔티티에 필드가 추가되거나 이름이 수정되었으며 열거형(enum)이 추가·수정·교체되었습니다. 또한 IDE/컴파일러 설정과 .gitignore에 항목이 추가되었습니다.

Changes

Cohort / File(s) Summary
구성 및 IDE 설정
\.gitignore, .idea/compiler.xml
gradle, .idea를 .gitignore에 추가하고 IntelliJ 애노테이션 처리 모듈 참조와 Javac 추가 옵션(-parameters)을 설정으로 업데이트했습니다.
Assist 도메인 - DTOs
src/main/java/ssurent/ssurentbe/domain/assists/dto/request/AdminAssistCreateRequest.java, src/main/java/ssurent/ssurentbe/domain/assists/dto/response/AdminAssistResponse.java
관리자용 Assist 생성 요청/응답 레코드 추가.
Item 도메인 - 요청 DTOs
src/main/java/ssurent/ssurentbe/domain/item/dto/request/AdminCategoryCreateRequest.java, src/main/java/ssurent/ssurentbe/domain/item/dto/request/AdminItemCreateRequest.java, src/main/java/ssurent/ssurentbe/domain/item/dto/request/AdminItemUpdateRequest.java
카테고리/아이템 생성 및 일괄 업데이트를 위한 레코드 추가(중첩 타입 포함).
Item 도메인 - 응답 DTOs
src/main/java/ssurent/ssurentbe/domain/item/dto/response/...
AdminItemResponse, AdminItemNameSearchResponse, AdminItemSearchResponse, CategoryResponse, ItemResponse 레코드 추가; 일부에 from() 팩토리 메서드 포함.
Item 도메인 - 엔티티/열거형
src/main/java/ssurent/ssurentbe/domain/item/entity/Category.java, .../Items.java, .../enums/Condition.java, .../enums/Status.java
Category에 description 필드 추가, Items에 condition 필드 추가, Condition enum 신규 생성. Status enum 상수와 설명 필드로 변경(기존 FIXING 제거 등).
Rental 도메인 - 요청 DTOs
src/main/java/ssurent/ssurentbe/domain/rental/dto/request/...
AdminRentalUpdateRequest(중첩), RentalExtendRequest, RentalReportRequest, RentalRequest, RentalReturnRequest 레코드 추가.
Rental 도메인 - 응답 DTOs
src/main/java/ssurent/ssurentbe/domain/rental/dto/response/...
AdminRentalHistoryResponse, AdminUserRentalItemResponse, RentalItemResponse 레코드 추가; 일부에 from() 메서드 포함.
Rental 도메인 - 엔티티/열거형
src/main/java/ssurent/ssurentbe/domain/rental/entity/RentalHistory.java, .../enums/Status.java
RentalHistory에 overdue boolean 컬럼 추가. Rental Status enum이 ACTIVE/OVERDUE/INACTIVE→RENT/RETURN으로 교체.
User 도메인 - 요청 DTOs
src/main/java/ssurent/ssurentbe/domain/users/dto/request/...
AdminUserPenaltyCreateRequest, AdminUserRoleUpdateRequest, AdminUserStatusUpdateRequest, UserPhoneNumberRequest 레코드 추가.
User 도메인 - 응답 DTOs
src/main/java/ssurent/ssurentbe/domain/users/dto/response/...
AdminUserDetailResponse(from 포함), AdminUserResponse(from 포함), UserPenaltyResponse(from 포함), UserResponse(from 포함) 레코드 추가.
User 도메인 - 엔티티/열거형 변경
src/main/java/ssurent/ssurentbe/domain/users/entity/UserPenaltyLog.java, .../enums/PanaltyTypes.java (삭제), .../enums/PenaltyTypes.java
클래스명 UserPanaltyLogUserPenaltyLog로 정정, 잘못된 PanaltyTypes 삭제 및 설명 필드가 있는 PenaltyTypes enum 신규 추가(상수: OVERDUE, UNAUTHORIZED_USE).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • fprtmjinho
  • CromNEXT

Poem

🐰 새 레코드들이 줄지어오네,
필드와 enum이 춤추는 밤,
from()로 변신 마법을 쓰고,
컬럼 하나 더해 데이터도 웃네,
당근 한 조각, 축하해요! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목 '[Feat] DTO 추가, 엔티티 변경'은 주요 변경 사항을 명확하게 요약하고 있습니다. DTO 추가 및 엔티티 변경이라는 핵심 내용을 간결하게 전달합니다.
Description check ✅ Passed PR 설명은 템플릿의 주요 섹션(개요, PR 유형, 체크리스트, 작업 내용)을 대부분 완성했으며, 상세한 작업 내용과 설계 의도를 명확히 기술하고 있습니다.
Linked Issues check ✅ Passed PR의 모든 주요 변경사항이 이슈 #2의 요구사항을 충족합니다. 모든 API에 대한 DTO 레코드 정의 및 from() 메서드 구현이 완료되었습니다.
Out of Scope Changes check ✅ Passed PR의 모든 변경사항이 이슈 #2의 범위 내입니다. .gitignore와 .idea/compiler.xml 수정은 프로젝트 세팅으로 정당화되며, Status/Condition 분리는 DTO 설계의 필수 요소입니다.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Add/#2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/ssurent/ssurentbe/domain/item/entity/Items.java (1)

32-38: ⚠️ Potential issue | 🟡 Minor

새 컬럼의 nullable = false 제약 조건과 백필이 필요합니다.

condition 컬럼이 nullable = false 없이 추가되었기 때문에 기존 레코드는 NULL 값을 가집니다. ItemResponse 등의 API 응답 DTO에서 Condition condition 필드가 null 처리 없이 노출되므로 NPE 또는 응답 스키마 불일치로 이어질 수 있습니다.

BaseEntitycreatedAt, updatedAt처럼 명시적인 nullable = false 제약을 추가하거나, 기존 레코드에 대한 백필(예: 기본값 설정)을 진행해야 합니다.

🤖 Fix all issues with AI agents
In @.idea/compiler.xml:
- Around line 15-20: The Gradle build is missing the Java compiler -parameters
flag causing mismatch with IDE settings; update build.gradle to configure all
JavaCompile tasks (use tasks.withType(JavaCompile).configureEach) and add the
'-parameters' argument to options.compilerArgs so the Gradle build and CI
produce parameter metadata consistent with the IDE; ensure this is applied for
all modules and commits the change.

In
`@src/main/java/ssurent/ssurentbe/domain/assists/dto/response/AdminAssistResponse.java`:
- Around line 3-7: Add a public static factory method named from to
AdminAssistResponse that accepts the corresponding entity (e.g., Assist assist)
and returns a new AdminAssistResponse populated from the entity's fields;
implement it as public static AdminAssistResponse from(Assist assist) { /* map
assist.getId(), assist.getName(), etc. */ } and include a null check if desired
to avoid NPEs.

In `@src/main/java/ssurent/ssurentbe/domain/item/dto/response/ItemResponse.java`:
- Around line 7-21: The ItemResponse.record declares itemId as String but
from(Items item) passes item.getId() (Long), causing a type mismatch; update the
from(Items item) method to convert the ID to a String (e.g.,
String.valueOf(item.getId()) or item.getId().toString()) when constructing the
new ItemResponse so the itemId parameter matches the record's String type and
consider null-safety if Items.getId() can be null.

In
`@src/main/java/ssurent/ssurentbe/domain/rental/dto/response/AdminUserRentalItemResponse.java`:
- Around line 5-9: The record AdminUserRentalItemResponse currently defines a
component named RentalId which makes the generated accessor/JSON field
"RentalId"; rename the component to rentalId (camelCase) in the record
declaration to match other DTOs and ensure JSON/serialization uses "rentalId",
then update any usages/constructors/serializers that reference
AdminUserRentalItemResponse.RentalId or the positional parameter order to use
the new rentalId component name.

In `@src/main/java/ssurent/ssurentbe/domain/rental/entity/RentalHistory.java`:
- Around line 47-49: 필드 overdue가 Boolean 래퍼 타입이라 언박싱 시 NPE 위험이 있으니 RentalHistory
엔티티의 private Boolean overdue를 primitive로 변경하여 기본값 false를 보장하세요; 즉 RentalHistory의
overdue를 private boolean overdue로 바꾸고 필요하면 `@Column`(name = "is_overdue", nullable
= false)로 null 불허 제약을 추가한 뒤 Lombok/수동 getter가 isOverdue() 시그니처를 내보내는지 확인하고 DTO
매핑 코드(또는 getOverdue() 사용처)가 isOverdue()로 맞춰지도록 관련 변환/참조를 수정하세요.

In `@src/main/java/ssurent/ssurentbe/domain/rental/enums/Status.java`:
- Around line 3-6: Status enum (Status.RENT/RETURN) is declared but never used;
update the service and mapping logic to set and persist these values: in the
rental flow implement or update methods like RentalService.rentItem(...) and
RentalService.returnItem(...) to assign RentalHistory.setStatus(Status.RENT) on
checkout and RentalHistory.setStatus(Status.RETURN) on checkin, save via
RentalHistoryRepository, and ensure AdminRentalHistoryResponse mapping (e.g., a
mapper or constructor that reads RentalHistory.getStatus()) returns the new enum
value; also add tests exercising both transitions and adjust any
DTOs/serializers to handle the Status enum.

In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserPenaltyCreateRequest.java`:
- Around line 6-10: AdminUserPenaltyCreateRequest currently accepts createdAt
from clients; remove the createdAt component from the record declaration
(AdminUserPenaltyCreateRequest) so clients no longer supply it, and update any
code that constructs or maps this DTO (controllers, mappers, tests) to stop
passing createdAt and instead let the server set creation time when assembling
the domain/entity (e.g., in the service or entity factory where the penalty is
persisted, populate createdAt via LocalDateTime.now() or database default).
Ensure any mapping functions or constructors that referenced
AdminUserPenaltyCreateRequest.createdAt are updated accordingly.

In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/response/AdminUserDetailResponse.java`:
- Around line 18-28: AdminUserDetailResponse.from currently streams the
penalties list without null-check, causing NPE if penalties is null; update
AdminUserDetailResponse.from to defensively handle a null penalties parameter
(e.g., treat null as an empty list) before mapping with
UserPenaltyResponse::from so the constructor always receives a non-null list of
penalty DTOs; locate the from method in AdminUserDetailResponse and wrap or
replace the penalties usage with a safe fallback (e.g., Optional/Objects
null-check or Collections.emptyList()) prior to .stream()/mapping.

In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/response/AdminUserResponse.java`:
- Around line 5-11: The AdminUserResponse record is missing the static factory
method from() for converting a User entity to this DTO; add a public static
AdminUserResponse from(User user) method (similar to AdminAssistResponse.from)
that constructs and returns a new AdminUserResponse by mapping the entity fields
(use user.getId(), user.getUserName(), user.getStudentNum(), user.getRole() or
the actual getter names on your User class) to the record components (userId,
userName, studentNum, role).

In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/response/UserPenaltyResponse.java`:
- Around line 8-22: The record field userPenaltyId in UserPenaltyResponse is
declared as String but from(UserPenaltyLog) passes a Long
(userPenaltyLog.getId()), causing a type error; fix by converting the ID to a
String when constructing the record (e.g., call
String.valueOf(userPenaltyLog.getId()) or userPenaltyLog.getId().toString()) in
the UserPenaltyResponse.from method so the passed value matches the
userPenaltyId String type, keeping the rest of the return values (createdAt,
itemInfo, penaltyType) unchanged.
🧹 Nitpick comments (9)
src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserRoleUpdateRequest.java (1)

3-6: 요청 DTO에 입력 검증 추가 권장

userId/role이 비어 있거나 null이어도 통과합니다. 최소한 Bean Validation으로 공백/널을 막고, 가능하다면 역할은 도메인 Enum으로 제한하는 게 안전합니다.

✅ 제안 변경 (Bean Validation 적용)
 public record AdminUserRoleUpdateRequest(
-        String userId,
-        String role
+        `@jakarta.validation.constraints.NotBlank` String userId,
+        `@jakarta.validation.constraints.NotBlank` String role
 ) {
 }
src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserStatusUpdateRequest.java (1)

3-5: status 값은 가능한 Enum으로 제한하세요.

String status는 오탈자/임의 값이 그대로 통과합니다. 기존 사용자 상태 Enum이 있다면 그 타입으로 받는 편이 더 안전합니다.

♻️ 예시 변경안
-public record AdminUserStatusUpdateRequest(
-        String status
-) {
-}
+public record AdminUserStatusUpdateRequest(
+        UserStatus status
+) {
+}
.gitignore (1)

4-5: .idea/gradle 무시 규칙 정합성 정리 필요

  • .idea가 IntelliJ 섹션에 이미 있어 중복입니다. 한 곳으로 정리하는 게 깔끔합니다.
  • gradle 디렉터리를 무시한다면 gradle/wrapper/gradle-wrapper.properties도 예외 처리하지 않으면 추후 변경이 누락될 수 있습니다.
  • 또한 이번 PR에 .idea/compiler.xml 변경이 있어, .idea를 추적할지/무시할지 정책을 한쪽으로 맞추는 게 좋습니다.
♻️ 정리 제안 (한 가지 옵션)
- gradle
- .idea
+ gradle/
+ !gradle/wrapper/gradle-wrapper.properties
src/main/java/ssurent/ssurentbe/domain/item/dto/request/AdminCategoryCreateRequest.java (1)

3-6: 입력 유효성 검증 누락

categoryName 필드에 @NotBlank 또는 @NotNull 같은 Bean Validation 어노테이션이 없습니다. 빈 문자열이나 null 값으로 카테고리가 생성될 수 있습니다.

♻️ 유효성 검증 추가 제안
 package ssurent.ssurentbe.domain.item.dto.request;
 
+import jakarta.validation.constraints.NotBlank;
+
 public record AdminCategoryCreateRequest(
-        String categoryName
+        `@NotBlank`(message = "카테고리 이름은 필수입니다")
+        String categoryName
 ) {
 }
src/main/java/ssurent/ssurentbe/domain/assists/dto/request/AdminAssistCreateRequest.java (1)

3-6: 입력 유효성 검증 누락

assistName 필드에 유효성 검증 어노테이션이 없습니다. AdminCategoryCreateRequest와 동일하게 @NotBlank 추가를 권장합니다.

♻️ 유효성 검증 추가 제안
 package ssurent.ssurentbe.domain.assists.dto.request;
 
+import jakarta.validation.constraints.NotBlank;
+
 public record AdminAssistCreateRequest(
-        String assistName
+        `@NotBlank`(message = "조교 이름은 필수입니다")
+        String assistName
 ) {
 }
src/main/java/ssurent/ssurentbe/domain/item/entity/Category.java (1)

23-24: 기존 코드 오타: isDeleltedisDeleted

이번 변경 범위는 아니지만, Line 24의 isDelelted 필드명에 오타가 있습니다. Lombok이 생성하는 getter 이름도 isDelelted()가 되어 혼란을 줄 수 있으니, 이번 PR 또는 후속 작업에서 수정을 고려해 주세요.

src/main/java/ssurent/ssurentbe/domain/item/dto/request/AdminItemUpdateRequest.java (1)

3-11: status는 String 대신 Status enum 사용을 권장합니다.
타입 안정성과 유효성 검증이 강화됩니다.

♻️ 제안 수정안
+import ssurent.ssurentbe.domain.item.enums.Status;
 import java.util.List;

 public record AdminItemUpdateRequest(
         List<ItemUpdate> itemUpdates
 ) {
     public record ItemUpdate(
             Long itemId,
-            String status
+            Status status
     ){
     }
 }
src/main/java/ssurent/ssurentbe/domain/rental/dto/request/RentalExtendRequest.java (1)

5-8: 요청 DTO 입력 검증 추가 권장

rentalId 공백/누락, dueDate 누락을 초기에 차단하는 기본 검증이 없어서 컨트롤러 레벨에서 오류가 늦게 드러날 수 있습니다. Bean Validation 적용을 권장합니다.

🔧 제안 변경안
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Future;
 import java.time.LocalDateTime;

 public record RentalExtendRequest(
-        String rentalId,
-        LocalDateTime dueDate
+        `@NotBlank` String rentalId,
+        `@NotNull` `@Future` LocalDateTime dueDate
 ) {
 }
src/main/java/ssurent/ssurentbe/domain/rental/dto/response/RentalItemResponse.java (1)

14-21: DTO 매핑에서 null 방어와 중복 접근 최소화

rentalHistory 또는 itemId가 null이면 NPE가 즉시 발생합니다. DTO 매핑 진입점에서 최소한의 방어를 추가하고, 이미 가져온 Items로 ID를 재사용하는 편이 명확합니다.

♻️ 제안 변경안
 import ssurent.ssurentbe.domain.item.entity.Items;
 import ssurent.ssurentbe.domain.rental.entity.RentalHistory;

 import java.time.LocalDateTime;
+import java.util.Objects;

 public record RentalItemResponse(
         String rentalId,
         String itemId,
         String itemName,
         LocalDateTime dueDate
 ) {
     public static RentalItemResponse from(RentalHistory rentalHistory) {
-        Items items = rentalHistory.getItemId();
+        Objects.requireNonNull(rentalHistory, "rentalHistory");
+        Items items = Objects.requireNonNull(rentalHistory.getItemId(), "item");
         String itemName = items.getName() + "(" + items.getItemNum() + ")";
         return new RentalItemResponse(
                 rentalHistory.getId(),
-                rentalHistory.getItemId().getId(),
+                items.getId(),
                 itemName,
                 rentalHistory.getDueDate()
         );
     }
 }

Comment on lines 3 to 6
public enum Status {
ACTIVE,
OVERDUE,
INACTIVE
RENT,
RETURN
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify Status enum constant updates

echo "=== Checking for references to old enum constants ==="
rg -n "Status\.(ACTIVE|OVERDUE|INACTIVE)" --type java

echo ""
echo "=== Checking for references to new enum constants ==="
rg -n "Status\.(RENT|RETURN)" --type java

echo ""
echo "=== Checking for Status enum import statements ==="
rg -n "import.*Status" --type java | head -20

Repository: SSURENT/SSURENT-BE

Length of output: 2816


🏁 Script executed:

#!/bin/bash
# Check the users Status enum definition
echo "=== Users Status enum definition ==="
cat -n src/main/java/ssurent/ssurentbe/domain/users/enums/Status.java

echo ""
echo "=== RentalHistory entity to see Status usage ==="
cat -n src/main/java/ssurent/ssurentbe/domain/rental/entity/RentalHistory.java

echo ""
echo "=== AuthService.java around line 39 ==="
sed -n '35,45p' src/main/java/ssurent/ssurentbe/domain/users/service/AuthService.java

Repository: SSURENT/SSURENT-BE

Length of output: 2377


🏁 Script executed:

#!/bin/bash
# Check where rental Status is being used

echo "=== AdminRentalHistoryResponse (imports rental Status) ==="
cat -n src/main/java/ssurent/ssurentbe/domain/rental/dto/response/AdminRentalHistoryResponse.java

echo ""
echo "=== Search for RentalHistory instantiation with status field ==="
rg -n "RentalHistory.*builder\|\.status\(" --type java -A 2 -B 2 | head -50

Repository: SSURENT/SSURENT-BE

Length of output: 696


🏁 Script executed:

#!/bin/bash
# Search for status field usage in rental domain

echo "=== Search for status assignments in rental domain ==="
rg -n "\.status\|status\s*=" src/main/java/ssurent/ssurentbe/domain/rental/ --type java

echo ""
echo "=== List rental domain files ==="
find src/main/java/ssurent/ssurentbe/domain/rental -name "*.java" -type f

Repository: SSURENT/SSURENT-BE

Length of output: 966


🏁 Script executed:

#!/bin/bash
# Check if there are service classes in rental domain

echo "=== Find service/repository classes ==="
find src/main/java/ssurent/ssurentbe/domain/rental -name "*Service.java" -o -name "*Repository.java"

echo ""
echo "=== Search all files for Status.RENT or Status.RETURN ==="
rg -n "Status\.(RENT|RETURN)" --type java

Repository: SSURENT/SSURENT-BE

Length of output: 160


🏁 Script executed:

#!/bin/bash
# Check if rental service/repository might be in a different location

echo "=== Search entire codebase for Rental service/repository ==="
find src -name "*Rental*Service.java" -o -name "*Rental*Repository.java" 2>/dev/null

echo ""
echo "=== Verify the new Status enum constants are defined ==="
cat -n src/main/java/ssurent/ssurentbe/domain/rental/enums/Status.java

Repository: SSURENT/SSURENT-BE

Length of output: 314


기존 enum 상수 참조는 없으나, 새 상수의 사용처도 없어 구현 완성도 검토 필요

RENT/RETURN 상수는 정의되었으나, 코드베이스 전체에서 이들을 사용하는 부분이 없습니다. RentalHistory 엔티티의 status 필드와 AdminRentalHistoryResponse의 status 필드가 정의되어 있지만, 실제로 상태를 설정하고 관리하는 서비스 계층이 보이지 않습니다.

enum 정의 후 이를 활용한 비즈니스 로직(대여 시 RENT 설정, 반납 시 RETURN 설정 등)의 구현이 필요합니다.

🤖 Prompt for AI Agents
In `@src/main/java/ssurent/ssurentbe/domain/rental/enums/Status.java` around lines
3 - 6, Status enum (Status.RENT/RETURN) is declared but never used; update the
service and mapping logic to set and persist these values: in the rental flow
implement or update methods like RentalService.rentItem(...) and
RentalService.returnItem(...) to assign RentalHistory.setStatus(Status.RENT) on
checkout and RentalHistory.setStatus(Status.RETURN) on checkin, save via
RentalHistoryRepository, and ensure AdminRentalHistoryResponse mapping (e.g., a
mapper or constructor that reads RentalHistory.getStatus()) returns the new enum
value; also add tests exercising both transitions and adjust any
DTOs/serializers to handle the Status enum.

Comment on lines 18 to 28
public static AdminUserDetailResponse from(Users user, List<UserPenaltyLog> penalties) {
return new AdminUserDetailResponse(
user.getId(),
user.getName(),
user.getStudentNum(),
user.getRole().name(),
user.getStatus().name(),
user.getPhoneNum(),
penalties.stream()
.map(UserPenaltyResponse::from)
.toList()
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

penalties가 null이면 NPE가 발생합니다.

호출부에서 항상 빈 리스트를 보장하거나, 여기서 방어 처리를 넣어주세요.

🔧 제안 수정
     public static AdminUserDetailResponse from(Users user, List<UserPenaltyLog> penalties) {
         return new AdminUserDetailResponse(
                 user.getId(),
                 user.getName(),
                 user.getStudentNum(),
                 user.getRole().name(),
                 user.getStatus().name(),
                 user.getPhoneNum(),
-                penalties.stream()
+                (penalties == null ? List.<UserPenaltyResponse>of() : penalties).stream()
                         .map(UserPenaltyResponse::from)
                         .toList()
         );
     }
🤖 Prompt for AI Agents
In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/response/AdminUserDetailResponse.java`
around lines 18 - 28, AdminUserDetailResponse.from currently streams the
penalties list without null-check, causing NPE if penalties is null; update
AdminUserDetailResponse.from to defensively handle a null penalties parameter
(e.g., treat null as an empty list) before mapping with
UserPenaltyResponse::from so the constructor always receives a non-null list of
penalty DTOs; locate the from method in AdminUserDetailResponse and wrap or
replace the penalties usage with a safe fallback (e.g., Optional/Objects
null-check or Collections.emptyList()) prior to .stream()/mapping.

Comment on lines 5 to 11
public record AdminUserResponse(
Long userId,
String userName,
String studentNum,
Role role
) {
}
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

from() 정적 팩토리 메서드 누락

AdminAssistResponse와 마찬가지로, PR 목표에 명시된 엔티티 → 레코드 변환용 from() 메서드가 누락되었습니다.

♻️ from() 메서드 추가 제안
 package ssurent.ssurentbe.domain.users.dto.response;
 
 import ssurent.ssurentbe.domain.users.enums.Role;
+import ssurent.ssurentbe.domain.users.entity.Users;
 
 public record AdminUserResponse(
     Long userId,
     String userName,
     String studentNum,
     Role role
 ) {
+    public static AdminUserResponse from(Users user) {
+        return new AdminUserResponse(
+                user.getId(),
+                user.getUserName(),
+                user.getStudentNum(),
+                user.getRole()
+        );
+    }
 }
📝 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
public record AdminUserResponse(
Long userId,
String userName,
String studentNum,
Role role
) {
}
package ssurent.ssurentbe.domain.users.dto.response;
import ssurent.ssurentbe.domain.users.enums.Role;
import ssurent.ssurentbe.domain.users.entity.Users;
public record AdminUserResponse(
Long userId,
String userName,
String studentNum,
Role role
) {
public static AdminUserResponse from(Users user) {
return new AdminUserResponse(
user.getId(),
user.getUserName(),
user.getStudentNum(),
user.getRole()
);
}
}
🤖 Prompt for AI Agents
In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/response/AdminUserResponse.java`
around lines 5 - 11, The AdminUserResponse record is missing the static factory
method from() for converting a User entity to this DTO; add a public static
AdminUserResponse from(User user) method (similar to AdminAssistResponse.from)
that constructs and returns a new AdminUserResponse by mapping the entity fields
(use user.getId(), user.getUserName(), user.getStudentNum(), user.getRole() or
the actual getter names on your User class) to the record components (userId,
userName, studentNum, role).

Copy link
Contributor

@CromNEXT CromNEXT left a comment

Choose a reason for hiding this comment

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

굿

Id String -> Long 타입 변경
from() 메서드 추가
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@src/main/java/ssurent/ssurentbe/domain/rental/dto/response/AdminUserRentalItemResponse.java`:
- Around line 14-23: AdminUserRentalItemResponse.from currently calls
RentalHistory.getItemId() and immediately dereferences it
(Items.getName()/getItemNum()), which risks NPE; update
AdminUserRentalItemResponse.from to null-check rentalHistory.getItemId() and
produce a safe itemName (e.g., "Unknown Item" or empty values) when null,
ensuring the constructor still receives valid values; apply the same defensive
check/pattern to the similar factory in RentalItemResponse so both handle
nullable item relations safely; reference the methods/classes:
AdminUserRentalItemResponse.from, RentalHistory.getItemId, Items.getName,
Items.getItemNum, and RentalItemResponse when making the changes.

In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserPenaltyCreateRequest.java`:
- Line 4: The import of LocalDateTime in AdminUserPenaltyCreateRequest is unused
after removal of the createdAt field; remove the unused import statement (the
"import java.time.LocalDateTime;" line) from the AdminUserPenaltyCreateRequest
record to clean up the code and eliminate the unused-import warning.
🧹 Nitpick comments (4)
src/main/java/ssurent/ssurentbe/domain/rental/dto/request/RentalExtendRequest.java (1)

5-9: Bean Validation 어노테이션 추가를 권장합니다.

요청 DTO에 유효성 검증 어노테이션이 없습니다. rentalIddueDate 필드에 @NotNull을 추가하고, dueDate에는 @Future 또는 @FutureOrPresent를 추가하여 잘못된 데이터가 서비스 레이어에 도달하는 것을 방지하는 것이 좋습니다.

♻️ 유효성 검증 어노테이션 추가 제안
 package ssurent.ssurentbe.domain.rental.dto.request;
 
 import java.time.LocalDateTime;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.FutureOrPresent;
 
 public record RentalExtendRequest(
-        Long rentalId,
-        LocalDateTime dueDate
+        `@NotNull` Long rentalId,
+        `@NotNull` `@FutureOrPresent` LocalDateTime dueDate
 ) {
 }
src/main/java/ssurent/ssurentbe/domain/rental/dto/response/RentalItemResponse.java (1)

14-22: 연관 엔티티 접근을 단일화하고 NPE 방어를 고려하세요.
rentalHistory.getItemId()를 두 번 호출하기보다 items를 재사용하고, null 방어로 실패 원인을 명확히 하는 편이 안정적입니다.

🔧 제안 변경(diff)
 import ssurent.ssurentbe.domain.item.entity.Items;
 import ssurent.ssurentbe.domain.rental.entity.RentalHistory;

 import java.time.LocalDateTime;
+import java.util.Objects;

 public record RentalItemResponse(
         Long rentalId,
         Long itemId,
         String itemName,
         LocalDateTime dueDate
 ) {
     public static RentalItemResponse from(RentalHistory rentalHistory) {
-        Items items = rentalHistory.getItemId();
+        Objects.requireNonNull(rentalHistory, "rentalHistory");
+        Items items = Objects.requireNonNull(rentalHistory.getItemId(), "items");
         String itemName = items.getName() + "(" + items.getItemNum() + ")";
         return new RentalItemResponse(
                 rentalHistory.getId(),
-                rentalHistory.getItemId().getId(),
+                items.getId(),
                 itemName,
                 rentalHistory.getDueDate()
         );
     }
 }
src/main/java/ssurent/ssurentbe/domain/item/dto/response/CategoryResponse.java (1)

9-14: 선택 사항: null 입력에 대한 방어 코드 고려

from 메서드에 null category가 전달될 경우 NPE가 발생합니다. 서비스/컨트롤러 레이어에서 이미 null 체크가 이루어지고 있다면 무시해도 됩니다. 다만, 방어적 코딩 관점에서 명시적인 null 체크를 추가하는 것도 고려해 볼 수 있습니다.

🛡️ 방어 코드 추가 예시
 public static CategoryResponse from(Category category) {
+    if (category == null) {
+        throw new IllegalArgumentException("Category cannot be null");
+    }
     return new CategoryResponse(
             category.getId(),
             category.getName()
     );
 }
src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserPenaltyCreateRequest.java (1)

6-9: penaltyTypePenaltyTypes enum으로 변경하세요

PenaltyTypes enum이 이미 존재하며 UserPenaltyLog 엔티티에서 사용 중입니다. 요청 DTO에서도 String 대신 enum 타입을 사용하면 타입 안전성을 확보할 수 있고, 유효하지 않은 값이 전달되는 것을 컴파일 타임에 방지할 수 있습니다. 엔티티와 DTO 간의 타입 일관성도 개선됩니다.

import ssurent.ssurentbe.domain.users.enums.PenaltyTypes;

public record AdminUserPenaltyCreateRequest (
        String itemName,
        PenaltyTypes penaltyType
){
}

Comment on lines +14 to +23
public static AdminUserRentalItemResponse from(RentalHistory rentalHistory) {
Items items = rentalHistory.getItemId();
String itemName = items.getName() + "(" + items.getItemNum() + ")";
return new AdminUserRentalItemResponse(
rentalHistory.getId(),
rentalHistory.getRentalDate(),
rentalHistory.getReturnDate(),
itemName
);
}
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

🧩 Analysis chain

🏁 Script executed:

fd -e java "RentalHistory\.java" --exec cat -n {} \;

Repository: SSURENT/SSURENT-BE

Length of output: 1704


🏁 Script executed:

fd -e sql -e yml -e yaml | xargs grep -l "rental_history\|item_id" | head -10

Repository: SSURENT/SSURENT-BE

Length of output: 44


🏁 Script executed:

rg "RentalHistory\." --type java -A 2 | head -50

Repository: SSURENT/SSURENT-BE

Length of output: 44


🏁 Script executed:

rg "getItemId" --type java -B 2 -A 2

Repository: SSURENT/SSURENT-BE

Length of output: 1930


🏁 Script executed:

rg "from\(RentalHistory" --type java -A 5 | grep -E "(from|getItemId|getName|getItem)"

Repository: SSURENT/SSURENT-BE

Length of output: 1125


null 체크 추가 필수 - NPE 위험 확인됨

rentalHistory.getItemId()가 null을 반환할 경우 Line 17에서 NullPointerException이 발생합니다. RentalHistory 엔티티의 itemId 필드는 @ManyToOne 관계이며 nullable=false 제약이 없어 null 값이 가능합니다.

유사한 패턴이 RentalItemResponse에도 존재하므로 일괄 수정이 필요합니다:

🛡️ 방어적 null 체크 추가
     public static AdminUserRentalItemResponse from(RentalHistory rentalHistory) {
         Items items = rentalHistory.getItemId();
+        if (items == null) {
+            throw new IllegalArgumentException("RentalHistory must have an associated Item");
+        }
         String itemName = items.getName() + "(" + items.getItemNum() + ")";
         return new AdminUserRentalItemResponse(
                 rentalHistory.getId(),
                 rentalHistory.getRentalDate(),
                 rentalHistory.getReturnDate(),
                 itemName
         );
     }

부가 사항: getItemId()가 실제로 Items 엔티티를 반환하므로 메서드명이 명확하지 않습니다.

📝 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
public static AdminUserRentalItemResponse from(RentalHistory rentalHistory) {
Items items = rentalHistory.getItemId();
String itemName = items.getName() + "(" + items.getItemNum() + ")";
return new AdminUserRentalItemResponse(
rentalHistory.getId(),
rentalHistory.getRentalDate(),
rentalHistory.getReturnDate(),
itemName
);
}
public static AdminUserRentalItemResponse from(RentalHistory rentalHistory) {
Items items = rentalHistory.getItemId();
if (items == null) {
throw new IllegalArgumentException("RentalHistory must have an associated Item");
}
String itemName = items.getName() + "(" + items.getItemNum() + ")";
return new AdminUserRentalItemResponse(
rentalHistory.getId(),
rentalHistory.getRentalDate(),
rentalHistory.getReturnDate(),
itemName
);
}
🤖 Prompt for AI Agents
In
`@src/main/java/ssurent/ssurentbe/domain/rental/dto/response/AdminUserRentalItemResponse.java`
around lines 14 - 23, AdminUserRentalItemResponse.from currently calls
RentalHistory.getItemId() and immediately dereferences it
(Items.getName()/getItemNum()), which risks NPE; update
AdminUserRentalItemResponse.from to null-check rentalHistory.getItemId() and
produce a safe itemName (e.g., "Unknown Item" or empty values) when null,
ensuring the constructor still receives valid values; apply the same defensive
check/pattern to the similar factory in RentalItemResponse so both handle
nullable item relations safely; reference the methods/classes:
AdminUserRentalItemResponse.from, RentalHistory.getItemId, Items.getName,
Items.getItemNum, and RentalItemResponse when making the changes.

package ssurent.ssurentbe.domain.users.dto.request;


import java.time.LocalDateTime;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

사용하지 않는 import 제거 필요

LocalDateTime이 import되어 있지만 레코드 내에서 사용되지 않습니다. 이전 리뷰에서 createdAt 필드가 제거되면서 남은 것으로 보입니다.

🧹 수정 제안
 package ssurent.ssurentbe.domain.users.dto.request;
 
-
-import java.time.LocalDateTime;
 
 public record AdminUserPenaltyCreateRequest (
         String itemName,
         String penaltyType
 ){
 }
📝 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
import java.time.LocalDateTime;
package ssurent.ssurentbe.domain.users.dto.request;
public record AdminUserPenaltyCreateRequest (
String itemName,
String penaltyType
){
}
🤖 Prompt for AI Agents
In
`@src/main/java/ssurent/ssurentbe/domain/users/dto/request/AdminUserPenaltyCreateRequest.java`
at line 4, The import of LocalDateTime in AdminUserPenaltyCreateRequest is
unused after removal of the createdAt field; remove the unused import statement
(the "import java.time.LocalDateTime;" line) from the
AdminUserPenaltyCreateRequest record to clean up the code and eliminate the
unused-import warning.

@Todom2 Todom2 merged commit e6bfc7f into Develop Feb 5, 2026
1 check passed
@Todom2 Todom2 deleted the Add/#2 branch February 5, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature 새로운기능구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Add] : DTO 레코드 생성

3 participants