Skip to content

Commit

Permalink
Багфикс юзера
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Ungurean committed Mar 3, 2025
1 parent 3027698 commit cf9879c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/club/ttg/dnd5/domain/user/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.SourceType;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.annotations.UuidGenerator;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
Expand All @@ -18,7 +22,7 @@
@Setter
@Entity
@Table(name = "users")
public class User extends Timestamped implements UserDetails {
public class User implements UserDetails {
@Id
@UuidGenerator
@GeneratedValue(strategy = GenerationType.UUID)
Expand All @@ -42,6 +46,13 @@ public class User extends Timestamped implements UserDetails {
@ManyToMany(mappedBy = "userList", fetch = FetchType.LAZY)
private List<UserParty> userParties;

@Column(name = "created_at", updatable = false)
@CreationTimestamp(source = SourceType.DB)
private Instant createdAt;
@Column(name = "updated_at")
@UpdateTimestamp(source = SourceType.DB)
private Instant updatedAt;

@Override
public Collection<GrantedAuthority> getAuthorities() {
String[] userRoles = this.getRoles().stream()
Expand All @@ -50,4 +61,5 @@ public Collection<GrantedAuthority> getAuthorities() {

return AuthorityUtils.createAuthorityList(userRoles);
}

}

0 comments on commit cf9879c

Please sign in to comment.