Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/fisa/pg/dto/response/ApiKeyResponseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class ApiKeyResponseDto {
*/
private LocalDateTime lastUsed;


public static ApiKeyResponseDto from(ApiKey apiKey) {
return ApiKeyResponseDto.builder()
.id(apiKey.getId())
Expand All @@ -69,6 +70,7 @@ public static ApiKeyResponseDto from(ApiKey apiKey) {
.isActive(apiKey.isActive())
.issuedAt(apiKey.getIssuedAt())
.expiresAt(apiKey.getExpiresAt())
.lastUsed(apiKey.getLastUsed())
.build();
}

Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/fisa/pg/entity/auth/ApiKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,24 @@ public class ApiKey {
@Column(name = "is_active", nullable = false)
private boolean isActive;

/**
* 마지막 사용 시각
*/
@Column(name = "last_used", nullable = true)
private LocalDateTime lastUsed;

/**
* API 키 비활성화 메서드
*/

public void deactivate() {
this.isActive = false;
}


}
/**
* API 키 사용 시각 업데이트 메서드
*/
public void updateLastUsed() {
this.lastUsed = LocalDateTime.now();
}
}
Loading