Add dynamic admin panel for managing entities (#108)
This commit is contained in:
parent
60009df0bf
commit
1a6874fd82
47 changed files with 2173 additions and 320 deletions
|
|
@ -53,6 +53,20 @@ func (uc *UserCreate) SetNillableVerified(b *bool) *UserCreate {
|
|||
return uc
|
||||
}
|
||||
|
||||
// SetAdmin sets the "admin" field.
|
||||
func (uc *UserCreate) SetAdmin(b bool) *UserCreate {
|
||||
uc.mutation.SetAdmin(b)
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetNillableAdmin sets the "admin" field if the given value is not nil.
|
||||
func (uc *UserCreate) SetNillableAdmin(b *bool) *UserCreate {
|
||||
if b != nil {
|
||||
uc.SetAdmin(*b)
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate {
|
||||
uc.mutation.SetCreatedAt(t)
|
||||
|
|
@ -123,6 +137,10 @@ func (uc *UserCreate) defaults() error {
|
|||
v := user.DefaultVerified
|
||||
uc.mutation.SetVerified(v)
|
||||
}
|
||||
if _, ok := uc.mutation.Admin(); !ok {
|
||||
v := user.DefaultAdmin
|
||||
uc.mutation.SetAdmin(v)
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
if user.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized user.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
|
|
@ -162,6 +180,9 @@ func (uc *UserCreate) check() error {
|
|||
if _, ok := uc.mutation.Verified(); !ok {
|
||||
return &ValidationError{Name: "verified", err: errors.New(`ent: missing required field "User.verified"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.Admin(); !ok {
|
||||
return &ValidationError{Name: "admin", err: errors.New(`ent: missing required field "User.admin"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
|
||||
}
|
||||
|
|
@ -207,6 +228,10 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
|||
_spec.SetField(user.FieldVerified, field.TypeBool, value)
|
||||
_node.Verified = value
|
||||
}
|
||||
if value, ok := uc.mutation.Admin(); ok {
|
||||
_spec.SetField(user.FieldAdmin, field.TypeBool, value)
|
||||
_node.Admin = value
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue