Checkpoint: Application SONUM v1.0 - Cartographie des Solutions Numériques FEHAP. Toutes les fonctionnalités implémentées : charte CGU, moteur de recherche multicritères avec tri, Mes Établissements avec accordéons et édition inline, formulaire de saisie guidé en 3 étapes, fiche établissement avec compteur de consultation, prise de contact, Mes Demandes de Contact avec réponse directe, administration SONUM, gestion des rôles (Référent / Gestionnaire), traçabilité, lien espace adhérent FEHAP. 14 tests Vitest passés.
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
import { int, mysqlEnum, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
|
||||
import {
|
||||
boolean,
|
||||
int,
|
||||
mysqlEnum,
|
||||
mysqlTable,
|
||||
text,
|
||||
timestamp,
|
||||
varchar,
|
||||
} from "drizzle-orm/mysql-core";
|
||||
|
||||
// ─── Utilisateurs ────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Core user table backing auth flow.
|
||||
* Extend this file with additional tables as your product grows.
|
||||
* Columns use camelCase to match both database fields and generated types.
|
||||
*/
|
||||
export const users = mysqlTable("users", {
|
||||
/**
|
||||
* Surrogate primary key. Auto-incremented numeric value managed by the database.
|
||||
* Use this for relations between tables.
|
||||
*/
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
/** Manus OAuth identifier (openId) returned from the OAuth callback. Unique per user. */
|
||||
openId: varchar("openId", { length: 64 }).notNull().unique(),
|
||||
name: text("name"),
|
||||
email: varchar("email", { length: 320 }),
|
||||
loginMethod: varchar("loginMethod", { length: 64 }),
|
||||
role: mysqlEnum("role", ["user", "admin"]).default("user").notNull(),
|
||||
// Profil SONUM : referent = référent numérique, gestionnaire = gestionnaire SONUM
|
||||
sonumRole: mysqlEnum("sonumRole", ["referent", "gestionnaire"]).default("referent").notNull(),
|
||||
// CGU acceptée
|
||||
cguAccepted: boolean("cguAccepted").default(false).notNull(),
|
||||
cguAcceptedAt: timestamp("cguAcceptedAt"),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
lastSignedIn: timestamp("lastSignedIn").defaultNow().notNull(),
|
||||
@@ -25,4 +30,130 @@ export const users = mysqlTable("users", {
|
||||
export type User = typeof users.$inferSelect;
|
||||
export type InsertUser = typeof users.$inferInsert;
|
||||
|
||||
// TODO: Add your tables here
|
||||
// ─── Référentiel : Éditeurs ───────────────────────────────────────────────────
|
||||
|
||||
export const editeurs = mysqlTable("editeurs", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
nom: varchar("nom", { length: 255 }).notNull(),
|
||||
estValide: boolean("estValide").default(true).notNull(), // false = ajouté par un référent, en attente de validation FEHAP
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export type Editeur = typeof editeurs.$inferSelect;
|
||||
|
||||
// ─── Référentiel : Blocs Fonctionnels ────────────────────────────────────────
|
||||
|
||||
export const blocsFonctionnels = mysqlTable("blocs_fonctionnels", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
nom: varchar("nom", { length: 255 }).notNull(),
|
||||
estValide: boolean("estValide").default(true).notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export type BlocFonctionnel = typeof blocsFonctionnels.$inferSelect;
|
||||
|
||||
// ─── Référentiel : Solutions ──────────────────────────────────────────────────
|
||||
|
||||
export const solutions = mysqlTable("solutions", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
nom: varchar("nom", { length: 255 }).notNull(),
|
||||
editeurId: int("editeurId").notNull(),
|
||||
blocFonctionnelId: int("blocFonctionnelId"),
|
||||
estValide: boolean("estValide").default(true).notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export type Solution = typeof solutions.$inferSelect;
|
||||
|
||||
// ─── Établissements ───────────────────────────────────────────────────────────
|
||||
|
||||
export const etablissements = mysqlTable("etablissements", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
finess: varchar("finess", { length: 20 }),
|
||||
nom: varchar("nom", { length: 255 }).notNull(),
|
||||
region: varchar("region", { length: 100 }),
|
||||
departement: varchar("departement", { length: 100 }),
|
||||
typeActivite: varchar("typeActivite", { length: 100 }),
|
||||
tailleEffectifs: varchar("tailleEffectifs", { length: 50 }),
|
||||
// Référent numérique responsable
|
||||
referentId: int("referentId"),
|
||||
// Visibilité : "tous" = visible par tous les référents, "gestionnaires" = visible uniquement par gestionnaires SONUM
|
||||
visibilite: mysqlEnum("visibilite", ["tous", "gestionnaires"]).default("tous").notNull(),
|
||||
// Acceptation mise en relation
|
||||
accepteMiseEnRelation: boolean("accepteMiseEnRelation").default(true).notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
});
|
||||
|
||||
export type Etablissement = typeof etablissements.$inferSelect;
|
||||
|
||||
// ─── Logiciels par Établissement ─────────────────────────────────────────────
|
||||
|
||||
export const logicielsEtablissements = mysqlTable("logiciels_etablissements", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
etablissementId: int("etablissementId").notNull(),
|
||||
solutionId: int("solutionId").notNull(),
|
||||
etatDeploiement: mysqlEnum("etatDeploiement", [
|
||||
"demarrage",
|
||||
"en_cours",
|
||||
"operationnel",
|
||||
"en_remplacement",
|
||||
]).notNull(),
|
||||
modeHebergement: mysqlEnum("modeHebergement", [
|
||||
"hds",
|
||||
"on_premise",
|
||||
"hybride",
|
||||
]),
|
||||
modeFacturation: mysqlEnum("modeFacturation", [
|
||||
"saas",
|
||||
"achat_maintenance",
|
||||
"location",
|
||||
]),
|
||||
interoperabilite: mysqlEnum("interoperabilite", ["non", "oui_interface", "oui_eai"]),
|
||||
versionMajeure: varchar("versionMajeure", { length: 50 }),
|
||||
commentaire: text("commentaire"),
|
||||
// Contact référent pour ce logiciel
|
||||
contactNom: varchar("contactNom", { length: 255 }),
|
||||
contactFonction: varchar("contactFonction", { length: 255 }),
|
||||
contactEmail: varchar("contactEmail", { length: 320 }),
|
||||
saisiePar: int("saisiePar"), // userId
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
});
|
||||
|
||||
export type LogicielEtablissement = typeof logicielsEtablissements.$inferSelect;
|
||||
|
||||
// ─── Traçabilité : Consultations ──────────────────────────────────────────────
|
||||
|
||||
export const consultations = mysqlTable("consultations", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
etablissementId: int("etablissementId").notNull(),
|
||||
consultePar: int("consultePar").notNull(), // userId
|
||||
consultéParNom: varchar("consulteParNom", { length: 255 }),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export type Consultation = typeof consultations.$inferSelect;
|
||||
|
||||
// ─── Demandes de Contact ──────────────────────────────────────────────────────
|
||||
|
||||
export const demandesContact = mysqlTable("demandes_contact", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
// Établissement cible
|
||||
etablissementCibleId: int("etablissementCibleId").notNull(),
|
||||
// Demandeur
|
||||
demandeurId: int("demandeurId").notNull(),
|
||||
demandeurNom: varchar("demandeurNom", { length: 255 }),
|
||||
demandeurEmail: varchar("demandeurEmail", { length: 320 }),
|
||||
// Message
|
||||
message: text("message").notNull(),
|
||||
// Statut
|
||||
statut: mysqlEnum("statut", ["en_attente", "repondu", "ferme"]).default("en_attente").notNull(),
|
||||
reponse: text("reponse"),
|
||||
reponsePar: int("reponsePar"),
|
||||
reponduAt: timestamp("reponduAt"),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
});
|
||||
|
||||
export type DemandeContact = typeof demandesContact.$inferSelect;
|
||||
|
||||
Reference in New Issue
Block a user