inseriti i types e i constraints e aggiunta la via in 02_seed.sql
This commit is contained in:
parent
de33e61496
commit
f46a11d762
3 changed files with 76 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ CREATE TABLE IF NOT EXISTS cliente (
|
|||
ClienteID INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
Nome VARCHAR(100) NOT NULL,
|
||||
Cognome VARCHAR(100) NOT NULL,
|
||||
Via VARCHAR(100) NOT NULL,
|
||||
Comune VARCHAR(100) NOT NULL,
|
||||
Provincia VARCHAR(2) NOT NULL,
|
||||
Telefono VARCHAR(30) NOT NULL,
|
||||
|
|
|
|||
35
src/types/index.ts
Normal file
35
src/types/index.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { CONSEGNA_CONSTRAINTS, UTENTE_CONSTRAINTS } from "../validation/constraints.js";
|
||||
|
||||
export type Ruolo = (typeof UTENTE_CONSTRAINTS.ruolo.allowedValues)[number];
|
||||
|
||||
export type StatoConsegna = (typeof CONSEGNA_CONSTRAINTS.stato.allowedValues)[number];
|
||||
|
||||
export interface Utente {
|
||||
UtenteID: number;
|
||||
Nome: string;
|
||||
Cognome: string;
|
||||
Email: string;
|
||||
PasswordHash: string;
|
||||
Ruolo: Ruolo;
|
||||
}
|
||||
|
||||
export interface Cliente {
|
||||
ClienteID: number;
|
||||
Nome: string;
|
||||
Via: string;
|
||||
Cognome: string;
|
||||
Comune: string;
|
||||
Provincia: string;
|
||||
Telefono: string;
|
||||
Email: string;
|
||||
Note: string | null;
|
||||
}
|
||||
|
||||
export interface Consegna {
|
||||
ConsegnaID: number;
|
||||
ClienteID: number;
|
||||
DataRitiro: Date;
|
||||
DataConsegna: Date;
|
||||
Stato: StatoConsegna;
|
||||
ChiaveConsegna: string;
|
||||
}
|
||||
40
src/validation/constraints.ts
Normal file
40
src/validation/constraints.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//=========================================
|
||||
// File: constraints.ts
|
||||
// Vincoli derivati da initdb/01_schema.sql.
|
||||
// author: "villari.andrea@libero.it"
|
||||
// version: "1.0.0 2026-06-18"
|
||||
//=========================================
|
||||
|
||||
export const UTENTE_CONSTRAINTS = {
|
||||
nome: { maxLength: 100, required: true },
|
||||
cognome: { maxLength: 100, required: true },
|
||||
email: { maxLength: 255, required: true },
|
||||
password: { minLength: 8, maxLength: 72, required: true },
|
||||
ruolo: {allowedValues: ["Operatore", "Amministratore"],
|
||||
required: true,
|
||||
}
|
||||
} as const;
|
||||
|
||||
export const CLIENTE_CONSTRAINTS = {
|
||||
nome: { maxLength: 100, required: true },
|
||||
cognome: { maxLength: 100, required: true },
|
||||
via: {maxLength: 100, required: true},
|
||||
Comune: {maxLength: 100, required: true},
|
||||
Provincia: {maxLength: 2, required: true},
|
||||
telefono: { maxLength: 30, required: true },
|
||||
email: { maxLength: 255, required: true },
|
||||
note: { required: false },
|
||||
} as const;
|
||||
|
||||
|
||||
export const CONSEGNA_CONSTRAINTS = {
|
||||
dataconsegna: { required: true },
|
||||
dataritiro: {required: true},
|
||||
stato: {
|
||||
allowedValues: ["da ritirare", "in consegna", "in giacenza", "in deposito"],
|
||||
required: true,
|
||||
},
|
||||
chiaveConsegna: { maxLength: 8, required: true },
|
||||
clienteId: { required: true },
|
||||
} as const;
|
||||
|
||||
Loading…
Add table
Reference in a new issue