mirror of
https://github.com/cna-bootcamp/phonebill.git
synced 2025-12-06 16:16:23 +00:00
Entity 클래스 및 서비스 로직 개선
- kos-mock Entity 클래스 개선 (BillEntity, CustomerEntity, ProductEntity) - user-service Entity 클래스 개선 (AuthUserEntity, AuthUserPermissionEntity) - UserService 로직 개선 - kos-mock 데이터베이스 업데이트 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
77fd4a56a5
commit
21b9c77109
Binary file not shown.
@ -62,9 +62,10 @@ public class BillEntity {
|
||||
private String dueDate;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
@Builder.Default
|
||||
private LocalDateTime createdAt = LocalDateTime.now();
|
||||
|
||||
// 고객 정보와의 관계
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "line_number", insertable = false, updatable = false)
|
||||
|
||||
@ -41,12 +41,14 @@ public class CustomerEntity {
|
||||
private LocalDateTime contractDate;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
@Builder.Default
|
||||
private LocalDateTime createdAt = LocalDateTime.now();
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private LocalDateTime updatedAt;
|
||||
@Builder.Default
|
||||
private LocalDateTime updatedAt = LocalDateTime.now();
|
||||
|
||||
// 상품 엔티티와의 관계 설정 (조회 성능을 위해)
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
||||
@ -54,10 +54,12 @@ public class ProductEntity {
|
||||
private String description;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
@Builder.Default
|
||||
private LocalDateTime createdAt = LocalDateTime.now();
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private LocalDateTime updatedAt;
|
||||
@Builder.Default
|
||||
private LocalDateTime updatedAt = LocalDateTime.now();
|
||||
}
|
||||
@ -21,9 +21,12 @@ public class AuthUserEntity extends BaseTimeEntity {
|
||||
@Column(name = "user_id", length = 50)
|
||||
private String userId;
|
||||
|
||||
@Column(name = "password", nullable = false, length = 255)
|
||||
private String password;
|
||||
|
||||
@Column(name = "password_hash", nullable = false, length = 255)
|
||||
private String passwordHash;
|
||||
|
||||
|
||||
@Column(name = "password_salt", nullable = false, length = 100)
|
||||
private String passwordSalt;
|
||||
|
||||
@ -35,7 +38,15 @@ public class AuthUserEntity extends BaseTimeEntity {
|
||||
|
||||
@Column(name = "user_name", length = 100)
|
||||
private String userName;
|
||||
|
||||
|
||||
@Column(name = "enabled", nullable = false)
|
||||
@Builder.Default
|
||||
private Boolean enabled = true;
|
||||
|
||||
@Column(name = "locked", nullable = false)
|
||||
@Builder.Default
|
||||
private Boolean locked = false;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "account_status", length = 20)
|
||||
@Builder.Default
|
||||
|
||||
@ -19,17 +19,23 @@ public class AuthUserPermissionEntity extends BaseTimeEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "user_permission_id")
|
||||
private Long userPermissionId;
|
||||
|
||||
|
||||
@Column(name = "user_id", nullable = false, length = 50)
|
||||
private String userId;
|
||||
|
||||
@Column(name = "permission_id", nullable = false)
|
||||
|
||||
@Column(name = "permission_id")
|
||||
private Long permissionId;
|
||||
|
||||
|
||||
@Column(name = "permission_name", nullable = false, length = 50)
|
||||
private String permissionName;
|
||||
|
||||
@Column(name = "description", length = 200)
|
||||
private String description;
|
||||
|
||||
@Column(name = "granted")
|
||||
@Builder.Default
|
||||
private Boolean granted = true;
|
||||
|
||||
|
||||
@Column(name = "granted_by", length = 50)
|
||||
private String grantedBy;
|
||||
|
||||
|
||||
@ -118,10 +118,12 @@ public class UserService {
|
||||
AuthUserPermissionEntity userPermission = AuthUserPermissionEntity.builder()
|
||||
.userId(userId)
|
||||
.permissionId(permission.getPermissionId())
|
||||
.permissionName(permission.getPermissionCode())
|
||||
.description(permission.getPermissionDescription())
|
||||
.granted(true)
|
||||
.grantedBy(grantedBy)
|
||||
.build();
|
||||
|
||||
|
||||
authUserPermissionRepository.save(userPermission);
|
||||
}
|
||||
|
||||
@ -261,8 +263,11 @@ public class UserService {
|
||||
.customerId(request.getCustomerId())
|
||||
.lineNumber(request.getLineNumber())
|
||||
.userName(request.getUserName())
|
||||
.password(hashedPassword)
|
||||
.passwordHash(hashedPassword)
|
||||
.passwordSalt(salt)
|
||||
.enabled(existingUser.getEnabled())
|
||||
.locked(existingUser.getLocked())
|
||||
.accountStatus(existingUser.getAccountStatus())
|
||||
.failedLoginCount(existingUser.getFailedLoginCount())
|
||||
.lastFailedLoginAt(existingUser.getLastFailedLoginAt())
|
||||
@ -331,8 +336,11 @@ public class UserService {
|
||||
.customerId(request.getCustomerId())
|
||||
.lineNumber(request.getLineNumber())
|
||||
.userName(request.getUserName())
|
||||
.password(hashedPassword)
|
||||
.passwordHash(hashedPassword)
|
||||
.passwordSalt(salt)
|
||||
.enabled(true)
|
||||
.locked(false)
|
||||
.accountStatus(AuthUserEntity.AccountStatus.ACTIVE)
|
||||
.failedLoginCount(0)
|
||||
.build();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user