gc-guide-api/src/main/java/com/gcsc/guide/entity/Role.java
htlee ef667db990 feat(auth): JWT 기반 Google 로그인 인증 API 구현
- Entity: User, Role, RoleUrlPattern, UserStatus enum
- Repository: UserRepository, RoleRepository (fetch join 쿼리)
- Auth: GoogleTokenVerifier, JwtTokenProvider, JwtAuthenticationFilter
- API: POST /api/auth/google, GET /api/auth/me, POST /api/auth/logout
- DTO: AuthResponse, UserResponse, RoleResponse, GoogleLoginRequest
- SecurityConfig: JWT 필터 등록, CORS 설정, 공개 엔드포인트 정의
- 초기 데이터: roles + role_url_patterns 시드 (data.sql)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:28:51 +09:00

48 lines
1.1 KiB
Java

package com.gcsc.guide.entity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "roles")
@Getter
@NoArgsConstructor
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, unique = true, length = 50)
private String name;
@Column(length = 255)
private String description;
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private List<RoleUrlPattern> urlPatterns = new ArrayList<>();
public Role(String name, String description) {
this.name = name;
this.description = description;
}
public void update(String name, String description) {
this.name = name;
this.description = description;
}
@PrePersist
protected void onCreate() {
this.createdAt = LocalDateTime.now();
}
}