Skip to content

feat: 초반 flow 책 추가 후 개구리 보상 지급 API 구현#11

Merged
lilloo04 merged 2 commits intodevfrom
feat/#10
Jul 15, 2025
Merged

feat: 초반 flow 책 추가 후 개구리 보상 지급 API 구현#11
lilloo04 merged 2 commits intodevfrom
feat/#10

Conversation

@lilloo04
Copy link
Copy Markdown
Member

@lilloo04 lilloo04 commented Jul 8, 2025

관련 이슈

내용

  • 유저가 첫 책 등록 시 개구리 한 마리 선택 지급,
  • 두 번째 책 등록 시 나머지 미지급 개구리 일괄 지급하는 로직 (두 마리)

상세 내용

  • 지급 가능한 개구리 아이템 키 목록 정의 (fro, rogy, roro)
  • 유저가 이미 보유 중인 개구리 아이템 조회
  • 조건에 따라 지급 대상 결정:
    • 책 1권 등록: 요청에서 전달된 key가 미보유 상태일 경우에만 해당 개구리 지급
    • 책 2권 이상 등록: 나머지 미보유 개구리 전체 지급
    • 지급 대상이 없으면 early return
  • 지급할 아이템이 있을 경우 트랜잭션으로 OwnedItem 테이블에 insert

@lilloo04 lilloo04 requested a review from wooodypark July 8, 2025 04:52
@lilloo04 lilloo04 self-assigned this Jul 8, 2025
/**
* 초기 유저의 책 등록 수에 따라 개구리 부여
* @param {import('@frolog/frolog-api').GrantInitialStoreItemReq} reqDto 요청 DTO.
* @returns {Promise<import('@frolog/frolog-api').GrantInitialStoreItemRes>} 응답 DTO.
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.

이 api는 로그인한 유저가 요청하는 거니까 여기 param에 user도 있는게 좋을 것 같습니다.
그리고 밑에서 reqDto.id랑 user 인수의 id랑 비교하는 인가 체크도 있어야 할 것 같아요!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

넵 꼼꼼하게 리뷰 봐주셔서 감사합니다!

export default async function grantInitialStoreItem(reqDto) {
const userId = decodeHashId(reqDto.id);
const count = reqDto.count;

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에서 말한 인가 체크와 count가 1 미만일때에 대한 validation 적용해놓으면 완벽할 것 같슴다

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

반영했습니다!

@lilloo04 lilloo04 merged commit 60f0c98 into dev Jul 15, 2025
1 check passed
@lilloo04 lilloo04 mentioned this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants