backend api, swagger, tooling, frontend skeleton
This commit is contained in:
10
.env.example
Normal file
10
.env.example
Normal file
@@ -0,0 +1,10 @@
|
||||
# Backend
|
||||
PORT=8080
|
||||
DATABASE_DRIVER=sqlite3
|
||||
DATABASE_URL=file:./data/matosbox.db?_fk=1
|
||||
ATTACHMENTS_DIR=./data/pieces_jointes
|
||||
BACKUP_DIR=./data/backups
|
||||
MAX_UPLOAD_MB=50
|
||||
|
||||
# App
|
||||
TIMEZONE=Europe/Paris
|
||||
@@ -4,6 +4,8 @@
|
||||
- Analyse detaillee des consignes.
|
||||
- Reference structure BDD.
|
||||
- TODO projet global.
|
||||
- Migration SQL initiale.
|
||||
- Handlers CRUD pour objets, categories, emplacements.
|
||||
|
||||
## [0.1.0] - 2026-01-21
|
||||
- MVP core + DB SQLite (planifie).
|
||||
|
||||
2
TODO.md
2
TODO.md
@@ -1,4 +1,6 @@
|
||||
# TODO MatosBox
|
||||
en suivant consigne: MatosBox Documentation.md
|
||||
|
||||
|
||||
## Priorite haute (MVP)
|
||||
- [ ] Creer schemas Ent en francais : Objet, Categorie, Emplacement.
|
||||
|
||||
12
Taskfile.yml
Normal file
12
Taskfile.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3'
|
||||
|
||||
env:
|
||||
GOPATH: /tmp/go
|
||||
GOMODCACHE: /tmp/go/pkg/mod
|
||||
GOCACHE: /tmp/go/cache
|
||||
|
||||
includes:
|
||||
backend:
|
||||
taskfile: ./backend/Taskfile.yml
|
||||
dir: ./backend
|
||||
|
||||
22
backend/Taskfile.yml
Normal file
22
backend/Taskfile.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
run:
|
||||
desc: Lancer le backend en mode dev
|
||||
cmds:
|
||||
- go run ./cmd/app
|
||||
|
||||
test:
|
||||
desc: Lancer les tests Go
|
||||
cmds:
|
||||
- go test ./...
|
||||
|
||||
ent:
|
||||
desc: Generer le code Ent
|
||||
cmds:
|
||||
- go run -mod=mod entgo.io/ent/cmd/ent generate ./internal/data/ent/schema --target ./internal/data/ent
|
||||
|
||||
swagger:
|
||||
desc: Regenerer la doc Swagger
|
||||
cmds:
|
||||
- bash scripts/gen_swagger.sh
|
||||
@@ -1,12 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/docs"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/handlers"
|
||||
)
|
||||
|
||||
// @title MatosBox API
|
||||
// @version 0.1.0
|
||||
// @description API MatosBox pour la gestion d'inventaire.
|
||||
// @BasePath /v1
|
||||
func main() {
|
||||
// Config simple : port via PORT, defaut 8080.
|
||||
port := os.Getenv("PORT")
|
||||
@@ -16,10 +29,41 @@ func main() {
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
// Connexion base de donnees.
|
||||
driver := os.Getenv("DATABASE_DRIVER")
|
||||
if driver == "" {
|
||||
driver = "sqlite3"
|
||||
}
|
||||
dsn := os.Getenv("DATABASE_URL")
|
||||
if dsn == "" {
|
||||
dsn = "file:./data/matosbox.db?_fk=1"
|
||||
}
|
||||
|
||||
client, err := ent.Open(driver, dsn)
|
||||
if err != nil {
|
||||
log.Fatalf("connexion base impossible: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := client.Close(); err != nil {
|
||||
log.Printf("fermeture base impossible: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Auto-creation du schema en dev. A remplacer par migrations en prod.
|
||||
if err := client.Schema.Create(context.Background()); err != nil {
|
||||
log.Fatalf("creation schema impossible: %v", err)
|
||||
}
|
||||
|
||||
// Route de sante pour verifier que le backend repond.
|
||||
r.GET("/healthz", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
||||
})
|
||||
|
||||
handlers.RegisterRoutes(r, client)
|
||||
|
||||
// Swagger (doc API).
|
||||
docs.SwaggerInfo.BasePath = "/v1"
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
_ = r.Run(":" + port)
|
||||
}
|
||||
|
||||
2142
backend/docs/docs.go
Normal file
2142
backend/docs/docs.go
Normal file
File diff suppressed because it is too large
Load Diff
2117
backend/docs/swagger.json
Normal file
2117
backend/docs/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
1424
backend/docs/swagger.yaml
Normal file
1424
backend/docs/swagger.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,63 @@ module gitea.maison43.duckdns.org/gilles/matosbox
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.13.1
|
||||
entgo.io/ent v0.14.5
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/mattn/go-sqlite3 v1.14.22
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.8.12
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/agext/levenshtein v1.2.3 // indirect
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||
github.com/bmatcuk/doublestar v1.3.4 // indirect
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||
github.com/go-openapi/spec v0.20.4 // indirect
|
||||
github.com/go-openapi/swag v0.19.15 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.6 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/zclconf/go-cty v1.14.4 // indirect
|
||||
github.com/zclconf/go-cty-yaml v1.1.0 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
203
backend/go.sum
Normal file
203
backend/go.sum
Normal file
@@ -0,0 +1,203 @@
|
||||
ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNGMytJN8afmIWXJVMi4cc=
|
||||
ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w=
|
||||
entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=
|
||||
entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
|
||||
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
|
||||
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
|
||||
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs=
|
||||
github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
|
||||
github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M=
|
||||
github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
|
||||
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo=
|
||||
github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M=
|
||||
github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo=
|
||||
github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
|
||||
github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
|
||||
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||
github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0=
|
||||
github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
|
||||
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
|
||||
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
218
backend/internal/data/ent/categorie.go
Normal file
218
backend/internal/data/ent/categorie.go
Normal file
@@ -0,0 +1,218 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Categorie is the model entity for the Categorie schema.
|
||||
type Categorie struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique de la categorie
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Nom de la categorie
|
||||
Nom string `json:"nom,omitempty"`
|
||||
// Identifiant du parent
|
||||
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
||||
// Slug URL-friendly
|
||||
Slug *string `json:"slug,omitempty"`
|
||||
// Nom ou code d'icone
|
||||
Icone *string `json:"icone,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the CategorieQuery when eager-loading is set.
|
||||
Edges CategorieEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// CategorieEdges holds the relations/edges for other nodes in the graph.
|
||||
type CategorieEdges struct {
|
||||
// Lien parent/enfants pour l'arbre des categories
|
||||
Parent *Categorie `json:"parent,omitempty"`
|
||||
// Enfants holds the value of the enfants edge.
|
||||
Enfants []*Categorie `json:"enfants,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [2]bool
|
||||
}
|
||||
|
||||
// ParentOrErr returns the Parent value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e CategorieEdges) ParentOrErr() (*Categorie, error) {
|
||||
if e.Parent != nil {
|
||||
return e.Parent, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: categorie.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "parent"}
|
||||
}
|
||||
|
||||
// EnfantsOrErr returns the Enfants value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e CategorieEdges) EnfantsOrErr() ([]*Categorie, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Enfants, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "enfants"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Categorie) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case categorie.FieldParentID:
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
case categorie.FieldNom, categorie.FieldSlug, categorie.FieldIcone:
|
||||
values[i] = new(sql.NullString)
|
||||
case categorie.FieldCreatedAt, categorie.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case categorie.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Categorie fields.
|
||||
func (_m *Categorie) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case categorie.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case categorie.FieldNom:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nom", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Nom = value.String
|
||||
}
|
||||
case categorie.FieldParentID:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field parent_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ParentID = new(uuid.UUID)
|
||||
*_m.ParentID = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case categorie.FieldSlug:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field slug", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Slug = new(string)
|
||||
*_m.Slug = value.String
|
||||
}
|
||||
case categorie.FieldIcone:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field icone", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Icone = new(string)
|
||||
*_m.Icone = value.String
|
||||
}
|
||||
case categorie.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case categorie.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Categorie.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Categorie) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryParent queries the "parent" edge of the Categorie entity.
|
||||
func (_m *Categorie) QueryParent() *CategorieQuery {
|
||||
return NewCategorieClient(_m.config).QueryParent(_m)
|
||||
}
|
||||
|
||||
// QueryEnfants queries the "enfants" edge of the Categorie entity.
|
||||
func (_m *Categorie) QueryEnfants() *CategorieQuery {
|
||||
return NewCategorieClient(_m.config).QueryEnfants(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Categorie.
|
||||
// Note that you need to call Categorie.Unwrap() before calling this method if this Categorie
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Categorie) Update() *CategorieUpdateOne {
|
||||
return NewCategorieClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Categorie entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *Categorie) Unwrap() *Categorie {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Categorie is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Categorie) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Categorie(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("nom=")
|
||||
builder.WriteString(_m.Nom)
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ParentID; v != nil {
|
||||
builder.WriteString("parent_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Slug; v != nil {
|
||||
builder.WriteString("slug=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Icone; v != nil {
|
||||
builder.WriteString("icone=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Categories is a parsable slice of Categorie.
|
||||
type Categories []*Categorie
|
||||
151
backend/internal/data/ent/categorie/categorie.go
Normal file
151
backend/internal/data/ent/categorie/categorie.go
Normal file
@@ -0,0 +1,151 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package categorie
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the categorie type in the database.
|
||||
Label = "categorie"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldNom holds the string denoting the nom field in the database.
|
||||
FieldNom = "nom"
|
||||
// FieldParentID holds the string denoting the parent_id field in the database.
|
||||
FieldParentID = "parent_id"
|
||||
// FieldSlug holds the string denoting the slug field in the database.
|
||||
FieldSlug = "slug"
|
||||
// FieldIcone holds the string denoting the icone field in the database.
|
||||
FieldIcone = "icone"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeParent holds the string denoting the parent edge name in mutations.
|
||||
EdgeParent = "parent"
|
||||
// EdgeEnfants holds the string denoting the enfants edge name in mutations.
|
||||
EdgeEnfants = "enfants"
|
||||
// Table holds the table name of the categorie in the database.
|
||||
Table = "categorie"
|
||||
// ParentTable is the table that holds the parent relation/edge.
|
||||
ParentTable = "categorie"
|
||||
// ParentColumn is the table column denoting the parent relation/edge.
|
||||
ParentColumn = "parent_id"
|
||||
// EnfantsTable is the table that holds the enfants relation/edge.
|
||||
EnfantsTable = "categorie"
|
||||
// EnfantsColumn is the table column denoting the enfants relation/edge.
|
||||
EnfantsColumn = "parent_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for categorie fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldNom,
|
||||
FieldParentID,
|
||||
FieldSlug,
|
||||
FieldIcone,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
NomValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Categorie queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNom orders the results by the nom field.
|
||||
func ByNom(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNom, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByParentID orders the results by the parent_id field.
|
||||
func ByParentID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldParentID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySlug orders the results by the slug field.
|
||||
func BySlug(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSlug, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIcone orders the results by the icone field.
|
||||
func ByIcone(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIcone, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByParentField orders the results by parent field.
|
||||
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByEnfantsCount orders the results by enfants count.
|
||||
func ByEnfantsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newEnfantsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByEnfants orders the results by enfants terms.
|
||||
func ByEnfants(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newEnfantsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newParentStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
|
||||
)
|
||||
}
|
||||
func newEnfantsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, EnfantsTable, EnfantsColumn),
|
||||
)
|
||||
}
|
||||
473
backend/internal/data/ent/categorie/where.go
Normal file
473
backend/internal/data/ent/categorie/where.go
Normal file
@@ -0,0 +1,473 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package categorie
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Nom applies equality check predicate on the "nom" field. It's identical to NomEQ.
|
||||
func Nom(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ.
|
||||
func ParentID(v uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// Slug applies equality check predicate on the "slug" field. It's identical to SlugEQ.
|
||||
func Slug(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// Icone applies equality check predicate on the "icone" field. It's identical to IconeEQ.
|
||||
func Icone(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NomEQ applies the EQ predicate on the "nom" field.
|
||||
func NomEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomNEQ applies the NEQ predicate on the "nom" field.
|
||||
func NomNEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomIn applies the In predicate on the "nom" field.
|
||||
func NomIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomNotIn applies the NotIn predicate on the "nom" field.
|
||||
func NomNotIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomGT applies the GT predicate on the "nom" field.
|
||||
func NomGT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomGTE applies the GTE predicate on the "nom" field.
|
||||
func NomGTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLT applies the LT predicate on the "nom" field.
|
||||
func NomLT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLTE applies the LTE predicate on the "nom" field.
|
||||
func NomLTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContains applies the Contains predicate on the "nom" field.
|
||||
func NomContains(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContains(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasPrefix applies the HasPrefix predicate on the "nom" field.
|
||||
func NomHasPrefix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasPrefix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasSuffix applies the HasSuffix predicate on the "nom" field.
|
||||
func NomHasSuffix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasSuffix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomEqualFold applies the EqualFold predicate on the "nom" field.
|
||||
func NomEqualFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEqualFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContainsFold applies the ContainsFold predicate on the "nom" field.
|
||||
func NomContainsFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContainsFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// ParentIDEQ applies the EQ predicate on the "parent_id" field.
|
||||
func ParentIDEQ(v uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// ParentIDNEQ applies the NEQ predicate on the "parent_id" field.
|
||||
func ParentIDNEQ(v uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// ParentIDIn applies the In predicate on the "parent_id" field.
|
||||
func ParentIDIn(vs ...uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldParentID, vs...))
|
||||
}
|
||||
|
||||
// ParentIDNotIn applies the NotIn predicate on the "parent_id" field.
|
||||
func ParentIDNotIn(vs ...uuid.UUID) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldParentID, vs...))
|
||||
}
|
||||
|
||||
// ParentIDIsNil applies the IsNil predicate on the "parent_id" field.
|
||||
func ParentIDIsNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIsNull(FieldParentID))
|
||||
}
|
||||
|
||||
// ParentIDNotNil applies the NotNil predicate on the "parent_id" field.
|
||||
func ParentIDNotNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotNull(FieldParentID))
|
||||
}
|
||||
|
||||
// SlugEQ applies the EQ predicate on the "slug" field.
|
||||
func SlugEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugNEQ applies the NEQ predicate on the "slug" field.
|
||||
func SlugNEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugIn applies the In predicate on the "slug" field.
|
||||
func SlugIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldSlug, vs...))
|
||||
}
|
||||
|
||||
// SlugNotIn applies the NotIn predicate on the "slug" field.
|
||||
func SlugNotIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldSlug, vs...))
|
||||
}
|
||||
|
||||
// SlugGT applies the GT predicate on the "slug" field.
|
||||
func SlugGT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugGTE applies the GTE predicate on the "slug" field.
|
||||
func SlugGTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugLT applies the LT predicate on the "slug" field.
|
||||
func SlugLT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugLTE applies the LTE predicate on the "slug" field.
|
||||
func SlugLTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugContains applies the Contains predicate on the "slug" field.
|
||||
func SlugContains(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContains(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugHasPrefix applies the HasPrefix predicate on the "slug" field.
|
||||
func SlugHasPrefix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasPrefix(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugHasSuffix applies the HasSuffix predicate on the "slug" field.
|
||||
func SlugHasSuffix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasSuffix(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugIsNil applies the IsNil predicate on the "slug" field.
|
||||
func SlugIsNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIsNull(FieldSlug))
|
||||
}
|
||||
|
||||
// SlugNotNil applies the NotNil predicate on the "slug" field.
|
||||
func SlugNotNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotNull(FieldSlug))
|
||||
}
|
||||
|
||||
// SlugEqualFold applies the EqualFold predicate on the "slug" field.
|
||||
func SlugEqualFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEqualFold(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugContainsFold applies the ContainsFold predicate on the "slug" field.
|
||||
func SlugContainsFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContainsFold(FieldSlug, v))
|
||||
}
|
||||
|
||||
// IconeEQ applies the EQ predicate on the "icone" field.
|
||||
func IconeEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeNEQ applies the NEQ predicate on the "icone" field.
|
||||
func IconeNEQ(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeIn applies the In predicate on the "icone" field.
|
||||
func IconeIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldIcone, vs...))
|
||||
}
|
||||
|
||||
// IconeNotIn applies the NotIn predicate on the "icone" field.
|
||||
func IconeNotIn(vs ...string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldIcone, vs...))
|
||||
}
|
||||
|
||||
// IconeGT applies the GT predicate on the "icone" field.
|
||||
func IconeGT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeGTE applies the GTE predicate on the "icone" field.
|
||||
func IconeGTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeLT applies the LT predicate on the "icone" field.
|
||||
func IconeLT(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeLTE applies the LTE predicate on the "icone" field.
|
||||
func IconeLTE(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeContains applies the Contains predicate on the "icone" field.
|
||||
func IconeContains(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContains(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeHasPrefix applies the HasPrefix predicate on the "icone" field.
|
||||
func IconeHasPrefix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasPrefix(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeHasSuffix applies the HasSuffix predicate on the "icone" field.
|
||||
func IconeHasSuffix(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldHasSuffix(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeIsNil applies the IsNil predicate on the "icone" field.
|
||||
func IconeIsNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIsNull(FieldIcone))
|
||||
}
|
||||
|
||||
// IconeNotNil applies the NotNil predicate on the "icone" field.
|
||||
func IconeNotNil() predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotNull(FieldIcone))
|
||||
}
|
||||
|
||||
// IconeEqualFold applies the EqualFold predicate on the "icone" field.
|
||||
func IconeEqualFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEqualFold(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeContainsFold applies the ContainsFold predicate on the "icone" field.
|
||||
func IconeContainsFold(v string) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldContainsFold(FieldIcone, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Categorie {
|
||||
return predicate.Categorie(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasParent applies the HasEdge predicate on the "parent" edge.
|
||||
func HasParent() predicate.Categorie {
|
||||
return predicate.Categorie(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates).
|
||||
func HasParentWith(preds ...predicate.Categorie) predicate.Categorie {
|
||||
return predicate.Categorie(func(s *sql.Selector) {
|
||||
step := newParentStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasEnfants applies the HasEdge predicate on the "enfants" edge.
|
||||
func HasEnfants() predicate.Categorie {
|
||||
return predicate.Categorie(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, EnfantsTable, EnfantsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasEnfantsWith applies the HasEdge predicate on the "enfants" edge with a given conditions (other predicates).
|
||||
func HasEnfantsWith(preds ...predicate.Categorie) predicate.Categorie {
|
||||
return predicate.Categorie(func(s *sql.Selector) {
|
||||
step := newEnfantsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Categorie) predicate.Categorie {
|
||||
return predicate.Categorie(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Categorie) predicate.Categorie {
|
||||
return predicate.Categorie(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Categorie) predicate.Categorie {
|
||||
return predicate.Categorie(sql.NotPredicates(p))
|
||||
}
|
||||
372
backend/internal/data/ent/categorie_create.go
Normal file
372
backend/internal/data/ent/categorie_create.go
Normal file
@@ -0,0 +1,372 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// CategorieCreate is the builder for creating a Categorie entity.
|
||||
type CategorieCreate struct {
|
||||
config
|
||||
mutation *CategorieMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetNom sets the "nom" field.
|
||||
func (_c *CategorieCreate) SetNom(v string) *CategorieCreate {
|
||||
_c.mutation.SetNom(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent_id" field.
|
||||
func (_c *CategorieCreate) SetParentID(v uuid.UUID) *CategorieCreate {
|
||||
_c.mutation.SetParentID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableParentID sets the "parent_id" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableParentID(v *uuid.UUID) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetParentID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (_c *CategorieCreate) SetSlug(v string) *CategorieCreate {
|
||||
_c.mutation.SetSlug(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableSlug(v *string) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetSlug(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIcone sets the "icone" field.
|
||||
func (_c *CategorieCreate) SetIcone(v string) *CategorieCreate {
|
||||
_c.mutation.SetIcone(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIcone sets the "icone" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableIcone(v *string) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetIcone(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *CategorieCreate) SetCreatedAt(v time.Time) *CategorieCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableCreatedAt(v *time.Time) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *CategorieCreate) SetUpdatedAt(v time.Time) *CategorieCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableUpdatedAt(v *time.Time) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *CategorieCreate) SetID(v uuid.UUID) *CategorieCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *CategorieCreate) SetNillableID(v *uuid.UUID) *CategorieCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetParent sets the "parent" edge to the Categorie entity.
|
||||
func (_c *CategorieCreate) SetParent(v *Categorie) *CategorieCreate {
|
||||
return _c.SetParentID(v.ID)
|
||||
}
|
||||
|
||||
// AddEnfantIDs adds the "enfants" edge to the Categorie entity by IDs.
|
||||
func (_c *CategorieCreate) AddEnfantIDs(ids ...uuid.UUID) *CategorieCreate {
|
||||
_c.mutation.AddEnfantIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEnfants adds the "enfants" edges to the Categorie entity.
|
||||
func (_c *CategorieCreate) AddEnfants(v ...*Categorie) *CategorieCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CategorieMutation object of the builder.
|
||||
func (_c *CategorieCreate) Mutation() *CategorieMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Categorie in the database.
|
||||
func (_c *CategorieCreate) Save(ctx context.Context) (*Categorie, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *CategorieCreate) SaveX(ctx context.Context) *Categorie {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *CategorieCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *CategorieCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *CategorieCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := categorie.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := categorie.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := categorie.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *CategorieCreate) check() error {
|
||||
if _, ok := _c.mutation.Nom(); !ok {
|
||||
return &ValidationError{Name: "nom", err: errors.New(`ent: missing required field "Categorie.nom"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Nom(); ok {
|
||||
if err := categorie.NomValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom", err: fmt.Errorf(`ent: validator failed for field "Categorie.nom": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Categorie.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Categorie.updated_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *CategorieCreate) sqlSave(ctx context.Context) (*Categorie, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *CategorieCreate) createSpec() (*Categorie, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Categorie{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(categorie.Table, sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.Nom(); ok {
|
||||
_spec.SetField(categorie.FieldNom, field.TypeString, value)
|
||||
_node.Nom = value
|
||||
}
|
||||
if value, ok := _c.mutation.Slug(); ok {
|
||||
_spec.SetField(categorie.FieldSlug, field.TypeString, value)
|
||||
_node.Slug = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Icone(); ok {
|
||||
_spec.SetField(categorie.FieldIcone, field.TypeString, value)
|
||||
_node.Icone = &value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorie.ParentTable,
|
||||
Columns: []string{categorie.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.ParentID = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.EnfantsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// CategorieCreateBulk is the builder for creating many Categorie entities in bulk.
|
||||
type CategorieCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*CategorieCreate
|
||||
}
|
||||
|
||||
// Save creates the Categorie entities in the database.
|
||||
func (_c *CategorieCreateBulk) Save(ctx context.Context) ([]*Categorie, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Categorie, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CategorieMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *CategorieCreateBulk) SaveX(ctx context.Context) []*Categorie {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *CategorieCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *CategorieCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/categorie_delete.go
Normal file
88
backend/internal/data/ent/categorie_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// CategorieDelete is the builder for deleting a Categorie entity.
|
||||
type CategorieDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CategorieMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategorieDelete builder.
|
||||
func (_d *CategorieDelete) Where(ps ...predicate.Categorie) *CategorieDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *CategorieDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *CategorieDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *CategorieDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(categorie.Table, sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// CategorieDeleteOne is the builder for deleting a single Categorie entity.
|
||||
type CategorieDeleteOne struct {
|
||||
_d *CategorieDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategorieDelete builder.
|
||||
func (_d *CategorieDeleteOne) Where(ps ...predicate.Categorie) *CategorieDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *CategorieDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{categorie.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *CategorieDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
686
backend/internal/data/ent/categorie_query.go
Normal file
686
backend/internal/data/ent/categorie_query.go
Normal file
@@ -0,0 +1,686 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// CategorieQuery is the builder for querying Categorie entities.
|
||||
type CategorieQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []categorie.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Categorie
|
||||
withParent *CategorieQuery
|
||||
withEnfants *CategorieQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the CategorieQuery builder.
|
||||
func (_q *CategorieQuery) Where(ps ...predicate.Categorie) *CategorieQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *CategorieQuery) Limit(limit int) *CategorieQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *CategorieQuery) Offset(offset int) *CategorieQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *CategorieQuery) Unique(unique bool) *CategorieQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *CategorieQuery) Order(o ...categorie.OrderOption) *CategorieQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryParent chains the current query on the "parent" edge.
|
||||
func (_q *CategorieQuery) QueryParent() *CategorieQuery {
|
||||
query := (&CategorieClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(categorie.Table, categorie.FieldID, selector),
|
||||
sqlgraph.To(categorie.Table, categorie.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, categorie.ParentTable, categorie.ParentColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEnfants chains the current query on the "enfants" edge.
|
||||
func (_q *CategorieQuery) QueryEnfants() *CategorieQuery {
|
||||
query := (&CategorieClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(categorie.Table, categorie.FieldID, selector),
|
||||
sqlgraph.To(categorie.Table, categorie.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, categorie.EnfantsTable, categorie.EnfantsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Categorie entity from the query.
|
||||
// Returns a *NotFoundError when no Categorie was found.
|
||||
func (_q *CategorieQuery) First(ctx context.Context) (*Categorie, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{categorie.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) FirstX(ctx context.Context) *Categorie {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Categorie ID from the query.
|
||||
// Returns a *NotFoundError when no Categorie ID was found.
|
||||
func (_q *CategorieQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{categorie.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Categorie entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Categorie entity is found.
|
||||
// Returns a *NotFoundError when no Categorie entities are found.
|
||||
func (_q *CategorieQuery) Only(ctx context.Context) (*Categorie, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{categorie.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{categorie.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) OnlyX(ctx context.Context) *Categorie {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Categorie ID in the query.
|
||||
// Returns a *NotSingularError when more than one Categorie ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *CategorieQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{categorie.Label}
|
||||
default:
|
||||
err = &NotSingularError{categorie.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Categories.
|
||||
func (_q *CategorieQuery) All(ctx context.Context) ([]*Categorie, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Categorie, *CategorieQuery]()
|
||||
return withInterceptors[[]*Categorie](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) AllX(ctx context.Context) []*Categorie {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Categorie IDs.
|
||||
func (_q *CategorieQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(categorie.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *CategorieQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*CategorieQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *CategorieQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *CategorieQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the CategorieQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *CategorieQuery) Clone() *CategorieQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &CategorieQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]categorie.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Categorie{}, _q.predicates...),
|
||||
withParent: _q.withParent.Clone(),
|
||||
withEnfants: _q.withEnfants.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithParent tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "parent" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *CategorieQuery) WithParent(opts ...func(*CategorieQuery)) *CategorieQuery {
|
||||
query := (&CategorieClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withParent = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEnfants tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "enfants" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *CategorieQuery) WithEnfants(opts ...func(*CategorieQuery)) *CategorieQuery {
|
||||
query := (&CategorieClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withEnfants = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Categorie.Query().
|
||||
// GroupBy(categorie.FieldNom).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CategorieQuery) GroupBy(field string, fields ...string) *CategorieGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &CategorieGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = categorie.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Categorie.Query().
|
||||
// Select(categorie.FieldNom).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CategorieQuery) Select(fields ...string) *CategorieSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &CategorieSelect{CategorieQuery: _q}
|
||||
sbuild.label = categorie.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a CategorieSelect configured with the given aggregations.
|
||||
func (_q *CategorieQuery) Aggregate(fns ...AggregateFunc) *CategorieSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !categorie.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Categorie, error) {
|
||||
var (
|
||||
nodes = []*Categorie{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
_q.withParent != nil,
|
||||
_q.withEnfants != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Categorie).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Categorie{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withParent; query != nil {
|
||||
if err := _q.loadParent(ctx, query, nodes, nil,
|
||||
func(n *Categorie, e *Categorie) { n.Edges.Parent = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withEnfants; query != nil {
|
||||
if err := _q.loadEnfants(ctx, query, nodes,
|
||||
func(n *Categorie) { n.Edges.Enfants = []*Categorie{} },
|
||||
func(n *Categorie, e *Categorie) { n.Edges.Enfants = append(n.Edges.Enfants, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) loadParent(ctx context.Context, query *CategorieQuery, nodes []*Categorie, init func(*Categorie), assign func(*Categorie, *Categorie)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Categorie)
|
||||
for i := range nodes {
|
||||
if nodes[i].ParentID == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].ParentID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(categorie.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *CategorieQuery) loadEnfants(ctx context.Context, query *CategorieQuery, nodes []*Categorie, init func(*Categorie), assign func(*Categorie, *Categorie)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Categorie)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(categorie.FieldParentID)
|
||||
}
|
||||
query.Where(predicate.Categorie(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(categorie.EnfantsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.ParentID
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "parent_id" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(categorie.Table, categorie.Columns, sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, categorie.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != categorie.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withParent != nil {
|
||||
_spec.Node.AddColumnOnce(categorie.FieldParentID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *CategorieQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(categorie.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = categorie.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// CategorieGroupBy is the group-by builder for Categorie entities.
|
||||
type CategorieGroupBy struct {
|
||||
selector
|
||||
build *CategorieQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *CategorieGroupBy) Aggregate(fns ...AggregateFunc) *CategorieGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *CategorieGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CategorieQuery, *CategorieGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *CategorieGroupBy) sqlScan(ctx context.Context, root *CategorieQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// CategorieSelect is the builder for selecting fields of Categorie entities.
|
||||
type CategorieSelect struct {
|
||||
*CategorieQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *CategorieSelect) Aggregate(fns ...AggregateFunc) *CategorieSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *CategorieSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CategorieQuery, *CategorieSelect](ctx, _s.CategorieQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *CategorieSelect) sqlScan(ctx context.Context, root *CategorieQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
693
backend/internal/data/ent/categorie_update.go
Normal file
693
backend/internal/data/ent/categorie_update.go
Normal file
@@ -0,0 +1,693 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// CategorieUpdate is the builder for updating Categorie entities.
|
||||
type CategorieUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CategorieMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategorieUpdate builder.
|
||||
func (_u *CategorieUpdate) Where(ps ...predicate.Categorie) *CategorieUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNom sets the "nom" field.
|
||||
func (_u *CategorieUpdate) SetNom(v string) *CategorieUpdate {
|
||||
_u.mutation.SetNom(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNom sets the "nom" field if the given value is not nil.
|
||||
func (_u *CategorieUpdate) SetNillableNom(v *string) *CategorieUpdate {
|
||||
if v != nil {
|
||||
_u.SetNom(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent_id" field.
|
||||
func (_u *CategorieUpdate) SetParentID(v uuid.UUID) *CategorieUpdate {
|
||||
_u.mutation.SetParentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableParentID sets the "parent_id" field if the given value is not nil.
|
||||
func (_u *CategorieUpdate) SetNillableParentID(v *uuid.UUID) *CategorieUpdate {
|
||||
if v != nil {
|
||||
_u.SetParentID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearParentID clears the value of the "parent_id" field.
|
||||
func (_u *CategorieUpdate) ClearParentID() *CategorieUpdate {
|
||||
_u.mutation.ClearParentID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (_u *CategorieUpdate) SetSlug(v string) *CategorieUpdate {
|
||||
_u.mutation.SetSlug(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (_u *CategorieUpdate) SetNillableSlug(v *string) *CategorieUpdate {
|
||||
if v != nil {
|
||||
_u.SetSlug(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSlug clears the value of the "slug" field.
|
||||
func (_u *CategorieUpdate) ClearSlug() *CategorieUpdate {
|
||||
_u.mutation.ClearSlug()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIcone sets the "icone" field.
|
||||
func (_u *CategorieUpdate) SetIcone(v string) *CategorieUpdate {
|
||||
_u.mutation.SetIcone(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIcone sets the "icone" field if the given value is not nil.
|
||||
func (_u *CategorieUpdate) SetNillableIcone(v *string) *CategorieUpdate {
|
||||
if v != nil {
|
||||
_u.SetIcone(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIcone clears the value of the "icone" field.
|
||||
func (_u *CategorieUpdate) ClearIcone() *CategorieUpdate {
|
||||
_u.mutation.ClearIcone()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *CategorieUpdate) SetCreatedAt(v time.Time) *CategorieUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *CategorieUpdate) SetNillableCreatedAt(v *time.Time) *CategorieUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *CategorieUpdate) SetUpdatedAt(v time.Time) *CategorieUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetParent sets the "parent" edge to the Categorie entity.
|
||||
func (_u *CategorieUpdate) SetParent(v *Categorie) *CategorieUpdate {
|
||||
return _u.SetParentID(v.ID)
|
||||
}
|
||||
|
||||
// AddEnfantIDs adds the "enfants" edge to the Categorie entity by IDs.
|
||||
func (_u *CategorieUpdate) AddEnfantIDs(ids ...uuid.UUID) *CategorieUpdate {
|
||||
_u.mutation.AddEnfantIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEnfants adds the "enfants" edges to the Categorie entity.
|
||||
func (_u *CategorieUpdate) AddEnfants(v ...*Categorie) *CategorieUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CategorieMutation object of the builder.
|
||||
func (_u *CategorieUpdate) Mutation() *CategorieMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearParent clears the "parent" edge to the Categorie entity.
|
||||
func (_u *CategorieUpdate) ClearParent() *CategorieUpdate {
|
||||
_u.mutation.ClearParent()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEnfants clears all "enfants" edges to the Categorie entity.
|
||||
func (_u *CategorieUpdate) ClearEnfants() *CategorieUpdate {
|
||||
_u.mutation.ClearEnfants()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEnfantIDs removes the "enfants" edge to Categorie entities by IDs.
|
||||
func (_u *CategorieUpdate) RemoveEnfantIDs(ids ...uuid.UUID) *CategorieUpdate {
|
||||
_u.mutation.RemoveEnfantIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEnfants removes "enfants" edges to Categorie entities.
|
||||
func (_u *CategorieUpdate) RemoveEnfants(v ...*Categorie) *CategorieUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *CategorieUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *CategorieUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *CategorieUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *CategorieUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *CategorieUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := categorie.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *CategorieUpdate) check() error {
|
||||
if v, ok := _u.mutation.Nom(); ok {
|
||||
if err := categorie.NomValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom", err: fmt.Errorf(`ent: validator failed for field "Categorie.nom": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *CategorieUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(categorie.Table, categorie.Columns, sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.Nom(); ok {
|
||||
_spec.SetField(categorie.FieldNom, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Slug(); ok {
|
||||
_spec.SetField(categorie.FieldSlug, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SlugCleared() {
|
||||
_spec.ClearField(categorie.FieldSlug, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Icone(); ok {
|
||||
_spec.SetField(categorie.FieldIcone, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.IconeCleared() {
|
||||
_spec.ClearField(categorie.FieldIcone, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorie.ParentTable,
|
||||
Columns: []string{categorie.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorie.ParentTable,
|
||||
Columns: []string{categorie.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.EnfantsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedEnfantsIDs(); len(nodes) > 0 && !_u.mutation.EnfantsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.EnfantsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{categorie.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// CategorieUpdateOne is the builder for updating a single Categorie entity.
|
||||
type CategorieUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *CategorieMutation
|
||||
}
|
||||
|
||||
// SetNom sets the "nom" field.
|
||||
func (_u *CategorieUpdateOne) SetNom(v string) *CategorieUpdateOne {
|
||||
_u.mutation.SetNom(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNom sets the "nom" field if the given value is not nil.
|
||||
func (_u *CategorieUpdateOne) SetNillableNom(v *string) *CategorieUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetNom(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent_id" field.
|
||||
func (_u *CategorieUpdateOne) SetParentID(v uuid.UUID) *CategorieUpdateOne {
|
||||
_u.mutation.SetParentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableParentID sets the "parent_id" field if the given value is not nil.
|
||||
func (_u *CategorieUpdateOne) SetNillableParentID(v *uuid.UUID) *CategorieUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetParentID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearParentID clears the value of the "parent_id" field.
|
||||
func (_u *CategorieUpdateOne) ClearParentID() *CategorieUpdateOne {
|
||||
_u.mutation.ClearParentID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (_u *CategorieUpdateOne) SetSlug(v string) *CategorieUpdateOne {
|
||||
_u.mutation.SetSlug(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (_u *CategorieUpdateOne) SetNillableSlug(v *string) *CategorieUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSlug(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearSlug clears the value of the "slug" field.
|
||||
func (_u *CategorieUpdateOne) ClearSlug() *CategorieUpdateOne {
|
||||
_u.mutation.ClearSlug()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIcone sets the "icone" field.
|
||||
func (_u *CategorieUpdateOne) SetIcone(v string) *CategorieUpdateOne {
|
||||
_u.mutation.SetIcone(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIcone sets the "icone" field if the given value is not nil.
|
||||
func (_u *CategorieUpdateOne) SetNillableIcone(v *string) *CategorieUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIcone(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIcone clears the value of the "icone" field.
|
||||
func (_u *CategorieUpdateOne) ClearIcone() *CategorieUpdateOne {
|
||||
_u.mutation.ClearIcone()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *CategorieUpdateOne) SetCreatedAt(v time.Time) *CategorieUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *CategorieUpdateOne) SetNillableCreatedAt(v *time.Time) *CategorieUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *CategorieUpdateOne) SetUpdatedAt(v time.Time) *CategorieUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetParent sets the "parent" edge to the Categorie entity.
|
||||
func (_u *CategorieUpdateOne) SetParent(v *Categorie) *CategorieUpdateOne {
|
||||
return _u.SetParentID(v.ID)
|
||||
}
|
||||
|
||||
// AddEnfantIDs adds the "enfants" edge to the Categorie entity by IDs.
|
||||
func (_u *CategorieUpdateOne) AddEnfantIDs(ids ...uuid.UUID) *CategorieUpdateOne {
|
||||
_u.mutation.AddEnfantIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEnfants adds the "enfants" edges to the Categorie entity.
|
||||
func (_u *CategorieUpdateOne) AddEnfants(v ...*Categorie) *CategorieUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CategorieMutation object of the builder.
|
||||
func (_u *CategorieUpdateOne) Mutation() *CategorieMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearParent clears the "parent" edge to the Categorie entity.
|
||||
func (_u *CategorieUpdateOne) ClearParent() *CategorieUpdateOne {
|
||||
_u.mutation.ClearParent()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEnfants clears all "enfants" edges to the Categorie entity.
|
||||
func (_u *CategorieUpdateOne) ClearEnfants() *CategorieUpdateOne {
|
||||
_u.mutation.ClearEnfants()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEnfantIDs removes the "enfants" edge to Categorie entities by IDs.
|
||||
func (_u *CategorieUpdateOne) RemoveEnfantIDs(ids ...uuid.UUID) *CategorieUpdateOne {
|
||||
_u.mutation.RemoveEnfantIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveEnfants removes "enfants" edges to Categorie entities.
|
||||
func (_u *CategorieUpdateOne) RemoveEnfants(v ...*Categorie) *CategorieUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategorieUpdate builder.
|
||||
func (_u *CategorieUpdateOne) Where(ps ...predicate.Categorie) *CategorieUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *CategorieUpdateOne) Select(field string, fields ...string) *CategorieUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Categorie entity.
|
||||
func (_u *CategorieUpdateOne) Save(ctx context.Context) (*Categorie, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *CategorieUpdateOne) SaveX(ctx context.Context) *Categorie {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *CategorieUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *CategorieUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *CategorieUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := categorie.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *CategorieUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Nom(); ok {
|
||||
if err := categorie.NomValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom", err: fmt.Errorf(`ent: validator failed for field "Categorie.nom": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *CategorieUpdateOne) sqlSave(ctx context.Context) (_node *Categorie, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(categorie.Table, categorie.Columns, sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Categorie.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, categorie.FieldID)
|
||||
for _, f := range fields {
|
||||
if !categorie.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != categorie.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.Nom(); ok {
|
||||
_spec.SetField(categorie.FieldNom, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Slug(); ok {
|
||||
_spec.SetField(categorie.FieldSlug, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.SlugCleared() {
|
||||
_spec.ClearField(categorie.FieldSlug, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Icone(); ok {
|
||||
_spec.SetField(categorie.FieldIcone, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.IconeCleared() {
|
||||
_spec.ClearField(categorie.FieldIcone, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(categorie.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorie.ParentTable,
|
||||
Columns: []string{categorie.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorie.ParentTable,
|
||||
Columns: []string{categorie.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.EnfantsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedEnfantsIDs(); len(nodes) > 0 && !_u.mutation.EnfantsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.EnfantsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: categorie.EnfantsTable,
|
||||
Columns: []string{categorie.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(categorie.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Categorie{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{categorie.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
209
backend/internal/data/ent/champpersonnalise.go
Normal file
209
backend/internal/data/ent/champpersonnalise.go
Normal file
@@ -0,0 +1,209 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ChampPersonnalise is the model entity for the ChampPersonnalise schema.
|
||||
type ChampPersonnalise struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique du champ
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Identifiant de l'objet
|
||||
ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Nom du champ
|
||||
NomChamp string `json:"nom_champ,omitempty"`
|
||||
// Type du champ
|
||||
TypeChamp champpersonnalise.TypeChamp `json:"type_champ,omitempty"`
|
||||
// Valeur stockee en texte
|
||||
Valeur *string `json:"valeur,omitempty"`
|
||||
// Unite (si applicable)
|
||||
Unite *string `json:"unite,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ChampPersonnaliseQuery when eager-loading is set.
|
||||
Edges ChampPersonnaliseEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ChampPersonnaliseEdges holds the relations/edges for other nodes in the graph.
|
||||
type ChampPersonnaliseEdges struct {
|
||||
// Objet holds the value of the objet edge.
|
||||
Objet *Objet `json:"objet,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ObjetOrErr returns the Objet value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ChampPersonnaliseEdges) ObjetOrErr() (*Objet, error) {
|
||||
if e.Objet != nil {
|
||||
return e.Objet, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: objet.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "objet"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*ChampPersonnalise) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case champpersonnalise.FieldNomChamp, champpersonnalise.FieldTypeChamp, champpersonnalise.FieldValeur, champpersonnalise.FieldUnite:
|
||||
values[i] = new(sql.NullString)
|
||||
case champpersonnalise.FieldCreatedAt, champpersonnalise.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case champpersonnalise.FieldID, champpersonnalise.FieldObjetID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the ChampPersonnalise fields.
|
||||
func (_m *ChampPersonnalise) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case champpersonnalise.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case champpersonnalise.FieldObjetID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field objet_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ObjetID = *value
|
||||
}
|
||||
case champpersonnalise.FieldNomChamp:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nom_champ", values[i])
|
||||
} else if value.Valid {
|
||||
_m.NomChamp = value.String
|
||||
}
|
||||
case champpersonnalise.FieldTypeChamp:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type_champ", values[i])
|
||||
} else if value.Valid {
|
||||
_m.TypeChamp = champpersonnalise.TypeChamp(value.String)
|
||||
}
|
||||
case champpersonnalise.FieldValeur:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field valeur", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Valeur = new(string)
|
||||
*_m.Valeur = value.String
|
||||
}
|
||||
case champpersonnalise.FieldUnite:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field unite", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Unite = new(string)
|
||||
*_m.Unite = value.String
|
||||
}
|
||||
case champpersonnalise.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case champpersonnalise.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the ChampPersonnalise.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *ChampPersonnalise) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryObjet queries the "objet" edge of the ChampPersonnalise entity.
|
||||
func (_m *ChampPersonnalise) QueryObjet() *ObjetQuery {
|
||||
return NewChampPersonnaliseClient(_m.config).QueryObjet(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ChampPersonnalise.
|
||||
// Note that you need to call ChampPersonnalise.Unwrap() before calling this method if this ChampPersonnalise
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *ChampPersonnalise) Update() *ChampPersonnaliseUpdateOne {
|
||||
return NewChampPersonnaliseClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the ChampPersonnalise entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *ChampPersonnalise) Unwrap() *ChampPersonnalise {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: ChampPersonnalise is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *ChampPersonnalise) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ChampPersonnalise(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("objet_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ObjetID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("nom_champ=")
|
||||
builder.WriteString(_m.NomChamp)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type_champ=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TypeChamp))
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Valeur; v != nil {
|
||||
builder.WriteString("valeur=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Unite; v != nil {
|
||||
builder.WriteString("unite=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// ChampPersonnalises is a parsable slice of ChampPersonnalise.
|
||||
type ChampPersonnalises []*ChampPersonnalise
|
||||
164
backend/internal/data/ent/champpersonnalise/champpersonnalise.go
Normal file
164
backend/internal/data/ent/champpersonnalise/champpersonnalise.go
Normal file
@@ -0,0 +1,164 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package champpersonnalise
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the champpersonnalise type in the database.
|
||||
Label = "champ_personnalise"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldObjetID holds the string denoting the objet_id field in the database.
|
||||
FieldObjetID = "objet_id"
|
||||
// FieldNomChamp holds the string denoting the nom_champ field in the database.
|
||||
FieldNomChamp = "nom_champ"
|
||||
// FieldTypeChamp holds the string denoting the type_champ field in the database.
|
||||
FieldTypeChamp = "type_champ"
|
||||
// FieldValeur holds the string denoting the valeur field in the database.
|
||||
FieldValeur = "valeur"
|
||||
// FieldUnite holds the string denoting the unite field in the database.
|
||||
FieldUnite = "unite"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeObjet holds the string denoting the objet edge name in mutations.
|
||||
EdgeObjet = "objet"
|
||||
// Table holds the table name of the champpersonnalise in the database.
|
||||
Table = "champ_personnalise"
|
||||
// ObjetTable is the table that holds the objet relation/edge.
|
||||
ObjetTable = "champ_personnalise"
|
||||
// ObjetInverseTable is the table name for the Objet entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "objet" package.
|
||||
ObjetInverseTable = "objet"
|
||||
// ObjetColumn is the table column denoting the objet relation/edge.
|
||||
ObjetColumn = "objet_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for champpersonnalise fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldObjetID,
|
||||
FieldNomChamp,
|
||||
FieldTypeChamp,
|
||||
FieldValeur,
|
||||
FieldUnite,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NomChampValidator is a validator for the "nom_champ" field. It is called by the builders before save.
|
||||
NomChampValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// TypeChamp defines the type for the "type_champ" enum field.
|
||||
type TypeChamp string
|
||||
|
||||
// TypeChampString is the default value of the TypeChamp enum.
|
||||
const DefaultTypeChamp = TypeChampString
|
||||
|
||||
// TypeChamp values.
|
||||
const (
|
||||
TypeChampString TypeChamp = "string"
|
||||
TypeChampInt TypeChamp = "int"
|
||||
TypeChampBool TypeChamp = "bool"
|
||||
TypeChampDate TypeChamp = "date"
|
||||
)
|
||||
|
||||
func (tc TypeChamp) String() string {
|
||||
return string(tc)
|
||||
}
|
||||
|
||||
// TypeChampValidator is a validator for the "type_champ" field enum values. It is called by the builders before save.
|
||||
func TypeChampValidator(tc TypeChamp) error {
|
||||
switch tc {
|
||||
case TypeChampString, TypeChampInt, TypeChampBool, TypeChampDate:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("champpersonnalise: invalid enum value for type_champ field: %q", tc)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the ChampPersonnalise queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetID orders the results by the objet_id field.
|
||||
func ByObjetID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldObjetID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNomChamp orders the results by the nom_champ field.
|
||||
func ByNomChamp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNomChamp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTypeChamp orders the results by the type_champ field.
|
||||
func ByTypeChamp(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTypeChamp, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByValeur orders the results by the valeur field.
|
||||
func ByValeur(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldValeur, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUnite orders the results by the unite field.
|
||||
func ByUnite(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUnite, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetField orders the results by objet field.
|
||||
func ByObjetField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newObjetStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newObjetStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ObjetInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
}
|
||||
460
backend/internal/data/ent/champpersonnalise/where.go
Normal file
460
backend/internal/data/ent/champpersonnalise/where.go
Normal file
@@ -0,0 +1,460 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package champpersonnalise
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// ObjetID applies equality check predicate on the "objet_id" field. It's identical to ObjetIDEQ.
|
||||
func ObjetID(v uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// NomChamp applies equality check predicate on the "nom_champ" field. It's identical to NomChampEQ.
|
||||
func NomChamp(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// Valeur applies equality check predicate on the "valeur" field. It's identical to ValeurEQ.
|
||||
func Valeur(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldValeur, v))
|
||||
}
|
||||
|
||||
// Unite applies equality check predicate on the "unite" field. It's identical to UniteEQ.
|
||||
func Unite(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldUnite, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// ObjetIDEQ applies the EQ predicate on the "objet_id" field.
|
||||
func ObjetIDEQ(v uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDNEQ applies the NEQ predicate on the "objet_id" field.
|
||||
func ObjetIDNEQ(v uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDIn applies the In predicate on the "objet_id" field.
|
||||
func ObjetIDIn(vs ...uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// ObjetIDNotIn applies the NotIn predicate on the "objet_id" field.
|
||||
func ObjetIDNotIn(vs ...uuid.UUID) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// NomChampEQ applies the EQ predicate on the "nom_champ" field.
|
||||
func NomChampEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampNEQ applies the NEQ predicate on the "nom_champ" field.
|
||||
func NomChampNEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampIn applies the In predicate on the "nom_champ" field.
|
||||
func NomChampIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldNomChamp, vs...))
|
||||
}
|
||||
|
||||
// NomChampNotIn applies the NotIn predicate on the "nom_champ" field.
|
||||
func NomChampNotIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldNomChamp, vs...))
|
||||
}
|
||||
|
||||
// NomChampGT applies the GT predicate on the "nom_champ" field.
|
||||
func NomChampGT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampGTE applies the GTE predicate on the "nom_champ" field.
|
||||
func NomChampGTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampLT applies the LT predicate on the "nom_champ" field.
|
||||
func NomChampLT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampLTE applies the LTE predicate on the "nom_champ" field.
|
||||
func NomChampLTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampContains applies the Contains predicate on the "nom_champ" field.
|
||||
func NomChampContains(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContains(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampHasPrefix applies the HasPrefix predicate on the "nom_champ" field.
|
||||
func NomChampHasPrefix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasPrefix(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampHasSuffix applies the HasSuffix predicate on the "nom_champ" field.
|
||||
func NomChampHasSuffix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasSuffix(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampEqualFold applies the EqualFold predicate on the "nom_champ" field.
|
||||
func NomChampEqualFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEqualFold(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// NomChampContainsFold applies the ContainsFold predicate on the "nom_champ" field.
|
||||
func NomChampContainsFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContainsFold(FieldNomChamp, v))
|
||||
}
|
||||
|
||||
// TypeChampEQ applies the EQ predicate on the "type_champ" field.
|
||||
func TypeChampEQ(v TypeChamp) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldTypeChamp, v))
|
||||
}
|
||||
|
||||
// TypeChampNEQ applies the NEQ predicate on the "type_champ" field.
|
||||
func TypeChampNEQ(v TypeChamp) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldTypeChamp, v))
|
||||
}
|
||||
|
||||
// TypeChampIn applies the In predicate on the "type_champ" field.
|
||||
func TypeChampIn(vs ...TypeChamp) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldTypeChamp, vs...))
|
||||
}
|
||||
|
||||
// TypeChampNotIn applies the NotIn predicate on the "type_champ" field.
|
||||
func TypeChampNotIn(vs ...TypeChamp) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldTypeChamp, vs...))
|
||||
}
|
||||
|
||||
// ValeurEQ applies the EQ predicate on the "valeur" field.
|
||||
func ValeurEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurNEQ applies the NEQ predicate on the "valeur" field.
|
||||
func ValeurNEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurIn applies the In predicate on the "valeur" field.
|
||||
func ValeurIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldValeur, vs...))
|
||||
}
|
||||
|
||||
// ValeurNotIn applies the NotIn predicate on the "valeur" field.
|
||||
func ValeurNotIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldValeur, vs...))
|
||||
}
|
||||
|
||||
// ValeurGT applies the GT predicate on the "valeur" field.
|
||||
func ValeurGT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurGTE applies the GTE predicate on the "valeur" field.
|
||||
func ValeurGTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurLT applies the LT predicate on the "valeur" field.
|
||||
func ValeurLT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurLTE applies the LTE predicate on the "valeur" field.
|
||||
func ValeurLTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurContains applies the Contains predicate on the "valeur" field.
|
||||
func ValeurContains(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContains(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurHasPrefix applies the HasPrefix predicate on the "valeur" field.
|
||||
func ValeurHasPrefix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasPrefix(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurHasSuffix applies the HasSuffix predicate on the "valeur" field.
|
||||
func ValeurHasSuffix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasSuffix(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurIsNil applies the IsNil predicate on the "valeur" field.
|
||||
func ValeurIsNil() predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIsNull(FieldValeur))
|
||||
}
|
||||
|
||||
// ValeurNotNil applies the NotNil predicate on the "valeur" field.
|
||||
func ValeurNotNil() predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotNull(FieldValeur))
|
||||
}
|
||||
|
||||
// ValeurEqualFold applies the EqualFold predicate on the "valeur" field.
|
||||
func ValeurEqualFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEqualFold(FieldValeur, v))
|
||||
}
|
||||
|
||||
// ValeurContainsFold applies the ContainsFold predicate on the "valeur" field.
|
||||
func ValeurContainsFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContainsFold(FieldValeur, v))
|
||||
}
|
||||
|
||||
// UniteEQ applies the EQ predicate on the "unite" field.
|
||||
func UniteEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteNEQ applies the NEQ predicate on the "unite" field.
|
||||
func UniteNEQ(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteIn applies the In predicate on the "unite" field.
|
||||
func UniteIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldUnite, vs...))
|
||||
}
|
||||
|
||||
// UniteNotIn applies the NotIn predicate on the "unite" field.
|
||||
func UniteNotIn(vs ...string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldUnite, vs...))
|
||||
}
|
||||
|
||||
// UniteGT applies the GT predicate on the "unite" field.
|
||||
func UniteGT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteGTE applies the GTE predicate on the "unite" field.
|
||||
func UniteGTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteLT applies the LT predicate on the "unite" field.
|
||||
func UniteLT(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteLTE applies the LTE predicate on the "unite" field.
|
||||
func UniteLTE(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteContains applies the Contains predicate on the "unite" field.
|
||||
func UniteContains(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContains(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteHasPrefix applies the HasPrefix predicate on the "unite" field.
|
||||
func UniteHasPrefix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasPrefix(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteHasSuffix applies the HasSuffix predicate on the "unite" field.
|
||||
func UniteHasSuffix(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldHasSuffix(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteIsNil applies the IsNil predicate on the "unite" field.
|
||||
func UniteIsNil() predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIsNull(FieldUnite))
|
||||
}
|
||||
|
||||
// UniteNotNil applies the NotNil predicate on the "unite" field.
|
||||
func UniteNotNil() predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotNull(FieldUnite))
|
||||
}
|
||||
|
||||
// UniteEqualFold applies the EqualFold predicate on the "unite" field.
|
||||
func UniteEqualFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEqualFold(FieldUnite, v))
|
||||
}
|
||||
|
||||
// UniteContainsFold applies the ContainsFold predicate on the "unite" field.
|
||||
func UniteContainsFold(v string) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldContainsFold(FieldUnite, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasObjet applies the HasEdge predicate on the "objet" edge.
|
||||
func HasObjet() predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasObjetWith applies the HasEdge predicate on the "objet" edge with a given conditions (other predicates).
|
||||
func HasObjetWith(preds ...predicate.Objet) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(func(s *sql.Selector) {
|
||||
step := newObjetStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ChampPersonnalise) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.ChampPersonnalise) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.ChampPersonnalise) predicate.ChampPersonnalise {
|
||||
return predicate.ChampPersonnalise(sql.NotPredicates(p))
|
||||
}
|
||||
370
backend/internal/data/ent/champpersonnalise_create.go
Normal file
370
backend/internal/data/ent/champpersonnalise_create.go
Normal file
@@ -0,0 +1,370 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ChampPersonnaliseCreate is the builder for creating a ChampPersonnalise entity.
|
||||
type ChampPersonnaliseCreate struct {
|
||||
config
|
||||
mutation *ChampPersonnaliseMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetObjetID(v uuid.UUID) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetObjetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNomChamp sets the "nom_champ" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetNomChamp(v string) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetNomChamp(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTypeChamp sets the "type_champ" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetTypeChamp(v champpersonnalise.TypeChamp) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetTypeChamp(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTypeChamp sets the "type_champ" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableTypeChamp(v *champpersonnalise.TypeChamp) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetTypeChamp(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetValeur sets the "valeur" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetValeur(v string) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetValeur(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableValeur sets the "valeur" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableValeur(v *string) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetValeur(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUnite sets the "unite" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetUnite(v string) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetUnite(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUnite sets the "unite" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableUnite(v *string) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetUnite(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetCreatedAt(v time.Time) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableCreatedAt(v *time.Time) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetUpdatedAt(v time.Time) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableUpdatedAt(v *time.Time) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *ChampPersonnaliseCreate) SetID(v uuid.UUID) *ChampPersonnaliseCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *ChampPersonnaliseCreate) SetNillableID(v *uuid.UUID) *ChampPersonnaliseCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_c *ChampPersonnaliseCreate) SetObjet(v *Objet) *ChampPersonnaliseCreate {
|
||||
return _c.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ChampPersonnaliseMutation object of the builder.
|
||||
func (_c *ChampPersonnaliseCreate) Mutation() *ChampPersonnaliseMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the ChampPersonnalise in the database.
|
||||
func (_c *ChampPersonnaliseCreate) Save(ctx context.Context) (*ChampPersonnalise, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *ChampPersonnaliseCreate) SaveX(ctx context.Context) *ChampPersonnalise {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ChampPersonnaliseCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ChampPersonnaliseCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *ChampPersonnaliseCreate) defaults() {
|
||||
if _, ok := _c.mutation.TypeChamp(); !ok {
|
||||
v := champpersonnalise.DefaultTypeChamp
|
||||
_c.mutation.SetTypeChamp(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := champpersonnalise.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := champpersonnalise.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := champpersonnalise.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *ChampPersonnaliseCreate) check() error {
|
||||
if _, ok := _c.mutation.ObjetID(); !ok {
|
||||
return &ValidationError{Name: "objet_id", err: errors.New(`ent: missing required field "ChampPersonnalise.objet_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.NomChamp(); !ok {
|
||||
return &ValidationError{Name: "nom_champ", err: errors.New(`ent: missing required field "ChampPersonnalise.nom_champ"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.NomChamp(); ok {
|
||||
if err := champpersonnalise.NomChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.nom_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.TypeChamp(); !ok {
|
||||
return &ValidationError{Name: "type_champ", err: errors.New(`ent: missing required field "ChampPersonnalise.type_champ"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.TypeChamp(); ok {
|
||||
if err := champpersonnalise.TypeChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.type_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ChampPersonnalise.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ChampPersonnalise.updated_at"`)}
|
||||
}
|
||||
if len(_c.mutation.ObjetIDs()) == 0 {
|
||||
return &ValidationError{Name: "objet", err: errors.New(`ent: missing required edge "ChampPersonnalise.objet"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *ChampPersonnaliseCreate) sqlSave(ctx context.Context) (*ChampPersonnalise, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *ChampPersonnaliseCreate) createSpec() (*ChampPersonnalise, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &ChampPersonnalise{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(champpersonnalise.Table, sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.NomChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldNomChamp, field.TypeString, value)
|
||||
_node.NomChamp = value
|
||||
}
|
||||
if value, ok := _c.mutation.TypeChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldTypeChamp, field.TypeEnum, value)
|
||||
_node.TypeChamp = value
|
||||
}
|
||||
if value, ok := _c.mutation.Valeur(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldValeur, field.TypeString, value)
|
||||
_node.Valeur = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Unite(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUnite, field.TypeString, value)
|
||||
_node.Unite = &value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: champpersonnalise.ObjetTable,
|
||||
Columns: []string{champpersonnalise.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.ObjetID = nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// ChampPersonnaliseCreateBulk is the builder for creating many ChampPersonnalise entities in bulk.
|
||||
type ChampPersonnaliseCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*ChampPersonnaliseCreate
|
||||
}
|
||||
|
||||
// Save creates the ChampPersonnalise entities in the database.
|
||||
func (_c *ChampPersonnaliseCreateBulk) Save(ctx context.Context) ([]*ChampPersonnalise, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*ChampPersonnalise, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ChampPersonnaliseMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *ChampPersonnaliseCreateBulk) SaveX(ctx context.Context) []*ChampPersonnalise {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ChampPersonnaliseCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ChampPersonnaliseCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/champpersonnalise_delete.go
Normal file
88
backend/internal/data/ent/champpersonnalise_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ChampPersonnaliseDelete is the builder for deleting a ChampPersonnalise entity.
|
||||
type ChampPersonnaliseDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ChampPersonnaliseMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ChampPersonnaliseDelete builder.
|
||||
func (_d *ChampPersonnaliseDelete) Where(ps ...predicate.ChampPersonnalise) *ChampPersonnaliseDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *ChampPersonnaliseDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ChampPersonnaliseDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *ChampPersonnaliseDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(champpersonnalise.Table, sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ChampPersonnaliseDeleteOne is the builder for deleting a single ChampPersonnalise entity.
|
||||
type ChampPersonnaliseDeleteOne struct {
|
||||
_d *ChampPersonnaliseDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ChampPersonnaliseDelete builder.
|
||||
func (_d *ChampPersonnaliseDeleteOne) Where(ps ...predicate.ChampPersonnalise) *ChampPersonnaliseDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *ChampPersonnaliseDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{champpersonnalise.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ChampPersonnaliseDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
607
backend/internal/data/ent/champpersonnalise_query.go
Normal file
607
backend/internal/data/ent/champpersonnalise_query.go
Normal file
@@ -0,0 +1,607 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ChampPersonnaliseQuery is the builder for querying ChampPersonnalise entities.
|
||||
type ChampPersonnaliseQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []champpersonnalise.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ChampPersonnalise
|
||||
withObjet *ObjetQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the ChampPersonnaliseQuery builder.
|
||||
func (_q *ChampPersonnaliseQuery) Where(ps ...predicate.ChampPersonnalise) *ChampPersonnaliseQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *ChampPersonnaliseQuery) Limit(limit int) *ChampPersonnaliseQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *ChampPersonnaliseQuery) Offset(offset int) *ChampPersonnaliseQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *ChampPersonnaliseQuery) Unique(unique bool) *ChampPersonnaliseQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *ChampPersonnaliseQuery) Order(o ...champpersonnalise.OrderOption) *ChampPersonnaliseQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryObjet chains the current query on the "objet" edge.
|
||||
func (_q *ChampPersonnaliseQuery) QueryObjet() *ObjetQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(champpersonnalise.Table, champpersonnalise.FieldID, selector),
|
||||
sqlgraph.To(objet.Table, objet.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, champpersonnalise.ObjetTable, champpersonnalise.ObjetColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ChampPersonnalise entity from the query.
|
||||
// Returns a *NotFoundError when no ChampPersonnalise was found.
|
||||
func (_q *ChampPersonnaliseQuery) First(ctx context.Context) (*ChampPersonnalise, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{champpersonnalise.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) FirstX(ctx context.Context) *ChampPersonnalise {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first ChampPersonnalise ID from the query.
|
||||
// Returns a *NotFoundError when no ChampPersonnalise ID was found.
|
||||
func (_q *ChampPersonnaliseQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{champpersonnalise.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single ChampPersonnalise entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one ChampPersonnalise entity is found.
|
||||
// Returns a *NotFoundError when no ChampPersonnalise entities are found.
|
||||
func (_q *ChampPersonnaliseQuery) Only(ctx context.Context) (*ChampPersonnalise, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{champpersonnalise.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{champpersonnalise.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) OnlyX(ctx context.Context) *ChampPersonnalise {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only ChampPersonnalise ID in the query.
|
||||
// Returns a *NotSingularError when more than one ChampPersonnalise ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *ChampPersonnaliseQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{champpersonnalise.Label}
|
||||
default:
|
||||
err = &NotSingularError{champpersonnalise.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of ChampPersonnalises.
|
||||
func (_q *ChampPersonnaliseQuery) All(ctx context.Context) ([]*ChampPersonnalise, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*ChampPersonnalise, *ChampPersonnaliseQuery]()
|
||||
return withInterceptors[[]*ChampPersonnalise](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) AllX(ctx context.Context) []*ChampPersonnalise {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of ChampPersonnalise IDs.
|
||||
func (_q *ChampPersonnaliseQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(champpersonnalise.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *ChampPersonnaliseQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*ChampPersonnaliseQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *ChampPersonnaliseQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *ChampPersonnaliseQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the ChampPersonnaliseQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *ChampPersonnaliseQuery) Clone() *ChampPersonnaliseQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &ChampPersonnaliseQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]champpersonnalise.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.ChampPersonnalise{}, _q.predicates...),
|
||||
withObjet: _q.withObjet.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithObjet tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "objet" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ChampPersonnaliseQuery) WithObjet(opts ...func(*ObjetQuery)) *ChampPersonnaliseQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withObjet = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChampPersonnalise.Query().
|
||||
// GroupBy(champpersonnalise.FieldObjetID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChampPersonnaliseQuery) GroupBy(field string, fields ...string) *ChampPersonnaliseGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &ChampPersonnaliseGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = champpersonnalise.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.ChampPersonnalise.Query().
|
||||
// Select(champpersonnalise.FieldObjetID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ChampPersonnaliseQuery) Select(fields ...string) *ChampPersonnaliseSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &ChampPersonnaliseSelect{ChampPersonnaliseQuery: _q}
|
||||
sbuild.label = champpersonnalise.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ChampPersonnaliseSelect configured with the given aggregations.
|
||||
func (_q *ChampPersonnaliseQuery) Aggregate(fns ...AggregateFunc) *ChampPersonnaliseSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !champpersonnalise.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ChampPersonnalise, error) {
|
||||
var (
|
||||
nodes = []*ChampPersonnalise{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
_q.withObjet != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ChampPersonnalise).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ChampPersonnalise{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withObjet; query != nil {
|
||||
if err := _q.loadObjet(ctx, query, nodes, nil,
|
||||
func(n *ChampPersonnalise, e *Objet) { n.Edges.Objet = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) loadObjet(ctx context.Context, query *ObjetQuery, nodes []*ChampPersonnalise, init func(*ChampPersonnalise), assign func(*ChampPersonnalise, *Objet)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*ChampPersonnalise)
|
||||
for i := range nodes {
|
||||
fk := nodes[i].ObjetID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(objet.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "objet_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(champpersonnalise.Table, champpersonnalise.Columns, sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, champpersonnalise.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != champpersonnalise.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withObjet != nil {
|
||||
_spec.Node.AddColumnOnce(champpersonnalise.FieldObjetID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *ChampPersonnaliseQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(champpersonnalise.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = champpersonnalise.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ChampPersonnaliseGroupBy is the group-by builder for ChampPersonnalise entities.
|
||||
type ChampPersonnaliseGroupBy struct {
|
||||
selector
|
||||
build *ChampPersonnaliseQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *ChampPersonnaliseGroupBy) Aggregate(fns ...AggregateFunc) *ChampPersonnaliseGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *ChampPersonnaliseGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ChampPersonnaliseQuery, *ChampPersonnaliseGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *ChampPersonnaliseGroupBy) sqlScan(ctx context.Context, root *ChampPersonnaliseQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// ChampPersonnaliseSelect is the builder for selecting fields of ChampPersonnalise entities.
|
||||
type ChampPersonnaliseSelect struct {
|
||||
*ChampPersonnaliseQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *ChampPersonnaliseSelect) Aggregate(fns ...AggregateFunc) *ChampPersonnaliseSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *ChampPersonnaliseSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ChampPersonnaliseQuery, *ChampPersonnaliseSelect](ctx, _s.ChampPersonnaliseQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *ChampPersonnaliseSelect) sqlScan(ctx context.Context, root *ChampPersonnaliseQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
570
backend/internal/data/ent/champpersonnalise_update.go
Normal file
570
backend/internal/data/ent/champpersonnalise_update.go
Normal file
@@ -0,0 +1,570 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ChampPersonnaliseUpdate is the builder for updating ChampPersonnalise entities.
|
||||
type ChampPersonnaliseUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ChampPersonnaliseMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ChampPersonnaliseUpdate builder.
|
||||
func (_u *ChampPersonnaliseUpdate) Where(ps ...predicate.ChampPersonnalise) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetObjetID(v uuid.UUID) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableObjetID(v *uuid.UUID) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNomChamp sets the "nom_champ" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNomChamp(v string) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetNomChamp(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNomChamp sets the "nom_champ" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableNomChamp(v *string) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetNomChamp(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTypeChamp sets the "type_champ" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetTypeChamp(v champpersonnalise.TypeChamp) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetTypeChamp(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTypeChamp sets the "type_champ" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableTypeChamp(v *champpersonnalise.TypeChamp) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetTypeChamp(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetValeur sets the "valeur" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetValeur(v string) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetValeur(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableValeur sets the "valeur" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableValeur(v *string) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetValeur(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearValeur clears the value of the "valeur" field.
|
||||
func (_u *ChampPersonnaliseUpdate) ClearValeur() *ChampPersonnaliseUpdate {
|
||||
_u.mutation.ClearValeur()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUnite sets the "unite" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetUnite(v string) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetUnite(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUnite sets the "unite" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableUnite(v *string) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetUnite(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUnite clears the value of the "unite" field.
|
||||
func (_u *ChampPersonnaliseUpdate) ClearUnite() *ChampPersonnaliseUpdate {
|
||||
_u.mutation.ClearUnite()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetCreatedAt(v time.Time) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdate) SetNillableCreatedAt(v *time.Time) *ChampPersonnaliseUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *ChampPersonnaliseUpdate) SetUpdatedAt(v time.Time) *ChampPersonnaliseUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *ChampPersonnaliseUpdate) SetObjet(v *Objet) *ChampPersonnaliseUpdate {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ChampPersonnaliseMutation object of the builder.
|
||||
func (_u *ChampPersonnaliseUpdate) Mutation() *ChampPersonnaliseMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *ChampPersonnaliseUpdate) ClearObjet() *ChampPersonnaliseUpdate {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *ChampPersonnaliseUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *ChampPersonnaliseUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *ChampPersonnaliseUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *ChampPersonnaliseUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *ChampPersonnaliseUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := champpersonnalise.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *ChampPersonnaliseUpdate) check() error {
|
||||
if v, ok := _u.mutation.NomChamp(); ok {
|
||||
if err := champpersonnalise.NomChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.nom_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TypeChamp(); ok {
|
||||
if err := champpersonnalise.TypeChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.type_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "ChampPersonnalise.objet"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *ChampPersonnaliseUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(champpersonnalise.Table, champpersonnalise.Columns, sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.NomChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldNomChamp, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TypeChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldTypeChamp, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Valeur(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldValeur, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ValeurCleared() {
|
||||
_spec.ClearField(champpersonnalise.FieldValeur, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Unite(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUnite, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UniteCleared() {
|
||||
_spec.ClearField(champpersonnalise.FieldUnite, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: champpersonnalise.ObjetTable,
|
||||
Columns: []string{champpersonnalise.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: champpersonnalise.ObjetTable,
|
||||
Columns: []string{champpersonnalise.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{champpersonnalise.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// ChampPersonnaliseUpdateOne is the builder for updating a single ChampPersonnalise entity.
|
||||
type ChampPersonnaliseUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *ChampPersonnaliseMutation
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetObjetID(v uuid.UUID) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableObjetID(v *uuid.UUID) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNomChamp sets the "nom_champ" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNomChamp(v string) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetNomChamp(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNomChamp sets the "nom_champ" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableNomChamp(v *string) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetNomChamp(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTypeChamp sets the "type_champ" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetTypeChamp(v champpersonnalise.TypeChamp) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetTypeChamp(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTypeChamp sets the "type_champ" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableTypeChamp(v *champpersonnalise.TypeChamp) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTypeChamp(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetValeur sets the "valeur" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetValeur(v string) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetValeur(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableValeur sets the "valeur" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableValeur(v *string) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetValeur(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearValeur clears the value of the "valeur" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) ClearValeur() *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.ClearValeur()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUnite sets the "unite" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetUnite(v string) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetUnite(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUnite sets the "unite" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableUnite(v *string) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUnite(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUnite clears the value of the "unite" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) ClearUnite() *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.ClearUnite()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetCreatedAt(v time.Time) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetNillableCreatedAt(v *time.Time) *ChampPersonnaliseUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetUpdatedAt(v time.Time) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SetObjet(v *Objet) *ChampPersonnaliseUpdateOne {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ChampPersonnaliseMutation object of the builder.
|
||||
func (_u *ChampPersonnaliseUpdateOne) Mutation() *ChampPersonnaliseMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *ChampPersonnaliseUpdateOne) ClearObjet() *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ChampPersonnaliseUpdate builder.
|
||||
func (_u *ChampPersonnaliseUpdateOne) Where(ps ...predicate.ChampPersonnalise) *ChampPersonnaliseUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *ChampPersonnaliseUpdateOne) Select(field string, fields ...string) *ChampPersonnaliseUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated ChampPersonnalise entity.
|
||||
func (_u *ChampPersonnaliseUpdateOne) Save(ctx context.Context) (*ChampPersonnalise, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *ChampPersonnaliseUpdateOne) SaveX(ctx context.Context) *ChampPersonnalise {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *ChampPersonnaliseUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *ChampPersonnaliseUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *ChampPersonnaliseUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := champpersonnalise.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *ChampPersonnaliseUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.NomChamp(); ok {
|
||||
if err := champpersonnalise.NomChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.nom_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TypeChamp(); ok {
|
||||
if err := champpersonnalise.TypeChampValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_champ", err: fmt.Errorf(`ent: validator failed for field "ChampPersonnalise.type_champ": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "ChampPersonnalise.objet"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *ChampPersonnaliseUpdateOne) sqlSave(ctx context.Context) (_node *ChampPersonnalise, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(champpersonnalise.Table, champpersonnalise.Columns, sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ChampPersonnalise.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, champpersonnalise.FieldID)
|
||||
for _, f := range fields {
|
||||
if !champpersonnalise.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != champpersonnalise.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.NomChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldNomChamp, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TypeChamp(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldTypeChamp, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Valeur(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldValeur, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ValeurCleared() {
|
||||
_spec.ClearField(champpersonnalise.FieldValeur, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Unite(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUnite, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UniteCleared() {
|
||||
_spec.ClearField(champpersonnalise.FieldUnite, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(champpersonnalise.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: champpersonnalise.ObjetTable,
|
||||
Columns: []string{champpersonnalise.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: champpersonnalise.ObjetTable,
|
||||
Columns: []string{champpersonnalise.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ChampPersonnalise{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{champpersonnalise.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
1251
backend/internal/data/ent/client.go
Normal file
1251
backend/internal/data/ent/client.go
Normal file
File diff suppressed because it is too large
Load Diff
3
backend/internal/data/ent/doc.go
Normal file
3
backend/internal/data/ent/doc.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package ent
|
||||
|
||||
// Package ent contient le code genere par Ent.
|
||||
276
backend/internal/data/ent/emplacement.go
Normal file
276
backend/internal/data/ent/emplacement.go
Normal file
@@ -0,0 +1,276 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Emplacement is the model entity for the Emplacement schema.
|
||||
type Emplacement struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique de l'emplacement
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Nom de l'emplacement
|
||||
Nom string `json:"nom,omitempty"`
|
||||
// Identifiant du parent
|
||||
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
||||
// Slug URL-friendly
|
||||
Slug *string `json:"slug,omitempty"`
|
||||
// Piece associee
|
||||
Piece *string `json:"piece,omitempty"`
|
||||
// Meuble associe
|
||||
Meuble *string `json:"meuble,omitempty"`
|
||||
// Numero de boite
|
||||
NumeroBoite *string `json:"numero_boite,omitempty"`
|
||||
// Nom ou code d'icone
|
||||
Icone *string `json:"icone,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the EmplacementQuery when eager-loading is set.
|
||||
Edges EmplacementEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// EmplacementEdges holds the relations/edges for other nodes in the graph.
|
||||
type EmplacementEdges struct {
|
||||
// Lien parent/enfants pour l'arbre des emplacements
|
||||
Parent *Emplacement `json:"parent,omitempty"`
|
||||
// Enfants holds the value of the enfants edge.
|
||||
Enfants []*Emplacement `json:"enfants,omitempty"`
|
||||
// Liens entre emplacements et objets
|
||||
LiensObjets []*LienObjetEmplacement `json:"liens_objets,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [3]bool
|
||||
}
|
||||
|
||||
// ParentOrErr returns the Parent value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e EmplacementEdges) ParentOrErr() (*Emplacement, error) {
|
||||
if e.Parent != nil {
|
||||
return e.Parent, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: emplacement.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "parent"}
|
||||
}
|
||||
|
||||
// EnfantsOrErr returns the Enfants value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e EmplacementEdges) EnfantsOrErr() ([]*Emplacement, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Enfants, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "enfants"}
|
||||
}
|
||||
|
||||
// LiensObjetsOrErr returns the LiensObjets value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e EmplacementEdges) LiensObjetsOrErr() ([]*LienObjetEmplacement, error) {
|
||||
if e.loadedTypes[2] {
|
||||
return e.LiensObjets, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "liens_objets"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Emplacement) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case emplacement.FieldParentID:
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
case emplacement.FieldNom, emplacement.FieldSlug, emplacement.FieldPiece, emplacement.FieldMeuble, emplacement.FieldNumeroBoite, emplacement.FieldIcone:
|
||||
values[i] = new(sql.NullString)
|
||||
case emplacement.FieldCreatedAt, emplacement.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case emplacement.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Emplacement fields.
|
||||
func (_m *Emplacement) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case emplacement.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case emplacement.FieldNom:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nom", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Nom = value.String
|
||||
}
|
||||
case emplacement.FieldParentID:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field parent_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ParentID = new(uuid.UUID)
|
||||
*_m.ParentID = *value.S.(*uuid.UUID)
|
||||
}
|
||||
case emplacement.FieldSlug:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field slug", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Slug = new(string)
|
||||
*_m.Slug = value.String
|
||||
}
|
||||
case emplacement.FieldPiece:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field piece", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Piece = new(string)
|
||||
*_m.Piece = value.String
|
||||
}
|
||||
case emplacement.FieldMeuble:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field meuble", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Meuble = new(string)
|
||||
*_m.Meuble = value.String
|
||||
}
|
||||
case emplacement.FieldNumeroBoite:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field numero_boite", values[i])
|
||||
} else if value.Valid {
|
||||
_m.NumeroBoite = new(string)
|
||||
*_m.NumeroBoite = value.String
|
||||
}
|
||||
case emplacement.FieldIcone:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field icone", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Icone = new(string)
|
||||
*_m.Icone = value.String
|
||||
}
|
||||
case emplacement.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case emplacement.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Emplacement.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Emplacement) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryParent queries the "parent" edge of the Emplacement entity.
|
||||
func (_m *Emplacement) QueryParent() *EmplacementQuery {
|
||||
return NewEmplacementClient(_m.config).QueryParent(_m)
|
||||
}
|
||||
|
||||
// QueryEnfants queries the "enfants" edge of the Emplacement entity.
|
||||
func (_m *Emplacement) QueryEnfants() *EmplacementQuery {
|
||||
return NewEmplacementClient(_m.config).QueryEnfants(_m)
|
||||
}
|
||||
|
||||
// QueryLiensObjets queries the "liens_objets" edge of the Emplacement entity.
|
||||
func (_m *Emplacement) QueryLiensObjets() *LienObjetEmplacementQuery {
|
||||
return NewEmplacementClient(_m.config).QueryLiensObjets(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Emplacement.
|
||||
// Note that you need to call Emplacement.Unwrap() before calling this method if this Emplacement
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Emplacement) Update() *EmplacementUpdateOne {
|
||||
return NewEmplacementClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Emplacement entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *Emplacement) Unwrap() *Emplacement {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Emplacement is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Emplacement) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Emplacement(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("nom=")
|
||||
builder.WriteString(_m.Nom)
|
||||
builder.WriteString(", ")
|
||||
if v := _m.ParentID; v != nil {
|
||||
builder.WriteString("parent_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Slug; v != nil {
|
||||
builder.WriteString("slug=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Piece; v != nil {
|
||||
builder.WriteString("piece=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Meuble; v != nil {
|
||||
builder.WriteString("meuble=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.NumeroBoite; v != nil {
|
||||
builder.WriteString("numero_boite=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Icone; v != nil {
|
||||
builder.WriteString("icone=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Emplacements is a parsable slice of Emplacement.
|
||||
type Emplacements []*Emplacement
|
||||
205
backend/internal/data/ent/emplacement/emplacement.go
Normal file
205
backend/internal/data/ent/emplacement/emplacement.go
Normal file
@@ -0,0 +1,205 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package emplacement
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the emplacement type in the database.
|
||||
Label = "emplacement"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldNom holds the string denoting the nom field in the database.
|
||||
FieldNom = "nom"
|
||||
// FieldParentID holds the string denoting the parent_id field in the database.
|
||||
FieldParentID = "parent_id"
|
||||
// FieldSlug holds the string denoting the slug field in the database.
|
||||
FieldSlug = "slug"
|
||||
// FieldPiece holds the string denoting the piece field in the database.
|
||||
FieldPiece = "piece"
|
||||
// FieldMeuble holds the string denoting the meuble field in the database.
|
||||
FieldMeuble = "meuble"
|
||||
// FieldNumeroBoite holds the string denoting the numero_boite field in the database.
|
||||
FieldNumeroBoite = "numero_boite"
|
||||
// FieldIcone holds the string denoting the icone field in the database.
|
||||
FieldIcone = "icone"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeParent holds the string denoting the parent edge name in mutations.
|
||||
EdgeParent = "parent"
|
||||
// EdgeEnfants holds the string denoting the enfants edge name in mutations.
|
||||
EdgeEnfants = "enfants"
|
||||
// EdgeLiensObjets holds the string denoting the liens_objets edge name in mutations.
|
||||
EdgeLiensObjets = "liens_objets"
|
||||
// Table holds the table name of the emplacement in the database.
|
||||
Table = "emplacement"
|
||||
// ParentTable is the table that holds the parent relation/edge.
|
||||
ParentTable = "emplacement"
|
||||
// ParentColumn is the table column denoting the parent relation/edge.
|
||||
ParentColumn = "parent_id"
|
||||
// EnfantsTable is the table that holds the enfants relation/edge.
|
||||
EnfantsTable = "emplacement"
|
||||
// EnfantsColumn is the table column denoting the enfants relation/edge.
|
||||
EnfantsColumn = "parent_id"
|
||||
// LiensObjetsTable is the table that holds the liens_objets relation/edge.
|
||||
LiensObjetsTable = "lien_objet_emplacement"
|
||||
// LiensObjetsInverseTable is the table name for the LienObjetEmplacement entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "lienobjetemplacement" package.
|
||||
LiensObjetsInverseTable = "lien_objet_emplacement"
|
||||
// LiensObjetsColumn is the table column denoting the liens_objets relation/edge.
|
||||
LiensObjetsColumn = "emplacement_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for emplacement fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldNom,
|
||||
FieldParentID,
|
||||
FieldSlug,
|
||||
FieldPiece,
|
||||
FieldMeuble,
|
||||
FieldNumeroBoite,
|
||||
FieldIcone,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
NomValidator func(string) error
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Emplacement queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNom orders the results by the nom field.
|
||||
func ByNom(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNom, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByParentID orders the results by the parent_id field.
|
||||
func ByParentID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldParentID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySlug orders the results by the slug field.
|
||||
func BySlug(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSlug, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPiece orders the results by the piece field.
|
||||
func ByPiece(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPiece, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMeuble orders the results by the meuble field.
|
||||
func ByMeuble(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMeuble, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNumeroBoite orders the results by the numero_boite field.
|
||||
func ByNumeroBoite(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNumeroBoite, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIcone orders the results by the icone field.
|
||||
func ByIcone(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIcone, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByParentField orders the results by parent field.
|
||||
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByEnfantsCount orders the results by enfants count.
|
||||
func ByEnfantsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newEnfantsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByEnfants orders the results by enfants terms.
|
||||
func ByEnfants(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newEnfantsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByLiensObjetsCount orders the results by liens_objets count.
|
||||
func ByLiensObjetsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newLiensObjetsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByLiensObjets orders the results by liens_objets terms.
|
||||
func ByLiensObjets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newLiensObjetsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newParentStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
|
||||
)
|
||||
}
|
||||
func newEnfantsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, EnfantsTable, EnfantsColumn),
|
||||
)
|
||||
}
|
||||
func newLiensObjetsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LiensObjetsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LiensObjetsTable, LiensObjetsColumn),
|
||||
)
|
||||
}
|
||||
736
backend/internal/data/ent/emplacement/where.go
Normal file
736
backend/internal/data/ent/emplacement/where.go
Normal file
@@ -0,0 +1,736 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package emplacement
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Nom applies equality check predicate on the "nom" field. It's identical to NomEQ.
|
||||
func Nom(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ.
|
||||
func ParentID(v uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// Slug applies equality check predicate on the "slug" field. It's identical to SlugEQ.
|
||||
func Slug(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// Piece applies equality check predicate on the "piece" field. It's identical to PieceEQ.
|
||||
func Piece(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldPiece, v))
|
||||
}
|
||||
|
||||
// Meuble applies equality check predicate on the "meuble" field. It's identical to MeubleEQ.
|
||||
func Meuble(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// NumeroBoite applies equality check predicate on the "numero_boite" field. It's identical to NumeroBoiteEQ.
|
||||
func NumeroBoite(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// Icone applies equality check predicate on the "icone" field. It's identical to IconeEQ.
|
||||
func Icone(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NomEQ applies the EQ predicate on the "nom" field.
|
||||
func NomEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomNEQ applies the NEQ predicate on the "nom" field.
|
||||
func NomNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomIn applies the In predicate on the "nom" field.
|
||||
func NomIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomNotIn applies the NotIn predicate on the "nom" field.
|
||||
func NomNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomGT applies the GT predicate on the "nom" field.
|
||||
func NomGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomGTE applies the GTE predicate on the "nom" field.
|
||||
func NomGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLT applies the LT predicate on the "nom" field.
|
||||
func NomLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLTE applies the LTE predicate on the "nom" field.
|
||||
func NomLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContains applies the Contains predicate on the "nom" field.
|
||||
func NomContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasPrefix applies the HasPrefix predicate on the "nom" field.
|
||||
func NomHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasSuffix applies the HasSuffix predicate on the "nom" field.
|
||||
func NomHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomEqualFold applies the EqualFold predicate on the "nom" field.
|
||||
func NomEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContainsFold applies the ContainsFold predicate on the "nom" field.
|
||||
func NomContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// ParentIDEQ applies the EQ predicate on the "parent_id" field.
|
||||
func ParentIDEQ(v uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// ParentIDNEQ applies the NEQ predicate on the "parent_id" field.
|
||||
func ParentIDNEQ(v uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldParentID, v))
|
||||
}
|
||||
|
||||
// ParentIDIn applies the In predicate on the "parent_id" field.
|
||||
func ParentIDIn(vs ...uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldParentID, vs...))
|
||||
}
|
||||
|
||||
// ParentIDNotIn applies the NotIn predicate on the "parent_id" field.
|
||||
func ParentIDNotIn(vs ...uuid.UUID) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldParentID, vs...))
|
||||
}
|
||||
|
||||
// ParentIDIsNil applies the IsNil predicate on the "parent_id" field.
|
||||
func ParentIDIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldParentID))
|
||||
}
|
||||
|
||||
// ParentIDNotNil applies the NotNil predicate on the "parent_id" field.
|
||||
func ParentIDNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldParentID))
|
||||
}
|
||||
|
||||
// SlugEQ applies the EQ predicate on the "slug" field.
|
||||
func SlugEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugNEQ applies the NEQ predicate on the "slug" field.
|
||||
func SlugNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugIn applies the In predicate on the "slug" field.
|
||||
func SlugIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldSlug, vs...))
|
||||
}
|
||||
|
||||
// SlugNotIn applies the NotIn predicate on the "slug" field.
|
||||
func SlugNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldSlug, vs...))
|
||||
}
|
||||
|
||||
// SlugGT applies the GT predicate on the "slug" field.
|
||||
func SlugGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugGTE applies the GTE predicate on the "slug" field.
|
||||
func SlugGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugLT applies the LT predicate on the "slug" field.
|
||||
func SlugLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugLTE applies the LTE predicate on the "slug" field.
|
||||
func SlugLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugContains applies the Contains predicate on the "slug" field.
|
||||
func SlugContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugHasPrefix applies the HasPrefix predicate on the "slug" field.
|
||||
func SlugHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugHasSuffix applies the HasSuffix predicate on the "slug" field.
|
||||
func SlugHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugIsNil applies the IsNil predicate on the "slug" field.
|
||||
func SlugIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldSlug))
|
||||
}
|
||||
|
||||
// SlugNotNil applies the NotNil predicate on the "slug" field.
|
||||
func SlugNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldSlug))
|
||||
}
|
||||
|
||||
// SlugEqualFold applies the EqualFold predicate on the "slug" field.
|
||||
func SlugEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldSlug, v))
|
||||
}
|
||||
|
||||
// SlugContainsFold applies the ContainsFold predicate on the "slug" field.
|
||||
func SlugContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldSlug, v))
|
||||
}
|
||||
|
||||
// PieceEQ applies the EQ predicate on the "piece" field.
|
||||
func PieceEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceNEQ applies the NEQ predicate on the "piece" field.
|
||||
func PieceNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceIn applies the In predicate on the "piece" field.
|
||||
func PieceIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldPiece, vs...))
|
||||
}
|
||||
|
||||
// PieceNotIn applies the NotIn predicate on the "piece" field.
|
||||
func PieceNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldPiece, vs...))
|
||||
}
|
||||
|
||||
// PieceGT applies the GT predicate on the "piece" field.
|
||||
func PieceGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceGTE applies the GTE predicate on the "piece" field.
|
||||
func PieceGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceLT applies the LT predicate on the "piece" field.
|
||||
func PieceLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceLTE applies the LTE predicate on the "piece" field.
|
||||
func PieceLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceContains applies the Contains predicate on the "piece" field.
|
||||
func PieceContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceHasPrefix applies the HasPrefix predicate on the "piece" field.
|
||||
func PieceHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceHasSuffix applies the HasSuffix predicate on the "piece" field.
|
||||
func PieceHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceIsNil applies the IsNil predicate on the "piece" field.
|
||||
func PieceIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldPiece))
|
||||
}
|
||||
|
||||
// PieceNotNil applies the NotNil predicate on the "piece" field.
|
||||
func PieceNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldPiece))
|
||||
}
|
||||
|
||||
// PieceEqualFold applies the EqualFold predicate on the "piece" field.
|
||||
func PieceEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldPiece, v))
|
||||
}
|
||||
|
||||
// PieceContainsFold applies the ContainsFold predicate on the "piece" field.
|
||||
func PieceContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldPiece, v))
|
||||
}
|
||||
|
||||
// MeubleEQ applies the EQ predicate on the "meuble" field.
|
||||
func MeubleEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleNEQ applies the NEQ predicate on the "meuble" field.
|
||||
func MeubleNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleIn applies the In predicate on the "meuble" field.
|
||||
func MeubleIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldMeuble, vs...))
|
||||
}
|
||||
|
||||
// MeubleNotIn applies the NotIn predicate on the "meuble" field.
|
||||
func MeubleNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldMeuble, vs...))
|
||||
}
|
||||
|
||||
// MeubleGT applies the GT predicate on the "meuble" field.
|
||||
func MeubleGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleGTE applies the GTE predicate on the "meuble" field.
|
||||
func MeubleGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleLT applies the LT predicate on the "meuble" field.
|
||||
func MeubleLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleLTE applies the LTE predicate on the "meuble" field.
|
||||
func MeubleLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleContains applies the Contains predicate on the "meuble" field.
|
||||
func MeubleContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleHasPrefix applies the HasPrefix predicate on the "meuble" field.
|
||||
func MeubleHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleHasSuffix applies the HasSuffix predicate on the "meuble" field.
|
||||
func MeubleHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleIsNil applies the IsNil predicate on the "meuble" field.
|
||||
func MeubleIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldMeuble))
|
||||
}
|
||||
|
||||
// MeubleNotNil applies the NotNil predicate on the "meuble" field.
|
||||
func MeubleNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldMeuble))
|
||||
}
|
||||
|
||||
// MeubleEqualFold applies the EqualFold predicate on the "meuble" field.
|
||||
func MeubleEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// MeubleContainsFold applies the ContainsFold predicate on the "meuble" field.
|
||||
func MeubleContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldMeuble, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteEQ applies the EQ predicate on the "numero_boite" field.
|
||||
func NumeroBoiteEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteNEQ applies the NEQ predicate on the "numero_boite" field.
|
||||
func NumeroBoiteNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteIn applies the In predicate on the "numero_boite" field.
|
||||
func NumeroBoiteIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldNumeroBoite, vs...))
|
||||
}
|
||||
|
||||
// NumeroBoiteNotIn applies the NotIn predicate on the "numero_boite" field.
|
||||
func NumeroBoiteNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldNumeroBoite, vs...))
|
||||
}
|
||||
|
||||
// NumeroBoiteGT applies the GT predicate on the "numero_boite" field.
|
||||
func NumeroBoiteGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteGTE applies the GTE predicate on the "numero_boite" field.
|
||||
func NumeroBoiteGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteLT applies the LT predicate on the "numero_boite" field.
|
||||
func NumeroBoiteLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteLTE applies the LTE predicate on the "numero_boite" field.
|
||||
func NumeroBoiteLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteContains applies the Contains predicate on the "numero_boite" field.
|
||||
func NumeroBoiteContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteHasPrefix applies the HasPrefix predicate on the "numero_boite" field.
|
||||
func NumeroBoiteHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteHasSuffix applies the HasSuffix predicate on the "numero_boite" field.
|
||||
func NumeroBoiteHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteIsNil applies the IsNil predicate on the "numero_boite" field.
|
||||
func NumeroBoiteIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldNumeroBoite))
|
||||
}
|
||||
|
||||
// NumeroBoiteNotNil applies the NotNil predicate on the "numero_boite" field.
|
||||
func NumeroBoiteNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldNumeroBoite))
|
||||
}
|
||||
|
||||
// NumeroBoiteEqualFold applies the EqualFold predicate on the "numero_boite" field.
|
||||
func NumeroBoiteEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// NumeroBoiteContainsFold applies the ContainsFold predicate on the "numero_boite" field.
|
||||
func NumeroBoiteContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldNumeroBoite, v))
|
||||
}
|
||||
|
||||
// IconeEQ applies the EQ predicate on the "icone" field.
|
||||
func IconeEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeNEQ applies the NEQ predicate on the "icone" field.
|
||||
func IconeNEQ(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeIn applies the In predicate on the "icone" field.
|
||||
func IconeIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldIcone, vs...))
|
||||
}
|
||||
|
||||
// IconeNotIn applies the NotIn predicate on the "icone" field.
|
||||
func IconeNotIn(vs ...string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldIcone, vs...))
|
||||
}
|
||||
|
||||
// IconeGT applies the GT predicate on the "icone" field.
|
||||
func IconeGT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeGTE applies the GTE predicate on the "icone" field.
|
||||
func IconeGTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeLT applies the LT predicate on the "icone" field.
|
||||
func IconeLT(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeLTE applies the LTE predicate on the "icone" field.
|
||||
func IconeLTE(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeContains applies the Contains predicate on the "icone" field.
|
||||
func IconeContains(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContains(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeHasPrefix applies the HasPrefix predicate on the "icone" field.
|
||||
func IconeHasPrefix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasPrefix(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeHasSuffix applies the HasSuffix predicate on the "icone" field.
|
||||
func IconeHasSuffix(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldHasSuffix(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeIsNil applies the IsNil predicate on the "icone" field.
|
||||
func IconeIsNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIsNull(FieldIcone))
|
||||
}
|
||||
|
||||
// IconeNotNil applies the NotNil predicate on the "icone" field.
|
||||
func IconeNotNil() predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotNull(FieldIcone))
|
||||
}
|
||||
|
||||
// IconeEqualFold applies the EqualFold predicate on the "icone" field.
|
||||
func IconeEqualFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEqualFold(FieldIcone, v))
|
||||
}
|
||||
|
||||
// IconeContainsFold applies the ContainsFold predicate on the "icone" field.
|
||||
func IconeContainsFold(v string) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldContainsFold(FieldIcone, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasParent applies the HasEdge predicate on the "parent" edge.
|
||||
func HasParent() predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates).
|
||||
func HasParentWith(preds ...predicate.Emplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := newParentStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasEnfants applies the HasEdge predicate on the "enfants" edge.
|
||||
func HasEnfants() predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, EnfantsTable, EnfantsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasEnfantsWith applies the HasEdge predicate on the "enfants" edge with a given conditions (other predicates).
|
||||
func HasEnfantsWith(preds ...predicate.Emplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := newEnfantsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasLiensObjets applies the HasEdge predicate on the "liens_objets" edge.
|
||||
func HasLiensObjets() predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LiensObjetsTable, LiensObjetsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasLiensObjetsWith applies the HasEdge predicate on the "liens_objets" edge with a given conditions (other predicates).
|
||||
func HasLiensObjetsWith(preds ...predicate.LienObjetEmplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(func(s *sql.Selector) {
|
||||
step := newLiensObjetsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Emplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Emplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Emplacement) predicate.Emplacement {
|
||||
return predicate.Emplacement(sql.NotPredicates(p))
|
||||
}
|
||||
458
backend/internal/data/ent/emplacement_create.go
Normal file
458
backend/internal/data/ent/emplacement_create.go
Normal file
@@ -0,0 +1,458 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// EmplacementCreate is the builder for creating a Emplacement entity.
|
||||
type EmplacementCreate struct {
|
||||
config
|
||||
mutation *EmplacementMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetNom sets the "nom" field.
|
||||
func (_c *EmplacementCreate) SetNom(v string) *EmplacementCreate {
|
||||
_c.mutation.SetNom(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetParentID sets the "parent_id" field.
|
||||
func (_c *EmplacementCreate) SetParentID(v uuid.UUID) *EmplacementCreate {
|
||||
_c.mutation.SetParentID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableParentID sets the "parent_id" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableParentID(v *uuid.UUID) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetParentID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (_c *EmplacementCreate) SetSlug(v string) *EmplacementCreate {
|
||||
_c.mutation.SetSlug(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableSlug(v *string) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetSlug(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPiece sets the "piece" field.
|
||||
func (_c *EmplacementCreate) SetPiece(v string) *EmplacementCreate {
|
||||
_c.mutation.SetPiece(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePiece sets the "piece" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillablePiece(v *string) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetPiece(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMeuble sets the "meuble" field.
|
||||
func (_c *EmplacementCreate) SetMeuble(v string) *EmplacementCreate {
|
||||
_c.mutation.SetMeuble(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMeuble sets the "meuble" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableMeuble(v *string) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetMeuble(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNumeroBoite sets the "numero_boite" field.
|
||||
func (_c *EmplacementCreate) SetNumeroBoite(v string) *EmplacementCreate {
|
||||
_c.mutation.SetNumeroBoite(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableNumeroBoite sets the "numero_boite" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableNumeroBoite(v *string) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetNumeroBoite(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIcone sets the "icone" field.
|
||||
func (_c *EmplacementCreate) SetIcone(v string) *EmplacementCreate {
|
||||
_c.mutation.SetIcone(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIcone sets the "icone" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableIcone(v *string) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetIcone(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *EmplacementCreate) SetCreatedAt(v time.Time) *EmplacementCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableCreatedAt(v *time.Time) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *EmplacementCreate) SetUpdatedAt(v time.Time) *EmplacementCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableUpdatedAt(v *time.Time) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *EmplacementCreate) SetID(v uuid.UUID) *EmplacementCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *EmplacementCreate) SetNillableID(v *uuid.UUID) *EmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetParent sets the "parent" edge to the Emplacement entity.
|
||||
func (_c *EmplacementCreate) SetParent(v *Emplacement) *EmplacementCreate {
|
||||
return _c.SetParentID(v.ID)
|
||||
}
|
||||
|
||||
// AddEnfantIDs adds the "enfants" edge to the Emplacement entity by IDs.
|
||||
func (_c *EmplacementCreate) AddEnfantIDs(ids ...uuid.UUID) *EmplacementCreate {
|
||||
_c.mutation.AddEnfantIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddEnfants adds the "enfants" edges to the Emplacement entity.
|
||||
func (_c *EmplacementCreate) AddEnfants(v ...*Emplacement) *EmplacementCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddEnfantIDs(ids...)
|
||||
}
|
||||
|
||||
// AddLiensObjetIDs adds the "liens_objets" edge to the LienObjetEmplacement entity by IDs.
|
||||
func (_c *EmplacementCreate) AddLiensObjetIDs(ids ...uuid.UUID) *EmplacementCreate {
|
||||
_c.mutation.AddLiensObjetIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddLiensObjets adds the "liens_objets" edges to the LienObjetEmplacement entity.
|
||||
func (_c *EmplacementCreate) AddLiensObjets(v ...*LienObjetEmplacement) *EmplacementCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddLiensObjetIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the EmplacementMutation object of the builder.
|
||||
func (_c *EmplacementCreate) Mutation() *EmplacementMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Emplacement in the database.
|
||||
func (_c *EmplacementCreate) Save(ctx context.Context) (*Emplacement, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *EmplacementCreate) SaveX(ctx context.Context) *Emplacement {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *EmplacementCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *EmplacementCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *EmplacementCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := emplacement.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := emplacement.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := emplacement.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *EmplacementCreate) check() error {
|
||||
if _, ok := _c.mutation.Nom(); !ok {
|
||||
return &ValidationError{Name: "nom", err: errors.New(`ent: missing required field "Emplacement.nom"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Nom(); ok {
|
||||
if err := emplacement.NomValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom", err: fmt.Errorf(`ent: validator failed for field "Emplacement.nom": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Emplacement.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Emplacement.updated_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *EmplacementCreate) sqlSave(ctx context.Context) (*Emplacement, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *EmplacementCreate) createSpec() (*Emplacement, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Emplacement{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(emplacement.Table, sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.Nom(); ok {
|
||||
_spec.SetField(emplacement.FieldNom, field.TypeString, value)
|
||||
_node.Nom = value
|
||||
}
|
||||
if value, ok := _c.mutation.Slug(); ok {
|
||||
_spec.SetField(emplacement.FieldSlug, field.TypeString, value)
|
||||
_node.Slug = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Piece(); ok {
|
||||
_spec.SetField(emplacement.FieldPiece, field.TypeString, value)
|
||||
_node.Piece = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Meuble(); ok {
|
||||
_spec.SetField(emplacement.FieldMeuble, field.TypeString, value)
|
||||
_node.Meuble = &value
|
||||
}
|
||||
if value, ok := _c.mutation.NumeroBoite(); ok {
|
||||
_spec.SetField(emplacement.FieldNumeroBoite, field.TypeString, value)
|
||||
_node.NumeroBoite = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Icone(); ok {
|
||||
_spec.SetField(emplacement.FieldIcone, field.TypeString, value)
|
||||
_node.Icone = &value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(emplacement.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(emplacement.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: emplacement.ParentTable,
|
||||
Columns: []string{emplacement.ParentColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.ParentID = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.EnfantsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: emplacement.EnfantsTable,
|
||||
Columns: []string{emplacement.EnfantsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.LiensObjetsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: emplacement.LiensObjetsTable,
|
||||
Columns: []string{emplacement.LiensObjetsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// EmplacementCreateBulk is the builder for creating many Emplacement entities in bulk.
|
||||
type EmplacementCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*EmplacementCreate
|
||||
}
|
||||
|
||||
// Save creates the Emplacement entities in the database.
|
||||
func (_c *EmplacementCreateBulk) Save(ctx context.Context) ([]*Emplacement, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Emplacement, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*EmplacementMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *EmplacementCreateBulk) SaveX(ctx context.Context) []*Emplacement {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *EmplacementCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *EmplacementCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/emplacement_delete.go
Normal file
88
backend/internal/data/ent/emplacement_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// EmplacementDelete is the builder for deleting a Emplacement entity.
|
||||
type EmplacementDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *EmplacementMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EmplacementDelete builder.
|
||||
func (_d *EmplacementDelete) Where(ps ...predicate.Emplacement) *EmplacementDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *EmplacementDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *EmplacementDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *EmplacementDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(emplacement.Table, sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// EmplacementDeleteOne is the builder for deleting a single Emplacement entity.
|
||||
type EmplacementDeleteOne struct {
|
||||
_d *EmplacementDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EmplacementDelete builder.
|
||||
func (_d *EmplacementDeleteOne) Where(ps ...predicate.Emplacement) *EmplacementDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *EmplacementDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{emplacement.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *EmplacementDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
760
backend/internal/data/ent/emplacement_query.go
Normal file
760
backend/internal/data/ent/emplacement_query.go
Normal file
@@ -0,0 +1,760 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// EmplacementQuery is the builder for querying Emplacement entities.
|
||||
type EmplacementQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []emplacement.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Emplacement
|
||||
withParent *EmplacementQuery
|
||||
withEnfants *EmplacementQuery
|
||||
withLiensObjets *LienObjetEmplacementQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the EmplacementQuery builder.
|
||||
func (_q *EmplacementQuery) Where(ps ...predicate.Emplacement) *EmplacementQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *EmplacementQuery) Limit(limit int) *EmplacementQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *EmplacementQuery) Offset(offset int) *EmplacementQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *EmplacementQuery) Unique(unique bool) *EmplacementQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *EmplacementQuery) Order(o ...emplacement.OrderOption) *EmplacementQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryParent chains the current query on the "parent" edge.
|
||||
func (_q *EmplacementQuery) QueryParent() *EmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(emplacement.Table, emplacement.FieldID, selector),
|
||||
sqlgraph.To(emplacement.Table, emplacement.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, emplacement.ParentTable, emplacement.ParentColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEnfants chains the current query on the "enfants" edge.
|
||||
func (_q *EmplacementQuery) QueryEnfants() *EmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(emplacement.Table, emplacement.FieldID, selector),
|
||||
sqlgraph.To(emplacement.Table, emplacement.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, emplacement.EnfantsTable, emplacement.EnfantsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLiensObjets chains the current query on the "liens_objets" edge.
|
||||
func (_q *EmplacementQuery) QueryLiensObjets() *LienObjetEmplacementQuery {
|
||||
query := (&LienObjetEmplacementClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(emplacement.Table, emplacement.FieldID, selector),
|
||||
sqlgraph.To(lienobjetemplacement.Table, lienobjetemplacement.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, emplacement.LiensObjetsTable, emplacement.LiensObjetsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Emplacement entity from the query.
|
||||
// Returns a *NotFoundError when no Emplacement was found.
|
||||
func (_q *EmplacementQuery) First(ctx context.Context) (*Emplacement, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{emplacement.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) FirstX(ctx context.Context) *Emplacement {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Emplacement ID from the query.
|
||||
// Returns a *NotFoundError when no Emplacement ID was found.
|
||||
func (_q *EmplacementQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{emplacement.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Emplacement entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Emplacement entity is found.
|
||||
// Returns a *NotFoundError when no Emplacement entities are found.
|
||||
func (_q *EmplacementQuery) Only(ctx context.Context) (*Emplacement, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{emplacement.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{emplacement.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) OnlyX(ctx context.Context) *Emplacement {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Emplacement ID in the query.
|
||||
// Returns a *NotSingularError when more than one Emplacement ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *EmplacementQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{emplacement.Label}
|
||||
default:
|
||||
err = &NotSingularError{emplacement.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Emplacements.
|
||||
func (_q *EmplacementQuery) All(ctx context.Context) ([]*Emplacement, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Emplacement, *EmplacementQuery]()
|
||||
return withInterceptors[[]*Emplacement](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) AllX(ctx context.Context) []*Emplacement {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Emplacement IDs.
|
||||
func (_q *EmplacementQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(emplacement.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *EmplacementQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*EmplacementQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *EmplacementQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *EmplacementQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the EmplacementQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *EmplacementQuery) Clone() *EmplacementQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &EmplacementQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]emplacement.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Emplacement{}, _q.predicates...),
|
||||
withParent: _q.withParent.Clone(),
|
||||
withEnfants: _q.withEnfants.Clone(),
|
||||
withLiensObjets: _q.withLiensObjets.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithParent tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "parent" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *EmplacementQuery) WithParent(opts ...func(*EmplacementQuery)) *EmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withParent = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEnfants tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "enfants" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *EmplacementQuery) WithEnfants(opts ...func(*EmplacementQuery)) *EmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withEnfants = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithLiensObjets tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "liens_objets" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *EmplacementQuery) WithLiensObjets(opts ...func(*LienObjetEmplacementQuery)) *EmplacementQuery {
|
||||
query := (&LienObjetEmplacementClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withLiensObjets = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Emplacement.Query().
|
||||
// GroupBy(emplacement.FieldNom).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *EmplacementQuery) GroupBy(field string, fields ...string) *EmplacementGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EmplacementGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = emplacement.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Emplacement.Query().
|
||||
// Select(emplacement.FieldNom).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *EmplacementQuery) Select(fields ...string) *EmplacementSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &EmplacementSelect{EmplacementQuery: _q}
|
||||
sbuild.label = emplacement.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a EmplacementSelect configured with the given aggregations.
|
||||
func (_q *EmplacementQuery) Aggregate(fns ...AggregateFunc) *EmplacementSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !emplacement.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Emplacement, error) {
|
||||
var (
|
||||
nodes = []*Emplacement{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [3]bool{
|
||||
_q.withParent != nil,
|
||||
_q.withEnfants != nil,
|
||||
_q.withLiensObjets != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Emplacement).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Emplacement{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withParent; query != nil {
|
||||
if err := _q.loadParent(ctx, query, nodes, nil,
|
||||
func(n *Emplacement, e *Emplacement) { n.Edges.Parent = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withEnfants; query != nil {
|
||||
if err := _q.loadEnfants(ctx, query, nodes,
|
||||
func(n *Emplacement) { n.Edges.Enfants = []*Emplacement{} },
|
||||
func(n *Emplacement, e *Emplacement) { n.Edges.Enfants = append(n.Edges.Enfants, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withLiensObjets; query != nil {
|
||||
if err := _q.loadLiensObjets(ctx, query, nodes,
|
||||
func(n *Emplacement) { n.Edges.LiensObjets = []*LienObjetEmplacement{} },
|
||||
func(n *Emplacement, e *LienObjetEmplacement) { n.Edges.LiensObjets = append(n.Edges.LiensObjets, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) loadParent(ctx context.Context, query *EmplacementQuery, nodes []*Emplacement, init func(*Emplacement), assign func(*Emplacement, *Emplacement)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Emplacement)
|
||||
for i := range nodes {
|
||||
if nodes[i].ParentID == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].ParentID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(emplacement.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *EmplacementQuery) loadEnfants(ctx context.Context, query *EmplacementQuery, nodes []*Emplacement, init func(*Emplacement), assign func(*Emplacement, *Emplacement)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Emplacement)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(emplacement.FieldParentID)
|
||||
}
|
||||
query.Where(predicate.Emplacement(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(emplacement.EnfantsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.ParentID
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "parent_id" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *EmplacementQuery) loadLiensObjets(ctx context.Context, query *LienObjetEmplacementQuery, nodes []*Emplacement, init func(*Emplacement), assign func(*Emplacement, *LienObjetEmplacement)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Emplacement)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(lienobjetemplacement.FieldEmplacementID)
|
||||
}
|
||||
query.Where(predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(emplacement.LiensObjetsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.EmplacementID
|
||||
node, ok := nodeids[fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "emplacement_id" returned %v for node %v`, fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(emplacement.Table, emplacement.Columns, sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, emplacement.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != emplacement.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withParent != nil {
|
||||
_spec.Node.AddColumnOnce(emplacement.FieldParentID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *EmplacementQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(emplacement.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = emplacement.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// EmplacementGroupBy is the group-by builder for Emplacement entities.
|
||||
type EmplacementGroupBy struct {
|
||||
selector
|
||||
build *EmplacementQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *EmplacementGroupBy) Aggregate(fns ...AggregateFunc) *EmplacementGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *EmplacementGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EmplacementQuery, *EmplacementGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *EmplacementGroupBy) sqlScan(ctx context.Context, root *EmplacementQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// EmplacementSelect is the builder for selecting fields of Emplacement entities.
|
||||
type EmplacementSelect struct {
|
||||
*EmplacementQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *EmplacementSelect) Aggregate(fns ...AggregateFunc) *EmplacementSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *EmplacementSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EmplacementQuery, *EmplacementSelect](ctx, _s.EmplacementQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *EmplacementSelect) sqlScan(ctx context.Context, root *EmplacementQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
1012
backend/internal/data/ent/emplacement_update.go
Normal file
1012
backend/internal/data/ent/emplacement_update.go
Normal file
File diff suppressed because it is too large
Load Diff
618
backend/internal/data/ent/ent.go
Normal file
618
backend/internal/data/ent/ent.go
Normal file
@@ -0,0 +1,618 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflicts in user's code.
|
||||
type (
|
||||
Op = ent.Op
|
||||
Hook = ent.Hook
|
||||
Value = ent.Value
|
||||
Query = ent.Query
|
||||
QueryContext = ent.QueryContext
|
||||
Querier = ent.Querier
|
||||
QuerierFunc = ent.QuerierFunc
|
||||
Interceptor = ent.Interceptor
|
||||
InterceptFunc = ent.InterceptFunc
|
||||
Traverser = ent.Traverser
|
||||
TraverseFunc = ent.TraverseFunc
|
||||
Policy = ent.Policy
|
||||
Mutator = ent.Mutator
|
||||
Mutation = ent.Mutation
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Tx attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
var (
|
||||
initCheck sync.Once
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// checkColumn checks if the column exists in the given table.
|
||||
func checkColumn(t, c string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
categorie.Table: categorie.ValidColumn,
|
||||
champpersonnalise.Table: champpersonnalise.ValidColumn,
|
||||
emplacement.Table: emplacement.ValidColumn,
|
||||
lienobjetemplacement.Table: lienobjetemplacement.ValidColumn,
|
||||
objet.Table: objet.ValidColumn,
|
||||
piecejointe.Table: piecejointe.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(t, c)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Asc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Desc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||
type AggregateFunc func(*sql.Selector) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
// GroupBy(field1, field2).
|
||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||
// Scan(ctx, &v)
|
||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.As(fn(s), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field or edge fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ValidationError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ValidationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validation error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ValidationError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||
type NotFoundError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotFoundError) Error() string {
|
||||
return "ent: " + e.label + " not found"
|
||||
}
|
||||
|
||||
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||
func IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// MaskNotFound masks not found error.
|
||||
func MaskNotFound(err error) error {
|
||||
if IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||
type NotSingularError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotSingularError) Error() string {
|
||||
return "ent: " + e.label + " not singular"
|
||||
}
|
||||
|
||||
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||
func IsNotSingular(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotSingularError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||
type NotLoadedError struct {
|
||||
edge string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotLoadedError) Error() string {
|
||||
return "ent: " + e.edge + " edge was not loaded"
|
||||
}
|
||||
|
||||
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||
func IsNotLoaded(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotLoadedError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// ConstraintError returns when trying to create/update one or more entities and
|
||||
// one or more of their constraints failed. For example, violation of edge or
|
||||
// field uniqueness.
|
||||
type ConstraintError struct {
|
||||
msg string
|
||||
wrap error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e ConstraintError) Error() string {
|
||||
return "ent: constraint failed: " + e.msg
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ConstraintError) Unwrap() error {
|
||||
return e.wrap
|
||||
}
|
||||
|
||||
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||
func IsConstraintError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// selector embedded by the different Select/GroupBy builders.
|
||||
type selector struct {
|
||||
label string
|
||||
flds *[]string
|
||||
fns []AggregateFunc
|
||||
scan func(context.Context, any) error
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||
if err := s.scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (s *selector) StringsX(ctx context.Context) []string {
|
||||
v, err := s.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = s.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (s *selector) StringX(ctx context.Context) string {
|
||||
v, err := s.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (s *selector) IntsX(ctx context.Context) []int {
|
||||
v, err := s.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = s.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (s *selector) IntX(ctx context.Context) int {
|
||||
v, err := s.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (s *selector) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := s.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = s.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (s *selector) Float64X(ctx context.Context) float64 {
|
||||
v, err := s.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (s *selector) BoolsX(ctx context.Context) []bool {
|
||||
v, err := s.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = s.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (s *selector) BoolX(ctx context.Context) bool {
|
||||
v, err := s.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// withHooks invokes the builder operation with the given hooks, if any.
|
||||
func withHooks[V Value, M any, PM interface {
|
||||
*M
|
||||
Mutation
|
||||
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
|
||||
if len(hooks) == 0 {
|
||||
return exec(ctx)
|
||||
}
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutationT, ok := any(m).(PM)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
// Set the mutation to the builder.
|
||||
*mutation = *mutationT
|
||||
return exec(ctx)
|
||||
})
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
if hooks[i] == nil {
|
||||
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = hooks[i](mut)
|
||||
}
|
||||
v, err := mut.Mutate(ctx, mutation)
|
||||
if err != nil {
|
||||
return value, err
|
||||
}
|
||||
nv, ok := v.(V)
|
||||
if !ok {
|
||||
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
|
||||
}
|
||||
return nv, nil
|
||||
}
|
||||
|
||||
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
|
||||
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
|
||||
if ent.QueryFromContext(ctx) == nil {
|
||||
qc.Op = op
|
||||
ctx = ent.NewQueryContext(ctx, qc)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func querierAll[V Value, Q interface {
|
||||
sqlAll(context.Context, ...queryHook) (V, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlAll(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func querierCount[Q interface {
|
||||
sqlCount(context.Context) (int, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlCount(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
rv, err := qr.Query(ctx, q)
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
vt, ok := rv.(V)
|
||||
if !ok {
|
||||
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
|
||||
}
|
||||
return vt, nil
|
||||
}
|
||||
|
||||
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
|
||||
sqlScan(context.Context, Q1, any) error
|
||||
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
|
||||
rv := reflect.ValueOf(v)
|
||||
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q1)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
|
||||
return rv.Elem().Interface(), nil
|
||||
}
|
||||
return v, nil
|
||||
})
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
vv, err := qr.Query(ctx, rootQuery)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch rv2 := reflect.ValueOf(vv); {
|
||||
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
|
||||
case rv.Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2.Elem())
|
||||
case rv.Elem().Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// queryHook describes an internal hook for the different sqlAll methods.
|
||||
type queryHook func(context.Context, *sqlgraph.QuerySpec)
|
||||
84
backend/internal/data/ent/enttest/enttest.go
Normal file
84
backend/internal/data/ent/enttest/enttest.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
// required by schema hooks.
|
||||
_ "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/runtime"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/migrate"
|
||||
)
|
||||
|
||||
type (
|
||||
// TestingT is the interface that is shared between
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...any)
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
Option func(*options)
|
||||
|
||||
options struct {
|
||||
opts []ent.Option
|
||||
migrateOpts []schema.MigrateOption
|
||||
}
|
||||
)
|
||||
|
||||
// WithOptions forwards options to client creation.
|
||||
func WithOptions(opts ...ent.Option) Option {
|
||||
return func(o *options) {
|
||||
o.opts = append(o.opts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigrateOptions forwards options to auto migration.
|
||||
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||
return func(o *options) {
|
||||
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(opts []Option) *options {
|
||||
o := &options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// Open calls ent.Open and auto-run migration.
|
||||
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClient calls ent.NewClient and auto-run migration.
|
||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c := ent.NewClient(o.opts...)
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||
tables, err := schema.CopyTables(migrate.Tables)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
259
backend/internal/data/ent/hook/hook.go
Normal file
259
backend/internal/data/ent/hook/hook.go
Normal file
@@ -0,0 +1,259 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
)
|
||||
|
||||
// The CategorieFunc type is an adapter to allow the use of ordinary
|
||||
// function as Categorie mutator.
|
||||
type CategorieFunc func(context.Context, *ent.CategorieMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f CategorieFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.CategorieMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CategorieMutation", m)
|
||||
}
|
||||
|
||||
// The ChampPersonnaliseFunc type is an adapter to allow the use of ordinary
|
||||
// function as ChampPersonnalise mutator.
|
||||
type ChampPersonnaliseFunc func(context.Context, *ent.ChampPersonnaliseMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ChampPersonnaliseFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.ChampPersonnaliseMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChampPersonnaliseMutation", m)
|
||||
}
|
||||
|
||||
// The EmplacementFunc type is an adapter to allow the use of ordinary
|
||||
// function as Emplacement mutator.
|
||||
type EmplacementFunc func(context.Context, *ent.EmplacementMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f EmplacementFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.EmplacementMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EmplacementMutation", m)
|
||||
}
|
||||
|
||||
// The LienObjetEmplacementFunc type is an adapter to allow the use of ordinary
|
||||
// function as LienObjetEmplacement mutator.
|
||||
type LienObjetEmplacementFunc func(context.Context, *ent.LienObjetEmplacementMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f LienObjetEmplacementFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.LienObjetEmplacementMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LienObjetEmplacementMutation", m)
|
||||
}
|
||||
|
||||
// The ObjetFunc type is an adapter to allow the use of ordinary
|
||||
// function as Objet mutator.
|
||||
type ObjetFunc func(context.Context, *ent.ObjetMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ObjetFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.ObjetMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ObjetMutation", m)
|
||||
}
|
||||
|
||||
// The PieceJointeFunc type is an adapter to allow the use of ordinary
|
||||
// function as PieceJointe mutator.
|
||||
type PieceJointeFunc func(context.Context, *ent.PieceJointeMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f PieceJointeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.PieceJointeMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PieceJointeMutation", m)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op ent.Op) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, ent.Delete|ent.Create)
|
||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// FixedError is a hook returning a fixed error.
|
||||
func FixedError(err error) ent.Hook {
|
||||
return func(ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []ent.Hook {
|
||||
// return []ent.Hook{
|
||||
// Reject(ent.Delete|ent.Update),
|
||||
// }
|
||||
// }
|
||||
func Reject(op ent.Op) ent.Hook {
|
||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []ent.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...ent.Hook) Chain {
|
||||
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() ent.Hook {
|
||||
return func(mutator ent.Mutator) ent.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
||||
200
backend/internal/data/ent/lienobjetemplacement.go
Normal file
200
backend/internal/data/ent/lienobjetemplacement.go
Normal file
@@ -0,0 +1,200 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// LienObjetEmplacement is the model entity for the LienObjetEmplacement schema.
|
||||
type LienObjetEmplacement struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique du lien
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Identifiant de l'objet
|
||||
ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Identifiant de l'emplacement
|
||||
EmplacementID uuid.UUID `json:"emplacement_id,omitempty"`
|
||||
// Type de relation
|
||||
Type lienobjetemplacement.Type `json:"type,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the LienObjetEmplacementQuery when eager-loading is set.
|
||||
Edges LienObjetEmplacementEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// LienObjetEmplacementEdges holds the relations/edges for other nodes in the graph.
|
||||
type LienObjetEmplacementEdges struct {
|
||||
// Objet holds the value of the objet edge.
|
||||
Objet *Objet `json:"objet,omitempty"`
|
||||
// Emplacement holds the value of the emplacement edge.
|
||||
Emplacement *Emplacement `json:"emplacement,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [2]bool
|
||||
}
|
||||
|
||||
// ObjetOrErr returns the Objet value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e LienObjetEmplacementEdges) ObjetOrErr() (*Objet, error) {
|
||||
if e.Objet != nil {
|
||||
return e.Objet, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: objet.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "objet"}
|
||||
}
|
||||
|
||||
// EmplacementOrErr returns the Emplacement value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e LienObjetEmplacementEdges) EmplacementOrErr() (*Emplacement, error) {
|
||||
if e.Emplacement != nil {
|
||||
return e.Emplacement, nil
|
||||
} else if e.loadedTypes[1] {
|
||||
return nil, &NotFoundError{label: emplacement.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "emplacement"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*LienObjetEmplacement) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case lienobjetemplacement.FieldType:
|
||||
values[i] = new(sql.NullString)
|
||||
case lienobjetemplacement.FieldCreatedAt, lienobjetemplacement.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case lienobjetemplacement.FieldID, lienobjetemplacement.FieldObjetID, lienobjetemplacement.FieldEmplacementID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the LienObjetEmplacement fields.
|
||||
func (_m *LienObjetEmplacement) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case lienobjetemplacement.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case lienobjetemplacement.FieldObjetID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field objet_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ObjetID = *value
|
||||
}
|
||||
case lienobjetemplacement.FieldEmplacementID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field emplacement_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.EmplacementID = *value
|
||||
}
|
||||
case lienobjetemplacement.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Type = lienobjetemplacement.Type(value.String)
|
||||
}
|
||||
case lienobjetemplacement.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case lienobjetemplacement.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the LienObjetEmplacement.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *LienObjetEmplacement) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryObjet queries the "objet" edge of the LienObjetEmplacement entity.
|
||||
func (_m *LienObjetEmplacement) QueryObjet() *ObjetQuery {
|
||||
return NewLienObjetEmplacementClient(_m.config).QueryObjet(_m)
|
||||
}
|
||||
|
||||
// QueryEmplacement queries the "emplacement" edge of the LienObjetEmplacement entity.
|
||||
func (_m *LienObjetEmplacement) QueryEmplacement() *EmplacementQuery {
|
||||
return NewLienObjetEmplacementClient(_m.config).QueryEmplacement(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this LienObjetEmplacement.
|
||||
// Note that you need to call LienObjetEmplacement.Unwrap() before calling this method if this LienObjetEmplacement
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *LienObjetEmplacement) Update() *LienObjetEmplacementUpdateOne {
|
||||
return NewLienObjetEmplacementClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the LienObjetEmplacement entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *LienObjetEmplacement) Unwrap() *LienObjetEmplacement {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: LienObjetEmplacement is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *LienObjetEmplacement) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("LienObjetEmplacement(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("objet_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ObjetID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("emplacement_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.EmplacementID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Type))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// LienObjetEmplacements is a parsable slice of LienObjetEmplacement.
|
||||
type LienObjetEmplacements []*LienObjetEmplacement
|
||||
@@ -0,0 +1,167 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package lienobjetemplacement
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the lienobjetemplacement type in the database.
|
||||
Label = "lien_objet_emplacement"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldObjetID holds the string denoting the objet_id field in the database.
|
||||
FieldObjetID = "objet_id"
|
||||
// FieldEmplacementID holds the string denoting the emplacement_id field in the database.
|
||||
FieldEmplacementID = "emplacement_id"
|
||||
// FieldType holds the string denoting the type field in the database.
|
||||
FieldType = "type"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeObjet holds the string denoting the objet edge name in mutations.
|
||||
EdgeObjet = "objet"
|
||||
// EdgeEmplacement holds the string denoting the emplacement edge name in mutations.
|
||||
EdgeEmplacement = "emplacement"
|
||||
// Table holds the table name of the lienobjetemplacement in the database.
|
||||
Table = "lien_objet_emplacement"
|
||||
// ObjetTable is the table that holds the objet relation/edge.
|
||||
ObjetTable = "lien_objet_emplacement"
|
||||
// ObjetInverseTable is the table name for the Objet entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "objet" package.
|
||||
ObjetInverseTable = "objet"
|
||||
// ObjetColumn is the table column denoting the objet relation/edge.
|
||||
ObjetColumn = "objet_id"
|
||||
// EmplacementTable is the table that holds the emplacement relation/edge.
|
||||
EmplacementTable = "lien_objet_emplacement"
|
||||
// EmplacementInverseTable is the table name for the Emplacement entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "emplacement" package.
|
||||
EmplacementInverseTable = "emplacement"
|
||||
// EmplacementColumn is the table column denoting the emplacement relation/edge.
|
||||
EmplacementColumn = "emplacement_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for lienobjetemplacement fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldObjetID,
|
||||
FieldEmplacementID,
|
||||
FieldType,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// Type defines the type for the "type" enum field.
|
||||
type Type string
|
||||
|
||||
// TypeStocke is the default value of the Type enum.
|
||||
const DefaultType = TypeStocke
|
||||
|
||||
// Type values.
|
||||
const (
|
||||
TypeStocke Type = "stocke"
|
||||
TypeUtiliseDans Type = "utilise_dans"
|
||||
)
|
||||
|
||||
func (_type Type) String() string {
|
||||
return string(_type)
|
||||
}
|
||||
|
||||
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
|
||||
func TypeValidator(_type Type) error {
|
||||
switch _type {
|
||||
case TypeStocke, TypeUtiliseDans:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("lienobjetemplacement: invalid enum value for type field: %q", _type)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the LienObjetEmplacement queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetID orders the results by the objet_id field.
|
||||
func ByObjetID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldObjetID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEmplacementID orders the results by the emplacement_id field.
|
||||
func ByEmplacementID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEmplacementID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByType orders the results by the type field.
|
||||
func ByType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetField orders the results by objet field.
|
||||
func ByObjetField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newObjetStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByEmplacementField orders the results by emplacement field.
|
||||
func ByEmplacementField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newEmplacementStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newObjetStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ObjetInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
}
|
||||
func newEmplacementStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(EmplacementInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, EmplacementTable, EmplacementColumn),
|
||||
)
|
||||
}
|
||||
278
backend/internal/data/ent/lienobjetemplacement/where.go
Normal file
278
backend/internal/data/ent/lienobjetemplacement/where.go
Normal file
@@ -0,0 +1,278 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package lienobjetemplacement
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// ObjetID applies equality check predicate on the "objet_id" field. It's identical to ObjetIDEQ.
|
||||
func ObjetID(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// EmplacementID applies equality check predicate on the "emplacement_id" field. It's identical to EmplacementIDEQ.
|
||||
func EmplacementID(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldEmplacementID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// ObjetIDEQ applies the EQ predicate on the "objet_id" field.
|
||||
func ObjetIDEQ(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDNEQ applies the NEQ predicate on the "objet_id" field.
|
||||
func ObjetIDNEQ(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDIn applies the In predicate on the "objet_id" field.
|
||||
func ObjetIDIn(vs ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// ObjetIDNotIn applies the NotIn predicate on the "objet_id" field.
|
||||
func ObjetIDNotIn(vs ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// EmplacementIDEQ applies the EQ predicate on the "emplacement_id" field.
|
||||
func EmplacementIDEQ(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldEmplacementID, v))
|
||||
}
|
||||
|
||||
// EmplacementIDNEQ applies the NEQ predicate on the "emplacement_id" field.
|
||||
func EmplacementIDNEQ(v uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldEmplacementID, v))
|
||||
}
|
||||
|
||||
// EmplacementIDIn applies the In predicate on the "emplacement_id" field.
|
||||
func EmplacementIDIn(vs ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldEmplacementID, vs...))
|
||||
}
|
||||
|
||||
// EmplacementIDNotIn applies the NotIn predicate on the "emplacement_id" field.
|
||||
func EmplacementIDNotIn(vs ...uuid.UUID) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldEmplacementID, vs...))
|
||||
}
|
||||
|
||||
// TypeEQ applies the EQ predicate on the "type" field.
|
||||
func TypeEQ(v Type) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeNEQ applies the NEQ predicate on the "type" field.
|
||||
func TypeNEQ(v Type) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldType, v))
|
||||
}
|
||||
|
||||
// TypeIn applies the In predicate on the "type" field.
|
||||
func TypeIn(vs ...Type) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||
func TypeNotIn(vs ...Type) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldType, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasObjet applies the HasEdge predicate on the "objet" edge.
|
||||
func HasObjet() predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasObjetWith applies the HasEdge predicate on the "objet" edge with a given conditions (other predicates).
|
||||
func HasObjetWith(preds ...predicate.Objet) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
step := newObjetStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasEmplacement applies the HasEdge predicate on the "emplacement" edge.
|
||||
func HasEmplacement() predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, EmplacementTable, EmplacementColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasEmplacementWith applies the HasEdge predicate on the "emplacement" edge with a given conditions (other predicates).
|
||||
func HasEmplacementWith(preds ...predicate.Emplacement) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
step := newEmplacementStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.LienObjetEmplacement) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.LienObjetEmplacement) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.LienObjetEmplacement) predicate.LienObjetEmplacement {
|
||||
return predicate.LienObjetEmplacement(sql.NotPredicates(p))
|
||||
}
|
||||
351
backend/internal/data/ent/lienobjetemplacement_create.go
Normal file
351
backend/internal/data/ent/lienobjetemplacement_create.go
Normal file
@@ -0,0 +1,351 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// LienObjetEmplacementCreate is the builder for creating a LienObjetEmplacement entity.
|
||||
type LienObjetEmplacementCreate struct {
|
||||
config
|
||||
mutation *LienObjetEmplacementMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetObjetID(v uuid.UUID) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetObjetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEmplacementID sets the "emplacement_id" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetEmplacementID(v uuid.UUID) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetEmplacementID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetType(v lienobjetemplacement.Type) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (_c *LienObjetEmplacementCreate) SetNillableType(v *lienobjetemplacement.Type) *LienObjetEmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetType(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetCreatedAt(v time.Time) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *LienObjetEmplacementCreate) SetNillableCreatedAt(v *time.Time) *LienObjetEmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetUpdatedAt(v time.Time) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *LienObjetEmplacementCreate) SetNillableUpdatedAt(v *time.Time) *LienObjetEmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *LienObjetEmplacementCreate) SetID(v uuid.UUID) *LienObjetEmplacementCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *LienObjetEmplacementCreate) SetNillableID(v *uuid.UUID) *LienObjetEmplacementCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_c *LienObjetEmplacementCreate) SetObjet(v *Objet) *LienObjetEmplacementCreate {
|
||||
return _c.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// SetEmplacement sets the "emplacement" edge to the Emplacement entity.
|
||||
func (_c *LienObjetEmplacementCreate) SetEmplacement(v *Emplacement) *LienObjetEmplacementCreate {
|
||||
return _c.SetEmplacementID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the LienObjetEmplacementMutation object of the builder.
|
||||
func (_c *LienObjetEmplacementCreate) Mutation() *LienObjetEmplacementMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the LienObjetEmplacement in the database.
|
||||
func (_c *LienObjetEmplacementCreate) Save(ctx context.Context) (*LienObjetEmplacement, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *LienObjetEmplacementCreate) SaveX(ctx context.Context) *LienObjetEmplacement {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *LienObjetEmplacementCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *LienObjetEmplacementCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *LienObjetEmplacementCreate) defaults() {
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
v := lienobjetemplacement.DefaultType
|
||||
_c.mutation.SetType(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := lienobjetemplacement.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := lienobjetemplacement.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := lienobjetemplacement.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *LienObjetEmplacementCreate) check() error {
|
||||
if _, ok := _c.mutation.ObjetID(); !ok {
|
||||
return &ValidationError{Name: "objet_id", err: errors.New(`ent: missing required field "LienObjetEmplacement.objet_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.EmplacementID(); !ok {
|
||||
return &ValidationError{Name: "emplacement_id", err: errors.New(`ent: missing required field "LienObjetEmplacement.emplacement_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.GetType(); !ok {
|
||||
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "LienObjetEmplacement.type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.GetType(); ok {
|
||||
if err := lienobjetemplacement.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "LienObjetEmplacement.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "LienObjetEmplacement.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "LienObjetEmplacement.updated_at"`)}
|
||||
}
|
||||
if len(_c.mutation.ObjetIDs()) == 0 {
|
||||
return &ValidationError{Name: "objet", err: errors.New(`ent: missing required edge "LienObjetEmplacement.objet"`)}
|
||||
}
|
||||
if len(_c.mutation.EmplacementIDs()) == 0 {
|
||||
return &ValidationError{Name: "emplacement", err: errors.New(`ent: missing required edge "LienObjetEmplacement.emplacement"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *LienObjetEmplacementCreate) sqlSave(ctx context.Context) (*LienObjetEmplacement, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *LienObjetEmplacementCreate) createSpec() (*LienObjetEmplacement, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &LienObjetEmplacement{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(lienobjetemplacement.Table, sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.GetType(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.ObjetTable,
|
||||
Columns: []string{lienobjetemplacement.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.ObjetID = nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.EmplacementIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.EmplacementTable,
|
||||
Columns: []string{lienobjetemplacement.EmplacementColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.EmplacementID = nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// LienObjetEmplacementCreateBulk is the builder for creating many LienObjetEmplacement entities in bulk.
|
||||
type LienObjetEmplacementCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*LienObjetEmplacementCreate
|
||||
}
|
||||
|
||||
// Save creates the LienObjetEmplacement entities in the database.
|
||||
func (_c *LienObjetEmplacementCreateBulk) Save(ctx context.Context) ([]*LienObjetEmplacement, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*LienObjetEmplacement, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*LienObjetEmplacementMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *LienObjetEmplacementCreateBulk) SaveX(ctx context.Context) []*LienObjetEmplacement {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *LienObjetEmplacementCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *LienObjetEmplacementCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/lienobjetemplacement_delete.go
Normal file
88
backend/internal/data/ent/lienobjetemplacement_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// LienObjetEmplacementDelete is the builder for deleting a LienObjetEmplacement entity.
|
||||
type LienObjetEmplacementDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *LienObjetEmplacementMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LienObjetEmplacementDelete builder.
|
||||
func (_d *LienObjetEmplacementDelete) Where(ps ...predicate.LienObjetEmplacement) *LienObjetEmplacementDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *LienObjetEmplacementDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *LienObjetEmplacementDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *LienObjetEmplacementDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(lienobjetemplacement.Table, sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// LienObjetEmplacementDeleteOne is the builder for deleting a single LienObjetEmplacement entity.
|
||||
type LienObjetEmplacementDeleteOne struct {
|
||||
_d *LienObjetEmplacementDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LienObjetEmplacementDelete builder.
|
||||
func (_d *LienObjetEmplacementDeleteOne) Where(ps ...predicate.LienObjetEmplacement) *LienObjetEmplacementDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *LienObjetEmplacementDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{lienobjetemplacement.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *LienObjetEmplacementDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
682
backend/internal/data/ent/lienobjetemplacement_query.go
Normal file
682
backend/internal/data/ent/lienobjetemplacement_query.go
Normal file
@@ -0,0 +1,682 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// LienObjetEmplacementQuery is the builder for querying LienObjetEmplacement entities.
|
||||
type LienObjetEmplacementQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []lienobjetemplacement.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.LienObjetEmplacement
|
||||
withObjet *ObjetQuery
|
||||
withEmplacement *EmplacementQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the LienObjetEmplacementQuery builder.
|
||||
func (_q *LienObjetEmplacementQuery) Where(ps ...predicate.LienObjetEmplacement) *LienObjetEmplacementQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *LienObjetEmplacementQuery) Limit(limit int) *LienObjetEmplacementQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *LienObjetEmplacementQuery) Offset(offset int) *LienObjetEmplacementQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *LienObjetEmplacementQuery) Unique(unique bool) *LienObjetEmplacementQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *LienObjetEmplacementQuery) Order(o ...lienobjetemplacement.OrderOption) *LienObjetEmplacementQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryObjet chains the current query on the "objet" edge.
|
||||
func (_q *LienObjetEmplacementQuery) QueryObjet() *ObjetQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(lienobjetemplacement.Table, lienobjetemplacement.FieldID, selector),
|
||||
sqlgraph.To(objet.Table, objet.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, lienobjetemplacement.ObjetTable, lienobjetemplacement.ObjetColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryEmplacement chains the current query on the "emplacement" edge.
|
||||
func (_q *LienObjetEmplacementQuery) QueryEmplacement() *EmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(lienobjetemplacement.Table, lienobjetemplacement.FieldID, selector),
|
||||
sqlgraph.To(emplacement.Table, emplacement.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, lienobjetemplacement.EmplacementTable, lienobjetemplacement.EmplacementColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first LienObjetEmplacement entity from the query.
|
||||
// Returns a *NotFoundError when no LienObjetEmplacement was found.
|
||||
func (_q *LienObjetEmplacementQuery) First(ctx context.Context) (*LienObjetEmplacement, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{lienobjetemplacement.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) FirstX(ctx context.Context) *LienObjetEmplacement {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first LienObjetEmplacement ID from the query.
|
||||
// Returns a *NotFoundError when no LienObjetEmplacement ID was found.
|
||||
func (_q *LienObjetEmplacementQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{lienobjetemplacement.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single LienObjetEmplacement entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one LienObjetEmplacement entity is found.
|
||||
// Returns a *NotFoundError when no LienObjetEmplacement entities are found.
|
||||
func (_q *LienObjetEmplacementQuery) Only(ctx context.Context) (*LienObjetEmplacement, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{lienobjetemplacement.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{lienobjetemplacement.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) OnlyX(ctx context.Context) *LienObjetEmplacement {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only LienObjetEmplacement ID in the query.
|
||||
// Returns a *NotSingularError when more than one LienObjetEmplacement ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *LienObjetEmplacementQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{lienobjetemplacement.Label}
|
||||
default:
|
||||
err = &NotSingularError{lienobjetemplacement.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of LienObjetEmplacements.
|
||||
func (_q *LienObjetEmplacementQuery) All(ctx context.Context) ([]*LienObjetEmplacement, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*LienObjetEmplacement, *LienObjetEmplacementQuery]()
|
||||
return withInterceptors[[]*LienObjetEmplacement](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) AllX(ctx context.Context) []*LienObjetEmplacement {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of LienObjetEmplacement IDs.
|
||||
func (_q *LienObjetEmplacementQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(lienobjetemplacement.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *LienObjetEmplacementQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*LienObjetEmplacementQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *LienObjetEmplacementQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *LienObjetEmplacementQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the LienObjetEmplacementQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *LienObjetEmplacementQuery) Clone() *LienObjetEmplacementQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &LienObjetEmplacementQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]lienobjetemplacement.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.LienObjetEmplacement{}, _q.predicates...),
|
||||
withObjet: _q.withObjet.Clone(),
|
||||
withEmplacement: _q.withEmplacement.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithObjet tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "objet" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *LienObjetEmplacementQuery) WithObjet(opts ...func(*ObjetQuery)) *LienObjetEmplacementQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withObjet = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithEmplacement tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "emplacement" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *LienObjetEmplacementQuery) WithEmplacement(opts ...func(*EmplacementQuery)) *LienObjetEmplacementQuery {
|
||||
query := (&EmplacementClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withEmplacement = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.LienObjetEmplacement.Query().
|
||||
// GroupBy(lienobjetemplacement.FieldObjetID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *LienObjetEmplacementQuery) GroupBy(field string, fields ...string) *LienObjetEmplacementGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &LienObjetEmplacementGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = lienobjetemplacement.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.LienObjetEmplacement.Query().
|
||||
// Select(lienobjetemplacement.FieldObjetID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *LienObjetEmplacementQuery) Select(fields ...string) *LienObjetEmplacementSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &LienObjetEmplacementSelect{LienObjetEmplacementQuery: _q}
|
||||
sbuild.label = lienobjetemplacement.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a LienObjetEmplacementSelect configured with the given aggregations.
|
||||
func (_q *LienObjetEmplacementQuery) Aggregate(fns ...AggregateFunc) *LienObjetEmplacementSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !lienobjetemplacement.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*LienObjetEmplacement, error) {
|
||||
var (
|
||||
nodes = []*LienObjetEmplacement{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
_q.withObjet != nil,
|
||||
_q.withEmplacement != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*LienObjetEmplacement).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &LienObjetEmplacement{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withObjet; query != nil {
|
||||
if err := _q.loadObjet(ctx, query, nodes, nil,
|
||||
func(n *LienObjetEmplacement, e *Objet) { n.Edges.Objet = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withEmplacement; query != nil {
|
||||
if err := _q.loadEmplacement(ctx, query, nodes, nil,
|
||||
func(n *LienObjetEmplacement, e *Emplacement) { n.Edges.Emplacement = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) loadObjet(ctx context.Context, query *ObjetQuery, nodes []*LienObjetEmplacement, init func(*LienObjetEmplacement), assign func(*LienObjetEmplacement, *Objet)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*LienObjetEmplacement)
|
||||
for i := range nodes {
|
||||
fk := nodes[i].ObjetID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(objet.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "objet_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *LienObjetEmplacementQuery) loadEmplacement(ctx context.Context, query *EmplacementQuery, nodes []*LienObjetEmplacement, init func(*LienObjetEmplacement), assign func(*LienObjetEmplacement, *Emplacement)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*LienObjetEmplacement)
|
||||
for i := range nodes {
|
||||
fk := nodes[i].EmplacementID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(emplacement.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "emplacement_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(lienobjetemplacement.Table, lienobjetemplacement.Columns, sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, lienobjetemplacement.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != lienobjetemplacement.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withObjet != nil {
|
||||
_spec.Node.AddColumnOnce(lienobjetemplacement.FieldObjetID)
|
||||
}
|
||||
if _q.withEmplacement != nil {
|
||||
_spec.Node.AddColumnOnce(lienobjetemplacement.FieldEmplacementID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *LienObjetEmplacementQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(lienobjetemplacement.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = lienobjetemplacement.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// LienObjetEmplacementGroupBy is the group-by builder for LienObjetEmplacement entities.
|
||||
type LienObjetEmplacementGroupBy struct {
|
||||
selector
|
||||
build *LienObjetEmplacementQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *LienObjetEmplacementGroupBy) Aggregate(fns ...AggregateFunc) *LienObjetEmplacementGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *LienObjetEmplacementGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*LienObjetEmplacementQuery, *LienObjetEmplacementGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *LienObjetEmplacementGroupBy) sqlScan(ctx context.Context, root *LienObjetEmplacementQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// LienObjetEmplacementSelect is the builder for selecting fields of LienObjetEmplacement entities.
|
||||
type LienObjetEmplacementSelect struct {
|
||||
*LienObjetEmplacementQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *LienObjetEmplacementSelect) Aggregate(fns ...AggregateFunc) *LienObjetEmplacementSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *LienObjetEmplacementSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*LienObjetEmplacementQuery, *LienObjetEmplacementSelect](ctx, _s.LienObjetEmplacementQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *LienObjetEmplacementSelect) sqlScan(ctx context.Context, root *LienObjetEmplacementQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
537
backend/internal/data/ent/lienobjetemplacement_update.go
Normal file
537
backend/internal/data/ent/lienobjetemplacement_update.go
Normal file
@@ -0,0 +1,537 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// LienObjetEmplacementUpdate is the builder for updating LienObjetEmplacement entities.
|
||||
type LienObjetEmplacementUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *LienObjetEmplacementMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LienObjetEmplacementUpdate builder.
|
||||
func (_u *LienObjetEmplacementUpdate) Where(ps ...predicate.LienObjetEmplacement) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *LienObjetEmplacementUpdate) SetObjetID(v uuid.UUID) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdate) SetNillableObjetID(v *uuid.UUID) *LienObjetEmplacementUpdate {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEmplacementID sets the "emplacement_id" field.
|
||||
func (_u *LienObjetEmplacementUpdate) SetEmplacementID(v uuid.UUID) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.SetEmplacementID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEmplacementID sets the "emplacement_id" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdate) SetNillableEmplacementID(v *uuid.UUID) *LienObjetEmplacementUpdate {
|
||||
if v != nil {
|
||||
_u.SetEmplacementID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_u *LienObjetEmplacementUpdate) SetType(v lienobjetemplacement.Type) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdate) SetNillableType(v *lienobjetemplacement.Type) *LienObjetEmplacementUpdate {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *LienObjetEmplacementUpdate) SetCreatedAt(v time.Time) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdate) SetNillableCreatedAt(v *time.Time) *LienObjetEmplacementUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *LienObjetEmplacementUpdate) SetUpdatedAt(v time.Time) *LienObjetEmplacementUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *LienObjetEmplacementUpdate) SetObjet(v *Objet) *LienObjetEmplacementUpdate {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// SetEmplacement sets the "emplacement" edge to the Emplacement entity.
|
||||
func (_u *LienObjetEmplacementUpdate) SetEmplacement(v *Emplacement) *LienObjetEmplacementUpdate {
|
||||
return _u.SetEmplacementID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the LienObjetEmplacementMutation object of the builder.
|
||||
func (_u *LienObjetEmplacementUpdate) Mutation() *LienObjetEmplacementMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *LienObjetEmplacementUpdate) ClearObjet() *LienObjetEmplacementUpdate {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEmplacement clears the "emplacement" edge to the Emplacement entity.
|
||||
func (_u *LienObjetEmplacementUpdate) ClearEmplacement() *LienObjetEmplacementUpdate {
|
||||
_u.mutation.ClearEmplacement()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *LienObjetEmplacementUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *LienObjetEmplacementUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *LienObjetEmplacementUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *LienObjetEmplacementUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *LienObjetEmplacementUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := lienobjetemplacement.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *LienObjetEmplacementUpdate) check() error {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := lienobjetemplacement.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "LienObjetEmplacement.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "LienObjetEmplacement.objet"`)
|
||||
}
|
||||
if _u.mutation.EmplacementCleared() && len(_u.mutation.EmplacementIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "LienObjetEmplacement.emplacement"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *LienObjetEmplacementUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(lienobjetemplacement.Table, lienobjetemplacement.Columns, sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.ObjetTable,
|
||||
Columns: []string{lienobjetemplacement.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.ObjetTable,
|
||||
Columns: []string{lienobjetemplacement.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.EmplacementCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.EmplacementTable,
|
||||
Columns: []string{lienobjetemplacement.EmplacementColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.EmplacementIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.EmplacementTable,
|
||||
Columns: []string{lienobjetemplacement.EmplacementColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{lienobjetemplacement.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// LienObjetEmplacementUpdateOne is the builder for updating a single LienObjetEmplacement entity.
|
||||
type LienObjetEmplacementUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *LienObjetEmplacementMutation
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetObjetID(v uuid.UUID) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetNillableObjetID(v *uuid.UUID) *LienObjetEmplacementUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEmplacementID sets the "emplacement_id" field.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetEmplacementID(v uuid.UUID) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.SetEmplacementID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEmplacementID sets the "emplacement_id" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetNillableEmplacementID(v *uuid.UUID) *LienObjetEmplacementUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEmplacementID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetType sets the "type" field.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetType(v lienobjetemplacement.Type) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.SetType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableType sets the "type" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetNillableType(v *lienobjetemplacement.Type) *LienObjetEmplacementUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetCreatedAt(v time.Time) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetNillableCreatedAt(v *time.Time) *LienObjetEmplacementUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetUpdatedAt(v time.Time) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetObjet(v *Objet) *LienObjetEmplacementUpdateOne {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// SetEmplacement sets the "emplacement" edge to the Emplacement entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SetEmplacement(v *Emplacement) *LienObjetEmplacementUpdateOne {
|
||||
return _u.SetEmplacementID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the LienObjetEmplacementMutation object of the builder.
|
||||
func (_u *LienObjetEmplacementUpdateOne) Mutation() *LienObjetEmplacementMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) ClearObjet() *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEmplacement clears the "emplacement" edge to the Emplacement entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) ClearEmplacement() *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.ClearEmplacement()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the LienObjetEmplacementUpdate builder.
|
||||
func (_u *LienObjetEmplacementUpdateOne) Where(ps ...predicate.LienObjetEmplacement) *LienObjetEmplacementUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *LienObjetEmplacementUpdateOne) Select(field string, fields ...string) *LienObjetEmplacementUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated LienObjetEmplacement entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) Save(ctx context.Context) (*LienObjetEmplacement, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *LienObjetEmplacementUpdateOne) SaveX(ctx context.Context) *LienObjetEmplacement {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *LienObjetEmplacementUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *LienObjetEmplacementUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *LienObjetEmplacementUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := lienobjetemplacement.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *LienObjetEmplacementUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.GetType(); ok {
|
||||
if err := lienobjetemplacement.TypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "LienObjetEmplacement.type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "LienObjetEmplacement.objet"`)
|
||||
}
|
||||
if _u.mutation.EmplacementCleared() && len(_u.mutation.EmplacementIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "LienObjetEmplacement.emplacement"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *LienObjetEmplacementUpdateOne) sqlSave(ctx context.Context) (_node *LienObjetEmplacement, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(lienobjetemplacement.Table, lienobjetemplacement.Columns, sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "LienObjetEmplacement.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, lienobjetemplacement.FieldID)
|
||||
for _, f := range fields {
|
||||
if !lienobjetemplacement.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != lienobjetemplacement.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.GetType(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(lienobjetemplacement.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.ObjetTable,
|
||||
Columns: []string{lienobjetemplacement.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.ObjetTable,
|
||||
Columns: []string{lienobjetemplacement.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.EmplacementCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.EmplacementTable,
|
||||
Columns: []string{lienobjetemplacement.EmplacementColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.EmplacementIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: lienobjetemplacement.EmplacementTable,
|
||||
Columns: []string{lienobjetemplacement.EmplacementColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(emplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &LienObjetEmplacement{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{lienobjetemplacement.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
64
backend/internal/data/ent/migrate/migrate.go
Normal file
64
backend/internal/data/ent/migrate/migrate.go
Normal file
@@ -0,0 +1,64 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||
WithForeignKeys = schema.WithForeignKeys
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, s, Tables, opts...)
|
||||
}
|
||||
|
||||
// Create creates all table resources using the given schema driver.
|
||||
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Create(ctx, tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||
}
|
||||
202
backend/internal/data/ent/migrate/schema.go
Normal file
202
backend/internal/data/ent/migrate/schema.go
Normal file
@@ -0,0 +1,202 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// CategorieColumns holds the columns for the "categorie" table.
|
||||
CategorieColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "nom", Type: field.TypeString},
|
||||
{Name: "slug", Type: field.TypeString, Nullable: true},
|
||||
{Name: "icone", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "parent_id", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// CategorieTable holds the schema information for the "categorie" table.
|
||||
CategorieTable = &schema.Table{
|
||||
Name: "categorie",
|
||||
Columns: CategorieColumns,
|
||||
PrimaryKey: []*schema.Column{CategorieColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "categorie_categorie_enfants",
|
||||
Columns: []*schema.Column{CategorieColumns[6]},
|
||||
RefColumns: []*schema.Column{CategorieColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ChampPersonnaliseColumns holds the columns for the "champ_personnalise" table.
|
||||
ChampPersonnaliseColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "nom_champ", Type: field.TypeString},
|
||||
{Name: "type_champ", Type: field.TypeEnum, Enums: []string{"string", "int", "bool", "date"}, Default: "string"},
|
||||
{Name: "valeur", Type: field.TypeString, Nullable: true},
|
||||
{Name: "unite", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "objet_id", Type: field.TypeUUID},
|
||||
}
|
||||
// ChampPersonnaliseTable holds the schema information for the "champ_personnalise" table.
|
||||
ChampPersonnaliseTable = &schema.Table{
|
||||
Name: "champ_personnalise",
|
||||
Columns: ChampPersonnaliseColumns,
|
||||
PrimaryKey: []*schema.Column{ChampPersonnaliseColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "champ_personnalise_objet_champs_personnalises",
|
||||
Columns: []*schema.Column{ChampPersonnaliseColumns[7]},
|
||||
RefColumns: []*schema.Column{ObjetColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// EmplacementColumns holds the columns for the "emplacement" table.
|
||||
EmplacementColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "nom", Type: field.TypeString},
|
||||
{Name: "slug", Type: field.TypeString, Nullable: true},
|
||||
{Name: "piece", Type: field.TypeString, Nullable: true},
|
||||
{Name: "meuble", Type: field.TypeString, Nullable: true},
|
||||
{Name: "numero_boite", Type: field.TypeString, Nullable: true},
|
||||
{Name: "icone", Type: field.TypeString, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "parent_id", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
// EmplacementTable holds the schema information for the "emplacement" table.
|
||||
EmplacementTable = &schema.Table{
|
||||
Name: "emplacement",
|
||||
Columns: EmplacementColumns,
|
||||
PrimaryKey: []*schema.Column{EmplacementColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "emplacement_emplacement_enfants",
|
||||
Columns: []*schema.Column{EmplacementColumns[9]},
|
||||
RefColumns: []*schema.Column{EmplacementColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// LienObjetEmplacementColumns holds the columns for the "lien_objet_emplacement" table.
|
||||
LienObjetEmplacementColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "type", Type: field.TypeEnum, Enums: []string{"stocke", "utilise_dans"}, Default: "stocke"},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "emplacement_id", Type: field.TypeUUID},
|
||||
{Name: "objet_id", Type: field.TypeUUID},
|
||||
}
|
||||
// LienObjetEmplacementTable holds the schema information for the "lien_objet_emplacement" table.
|
||||
LienObjetEmplacementTable = &schema.Table{
|
||||
Name: "lien_objet_emplacement",
|
||||
Columns: LienObjetEmplacementColumns,
|
||||
PrimaryKey: []*schema.Column{LienObjetEmplacementColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "lien_objet_emplacement_emplacement_liens_objets",
|
||||
Columns: []*schema.Column{LienObjetEmplacementColumns[4]},
|
||||
RefColumns: []*schema.Column{EmplacementColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "lien_objet_emplacement_objet_liens_emplacements",
|
||||
Columns: []*schema.Column{LienObjetEmplacementColumns[5]},
|
||||
RefColumns: []*schema.Column{ObjetColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ObjetColumns holds the columns for the "objet" table.
|
||||
ObjetColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "nom", Type: field.TypeString},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true},
|
||||
{Name: "quantite", Type: field.TypeInt, Default: 0},
|
||||
{Name: "prix_achat", Type: field.TypeFloat64, Nullable: true},
|
||||
{Name: "date_achat", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "boutique", Type: field.TypeString, Nullable: true},
|
||||
{Name: "numero_serie", Type: field.TypeString, Nullable: true},
|
||||
{Name: "numero_modele", Type: field.TypeString, Nullable: true},
|
||||
{Name: "fabricant", Type: field.TypeString, Nullable: true},
|
||||
{Name: "statut", Type: field.TypeEnum, Enums: []string{"en_stock", "pret", "hors_service", "archive"}, Default: "en_stock"},
|
||||
{Name: "caracteristiques", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// ObjetTable holds the schema information for the "objet" table.
|
||||
ObjetTable = &schema.Table{
|
||||
Name: "objet",
|
||||
Columns: ObjetColumns,
|
||||
PrimaryKey: []*schema.Column{ObjetColumns[0]},
|
||||
}
|
||||
// PieceJointeColumns holds the columns for the "piece_jointe" table.
|
||||
PieceJointeColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "nom_fichier", Type: field.TypeString},
|
||||
{Name: "chemin", Type: field.TypeString},
|
||||
{Name: "type_mime", Type: field.TypeString},
|
||||
{Name: "est_principale", Type: field.TypeBool, Default: false},
|
||||
{Name: "categorie", Type: field.TypeEnum, Enums: []string{"image", "pdf_notice", "markdown_tuto"}, Default: "image"},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "objet_id", Type: field.TypeUUID},
|
||||
}
|
||||
// PieceJointeTable holds the schema information for the "piece_jointe" table.
|
||||
PieceJointeTable = &schema.Table{
|
||||
Name: "piece_jointe",
|
||||
Columns: PieceJointeColumns,
|
||||
PrimaryKey: []*schema.Column{PieceJointeColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "piece_jointe_objet_pieces_jointes",
|
||||
Columns: []*schema.Column{PieceJointeColumns[8]},
|
||||
RefColumns: []*schema.Column{ObjetColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
CategorieTable,
|
||||
ChampPersonnaliseTable,
|
||||
EmplacementTable,
|
||||
LienObjetEmplacementTable,
|
||||
ObjetTable,
|
||||
PieceJointeTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
CategorieTable.ForeignKeys[0].RefTable = CategorieTable
|
||||
CategorieTable.Annotation = &entsql.Annotation{
|
||||
Table: "categorie",
|
||||
}
|
||||
ChampPersonnaliseTable.ForeignKeys[0].RefTable = ObjetTable
|
||||
ChampPersonnaliseTable.Annotation = &entsql.Annotation{
|
||||
Table: "champ_personnalise",
|
||||
}
|
||||
EmplacementTable.ForeignKeys[0].RefTable = EmplacementTable
|
||||
EmplacementTable.Annotation = &entsql.Annotation{
|
||||
Table: "emplacement",
|
||||
}
|
||||
LienObjetEmplacementTable.ForeignKeys[0].RefTable = EmplacementTable
|
||||
LienObjetEmplacementTable.ForeignKeys[1].RefTable = ObjetTable
|
||||
LienObjetEmplacementTable.Annotation = &entsql.Annotation{
|
||||
Table: "lien_objet_emplacement",
|
||||
}
|
||||
ObjetTable.Annotation = &entsql.Annotation{
|
||||
Table: "objet",
|
||||
}
|
||||
PieceJointeTable.ForeignKeys[0].RefTable = ObjetTable
|
||||
PieceJointeTable.Annotation = &entsql.Annotation{
|
||||
Table: "piece_jointe",
|
||||
}
|
||||
}
|
||||
5570
backend/internal/data/ent/mutation.go
Normal file
5570
backend/internal/data/ent/mutation.go
Normal file
File diff suppressed because it is too large
Load Diff
328
backend/internal/data/ent/objet.go
Normal file
328
backend/internal/data/ent/objet.go
Normal file
@@ -0,0 +1,328 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Objet is the model entity for the Objet schema.
|
||||
type Objet struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique de l'objet
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Nom de l'objet
|
||||
Nom string `json:"nom,omitempty"`
|
||||
// Description libre
|
||||
Description *string `json:"description,omitempty"`
|
||||
// Quantite en stock
|
||||
Quantite int `json:"quantite,omitempty"`
|
||||
// Prix d'achat
|
||||
PrixAchat *float64 `json:"prix_achat,omitempty"`
|
||||
// Date d'achat
|
||||
DateAchat *time.Time `json:"date_achat,omitempty"`
|
||||
// Boutique ou fournisseur
|
||||
Boutique *string `json:"boutique,omitempty"`
|
||||
// Numero de serie
|
||||
NumeroSerie *string `json:"numero_serie,omitempty"`
|
||||
// Numero de modele
|
||||
NumeroModele *string `json:"numero_modele,omitempty"`
|
||||
// Fabricant
|
||||
Fabricant *string `json:"fabricant,omitempty"`
|
||||
// Statut de l'objet
|
||||
Statut objet.Statut `json:"statut,omitempty"`
|
||||
// Caracteristiques personnalisees
|
||||
Caracteristiques map[string]interface{} `json:"caracteristiques,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ObjetQuery when eager-loading is set.
|
||||
Edges ObjetEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ObjetEdges holds the relations/edges for other nodes in the graph.
|
||||
type ObjetEdges struct {
|
||||
// LiensEmplacements holds the value of the liens_emplacements edge.
|
||||
LiensEmplacements []*LienObjetEmplacement `json:"liens_emplacements,omitempty"`
|
||||
// ChampsPersonnalises holds the value of the champs_personnalises edge.
|
||||
ChampsPersonnalises []*ChampPersonnalise `json:"champs_personnalises,omitempty"`
|
||||
// PiecesJointes holds the value of the pieces_jointes edge.
|
||||
PiecesJointes []*PieceJointe `json:"pieces_jointes,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [3]bool
|
||||
}
|
||||
|
||||
// LiensEmplacementsOrErr returns the LiensEmplacements value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ObjetEdges) LiensEmplacementsOrErr() ([]*LienObjetEmplacement, error) {
|
||||
if e.loadedTypes[0] {
|
||||
return e.LiensEmplacements, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "liens_emplacements"}
|
||||
}
|
||||
|
||||
// ChampsPersonnalisesOrErr returns the ChampsPersonnalises value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ObjetEdges) ChampsPersonnalisesOrErr() ([]*ChampPersonnalise, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.ChampsPersonnalises, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "champs_personnalises"}
|
||||
}
|
||||
|
||||
// PiecesJointesOrErr returns the PiecesJointes value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ObjetEdges) PiecesJointesOrErr() ([]*PieceJointe, error) {
|
||||
if e.loadedTypes[2] {
|
||||
return e.PiecesJointes, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "pieces_jointes"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Objet) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case objet.FieldCaracteristiques:
|
||||
values[i] = new([]byte)
|
||||
case objet.FieldPrixAchat:
|
||||
values[i] = new(sql.NullFloat64)
|
||||
case objet.FieldQuantite:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case objet.FieldNom, objet.FieldDescription, objet.FieldBoutique, objet.FieldNumeroSerie, objet.FieldNumeroModele, objet.FieldFabricant, objet.FieldStatut:
|
||||
values[i] = new(sql.NullString)
|
||||
case objet.FieldDateAchat, objet.FieldCreatedAt, objet.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case objet.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Objet fields.
|
||||
func (_m *Objet) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case objet.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case objet.FieldNom:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nom", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Nom = value.String
|
||||
}
|
||||
case objet.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Description = new(string)
|
||||
*_m.Description = value.String
|
||||
}
|
||||
case objet.FieldQuantite:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field quantite", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Quantite = int(value.Int64)
|
||||
}
|
||||
case objet.FieldPrixAchat:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field prix_achat", values[i])
|
||||
} else if value.Valid {
|
||||
_m.PrixAchat = new(float64)
|
||||
*_m.PrixAchat = value.Float64
|
||||
}
|
||||
case objet.FieldDateAchat:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field date_achat", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DateAchat = new(time.Time)
|
||||
*_m.DateAchat = value.Time
|
||||
}
|
||||
case objet.FieldBoutique:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field boutique", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Boutique = new(string)
|
||||
*_m.Boutique = value.String
|
||||
}
|
||||
case objet.FieldNumeroSerie:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field numero_serie", values[i])
|
||||
} else if value.Valid {
|
||||
_m.NumeroSerie = new(string)
|
||||
*_m.NumeroSerie = value.String
|
||||
}
|
||||
case objet.FieldNumeroModele:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field numero_modele", values[i])
|
||||
} else if value.Valid {
|
||||
_m.NumeroModele = new(string)
|
||||
*_m.NumeroModele = value.String
|
||||
}
|
||||
case objet.FieldFabricant:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field fabricant", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Fabricant = new(string)
|
||||
*_m.Fabricant = value.String
|
||||
}
|
||||
case objet.FieldStatut:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field statut", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Statut = objet.Statut(value.String)
|
||||
}
|
||||
case objet.FieldCaracteristiques:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field caracteristiques", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.Caracteristiques); err != nil {
|
||||
return fmt.Errorf("unmarshal field caracteristiques: %w", err)
|
||||
}
|
||||
}
|
||||
case objet.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case objet.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Objet.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Objet) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryLiensEmplacements queries the "liens_emplacements" edge of the Objet entity.
|
||||
func (_m *Objet) QueryLiensEmplacements() *LienObjetEmplacementQuery {
|
||||
return NewObjetClient(_m.config).QueryLiensEmplacements(_m)
|
||||
}
|
||||
|
||||
// QueryChampsPersonnalises queries the "champs_personnalises" edge of the Objet entity.
|
||||
func (_m *Objet) QueryChampsPersonnalises() *ChampPersonnaliseQuery {
|
||||
return NewObjetClient(_m.config).QueryChampsPersonnalises(_m)
|
||||
}
|
||||
|
||||
// QueryPiecesJointes queries the "pieces_jointes" edge of the Objet entity.
|
||||
func (_m *Objet) QueryPiecesJointes() *PieceJointeQuery {
|
||||
return NewObjetClient(_m.config).QueryPiecesJointes(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Objet.
|
||||
// Note that you need to call Objet.Unwrap() before calling this method if this Objet
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Objet) Update() *ObjetUpdateOne {
|
||||
return NewObjetClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Objet entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *Objet) Unwrap() *Objet {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Objet is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Objet) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Objet(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("nom=")
|
||||
builder.WriteString(_m.Nom)
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Description; v != nil {
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("quantite=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Quantite))
|
||||
builder.WriteString(", ")
|
||||
if v := _m.PrixAchat; v != nil {
|
||||
builder.WriteString("prix_achat=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.DateAchat; v != nil {
|
||||
builder.WriteString("date_achat=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Boutique; v != nil {
|
||||
builder.WriteString("boutique=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.NumeroSerie; v != nil {
|
||||
builder.WriteString("numero_serie=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.NumeroModele; v != nil {
|
||||
builder.WriteString("numero_modele=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Fabricant; v != nil {
|
||||
builder.WriteString("fabricant=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("statut=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Statut))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("caracteristiques=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Caracteristiques))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Objets is a parsable slice of Objet.
|
||||
type Objets []*Objet
|
||||
276
backend/internal/data/ent/objet/objet.go
Normal file
276
backend/internal/data/ent/objet/objet.go
Normal file
@@ -0,0 +1,276 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package objet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the objet type in the database.
|
||||
Label = "objet"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldNom holds the string denoting the nom field in the database.
|
||||
FieldNom = "nom"
|
||||
// FieldDescription holds the string denoting the description field in the database.
|
||||
FieldDescription = "description"
|
||||
// FieldQuantite holds the string denoting the quantite field in the database.
|
||||
FieldQuantite = "quantite"
|
||||
// FieldPrixAchat holds the string denoting the prix_achat field in the database.
|
||||
FieldPrixAchat = "prix_achat"
|
||||
// FieldDateAchat holds the string denoting the date_achat field in the database.
|
||||
FieldDateAchat = "date_achat"
|
||||
// FieldBoutique holds the string denoting the boutique field in the database.
|
||||
FieldBoutique = "boutique"
|
||||
// FieldNumeroSerie holds the string denoting the numero_serie field in the database.
|
||||
FieldNumeroSerie = "numero_serie"
|
||||
// FieldNumeroModele holds the string denoting the numero_modele field in the database.
|
||||
FieldNumeroModele = "numero_modele"
|
||||
// FieldFabricant holds the string denoting the fabricant field in the database.
|
||||
FieldFabricant = "fabricant"
|
||||
// FieldStatut holds the string denoting the statut field in the database.
|
||||
FieldStatut = "statut"
|
||||
// FieldCaracteristiques holds the string denoting the caracteristiques field in the database.
|
||||
FieldCaracteristiques = "caracteristiques"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeLiensEmplacements holds the string denoting the liens_emplacements edge name in mutations.
|
||||
EdgeLiensEmplacements = "liens_emplacements"
|
||||
// EdgeChampsPersonnalises holds the string denoting the champs_personnalises edge name in mutations.
|
||||
EdgeChampsPersonnalises = "champs_personnalises"
|
||||
// EdgePiecesJointes holds the string denoting the pieces_jointes edge name in mutations.
|
||||
EdgePiecesJointes = "pieces_jointes"
|
||||
// Table holds the table name of the objet in the database.
|
||||
Table = "objet"
|
||||
// LiensEmplacementsTable is the table that holds the liens_emplacements relation/edge.
|
||||
LiensEmplacementsTable = "lien_objet_emplacement"
|
||||
// LiensEmplacementsInverseTable is the table name for the LienObjetEmplacement entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "lienobjetemplacement" package.
|
||||
LiensEmplacementsInverseTable = "lien_objet_emplacement"
|
||||
// LiensEmplacementsColumn is the table column denoting the liens_emplacements relation/edge.
|
||||
LiensEmplacementsColumn = "objet_id"
|
||||
// ChampsPersonnalisesTable is the table that holds the champs_personnalises relation/edge.
|
||||
ChampsPersonnalisesTable = "champ_personnalise"
|
||||
// ChampsPersonnalisesInverseTable is the table name for the ChampPersonnalise entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "champpersonnalise" package.
|
||||
ChampsPersonnalisesInverseTable = "champ_personnalise"
|
||||
// ChampsPersonnalisesColumn is the table column denoting the champs_personnalises relation/edge.
|
||||
ChampsPersonnalisesColumn = "objet_id"
|
||||
// PiecesJointesTable is the table that holds the pieces_jointes relation/edge.
|
||||
PiecesJointesTable = "piece_jointe"
|
||||
// PiecesJointesInverseTable is the table name for the PieceJointe entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "piecejointe" package.
|
||||
PiecesJointesInverseTable = "piece_jointe"
|
||||
// PiecesJointesColumn is the table column denoting the pieces_jointes relation/edge.
|
||||
PiecesJointesColumn = "objet_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for objet fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldNom,
|
||||
FieldDescription,
|
||||
FieldQuantite,
|
||||
FieldPrixAchat,
|
||||
FieldDateAchat,
|
||||
FieldBoutique,
|
||||
FieldNumeroSerie,
|
||||
FieldNumeroModele,
|
||||
FieldFabricant,
|
||||
FieldStatut,
|
||||
FieldCaracteristiques,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
NomValidator func(string) error
|
||||
// DefaultQuantite holds the default value on creation for the "quantite" field.
|
||||
DefaultQuantite int
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// Statut defines the type for the "statut" enum field.
|
||||
type Statut string
|
||||
|
||||
// StatutEnStock is the default value of the Statut enum.
|
||||
const DefaultStatut = StatutEnStock
|
||||
|
||||
// Statut values.
|
||||
const (
|
||||
StatutEnStock Statut = "en_stock"
|
||||
StatutPret Statut = "pret"
|
||||
StatutHorsService Statut = "hors_service"
|
||||
StatutArchive Statut = "archive"
|
||||
)
|
||||
|
||||
func (s Statut) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// StatutValidator is a validator for the "statut" field enum values. It is called by the builders before save.
|
||||
func StatutValidator(s Statut) error {
|
||||
switch s {
|
||||
case StatutEnStock, StatutPret, StatutHorsService, StatutArchive:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("objet: invalid enum value for statut field: %q", s)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Objet queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNom orders the results by the nom field.
|
||||
func ByNom(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNom, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDescription orders the results by the description field.
|
||||
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDescription, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByQuantite orders the results by the quantite field.
|
||||
func ByQuantite(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldQuantite, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPrixAchat orders the results by the prix_achat field.
|
||||
func ByPrixAchat(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPrixAchat, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDateAchat orders the results by the date_achat field.
|
||||
func ByDateAchat(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDateAchat, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByBoutique orders the results by the boutique field.
|
||||
func ByBoutique(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldBoutique, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNumeroSerie orders the results by the numero_serie field.
|
||||
func ByNumeroSerie(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNumeroSerie, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNumeroModele orders the results by the numero_modele field.
|
||||
func ByNumeroModele(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNumeroModele, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFabricant orders the results by the fabricant field.
|
||||
func ByFabricant(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFabricant, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatut orders the results by the statut field.
|
||||
func ByStatut(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatut, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLiensEmplacementsCount orders the results by liens_emplacements count.
|
||||
func ByLiensEmplacementsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newLiensEmplacementsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByLiensEmplacements orders the results by liens_emplacements terms.
|
||||
func ByLiensEmplacements(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newLiensEmplacementsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByChampsPersonnalisesCount orders the results by champs_personnalises count.
|
||||
func ByChampsPersonnalisesCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newChampsPersonnalisesStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByChampsPersonnalises orders the results by champs_personnalises terms.
|
||||
func ByChampsPersonnalises(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newChampsPersonnalisesStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByPiecesJointesCount orders the results by pieces_jointes count.
|
||||
func ByPiecesJointesCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newPiecesJointesStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByPiecesJointes orders the results by pieces_jointes terms.
|
||||
func ByPiecesJointes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newPiecesJointesStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newLiensEmplacementsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LiensEmplacementsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LiensEmplacementsTable, LiensEmplacementsColumn),
|
||||
)
|
||||
}
|
||||
func newChampsPersonnalisesStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ChampsPersonnalisesInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ChampsPersonnalisesTable, ChampsPersonnalisesColumn),
|
||||
)
|
||||
}
|
||||
func newPiecesJointesStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PiecesJointesInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, PiecesJointesTable, PiecesJointesColumn),
|
||||
)
|
||||
}
|
||||
886
backend/internal/data/ent/objet/where.go
Normal file
886
backend/internal/data/ent/objet/where.go
Normal file
@@ -0,0 +1,886 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package objet
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Nom applies equality check predicate on the "nom" field. It's identical to NomEQ.
|
||||
func Nom(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||
func Description(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// Quantite applies equality check predicate on the "quantite" field. It's identical to QuantiteEQ.
|
||||
func Quantite(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// PrixAchat applies equality check predicate on the "prix_achat" field. It's identical to PrixAchatEQ.
|
||||
func PrixAchat(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// DateAchat applies equality check predicate on the "date_achat" field. It's identical to DateAchatEQ.
|
||||
func DateAchat(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// Boutique applies equality check predicate on the "boutique" field. It's identical to BoutiqueEQ.
|
||||
func Boutique(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// NumeroSerie applies equality check predicate on the "numero_serie" field. It's identical to NumeroSerieEQ.
|
||||
func NumeroSerie(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroModele applies equality check predicate on the "numero_modele" field. It's identical to NumeroModeleEQ.
|
||||
func NumeroModele(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// Fabricant applies equality check predicate on the "fabricant" field. It's identical to FabricantEQ.
|
||||
func Fabricant(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NomEQ applies the EQ predicate on the "nom" field.
|
||||
func NomEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomNEQ applies the NEQ predicate on the "nom" field.
|
||||
func NomNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomIn applies the In predicate on the "nom" field.
|
||||
func NomIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomNotIn applies the NotIn predicate on the "nom" field.
|
||||
func NomNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldNom, vs...))
|
||||
}
|
||||
|
||||
// NomGT applies the GT predicate on the "nom" field.
|
||||
func NomGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomGTE applies the GTE predicate on the "nom" field.
|
||||
func NomGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLT applies the LT predicate on the "nom" field.
|
||||
func NomLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomLTE applies the LTE predicate on the "nom" field.
|
||||
func NomLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContains applies the Contains predicate on the "nom" field.
|
||||
func NomContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasPrefix applies the HasPrefix predicate on the "nom" field.
|
||||
func NomHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomHasSuffix applies the HasSuffix predicate on the "nom" field.
|
||||
func NomHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomEqualFold applies the EqualFold predicate on the "nom" field.
|
||||
func NomEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// NomContainsFold applies the ContainsFold predicate on the "nom" field.
|
||||
func NomContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldNom, v))
|
||||
}
|
||||
|
||||
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||
func DescriptionEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||
func DescriptionNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIn applies the In predicate on the "description" field.
|
||||
func DescriptionIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||
func DescriptionNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionGT applies the GT predicate on the "description" field.
|
||||
func DescriptionGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||
func DescriptionGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLT applies the LT predicate on the "description" field.
|
||||
func DescriptionLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||
func DescriptionLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||
func DescriptionContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||
func DescriptionHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||
func DescriptionHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIsNil applies the IsNil predicate on the "description" field.
|
||||
func DescriptionIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionNotNil applies the NotNil predicate on the "description" field.
|
||||
func DescriptionNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||
func DescriptionEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||
func DescriptionContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// QuantiteEQ applies the EQ predicate on the "quantite" field.
|
||||
func QuantiteEQ(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// QuantiteNEQ applies the NEQ predicate on the "quantite" field.
|
||||
func QuantiteNEQ(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// QuantiteIn applies the In predicate on the "quantite" field.
|
||||
func QuantiteIn(vs ...int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldQuantite, vs...))
|
||||
}
|
||||
|
||||
// QuantiteNotIn applies the NotIn predicate on the "quantite" field.
|
||||
func QuantiteNotIn(vs ...int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldQuantite, vs...))
|
||||
}
|
||||
|
||||
// QuantiteGT applies the GT predicate on the "quantite" field.
|
||||
func QuantiteGT(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// QuantiteGTE applies the GTE predicate on the "quantite" field.
|
||||
func QuantiteGTE(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// QuantiteLT applies the LT predicate on the "quantite" field.
|
||||
func QuantiteLT(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// QuantiteLTE applies the LTE predicate on the "quantite" field.
|
||||
func QuantiteLTE(v int) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldQuantite, v))
|
||||
}
|
||||
|
||||
// PrixAchatEQ applies the EQ predicate on the "prix_achat" field.
|
||||
func PrixAchatEQ(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatNEQ applies the NEQ predicate on the "prix_achat" field.
|
||||
func PrixAchatNEQ(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatIn applies the In predicate on the "prix_achat" field.
|
||||
func PrixAchatIn(vs ...float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldPrixAchat, vs...))
|
||||
}
|
||||
|
||||
// PrixAchatNotIn applies the NotIn predicate on the "prix_achat" field.
|
||||
func PrixAchatNotIn(vs ...float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldPrixAchat, vs...))
|
||||
}
|
||||
|
||||
// PrixAchatGT applies the GT predicate on the "prix_achat" field.
|
||||
func PrixAchatGT(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatGTE applies the GTE predicate on the "prix_achat" field.
|
||||
func PrixAchatGTE(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatLT applies the LT predicate on the "prix_achat" field.
|
||||
func PrixAchatLT(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatLTE applies the LTE predicate on the "prix_achat" field.
|
||||
func PrixAchatLTE(v float64) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldPrixAchat, v))
|
||||
}
|
||||
|
||||
// PrixAchatIsNil applies the IsNil predicate on the "prix_achat" field.
|
||||
func PrixAchatIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldPrixAchat))
|
||||
}
|
||||
|
||||
// PrixAchatNotNil applies the NotNil predicate on the "prix_achat" field.
|
||||
func PrixAchatNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldPrixAchat))
|
||||
}
|
||||
|
||||
// DateAchatEQ applies the EQ predicate on the "date_achat" field.
|
||||
func DateAchatEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatNEQ applies the NEQ predicate on the "date_achat" field.
|
||||
func DateAchatNEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatIn applies the In predicate on the "date_achat" field.
|
||||
func DateAchatIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldDateAchat, vs...))
|
||||
}
|
||||
|
||||
// DateAchatNotIn applies the NotIn predicate on the "date_achat" field.
|
||||
func DateAchatNotIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldDateAchat, vs...))
|
||||
}
|
||||
|
||||
// DateAchatGT applies the GT predicate on the "date_achat" field.
|
||||
func DateAchatGT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatGTE applies the GTE predicate on the "date_achat" field.
|
||||
func DateAchatGTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatLT applies the LT predicate on the "date_achat" field.
|
||||
func DateAchatLT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatLTE applies the LTE predicate on the "date_achat" field.
|
||||
func DateAchatLTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldDateAchat, v))
|
||||
}
|
||||
|
||||
// DateAchatIsNil applies the IsNil predicate on the "date_achat" field.
|
||||
func DateAchatIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldDateAchat))
|
||||
}
|
||||
|
||||
// DateAchatNotNil applies the NotNil predicate on the "date_achat" field.
|
||||
func DateAchatNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldDateAchat))
|
||||
}
|
||||
|
||||
// BoutiqueEQ applies the EQ predicate on the "boutique" field.
|
||||
func BoutiqueEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueNEQ applies the NEQ predicate on the "boutique" field.
|
||||
func BoutiqueNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueIn applies the In predicate on the "boutique" field.
|
||||
func BoutiqueIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldBoutique, vs...))
|
||||
}
|
||||
|
||||
// BoutiqueNotIn applies the NotIn predicate on the "boutique" field.
|
||||
func BoutiqueNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldBoutique, vs...))
|
||||
}
|
||||
|
||||
// BoutiqueGT applies the GT predicate on the "boutique" field.
|
||||
func BoutiqueGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueGTE applies the GTE predicate on the "boutique" field.
|
||||
func BoutiqueGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueLT applies the LT predicate on the "boutique" field.
|
||||
func BoutiqueLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueLTE applies the LTE predicate on the "boutique" field.
|
||||
func BoutiqueLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueContains applies the Contains predicate on the "boutique" field.
|
||||
func BoutiqueContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueHasPrefix applies the HasPrefix predicate on the "boutique" field.
|
||||
func BoutiqueHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueHasSuffix applies the HasSuffix predicate on the "boutique" field.
|
||||
func BoutiqueHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueIsNil applies the IsNil predicate on the "boutique" field.
|
||||
func BoutiqueIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldBoutique))
|
||||
}
|
||||
|
||||
// BoutiqueNotNil applies the NotNil predicate on the "boutique" field.
|
||||
func BoutiqueNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldBoutique))
|
||||
}
|
||||
|
||||
// BoutiqueEqualFold applies the EqualFold predicate on the "boutique" field.
|
||||
func BoutiqueEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// BoutiqueContainsFold applies the ContainsFold predicate on the "boutique" field.
|
||||
func BoutiqueContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldBoutique, v))
|
||||
}
|
||||
|
||||
// NumeroSerieEQ applies the EQ predicate on the "numero_serie" field.
|
||||
func NumeroSerieEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieNEQ applies the NEQ predicate on the "numero_serie" field.
|
||||
func NumeroSerieNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieIn applies the In predicate on the "numero_serie" field.
|
||||
func NumeroSerieIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldNumeroSerie, vs...))
|
||||
}
|
||||
|
||||
// NumeroSerieNotIn applies the NotIn predicate on the "numero_serie" field.
|
||||
func NumeroSerieNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldNumeroSerie, vs...))
|
||||
}
|
||||
|
||||
// NumeroSerieGT applies the GT predicate on the "numero_serie" field.
|
||||
func NumeroSerieGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieGTE applies the GTE predicate on the "numero_serie" field.
|
||||
func NumeroSerieGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieLT applies the LT predicate on the "numero_serie" field.
|
||||
func NumeroSerieLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieLTE applies the LTE predicate on the "numero_serie" field.
|
||||
func NumeroSerieLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieContains applies the Contains predicate on the "numero_serie" field.
|
||||
func NumeroSerieContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieHasPrefix applies the HasPrefix predicate on the "numero_serie" field.
|
||||
func NumeroSerieHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieHasSuffix applies the HasSuffix predicate on the "numero_serie" field.
|
||||
func NumeroSerieHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieIsNil applies the IsNil predicate on the "numero_serie" field.
|
||||
func NumeroSerieIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldNumeroSerie))
|
||||
}
|
||||
|
||||
// NumeroSerieNotNil applies the NotNil predicate on the "numero_serie" field.
|
||||
func NumeroSerieNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldNumeroSerie))
|
||||
}
|
||||
|
||||
// NumeroSerieEqualFold applies the EqualFold predicate on the "numero_serie" field.
|
||||
func NumeroSerieEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroSerieContainsFold applies the ContainsFold predicate on the "numero_serie" field.
|
||||
func NumeroSerieContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldNumeroSerie, v))
|
||||
}
|
||||
|
||||
// NumeroModeleEQ applies the EQ predicate on the "numero_modele" field.
|
||||
func NumeroModeleEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleNEQ applies the NEQ predicate on the "numero_modele" field.
|
||||
func NumeroModeleNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleIn applies the In predicate on the "numero_modele" field.
|
||||
func NumeroModeleIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldNumeroModele, vs...))
|
||||
}
|
||||
|
||||
// NumeroModeleNotIn applies the NotIn predicate on the "numero_modele" field.
|
||||
func NumeroModeleNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldNumeroModele, vs...))
|
||||
}
|
||||
|
||||
// NumeroModeleGT applies the GT predicate on the "numero_modele" field.
|
||||
func NumeroModeleGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleGTE applies the GTE predicate on the "numero_modele" field.
|
||||
func NumeroModeleGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleLT applies the LT predicate on the "numero_modele" field.
|
||||
func NumeroModeleLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleLTE applies the LTE predicate on the "numero_modele" field.
|
||||
func NumeroModeleLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleContains applies the Contains predicate on the "numero_modele" field.
|
||||
func NumeroModeleContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleHasPrefix applies the HasPrefix predicate on the "numero_modele" field.
|
||||
func NumeroModeleHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleHasSuffix applies the HasSuffix predicate on the "numero_modele" field.
|
||||
func NumeroModeleHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleIsNil applies the IsNil predicate on the "numero_modele" field.
|
||||
func NumeroModeleIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldNumeroModele))
|
||||
}
|
||||
|
||||
// NumeroModeleNotNil applies the NotNil predicate on the "numero_modele" field.
|
||||
func NumeroModeleNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldNumeroModele))
|
||||
}
|
||||
|
||||
// NumeroModeleEqualFold applies the EqualFold predicate on the "numero_modele" field.
|
||||
func NumeroModeleEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// NumeroModeleContainsFold applies the ContainsFold predicate on the "numero_modele" field.
|
||||
func NumeroModeleContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldNumeroModele, v))
|
||||
}
|
||||
|
||||
// FabricantEQ applies the EQ predicate on the "fabricant" field.
|
||||
func FabricantEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantNEQ applies the NEQ predicate on the "fabricant" field.
|
||||
func FabricantNEQ(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantIn applies the In predicate on the "fabricant" field.
|
||||
func FabricantIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldFabricant, vs...))
|
||||
}
|
||||
|
||||
// FabricantNotIn applies the NotIn predicate on the "fabricant" field.
|
||||
func FabricantNotIn(vs ...string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldFabricant, vs...))
|
||||
}
|
||||
|
||||
// FabricantGT applies the GT predicate on the "fabricant" field.
|
||||
func FabricantGT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantGTE applies the GTE predicate on the "fabricant" field.
|
||||
func FabricantGTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantLT applies the LT predicate on the "fabricant" field.
|
||||
func FabricantLT(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantLTE applies the LTE predicate on the "fabricant" field.
|
||||
func FabricantLTE(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantContains applies the Contains predicate on the "fabricant" field.
|
||||
func FabricantContains(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContains(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantHasPrefix applies the HasPrefix predicate on the "fabricant" field.
|
||||
func FabricantHasPrefix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasPrefix(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantHasSuffix applies the HasSuffix predicate on the "fabricant" field.
|
||||
func FabricantHasSuffix(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldHasSuffix(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantIsNil applies the IsNil predicate on the "fabricant" field.
|
||||
func FabricantIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldFabricant))
|
||||
}
|
||||
|
||||
// FabricantNotNil applies the NotNil predicate on the "fabricant" field.
|
||||
func FabricantNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldFabricant))
|
||||
}
|
||||
|
||||
// FabricantEqualFold applies the EqualFold predicate on the "fabricant" field.
|
||||
func FabricantEqualFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEqualFold(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// FabricantContainsFold applies the ContainsFold predicate on the "fabricant" field.
|
||||
func FabricantContainsFold(v string) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldContainsFold(FieldFabricant, v))
|
||||
}
|
||||
|
||||
// StatutEQ applies the EQ predicate on the "statut" field.
|
||||
func StatutEQ(v Statut) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldStatut, v))
|
||||
}
|
||||
|
||||
// StatutNEQ applies the NEQ predicate on the "statut" field.
|
||||
func StatutNEQ(v Statut) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldStatut, v))
|
||||
}
|
||||
|
||||
// StatutIn applies the In predicate on the "statut" field.
|
||||
func StatutIn(vs ...Statut) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldStatut, vs...))
|
||||
}
|
||||
|
||||
// StatutNotIn applies the NotIn predicate on the "statut" field.
|
||||
func StatutNotIn(vs ...Statut) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldStatut, vs...))
|
||||
}
|
||||
|
||||
// CaracteristiquesIsNil applies the IsNil predicate on the "caracteristiques" field.
|
||||
func CaracteristiquesIsNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIsNull(FieldCaracteristiques))
|
||||
}
|
||||
|
||||
// CaracteristiquesNotNil applies the NotNil predicate on the "caracteristiques" field.
|
||||
func CaracteristiquesNotNil() predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotNull(FieldCaracteristiques))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Objet {
|
||||
return predicate.Objet(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasLiensEmplacements applies the HasEdge predicate on the "liens_emplacements" edge.
|
||||
func HasLiensEmplacements() predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LiensEmplacementsTable, LiensEmplacementsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasLiensEmplacementsWith applies the HasEdge predicate on the "liens_emplacements" edge with a given conditions (other predicates).
|
||||
func HasLiensEmplacementsWith(preds ...predicate.LienObjetEmplacement) predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := newLiensEmplacementsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasChampsPersonnalises applies the HasEdge predicate on the "champs_personnalises" edge.
|
||||
func HasChampsPersonnalises() predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ChampsPersonnalisesTable, ChampsPersonnalisesColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasChampsPersonnalisesWith applies the HasEdge predicate on the "champs_personnalises" edge with a given conditions (other predicates).
|
||||
func HasChampsPersonnalisesWith(preds ...predicate.ChampPersonnalise) predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := newChampsPersonnalisesStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasPiecesJointes applies the HasEdge predicate on the "pieces_jointes" edge.
|
||||
func HasPiecesJointes() predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, PiecesJointesTable, PiecesJointesColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasPiecesJointesWith applies the HasEdge predicate on the "pieces_jointes" edge with a given conditions (other predicates).
|
||||
func HasPiecesJointesWith(preds ...predicate.PieceJointe) predicate.Objet {
|
||||
return predicate.Objet(func(s *sql.Selector) {
|
||||
step := newPiecesJointesStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Objet) predicate.Objet {
|
||||
return predicate.Objet(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Objet) predicate.Objet {
|
||||
return predicate.Objet(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Objet) predicate.Objet {
|
||||
return predicate.Objet(sql.NotPredicates(p))
|
||||
}
|
||||
556
backend/internal/data/ent/objet_create.go
Normal file
556
backend/internal/data/ent/objet_create.go
Normal file
@@ -0,0 +1,556 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ObjetCreate is the builder for creating a Objet entity.
|
||||
type ObjetCreate struct {
|
||||
config
|
||||
mutation *ObjetMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetNom sets the "nom" field.
|
||||
func (_c *ObjetCreate) SetNom(v string) *ObjetCreate {
|
||||
_c.mutation.SetNom(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_c *ObjetCreate) SetDescription(v string) *ObjetCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableDescription(v *string) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetQuantite sets the "quantite" field.
|
||||
func (_c *ObjetCreate) SetQuantite(v int) *ObjetCreate {
|
||||
_c.mutation.SetQuantite(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableQuantite sets the "quantite" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableQuantite(v *int) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetQuantite(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPrixAchat sets the "prix_achat" field.
|
||||
func (_c *ObjetCreate) SetPrixAchat(v float64) *ObjetCreate {
|
||||
_c.mutation.SetPrixAchat(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePrixAchat sets the "prix_achat" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillablePrixAchat(v *float64) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetPrixAchat(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDateAchat sets the "date_achat" field.
|
||||
func (_c *ObjetCreate) SetDateAchat(v time.Time) *ObjetCreate {
|
||||
_c.mutation.SetDateAchat(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDateAchat sets the "date_achat" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableDateAchat(v *time.Time) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetDateAchat(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetBoutique sets the "boutique" field.
|
||||
func (_c *ObjetCreate) SetBoutique(v string) *ObjetCreate {
|
||||
_c.mutation.SetBoutique(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableBoutique sets the "boutique" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableBoutique(v *string) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetBoutique(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNumeroSerie sets the "numero_serie" field.
|
||||
func (_c *ObjetCreate) SetNumeroSerie(v string) *ObjetCreate {
|
||||
_c.mutation.SetNumeroSerie(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableNumeroSerie sets the "numero_serie" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableNumeroSerie(v *string) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetNumeroSerie(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNumeroModele sets the "numero_modele" field.
|
||||
func (_c *ObjetCreate) SetNumeroModele(v string) *ObjetCreate {
|
||||
_c.mutation.SetNumeroModele(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableNumeroModele sets the "numero_modele" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableNumeroModele(v *string) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetNumeroModele(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetFabricant sets the "fabricant" field.
|
||||
func (_c *ObjetCreate) SetFabricant(v string) *ObjetCreate {
|
||||
_c.mutation.SetFabricant(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableFabricant sets the "fabricant" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableFabricant(v *string) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetFabricant(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetStatut sets the "statut" field.
|
||||
func (_c *ObjetCreate) SetStatut(v objet.Statut) *ObjetCreate {
|
||||
_c.mutation.SetStatut(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableStatut sets the "statut" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableStatut(v *objet.Statut) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetStatut(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCaracteristiques sets the "caracteristiques" field.
|
||||
func (_c *ObjetCreate) SetCaracteristiques(v map[string]interface{}) *ObjetCreate {
|
||||
_c.mutation.SetCaracteristiques(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *ObjetCreate) SetCreatedAt(v time.Time) *ObjetCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableCreatedAt(v *time.Time) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *ObjetCreate) SetUpdatedAt(v time.Time) *ObjetCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableUpdatedAt(v *time.Time) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *ObjetCreate) SetID(v uuid.UUID) *ObjetCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *ObjetCreate) SetNillableID(v *uuid.UUID) *ObjetCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddLiensEmplacementIDs adds the "liens_emplacements" edge to the LienObjetEmplacement entity by IDs.
|
||||
func (_c *ObjetCreate) AddLiensEmplacementIDs(ids ...uuid.UUID) *ObjetCreate {
|
||||
_c.mutation.AddLiensEmplacementIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddLiensEmplacements adds the "liens_emplacements" edges to the LienObjetEmplacement entity.
|
||||
func (_c *ObjetCreate) AddLiensEmplacements(v ...*LienObjetEmplacement) *ObjetCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddLiensEmplacementIDs(ids...)
|
||||
}
|
||||
|
||||
// AddChampsPersonnaliseIDs adds the "champs_personnalises" edge to the ChampPersonnalise entity by IDs.
|
||||
func (_c *ObjetCreate) AddChampsPersonnaliseIDs(ids ...uuid.UUID) *ObjetCreate {
|
||||
_c.mutation.AddChampsPersonnaliseIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddChampsPersonnalises adds the "champs_personnalises" edges to the ChampPersonnalise entity.
|
||||
func (_c *ObjetCreate) AddChampsPersonnalises(v ...*ChampPersonnalise) *ObjetCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddChampsPersonnaliseIDs(ids...)
|
||||
}
|
||||
|
||||
// AddPiecesJointeIDs adds the "pieces_jointes" edge to the PieceJointe entity by IDs.
|
||||
func (_c *ObjetCreate) AddPiecesJointeIDs(ids ...uuid.UUID) *ObjetCreate {
|
||||
_c.mutation.AddPiecesJointeIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddPiecesJointes adds the "pieces_jointes" edges to the PieceJointe entity.
|
||||
func (_c *ObjetCreate) AddPiecesJointes(v ...*PieceJointe) *ObjetCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddPiecesJointeIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ObjetMutation object of the builder.
|
||||
func (_c *ObjetCreate) Mutation() *ObjetMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Objet in the database.
|
||||
func (_c *ObjetCreate) Save(ctx context.Context) (*Objet, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *ObjetCreate) SaveX(ctx context.Context) *Objet {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ObjetCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ObjetCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *ObjetCreate) defaults() {
|
||||
if _, ok := _c.mutation.Quantite(); !ok {
|
||||
v := objet.DefaultQuantite
|
||||
_c.mutation.SetQuantite(v)
|
||||
}
|
||||
if _, ok := _c.mutation.Statut(); !ok {
|
||||
v := objet.DefaultStatut
|
||||
_c.mutation.SetStatut(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := objet.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := objet.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := objet.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *ObjetCreate) check() error {
|
||||
if _, ok := _c.mutation.Nom(); !ok {
|
||||
return &ValidationError{Name: "nom", err: errors.New(`ent: missing required field "Objet.nom"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Nom(); ok {
|
||||
if err := objet.NomValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom", err: fmt.Errorf(`ent: validator failed for field "Objet.nom": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Quantite(); !ok {
|
||||
return &ValidationError{Name: "quantite", err: errors.New(`ent: missing required field "Objet.quantite"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Statut(); !ok {
|
||||
return &ValidationError{Name: "statut", err: errors.New(`ent: missing required field "Objet.statut"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Statut(); ok {
|
||||
if err := objet.StatutValidator(v); err != nil {
|
||||
return &ValidationError{Name: "statut", err: fmt.Errorf(`ent: validator failed for field "Objet.statut": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Objet.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Objet.updated_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *ObjetCreate) sqlSave(ctx context.Context) (*Objet, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *ObjetCreate) createSpec() (*Objet, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Objet{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(objet.Table, sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.Nom(); ok {
|
||||
_spec.SetField(objet.FieldNom, field.TypeString, value)
|
||||
_node.Nom = value
|
||||
}
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(objet.FieldDescription, field.TypeString, value)
|
||||
_node.Description = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Quantite(); ok {
|
||||
_spec.SetField(objet.FieldQuantite, field.TypeInt, value)
|
||||
_node.Quantite = value
|
||||
}
|
||||
if value, ok := _c.mutation.PrixAchat(); ok {
|
||||
_spec.SetField(objet.FieldPrixAchat, field.TypeFloat64, value)
|
||||
_node.PrixAchat = &value
|
||||
}
|
||||
if value, ok := _c.mutation.DateAchat(); ok {
|
||||
_spec.SetField(objet.FieldDateAchat, field.TypeTime, value)
|
||||
_node.DateAchat = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Boutique(); ok {
|
||||
_spec.SetField(objet.FieldBoutique, field.TypeString, value)
|
||||
_node.Boutique = &value
|
||||
}
|
||||
if value, ok := _c.mutation.NumeroSerie(); ok {
|
||||
_spec.SetField(objet.FieldNumeroSerie, field.TypeString, value)
|
||||
_node.NumeroSerie = &value
|
||||
}
|
||||
if value, ok := _c.mutation.NumeroModele(); ok {
|
||||
_spec.SetField(objet.FieldNumeroModele, field.TypeString, value)
|
||||
_node.NumeroModele = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Fabricant(); ok {
|
||||
_spec.SetField(objet.FieldFabricant, field.TypeString, value)
|
||||
_node.Fabricant = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Statut(); ok {
|
||||
_spec.SetField(objet.FieldStatut, field.TypeEnum, value)
|
||||
_node.Statut = value
|
||||
}
|
||||
if value, ok := _c.mutation.Caracteristiques(); ok {
|
||||
_spec.SetField(objet.FieldCaracteristiques, field.TypeJSON, value)
|
||||
_node.Caracteristiques = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(objet.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(objet.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.LiensEmplacementsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: objet.LiensEmplacementsTable,
|
||||
Columns: []string{objet.LiensEmplacementsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(lienobjetemplacement.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.ChampsPersonnalisesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: objet.ChampsPersonnalisesTable,
|
||||
Columns: []string{objet.ChampsPersonnalisesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(champpersonnalise.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.PiecesJointesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: objet.PiecesJointesTable,
|
||||
Columns: []string{objet.PiecesJointesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// ObjetCreateBulk is the builder for creating many Objet entities in bulk.
|
||||
type ObjetCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*ObjetCreate
|
||||
}
|
||||
|
||||
// Save creates the Objet entities in the database.
|
||||
func (_c *ObjetCreateBulk) Save(ctx context.Context) ([]*Objet, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Objet, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ObjetMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *ObjetCreateBulk) SaveX(ctx context.Context) []*Objet {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *ObjetCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *ObjetCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/objet_delete.go
Normal file
88
backend/internal/data/ent/objet_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ObjetDelete is the builder for deleting a Objet entity.
|
||||
type ObjetDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ObjetMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ObjetDelete builder.
|
||||
func (_d *ObjetDelete) Where(ps ...predicate.Objet) *ObjetDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *ObjetDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ObjetDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *ObjetDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(objet.Table, sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ObjetDeleteOne is the builder for deleting a single Objet entity.
|
||||
type ObjetDeleteOne struct {
|
||||
_d *ObjetDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ObjetDelete builder.
|
||||
func (_d *ObjetDeleteOne) Where(ps ...predicate.Objet) *ObjetDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *ObjetDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{objet.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *ObjetDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
759
backend/internal/data/ent/objet_query.go
Normal file
759
backend/internal/data/ent/objet_query.go
Normal file
@@ -0,0 +1,759 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ObjetQuery is the builder for querying Objet entities.
|
||||
type ObjetQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []objet.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Objet
|
||||
withLiensEmplacements *LienObjetEmplacementQuery
|
||||
withChampsPersonnalises *ChampPersonnaliseQuery
|
||||
withPiecesJointes *PieceJointeQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the ObjetQuery builder.
|
||||
func (_q *ObjetQuery) Where(ps ...predicate.Objet) *ObjetQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *ObjetQuery) Limit(limit int) *ObjetQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *ObjetQuery) Offset(offset int) *ObjetQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *ObjetQuery) Unique(unique bool) *ObjetQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *ObjetQuery) Order(o ...objet.OrderOption) *ObjetQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryLiensEmplacements chains the current query on the "liens_emplacements" edge.
|
||||
func (_q *ObjetQuery) QueryLiensEmplacements() *LienObjetEmplacementQuery {
|
||||
query := (&LienObjetEmplacementClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(objet.Table, objet.FieldID, selector),
|
||||
sqlgraph.To(lienobjetemplacement.Table, lienobjetemplacement.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, objet.LiensEmplacementsTable, objet.LiensEmplacementsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryChampsPersonnalises chains the current query on the "champs_personnalises" edge.
|
||||
func (_q *ObjetQuery) QueryChampsPersonnalises() *ChampPersonnaliseQuery {
|
||||
query := (&ChampPersonnaliseClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(objet.Table, objet.FieldID, selector),
|
||||
sqlgraph.To(champpersonnalise.Table, champpersonnalise.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, objet.ChampsPersonnalisesTable, objet.ChampsPersonnalisesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPiecesJointes chains the current query on the "pieces_jointes" edge.
|
||||
func (_q *ObjetQuery) QueryPiecesJointes() *PieceJointeQuery {
|
||||
query := (&PieceJointeClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(objet.Table, objet.FieldID, selector),
|
||||
sqlgraph.To(piecejointe.Table, piecejointe.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, objet.PiecesJointesTable, objet.PiecesJointesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Objet entity from the query.
|
||||
// Returns a *NotFoundError when no Objet was found.
|
||||
func (_q *ObjetQuery) First(ctx context.Context) (*Objet, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{objet.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) FirstX(ctx context.Context) *Objet {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Objet ID from the query.
|
||||
// Returns a *NotFoundError when no Objet ID was found.
|
||||
func (_q *ObjetQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{objet.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Objet entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Objet entity is found.
|
||||
// Returns a *NotFoundError when no Objet entities are found.
|
||||
func (_q *ObjetQuery) Only(ctx context.Context) (*Objet, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{objet.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{objet.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) OnlyX(ctx context.Context) *Objet {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Objet ID in the query.
|
||||
// Returns a *NotSingularError when more than one Objet ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *ObjetQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{objet.Label}
|
||||
default:
|
||||
err = &NotSingularError{objet.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Objets.
|
||||
func (_q *ObjetQuery) All(ctx context.Context) ([]*Objet, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Objet, *ObjetQuery]()
|
||||
return withInterceptors[[]*Objet](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) AllX(ctx context.Context) []*Objet {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Objet IDs.
|
||||
func (_q *ObjetQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(objet.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *ObjetQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*ObjetQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *ObjetQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *ObjetQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the ObjetQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *ObjetQuery) Clone() *ObjetQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &ObjetQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]objet.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Objet{}, _q.predicates...),
|
||||
withLiensEmplacements: _q.withLiensEmplacements.Clone(),
|
||||
withChampsPersonnalises: _q.withChampsPersonnalises.Clone(),
|
||||
withPiecesJointes: _q.withPiecesJointes.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithLiensEmplacements tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "liens_emplacements" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ObjetQuery) WithLiensEmplacements(opts ...func(*LienObjetEmplacementQuery)) *ObjetQuery {
|
||||
query := (&LienObjetEmplacementClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withLiensEmplacements = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithChampsPersonnalises tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "champs_personnalises" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ObjetQuery) WithChampsPersonnalises(opts ...func(*ChampPersonnaliseQuery)) *ObjetQuery {
|
||||
query := (&ChampPersonnaliseClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withChampsPersonnalises = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithPiecesJointes tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "pieces_jointes" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ObjetQuery) WithPiecesJointes(opts ...func(*PieceJointeQuery)) *ObjetQuery {
|
||||
query := (&PieceJointeClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withPiecesJointes = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Objet.Query().
|
||||
// GroupBy(objet.FieldNom).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ObjetQuery) GroupBy(field string, fields ...string) *ObjetGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &ObjetGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = objet.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Nom string `json:"nom,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Objet.Query().
|
||||
// Select(objet.FieldNom).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ObjetQuery) Select(fields ...string) *ObjetSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &ObjetSelect{ObjetQuery: _q}
|
||||
sbuild.label = objet.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ObjetSelect configured with the given aggregations.
|
||||
func (_q *ObjetQuery) Aggregate(fns ...AggregateFunc) *ObjetSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !objet.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Objet, error) {
|
||||
var (
|
||||
nodes = []*Objet{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [3]bool{
|
||||
_q.withLiensEmplacements != nil,
|
||||
_q.withChampsPersonnalises != nil,
|
||||
_q.withPiecesJointes != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Objet).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Objet{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withLiensEmplacements; query != nil {
|
||||
if err := _q.loadLiensEmplacements(ctx, query, nodes,
|
||||
func(n *Objet) { n.Edges.LiensEmplacements = []*LienObjetEmplacement{} },
|
||||
func(n *Objet, e *LienObjetEmplacement) {
|
||||
n.Edges.LiensEmplacements = append(n.Edges.LiensEmplacements, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withChampsPersonnalises; query != nil {
|
||||
if err := _q.loadChampsPersonnalises(ctx, query, nodes,
|
||||
func(n *Objet) { n.Edges.ChampsPersonnalises = []*ChampPersonnalise{} },
|
||||
func(n *Objet, e *ChampPersonnalise) {
|
||||
n.Edges.ChampsPersonnalises = append(n.Edges.ChampsPersonnalises, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withPiecesJointes; query != nil {
|
||||
if err := _q.loadPiecesJointes(ctx, query, nodes,
|
||||
func(n *Objet) { n.Edges.PiecesJointes = []*PieceJointe{} },
|
||||
func(n *Objet, e *PieceJointe) { n.Edges.PiecesJointes = append(n.Edges.PiecesJointes, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) loadLiensEmplacements(ctx context.Context, query *LienObjetEmplacementQuery, nodes []*Objet, init func(*Objet), assign func(*Objet, *LienObjetEmplacement)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Objet)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(lienobjetemplacement.FieldObjetID)
|
||||
}
|
||||
query.Where(predicate.LienObjetEmplacement(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(objet.LiensEmplacementsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.ObjetID
|
||||
node, ok := nodeids[fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "objet_id" returned %v for node %v`, fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *ObjetQuery) loadChampsPersonnalises(ctx context.Context, query *ChampPersonnaliseQuery, nodes []*Objet, init func(*Objet), assign func(*Objet, *ChampPersonnalise)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Objet)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(champpersonnalise.FieldObjetID)
|
||||
}
|
||||
query.Where(predicate.ChampPersonnalise(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(objet.ChampsPersonnalisesColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.ObjetID
|
||||
node, ok := nodeids[fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "objet_id" returned %v for node %v`, fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *ObjetQuery) loadPiecesJointes(ctx context.Context, query *PieceJointeQuery, nodes []*Objet, init func(*Objet), assign func(*Objet, *PieceJointe)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Objet)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
if len(query.ctx.Fields) > 0 {
|
||||
query.ctx.AppendFieldOnce(piecejointe.FieldObjetID)
|
||||
}
|
||||
query.Where(predicate.PieceJointe(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(objet.PiecesJointesColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.ObjetID
|
||||
node, ok := nodeids[fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "objet_id" returned %v for node %v`, fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(objet.Table, objet.Columns, sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, objet.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != objet.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *ObjetQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(objet.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = objet.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ObjetGroupBy is the group-by builder for Objet entities.
|
||||
type ObjetGroupBy struct {
|
||||
selector
|
||||
build *ObjetQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *ObjetGroupBy) Aggregate(fns ...AggregateFunc) *ObjetGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *ObjetGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ObjetQuery, *ObjetGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *ObjetGroupBy) sqlScan(ctx context.Context, root *ObjetQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// ObjetSelect is the builder for selecting fields of Objet entities.
|
||||
type ObjetSelect struct {
|
||||
*ObjetQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *ObjetSelect) Aggregate(fns ...AggregateFunc) *ObjetSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *ObjetSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*ObjetQuery, *ObjetSelect](ctx, _s.ObjetQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *ObjetSelect) sqlScan(ctx context.Context, root *ObjetQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
1314
backend/internal/data/ent/objet_update.go
Normal file
1314
backend/internal/data/ent/objet_update.go
Normal file
File diff suppressed because it is too large
Load Diff
216
backend/internal/data/ent/piecejointe.go
Normal file
216
backend/internal/data/ent/piecejointe.go
Normal file
@@ -0,0 +1,216 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PieceJointe is the model entity for the PieceJointe schema.
|
||||
type PieceJointe struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
// Identifiant unique de la piece jointe
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// Identifiant de l'objet
|
||||
ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Nom du fichier
|
||||
NomFichier string `json:"nom_fichier,omitempty"`
|
||||
// Chemin de stockage
|
||||
Chemin string `json:"chemin,omitempty"`
|
||||
// Type MIME
|
||||
TypeMime string `json:"type_mime,omitempty"`
|
||||
// Piece jointe principale
|
||||
EstPrincipale bool `json:"est_principale,omitempty"`
|
||||
// Categorie de la piece jointe
|
||||
Categorie piecejointe.Categorie `json:"categorie,omitempty"`
|
||||
// Date de creation
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// Date de derniere mise a jour
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the PieceJointeQuery when eager-loading is set.
|
||||
Edges PieceJointeEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// PieceJointeEdges holds the relations/edges for other nodes in the graph.
|
||||
type PieceJointeEdges struct {
|
||||
// Objet holds the value of the objet edge.
|
||||
Objet *Objet `json:"objet,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ObjetOrErr returns the Objet value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e PieceJointeEdges) ObjetOrErr() (*Objet, error) {
|
||||
if e.Objet != nil {
|
||||
return e.Objet, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: objet.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "objet"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*PieceJointe) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case piecejointe.FieldEstPrincipale:
|
||||
values[i] = new(sql.NullBool)
|
||||
case piecejointe.FieldNomFichier, piecejointe.FieldChemin, piecejointe.FieldTypeMime, piecejointe.FieldCategorie:
|
||||
values[i] = new(sql.NullString)
|
||||
case piecejointe.FieldCreatedAt, piecejointe.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case piecejointe.FieldID, piecejointe.FieldObjetID:
|
||||
values[i] = new(uuid.UUID)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the PieceJointe fields.
|
||||
func (_m *PieceJointe) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case piecejointe.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case piecejointe.FieldObjetID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field objet_id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ObjetID = *value
|
||||
}
|
||||
case piecejointe.FieldNomFichier:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nom_fichier", values[i])
|
||||
} else if value.Valid {
|
||||
_m.NomFichier = value.String
|
||||
}
|
||||
case piecejointe.FieldChemin:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field chemin", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Chemin = value.String
|
||||
}
|
||||
case piecejointe.FieldTypeMime:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type_mime", values[i])
|
||||
} else if value.Valid {
|
||||
_m.TypeMime = value.String
|
||||
}
|
||||
case piecejointe.FieldEstPrincipale:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field est_principale", values[i])
|
||||
} else if value.Valid {
|
||||
_m.EstPrincipale = value.Bool
|
||||
}
|
||||
case piecejointe.FieldCategorie:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field categorie", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Categorie = piecejointe.Categorie(value.String)
|
||||
}
|
||||
case piecejointe.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case piecejointe.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the PieceJointe.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *PieceJointe) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryObjet queries the "objet" edge of the PieceJointe entity.
|
||||
func (_m *PieceJointe) QueryObjet() *ObjetQuery {
|
||||
return NewPieceJointeClient(_m.config).QueryObjet(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this PieceJointe.
|
||||
// Note that you need to call PieceJointe.Unwrap() before calling this method if this PieceJointe
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *PieceJointe) Update() *PieceJointeUpdateOne {
|
||||
return NewPieceJointeClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the PieceJointe entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *PieceJointe) Unwrap() *PieceJointe {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: PieceJointe is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *PieceJointe) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("PieceJointe(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("objet_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ObjetID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("nom_fichier=")
|
||||
builder.WriteString(_m.NomFichier)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("chemin=")
|
||||
builder.WriteString(_m.Chemin)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("type_mime=")
|
||||
builder.WriteString(_m.TypeMime)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("est_principale=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.EstPrincipale))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("categorie=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Categorie))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// PieceJointes is a parsable slice of PieceJointe.
|
||||
type PieceJointes []*PieceJointe
|
||||
177
backend/internal/data/ent/piecejointe/piecejointe.go
Normal file
177
backend/internal/data/ent/piecejointe/piecejointe.go
Normal file
@@ -0,0 +1,177 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package piecejointe
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the piecejointe type in the database.
|
||||
Label = "piece_jointe"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldObjetID holds the string denoting the objet_id field in the database.
|
||||
FieldObjetID = "objet_id"
|
||||
// FieldNomFichier holds the string denoting the nom_fichier field in the database.
|
||||
FieldNomFichier = "nom_fichier"
|
||||
// FieldChemin holds the string denoting the chemin field in the database.
|
||||
FieldChemin = "chemin"
|
||||
// FieldTypeMime holds the string denoting the type_mime field in the database.
|
||||
FieldTypeMime = "type_mime"
|
||||
// FieldEstPrincipale holds the string denoting the est_principale field in the database.
|
||||
FieldEstPrincipale = "est_principale"
|
||||
// FieldCategorie holds the string denoting the categorie field in the database.
|
||||
FieldCategorie = "categorie"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeObjet holds the string denoting the objet edge name in mutations.
|
||||
EdgeObjet = "objet"
|
||||
// Table holds the table name of the piecejointe in the database.
|
||||
Table = "piece_jointe"
|
||||
// ObjetTable is the table that holds the objet relation/edge.
|
||||
ObjetTable = "piece_jointe"
|
||||
// ObjetInverseTable is the table name for the Objet entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "objet" package.
|
||||
ObjetInverseTable = "objet"
|
||||
// ObjetColumn is the table column denoting the objet relation/edge.
|
||||
ObjetColumn = "objet_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for piecejointe fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldObjetID,
|
||||
FieldNomFichier,
|
||||
FieldChemin,
|
||||
FieldTypeMime,
|
||||
FieldEstPrincipale,
|
||||
FieldCategorie,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NomFichierValidator is a validator for the "nom_fichier" field. It is called by the builders before save.
|
||||
NomFichierValidator func(string) error
|
||||
// CheminValidator is a validator for the "chemin" field. It is called by the builders before save.
|
||||
CheminValidator func(string) error
|
||||
// TypeMimeValidator is a validator for the "type_mime" field. It is called by the builders before save.
|
||||
TypeMimeValidator func(string) error
|
||||
// DefaultEstPrincipale holds the default value on creation for the "est_principale" field.
|
||||
DefaultEstPrincipale bool
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// Categorie defines the type for the "categorie" enum field.
|
||||
type Categorie string
|
||||
|
||||
// CategorieImage is the default value of the Categorie enum.
|
||||
const DefaultCategorie = CategorieImage
|
||||
|
||||
// Categorie values.
|
||||
const (
|
||||
CategorieImage Categorie = "image"
|
||||
CategoriePdfNotice Categorie = "pdf_notice"
|
||||
CategorieMarkdownTuto Categorie = "markdown_tuto"
|
||||
)
|
||||
|
||||
func (c Categorie) String() string {
|
||||
return string(c)
|
||||
}
|
||||
|
||||
// CategorieValidator is a validator for the "categorie" field enum values. It is called by the builders before save.
|
||||
func CategorieValidator(c Categorie) error {
|
||||
switch c {
|
||||
case CategorieImage, CategoriePdfNotice, CategorieMarkdownTuto:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("piecejointe: invalid enum value for categorie field: %q", c)
|
||||
}
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the PieceJointe queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetID orders the results by the objet_id field.
|
||||
func ByObjetID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldObjetID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByNomFichier orders the results by the nom_fichier field.
|
||||
func ByNomFichier(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldNomFichier, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByChemin orders the results by the chemin field.
|
||||
func ByChemin(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldChemin, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTypeMime orders the results by the type_mime field.
|
||||
func ByTypeMime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTypeMime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEstPrincipale orders the results by the est_principale field.
|
||||
func ByEstPrincipale(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEstPrincipale, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCategorie orders the results by the categorie field.
|
||||
func ByCategorie(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCategorie, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjetField orders the results by objet field.
|
||||
func ByObjetField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newObjetStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newObjetStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ObjetInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
}
|
||||
455
backend/internal/data/ent/piecejointe/where.go
Normal file
455
backend/internal/data/ent/piecejointe/where.go
Normal file
@@ -0,0 +1,455 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package piecejointe
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// ObjetID applies equality check predicate on the "objet_id" field. It's identical to ObjetIDEQ.
|
||||
func ObjetID(v uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// NomFichier applies equality check predicate on the "nom_fichier" field. It's identical to NomFichierEQ.
|
||||
func NomFichier(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// Chemin applies equality check predicate on the "chemin" field. It's identical to CheminEQ.
|
||||
func Chemin(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldChemin, v))
|
||||
}
|
||||
|
||||
// TypeMime applies equality check predicate on the "type_mime" field. It's identical to TypeMimeEQ.
|
||||
func TypeMime(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// EstPrincipale applies equality check predicate on the "est_principale" field. It's identical to EstPrincipaleEQ.
|
||||
func EstPrincipale(v bool) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldEstPrincipale, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// ObjetIDEQ applies the EQ predicate on the "objet_id" field.
|
||||
func ObjetIDEQ(v uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDNEQ applies the NEQ predicate on the "objet_id" field.
|
||||
func ObjetIDNEQ(v uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldObjetID, v))
|
||||
}
|
||||
|
||||
// ObjetIDIn applies the In predicate on the "objet_id" field.
|
||||
func ObjetIDIn(vs ...uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// ObjetIDNotIn applies the NotIn predicate on the "objet_id" field.
|
||||
func ObjetIDNotIn(vs ...uuid.UUID) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldObjetID, vs...))
|
||||
}
|
||||
|
||||
// NomFichierEQ applies the EQ predicate on the "nom_fichier" field.
|
||||
func NomFichierEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierNEQ applies the NEQ predicate on the "nom_fichier" field.
|
||||
func NomFichierNEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierIn applies the In predicate on the "nom_fichier" field.
|
||||
func NomFichierIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldNomFichier, vs...))
|
||||
}
|
||||
|
||||
// NomFichierNotIn applies the NotIn predicate on the "nom_fichier" field.
|
||||
func NomFichierNotIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldNomFichier, vs...))
|
||||
}
|
||||
|
||||
// NomFichierGT applies the GT predicate on the "nom_fichier" field.
|
||||
func NomFichierGT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierGTE applies the GTE predicate on the "nom_fichier" field.
|
||||
func NomFichierGTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierLT applies the LT predicate on the "nom_fichier" field.
|
||||
func NomFichierLT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierLTE applies the LTE predicate on the "nom_fichier" field.
|
||||
func NomFichierLTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierContains applies the Contains predicate on the "nom_fichier" field.
|
||||
func NomFichierContains(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContains(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierHasPrefix applies the HasPrefix predicate on the "nom_fichier" field.
|
||||
func NomFichierHasPrefix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasPrefix(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierHasSuffix applies the HasSuffix predicate on the "nom_fichier" field.
|
||||
func NomFichierHasSuffix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasSuffix(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierEqualFold applies the EqualFold predicate on the "nom_fichier" field.
|
||||
func NomFichierEqualFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEqualFold(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// NomFichierContainsFold applies the ContainsFold predicate on the "nom_fichier" field.
|
||||
func NomFichierContainsFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContainsFold(FieldNomFichier, v))
|
||||
}
|
||||
|
||||
// CheminEQ applies the EQ predicate on the "chemin" field.
|
||||
func CheminEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminNEQ applies the NEQ predicate on the "chemin" field.
|
||||
func CheminNEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminIn applies the In predicate on the "chemin" field.
|
||||
func CheminIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldChemin, vs...))
|
||||
}
|
||||
|
||||
// CheminNotIn applies the NotIn predicate on the "chemin" field.
|
||||
func CheminNotIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldChemin, vs...))
|
||||
}
|
||||
|
||||
// CheminGT applies the GT predicate on the "chemin" field.
|
||||
func CheminGT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminGTE applies the GTE predicate on the "chemin" field.
|
||||
func CheminGTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminLT applies the LT predicate on the "chemin" field.
|
||||
func CheminLT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminLTE applies the LTE predicate on the "chemin" field.
|
||||
func CheminLTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminContains applies the Contains predicate on the "chemin" field.
|
||||
func CheminContains(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContains(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminHasPrefix applies the HasPrefix predicate on the "chemin" field.
|
||||
func CheminHasPrefix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasPrefix(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminHasSuffix applies the HasSuffix predicate on the "chemin" field.
|
||||
func CheminHasSuffix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasSuffix(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminEqualFold applies the EqualFold predicate on the "chemin" field.
|
||||
func CheminEqualFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEqualFold(FieldChemin, v))
|
||||
}
|
||||
|
||||
// CheminContainsFold applies the ContainsFold predicate on the "chemin" field.
|
||||
func CheminContainsFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContainsFold(FieldChemin, v))
|
||||
}
|
||||
|
||||
// TypeMimeEQ applies the EQ predicate on the "type_mime" field.
|
||||
func TypeMimeEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeNEQ applies the NEQ predicate on the "type_mime" field.
|
||||
func TypeMimeNEQ(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeIn applies the In predicate on the "type_mime" field.
|
||||
func TypeMimeIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldTypeMime, vs...))
|
||||
}
|
||||
|
||||
// TypeMimeNotIn applies the NotIn predicate on the "type_mime" field.
|
||||
func TypeMimeNotIn(vs ...string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldTypeMime, vs...))
|
||||
}
|
||||
|
||||
// TypeMimeGT applies the GT predicate on the "type_mime" field.
|
||||
func TypeMimeGT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeGTE applies the GTE predicate on the "type_mime" field.
|
||||
func TypeMimeGTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeLT applies the LT predicate on the "type_mime" field.
|
||||
func TypeMimeLT(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeLTE applies the LTE predicate on the "type_mime" field.
|
||||
func TypeMimeLTE(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeContains applies the Contains predicate on the "type_mime" field.
|
||||
func TypeMimeContains(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContains(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeHasPrefix applies the HasPrefix predicate on the "type_mime" field.
|
||||
func TypeMimeHasPrefix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasPrefix(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeHasSuffix applies the HasSuffix predicate on the "type_mime" field.
|
||||
func TypeMimeHasSuffix(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldHasSuffix(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeEqualFold applies the EqualFold predicate on the "type_mime" field.
|
||||
func TypeMimeEqualFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEqualFold(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// TypeMimeContainsFold applies the ContainsFold predicate on the "type_mime" field.
|
||||
func TypeMimeContainsFold(v string) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldContainsFold(FieldTypeMime, v))
|
||||
}
|
||||
|
||||
// EstPrincipaleEQ applies the EQ predicate on the "est_principale" field.
|
||||
func EstPrincipaleEQ(v bool) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldEstPrincipale, v))
|
||||
}
|
||||
|
||||
// EstPrincipaleNEQ applies the NEQ predicate on the "est_principale" field.
|
||||
func EstPrincipaleNEQ(v bool) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldEstPrincipale, v))
|
||||
}
|
||||
|
||||
// CategorieEQ applies the EQ predicate on the "categorie" field.
|
||||
func CategorieEQ(v Categorie) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldCategorie, v))
|
||||
}
|
||||
|
||||
// CategorieNEQ applies the NEQ predicate on the "categorie" field.
|
||||
func CategorieNEQ(v Categorie) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldCategorie, v))
|
||||
}
|
||||
|
||||
// CategorieIn applies the In predicate on the "categorie" field.
|
||||
func CategorieIn(vs ...Categorie) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldCategorie, vs...))
|
||||
}
|
||||
|
||||
// CategorieNotIn applies the NotIn predicate on the "categorie" field.
|
||||
func CategorieNotIn(vs ...Categorie) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldCategorie, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasObjet applies the HasEdge predicate on the "objet" edge.
|
||||
func HasObjet() predicate.PieceJointe {
|
||||
return predicate.PieceJointe(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasObjetWith applies the HasEdge predicate on the "objet" edge with a given conditions (other predicates).
|
||||
func HasObjetWith(preds ...predicate.Objet) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(func(s *sql.Selector) {
|
||||
step := newObjetStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.PieceJointe) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.PieceJointe) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.PieceJointe) predicate.PieceJointe {
|
||||
return predicate.PieceJointe(sql.NotPredicates(p))
|
||||
}
|
||||
395
backend/internal/data/ent/piecejointe_create.go
Normal file
395
backend/internal/data/ent/piecejointe_create.go
Normal file
@@ -0,0 +1,395 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PieceJointeCreate is the builder for creating a PieceJointe entity.
|
||||
type PieceJointeCreate struct {
|
||||
config
|
||||
mutation *PieceJointeMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_c *PieceJointeCreate) SetObjetID(v uuid.UUID) *PieceJointeCreate {
|
||||
_c.mutation.SetObjetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNomFichier sets the "nom_fichier" field.
|
||||
func (_c *PieceJointeCreate) SetNomFichier(v string) *PieceJointeCreate {
|
||||
_c.mutation.SetNomFichier(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetChemin sets the "chemin" field.
|
||||
func (_c *PieceJointeCreate) SetChemin(v string) *PieceJointeCreate {
|
||||
_c.mutation.SetChemin(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTypeMime sets the "type_mime" field.
|
||||
func (_c *PieceJointeCreate) SetTypeMime(v string) *PieceJointeCreate {
|
||||
_c.mutation.SetTypeMime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEstPrincipale sets the "est_principale" field.
|
||||
func (_c *PieceJointeCreate) SetEstPrincipale(v bool) *PieceJointeCreate {
|
||||
_c.mutation.SetEstPrincipale(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableEstPrincipale sets the "est_principale" field if the given value is not nil.
|
||||
func (_c *PieceJointeCreate) SetNillableEstPrincipale(v *bool) *PieceJointeCreate {
|
||||
if v != nil {
|
||||
_c.SetEstPrincipale(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCategorie sets the "categorie" field.
|
||||
func (_c *PieceJointeCreate) SetCategorie(v piecejointe.Categorie) *PieceJointeCreate {
|
||||
_c.mutation.SetCategorie(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCategorie sets the "categorie" field if the given value is not nil.
|
||||
func (_c *PieceJointeCreate) SetNillableCategorie(v *piecejointe.Categorie) *PieceJointeCreate {
|
||||
if v != nil {
|
||||
_c.SetCategorie(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *PieceJointeCreate) SetCreatedAt(v time.Time) *PieceJointeCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *PieceJointeCreate) SetNillableCreatedAt(v *time.Time) *PieceJointeCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *PieceJointeCreate) SetUpdatedAt(v time.Time) *PieceJointeCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *PieceJointeCreate) SetNillableUpdatedAt(v *time.Time) *PieceJointeCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *PieceJointeCreate) SetID(v uuid.UUID) *PieceJointeCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *PieceJointeCreate) SetNillableID(v *uuid.UUID) *PieceJointeCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_c *PieceJointeCreate) SetObjet(v *Objet) *PieceJointeCreate {
|
||||
return _c.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the PieceJointeMutation object of the builder.
|
||||
func (_c *PieceJointeCreate) Mutation() *PieceJointeMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the PieceJointe in the database.
|
||||
func (_c *PieceJointeCreate) Save(ctx context.Context) (*PieceJointe, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *PieceJointeCreate) SaveX(ctx context.Context) *PieceJointe {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *PieceJointeCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *PieceJointeCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *PieceJointeCreate) defaults() {
|
||||
if _, ok := _c.mutation.EstPrincipale(); !ok {
|
||||
v := piecejointe.DefaultEstPrincipale
|
||||
_c.mutation.SetEstPrincipale(v)
|
||||
}
|
||||
if _, ok := _c.mutation.Categorie(); !ok {
|
||||
v := piecejointe.DefaultCategorie
|
||||
_c.mutation.SetCategorie(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := piecejointe.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := piecejointe.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := piecejointe.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *PieceJointeCreate) check() error {
|
||||
if _, ok := _c.mutation.ObjetID(); !ok {
|
||||
return &ValidationError{Name: "objet_id", err: errors.New(`ent: missing required field "PieceJointe.objet_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.NomFichier(); !ok {
|
||||
return &ValidationError{Name: "nom_fichier", err: errors.New(`ent: missing required field "PieceJointe.nom_fichier"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.NomFichier(); ok {
|
||||
if err := piecejointe.NomFichierValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_fichier", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.nom_fichier": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Chemin(); !ok {
|
||||
return &ValidationError{Name: "chemin", err: errors.New(`ent: missing required field "PieceJointe.chemin"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Chemin(); ok {
|
||||
if err := piecejointe.CheminValidator(v); err != nil {
|
||||
return &ValidationError{Name: "chemin", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.chemin": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.TypeMime(); !ok {
|
||||
return &ValidationError{Name: "type_mime", err: errors.New(`ent: missing required field "PieceJointe.type_mime"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.TypeMime(); ok {
|
||||
if err := piecejointe.TypeMimeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_mime", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.type_mime": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.EstPrincipale(); !ok {
|
||||
return &ValidationError{Name: "est_principale", err: errors.New(`ent: missing required field "PieceJointe.est_principale"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Categorie(); !ok {
|
||||
return &ValidationError{Name: "categorie", err: errors.New(`ent: missing required field "PieceJointe.categorie"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Categorie(); ok {
|
||||
if err := piecejointe.CategorieValidator(v); err != nil {
|
||||
return &ValidationError{Name: "categorie", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.categorie": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PieceJointe.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PieceJointe.updated_at"`)}
|
||||
}
|
||||
if len(_c.mutation.ObjetIDs()) == 0 {
|
||||
return &ValidationError{Name: "objet", err: errors.New(`ent: missing required edge "PieceJointe.objet"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *PieceJointeCreate) sqlSave(ctx context.Context) (*PieceJointe, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if _spec.ID.Value != nil {
|
||||
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||
_node.ID = *id
|
||||
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *PieceJointeCreate) createSpec() (*PieceJointe, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &PieceJointe{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(piecejointe.Table, sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.NomFichier(); ok {
|
||||
_spec.SetField(piecejointe.FieldNomFichier, field.TypeString, value)
|
||||
_node.NomFichier = value
|
||||
}
|
||||
if value, ok := _c.mutation.Chemin(); ok {
|
||||
_spec.SetField(piecejointe.FieldChemin, field.TypeString, value)
|
||||
_node.Chemin = value
|
||||
}
|
||||
if value, ok := _c.mutation.TypeMime(); ok {
|
||||
_spec.SetField(piecejointe.FieldTypeMime, field.TypeString, value)
|
||||
_node.TypeMime = value
|
||||
}
|
||||
if value, ok := _c.mutation.EstPrincipale(); ok {
|
||||
_spec.SetField(piecejointe.FieldEstPrincipale, field.TypeBool, value)
|
||||
_node.EstPrincipale = value
|
||||
}
|
||||
if value, ok := _c.mutation.Categorie(); ok {
|
||||
_spec.SetField(piecejointe.FieldCategorie, field.TypeEnum, value)
|
||||
_node.Categorie = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := _c.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: piecejointe.ObjetTable,
|
||||
Columns: []string{piecejointe.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.ObjetID = nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// PieceJointeCreateBulk is the builder for creating many PieceJointe entities in bulk.
|
||||
type PieceJointeCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*PieceJointeCreate
|
||||
}
|
||||
|
||||
// Save creates the PieceJointe entities in the database.
|
||||
func (_c *PieceJointeCreateBulk) Save(ctx context.Context) ([]*PieceJointe, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*PieceJointe, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*PieceJointeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *PieceJointeCreateBulk) SaveX(ctx context.Context) []*PieceJointe {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *PieceJointeCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *PieceJointeCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
backend/internal/data/ent/piecejointe_delete.go
Normal file
88
backend/internal/data/ent/piecejointe_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// PieceJointeDelete is the builder for deleting a PieceJointe entity.
|
||||
type PieceJointeDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *PieceJointeMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PieceJointeDelete builder.
|
||||
func (_d *PieceJointeDelete) Where(ps ...predicate.PieceJointe) *PieceJointeDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *PieceJointeDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *PieceJointeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *PieceJointeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(piecejointe.Table, sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// PieceJointeDeleteOne is the builder for deleting a single PieceJointe entity.
|
||||
type PieceJointeDeleteOne struct {
|
||||
_d *PieceJointeDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PieceJointeDelete builder.
|
||||
func (_d *PieceJointeDeleteOne) Where(ps ...predicate.PieceJointe) *PieceJointeDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *PieceJointeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{piecejointe.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *PieceJointeDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
607
backend/internal/data/ent/piecejointe_query.go
Normal file
607
backend/internal/data/ent/piecejointe_query.go
Normal file
@@ -0,0 +1,607 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PieceJointeQuery is the builder for querying PieceJointe entities.
|
||||
type PieceJointeQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []piecejointe.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.PieceJointe
|
||||
withObjet *ObjetQuery
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the PieceJointeQuery builder.
|
||||
func (_q *PieceJointeQuery) Where(ps ...predicate.PieceJointe) *PieceJointeQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *PieceJointeQuery) Limit(limit int) *PieceJointeQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *PieceJointeQuery) Offset(offset int) *PieceJointeQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *PieceJointeQuery) Unique(unique bool) *PieceJointeQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *PieceJointeQuery) Order(o ...piecejointe.OrderOption) *PieceJointeQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryObjet chains the current query on the "objet" edge.
|
||||
func (_q *PieceJointeQuery) QueryObjet() *ObjetQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(piecejointe.Table, piecejointe.FieldID, selector),
|
||||
sqlgraph.To(objet.Table, objet.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, piecejointe.ObjetTable, piecejointe.ObjetColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first PieceJointe entity from the query.
|
||||
// Returns a *NotFoundError when no PieceJointe was found.
|
||||
func (_q *PieceJointeQuery) First(ctx context.Context) (*PieceJointe, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{piecejointe.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) FirstX(ctx context.Context) *PieceJointe {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first PieceJointe ID from the query.
|
||||
// Returns a *NotFoundError when no PieceJointe ID was found.
|
||||
func (_q *PieceJointeQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{piecejointe.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single PieceJointe entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one PieceJointe entity is found.
|
||||
// Returns a *NotFoundError when no PieceJointe entities are found.
|
||||
func (_q *PieceJointeQuery) Only(ctx context.Context) (*PieceJointe, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{piecejointe.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{piecejointe.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) OnlyX(ctx context.Context) *PieceJointe {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only PieceJointe ID in the query.
|
||||
// Returns a *NotSingularError when more than one PieceJointe ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *PieceJointeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{piecejointe.Label}
|
||||
default:
|
||||
err = &NotSingularError{piecejointe.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of PieceJointes.
|
||||
func (_q *PieceJointeQuery) All(ctx context.Context) ([]*PieceJointe, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*PieceJointe, *PieceJointeQuery]()
|
||||
return withInterceptors[[]*PieceJointe](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) AllX(ctx context.Context) []*PieceJointe {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of PieceJointe IDs.
|
||||
func (_q *PieceJointeQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(piecejointe.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *PieceJointeQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*PieceJointeQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *PieceJointeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *PieceJointeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the PieceJointeQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *PieceJointeQuery) Clone() *PieceJointeQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &PieceJointeQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]piecejointe.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.PieceJointe{}, _q.predicates...),
|
||||
withObjet: _q.withObjet.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithObjet tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "objet" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *PieceJointeQuery) WithObjet(opts ...func(*ObjetQuery)) *PieceJointeQuery {
|
||||
query := (&ObjetClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withObjet = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.PieceJointe.Query().
|
||||
// GroupBy(piecejointe.FieldObjetID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *PieceJointeQuery) GroupBy(field string, fields ...string) *PieceJointeGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &PieceJointeGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = piecejointe.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ObjetID uuid.UUID `json:"objet_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.PieceJointe.Query().
|
||||
// Select(piecejointe.FieldObjetID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *PieceJointeQuery) Select(fields ...string) *PieceJointeSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &PieceJointeSelect{PieceJointeQuery: _q}
|
||||
sbuild.label = piecejointe.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a PieceJointeSelect configured with the given aggregations.
|
||||
func (_q *PieceJointeQuery) Aggregate(fns ...AggregateFunc) *PieceJointeSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !piecejointe.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PieceJointe, error) {
|
||||
var (
|
||||
nodes = []*PieceJointe{}
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
_q.withObjet != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*PieceJointe).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &PieceJointe{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := _q.withObjet; query != nil {
|
||||
if err := _q.loadObjet(ctx, query, nodes, nil,
|
||||
func(n *PieceJointe, e *Objet) { n.Edges.Objet = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) loadObjet(ctx context.Context, query *ObjetQuery, nodes []*PieceJointe, init func(*PieceJointe), assign func(*PieceJointe, *Objet)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*PieceJointe)
|
||||
for i := range nodes {
|
||||
fk := nodes[i].ObjetID
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(objet.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "objet_id" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(piecejointe.Table, piecejointe.Columns, sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, piecejointe.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != piecejointe.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if _q.withObjet != nil {
|
||||
_spec.Node.AddColumnOnce(piecejointe.FieldObjetID)
|
||||
}
|
||||
}
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *PieceJointeQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(piecejointe.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = piecejointe.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// PieceJointeGroupBy is the group-by builder for PieceJointe entities.
|
||||
type PieceJointeGroupBy struct {
|
||||
selector
|
||||
build *PieceJointeQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *PieceJointeGroupBy) Aggregate(fns ...AggregateFunc) *PieceJointeGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *PieceJointeGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*PieceJointeQuery, *PieceJointeGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *PieceJointeGroupBy) sqlScan(ctx context.Context, root *PieceJointeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// PieceJointeSelect is the builder for selecting fields of PieceJointe entities.
|
||||
type PieceJointeSelect struct {
|
||||
*PieceJointeQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *PieceJointeSelect) Aggregate(fns ...AggregateFunc) *PieceJointeSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *PieceJointeSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*PieceJointeQuery, *PieceJointeSelect](ctx, _s.PieceJointeQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *PieceJointeSelect) sqlScan(ctx context.Context, root *PieceJointeQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
588
backend/internal/data/ent/piecejointe_update.go
Normal file
588
backend/internal/data/ent/piecejointe_update.go
Normal file
@@ -0,0 +1,588 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PieceJointeUpdate is the builder for updating PieceJointe entities.
|
||||
type PieceJointeUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *PieceJointeMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PieceJointeUpdate builder.
|
||||
func (_u *PieceJointeUpdate) Where(ps ...predicate.PieceJointe) *PieceJointeUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *PieceJointeUpdate) SetObjetID(v uuid.UUID) *PieceJointeUpdate {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableObjetID(v *uuid.UUID) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNomFichier sets the "nom_fichier" field.
|
||||
func (_u *PieceJointeUpdate) SetNomFichier(v string) *PieceJointeUpdate {
|
||||
_u.mutation.SetNomFichier(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNomFichier sets the "nom_fichier" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableNomFichier(v *string) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetNomFichier(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetChemin sets the "chemin" field.
|
||||
func (_u *PieceJointeUpdate) SetChemin(v string) *PieceJointeUpdate {
|
||||
_u.mutation.SetChemin(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableChemin sets the "chemin" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableChemin(v *string) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetChemin(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTypeMime sets the "type_mime" field.
|
||||
func (_u *PieceJointeUpdate) SetTypeMime(v string) *PieceJointeUpdate {
|
||||
_u.mutation.SetTypeMime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTypeMime sets the "type_mime" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableTypeMime(v *string) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetTypeMime(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEstPrincipale sets the "est_principale" field.
|
||||
func (_u *PieceJointeUpdate) SetEstPrincipale(v bool) *PieceJointeUpdate {
|
||||
_u.mutation.SetEstPrincipale(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEstPrincipale sets the "est_principale" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableEstPrincipale(v *bool) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetEstPrincipale(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCategorie sets the "categorie" field.
|
||||
func (_u *PieceJointeUpdate) SetCategorie(v piecejointe.Categorie) *PieceJointeUpdate {
|
||||
_u.mutation.SetCategorie(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCategorie sets the "categorie" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableCategorie(v *piecejointe.Categorie) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetCategorie(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *PieceJointeUpdate) SetCreatedAt(v time.Time) *PieceJointeUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdate) SetNillableCreatedAt(v *time.Time) *PieceJointeUpdate {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *PieceJointeUpdate) SetUpdatedAt(v time.Time) *PieceJointeUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *PieceJointeUpdate) SetObjet(v *Objet) *PieceJointeUpdate {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the PieceJointeMutation object of the builder.
|
||||
func (_u *PieceJointeUpdate) Mutation() *PieceJointeMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *PieceJointeUpdate) ClearObjet() *PieceJointeUpdate {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *PieceJointeUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *PieceJointeUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *PieceJointeUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *PieceJointeUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *PieceJointeUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := piecejointe.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *PieceJointeUpdate) check() error {
|
||||
if v, ok := _u.mutation.NomFichier(); ok {
|
||||
if err := piecejointe.NomFichierValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_fichier", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.nom_fichier": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Chemin(); ok {
|
||||
if err := piecejointe.CheminValidator(v); err != nil {
|
||||
return &ValidationError{Name: "chemin", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.chemin": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TypeMime(); ok {
|
||||
if err := piecejointe.TypeMimeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_mime", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.type_mime": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Categorie(); ok {
|
||||
if err := piecejointe.CategorieValidator(v); err != nil {
|
||||
return &ValidationError{Name: "categorie", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.categorie": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "PieceJointe.objet"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *PieceJointeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(piecejointe.Table, piecejointe.Columns, sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.NomFichier(); ok {
|
||||
_spec.SetField(piecejointe.FieldNomFichier, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Chemin(); ok {
|
||||
_spec.SetField(piecejointe.FieldChemin, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TypeMime(); ok {
|
||||
_spec.SetField(piecejointe.FieldTypeMime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.EstPrincipale(); ok {
|
||||
_spec.SetField(piecejointe.FieldEstPrincipale, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Categorie(); ok {
|
||||
_spec.SetField(piecejointe.FieldCategorie, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: piecejointe.ObjetTable,
|
||||
Columns: []string{piecejointe.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: piecejointe.ObjetTable,
|
||||
Columns: []string{piecejointe.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{piecejointe.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// PieceJointeUpdateOne is the builder for updating a single PieceJointe entity.
|
||||
type PieceJointeUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *PieceJointeMutation
|
||||
}
|
||||
|
||||
// SetObjetID sets the "objet_id" field.
|
||||
func (_u *PieceJointeUpdateOne) SetObjetID(v uuid.UUID) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetObjetID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableObjetID sets the "objet_id" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableObjetID(v *uuid.UUID) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetObjetID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNomFichier sets the "nom_fichier" field.
|
||||
func (_u *PieceJointeUpdateOne) SetNomFichier(v string) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetNomFichier(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableNomFichier sets the "nom_fichier" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableNomFichier(v *string) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetNomFichier(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetChemin sets the "chemin" field.
|
||||
func (_u *PieceJointeUpdateOne) SetChemin(v string) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetChemin(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableChemin sets the "chemin" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableChemin(v *string) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetChemin(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTypeMime sets the "type_mime" field.
|
||||
func (_u *PieceJointeUpdateOne) SetTypeMime(v string) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetTypeMime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTypeMime sets the "type_mime" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableTypeMime(v *string) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTypeMime(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEstPrincipale sets the "est_principale" field.
|
||||
func (_u *PieceJointeUpdateOne) SetEstPrincipale(v bool) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetEstPrincipale(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEstPrincipale sets the "est_principale" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableEstPrincipale(v *bool) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEstPrincipale(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCategorie sets the "categorie" field.
|
||||
func (_u *PieceJointeUpdateOne) SetCategorie(v piecejointe.Categorie) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetCategorie(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCategorie sets the "categorie" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableCategorie(v *piecejointe.Categorie) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCategorie(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *PieceJointeUpdateOne) SetCreatedAt(v time.Time) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_u *PieceJointeUpdateOne) SetNillableCreatedAt(v *time.Time) *PieceJointeUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetCreatedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *PieceJointeUpdateOne) SetUpdatedAt(v time.Time) *PieceJointeUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetObjet sets the "objet" edge to the Objet entity.
|
||||
func (_u *PieceJointeUpdateOne) SetObjet(v *Objet) *PieceJointeUpdateOne {
|
||||
return _u.SetObjetID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the PieceJointeMutation object of the builder.
|
||||
func (_u *PieceJointeUpdateOne) Mutation() *PieceJointeMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearObjet clears the "objet" edge to the Objet entity.
|
||||
func (_u *PieceJointeUpdateOne) ClearObjet() *PieceJointeUpdateOne {
|
||||
_u.mutation.ClearObjet()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PieceJointeUpdate builder.
|
||||
func (_u *PieceJointeUpdateOne) Where(ps ...predicate.PieceJointe) *PieceJointeUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *PieceJointeUpdateOne) Select(field string, fields ...string) *PieceJointeUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated PieceJointe entity.
|
||||
func (_u *PieceJointeUpdateOne) Save(ctx context.Context) (*PieceJointe, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *PieceJointeUpdateOne) SaveX(ctx context.Context) *PieceJointe {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *PieceJointeUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *PieceJointeUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *PieceJointeUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := piecejointe.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *PieceJointeUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.NomFichier(); ok {
|
||||
if err := piecejointe.NomFichierValidator(v); err != nil {
|
||||
return &ValidationError{Name: "nom_fichier", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.nom_fichier": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Chemin(); ok {
|
||||
if err := piecejointe.CheminValidator(v); err != nil {
|
||||
return &ValidationError{Name: "chemin", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.chemin": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.TypeMime(); ok {
|
||||
if err := piecejointe.TypeMimeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "type_mime", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.type_mime": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Categorie(); ok {
|
||||
if err := piecejointe.CategorieValidator(v); err != nil {
|
||||
return &ValidationError{Name: "categorie", err: fmt.Errorf(`ent: validator failed for field "PieceJointe.categorie": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.ObjetCleared() && len(_u.mutation.ObjetIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "PieceJointe.objet"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *PieceJointeUpdateOne) sqlSave(ctx context.Context) (_node *PieceJointe, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(piecejointe.Table, piecejointe.Columns, sqlgraph.NewFieldSpec(piecejointe.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PieceJointe.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, piecejointe.FieldID)
|
||||
for _, f := range fields {
|
||||
if !piecejointe.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != piecejointe.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.NomFichier(); ok {
|
||||
_spec.SetField(piecejointe.FieldNomFichier, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Chemin(); ok {
|
||||
_spec.SetField(piecejointe.FieldChemin, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TypeMime(); ok {
|
||||
_spec.SetField(piecejointe.FieldTypeMime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.EstPrincipale(); ok {
|
||||
_spec.SetField(piecejointe.FieldEstPrincipale, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Categorie(); ok {
|
||||
_spec.SetField(piecejointe.FieldCategorie, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(piecejointe.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ObjetCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: piecejointe.ObjetTable,
|
||||
Columns: []string{piecejointe.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.ObjetIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: piecejointe.ObjetTable,
|
||||
Columns: []string{piecejointe.ObjetColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(objet.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &PieceJointe{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{piecejointe.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
25
backend/internal/data/ent/predicate/predicate.go
Normal file
25
backend/internal/data/ent/predicate/predicate.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Categorie is the predicate function for categorie builders.
|
||||
type Categorie func(*sql.Selector)
|
||||
|
||||
// ChampPersonnalise is the predicate function for champpersonnalise builders.
|
||||
type ChampPersonnalise func(*sql.Selector)
|
||||
|
||||
// Emplacement is the predicate function for emplacement builders.
|
||||
type Emplacement func(*sql.Selector)
|
||||
|
||||
// LienObjetEmplacement is the predicate function for lienobjetemplacement builders.
|
||||
type LienObjetEmplacement func(*sql.Selector)
|
||||
|
||||
// Objet is the predicate function for objet builders.
|
||||
type Objet func(*sql.Selector)
|
||||
|
||||
// PieceJointe is the predicate function for piecejointe builders.
|
||||
type PieceJointe func(*sql.Selector)
|
||||
154
backend/internal/data/ent/runtime.go
Normal file
154
backend/internal/data/ent/runtime.go
Normal file
@@ -0,0 +1,154 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/schema"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// The init function reads all schema descriptors with runtime code
|
||||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
categorieFields := schema.Categorie{}.Fields()
|
||||
_ = categorieFields
|
||||
// categorieDescNom is the schema descriptor for nom field.
|
||||
categorieDescNom := categorieFields[1].Descriptor()
|
||||
// categorie.NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
categorie.NomValidator = categorieDescNom.Validators[0].(func(string) error)
|
||||
// categorieDescCreatedAt is the schema descriptor for created_at field.
|
||||
categorieDescCreatedAt := categorieFields[5].Descriptor()
|
||||
// categorie.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
categorie.DefaultCreatedAt = categorieDescCreatedAt.Default.(func() time.Time)
|
||||
// categorieDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
categorieDescUpdatedAt := categorieFields[6].Descriptor()
|
||||
// categorie.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
categorie.DefaultUpdatedAt = categorieDescUpdatedAt.Default.(func() time.Time)
|
||||
// categorie.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
categorie.UpdateDefaultUpdatedAt = categorieDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// categorieDescID is the schema descriptor for id field.
|
||||
categorieDescID := categorieFields[0].Descriptor()
|
||||
// categorie.DefaultID holds the default value on creation for the id field.
|
||||
categorie.DefaultID = categorieDescID.Default.(func() uuid.UUID)
|
||||
champpersonnaliseFields := schema.ChampPersonnalise{}.Fields()
|
||||
_ = champpersonnaliseFields
|
||||
// champpersonnaliseDescNomChamp is the schema descriptor for nom_champ field.
|
||||
champpersonnaliseDescNomChamp := champpersonnaliseFields[2].Descriptor()
|
||||
// champpersonnalise.NomChampValidator is a validator for the "nom_champ" field. It is called by the builders before save.
|
||||
champpersonnalise.NomChampValidator = champpersonnaliseDescNomChamp.Validators[0].(func(string) error)
|
||||
// champpersonnaliseDescCreatedAt is the schema descriptor for created_at field.
|
||||
champpersonnaliseDescCreatedAt := champpersonnaliseFields[6].Descriptor()
|
||||
// champpersonnalise.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
champpersonnalise.DefaultCreatedAt = champpersonnaliseDescCreatedAt.Default.(func() time.Time)
|
||||
// champpersonnaliseDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
champpersonnaliseDescUpdatedAt := champpersonnaliseFields[7].Descriptor()
|
||||
// champpersonnalise.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
champpersonnalise.DefaultUpdatedAt = champpersonnaliseDescUpdatedAt.Default.(func() time.Time)
|
||||
// champpersonnalise.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
champpersonnalise.UpdateDefaultUpdatedAt = champpersonnaliseDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// champpersonnaliseDescID is the schema descriptor for id field.
|
||||
champpersonnaliseDescID := champpersonnaliseFields[0].Descriptor()
|
||||
// champpersonnalise.DefaultID holds the default value on creation for the id field.
|
||||
champpersonnalise.DefaultID = champpersonnaliseDescID.Default.(func() uuid.UUID)
|
||||
emplacementFields := schema.Emplacement{}.Fields()
|
||||
_ = emplacementFields
|
||||
// emplacementDescNom is the schema descriptor for nom field.
|
||||
emplacementDescNom := emplacementFields[1].Descriptor()
|
||||
// emplacement.NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
emplacement.NomValidator = emplacementDescNom.Validators[0].(func(string) error)
|
||||
// emplacementDescCreatedAt is the schema descriptor for created_at field.
|
||||
emplacementDescCreatedAt := emplacementFields[8].Descriptor()
|
||||
// emplacement.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
emplacement.DefaultCreatedAt = emplacementDescCreatedAt.Default.(func() time.Time)
|
||||
// emplacementDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
emplacementDescUpdatedAt := emplacementFields[9].Descriptor()
|
||||
// emplacement.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
emplacement.DefaultUpdatedAt = emplacementDescUpdatedAt.Default.(func() time.Time)
|
||||
// emplacement.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
emplacement.UpdateDefaultUpdatedAt = emplacementDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// emplacementDescID is the schema descriptor for id field.
|
||||
emplacementDescID := emplacementFields[0].Descriptor()
|
||||
// emplacement.DefaultID holds the default value on creation for the id field.
|
||||
emplacement.DefaultID = emplacementDescID.Default.(func() uuid.UUID)
|
||||
lienobjetemplacementFields := schema.LienObjetEmplacement{}.Fields()
|
||||
_ = lienobjetemplacementFields
|
||||
// lienobjetemplacementDescCreatedAt is the schema descriptor for created_at field.
|
||||
lienobjetemplacementDescCreatedAt := lienobjetemplacementFields[4].Descriptor()
|
||||
// lienobjetemplacement.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
lienobjetemplacement.DefaultCreatedAt = lienobjetemplacementDescCreatedAt.Default.(func() time.Time)
|
||||
// lienobjetemplacementDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
lienobjetemplacementDescUpdatedAt := lienobjetemplacementFields[5].Descriptor()
|
||||
// lienobjetemplacement.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
lienobjetemplacement.DefaultUpdatedAt = lienobjetemplacementDescUpdatedAt.Default.(func() time.Time)
|
||||
// lienobjetemplacement.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
lienobjetemplacement.UpdateDefaultUpdatedAt = lienobjetemplacementDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// lienobjetemplacementDescID is the schema descriptor for id field.
|
||||
lienobjetemplacementDescID := lienobjetemplacementFields[0].Descriptor()
|
||||
// lienobjetemplacement.DefaultID holds the default value on creation for the id field.
|
||||
lienobjetemplacement.DefaultID = lienobjetemplacementDescID.Default.(func() uuid.UUID)
|
||||
objetFields := schema.Objet{}.Fields()
|
||||
_ = objetFields
|
||||
// objetDescNom is the schema descriptor for nom field.
|
||||
objetDescNom := objetFields[1].Descriptor()
|
||||
// objet.NomValidator is a validator for the "nom" field. It is called by the builders before save.
|
||||
objet.NomValidator = objetDescNom.Validators[0].(func(string) error)
|
||||
// objetDescQuantite is the schema descriptor for quantite field.
|
||||
objetDescQuantite := objetFields[3].Descriptor()
|
||||
// objet.DefaultQuantite holds the default value on creation for the quantite field.
|
||||
objet.DefaultQuantite = objetDescQuantite.Default.(int)
|
||||
// objetDescCreatedAt is the schema descriptor for created_at field.
|
||||
objetDescCreatedAt := objetFields[12].Descriptor()
|
||||
// objet.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
objet.DefaultCreatedAt = objetDescCreatedAt.Default.(func() time.Time)
|
||||
// objetDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
objetDescUpdatedAt := objetFields[13].Descriptor()
|
||||
// objet.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
objet.DefaultUpdatedAt = objetDescUpdatedAt.Default.(func() time.Time)
|
||||
// objet.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
objet.UpdateDefaultUpdatedAt = objetDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// objetDescID is the schema descriptor for id field.
|
||||
objetDescID := objetFields[0].Descriptor()
|
||||
// objet.DefaultID holds the default value on creation for the id field.
|
||||
objet.DefaultID = objetDescID.Default.(func() uuid.UUID)
|
||||
piecejointeFields := schema.PieceJointe{}.Fields()
|
||||
_ = piecejointeFields
|
||||
// piecejointeDescNomFichier is the schema descriptor for nom_fichier field.
|
||||
piecejointeDescNomFichier := piecejointeFields[2].Descriptor()
|
||||
// piecejointe.NomFichierValidator is a validator for the "nom_fichier" field. It is called by the builders before save.
|
||||
piecejointe.NomFichierValidator = piecejointeDescNomFichier.Validators[0].(func(string) error)
|
||||
// piecejointeDescChemin is the schema descriptor for chemin field.
|
||||
piecejointeDescChemin := piecejointeFields[3].Descriptor()
|
||||
// piecejointe.CheminValidator is a validator for the "chemin" field. It is called by the builders before save.
|
||||
piecejointe.CheminValidator = piecejointeDescChemin.Validators[0].(func(string) error)
|
||||
// piecejointeDescTypeMime is the schema descriptor for type_mime field.
|
||||
piecejointeDescTypeMime := piecejointeFields[4].Descriptor()
|
||||
// piecejointe.TypeMimeValidator is a validator for the "type_mime" field. It is called by the builders before save.
|
||||
piecejointe.TypeMimeValidator = piecejointeDescTypeMime.Validators[0].(func(string) error)
|
||||
// piecejointeDescEstPrincipale is the schema descriptor for est_principale field.
|
||||
piecejointeDescEstPrincipale := piecejointeFields[5].Descriptor()
|
||||
// piecejointe.DefaultEstPrincipale holds the default value on creation for the est_principale field.
|
||||
piecejointe.DefaultEstPrincipale = piecejointeDescEstPrincipale.Default.(bool)
|
||||
// piecejointeDescCreatedAt is the schema descriptor for created_at field.
|
||||
piecejointeDescCreatedAt := piecejointeFields[7].Descriptor()
|
||||
// piecejointe.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
piecejointe.DefaultCreatedAt = piecejointeDescCreatedAt.Default.(func() time.Time)
|
||||
// piecejointeDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
piecejointeDescUpdatedAt := piecejointeFields[8].Descriptor()
|
||||
// piecejointe.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
piecejointe.DefaultUpdatedAt = piecejointeDescUpdatedAt.Default.(func() time.Time)
|
||||
// piecejointe.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
piecejointe.UpdateDefaultUpdatedAt = piecejointeDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// piecejointeDescID is the schema descriptor for id field.
|
||||
piecejointeDescID := piecejointeFields[0].Descriptor()
|
||||
// piecejointe.DefaultID holds the default value on creation for the id field.
|
||||
piecejointe.DefaultID = piecejointeDescID.Default.(func() uuid.UUID)
|
||||
}
|
||||
10
backend/internal/data/ent/runtime/runtime.go
Normal file
10
backend/internal/data/ent/runtime/runtime.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.14.5" // Version of ent codegen.
|
||||
Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen.
|
||||
)
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -45,6 +47,13 @@ func (Categorie) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (Categorie) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "categorie"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite Categorie.
|
||||
func (Categorie) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -47,12 +49,20 @@ func (ChampPersonnalise) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (ChampPersonnalise) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "champ_personnalise"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite ChampPersonnalise.
|
||||
func (ChampPersonnalise) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("objet", Objet.Type).
|
||||
Ref("champs_personnalises").
|
||||
Unique().
|
||||
Field("objet_id"),
|
||||
Field("objet_id").
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -57,6 +59,13 @@ func (Emplacement) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (Emplacement) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "emplacement"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite Emplacement.
|
||||
func (Emplacement) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
@@ -65,5 +74,7 @@ func (Emplacement) Edges() []ent.Edge {
|
||||
Unique().
|
||||
Field("parent_id").
|
||||
Comment("Lien parent/enfants pour l'arbre des emplacements"),
|
||||
edge.To("liens_objets", LienObjetEmplacement.Type).
|
||||
Comment("Liens entre emplacements et objets"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -38,16 +40,25 @@ func (LienObjetEmplacement) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (LienObjetEmplacement) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "lien_objet_emplacement"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite LienObjetEmplacement.
|
||||
func (LienObjetEmplacement) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("objet", Objet.Type).
|
||||
Ref("liens_emplacements").
|
||||
Unique().
|
||||
Field("objet_id"),
|
||||
Field("objet_id").
|
||||
Required(),
|
||||
edge.From("emplacement", Emplacement.Type).
|
||||
Ref("liens_objets").
|
||||
Unique().
|
||||
Field("emplacement_id"),
|
||||
Field("emplacement_id").
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -60,7 +62,6 @@ func (Objet) Fields() []ent.Field {
|
||||
Comment("Statut de l'objet"),
|
||||
field.JSON("caracteristiques", map[string]any{}).
|
||||
Optional().
|
||||
Nillable().
|
||||
Comment("Caracteristiques personnalisees"),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
@@ -72,6 +73,13 @@ func (Objet) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (Objet) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "objet"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite Objet.
|
||||
func (Objet) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
@@ -48,12 +50,20 @@ func (PieceJointe) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Annotations pour le nom de table.
|
||||
func (PieceJointe) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
entsql.Annotation{Table: "piece_jointe"},
|
||||
}
|
||||
}
|
||||
|
||||
// Edges de l'entite PieceJointe.
|
||||
func (PieceJointe) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("objet", Objet.Type).
|
||||
Ref("pieces_jointes").
|
||||
Unique().
|
||||
Field("objet_id"),
|
||||
Field("objet_id").
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
|
||||
225
backend/internal/data/ent/tx.go
Normal file
225
backend/internal/data/ent/tx.go
Normal file
@@ -0,0 +1,225 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
)
|
||||
|
||||
// Tx is a transactional client that is created by calling Client.Tx().
|
||||
type Tx struct {
|
||||
config
|
||||
// Categorie is the client for interacting with the Categorie builders.
|
||||
Categorie *CategorieClient
|
||||
// ChampPersonnalise is the client for interacting with the ChampPersonnalise builders.
|
||||
ChampPersonnalise *ChampPersonnaliseClient
|
||||
// Emplacement is the client for interacting with the Emplacement builders.
|
||||
Emplacement *EmplacementClient
|
||||
// LienObjetEmplacement is the client for interacting with the LienObjetEmplacement builders.
|
||||
LienObjetEmplacement *LienObjetEmplacementClient
|
||||
// Objet is the client for interacting with the Objet builders.
|
||||
Objet *ObjetClient
|
||||
// PieceJointe is the client for interacting with the PieceJointe builders.
|
||||
PieceJointe *PieceJointeClient
|
||||
|
||||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Commit method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Committer. If f is a function with the appropriate
|
||||
// signature, CommitFunc(f) is a Committer that calls f.
|
||||
CommitFunc func(context.Context, *Tx) error
|
||||
|
||||
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Commit(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
CommitHook func(Committer) Committer
|
||||
)
|
||||
|
||||
// Commit calls f(ctx, m).
|
||||
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Commit commits the transaction.
|
||||
func (tx *Tx) Commit() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), txDriver.onCommit...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Commit(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onCommit = append(txDriver.onCommit, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollback method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Rollbacker. If f is a function with the appropriate
|
||||
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||
RollbackFunc func(context.Context, *Tx) error
|
||||
|
||||
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Rollback(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
RollbackHook func(Rollbacker) Rollbacker
|
||||
)
|
||||
|
||||
// Rollback calls f(ctx, m).
|
||||
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Rollback rollbacks the transaction.
|
||||
func (tx *Tx) Rollback() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Rollback(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onRollback = append(txDriver.onRollback, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
func (tx *Tx) Client() *Client {
|
||||
tx.clientOnce.Do(func() {
|
||||
tx.client = &Client{config: tx.config}
|
||||
tx.client.init()
|
||||
})
|
||||
return tx.client
|
||||
}
|
||||
|
||||
func (tx *Tx) init() {
|
||||
tx.Categorie = NewCategorieClient(tx.config)
|
||||
tx.ChampPersonnalise = NewChampPersonnaliseClient(tx.config)
|
||||
tx.Emplacement = NewEmplacementClient(tx.config)
|
||||
tx.LienObjetEmplacement = NewLienObjetEmplacementClient(tx.config)
|
||||
tx.Objet = NewObjetClient(tx.config)
|
||||
tx.PieceJointe = NewPieceJointeClient(tx.config)
|
||||
}
|
||||
|
||||
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||
// The idea is to support transactions without adding any extra code to the builders.
|
||||
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||
// of them in order to commit or rollback the transaction.
|
||||
//
|
||||
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||
// applies a query, for example: Categorie.QueryXXX(), the query will be executed
|
||||
// through the driver which created this transaction.
|
||||
//
|
||||
// Note that txDriver is not goroutine safe.
|
||||
type txDriver struct {
|
||||
// the driver we started the transaction from.
|
||||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
// completion hooks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||
tx, err := drv.Tx(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &txDriver{tx: tx, drv: drv}, nil
|
||||
}
|
||||
|
||||
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||
// from the internal builders. Should be called only by the internal builders.
|
||||
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||
|
||||
// Dialect returns the dialect of the driver we started the transaction from.
|
||||
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||
|
||||
// Close is a nop close.
|
||||
func (*txDriver) Close() error { return nil }
|
||||
|
||||
// Commit is a nop commit for the internal builders.
|
||||
// User must call `Tx.Commit` in order to commit the transaction.
|
||||
func (*txDriver) Commit() error { return nil }
|
||||
|
||||
// Rollback is a nop rollback for the internal builders.
|
||||
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
var _ dialect.Driver = (*txDriver)(nil)
|
||||
193
backend/internal/handlers/categories.go
Normal file
193
backend/internal/handlers/categories.go
Normal file
@@ -0,0 +1,193 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/categorie"
|
||||
)
|
||||
|
||||
type categorieRequest struct {
|
||||
Nom *string `json:"nom"`
|
||||
ParentID *string `json:"parent_id"`
|
||||
Slug *string `json:"slug"`
|
||||
Icone *string `json:"icone"`
|
||||
}
|
||||
|
||||
// @Summary Lister les categories
|
||||
// @Tags Categories
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /categories [get]
|
||||
func (h *Handler) ListCategories(c *gin.Context) {
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.Categorie.Query()
|
||||
total, err := query.Count(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les categories"})
|
||||
return
|
||||
}
|
||||
|
||||
items, err := query.
|
||||
Order(ent.Desc(categorie.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les categories"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, items, total, page, limit)
|
||||
}
|
||||
|
||||
// @Summary Creer une categorie
|
||||
// @Tags Categories
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body categorieRequest true "Categorie a creer"
|
||||
// @Success 201 {object} ent.Categorie
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /categories [post]
|
||||
func (h *Handler) CreateCategorie(c *gin.Context) {
|
||||
var req categorieRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
if req.Nom == nil || *req.Nom == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "le champ nom est obligatoire"})
|
||||
return
|
||||
}
|
||||
|
||||
create := h.client.Categorie.Create().SetNom(*req.Nom)
|
||||
if req.ParentID != nil && *req.ParentID != "" {
|
||||
if parsed, err := uuid.Parse(*req.ParentID); err == nil {
|
||||
create.SetParentID(parsed)
|
||||
}
|
||||
}
|
||||
if req.Slug != nil {
|
||||
create.SetNillableSlug(req.Slug)
|
||||
}
|
||||
if req.Icone != nil {
|
||||
create.SetNillableIcone(req.Icone)
|
||||
}
|
||||
|
||||
created, err := create.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer la categorie"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, created)
|
||||
}
|
||||
|
||||
// @Summary Recuperer une categorie
|
||||
// @Tags Categories
|
||||
// @Produce json
|
||||
// @Param id path string true "ID categorie"
|
||||
// @Success 200 {object} ent.Categorie
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /categories/{id} [get]
|
||||
func (h *Handler) GetCategorie(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.client.Categorie.Get(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "categorie introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger la categorie"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, item)
|
||||
}
|
||||
|
||||
// @Summary Mettre a jour une categorie
|
||||
// @Tags Categories
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID categorie"
|
||||
// @Param body body categorieRequest true "Categorie a mettre a jour"
|
||||
// @Success 200 {object} ent.Categorie
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /categories/{id} [put]
|
||||
func (h *Handler) UpdateCategorie(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req categorieRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
|
||||
update := h.client.Categorie.UpdateOneID(id)
|
||||
if req.Nom != nil {
|
||||
update.SetNom(*req.Nom)
|
||||
}
|
||||
if req.ParentID != nil {
|
||||
if *req.ParentID == "" {
|
||||
update.ClearParentID()
|
||||
} else if parsed, err := uuid.Parse(*req.ParentID); err == nil {
|
||||
update.SetParentID(parsed)
|
||||
}
|
||||
}
|
||||
if req.Slug != nil {
|
||||
update.SetNillableSlug(req.Slug)
|
||||
}
|
||||
if req.Icone != nil {
|
||||
update.SetNillableIcone(req.Icone)
|
||||
}
|
||||
|
||||
updated, err := update.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "categorie introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de mettre a jour la categorie"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
|
||||
// @Summary Supprimer une categorie
|
||||
// @Tags Categories
|
||||
// @Param id path string true "ID categorie"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /categories/{id} [delete]
|
||||
func (h *Handler) DeleteCategorie(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.client.Categorie.DeleteOneID(id).Exec(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer la categorie"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// helper for compile reference
|
||||
var _ = ent.IsNotFound
|
||||
207
backend/internal/handlers/champs_personnalises.go
Normal file
207
backend/internal/handlers/champs_personnalises.go
Normal file
@@ -0,0 +1,207 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/champpersonnalise"
|
||||
)
|
||||
|
||||
type champPersonnaliseRequest struct {
|
||||
NomChamp *string `json:"nom_champ"`
|
||||
TypeChamp *string `json:"type_champ"`
|
||||
Valeur *string `json:"valeur"`
|
||||
Unite *string `json:"unite"`
|
||||
}
|
||||
|
||||
// @Summary Lister les champs personnalises
|
||||
// @Tags ChampsPersonnalises
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/champs_personnalises [get]
|
||||
func (h *Handler) ListChampsPersonnalises(c *gin.Context) {
|
||||
objetID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.ChampPersonnalise.Query().
|
||||
Where(champpersonnalise.ObjetID(objetID))
|
||||
total, err := query.Count(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les champs"})
|
||||
return
|
||||
}
|
||||
|
||||
items, err := query.
|
||||
Order(ent.Desc(champpersonnalise.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les champs"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, items, total, page, limit)
|
||||
}
|
||||
|
||||
// @Summary Creer un champ personnalise
|
||||
// @Tags ChampsPersonnalises
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param body body champPersonnaliseRequest true "Champ personnalise"
|
||||
// @Success 201 {object} ent.ChampPersonnalise
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/champs_personnalises [post]
|
||||
func (h *Handler) CreateChampPersonnalise(c *gin.Context) {
|
||||
objetID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req champPersonnaliseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
if req.NomChamp == nil || *req.NomChamp == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "le champ nom_champ est obligatoire"})
|
||||
return
|
||||
}
|
||||
|
||||
create := h.client.ChampPersonnalise.Create().
|
||||
SetObjetID(objetID).
|
||||
SetNomChamp(*req.NomChamp)
|
||||
|
||||
if req.TypeChamp != nil && *req.TypeChamp != "" {
|
||||
parsed, ok := parseTypeChamp(*req.TypeChamp)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "type_champ invalide"})
|
||||
return
|
||||
}
|
||||
create.SetTypeChamp(parsed)
|
||||
}
|
||||
if req.Valeur != nil {
|
||||
create.SetNillableValeur(req.Valeur)
|
||||
}
|
||||
if req.Unite != nil {
|
||||
create.SetNillableUnite(req.Unite)
|
||||
}
|
||||
|
||||
created, err := create.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer le champ"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, created)
|
||||
}
|
||||
|
||||
// @Summary Mettre a jour un champ personnalise
|
||||
// @Tags ChampsPersonnalises
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID champ"
|
||||
// @Param body body champPersonnaliseRequest true "Champ personnalise"
|
||||
// @Success 200 {object} ent.ChampPersonnalise
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /champs_personnalises/{id} [put]
|
||||
func (h *Handler) UpdateChampPersonnalise(c *gin.Context) {
|
||||
champID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req champPersonnaliseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
|
||||
update := h.client.ChampPersonnalise.UpdateOneID(champID)
|
||||
if req.NomChamp != nil {
|
||||
update.SetNomChamp(*req.NomChamp)
|
||||
}
|
||||
if req.TypeChamp != nil {
|
||||
if *req.TypeChamp != "" {
|
||||
parsed, ok := parseTypeChamp(*req.TypeChamp)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "type_champ invalide"})
|
||||
return
|
||||
}
|
||||
update.SetTypeChamp(parsed)
|
||||
}
|
||||
}
|
||||
if req.Valeur != nil {
|
||||
update.SetNillableValeur(req.Valeur)
|
||||
}
|
||||
if req.Unite != nil {
|
||||
update.SetNillableUnite(req.Unite)
|
||||
}
|
||||
|
||||
updated, err := update.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "champ introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de mettre a jour le champ"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
|
||||
// @Summary Supprimer un champ personnalise
|
||||
// @Tags ChampsPersonnalises
|
||||
// @Param id path string true "ID champ"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /champs_personnalises/{id} [delete]
|
||||
func (h *Handler) DeleteChampPersonnalise(c *gin.Context) {
|
||||
champID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.client.ChampPersonnalise.DeleteOneID(champID).Exec(c.Request.Context()); err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "champ introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer le champ"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func parseTypeChamp(value string) (champpersonnalise.TypeChamp, bool) {
|
||||
switch value {
|
||||
case "string":
|
||||
return champpersonnalise.TypeChampString, true
|
||||
case "int":
|
||||
return champpersonnalise.TypeChampInt, true
|
||||
case "bool":
|
||||
return champpersonnalise.TypeChampBool, true
|
||||
case "date":
|
||||
return champpersonnalise.TypeChampDate, true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
214
backend/internal/handlers/emplacements.go
Normal file
214
backend/internal/handlers/emplacements.go
Normal file
@@ -0,0 +1,214 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/emplacement"
|
||||
)
|
||||
|
||||
type emplacementRequest struct {
|
||||
Nom *string `json:"nom"`
|
||||
ParentID *string `json:"parent_id"`
|
||||
Slug *string `json:"slug"`
|
||||
Piece *string `json:"piece"`
|
||||
Meuble *string `json:"meuble"`
|
||||
NumeroBoite *string `json:"numero_boite"`
|
||||
Icone *string `json:"icone"`
|
||||
}
|
||||
|
||||
// @Summary Lister les emplacements
|
||||
// @Tags Emplacements
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /emplacements [get]
|
||||
func (h *Handler) ListEmplacements(c *gin.Context) {
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.Emplacement.Query()
|
||||
total, err := query.Count(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les emplacements"})
|
||||
return
|
||||
}
|
||||
|
||||
items, err := query.
|
||||
Order(ent.Desc(emplacement.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les emplacements"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, items, total, page, limit)
|
||||
}
|
||||
|
||||
// @Summary Creer un emplacement
|
||||
// @Tags Emplacements
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body emplacementRequest true "Emplacement a creer"
|
||||
// @Success 201 {object} ent.Emplacement
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /emplacements [post]
|
||||
func (h *Handler) CreateEmplacement(c *gin.Context) {
|
||||
var req emplacementRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
if req.Nom == nil || *req.Nom == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "le champ nom est obligatoire"})
|
||||
return
|
||||
}
|
||||
|
||||
create := h.client.Emplacement.Create().SetNom(*req.Nom)
|
||||
if req.ParentID != nil && *req.ParentID != "" {
|
||||
if parsed, err := uuid.Parse(*req.ParentID); err == nil {
|
||||
create.SetParentID(parsed)
|
||||
}
|
||||
}
|
||||
if req.Slug != nil {
|
||||
create.SetNillableSlug(req.Slug)
|
||||
}
|
||||
if req.Piece != nil {
|
||||
create.SetNillablePiece(req.Piece)
|
||||
}
|
||||
if req.Meuble != nil {
|
||||
create.SetNillableMeuble(req.Meuble)
|
||||
}
|
||||
if req.NumeroBoite != nil {
|
||||
create.SetNillableNumeroBoite(req.NumeroBoite)
|
||||
}
|
||||
if req.Icone != nil {
|
||||
create.SetNillableIcone(req.Icone)
|
||||
}
|
||||
|
||||
created, err := create.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer l'emplacement"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, created)
|
||||
}
|
||||
|
||||
// @Summary Recuperer un emplacement
|
||||
// @Tags Emplacements
|
||||
// @Produce json
|
||||
// @Param id path string true "ID emplacement"
|
||||
// @Success 200 {object} ent.Emplacement
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /emplacements/{id} [get]
|
||||
func (h *Handler) GetEmplacement(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.client.Emplacement.Get(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "emplacement introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger l'emplacement"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, item)
|
||||
}
|
||||
|
||||
// @Summary Mettre a jour un emplacement
|
||||
// @Tags Emplacements
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID emplacement"
|
||||
// @Param body body emplacementRequest true "Emplacement a mettre a jour"
|
||||
// @Success 200 {object} ent.Emplacement
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /emplacements/{id} [put]
|
||||
func (h *Handler) UpdateEmplacement(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req emplacementRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
|
||||
update := h.client.Emplacement.UpdateOneID(id)
|
||||
if req.Nom != nil {
|
||||
update.SetNom(*req.Nom)
|
||||
}
|
||||
if req.ParentID != nil {
|
||||
if *req.ParentID == "" {
|
||||
update.ClearParentID()
|
||||
} else if parsed, err := uuid.Parse(*req.ParentID); err == nil {
|
||||
update.SetParentID(parsed)
|
||||
}
|
||||
}
|
||||
if req.Slug != nil {
|
||||
update.SetNillableSlug(req.Slug)
|
||||
}
|
||||
if req.Piece != nil {
|
||||
update.SetNillablePiece(req.Piece)
|
||||
}
|
||||
if req.Meuble != nil {
|
||||
update.SetNillableMeuble(req.Meuble)
|
||||
}
|
||||
if req.NumeroBoite != nil {
|
||||
update.SetNillableNumeroBoite(req.NumeroBoite)
|
||||
}
|
||||
if req.Icone != nil {
|
||||
update.SetNillableIcone(req.Icone)
|
||||
}
|
||||
|
||||
updated, err := update.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "emplacement introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de mettre a jour l'emplacement"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
|
||||
// @Summary Supprimer un emplacement
|
||||
// @Tags Emplacements
|
||||
// @Param id path string true "ID emplacement"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /emplacements/{id} [delete]
|
||||
func (h *Handler) DeleteEmplacement(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.client.Emplacement.DeleteOneID(id).Exec(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer l'emplacement"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// helper for compile reference
|
||||
var _ = ent.IsNotFound
|
||||
8
backend/internal/handlers/handler.go
Normal file
8
backend/internal/handlers/handler.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import "gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
|
||||
// Handler regroupe les dependances pour les handlers.
|
||||
type Handler struct {
|
||||
client *ent.Client
|
||||
}
|
||||
108
backend/internal/handlers/helpers.go
Normal file
108
backend/internal/handlers/helpers.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
)
|
||||
|
||||
// parseDateTime parse une date ISO-8601.
|
||||
func parseDateTime(value string) (time.Time, error) {
|
||||
return time.Parse(time.RFC3339, value)
|
||||
}
|
||||
|
||||
// resolveCategorie determine la categorie d'une piece jointe.
|
||||
func resolveCategorie(ext string, mime string) string {
|
||||
ext = strings.ToLower(ext)
|
||||
mime = strings.ToLower(mime)
|
||||
if ext == ".md" || mime == "text/markdown" {
|
||||
return "markdown_tuto"
|
||||
}
|
||||
if mime == "application/pdf" || ext == ".pdf" {
|
||||
return "pdf_notice"
|
||||
}
|
||||
if strings.HasPrefix(mime, "image/") {
|
||||
return "image"
|
||||
}
|
||||
return "image"
|
||||
}
|
||||
|
||||
// maxUploadBytes retourne la taille max d'un fichier en octets.
|
||||
func maxUploadBytes() int64 {
|
||||
const defaultMB = 50
|
||||
value := os.Getenv("MAX_UPLOAD_MB")
|
||||
if value == "" {
|
||||
return defaultMB * 1024 * 1024
|
||||
}
|
||||
parsed, err := strconv.Atoi(value)
|
||||
if err != nil || parsed <= 0 {
|
||||
return defaultMB * 1024 * 1024
|
||||
}
|
||||
return int64(parsed) * 1024 * 1024
|
||||
}
|
||||
|
||||
// parsePagination calcule la limite et l'offset a partir des params page/limit.
|
||||
func parsePagination(pageValue string, limitValue string) (int, int, int) {
|
||||
const (
|
||||
defaultLimit = 50
|
||||
maxLimit = 200
|
||||
)
|
||||
|
||||
page := 1
|
||||
if pageValue != "" {
|
||||
if parsed, err := strconv.Atoi(pageValue); err == nil && parsed > 0 {
|
||||
page = parsed
|
||||
}
|
||||
}
|
||||
|
||||
limit := defaultLimit
|
||||
if limitValue != "" {
|
||||
if parsed, err := strconv.Atoi(limitValue); err == nil && parsed > 0 {
|
||||
limit = parsed
|
||||
}
|
||||
}
|
||||
if limit > maxLimit {
|
||||
limit = maxLimit
|
||||
}
|
||||
|
||||
offset := (page - 1) * limit
|
||||
return limit, offset, page
|
||||
}
|
||||
|
||||
// isAllowedUpload valide le type de fichier (images, PDF, Markdown).
|
||||
func isAllowedUpload(mime string, ext string) bool {
|
||||
mime = strings.ToLower(mime)
|
||||
ext = strings.ToLower(ext)
|
||||
if strings.HasPrefix(mime, "image/") {
|
||||
return true
|
||||
}
|
||||
if mime == "application/pdf" || ext == ".pdf" {
|
||||
return true
|
||||
}
|
||||
if mime == "text/markdown" || ext == ".md" || ext == ".markdown" {
|
||||
return true
|
||||
}
|
||||
if mime == "text/plain" && (ext == ".md" || ext == ".markdown") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// parseStatut convertit un statut texte vers l'enum Ent.
|
||||
func parseStatut(value string) (objet.Statut, bool) {
|
||||
switch value {
|
||||
case "en_stock":
|
||||
return objet.StatutEnStock, true
|
||||
case "pret":
|
||||
return objet.StatutPret, true
|
||||
case "hors_service":
|
||||
return objet.StatutHorsService, true
|
||||
case "archive":
|
||||
return objet.StatutArchive, true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
74
backend/internal/handlers/helpers_test.go
Normal file
74
backend/internal/handlers/helpers_test.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package handlers
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsAllowedUpload(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
mime string
|
||||
ext string
|
||||
want bool
|
||||
}{
|
||||
{"image", "image/png", ".png", true},
|
||||
{"pdf", "application/pdf", ".pdf", true},
|
||||
{"md", "text/markdown", ".md", true},
|
||||
{"md_plain", "text/plain", ".md", true},
|
||||
{"other", "application/zip", ".zip", false},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
if got := isAllowedUpload(c.mime, c.ext); got != c.want {
|
||||
t.Fatalf("attendu %v, obtenu %v", c.want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxUploadBytes(t *testing.T) {
|
||||
t.Setenv("MAX_UPLOAD_MB", "1")
|
||||
if got := maxUploadBytes(); got != 1*1024*1024 {
|
||||
t.Fatalf("taille inattendue: %d", got)
|
||||
}
|
||||
|
||||
t.Setenv("MAX_UPLOAD_MB", "0")
|
||||
if got := maxUploadBytes(); got != 50*1024*1024 {
|
||||
t.Fatalf("taille par defaut inattendue: %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTypeChamp(t *testing.T) {
|
||||
valid := []string{"string", "int", "bool", "date"}
|
||||
for _, v := range valid {
|
||||
if _, ok := parseTypeChamp(v); !ok {
|
||||
t.Fatalf("type_champ invalide: %s", v)
|
||||
}
|
||||
}
|
||||
if _, ok := parseTypeChamp("x"); ok {
|
||||
t.Fatal("type_champ devrait etre invalide")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseLienType(t *testing.T) {
|
||||
valid := []string{"stocke", "utilise_dans"}
|
||||
for _, v := range valid {
|
||||
if _, ok := parseLienType(v); !ok {
|
||||
t.Fatalf("type lien invalide: %s", v)
|
||||
}
|
||||
}
|
||||
if _, ok := parseLienType("x"); ok {
|
||||
t.Fatal("type lien devrait etre invalide")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseStatut(t *testing.T) {
|
||||
valid := []string{"en_stock", "pret", "hors_service", "archive"}
|
||||
for _, v := range valid {
|
||||
if _, ok := parseStatut(v); !ok {
|
||||
t.Fatalf("statut invalide: %s", v)
|
||||
}
|
||||
}
|
||||
if _, ok := parseStatut("x"); ok {
|
||||
t.Fatal("statut devrait etre invalide")
|
||||
}
|
||||
}
|
||||
269
backend/internal/handlers/liens_objet_emplacement.go
Normal file
269
backend/internal/handlers/liens_objet_emplacement.go
Normal file
@@ -0,0 +1,269 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/lienobjetemplacement"
|
||||
)
|
||||
|
||||
type lienObjetEmplacementRequest struct {
|
||||
EmplacementID *string `json:"emplacement_id"`
|
||||
Type *string `json:"type"`
|
||||
}
|
||||
|
||||
type lienObjetEmplacementUpdateRequest struct {
|
||||
EmplacementID *string `json:"emplacement_id"`
|
||||
Type *string `json:"type"`
|
||||
}
|
||||
|
||||
// @Summary Lister les liens objet/emplacement
|
||||
// @Tags LiensEmplacements
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/liens_emplacements [get]
|
||||
func (h *Handler) ListLiensEmplacements(c *gin.Context) {
|
||||
objetID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.LienObjetEmplacement.Query().
|
||||
Where(lienobjetemplacement.ObjetID(objetID))
|
||||
total, err := query.Count(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les liens"})
|
||||
return
|
||||
}
|
||||
|
||||
items, err := query.
|
||||
Order(ent.Desc(lienobjetemplacement.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les liens"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, items, total, page, limit)
|
||||
}
|
||||
|
||||
// @Summary Creer un lien objet/emplacement
|
||||
// @Tags LiensEmplacements
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param body body lienObjetEmplacementRequest true "Lien"
|
||||
// @Success 201 {object} ent.LienObjetEmplacement
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 409 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/liens_emplacements [post]
|
||||
func (h *Handler) CreateLienEmplacement(c *gin.Context) {
|
||||
objetID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req lienObjetEmplacementRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
if req.EmplacementID == nil || *req.EmplacementID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "emplacement_id obligatoire"})
|
||||
return
|
||||
}
|
||||
|
||||
emplacementID, err := uuid.Parse(*req.EmplacementID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "emplacement_id invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := h.client.Emplacement.Get(c.Request.Context(), emplacementID); err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "emplacement introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger l'emplacement"})
|
||||
return
|
||||
}
|
||||
|
||||
create := h.client.LienObjetEmplacement.Create().
|
||||
SetObjetID(objetID).
|
||||
SetEmplacementID(emplacementID)
|
||||
|
||||
typeValeur := lienobjetemplacement.TypeStocke
|
||||
if req.Type != nil && *req.Type != "" {
|
||||
parsed, ok := parseLienType(*req.Type)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "type invalide"})
|
||||
return
|
||||
}
|
||||
typeValeur = parsed
|
||||
}
|
||||
create.SetType(typeValeur)
|
||||
|
||||
exists, err := h.client.LienObjetEmplacement.Query().
|
||||
Where(
|
||||
lienobjetemplacement.ObjetID(objetID),
|
||||
lienobjetemplacement.EmplacementID(emplacementID),
|
||||
lienobjetemplacement.TypeEQ(typeValeur),
|
||||
).
|
||||
Exist(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de verifier le lien"})
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
c.JSON(http.StatusConflict, gin.H{"erreur": "lien deja existant"})
|
||||
return
|
||||
}
|
||||
|
||||
created, err := create.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer le lien"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, created)
|
||||
}
|
||||
|
||||
// @Summary Supprimer un lien objet/emplacement
|
||||
// @Tags LiensEmplacements
|
||||
// @Param id path string true "ID lien"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /liens_emplacements/{id} [delete]
|
||||
func (h *Handler) DeleteLienEmplacement(c *gin.Context) {
|
||||
lienID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.client.LienObjetEmplacement.DeleteOneID(lienID).Exec(c.Request.Context()); err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "lien introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer le lien"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// @Summary Mettre a jour un lien objet/emplacement
|
||||
// @Tags LiensEmplacements
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID lien"
|
||||
// @Param body body lienObjetEmplacementUpdateRequest true "Mise a jour"
|
||||
// @Success 200 {object} ent.LienObjetEmplacement
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 409 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /liens_emplacements/{id} [put]
|
||||
func (h *Handler) UpdateLienEmplacement(c *gin.Context) {
|
||||
lienID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req lienObjetEmplacementUpdateRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
|
||||
existant, err := h.client.LienObjetEmplacement.Get(c.Request.Context(), lienID)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "lien introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger le lien"})
|
||||
return
|
||||
}
|
||||
|
||||
nouveauEmplacementID := existant.EmplacementID
|
||||
if req.EmplacementID != nil && *req.EmplacementID != "" {
|
||||
parsed, err := uuid.Parse(*req.EmplacementID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "emplacement_id invalide"})
|
||||
return
|
||||
}
|
||||
if _, err := h.client.Emplacement.Get(c.Request.Context(), parsed); err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "emplacement introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger l'emplacement"})
|
||||
return
|
||||
}
|
||||
nouveauEmplacementID = parsed
|
||||
}
|
||||
|
||||
nouveauType := existant.Type
|
||||
if req.Type != nil && *req.Type != "" {
|
||||
parsed, ok := parseLienType(*req.Type)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "type invalide"})
|
||||
return
|
||||
}
|
||||
nouveauType = parsed
|
||||
}
|
||||
|
||||
dupe, err := h.client.LienObjetEmplacement.Query().
|
||||
Where(
|
||||
lienobjetemplacement.ObjetID(existant.ObjetID),
|
||||
lienobjetemplacement.EmplacementID(nouveauEmplacementID),
|
||||
lienobjetemplacement.TypeEQ(nouveauType),
|
||||
lienobjetemplacement.IDNEQ(lienID),
|
||||
).
|
||||
Exist(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de verifier le lien"})
|
||||
return
|
||||
}
|
||||
if dupe {
|
||||
c.JSON(http.StatusConflict, gin.H{"erreur": "lien deja existant"})
|
||||
return
|
||||
}
|
||||
|
||||
updated, err := h.client.LienObjetEmplacement.UpdateOneID(lienID).
|
||||
SetEmplacementID(nouveauEmplacementID).
|
||||
SetType(nouveauType).
|
||||
Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de mettre a jour le lien"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
|
||||
func parseLienType(value string) (lienobjetemplacement.Type, bool) {
|
||||
switch value {
|
||||
case "stocke":
|
||||
return lienobjetemplacement.TypeStocke, true
|
||||
case "utilise_dans":
|
||||
return lienobjetemplacement.TypeUtiliseDans, true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
267
backend/internal/handlers/objets.go
Normal file
267
backend/internal/handlers/objets.go
Normal file
@@ -0,0 +1,267 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/objet"
|
||||
)
|
||||
|
||||
type objetRequest struct {
|
||||
Nom *string `json:"nom"`
|
||||
Description *string `json:"description"`
|
||||
Quantite *int `json:"quantite"`
|
||||
PrixAchat *float64 `json:"prix_achat"`
|
||||
DateAchat *string `json:"date_achat"`
|
||||
Boutique *string `json:"boutique"`
|
||||
NumeroSerie *string `json:"numero_serie"`
|
||||
NumeroModele *string `json:"numero_modele"`
|
||||
Fabricant *string `json:"fabricant"`
|
||||
Statut *string `json:"statut"`
|
||||
Caracteristiques map[string]any `json:"caracteristiques"`
|
||||
}
|
||||
|
||||
// @Summary Lister les objets
|
||||
// @Tags Objets
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Param statut query string false "Statut"
|
||||
// @Param nom query string false "Recherche nom"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets [get]
|
||||
func (h *Handler) ListObjets(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.Objet.Query()
|
||||
|
||||
if statutValue := c.Query("statut"); statutValue != "" {
|
||||
statut, ok := parseStatut(statutValue)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "statut invalide"})
|
||||
return
|
||||
}
|
||||
query = query.Where(objet.StatutEQ(statut))
|
||||
}
|
||||
if nomValue := c.Query("nom"); nomValue != "" {
|
||||
query = query.Where(objet.NomContainsFold(nomValue))
|
||||
}
|
||||
total, err := query.Count(ctx)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les objets"})
|
||||
return
|
||||
}
|
||||
|
||||
objets, err := query.
|
||||
Order(ent.Desc(objet.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les objets"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, objets, total, page, limit)
|
||||
}
|
||||
|
||||
// @Summary Creer un objet
|
||||
// @Tags Objets
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body objetRequest true "Objet a creer"
|
||||
// @Success 201 {object} ent.Objet
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets [post]
|
||||
func (h *Handler) CreateObjet(c *gin.Context) {
|
||||
var req objetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
if req.Nom == nil || *req.Nom == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "le champ nom est obligatoire"})
|
||||
return
|
||||
}
|
||||
|
||||
create := h.client.Objet.Create().SetNom(*req.Nom)
|
||||
|
||||
if req.Description != nil {
|
||||
create.SetNillableDescription(req.Description)
|
||||
}
|
||||
if req.Quantite != nil {
|
||||
create.SetQuantite(*req.Quantite)
|
||||
}
|
||||
if req.PrixAchat != nil {
|
||||
create.SetNillablePrixAchat(req.PrixAchat)
|
||||
}
|
||||
if req.DateAchat != nil {
|
||||
if parsed, err := parseDateTime(*req.DateAchat); err == nil {
|
||||
create.SetNillableDateAchat(&parsed)
|
||||
}
|
||||
}
|
||||
if req.Boutique != nil {
|
||||
create.SetNillableBoutique(req.Boutique)
|
||||
}
|
||||
if req.NumeroSerie != nil {
|
||||
create.SetNillableNumeroSerie(req.NumeroSerie)
|
||||
}
|
||||
if req.NumeroModele != nil {
|
||||
create.SetNillableNumeroModele(req.NumeroModele)
|
||||
}
|
||||
if req.Fabricant != nil {
|
||||
create.SetNillableFabricant(req.Fabricant)
|
||||
}
|
||||
if req.Statut != nil {
|
||||
parsed, ok := parseStatut(*req.Statut)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "statut invalide"})
|
||||
return
|
||||
}
|
||||
create.SetStatut(parsed)
|
||||
}
|
||||
if req.Caracteristiques != nil {
|
||||
create.SetCaracteristiques(req.Caracteristiques)
|
||||
}
|
||||
|
||||
created, err := create.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer l'objet"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, created)
|
||||
}
|
||||
|
||||
// @Summary Recuperer un objet
|
||||
// @Tags Objets
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Success 200 {object} ent.Objet
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id} [get]
|
||||
func (h *Handler) GetObjet(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.client.Objet.Get(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "objet introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger l'objet"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, item)
|
||||
}
|
||||
|
||||
// @Summary Mettre a jour un objet
|
||||
// @Tags Objets
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param body body objetRequest true "Objet a mettre a jour"
|
||||
// @Success 200 {object} ent.Objet
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id} [put]
|
||||
func (h *Handler) UpdateObjet(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
var req objetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "donnees invalides"})
|
||||
return
|
||||
}
|
||||
|
||||
update := h.client.Objet.UpdateOneID(id)
|
||||
|
||||
if req.Nom != nil {
|
||||
update.SetNom(*req.Nom)
|
||||
}
|
||||
if req.Description != nil {
|
||||
update.SetNillableDescription(req.Description)
|
||||
}
|
||||
if req.Quantite != nil {
|
||||
update.SetQuantite(*req.Quantite)
|
||||
}
|
||||
if req.PrixAchat != nil {
|
||||
update.SetNillablePrixAchat(req.PrixAchat)
|
||||
}
|
||||
if req.DateAchat != nil {
|
||||
if parsed, err := parseDateTime(*req.DateAchat); err == nil {
|
||||
update.SetNillableDateAchat(&parsed)
|
||||
}
|
||||
}
|
||||
if req.Boutique != nil {
|
||||
update.SetNillableBoutique(req.Boutique)
|
||||
}
|
||||
if req.NumeroSerie != nil {
|
||||
update.SetNillableNumeroSerie(req.NumeroSerie)
|
||||
}
|
||||
if req.NumeroModele != nil {
|
||||
update.SetNillableNumeroModele(req.NumeroModele)
|
||||
}
|
||||
if req.Fabricant != nil {
|
||||
update.SetNillableFabricant(req.Fabricant)
|
||||
}
|
||||
if req.Statut != nil {
|
||||
parsed, ok := parseStatut(*req.Statut)
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "statut invalide"})
|
||||
return
|
||||
}
|
||||
update.SetStatut(parsed)
|
||||
}
|
||||
if req.Caracteristiques != nil {
|
||||
update.SetCaracteristiques(req.Caracteristiques)
|
||||
}
|
||||
|
||||
updated, err := update.Save(c.Request.Context())
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "objet introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de mettre a jour l'objet"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
|
||||
// @Summary Supprimer un objet
|
||||
// @Tags Objets
|
||||
// @Param id path string true "ID objet"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id} [delete]
|
||||
func (h *Handler) DeleteObjet(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.client.Objet.DeleteOneID(id).Exec(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer l'objet"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// helper for compile reference
|
||||
var _ = ent.IsNotFound
|
||||
25
backend/internal/handlers/pagination.go
Normal file
25
backend/internal/handlers/pagination.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type paginatedResponse struct {
|
||||
Items any `json:"items"`
|
||||
Meta struct {
|
||||
Total int `json:"total"`
|
||||
Page int `json:"page"`
|
||||
Limit int `json:"limit"`
|
||||
} `json:"meta"`
|
||||
}
|
||||
|
||||
func respondPaginated(c *gin.Context, items any, total int, page int, limit int) {
|
||||
var resp paginatedResponse
|
||||
resp.Items = items
|
||||
resp.Meta.Total = total
|
||||
resp.Meta.Page = page
|
||||
resp.Meta.Limit = limit
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
275
backend/internal/handlers/pieces_jointes.go
Normal file
275
backend/internal/handlers/pieces_jointes.go
Normal file
@@ -0,0 +1,275 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent/piecejointe"
|
||||
)
|
||||
|
||||
// UploadPiecesJointes gere l'upload multiple des fichiers d'un objet.
|
||||
// @Summary Uploader des pieces jointes
|
||||
// @Tags PiecesJointes
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param fichiers formData file true "Fichiers (multi)"
|
||||
// @Success 201 {object} map[string]any
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 413 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/pieces_jointes [post]
|
||||
func (h *Handler) UploadPiecesJointes(c *gin.Context) {
|
||||
id, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := h.client.Objet.Get(c.Request.Context(), id); err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "objet introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger l'objet"})
|
||||
return
|
||||
}
|
||||
|
||||
form, err := c.MultipartForm()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "formulaire invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
files := form.File["fichiers"]
|
||||
if len(files) == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "aucun fichier fourni"})
|
||||
return
|
||||
}
|
||||
|
||||
maxBytes := maxUploadBytes()
|
||||
|
||||
hasPrincipale, err := h.client.PieceJointe.Query().
|
||||
Where(
|
||||
piecejointe.ObjetID(id),
|
||||
piecejointe.EstPrincipale(true),
|
||||
).
|
||||
Exist(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de verifier la piece jointe principale"})
|
||||
return
|
||||
}
|
||||
|
||||
baseDir := os.Getenv("ATTACHMENTS_DIR")
|
||||
if baseDir == "" {
|
||||
baseDir = "./data/pieces_jointes"
|
||||
}
|
||||
if err := os.MkdirAll(baseDir, 0o755); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de creer le dossier de stockage"})
|
||||
return
|
||||
}
|
||||
|
||||
var saved []map[string]any
|
||||
for idx, file := range files {
|
||||
ext := strings.ToLower(filepath.Ext(file.Filename))
|
||||
if file.Size > maxBytes {
|
||||
c.JSON(http.StatusRequestEntityTooLarge, gin.H{"erreur": "fichier trop volumineux"})
|
||||
return
|
||||
}
|
||||
|
||||
mime := file.Header.Get("Content-Type")
|
||||
if !isAllowedUpload(mime, ext) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "type de fichier non supporte"})
|
||||
return
|
||||
}
|
||||
|
||||
uuidName := uuid.New().String() + ext
|
||||
path := filepath.Join(baseDir, uuidName)
|
||||
|
||||
if err := c.SaveUploadedFile(file, path); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "echec enregistrement fichier"})
|
||||
return
|
||||
}
|
||||
|
||||
categorie := resolveCategorie(ext, mime)
|
||||
estPrincipale := idx == 0 && !hasPrincipale
|
||||
|
||||
pj, err := h.client.PieceJointe.Create().
|
||||
SetObjetID(id).
|
||||
SetNomFichier(file.Filename).
|
||||
SetChemin(path).
|
||||
SetTypeMime(mime).
|
||||
SetCategorie(piecejointe.Categorie(categorie)).
|
||||
SetEstPrincipale(estPrincipale).
|
||||
Save(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible d'enregistrer la piece jointe"})
|
||||
return
|
||||
}
|
||||
|
||||
saved = append(saved, map[string]any{
|
||||
"id": pj.ID,
|
||||
"nom_fichier": pj.NomFichier,
|
||||
"chemin": pj.Chemin,
|
||||
"type_mime": pj.TypeMime,
|
||||
"categorie": pj.Categorie,
|
||||
"est_principale": pj.EstPrincipale,
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, gin.H{"pieces_jointes": saved})
|
||||
}
|
||||
|
||||
// ListPiecesJointes retourne la liste des pieces jointes d'un objet.
|
||||
// @Summary Lister les pieces jointes
|
||||
// @Tags PiecesJointes
|
||||
// @Produce json
|
||||
// @Param id path string true "ID objet"
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limite"
|
||||
// @Success 200 {object} map[string]any
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /objets/{id}/pieces_jointes [get]
|
||||
func (h *Handler) ListPiecesJointes(c *gin.Context) {
|
||||
objetID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
limit, offset, page := parsePagination(c.Query("page"), c.Query("limit"))
|
||||
query := h.client.PieceJointe.Query().
|
||||
Where(piecejointe.ObjetID(objetID))
|
||||
total, err := query.Count(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de compter les pieces jointes"})
|
||||
return
|
||||
}
|
||||
|
||||
items, err := query.
|
||||
Order(ent.Desc(piecejointe.FieldCreatedAt)).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
All(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de lister les pieces jointes"})
|
||||
return
|
||||
}
|
||||
respondPaginated(c, items, total, page, limit)
|
||||
}
|
||||
|
||||
// DeletePieceJointe supprime une piece jointe et son fichier.
|
||||
// @Summary Supprimer une piece jointe
|
||||
// @Tags PiecesJointes
|
||||
// @Param id path string true "ID piece jointe"
|
||||
// @Success 204 {string} string "No Content"
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /pieces_jointes/{id} [delete]
|
||||
func (h *Handler) DeletePieceJointe(c *gin.Context) {
|
||||
pieceID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.client.PieceJointe.Get(c.Request.Context(), pieceID)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "piece jointe introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger la piece jointe"})
|
||||
return
|
||||
}
|
||||
|
||||
if item.Chemin != "" {
|
||||
if err := os.Remove(item.Chemin); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer le fichier"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := h.client.PieceJointe.DeleteOneID(pieceID).Exec(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de supprimer la piece jointe"})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// SetPieceJointePrincipale marque une piece jointe comme principale.
|
||||
// @Summary Definir la piece jointe principale
|
||||
// @Tags PiecesJointes
|
||||
// @Produce json
|
||||
// @Param id path string true "ID piece jointe"
|
||||
// @Success 200 {object} ent.PieceJointe
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /pieces_jointes/{id}/principale [put]
|
||||
func (h *Handler) SetPieceJointePrincipale(c *gin.Context) {
|
||||
pieceID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"erreur": "identifiant invalide"})
|
||||
return
|
||||
}
|
||||
|
||||
item, err := h.client.PieceJointe.Get(c.Request.Context(), pieceID)
|
||||
if err != nil {
|
||||
if ent.IsNotFound(err) {
|
||||
c.JSON(http.StatusNotFound, gin.H{"erreur": "piece jointe introuvable"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger la piece jointe"})
|
||||
return
|
||||
}
|
||||
|
||||
tx, err := h.client.Tx(c.Request.Context())
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible d'ouvrir la transaction"})
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err = tx.PieceJointe.Update().
|
||||
Where(piecejointe.ObjetID(item.ObjetID)).
|
||||
SetEstPrincipale(false).
|
||||
Save(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de reinitialiser la principale"})
|
||||
_ = tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = tx.PieceJointe.UpdateOneID(pieceID).
|
||||
SetEstPrincipale(true).
|
||||
Save(c.Request.Context()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de definir la principale"})
|
||||
_ = tx.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
if err = tx.Commit(); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de finaliser la transaction"})
|
||||
return
|
||||
}
|
||||
|
||||
updated, err := h.client.PieceJointe.Get(c.Request.Context(), pieceID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"erreur": "impossible de charger la piece jointe"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, updated)
|
||||
}
|
||||
44
backend/internal/handlers/router.go
Normal file
44
backend/internal/handlers/router.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitea.maison43.duckdns.org/gilles/matosbox/internal/data/ent"
|
||||
)
|
||||
|
||||
// RegisterRoutes enregistre les routes v1.
|
||||
func RegisterRoutes(r *gin.Engine, client *ent.Client) {
|
||||
h := &Handler{client: client}
|
||||
|
||||
v1 := r.Group("/v1")
|
||||
{
|
||||
v1.GET("/objets", h.ListObjets)
|
||||
v1.POST("/objets", h.CreateObjet)
|
||||
v1.GET("/objets/:id", h.GetObjet)
|
||||
v1.PUT("/objets/:id", h.UpdateObjet)
|
||||
v1.DELETE("/objets/:id", h.DeleteObjet)
|
||||
v1.POST("/objets/:id/pieces_jointes", h.UploadPiecesJointes)
|
||||
v1.GET("/objets/:id/pieces_jointes", h.ListPiecesJointes)
|
||||
v1.DELETE("/pieces_jointes/:id", h.DeletePieceJointe)
|
||||
v1.PUT("/pieces_jointes/:id/principale", h.SetPieceJointePrincipale)
|
||||
v1.GET("/objets/:id/champs_personnalises", h.ListChampsPersonnalises)
|
||||
v1.POST("/objets/:id/champs_personnalises", h.CreateChampPersonnalise)
|
||||
v1.PUT("/champs_personnalises/:id", h.UpdateChampPersonnalise)
|
||||
v1.DELETE("/champs_personnalises/:id", h.DeleteChampPersonnalise)
|
||||
v1.GET("/objets/:id/liens_emplacements", h.ListLiensEmplacements)
|
||||
v1.POST("/objets/:id/liens_emplacements", h.CreateLienEmplacement)
|
||||
v1.PUT("/liens_emplacements/:id", h.UpdateLienEmplacement)
|
||||
v1.DELETE("/liens_emplacements/:id", h.DeleteLienEmplacement)
|
||||
|
||||
v1.GET("/categories", h.ListCategories)
|
||||
v1.POST("/categories", h.CreateCategorie)
|
||||
v1.GET("/categories/:id", h.GetCategorie)
|
||||
v1.PUT("/categories/:id", h.UpdateCategorie)
|
||||
v1.DELETE("/categories/:id", h.DeleteCategorie)
|
||||
|
||||
v1.GET("/emplacements", h.ListEmplacements)
|
||||
v1.POST("/emplacements", h.CreateEmplacement)
|
||||
v1.GET("/emplacements/:id", h.GetEmplacement)
|
||||
v1.PUT("/emplacements/:id", h.UpdateEmplacement)
|
||||
v1.DELETE("/emplacements/:id", h.DeleteEmplacement)
|
||||
}
|
||||
}
|
||||
14
backend/scripts/gen_swagger.sh
Normal file
14
backend/scripts/gen_swagger.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
SWAG_BIN="${SWAG_BIN:-/tmp/go/bin/swag}"
|
||||
if [ ! -x "${SWAG_BIN}" ]; then
|
||||
echo "swag introuvable: ${SWAG_BIN}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${ROOT_DIR}"
|
||||
"${SWAG_BIN}" init -g cmd/app/main.go -o docs
|
||||
12
doc_dev/08_etape3_migrations.md
Normal file
12
doc_dev/08_etape3_migrations.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Etape 3 - Migrations initiales
|
||||
|
||||
## Objectif
|
||||
Ajouter une migration SQL initiale pour SQLite selon les schemas Ent.
|
||||
|
||||
## Fichiers ajoutes
|
||||
- `migrations/0001_init.sql`
|
||||
|
||||
## Notes
|
||||
- Ent generate non execute (commande `go` indisponible dans l'environnement).
|
||||
- A relancer une fois Go installe :
|
||||
`go run -mod=mod entgo.io/ent/cmd/ent generate ./internal/data/ent/schema --target ./internal/data/ent`
|
||||
17
doc_dev/09_etape4_handlers.md
Normal file
17
doc_dev/09_etape4_handlers.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Etape 4 - Handlers CRUD (base)
|
||||
|
||||
## Objectif
|
||||
Ajouter les handlers CRUD pour Objets, Categories, Emplacements.
|
||||
|
||||
## Fichiers ajoutes
|
||||
- `backend/internal/handlers/handler.go`
|
||||
- `backend/internal/handlers/router.go`
|
||||
- `backend/internal/handlers/helpers.go`
|
||||
- `backend/internal/handlers/objets.go`
|
||||
- `backend/internal/handlers/categories.go`
|
||||
- `backend/internal/handlers/emplacements.go`
|
||||
|
||||
## Notes
|
||||
- Routes REST sous `/v1`.
|
||||
- Validation minimale (nom obligatoire, UUID).
|
||||
- Parsing des dates au format RFC3339.
|
||||
18
doc_dev/10_etape5_upload.md
Normal file
18
doc_dev/10_etape5_upload.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Etape 5 - Upload pieces jointes
|
||||
|
||||
## Objectif
|
||||
Ajouter l'endpoint d'upload multiple pour les pieces jointes des objets.
|
||||
|
||||
## Endpoint
|
||||
- `POST /v1/objets/:id/pieces_jointes`
|
||||
- Champ multipart : `fichiers`
|
||||
|
||||
## Comportement
|
||||
- Verifie l'existence de l'objet.
|
||||
- Enregistre les fichiers dans `ATTACHMENTS_DIR` (defaut `./data/pieces_jointes`).
|
||||
- Cree les entrees `PieceJointe` associees.
|
||||
- Retourne la liste des pieces jointes creees.
|
||||
|
||||
## Notes
|
||||
- Categorie deduite par extension/MIME.
|
||||
- Premiere piece jointe marquee comme principale.
|
||||
14
doc_dev/11_etape3_ent_gen.md
Normal file
14
doc_dev/11_etape3_ent_gen.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Etape 3 - Generation Ent
|
||||
|
||||
## Objectif
|
||||
Generer le code Ent a partir des schemas.
|
||||
|
||||
## Commande utilisee
|
||||
```
|
||||
env GOPATH=/tmp/go GOMODCACHE=/tmp/go/pkg/mod GOCACHE=/tmp/go/cache go run -mod=mod entgo.io/ent/cmd/ent generate ./internal/data/ent/schema --target ./internal/data/ent
|
||||
```
|
||||
|
||||
## Notes
|
||||
- Mise a jour de Ent vers v0.14.5 pour compatibilite.
|
||||
- Ajout d'un `doc.go` pour initialiser le package cible.
|
||||
- Generation reussie apres correction des edges obligatoires.
|
||||
12
doc_dev/12_etape5_pieces_jointes_crud.md
Normal file
12
doc_dev/12_etape5_pieces_jointes_crud.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Etape 5 (suite) - Pieces jointes CRUD
|
||||
|
||||
## Objectif
|
||||
Ajouter des endpoints de lecture et suppression des pieces jointes.
|
||||
|
||||
## Endpoints
|
||||
- `GET /v1/objets/:id/pieces_jointes` : liste des pieces jointes d'un objet.
|
||||
- `DELETE /v1/pieces_jointes/:id` : suppression d'une piece jointe + fichier.
|
||||
|
||||
## Comportement
|
||||
- Retourne 404 si la piece jointe n'existe pas.
|
||||
- Le fichier est supprime du disque si present.
|
||||
14
doc_dev/13_etape6_upload_validations.md
Normal file
14
doc_dev/13_etape6_upload_validations.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Etape 6 - Validations upload
|
||||
|
||||
## Objectif
|
||||
Renforcer la validation des pieces jointes.
|
||||
|
||||
## Ajouts
|
||||
- Taille max par fichier via `MAX_UPLOAD_MB` (defaut 50).
|
||||
- Types acceptes : images, PDF, Markdown.
|
||||
- Refus avec code 413 si taille depassee.
|
||||
- Refus avec code 400 si type non supporte.
|
||||
|
||||
## Comportement principale
|
||||
- Une seule piece jointe principale par objet.
|
||||
- La premiere piece upload est principale uniquement si aucune n'existe deja.
|
||||
15
doc_dev/14_etape7_champs_liens.md
Normal file
15
doc_dev/14_etape7_champs_liens.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Etape 7 - Champs personnalises et liens emplacements
|
||||
|
||||
## Objectif
|
||||
Ajouter les endpoints CRUD pour les champs personnalises et les liens objet/emplacement.
|
||||
|
||||
## Champs personnalises
|
||||
- `GET /v1/objets/:id/champs_personnalises`
|
||||
- `POST /v1/objets/:id/champs_personnalises`
|
||||
- `PUT /v1/champs_personnalises/:id`
|
||||
- `DELETE /v1/champs_personnalises/:id`
|
||||
|
||||
## Liens objet/emplacement
|
||||
- `GET /v1/objets/:id/liens_emplacements`
|
||||
- `POST /v1/objets/:id/liens_emplacements`
|
||||
- `DELETE /v1/liens_emplacements/:id`
|
||||
15
doc_dev/15_etape8_principale_dedup_tests.md
Normal file
15
doc_dev/15_etape8_principale_dedup_tests.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Etape 8 - Principale, dedup, tests
|
||||
|
||||
## Piece jointe principale
|
||||
- `PUT /v1/pieces_jointes/:id/principale`
|
||||
- Assure qu'une seule piece jointe est principale par objet (transaction).
|
||||
|
||||
## Dedup liens objet/emplacement
|
||||
- Refus si lien identique (objet, emplacement, type) existe deja.
|
||||
- Retour 409 avec message explicite.
|
||||
|
||||
## Tests
|
||||
- Ajout de tests unitaires simples pour :
|
||||
- types d'upload autorises
|
||||
- taille max par fichier
|
||||
- parsing type_champ et type lien
|
||||
11
doc_dev/16_etape9_pagination_liens.md
Normal file
11
doc_dev/16_etape9_pagination_liens.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Etape 9 - Pagination et liens
|
||||
|
||||
## Pagination
|
||||
- Ajout de `page` et `limit` sur les listes : objets, categories, emplacements,
|
||||
pieces jointes, champs personnalises, liens.
|
||||
- Defaut : 50 elements, max 200.
|
||||
|
||||
## Liens objet/emplacement
|
||||
- Verification d'existence de l'emplacement avant creation.
|
||||
- Endpoint `PUT /v1/liens_emplacements/:id` pour modifier le type.
|
||||
- Deduplication maintenue sur (objet, emplacement, type).
|
||||
11
doc_dev/17_etape10_liens_pagination_meta.md
Normal file
11
doc_dev/17_etape10_liens_pagination_meta.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Etape 10 - Liens + pagination avec meta
|
||||
|
||||
## Liens objet/emplacement
|
||||
- `PUT /v1/liens_emplacements/:id` accepte `emplacement_id` et `type`.
|
||||
- Verification de l'existence de l'emplacement avant mise a jour.
|
||||
- Deduplication maintenue (objet, emplacement, type).
|
||||
|
||||
## Pagination avec meta
|
||||
- Les listes renvoient maintenant :
|
||||
- `items`
|
||||
- `meta.total`, `meta.page`, `meta.limit`
|
||||
14
doc_dev/18_etape11_swagger.md
Normal file
14
doc_dev/18_etape11_swagger.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Etape 11 - Swagger
|
||||
|
||||
## Objectif
|
||||
Ajouter la documentation Swagger via Swaggo.
|
||||
|
||||
## Ajouts
|
||||
- Route Swagger : `GET /swagger/*any`.
|
||||
- Commentaires Swaggo dans `cmd/app/main.go`.
|
||||
- Generation des fichiers : `backend/docs/swagger.json` et `backend/docs/swagger.yaml`.
|
||||
|
||||
## Commande de generation
|
||||
```
|
||||
/tmp/go/bin/swag init -g cmd/app/main.go -o docs
|
||||
```
|
||||
14
doc_dev/19_etape12_swagger_auto.md
Normal file
14
doc_dev/19_etape12_swagger_auto.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Etape 12 - Swagger auto
|
||||
|
||||
## Objectif
|
||||
Documenter les endpoints avec Swaggo et fournir une commande d'auto-generation.
|
||||
|
||||
## Annotations
|
||||
- Ajout des annotations Swagger sur les handlers principaux.
|
||||
|
||||
## Script
|
||||
- `backend/scripts/gen_swagger.sh`
|
||||
- Usage :
|
||||
```
|
||||
bash backend/scripts/gen_swagger.sh
|
||||
```
|
||||
6
doc_dev/20_etape13_tooling_env.md
Normal file
6
doc_dev/20_etape13_tooling_env.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Etape 13 - Tooling et env
|
||||
|
||||
## Ajouts
|
||||
- `Taskfile.yml` + `backend/Taskfile.yml` pour run/test/ent/swagger.
|
||||
- `.env.example` pour variables backend.
|
||||
- `docker-compose.yml` (backend + postgres optionnel).
|
||||
15
doc_dev/21_etape14_frontend.md
Normal file
15
doc_dev/21_etape14_frontend.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Etape 14 - Frontend (squelette)
|
||||
|
||||
## Structure
|
||||
- Nuxt 3 minimal avec pages :
|
||||
- `/` (accueil)
|
||||
- `/objets`
|
||||
- `/objets/[id]`
|
||||
- `/emplacements`
|
||||
|
||||
## Fichiers
|
||||
- `frontend/package.json`
|
||||
- `frontend/nuxt.config.ts`
|
||||
- `frontend/app.vue`
|
||||
- `frontend/pages/*`
|
||||
- `frontend/assets/css/main.css`
|
||||
34
docker-compose.yml
Normal file
34
docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: golang:1.24
|
||||
working_dir: /app/backend
|
||||
command: bash -lc "go run ./cmd/app"
|
||||
environment:
|
||||
PORT: 8080
|
||||
DATABASE_DRIVER: sqlite3
|
||||
DATABASE_URL: file:./data/matosbox.db?_fk=1
|
||||
ATTACHMENTS_DIR: ./data/pieces_jointes
|
||||
BACKUP_DIR: ./data/backups
|
||||
MAX_UPLOAD_MB: 50
|
||||
volumes:
|
||||
- ./:/app
|
||||
- ./data:/app/data
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
postgres:
|
||||
profiles: ["postgres"]
|
||||
image: postgres:16
|
||||
environment:
|
||||
POSTGRES_DB: matosbox
|
||||
POSTGRES_USER: matosbox
|
||||
POSTGRES_PASSWORD: matosbox
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
3
frontend/app.vue
Normal file
3
frontend/app.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<NuxtPage />
|
||||
</template>
|
||||
45
frontend/assets/css/main.css
Normal file
45
frontend/assets/css/main.css
Normal file
@@ -0,0 +1,45 @@
|
||||
:root {
|
||||
--bg: #f5f1e8;
|
||||
--text: #1f1b16;
|
||||
--accent: #c46b2d;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Space Grotesk", system-ui, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.hero {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid #e3d8c5;
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
background: #fffaf2;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user