Skip to content

Commit

Permalink
fix: files and entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Oct 10, 2024
1 parent cb52804 commit 92e2bff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/chat/yourway/model/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Contact implements UserDetails {
@Column(nullable = false, unique = true)
private String email;

@Column(nullable = false, length = 2048)
@Column(nullable = false)
private String password;

@Column(nullable = false)
Expand Down Expand Up @@ -64,8 +64,8 @@ public class Contact implements UserDetails {
private List<Message> unreadMessages;

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return List.of(new SimpleGrantedAuthority(role.name()));
public Collection<Role> getAuthorities() {
return List.of(Role.valueOf(role.name()));
}

@Override
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/chat/yourway/model/Role.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.chat.yourway.model;

public enum Role {
USER,
ADMIN
}
import org.springframework.security.core.GrantedAuthority;

public enum Role implements GrantedAuthority {
USER, ADMIN;

@Override
public String getAuthority() {
return name();
}
}
7 changes: 3 additions & 4 deletions src/main/java/com/chat/yourway/model/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,26 @@ public class Topic {
@Enumerated(EnumType.STRING)
private TopicScope scope;

@Column(nullable = false)
@CreationTimestamp
private LocalDateTime createdAt;

@ManyToMany
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
schema = "chat",
name = "topic_tags",
joinColumns = @JoinColumn(name = "topic_id"),
inverseJoinColumns = @JoinColumn(name = "tag_id"))
private Set<Tag> tags;

@ManyToMany
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
schema = "chat",
name = "topic_contacts",
joinColumns = @JoinColumn(name = "topic_id"),
inverseJoinColumns = @JoinColumn(name = "contact_id"))
private List<Contact> topicSubscribers = new ArrayList<>();

@ManyToMany
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
schema = "chat",
name = "topic_complaints",
Expand Down

0 comments on commit 92e2bff

Please sign in to comment.