db

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

README

db

Pacchetto per la comunicazione con il database SQL. Utilizzare le seguenti librerie: database/sql e github.com/go-sql-driver/mysql.

Tipi

type Libro
type Autore
type Genere
type Prestito

Funzioni

func InizializzaDB() (error)
func ChiudiDB()

func GetLibro(codice uint32) (Libro, error)
func GetLibri(page uint32) ([]Libri, error)
func GetAutori(iniziale uint8) ([]Autore, error)
func GetTuttiAutori() ([]Autore, error)
func GetGeneri() ([]Genere, error)
func GetPrestiti(utente string) ([]Prestito, error)
func GetAssegnatario(cod uint32) (string, error)
func GetCurrentPrestito(codice uint32) (Prestito, error)
func GetLibri() ([]Libro, error)

func RicercaLibri(nome string, autore, genere []uint32, page int16) ([]Libro, error)
func RicercaLibriNoPage(nome string, autore, genere []uint32) ([]Libro, error)
func RicercaAutori(nome string) ([]Autore, error)
func RicercaGeneri(nome string) ([]Genere, error)

func AddLibro(titolo string, autore, genere uint32) (uint32, error)
func AddGenere(nome string) (uint32, error)
func AddAutore(nome, cognome string) (uint32, error)
func AddPrestito(libro uint32, utente string, data_prenotazione time.Time, durata uint32) (uint32, error)

func SetHash(codice uint32, hash string) error
func SetRestituzione(prestito uint32, data_restituzione time.Time) error

func RemoveLibro(codice uint32) error
func RemoveGenere(codice uint32) error
func RemoveAutore(codice uint32) error
func RemovePrestito(codice uint32) error

func LibriPrenotati() (uint32, error)
func LibriDisponibili() (uint32, error)

func CountAutori() (uint32, error)
func CountLibri() (uint32, error)

Documentation

Overview

Pacchetto per interfacciarsi con il database SQL

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAutore

func AddAutore(nome, cognome string) (uint32, error)

Funzione per aggiungere un autore

func AddGenere

func AddGenere(nome string) (uint32, error)

Funzione per aggiungere un genere

func AddLibro

func AddLibro(titolo string, autore, genere uint32) (uint32, error)

func AddPrestito

func AddPrestito(libro uint32, utente string, durata uint32) (uint32, error)

func ChiudiDB

func ChiudiDB()

Funzione per chiudere il database

func CountAutori

func CountAutori() (uint32, error)

Funzione che conta gli autori totali

func CountLibri

func CountLibri() (uint32, error)

Funzione per contare tutti i libri

func InizializzaDB

func InizializzaDB() (err error)

Funzione per inizializzare il database

func LibriDisponibili

func LibriDisponibili() (uint32, error)

Funzione che ritorna il numero di libri disponibili

func LibriPrenotati

func LibriPrenotati() (uint32, error)

Funzione che ritorna il numero di libri prenotati

func RemoveAutore

func RemoveAutore(codice uint32) error

Funzione per rimuovere un autore

func RemoveGenere

func RemoveGenere(codice uint32) error

Funzione per rimuovere un genere

func RemoveLibro

func RemoveLibro(codice uint32) error

Funzione per rimuovere un libro

func RemovePrestito

func RemovePrestito(codice uint32) error

Funzione per rimuovere un prestito

func SetHash

func SetHash(codice uint32, hash string) error

Funzione per impostare l'hash di un libro

func SetRestituzione

func SetRestituzione(libro uint32) error

Funzione per impostare la restituzione

Types

type Autore

type Autore struct {
	Codice  uint32
	Nome    string
	Cognome string
}

func GetAutori

func GetAutori(iniziale uint8) ([]Autore, error)

Funzione per trovare Autori in base all'iniziale del cognome

func GetTuttiAutori

func GetTuttiAutori() ([]Autore, error)

Funzione per trovare Autori in base all'iniziale del cognome

func RicercaAutori

func RicercaAutori(nome string) ([]Autore, error)

Funzione per la ricerca degli autori

type Genere

type Genere struct {
	Codice uint32
	Nome   string
}

func GetGeneri

func GetGeneri() ([]Genere, error)

Funzione per trovare tutti i generi esistenti nel database

func RicercaGeneri

func RicercaGeneri(nome string) ([]Genere, error)

Funzione per la ricerca dei generi

type Libro

type Libro struct {
	Codice        uint32
	Titolo        string
	NomeAutore    string
	CognomeAutore string
	Genere        string
	Prenotato     bool
	Hashz         string
}

Tabelle del database

func GetLibri

func GetLibri() ([]Libro, error)

Funzione per ottenere tutti i libri

func GetLibro

func GetLibro(cod uint32) (Libro, error)

Funzione per trovare un libro in base al suo codice

func RicercaLibri

func RicercaLibri(nome string, autore, genere []uint32, page uint16) ([]Libro, error)

Funzione per la ricerca dei libri

func RicercaLibriNoPage

func RicercaLibriNoPage(nome string, autore, genere []uint32) ([]Libro, error)

Funzione per la ricerca dei libri

type NoCurrentPrestitoError

type NoCurrentPrestitoError struct {
	// contains filtered or unexported fields
}

func (*NoCurrentPrestitoError) Error

func (e *NoCurrentPrestitoError) Error() string

type NullPrestito

type NullPrestito struct {
	Prestito Prestito
	Valid    bool
}

func GetCurrentPrestito

func GetCurrentPrestito(codice uint32) (NullPrestito, error)

Funzione per trovare tutti i prestiti di un utente

type Prestito

type Prestito struct {
	Codice            uint32
	Libro             uint32
	Utente            string
	Data_prenotazione time.Time
	Durata            uint32
	Data_restituzione sql.NullTime
}

func GetPrestitiLibro

func GetPrestitiLibro(libro uint32) ([]Prestito, error)

Funzione per trovare tutti i prestiti di un libro

func GetPrestitiUtente

func GetPrestitiUtente(utente string) ([]Prestito, error)

Funzione per trovare tutti i prestiti di un utente

func (Prestito) FormatDataPrenotazione

func (p Prestito) FormatDataPrenotazione() string

func (Prestito) FormatDataRestituzione

func (p Prestito) FormatDataRestituzione() string

func (Prestito) FormatScadenza

func (p Prestito) FormatScadenza() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL