mirror of
https://github.com/cna-bootcamp/phonebill.git
synced 2026-06-12 19:49:10 +00:00
kos-mock 상품변경 실제 DB 업데이트 기능 추가
- MockDataService에 updateCustomerProduct 메서드 추가 - KosMockService에 실제 고객 데이터 업데이트 로직 추가 - 상품변경 시 고객의 current_product_code를 실제로 업데이트하도록 수정 - 트랜잭션 처리로 데이터 일관성 보장 - product-service Hibernate dialect 설정 추가 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,8 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
String userId = jwtTokenProvider.getUserId(token);
|
||||
String username = null;
|
||||
String authority = null;
|
||||
String customerId = null;
|
||||
String lineNumber = null;
|
||||
|
||||
try {
|
||||
username = jwtTokenProvider.getUsername(token);
|
||||
@@ -50,12 +52,26 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
log.debug("JWT에 authority 클레임이 없음: {}", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
customerId = jwtTokenProvider.getCustomerId(token);
|
||||
} catch (Exception e) {
|
||||
log.debug("JWT에 customerId 클레임이 없음: {}", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
lineNumber = jwtTokenProvider.getLineNumber(token);
|
||||
} catch (Exception e) {
|
||||
log.debug("JWT에 lineNumber 클레임이 없음: {}", e.getMessage());
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(userId)) {
|
||||
// UserPrincipal 객체 생성 (username과 authority가 없어도 동작)
|
||||
UserPrincipal userPrincipal = UserPrincipal.builder()
|
||||
.userId(userId)
|
||||
.username(username != null ? username : "unknown")
|
||||
.authority(authority != null ? authority : "USER")
|
||||
.customerId(customerId)
|
||||
.lineNumber(lineNumber)
|
||||
.build();
|
||||
|
||||
UsernamePasswordAuthenticationToken authentication =
|
||||
|
||||
@@ -28,8 +28,8 @@ public class JwtTokenProvider {
|
||||
private final SecretKey secretKey;
|
||||
private final long tokenValidityInMilliseconds;
|
||||
|
||||
public JwtTokenProvider(@Value("${security.jwt.secret:}") String secret,
|
||||
@Value("${security.jwt.access-token-expiration:3600}") long tokenValidityInSeconds) {
|
||||
public JwtTokenProvider(@Value("${jwt.secret:}") String secret,
|
||||
@Value("${jwt.access-token-validity:3600}") long tokenValidityInSeconds) {
|
||||
if (StringUtils.hasText(secret)) {
|
||||
this.secretKey = Keys.hmacShaKeyFor(secret.getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
@@ -112,6 +112,32 @@ public class JwtTokenProvider {
|
||||
return claims.get("authority", String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* JWT 토큰에서 고객 ID 추출
|
||||
*/
|
||||
public String getCustomerId(String token) {
|
||||
Claims claims = Jwts.parser()
|
||||
.verifyWith(secretKey)
|
||||
.build()
|
||||
.parseSignedClaims(token)
|
||||
.getPayload();
|
||||
|
||||
return claims.get("customerId", String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* JWT 토큰에서 회선번호 추출
|
||||
*/
|
||||
public String getLineNumber(String token) {
|
||||
Claims claims = Jwts.parser()
|
||||
.verifyWith(secretKey)
|
||||
.build()
|
||||
.parseSignedClaims(token)
|
||||
.getPayload();
|
||||
|
||||
return claims.get("lineNumber", String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 토큰 만료 시간 확인
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,16 @@ public class UserPrincipal {
|
||||
*/
|
||||
private final String authority;
|
||||
|
||||
/**
|
||||
* 고객 ID
|
||||
*/
|
||||
private final String customerId;
|
||||
|
||||
/**
|
||||
* 회선번호
|
||||
*/
|
||||
private final String lineNumber;
|
||||
|
||||
/**
|
||||
* 사용자 ID 반환 (별칭)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user