- Entity: LoginHistory, PageView, Issue, IssueComment 추가 - Repository: 각 엔티티별 JpaRepository 추가 - Service: UserService, RoleService, ActivityService, IssueService - Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트 - Activity API: 페이지뷰 기록, 로그인 이력 조회 - Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원 - Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException - AuthController: 로그인 시 LoginHistory 기록 추가 - Dockerfile 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
966 B
Java
43 lines
966 B
Java
package com.gcsc.guide.entity;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@Entity
|
|
@Table(name = "login_history")
|
|
@Getter
|
|
@NoArgsConstructor
|
|
public class LoginHistory {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "user_id")
|
|
private User user;
|
|
|
|
@Column(name = "login_at", nullable = false, updatable = false)
|
|
private LocalDateTime loginAt;
|
|
|
|
@Column(name = "ip_address", length = 45)
|
|
private String ipAddress;
|
|
|
|
@Column(name = "user_agent", length = 500)
|
|
private String userAgent;
|
|
|
|
public LoginHistory(User user, String ipAddress, String userAgent) {
|
|
this.user = user;
|
|
this.ipAddress = ipAddress;
|
|
this.userAgent = userAgent;
|
|
}
|
|
|
|
@PrePersist
|
|
protected void onCreate() {
|
|
this.loginAt = LocalDateTime.now();
|
|
}
|
|
}
|