Merge branch 'route_alternatives'
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
# Conflicts: # src/main/java/SuMoC/backend/user/models/User.java
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package SuMoC.backend.user.models;
|
||||
|
||||
import SuMoC.backend.gamification.badges.models.UserBadge;
|
||||
import SuMoC.backend.notification.models.NotificationToken;
|
||||
import SuMoC.backend.routing.models.RoutingPreferences;
|
||||
import SuMoC.backend.trip.models.Trip;
|
||||
import SuMoC.backend.user.enums.RoleName;
|
||||
import SuMoC.backend.user.enums.VisibilityPrivacy;
|
||||
import SuMoC.backend.user.stats.StatsList;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
@@ -47,19 +51,29 @@ public class User {
|
||||
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<Friendship> friendships = new HashSet<>();
|
||||
|
||||
@Setter
|
||||
@ElementCollection(targetClass = RoleName.class, fetch = FetchType.EAGER)
|
||||
@Enumerated(EnumType.STRING)
|
||||
@CollectionTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "role")
|
||||
private Set<RoleName> roles;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "id", referencedColumnName = "user_id")
|
||||
private NotificationToken notificationToken;
|
||||
|
||||
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
|
||||
private Set<UserBadge> badges = new HashSet<>();
|
||||
|
||||
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private StatsList statsList;
|
||||
|
||||
public User() {}
|
||||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "routing_preferences_id", unique = true)
|
||||
private RoutingPreferences routingPreferences;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
// public User(Long id, String publicName, String privateName, String email, String password, VisibilityPrivacy visibilityPrivacy, String friendCode, Set<Trip> trips, Set<Friendship> friendships, Set<RoleName> roles) {
|
||||
// this.id = id;
|
||||
@@ -81,6 +95,7 @@ public class User {
|
||||
this.password = password;
|
||||
this.visibilityPrivacy = VisibilityPrivacy.NONE;
|
||||
this.friendCode = java.util.UUID.randomUUID().toString(); // generate unique friend code
|
||||
this.routingPreferences = RoutingPreferences.getDefaultPreferences(); // Init with default routing preferences
|
||||
this.roles = new HashSet<>();
|
||||
this.roles.add(RoleName.USER);
|
||||
this.statsList = new StatsList(this);
|
||||
@@ -169,15 +184,35 @@ public class User {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<RoleName> roles) {
|
||||
this.roles = roles;
|
||||
public Set<UserBadge> getBadges() {
|
||||
return badges;
|
||||
}
|
||||
|
||||
public Set<UserBadge> getBadges() { return badges; }
|
||||
public void setBadges(Set<UserBadge> badges) {
|
||||
this.badges = badges;
|
||||
}
|
||||
|
||||
public void setBadges(Set<UserBadge> badges) { this.badges = badges; }
|
||||
public StatsList getStats() {
|
||||
return statsList;
|
||||
}
|
||||
|
||||
public StatsList getStats() { return statsList;}
|
||||
public void setStats(StatsList statsList) {
|
||||
this.statsList = statsList;
|
||||
}
|
||||
|
||||
public void setStats(StatsList statsList) { this.statsList = statsList; }
|
||||
public NotificationToken getNotificationToken() {
|
||||
return notificationToken;
|
||||
}
|
||||
|
||||
public void setNotificationToken(NotificationToken notificationToken) {
|
||||
this.notificationToken = notificationToken;
|
||||
}
|
||||
|
||||
public RoutingPreferences getRoutingPreferences() {
|
||||
return routingPreferences;
|
||||
}
|
||||
|
||||
public void setRoutingPreferences(RoutingPreferences routingPreferences) {
|
||||
this.routingPreferences = routingPreferences;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user