189 lines
5.2 KiB
C++
189 lines
5.2 KiB
C++
#ifndef DATABASE_INTERFACE_H
|
|
#define DATABASE_INTERFACE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// Data structures representing the entities
|
|
|
|
struct Genre {
|
|
int genre_id;
|
|
std::string genre_name;
|
|
|
|
Genre() = default;
|
|
Genre(int id, const std::string &name) : genre_id(id), genre_name(name) {}
|
|
};
|
|
|
|
struct Movie {
|
|
int movie_id;
|
|
std::string title;
|
|
int genre_id;
|
|
int duration; // Duration in minutes
|
|
|
|
Movie() = default;
|
|
Movie(int id, const std::string &title, int genre_id, int duration)
|
|
: movie_id(id), title(title), genre_id(genre_id), duration(duration) {}
|
|
};
|
|
|
|
struct Hall {
|
|
int hall_id;
|
|
std::string hall_name;
|
|
int capacity;
|
|
|
|
Hall() = default;
|
|
Hall(int id, const std::string &name, int capacity)
|
|
: hall_id(id), hall_name(name), capacity(capacity) {}
|
|
};
|
|
|
|
struct Session {
|
|
int session_id;
|
|
int movie_id;
|
|
int hall_id;
|
|
std::string begin_at; // Use appropriate date-time type if needed
|
|
double ticket_price;
|
|
|
|
Session() = default;
|
|
Session(int id, int movie_id, int hall_id, const std::string &begin_at,
|
|
double price)
|
|
: session_id(id), movie_id(movie_id), hall_id(hall_id),
|
|
begin_at(begin_at), ticket_price(price) {}
|
|
};
|
|
|
|
struct Ticket {
|
|
int ticket_id;
|
|
int session_id;
|
|
int seat_number;
|
|
std::string sold_at; // Use appropriate date-time type if needed
|
|
|
|
Ticket() = default;
|
|
Ticket(int id, int session_id, int seat_number, const std::string &time)
|
|
: ticket_id(id), session_id(session_id), seat_number(seat_number),
|
|
sold_at(time) {}
|
|
};
|
|
|
|
struct Refund {
|
|
int refund_id;
|
|
int ticket_id;
|
|
std::string refund_at; // Use appropriate date-time type if needed
|
|
double refund_amount;
|
|
|
|
Refund() = default;
|
|
Refund(int id, int ticket_id, const std::string &time, double amount)
|
|
: refund_id(id), ticket_id(ticket_id), refund_at(time),
|
|
refund_amount(amount) {}
|
|
};
|
|
|
|
// Structures for adding new records (without IDs)
|
|
|
|
struct NewGenre {
|
|
std::string genre_name;
|
|
|
|
NewGenre() = default;
|
|
NewGenre(const std::string &name) : genre_name(name) {}
|
|
};
|
|
|
|
struct NewMovie {
|
|
std::string title;
|
|
int genre_id;
|
|
int duration; // Duration in minutes
|
|
|
|
NewMovie() = default;
|
|
NewMovie(const std::string &title, int genre_id, int duration)
|
|
: title(title), genre_id(genre_id), duration(duration) {}
|
|
};
|
|
|
|
struct NewHall {
|
|
std::string hall_name;
|
|
int capacity;
|
|
|
|
NewHall() = default;
|
|
NewHall(const std::string &name, int capacity)
|
|
: hall_name(name), capacity(capacity) {}
|
|
};
|
|
|
|
struct NewSession {
|
|
int movie_id;
|
|
int hall_id;
|
|
std::string begin_at; // Use appropriate date-time type if needed
|
|
double ticket_price;
|
|
|
|
NewSession() = default;
|
|
NewSession(int movie_id, int hall_id, const std::string &begin_at,
|
|
double price)
|
|
: movie_id(movie_id), hall_id(hall_id), begin_at(begin_at),
|
|
ticket_price(price) {}
|
|
};
|
|
|
|
struct NewTicket {
|
|
int session_id;
|
|
int seat_number;
|
|
std::string sold_at; // Optional, can default to CURRENT_TIMESTAMP
|
|
|
|
NewTicket() = default;
|
|
NewTicket(int session_id, int seat_number, const std::string &time)
|
|
: session_id(session_id), seat_number(seat_number), sold_at(time) {}
|
|
};
|
|
|
|
struct NewRefund {
|
|
int ticket_id;
|
|
std::string refund_at; // Optional, can default to CURRENT_TIMESTAMP
|
|
double refund_amount;
|
|
|
|
NewRefund() = default;
|
|
NewRefund(int ticket_id, const std::string &time, double amount)
|
|
: ticket_id(ticket_id), refund_at(time), refund_amount(amount) {}
|
|
};
|
|
|
|
// Abstract interface for database operations
|
|
class DatabaseInterface {
|
|
public:
|
|
virtual ~DatabaseInterface() {}
|
|
|
|
// Verification of the database availability
|
|
virtual bool isDatabaseAvailable() = 0;
|
|
|
|
// Genre operations
|
|
virtual bool addGenre(const NewGenre &genre) = 0;
|
|
virtual bool removeGenre(int genre_id) = 0;
|
|
virtual bool updateGenre(const Genre &genre) = 0;
|
|
virtual Genre getGenre(int genre_id) = 0;
|
|
virtual std::vector<Genre> getAllGenres() = 0;
|
|
|
|
// Movie operations
|
|
virtual bool addMovie(const NewMovie &movie) = 0;
|
|
virtual bool removeMovie(int movie_id) = 0;
|
|
virtual bool updateMovie(const Movie &movie) = 0;
|
|
virtual Movie getMovie(int movie_id) = 0;
|
|
virtual std::vector<Movie> getAllMovies() = 0;
|
|
|
|
// Hall operations
|
|
virtual bool addHall(const NewHall &hall) = 0;
|
|
virtual bool removeHall(int hall_id) = 0;
|
|
virtual bool updateHall(const Hall &hall) = 0;
|
|
virtual Hall getHall(int hall_id) = 0;
|
|
virtual std::vector<Hall> getAllHalls() = 0;
|
|
|
|
// Session operations
|
|
virtual bool addSession(const NewSession &session) = 0;
|
|
virtual bool removeSession(int session_id) = 0;
|
|
virtual bool updateSession(const Session &session) = 0;
|
|
virtual Session getSession(int session_id) = 0;
|
|
virtual std::vector<Session> getAllSessions() = 0;
|
|
|
|
// Ticket operations
|
|
virtual bool addTicket(const NewTicket &ticket) = 0;
|
|
virtual bool removeTicket(int ticket_id) = 0;
|
|
virtual bool updateTicket(const Ticket &ticket) = 0;
|
|
virtual Ticket getTicket(int ticket_id) = 0;
|
|
virtual std::vector<Ticket> getAllTickets() = 0;
|
|
|
|
// Refund operations
|
|
virtual bool addRefund(const NewRefund &refund) = 0;
|
|
virtual bool removeRefund(int refund_id) = 0;
|
|
virtual bool updateRefund(const Refund &refund) = 0;
|
|
virtual Refund getRefund(int refund_id) = 0;
|
|
virtual std::vector<Refund> getAllRefunds() = 0;
|
|
};
|
|
|
|
#endif // DATABASE_INTERFACE_H
|