> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wethehivers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Modèle Entreprise

> Schéma entreprise, RCCM, validations et médias

# Entreprise

Une **entreprise** est l'entité qui publie des offres. Identifiée par son `RCCM` (Registre du Commerce et du Crédit Mobilier, unique au Cameroun).

## Schéma

```mermaid theme={null}
classDiagram
    class Entreprise {
        +Long id
        +String nom
        +String rccm UK
        +String niu "Numéro Identifiant Unique"
        +String secteur
        +Long villeId
        +String adresse
        +String siteWeb
        +String logoKey
        +String bannerKey
        +String description
        +String linkedinUrl
        +Integer tailleEmployes
        +Integer anneeCreation
        +String status "ACTIVE|SUSPENDED"
        +Instant createdAt
    }

    class StaffPhoto {
        +Long id
        +Long entrepriseId
        +String r2Key
        +String caption
        +Integer ordre
    }

    class Ville {
        +Long id
        +String nom
    }

    Entreprise "1" --> "0..*" StaffPhoto
    Entreprise "N" --> "1" Ville
    Entreprise "1" --> "0..*" Recruteur
    Entreprise "1" --> "0..*" Offre
```

## Exemple JSON

```json theme={null}
{
  "id": 18,
  "nom": "Tech Corp SARL",
  "rccm": "RC/DLA/2019/B/1234",
  "niu": "M011912345678A",
  "secteur": "SOFTWARE",
  "ville": { "id": 101, "nom": "Douala", "region": "Littoral" },
  "adresse": "Rue Joss, immeuble Kassap, 3e étage",
  "siteWeb": "https://tech-corp.cm",
  "description": "Éditeur logiciel fondé en 2019...",
  "logoUrl": "https://cdn.wethehivers.com/public/entreprises/18/logo.png",
  "bannerUrl": "https://cdn.wethehivers.com/public/entreprises/18/banner.jpg",
  "linkedinUrl": "https://linkedin.com/company/tech-corp-cm",
  "tailleEmployes": 45,
  "anneeCreation": 2019,
  "nombreOffresActives": 3,
  "staffPhotos": [
    { "url": "...", "caption": "L'équipe dev" },
    { "url": "...", "caption": "Bureau Douala" }
  ]
}
```

## Règles de création

```mermaid theme={null}
flowchart TD
    REG[POST /recruiters/register\n +entreprise payload] --> Q{RCCM existant?}
    Q -->|non| NEW[Création entreprise + owner]
    Q -->|oui| OWN[Notif owner pour rattachement]
    OWN --> A{Owner accepte?}
    A -->|oui| MEM[Nouveau = MEMBER]
    A -->|non| REJ[Inscription rejetée]
```

## Médias entreprise

| Média        | Bucket             | Format               | Taille max            |
| ------------ | ------------------ | -------------------- | --------------------- |
| Logo         | `wethehive-public` | PNG / JPG carré      | 2 Mo                  |
| Bannière     | `wethehive-public` | JPG 16:9 (1920×1080) | 5 Mo                  |
| Photos staff | `wethehive-public` | JPG 4:3              | 3 Mo chacune (max 10) |

```mermaid theme={null}
flowchart LR
    UP[Upload logo] --> V{MIME + taille OK?}
    V -->|non| R413[413]
    V -->|oui| AV[Scan ClamAV]
    AV --> R2[PUT R2 public]
    R2 --> DB[UPDATE entreprise.logoKey]
    DB --> CDN[CDN Cloudflare warm]
```

## Champs verrouillés après validation admin

* `rccm` (immuable)
* `niu` (immuable)
* `nom` : modifiable sur justificatif (changement raison sociale)

## Endpoints principaux

| Méthode | Path                                      | Rôle                |
| ------- | ----------------------------------------- | ------------------- |
| `GET`   | `/v1/api/public/entreprises/{id}`         | Fiche publique      |
| `PUT`   | `/v1/api/recruiters/me/entreprise`        | Mise à jour (OWNER) |
| `POST`  | `/v1/api/recruiters/me/entreprise/logo`   | Upload logo         |
| `POST`  | `/v1/api/recruiters/me/entreprise/banner` | Upload bannière     |
| `GET`   | `/v1/api/admin/entreprises/{id}`          | Fiche admin         |
| `POST`  | `/v1/api/admin/entreprises/{id}/suspend`  | Suspendre           |

## Relation offres

```mermaid theme={null}
erDiagram
    ENTREPRISE ||--o{ OFFRE : "publishes"
    ENTREPRISE {
        long id PK
        string nom
        string rccm UK
    }
    OFFRE {
        long id PK
        long entrepriseId FK
        string titre
        string status
    }
```

Une offre hérite automatiquement de `entrepriseId` depuis le recruteur qui la publie. Impossible de rattacher une offre à une entreprise tierce.
