feat: 가입하면 신용관리 데모 데이터가 자동으로 붙는다 - #141
Merged
Merged
Conversation
신용관리 화면 여섯 조각 중 카드·대출은 마이데이터 연동이 채우지만 (MockMydataProvisioner가 복제한 목데이터를 동기화가 옮겨온다), 신용점수 이력과 비금융 납부 이력은 어디서도 만들어지지 않아 신규 가입자에게는 빈 화면이 떴다. data.sql이 데모 계정 것만 넣고 그 두 테이블에 쓰는 코드가 없었다. CreditDemoProvisioner를 두고 가입(AuthService.signup)과 마이데이터 연동(MydataConnectService.connect) 양쪽에서 부른다. 연동을 건너뛴 회원도 화면을 볼 수 있어야 해서 가입에 걸고, 연동 쪽은 그 전에 가입한 회원과 시드 계정을 메우는 보정으로 남긴다. MockMydataProvisioner와 같이 코드에 점수·금액을 다시 적지 않고 데모 계정(user1@test.com)의 DB 행을 복제한다. 하드코딩하면 시드와 두 벌이 되어 한쪽만 고쳤을 때 조용히 어긋난다. 네이티브 insert...select를 쓰는 이유는 credit_score.updated_at이 @UpdateTimestamp라 엔티티로 저장하면 Hibernate가 '지금'으로 덮어쓰기 때문이다. 화면은 이 값을 각 기록의 월 표시로 쓰므로 여섯 건이 전부 같은 달로 뜬다. 이미 있는 NonFinancialPaymentService.sync는 쓰지 않았다. 그쪽은 '오늘' 기준 12개월치를 생성해서 시드가 맞춰 둔 6개월·연체 위치와 어긋난다. 시드 그대로여야 해서 생성이 아니라 복제여야 한다. 멱등성: 납부 이력은 insert ignore + 유일 제약이, 신용점수는 유일 제약이 없어 existsByUserUserId 검사가 막는다. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S9r6EsJn3MZ3uUL1PuuA9g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
신용관리 화면 여섯 조각 중 신용점수 이력과 비금융 납부 이력(통신요금·건강보험료·국민연금)이
신규 가입자에게는 빈 채로 떴다.
data.sql이 데모 계정(user1@test.com) 것만 넣고,그 두 테이블에 쓰는 코드가 어디에도 없었기 때문이다.
(카드·대출은 이미
MockMydataProvisioner가 복제한 목데이터를 동기화가 옮겨와 채우고 있었다.)CreditDemoProvisioner를 새로 두고 가입(AuthService.signup)과마이데이터 연동(
MydataConnectService.connect) 양쪽에서 부른다.연동을 건너뛴(skip) 회원도 화면을 볼 수 있어야 해서 가입에 걸고,
연동 쪽은 그 전에 가입한 회원과 시드 계정을 메우는 보정으로 남겼다.
MockMydataProvisioner와 같이 코드에 점수·금액을 다시 적지 않고 데모 계정의 DB 행을 복제한다.데모 데이터를 바꾸려면
data.sql한 곳만 고치면 된다.결정 두 가지
네이티브
insert ... select를 썼다.credit_score.updated_at이@UpdateTimestamp라엔티티로 저장하면 Hibernate가 무조건 '지금'으로 덮어쓴다. 그런데 화면은 이 값을 각 기록의
월 표시로 쓰므로(
CreditHomeView.vue:105) 여섯 건이 전부 같은 달로 뜬다.원본 시각을 옮기려면 엔티티 생명주기를 우회하는 수밖에 없다 —
PocketRepository.insertIfAbsent에 같은 선례가 있다.이미 있는
NonFinancialPaymentService.sync는 쓰지 않았다. 그쪽은 '오늘' 기준 12개월치를생성해서, 시드가 손으로 맞춰 둔 6개월·연체 위치(2026-03 통신요금)와 어긋난다.
"시드 그대로"여야 해서 생성이 아니라 복제여야 했다.
멱등성 — 가입 때 한 번, 연동 때 한 번 불리므로 두 배가 되면 안 된다.
납부 이력은
insert ignore+uk_nonfinancial_payment_user_type_month가 막고,신용점수는 유일 제약이 없어
existsByUserUserId검사가 막는다.확인한 것
./gradlew build통과 (새 테스트 6개:CreditDemoProvisionerTest4 +AuthServiceTest2)가입 직후(연동 전):
연동 후:
연동을 두 번 눌러도 DB 행수는 신용점수 6 / 납부이력 18 그대로였고, 원본 계정도 오염되지 않았다.
리뷰어에게
CreditDemoProvisioner클래스 주석과 호출부 두 곳에⚠️표시를 남겨 뒀으니, 실제 신용평가사·기관이 붙으면 그것만 지우면 된다.AuthService(auth) →CreditDemoProvisioner(credit) 의존이 새로 생긴다.MydataConnectService가mockmydata·pocket을 부르는 것과 같은 결이라 그대로 뒀는데,가입 흐름에 시연용 코드가 들어오는 게 걸리면 말해달라.
사용자가 동의 버튼을 누르기 전에 서버가
mydata_connected=true를 기록하게 되어연동 동의 화면이 무의미해진다. 의도적으로 안 했다.
🤖 Generated with Claude Code
https://claude.ai/code/session_01S9r6EsJn3MZ3uUL1PuuA9g