Skip to content

feat: 사용량 조회 API (#76) - #77

Open
ji2081 wants to merge 1 commit into
developfrom
feat/76-user-usage
Open

ji2081 wants to merge 1 commit into
developfrom
feat/76-user-usage

Conversation

@ji2081

@ji2081 ji2081 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

작업 내용

  • GET /api/v1/users/me/usage (명세 6번)
  • 보유 템플릿 수와 AI 톤 교정 오늘 사용량 조회
  • template·ai 서비스를 조합하므로 UserUsageQueryService로 분리 (순환 참조 방지)

명세와 달라진 점

  • 명세 6번 에러 표에 USER404_1 추가. #61에서 getTodayUsage의 회원 확인을 빼면서 조합 서비스에서 하기로 한 내용입니다.

테스트

전체 ./gradlew build 통과

  • 사용 기록 없음, 응답 필드, 리셋 시각 +09:00, 캐시 금지
  • 템플릿 한도 경계 49개·50개
  • 휴지통과 다른 회원의 템플릿 제외
  • AI 5회 사용, 어제와 다른 회원의 사용량 제외
  • 탈퇴·없는 회원 USER404_1, 토큰 없음 COMMON401_1

확인 체크리스트

  • ./gradlew build 통과
  • 테스트 포함
  • 변경 400줄 안팎 (운영 136, 테스트 182, 문서 3)
  • 병합된 마이그레이션 수정 안 함
  • 비밀 값·개인정보 없음
  • global 공통 코드 수정 없음

리뷰어에게

  • #75와 UserController, UserSuccessCode가 겹칩니다. 나중에 병합하는 쪽에서 양쪽을 합칠 예정입니다.

@ji2081 ji2081 self-assigned this Nov 5, 2026
@ji2081 ji2081 added feature 기능 개발 user 내 정보·사용량·플랜 판정 labels Nov 5, 2026

@chjpooh2002 chjpooh2002 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.

리뷰 남긴 사항 참고부탁드립니다!

Comment on lines +12 to +13
new TemplateUsage(templateCount, templateLimit, Math.max(templateLimit - templateCount, 0),
templateCount >= templateLimit),

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.

한도 도달 판단(templateCount >= templateLimit)이TemplateCommandService.validateTemplateLimit과 따로 있어요. 나중에 기준이 바뀌면 화면 표시와 실제 차단이 어긋날 수 있으니, 판단을 한 곳(예: UsageLimits나 template 쪽)에 두는 걸 고려하면 좋을 거 같습니다!

new AiToneUsage(aiTone.usedCount(), aiTone.limit(), aiTone.remaining(), aiTone.resetAt()));
}

public record TemplateUsage(long count, int limit, long remaining, @JsonProperty("isFull") boolean isFull) {

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.

(사소) count, remaining이 long인데 명세 타입은 Integer예요. #68에서 totalCount를 명세에 맞춰 int로 둔 것과 맞추면 좋을 것 같습니다!


/** 없거나 탈퇴한 회원이면 USER404_1. */
public UserUsageResult getUsage(Long userId) {
if (userRepository.findByIdAndDeletedAtIsNull(userId).isEmpty()) {

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.

존재 확인만 하는데 회원 엔티티 전체를 읽고 있어요. #73 의 getNickname, #75 의 getDetail에도 같은 "탈퇴하지 않은 회원 확인 → USER404_1" 코드가 있으니, 병합할 때 하나로 모으면 좋겠습니다!

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

Labels

feature 기능 개발 user 내 정보·사용량·플랜 판정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 사용량 조회 API

2 participants