mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
implement HasID interface for entities
This commit is contained in:
parent
6dca8ffdda
commit
50e6d353dc
2 changed files with 63 additions and 0 deletions
45
backend/ent/has_id.go
Normal file
45
backend/ent/has_id.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
func (a *Attachment) GetID() uuid.UUID {
|
||||
return a.ID
|
||||
}
|
||||
|
||||
func (at *AuthTokens) GetID() uuid.UUID {
|
||||
return at.ID
|
||||
}
|
||||
|
||||
func (d *Document) GetID() uuid.UUID {
|
||||
return d.ID
|
||||
}
|
||||
|
||||
func (dt *DocumentToken) GetID() uuid.UUID {
|
||||
return dt.ID
|
||||
}
|
||||
|
||||
func (gr *Group) GetID() uuid.UUID {
|
||||
return gr.ID
|
||||
}
|
||||
|
||||
func (i *Item) GetID() uuid.UUID {
|
||||
return i.ID
|
||||
}
|
||||
|
||||
func (_if *ItemField) GetID() uuid.UUID {
|
||||
return _if.ID
|
||||
}
|
||||
|
||||
func (l *Label) GetID() uuid.UUID {
|
||||
return l.ID
|
||||
}
|
||||
|
||||
func (l *Location) GetID() uuid.UUID {
|
||||
return l.ID
|
||||
}
|
||||
|
||||
func (u *User) GetID() uuid.UUID {
|
||||
return u.ID
|
||||
}
|
18
backend/ent/schema/templates/has_id.tmpl
Normal file
18
backend/ent/schema/templates/has_id.tmpl
Normal file
|
@ -0,0 +1,18 @@
|
|||
{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}}
|
||||
{{/* gotype: entgo.io/ent/entc/gen.Graph */}}
|
||||
|
||||
{{ define "has_id" }}
|
||||
|
||||
{{/* Add the base header for the generated file */}}
|
||||
{{ $pkg := base $.Config.Package }}
|
||||
{{ template "header" $ }}
|
||||
import "github.com/google/uuid"
|
||||
{{/* Loop over all nodes and implement the "HasID" interface */}}
|
||||
{{ range $n := $.Nodes }}
|
||||
{{ $receiver := $n.Receiver }}
|
||||
func ({{ $receiver }} *{{ $n.Name }}) GetID() uuid.UUID {
|
||||
return {{ $receiver }}.ID
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue