129 lines
2.9 KiB
Markdown
129 lines
2.9 KiB
Markdown
# 📄 CONCEPT: DOCUMENT
|
|
|
|
## 📌 Vue d'ensemble
|
|
|
|
Le concept **DOCUMENT** gère la GED (Gestion Électronique des Documents) : plans, photos, rapports, contrats, etc.
|
|
|
|
**Importance**: ⭐⭐⭐ (Concept important)
|
|
|
|
---
|
|
|
|
## 🗂️ Fichiers concernés
|
|
|
|
### **Entités JPA**
|
|
| Fichier | Description |
|
|
|---------|-------------|
|
|
| `Document.java` | Entité principale document |
|
|
| `TypeDocument.java` | Enum types (PLAN, PERMIS, RAPPORT, PHOTO, CONTRAT, etc.) |
|
|
|
|
### **Services**
|
|
| Fichier | Description |
|
|
|---------|-------------|
|
|
| `DocumentService.java` | Service métier documents |
|
|
|
|
### **Resources**
|
|
| Fichier | Description |
|
|
|---------|-------------|
|
|
| `DocumentResource.java` | API REST documents |
|
|
| `PhotoResource.java` | API REST photos |
|
|
|
|
---
|
|
|
|
## 📊 Modèle de données
|
|
|
|
```java
|
|
@Entity
|
|
@Table(name = "documents")
|
|
public class Document extends PanacheEntityBase {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.UUID)
|
|
private UUID id;
|
|
|
|
@Column(name = "nom", nullable = false)
|
|
private String nom;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "type")
|
|
private TypeDocument type;
|
|
|
|
@Column(name = "chemin_fichier", nullable = false)
|
|
private String cheminFichier;
|
|
|
|
@Column(name = "taille_octets")
|
|
private Long tailleOctets;
|
|
|
|
@Column(name = "mime_type")
|
|
private String mimeType;
|
|
|
|
@ManyToOne
|
|
@JoinColumn(name = "chantier_id")
|
|
private Chantier chantier;
|
|
|
|
@Column(name = "description", length = 1000)
|
|
private String description;
|
|
|
|
@Column(name = "date_upload")
|
|
private LocalDateTime dateUpload;
|
|
}
|
|
```
|
|
|
|
### **Enum TypeDocument**
|
|
|
|
```java
|
|
public enum TypeDocument {
|
|
PLAN, // Plans architecturaux
|
|
PERMIS_CONSTRUIRE, // Permis de construire
|
|
RAPPORT_CHANTIER, // Rapports de chantier
|
|
PHOTO_CHANTIER, // Photos de chantier
|
|
CONTRAT, // Contrats
|
|
DEVIS, // Devis
|
|
FACTURE, // Factures
|
|
CERTIFICAT, // Certificats
|
|
AUTRE
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 🔌 API REST
|
|
|
|
### **Endpoints**
|
|
|
|
| Méthode | Endpoint | Description |
|
|
|---------|----------|-------------|
|
|
| GET | `/api/v1/documents` | Liste documents |
|
|
| GET | `/api/v1/documents/{id}` | Détails |
|
|
| POST | `/api/v1/documents/upload` | Upload document |
|
|
| GET | `/api/v1/documents/{id}/download` | Télécharger |
|
|
| DELETE | `/api/v1/documents/{id}` | Supprimer |
|
|
| GET | `/api/v1/documents/chantier/{id}` | Par chantier |
|
|
| GET | `/api/v1/documents/type/{type}` | Par type |
|
|
|
|
---
|
|
|
|
## 💻 Exemples
|
|
|
|
### **Upload document**
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/v1/documents/upload \
|
|
-F "file=@plan.pdf" \
|
|
-F "nom=Plan RDC" \
|
|
-F "type=PLAN" \
|
|
-F "chantierId=chantier-uuid" \
|
|
-F "description=Plan du rez-de-chaussée"
|
|
```
|
|
|
|
### **Télécharger document**
|
|
|
|
```bash
|
|
curl -X GET http://localhost:8080/api/v1/documents/{id}/download \
|
|
--output document.pdf
|
|
```
|
|
|
|
---
|
|
|
|
**Dernière mise à jour**: 2025-09-30
|
|
**Version**: 1.0
|
|
|