forked from mirrors/homebox
feat: QR Codes (#226)
* code gen updates * qrcode support * remove opacity on toast * update item view to use tab-like pages * adjust view for cards * fix old API calls for ioutils * move embed * extract QR code * add docs for QR codes * add QR code
This commit is contained in:
parent
f532b39c46
commit
c19fe94c08
88 changed files with 3151 additions and 6454 deletions
|
@ -172,50 +172,8 @@ func (uc *UserCreate) Mutation() *UserMutation {
|
|||
|
||||
// Save creates the User in the database.
|
||||
func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||
var (
|
||||
err error
|
||||
node *User
|
||||
)
|
||||
uc.defaults()
|
||||
if len(uc.hooks) == 0 {
|
||||
if err = uc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = uc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*UserMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = uc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uc.mutation = mutation
|
||||
if node, err = uc.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(uc.hooks) - 1; i >= 0; i-- {
|
||||
if uc.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = uc.hooks[i](mut)
|
||||
}
|
||||
v, err := mut.Mutate(ctx, uc.mutation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nv, ok := v.(*User)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v)
|
||||
}
|
||||
node = nv
|
||||
}
|
||||
return node, err
|
||||
return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
|
@ -321,6 +279,9 @@ func (uc *UserCreate) check() error {
|
|||
}
|
||||
|
||||
func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||
if err := uc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := uc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
|
@ -335,6 +296,8 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
uc.mutation.id = &_node.ID
|
||||
uc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue