Add dynamic admin panel for managing entities (#108)

This commit is contained in:
Mike Stefanello 2025-04-22 08:26:35 -04:00 committed by GitHub
parent 60009df0bf
commit 1a6874fd82
47 changed files with 2173 additions and 320 deletions

View file

@ -29,16 +29,30 @@ func (ptu *PasswordTokenUpdate) Where(ps ...predicate.PasswordToken) *PasswordTo
return ptu
}
// SetHash sets the "hash" field.
func (ptu *PasswordTokenUpdate) SetHash(s string) *PasswordTokenUpdate {
ptu.mutation.SetHash(s)
// SetToken sets the "token" field.
func (ptu *PasswordTokenUpdate) SetToken(s string) *PasswordTokenUpdate {
ptu.mutation.SetToken(s)
return ptu
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (ptu *PasswordTokenUpdate) SetNillableHash(s *string) *PasswordTokenUpdate {
// SetNillableToken sets the "token" field if the given value is not nil.
func (ptu *PasswordTokenUpdate) SetNillableToken(s *string) *PasswordTokenUpdate {
if s != nil {
ptu.SetHash(*s)
ptu.SetToken(*s)
}
return ptu
}
// SetUserID sets the "user_id" field.
func (ptu *PasswordTokenUpdate) SetUserID(i int) *PasswordTokenUpdate {
ptu.mutation.SetUserID(i)
return ptu
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (ptu *PasswordTokenUpdate) SetNillableUserID(i *int) *PasswordTokenUpdate {
if i != nil {
ptu.SetUserID(*i)
}
return ptu
}
@ -57,12 +71,6 @@ func (ptu *PasswordTokenUpdate) SetNillableCreatedAt(t *time.Time) *PasswordToke
return ptu
}
// SetUserID sets the "user" edge to the User entity by ID.
func (ptu *PasswordTokenUpdate) SetUserID(id int) *PasswordTokenUpdate {
ptu.mutation.SetUserID(id)
return ptu
}
// SetUser sets the "user" edge to the User entity.
func (ptu *PasswordTokenUpdate) SetUser(u *User) *PasswordTokenUpdate {
return ptu.SetUserID(u.ID)
@ -108,9 +116,9 @@ func (ptu *PasswordTokenUpdate) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (ptu *PasswordTokenUpdate) check() error {
if v, ok := ptu.mutation.Hash(); ok {
if err := passwordtoken.HashValidator(v); err != nil {
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.hash": %w`, err)}
if v, ok := ptu.mutation.Token(); ok {
if err := passwordtoken.TokenValidator(v); err != nil {
return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.token": %w`, err)}
}
}
if ptu.mutation.UserCleared() && len(ptu.mutation.UserIDs()) > 0 {
@ -131,8 +139,8 @@ func (ptu *PasswordTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
}
}
}
if value, ok := ptu.mutation.Hash(); ok {
_spec.SetField(passwordtoken.FieldHash, field.TypeString, value)
if value, ok := ptu.mutation.Token(); ok {
_spec.SetField(passwordtoken.FieldToken, field.TypeString, value)
}
if value, ok := ptu.mutation.CreatedAt(); ok {
_spec.SetField(passwordtoken.FieldCreatedAt, field.TypeTime, value)
@ -186,16 +194,30 @@ type PasswordTokenUpdateOne struct {
mutation *PasswordTokenMutation
}
// SetHash sets the "hash" field.
func (ptuo *PasswordTokenUpdateOne) SetHash(s string) *PasswordTokenUpdateOne {
ptuo.mutation.SetHash(s)
// SetToken sets the "token" field.
func (ptuo *PasswordTokenUpdateOne) SetToken(s string) *PasswordTokenUpdateOne {
ptuo.mutation.SetToken(s)
return ptuo
}
// SetNillableHash sets the "hash" field if the given value is not nil.
func (ptuo *PasswordTokenUpdateOne) SetNillableHash(s *string) *PasswordTokenUpdateOne {
// SetNillableToken sets the "token" field if the given value is not nil.
func (ptuo *PasswordTokenUpdateOne) SetNillableToken(s *string) *PasswordTokenUpdateOne {
if s != nil {
ptuo.SetHash(*s)
ptuo.SetToken(*s)
}
return ptuo
}
// SetUserID sets the "user_id" field.
func (ptuo *PasswordTokenUpdateOne) SetUserID(i int) *PasswordTokenUpdateOne {
ptuo.mutation.SetUserID(i)
return ptuo
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (ptuo *PasswordTokenUpdateOne) SetNillableUserID(i *int) *PasswordTokenUpdateOne {
if i != nil {
ptuo.SetUserID(*i)
}
return ptuo
}
@ -214,12 +236,6 @@ func (ptuo *PasswordTokenUpdateOne) SetNillableCreatedAt(t *time.Time) *Password
return ptuo
}
// SetUserID sets the "user" edge to the User entity by ID.
func (ptuo *PasswordTokenUpdateOne) SetUserID(id int) *PasswordTokenUpdateOne {
ptuo.mutation.SetUserID(id)
return ptuo
}
// SetUser sets the "user" edge to the User entity.
func (ptuo *PasswordTokenUpdateOne) SetUser(u *User) *PasswordTokenUpdateOne {
return ptuo.SetUserID(u.ID)
@ -278,9 +294,9 @@ func (ptuo *PasswordTokenUpdateOne) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (ptuo *PasswordTokenUpdateOne) check() error {
if v, ok := ptuo.mutation.Hash(); ok {
if err := passwordtoken.HashValidator(v); err != nil {
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.hash": %w`, err)}
if v, ok := ptuo.mutation.Token(); ok {
if err := passwordtoken.TokenValidator(v); err != nil {
return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.token": %w`, err)}
}
}
if ptuo.mutation.UserCleared() && len(ptuo.mutation.UserIDs()) > 0 {
@ -318,8 +334,8 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
}
}
}
if value, ok := ptuo.mutation.Hash(); ok {
_spec.SetField(passwordtoken.FieldHash, field.TypeString, value)
if value, ok := ptuo.mutation.Token(); ok {
_spec.SetField(passwordtoken.FieldToken, field.TypeString, value)
}
if value, ok := ptuo.mutation.CreatedAt(); ok {
_spec.SetField(passwordtoken.FieldCreatedAt, field.TypeTime, value)