Snippets
Cette page regroupe des snippets utiles pour initier un modèle destiné au générateur JPA. Ils couvrent les annotations, les domaines et les décorateurs les plus courants.
Conformément à la version 3 de TopModel, les annotations sont désormais définies comme des objets dédiés (annotation:) puis référencées depuis les domaines et les décorateurs via la propriété annotations:.
Annotations
---
annotation:
name: Email
description: Valide qu'une propriété contient un email bien formé.
target:
- property
java:
- text: '@Email(message = "Le mail ''${validatedValue}'' n''est pas valide")'
imports:
- jakarta.validation.constraints.Email
---
annotation:
name: Past
description: Valide qu'une date est dans le passé.
target:
- property
java:
- text: "@Past"
imports:
- jakarta.validation.constraints.Past
---
annotation:
name: PastOrPresent
description: Valide qu'une date est dans le passé ou le présent.
target:
- property
java:
- text: "@PastOrPresent"
imports:
- jakarta.validation.constraints.PastOrPresent
---
annotation:
name: CreatedDate
description: Date de création automatiquement renseignée par Spring Data.
target:
- property
java:
- text: "@CreatedDate"
imports:
- org.springframework.data.annotation.CreatedDate
when:
- persisted
---
annotation:
name: LastModifiedDate
description: Date de modification automatiquement renseignée par Spring Data.
target:
- property
java:
- text: "@LastModifiedDate"
imports:
- org.springframework.data.annotation.LastModifiedDate
when:
- persisted
---
annotation:
name: CreatedBy
description: Auteur de la création automatiquement renseigné par Spring Data.
target:
- property
java:
- text: "@CreatedBy"
imports:
- org.springframework.data.annotation.CreatedBy
when:
- persisted
---
annotation:
name: LastModifiedBy
description: Auteur de la dernière modification automatiquement renseigné par Spring Data.
target:
- property
java:
- text: "@LastModifiedBy"
imports:
- org.springframework.data.annotation.LastModifiedBy
when:
- persisted
---
annotation:
name: EntityListeners
description: Entity Listener pour suivre les évènements de création et de modification.
target:
- class
java:
- text: EntityListeners(AuditingEntityListener.class)
imports:
- org.springframework.data.jpa.domain.support.AuditingEntityListener
- jakarta.persistence.EntityListeners
---
annotation:
name: HasAuthority
description: Droit nécessaire pour pouvoir accéder au endpoint.
target:
- server-endpoint
parameters:
- name: authority
required: true
comment: Autorité à passer à `PreAuthorize`.
java:
- text: '@PreAuthorize("hasAuthority(''{authority}'')")'
imports:
- org.springframework.security.access.prepost.PreAuthorize
Domains
---
domain:
name: ID
label: ID technique
autoGeneratedValue: true
asDomains:
list: LIST
java:
type: Long
---
domain:
name: MAIL
asDomains:
list: LIST
label: Mail
length: 100
annotations:
- Email
java:
type: String
---
domain:
name: DATE_TIME
label: Date
asDomains:
list: LIST
java:
type: LocalDateTime
imports:
- java.time.LocalDateTime
---
domain:
name: TIME
label: Heure
asDomains:
list: LIST
java:
type: LocalTime
imports:
- java.time.LocalTime
---
domain:
name: DATE
label: Date
asDomains:
list: LIST
java:
type: LocalDate
imports:
- java.time.LocalDate
---
domain:
name: DATE_PAST
label: Date
asDomains:
list: LIST
annotations:
- Past
java:
type: LocalDate
imports:
- java.time.LocalDate
---
domain:
name: DATE_CREATION
label: Date
asDomains:
list: LIST
annotations:
- CreatedDate
- PastOrPresent
java:
type: LocalDate
imports:
- java.time.LocalDate
---
domain:
name: DATE_MODIFICATION
label: Date
asDomains:
list: LIST
annotations:
- LastModifiedDate
- PastOrPresent
java:
type: LocalDate
imports:
- java.time.LocalDate
---
domain:
name: CREE_PAR
label: Créé par
scale: 50
asDomains:
list: LIST
annotations:
- CreatedBy
java:
type: String
---
domain:
name: MODIFIE_PAR
label: Modifié par
scale: 50
asDomains:
list: LIST
annotations:
- LastModifiedBy
java:
type: String
---
domain:
name: FILE_FORM
mediaType: "multipart/form-data"
label: Fichier
bodyParam: true
java:
type: MultipartFile
imports:
- "org.springframework.web.multipart.MultipartFile"
---
domain:
name: FILE
mediaType: "multipart/form-data"
label: Fichier
bodyParam: true
java:
type: File
imports:
- "java.io.File"
---
domain:
name: RESPONSE_ENTITY
label: Response Entity
parameters:
- name: type
required: true
comment: Type de réponse
- name: import
required: true
comment: Import pour le type de la réponse
java:
type: ResponseEntity<{type}>
imports:
- org.springframework.http.ResponseEntity
- "{import}"
---
domain:
name: LIST
label: Liste
java:
type: List<String>
genericType: List<{T}>
imports:
- java.util.List
---
domain:
name: POINT
label: Point
java:
type: Point
imports:
- org.locationtech.jts.geom.Point
---
domain:
name: POLYGONE
label: Polygone
java:
type: Polygon
imports:
- org.locationtech.jts.geom.Polygon
---
domain:
name: PAGE
label: Date
java:
type: Page
genericType: Page<{T}>
imports:
- "org.springframework.data.domain.Page"
---
domain:
name: HTTP_RESPONSE
label: Réponse Http
java:
type: ResponseEntity<Void>
imports:
- org.springframework.http.ResponseEntity
Décorateurs
---
decorator:
name: DateCreation
description: Entity Listener pour suivre les évènements de création
annotations:
- EntityListeners
properties:
- name: DateCreation
comment: Date de création de l'objet
required: true
domain: DATE_CREATION
label: Date de création
---
decorator:
name: DateModification
description: Entity Listener pour suivre les évènements de modification
annotations:
- EntityListeners
properties:
- name: DateModification
comment: Date de modification de l'objet
required: true
domain: DATE_MODIFICATION
label: Date de modification
---
decorator:
name: CreePar
description: Entity Listener pour suivre les évènements de création
annotations:
- EntityListeners
properties:
- name: CreePar
comment: Auteur de la création de l'objet
required: true
domain: CREE_PAR
label: Créateur
---
decorator:
name: ModifiePar
description: Entity Listener pour suivre les évènements de modification
annotations:
- EntityListeners
properties:
- name: ModifiePar
comment: Auteur de la dernière modification de l'objet
required: true
domain: MODIFIE_PAR
label: Modificateur
Le décorateur
HasAuthoritydéfini avant la v3 ne portait que des annotations. Conformément au guide de migration, il a été transformé en annotation directement utilisable sur un endpoint :endpoint:name: GetSecretmethod: GETroute: /secretdescription: Endpoint nécessitant une autorité.annotations:- HasAuthority:authority: ADMIN