mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-03 07:24:57 +00:00
introduced eh-cache as a caching provider instead of caffeine to be used in hibernate (only ram cache is currently possible)
added caching configuration for 2nd level caching in hibernate added command to clear hibernate caches changed some interfaces so the api looks a bit more consistent (return the created/updated value) split user management and user in server management added try catch block to message received listener execution, to make them independent moved some feature flag methods to the feature flag service bean instead of the management service, as they used the FeatureEnum directly fixed feature disable text always rendering removed some non embed logging fixed message embed template added exception logging to message embedding
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package dev.sheldan.abstracto.experience.models.database;
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents an existing level to reach and the total necessary experience needed to reach that level.
|
||||
@@ -17,6 +20,8 @@ import java.io.Serializable;
|
||||
@Table(name = "experience_level")
|
||||
@Getter
|
||||
@Setter
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AExperienceLevel implements Serializable {
|
||||
/**
|
||||
* The unique level from 0 to as defined in the configuration. Will be created on startup.
|
||||
@@ -27,4 +32,18 @@ public class AExperienceLevel implements Serializable {
|
||||
* The total amount of experience needed for this level.
|
||||
*/
|
||||
private Long experienceNeeded;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AExperienceLevel that = (AExperienceLevel) o;
|
||||
return Objects.equals(level, that.level) &&
|
||||
Objects.equals(experienceNeeded, that.experienceNeeded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(level, experienceNeeded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package dev.sheldan.abstracto.experience.models.database;
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a role which is given when the user reaches a certain level. These roles are configurable per server and
|
||||
@@ -20,6 +22,8 @@ import java.util.List;
|
||||
@Table(name = "experience_role")
|
||||
@Getter
|
||||
@Setter
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AExperienceRole implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -58,5 +62,23 @@ public class AExperienceRole implements Serializable {
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@Builder.Default
|
||||
@JoinColumn(name = "experience_role_id")
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
private List<AUserExperience> users = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AExperienceRole that = (AExperienceRole) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(level, that.level) &&
|
||||
Objects.equals(roleServer, that.roleServer) &&
|
||||
Objects.equals(role, that.role) &&
|
||||
Objects.equals(users, that.users);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, level, roleServer, role, users);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package dev.sheldan.abstracto.experience.models.database;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,6 +20,8 @@ import java.io.Serializable;
|
||||
@Table(name = "user_experience")
|
||||
@Getter
|
||||
@Setter
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class AUserExperience implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -53,4 +57,22 @@ public class AUserExperience implements Serializable {
|
||||
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
|
||||
@JoinColumn(name = "experience_role_id")
|
||||
private AExperienceRole currentExperienceRole;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AUserExperience that = (AUserExperience) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(user, that.user) &&
|
||||
Objects.equals(experience, that.experience) &&
|
||||
Objects.equals(messageCount, that.messageCount) &&
|
||||
Objects.equals(currentLevel, that.currentLevel) &&
|
||||
Objects.equals(currentExperienceRole, that.currentExperienceRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, user, experience, messageCount, currentLevel, currentExperienceRole);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user