fix: some api bug
This commit is contained in:
@@ -21,12 +21,6 @@ type WalletCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_c *WalletCreate) SetUserID(v int64) *WalletCreate {
|
||||
_c.mutation.SetUserID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetBalance sets the "balance" field.
|
||||
func (_c *WalletCreate) SetBalance(v decimal.Decimal) *WalletCreate {
|
||||
_c.mutation.SetBalance(v)
|
||||
@@ -75,6 +69,20 @@ func (_c *WalletCreate) SetUpdatedAt(v time.Time) *WalletCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *WalletCreate) SetNillableUpdatedAt(v *time.Time) *WalletCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *WalletCreate) SetID(v int64) *WalletCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Mutation returns the WalletMutation object of the builder.
|
||||
func (_c *WalletCreate) Mutation() *WalletMutation {
|
||||
return _c.mutation
|
||||
@@ -122,13 +130,14 @@ func (_c *WalletCreate) defaults() {
|
||||
v := wallet.DefaultVersion
|
||||
_c.mutation.SetVersion(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := wallet.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *WalletCreate) check() error {
|
||||
if _, ok := _c.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New(`models: missing required field "Wallet.user_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Balance(); !ok {
|
||||
return &ValidationError{Name: "balance", err: errors.New(`models: missing required field "Wallet.balance"`)}
|
||||
}
|
||||
@@ -155,8 +164,10 @@ func (_c *WalletCreate) sqlSave(ctx context.Context) (*Wallet, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
if _spec.ID.Value != _node.ID {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int64(id)
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
@@ -165,11 +176,11 @@ func (_c *WalletCreate) sqlSave(ctx context.Context) (*Wallet, error) {
|
||||
func (_c *WalletCreate) createSpec() (*Wallet, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Wallet{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(wallet.Table, sqlgraph.NewFieldSpec(wallet.FieldID, field.TypeInt))
|
||||
_spec = sqlgraph.NewCreateSpec(wallet.Table, sqlgraph.NewFieldSpec(wallet.FieldID, field.TypeInt64))
|
||||
)
|
||||
if value, ok := _c.mutation.UserID(); ok {
|
||||
_spec.SetField(wallet.FieldUserID, field.TypeInt64, value)
|
||||
_node.UserID = value
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := _c.mutation.Balance(); ok {
|
||||
_spec.SetField(wallet.FieldBalance, field.TypeOther, value)
|
||||
@@ -235,9 +246,9 @@ func (_c *WalletCreateBulk) Save(ctx context.Context) ([]*Wallet, error) {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
nodes[i].ID = int64(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
|
||||
Reference in New Issue
Block a user