Adding configurable prefix for database table names, adding missing updated_at and is_active columns, updating db scripts
This commit is contained in:
parent
9b27d38026
commit
b6231feacd
|
@ -6,7 +6,7 @@ spring:
|
|||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
hibernate:
|
||||
naming:
|
||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
physical-strategy: gr.cite.notification.config.db.PrefixPhysicalNamingStrategy
|
||||
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
|
||||
datasource:
|
||||
url: ${DB_CONNECTION_STRING}
|
||||
|
@ -19,3 +19,6 @@ spring:
|
|||
maximum-pool-size: 5
|
||||
idle-timeout: 600000
|
||||
max-lifetime: 1800000
|
||||
|
||||
naming-strategy:
|
||||
prefix: ntf_
|
||||
|
|
|
@ -6,7 +6,7 @@ spring:
|
|||
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
hibernate:
|
||||
naming:
|
||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
physical-strategy: gr.cite.notification.config.db.PrefixPhysicalNamingStrategy
|
||||
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
|
||||
datasource:
|
||||
url: ${DB_CONNECTION_STRING}
|
||||
|
@ -19,3 +19,6 @@ spring:
|
|||
maximum-pool-size: 5
|
||||
idle-timeout: 600000
|
||||
max-lifetime: 1800000
|
||||
|
||||
naming-strategy:
|
||||
prefix: ntf_
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package gr.cite.notification.config.db;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||
|
||||
@ConfigurationProperties(prefix = "naming-strategy")
|
||||
public class NamingStrategyProperties {
|
||||
|
||||
private final String prefix;
|
||||
|
||||
@ConstructorBinding
|
||||
public NamingStrategyProperties(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package gr.cite.notification.config.db;
|
||||
|
||||
import gr.cite.notification.common.StringUtils;
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@EnableConfigurationProperties({NamingStrategyProperties.class})
|
||||
public class PrefixPhysicalNamingStrategy extends PhysicalNamingStrategyStandardImpl {
|
||||
|
||||
private final NamingStrategyProperties namingStrategyProperties;
|
||||
|
||||
public PrefixPhysicalNamingStrategy(NamingStrategyProperties namingStrategyProperties) {
|
||||
this.namingStrategyProperties = namingStrategyProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment context) {
|
||||
if (StringUtils.isNullOrEmpty(namingStrategyProperties.getPrefix()))
|
||||
return super.toPhysicalTableName(logicalName, context);
|
||||
Identifier identifier = new Identifier(namingStrategyProperties.getPrefix() + logicalName.getText(), logicalName.isQuoted());
|
||||
return super.toPhysicalTableName(identifier, context);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_InAppNotification\"")
|
||||
@Table(name = "\"InAppNotification\"")
|
||||
public class InAppNotificationEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
@ -27,12 +27,6 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _userId = "userId";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
@Column(name = "\"type\"", columnDefinition = "uuid", nullable = false)
|
||||
private UUID type;
|
||||
|
||||
|
@ -81,6 +75,12 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -97,14 +97,6 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity {
|
|||
this.userId = userId;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public UUID getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -177,4 +169,11 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity {
|
|||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_Language\"")
|
||||
@Table(name = "\"Language\"")
|
||||
public class LanguageEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_Notification\"")
|
||||
@Table(name = "\"Notification\"")
|
||||
public class NotificationEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_NotificationTemplate\"")
|
||||
@Table(name = "\"NotificationTemplate\"")
|
||||
public class NotificationTemplateEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_QueueInbox\"")
|
||||
@Table(name = "\"QueueInbox\"")
|
||||
public class QueueInboxEntity implements QueueInbox {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_QueueOutbox\"")
|
||||
@Table(name = "\"QueueOutbox\"")
|
||||
public class QueueOutboxEntity implements QueueOutbox {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_TenantConfiguration\"")
|
||||
@Table(name = "\"TenantConfiguration\"")
|
||||
public class TenantConfigurationEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_Tenant\"")
|
||||
@Table(name = "\"Tenant\"")
|
||||
public class TenantEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TenantUserEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "is_active", length = 100, nullable = false)
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package gr.cite.notification.data;
|
||||
|
||||
import gr.cite.notification.common.enums.ContactInfoType;
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.data.conventers.ContactInfoTypeConverter;
|
||||
import gr.cite.notification.data.conventers.IsActiveConverter;
|
||||
import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
|
@ -9,7 +11,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_UserContactInfo\"")
|
||||
@Table(name = "\"UserContactInfo\"")
|
||||
public class UserContactInfoEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
|
@ -44,6 +46,17 @@ public class UserContactInfoEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
@ -91,5 +104,22 @@ public class UserContactInfoEntity extends TenantScopedBaseEntity {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,33 @@
|
|||
package gr.cite.notification.data;
|
||||
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.data.conventers.IsActiveConverter;
|
||||
import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_UserCredential\"")
|
||||
@Table(name = "\"UserCredential\"")
|
||||
public class UserCredentialEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
|
||||
public static final String _id = "id";
|
||||
|
||||
@Column(name = "\"user\"", columnDefinition = "uuid", nullable = false)
|
||||
private UUID userId;
|
||||
|
||||
public static final String _userId = "userId";
|
||||
|
||||
@Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false)
|
||||
private String externalId;
|
||||
|
||||
public static final String _externalId = "externalId";
|
||||
|
||||
public static final int _externalIdLength = 512;
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
|
@ -30,6 +35,17 @@ public class UserCredentialEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -61,4 +77,21 @@ public class UserCredentialEntity extends TenantScopedBaseEntity {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_User\"")
|
||||
@Table(name = "\"User\"")
|
||||
public class UserEntity {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package gr.cite.notification.data;
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.common.enums.NotificationContactType;
|
||||
import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId;
|
||||
import gr.cite.notification.data.conventers.IsActiveConverter;
|
||||
import gr.cite.notification.data.conventers.NotificationContactTypeConverter;
|
||||
import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
|
||||
import jakarta.persistence.*;
|
||||
|
@ -10,7 +12,7 @@ import java.time.Instant;
|
|||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"ntf_UserNotificationPreference\"")
|
||||
@Table(name = "\"UserNotificationPreference\"")
|
||||
@IdClass(CompositeUserNotificationPreferenceId.class)
|
||||
public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity {
|
||||
|
||||
|
@ -43,6 +45,17 @@ public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity {
|
|||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
@ -82,4 +95,21 @@ public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,35 +1,51 @@
|
|||
package gr.cite.notification.data;
|
||||
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.data.conventers.IsActiveConverter;
|
||||
import gr.cite.notification.data.tenant.TenantScopedBaseEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"UserRole\"")
|
||||
public class UserRoleEntity extends TenantScopedBaseEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
|
||||
public static final String _id = "id";
|
||||
|
||||
@Column(name = "role", length = UserRoleEntity._roleLength, nullable = false)
|
||||
private String role;
|
||||
|
||||
public static final String _role = "role";
|
||||
|
||||
public static final int _roleLength = 512;
|
||||
|
||||
@Column(name = "\"user\"", nullable = false)
|
||||
private UUID userId;
|
||||
public static final String _userId = "userId";
|
||||
|
||||
public static final String _userId = "userId";
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
@Column(name = "updated_at", nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
@Column(name = "\"is_active\"", nullable = false)
|
||||
@Convert(converter = IsActiveConverter.class)
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -62,4 +78,20 @@ public class UserRoleEntity extends TenantScopedBaseEntity {
|
|||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import org.hibernate.annotations.ParamDef;
|
|||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -20,13 +22,14 @@ import java.util.UUID;
|
|||
@EntityListeners(TenantListener.class)
|
||||
public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String tenantFilter = "tenantFilter";
|
||||
|
||||
public static final String tenantFilterTenantParam = "tenantId";
|
||||
|
||||
@Column(name = "tenant", columnDefinition = "uuid", nullable = true)
|
||||
@Column(name = "tenant", columnDefinition = "uuid")
|
||||
private UUID tenantId;
|
||||
|
||||
public static final String _tenantId = "tenantId";
|
||||
|
@ -39,4 +42,5 @@ public abstract class TenantScopedBaseEntity implements TenantScoped, Serializab
|
|||
public void setTenantId(UUID tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package gr.cite.notification.model;
|
||||
|
||||
import gr.cite.notification.common.enums.ContactInfoType;
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
@ -8,26 +9,40 @@ import java.util.UUID;
|
|||
public class UserContactInfo {
|
||||
|
||||
private UUID id;
|
||||
|
||||
public static final String _id = "id";
|
||||
|
||||
private User user;
|
||||
|
||||
public static final String _user = "user";
|
||||
|
||||
private ContactInfoType type;
|
||||
|
||||
public static final String _type = "type";
|
||||
|
||||
private String value;
|
||||
|
||||
public static final String _value = "value";
|
||||
|
||||
private Integer ordinal;
|
||||
|
||||
public static final String _ordinal = "ordinal";
|
||||
|
||||
private Tenant tenant;
|
||||
|
||||
public static final String _tenant = "tenant";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -85,4 +100,19 @@ public class UserContactInfo {
|
|||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,36 @@
|
|||
package gr.cite.notification.model;
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserCredential {
|
||||
|
||||
private UUID id;
|
||||
|
||||
public static final String _id = "id";
|
||||
|
||||
private String externalId;
|
||||
|
||||
public static final String _externalId = "externalId";
|
||||
|
||||
private User user;
|
||||
|
||||
public static final String _user = "user";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -48,4 +62,20 @@ public class UserCredential {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package gr.cite.notification.model;
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.common.enums.NotificationContactType;
|
||||
|
||||
import java.time.Instant;
|
||||
|
@ -31,6 +32,14 @@ public class UserNotificationPreference {
|
|||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
@ -78,4 +87,21 @@ public class UserNotificationPreference {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package gr.cite.notification.model;
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.data.conventers.IsActiveConverter;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Convert;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -17,6 +22,14 @@ public class UserRole {
|
|||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
||||
private Instant updatedAt;
|
||||
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
private IsActive isActive;
|
||||
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -48,5 +61,22 @@ public class UserRole {
|
|||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Instant getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,9 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
|
|||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.isActives != null) {
|
||||
predicates.add(queryContext.Root.get(UserContactInfoEntity._isActive).in(isActives));
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
|
@ -264,6 +267,10 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
|
|||
return UserContactInfoEntity._ordinal;
|
||||
else if (item.match(UserContactInfo._createdAt))
|
||||
return UserContactInfoEntity._createdAt;
|
||||
else if (item.match(UserContactInfo._updatedAt))
|
||||
return UserContactInfoEntity._updatedAt;
|
||||
else if (item.match(UserContactInfo._isActive))
|
||||
return UserContactInfoEntity._isActive;
|
||||
else if (item.match(UserContactInfo._user, User._id))
|
||||
return UserContactInfoEntity._userId;
|
||||
else if (item.prefix(UserContactInfo._user))
|
||||
|
@ -282,6 +289,8 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
|
|||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._userId, UUID.class));
|
||||
item.setTenantId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._tenantId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._isActive, IsActive.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,34 +3,43 @@ package gr.cite.notification.query;
|
|||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.notification.authorization.AuthorizationFlags;
|
||||
import gr.cite.notification.authorization.Permission;
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.common.scope.user.UserScope;
|
||||
import gr.cite.notification.data.UserCredentialEntity;
|
||||
import gr.cite.notification.model.UserCredential;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
||||
|
||||
private Collection<UUID> ids;
|
||||
|
||||
private Collection<UUID> excludedIds;
|
||||
|
||||
private Collection<IsActive> isActives;
|
||||
|
||||
private Collection<UUID> userIds;
|
||||
|
||||
private Collection<String> externalIds;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
|
||||
private final AuthorizationService authService;
|
||||
|
||||
public UserCredentialQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
|
@ -66,6 +75,21 @@ public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery isActive(IsActive value) {
|
||||
this.isActives = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery isActive(IsActive... value) {
|
||||
this.isActives = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery isActive(Collection<IsActive> values) {
|
||||
this.isActives = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserCredentialQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
|
@ -117,11 +141,15 @@ public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
|||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.None))
|
||||
return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser))
|
||||
return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner))
|
||||
userId = this.userScope.getUserIdSafe();
|
||||
else
|
||||
userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
|
@ -144,6 +172,9 @@ public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
predicates.add(queryContext.Root.get(UserCredentialEntity._isActive).in(isActives));
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
|
@ -172,12 +203,22 @@ public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserCredential._id)) return UserCredentialEntity._id;
|
||||
else if (item.match(UserCredential._externalId)) return UserCredentialEntity._externalId;
|
||||
else if (item.prefix(UserCredential._user)) return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._user)) return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._createdAt) ) return UserCredentialEntity._createdAt;
|
||||
else return null;
|
||||
if (item.match(UserCredential._id))
|
||||
return UserCredentialEntity._id;
|
||||
else if (item.match(UserCredential._externalId))
|
||||
return UserCredentialEntity._externalId;
|
||||
else if (item.prefix(UserCredential._user))
|
||||
return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._user))
|
||||
return UserCredentialEntity._userId;
|
||||
else if (item.match(UserCredential._createdAt))
|
||||
return UserCredentialEntity._createdAt;
|
||||
else if (item.match(UserCredential._updatedAt))
|
||||
return UserCredentialEntity._updatedAt;
|
||||
else if (item.match(UserCredential._isActive))
|
||||
return UserCredentialEntity._isActive;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -187,6 +228,8 @@ public class UserCredentialQuery extends QueryBase<UserCredentialEntity> {
|
|||
item.setExternalId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._externalId, String.class));
|
||||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._userId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._createdAt, IsActive.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,34 @@
|
|||
package gr.cite.notification.query;
|
||||
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.common.enums.NotificationContactType;
|
||||
import gr.cite.notification.data.UserNotificationPreferenceEntity;
|
||||
import gr.cite.notification.model.UserNotificationPreference;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationPreferenceEntity> {
|
||||
|
||||
private List<UUID> userId;
|
||||
|
||||
private List<IsActive> isActives;
|
||||
|
||||
private List<UUID> type;
|
||||
|
||||
private List<NotificationContactType> channel;
|
||||
|
||||
public UserNotificationPreferenceQuery userId(UUID... userId) {
|
||||
|
@ -32,6 +41,16 @@ public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationP
|
|||
return this;
|
||||
}
|
||||
|
||||
public UserNotificationPreferenceQuery isActives(IsActive... isActives) {
|
||||
this.isActives = List.of(isActives);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserNotificationPreferenceQuery isActives(List<IsActive> isActives) {
|
||||
this.isActives = isActives;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserNotificationPreferenceQuery type(UUID... type) {
|
||||
this.type = List.of(type);
|
||||
return this;
|
||||
|
@ -69,6 +88,10 @@ public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationP
|
|||
predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._userId).in(this.userId));
|
||||
}
|
||||
|
||||
if (this.isActives != null) {
|
||||
predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._isActive).in(isActives));
|
||||
}
|
||||
|
||||
if (this.type != null) {
|
||||
predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._type).in(this.type));
|
||||
}
|
||||
|
@ -88,13 +111,24 @@ public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationP
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserNotificationPreference._userId)) return UserNotificationPreferenceEntity._userId;
|
||||
else if (item.match(UserNotificationPreference._tenantId)) return UserNotificationPreferenceEntity._tenantId;
|
||||
else if (item.match(UserNotificationPreference._type)) return UserNotificationPreferenceEntity._type;
|
||||
else if (item.match(UserNotificationPreference._channel)) return UserNotificationPreferenceEntity._channel;
|
||||
else if (item.match(UserNotificationPreference._ordinal)) return UserNotificationPreferenceEntity._ordinal;
|
||||
else if (item.match(UserNotificationPreference._createdAt)) return UserNotificationPreferenceEntity._createdAt;
|
||||
else return null;
|
||||
if (item.match(UserNotificationPreference._userId))
|
||||
return UserNotificationPreferenceEntity._userId;
|
||||
else if (item.match(UserNotificationPreference._tenantId))
|
||||
return UserNotificationPreferenceEntity._tenantId;
|
||||
else if (item.match(UserNotificationPreference._type))
|
||||
return UserNotificationPreferenceEntity._type;
|
||||
else if (item.match(UserNotificationPreference._channel))
|
||||
return UserNotificationPreferenceEntity._channel;
|
||||
else if (item.match(UserNotificationPreference._ordinal))
|
||||
return UserNotificationPreferenceEntity._ordinal;
|
||||
else if (item.match(UserNotificationPreference._createdAt))
|
||||
return UserNotificationPreferenceEntity._createdAt;
|
||||
else if (item.match(UserNotificationPreference._updatedAt))
|
||||
return UserNotificationPreferenceEntity._updatedAt;
|
||||
else if (item.match(UserNotificationPreference._isActive))
|
||||
return UserNotificationPreferenceEntity._isActive;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,8 +138,10 @@ public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationP
|
|||
item.setChannel(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._channel, NotificationContactType.class));
|
||||
item.setType(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._type, UUID.class));
|
||||
item.setTenantId(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._tenantId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._createdAt, Instant.class));
|
||||
item.setOrdinal(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._ordinal, Integer.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._isActive, IsActive.class));
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
package gr.cite.notification.query;
|
||||
|
||||
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.notification.authorization.AuthorizationFlags;
|
||||
import gr.cite.notification.authorization.Permission;
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
import gr.cite.notification.common.scope.user.UserScope;
|
||||
import gr.cite.notification.data.UserRoleEntity;
|
||||
import gr.cite.notification.model.UserRole;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
||||
|
||||
private Collection<UUID> ids;
|
||||
|
||||
private Collection<UUID> excludedIds;
|
||||
|
||||
private Collection<IsActive> isActives;
|
||||
|
||||
private Collection<UUID> userIds;
|
||||
|
||||
private Collection<String> roles;
|
||||
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
private final UserScope userScope;
|
||||
|
||||
private final AuthorizationService authService;
|
||||
|
||||
public UserRoleQuery(UserScope userScope, AuthorizationService authService) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
|
@ -67,6 +75,21 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery isActives(Collection<IsActive> values) {
|
||||
this.isActives = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery isActives(IsActive value) {
|
||||
this.isActives = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery isActives(IsActive... value) {
|
||||
this.isActives = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleQuery userIds(UUID value) {
|
||||
this.userIds = List.of(value);
|
||||
return this;
|
||||
|
@ -118,11 +141,15 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
|||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.None))
|
||||
return null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser))
|
||||
return null;
|
||||
UUID userId;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||
else userId = null;
|
||||
if (this.authorize.contains(AuthorizationFlags.Owner))
|
||||
userId = this.userScope.getUserIdSafe();
|
||||
else
|
||||
userId = null;
|
||||
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (userId != null) {
|
||||
|
@ -145,6 +172,9 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
predicates.add(queryContext.Root.get(UserRoleEntity._isActive).in(isActives));
|
||||
}
|
||||
if (this.userIds != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._userId));
|
||||
for (UUID item : this.userIds)
|
||||
|
@ -173,12 +203,22 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(UserRole._id)) return UserRoleEntity._id;
|
||||
else if (item.match(UserRole._role)) return UserRoleEntity._role;
|
||||
else if (item.prefix(UserRole._user)) return UserRoleEntity._userId;
|
||||
else if (item.match(UserRole._user)) return UserRoleEntity._userId;
|
||||
else if (item.match(UserRole._createdAt) ) return UserRoleEntity._createdAt;
|
||||
else return null;
|
||||
if (item.match(UserRole._id))
|
||||
return UserRoleEntity._id;
|
||||
else if (item.match(UserRole._role))
|
||||
return UserRoleEntity._role;
|
||||
else if (item.prefix(UserRole._user))
|
||||
return UserRoleEntity._userId;
|
||||
else if (item.match(UserRole._user))
|
||||
return UserRoleEntity._userId;
|
||||
else if (item.match(UserRole._createdAt))
|
||||
return UserRoleEntity._createdAt;
|
||||
else if (item.match(UserRole._updatedAt))
|
||||
return UserRoleEntity._updatedAt;
|
||||
else if (item.match(UserRole._isActive))
|
||||
return UserRoleEntity._isActive;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -188,6 +228,8 @@ public class UserRoleQuery extends QueryBase<UserRoleEntity> {
|
|||
item.setRole(QueryBase.convertSafe(tuple, columns, UserRoleEntity._role, String.class));
|
||||
item.setUserId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._userId, UUID.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._updatedAt, Instant.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserRoleEntity._isActive, IsActive.class));
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ BEGIN
|
|||
"type" uuid NOT NULL,
|
||||
"channel" smallint NOT NULL,
|
||||
"ordinal" numeric NOT NULL,
|
||||
"created_at" timestamp without time zone NOT NULL,
|
||||
"tenant" uuid,
|
||||
"created_at" timestamp without time zone NOT NULL,
|
||||
"updated_at" timestamp without time zone NOT NULL,
|
||||
"is_active" smallint NOT NULL DEFAULT 1,
|
||||
CONSTRAINT "ntf_UserNotificationPreference_pkey" PRIMARY KEY ("user", "type", "channel"),
|
||||
CONSTRAINT "ntf_UserNotificationPreference_tenant_fkey" FOREIGN KEY ("tenant")
|
||||
REFERENCES public."ntf_Tenant" (id) MATCH SIMPLE
|
||||
|
|
|
@ -12,6 +12,8 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserContactInfo"
|
|||
"type" smallint NOT NULL,
|
||||
"value" character varying(512) COLLATE pg_catalog."default" NOT NULL,
|
||||
"created_at" timestamp without time zone NOT NULL,
|
||||
"updated_at" timestamp without time zone NOT NULL,
|
||||
"is_active" smallint NOT NULL DEFAULT 1,
|
||||
"tenant" uuid,
|
||||
CONSTRAINT "ntf_UserContactInfo_pkey" PRIMARY KEY (id),
|
||||
CONSTRAINT "ntf_UserContactInfo_tenant_fkey" FOREIGN KEY ("tenant")
|
||||
|
|
|
@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserCredential"
|
|||
"user" uuid NOT NULL,
|
||||
"external_id" character varying(512) COLLATE pg_catalog."default" NOT NULL,
|
||||
"created_at" timestamp without time zone NOT NULL,
|
||||
"updated_at" timestamp without time zone NOT NULL,
|
||||
"is_active" smallint NOT NULL DEFAULT 1,
|
||||
"tenant" uuid,
|
||||
"data" character varying COLLATE pg_catalog."default",
|
||||
CONSTRAINT "ntf_UserCredential_pkey" PRIMARY KEY (id),
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
DO $$DECLARE
|
||||
this_version CONSTANT varchar := '00.01.046';
|
||||
BEGIN
|
||||
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||
IF FOUND THEN RETURN; END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."ntf_TenantUser"
|
||||
(
|
||||
"id" uuid NOT NULL,
|
||||
"user" uuid NOT NULL,
|
||||
"tenant" uuid NOT NULL,
|
||||
"is_active" smallint NOT NULL,
|
||||
"created_at" timestamp without time zone NOT NULL,
|
||||
"updated_at" timestamp without time zone NOT NULL,
|
||||
CONSTRAINT "ntf_TenantUser_pkey" PRIMARY KEY (id),
|
||||
CONSTRAINT "ntf_TenantUser_tenant_fkey" FOREIGN KEY ("tenant")
|
||||
REFERENCES public."ntf_Tenant" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION,
|
||||
CONSTRAINT "ntf_TenantUser_user_fkey" FOREIGN KEY ("user")
|
||||
REFERENCES public."ntf_User" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
)
|
||||
|
||||
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.046', '2024-01-25 12:00:00.000000+02', now(), 'Add table ntf_TenantUser.');
|
||||
|
||||
END$$;
|
Loading…
Reference in New Issue