Skip to content

Commit

Permalink
mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Dec 17, 2020
1 parent 70d9b4f commit 8dd9be8
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 1 deletion.
63 changes: 63 additions & 0 deletions src/main/java/alfio/model/Subscription.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* This file is part of alf.io.
*
* alf.io is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* alf.io is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with alf.io. If not, see <http://www.gnu.org/licenses/>.
*/
package alfio.model;

import ch.digitalfondue.npjt.ConstructorAnnotationRowMapper.Column;
import lombok.Getter;

import java.time.ZonedDateTime;
import java.util.UUID;

@Getter
public class Subscription {

private final UUID id;
private final String firstName;
private final String lastName;
private final String email;
private final String code;
private final long subscriptionDescriptorId;
private final String reservationId;
private final int usageCount;
private final int organizationId;
private final ZonedDateTime creationTime;
private final ZonedDateTime updateTime;

public Subscription(@Column("id") UUID id,
@Column("first_name") String firstName,
@Column("last_name") String lastName,
@Column("email") String email,
@Column("code") String code,
@Column("subscription_descriptor_fk") long subscriptionDescriptorId,
@Column("reservation_id_fk") String reservationId,
@Column("usage_count") int usageCount,
@Column("organization_id_fk") int organizationId,
@Column("creation_ts") ZonedDateTime creationTime,
@Column("update_ts") ZonedDateTime updateTime) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.code = code;
this.subscriptionDescriptorId = subscriptionDescriptorId;
this.reservationId = reservationId;
this.usageCount = usageCount;
this.organizationId = organizationId;
this.creationTime = creationTime;
this.updateTime = updateTime;
}
}
63 changes: 63 additions & 0 deletions src/main/java/alfio/model/SubscriptionDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* This file is part of alf.io.
*
* alf.io is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* alf.io is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with alf.io. If not, see <http://www.gnu.org/licenses/>.
*/
package alfio.model;

import ch.digitalfondue.npjt.ConstructorAnnotationRowMapper.Column;
import lombok.Getter;

import java.time.ZonedDateTime;

@Getter
public class SubscriptionDescriptor {

public enum SubscriptionAvailability {
ONCE_PER_EVENT, UNLIMITED
}

private final long id;
private final int maxEntries;
private final ZonedDateTime creation;
private final ZonedDateTime validFrom;
private final ZonedDateTime validTo;
private final int price;
private final String currency;
private final SubscriptionAvailability availability;
private final boolean isPublic;
private final int organizationId;

public SubscriptionDescriptor(@Column("id") long id,
@Column("max_entries") int maxEntries,
@Column("creation_ts") ZonedDateTime creation,
@Column("valid_from") ZonedDateTime validFrom,
@Column("valid_to") ZonedDateTime validTo,
@Column("price_cts") int price,
@Column("currency") String currency,
@Column("availability") SubscriptionAvailability availability,
@Column("is_public") boolean isPublic,
@Column("organization_id_fk") int organizationId) {
this.id = id;
this.maxEntries = maxEntries;
this.creation = creation;
this.validFrom = validFrom;
this.validTo = validTo;
this.price = price;
this.currency = currency;
this.availability = availability;
this.isPublic = isPublic;
this.organizationId = organizationId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ create table subscription (
subscription_descriptor_fk bigint not null constraint subscription_subscription_descriptor_fk references subscription_descriptor(id),
reservation_id_fk character(36) not null constraint subscription_reservation_id_fk references tickets_reservation(id),
usage_count integer not null,
organization_id_fk int not null constraint subscription_organization_id_fk references organization(id)
organization_id_fk int not null constraint subscription_organization_id_fk references organization(id),
creation_ts timestamp with time zone not null default now(),
update_ts timestamp with time zone
);

alter table subscription enable row level security;
Expand Down

0 comments on commit 8dd9be8

Please sign in to comment.