mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-02 06:43:23 +08:00
991 lines
30 KiB
Go
991 lines
30 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/db/setting"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// SettingCreate is the builder for creating a Setting entity.
|
|
type SettingCreate struct {
|
|
config
|
|
mutation *SettingMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetEnableSSO sets the "enable_sso" field.
|
|
func (sc *SettingCreate) SetEnableSSO(b bool) *SettingCreate {
|
|
sc.mutation.SetEnableSSO(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableEnableSSO sets the "enable_sso" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableEnableSSO(b *bool) *SettingCreate {
|
|
if b != nil {
|
|
sc.SetEnableSSO(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetForceTwoFactorAuth sets the "force_two_factor_auth" field.
|
|
func (sc *SettingCreate) SetForceTwoFactorAuth(b bool) *SettingCreate {
|
|
sc.mutation.SetForceTwoFactorAuth(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableForceTwoFactorAuth sets the "force_two_factor_auth" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableForceTwoFactorAuth(b *bool) *SettingCreate {
|
|
if b != nil {
|
|
sc.SetForceTwoFactorAuth(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetDisablePasswordLogin sets the "disable_password_login" field.
|
|
func (sc *SettingCreate) SetDisablePasswordLogin(b bool) *SettingCreate {
|
|
sc.mutation.SetDisablePasswordLogin(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableDisablePasswordLogin sets the "disable_password_login" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableDisablePasswordLogin(b *bool) *SettingCreate {
|
|
if b != nil {
|
|
sc.SetDisablePasswordLogin(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetEnableDingtalkOauth sets the "enable_dingtalk_oauth" field.
|
|
func (sc *SettingCreate) SetEnableDingtalkOauth(b bool) *SettingCreate {
|
|
sc.mutation.SetEnableDingtalkOauth(b)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableEnableDingtalkOauth sets the "enable_dingtalk_oauth" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableEnableDingtalkOauth(b *bool) *SettingCreate {
|
|
if b != nil {
|
|
sc.SetEnableDingtalkOauth(*b)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetDingtalkClientID sets the "dingtalk_client_id" field.
|
|
func (sc *SettingCreate) SetDingtalkClientID(s string) *SettingCreate {
|
|
sc.mutation.SetDingtalkClientID(s)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableDingtalkClientID sets the "dingtalk_client_id" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableDingtalkClientID(s *string) *SettingCreate {
|
|
if s != nil {
|
|
sc.SetDingtalkClientID(*s)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetDingtalkClientSecret sets the "dingtalk_client_secret" field.
|
|
func (sc *SettingCreate) SetDingtalkClientSecret(s string) *SettingCreate {
|
|
sc.mutation.SetDingtalkClientSecret(s)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableDingtalkClientSecret sets the "dingtalk_client_secret" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableDingtalkClientSecret(s *string) *SettingCreate {
|
|
if s != nil {
|
|
sc.SetDingtalkClientSecret(*s)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (sc *SettingCreate) SetCreatedAt(t time.Time) *SettingCreate {
|
|
sc.mutation.SetCreatedAt(t)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableCreatedAt(t *time.Time) *SettingCreate {
|
|
if t != nil {
|
|
sc.SetCreatedAt(*t)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (sc *SettingCreate) SetUpdatedAt(t time.Time) *SettingCreate {
|
|
sc.mutation.SetUpdatedAt(t)
|
|
return sc
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (sc *SettingCreate) SetNillableUpdatedAt(t *time.Time) *SettingCreate {
|
|
if t != nil {
|
|
sc.SetUpdatedAt(*t)
|
|
}
|
|
return sc
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (sc *SettingCreate) SetID(u uuid.UUID) *SettingCreate {
|
|
sc.mutation.SetID(u)
|
|
return sc
|
|
}
|
|
|
|
// Mutation returns the SettingMutation object of the builder.
|
|
func (sc *SettingCreate) Mutation() *SettingMutation {
|
|
return sc.mutation
|
|
}
|
|
|
|
// Save creates the Setting in the database.
|
|
func (sc *SettingCreate) Save(ctx context.Context) (*Setting, error) {
|
|
sc.defaults()
|
|
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (sc *SettingCreate) SaveX(ctx context.Context) *Setting {
|
|
v, err := sc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (sc *SettingCreate) Exec(ctx context.Context) error {
|
|
_, err := sc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sc *SettingCreate) ExecX(ctx context.Context) {
|
|
if err := sc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (sc *SettingCreate) defaults() {
|
|
if _, ok := sc.mutation.EnableSSO(); !ok {
|
|
v := setting.DefaultEnableSSO
|
|
sc.mutation.SetEnableSSO(v)
|
|
}
|
|
if _, ok := sc.mutation.ForceTwoFactorAuth(); !ok {
|
|
v := setting.DefaultForceTwoFactorAuth
|
|
sc.mutation.SetForceTwoFactorAuth(v)
|
|
}
|
|
if _, ok := sc.mutation.DisablePasswordLogin(); !ok {
|
|
v := setting.DefaultDisablePasswordLogin
|
|
sc.mutation.SetDisablePasswordLogin(v)
|
|
}
|
|
if _, ok := sc.mutation.EnableDingtalkOauth(); !ok {
|
|
v := setting.DefaultEnableDingtalkOauth
|
|
sc.mutation.SetEnableDingtalkOauth(v)
|
|
}
|
|
if _, ok := sc.mutation.CreatedAt(); !ok {
|
|
v := setting.DefaultCreatedAt()
|
|
sc.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := sc.mutation.UpdatedAt(); !ok {
|
|
v := setting.DefaultUpdatedAt()
|
|
sc.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (sc *SettingCreate) check() error {
|
|
if _, ok := sc.mutation.EnableSSO(); !ok {
|
|
return &ValidationError{Name: "enable_sso", err: errors.New(`db: missing required field "Setting.enable_sso"`)}
|
|
}
|
|
if _, ok := sc.mutation.ForceTwoFactorAuth(); !ok {
|
|
return &ValidationError{Name: "force_two_factor_auth", err: errors.New(`db: missing required field "Setting.force_two_factor_auth"`)}
|
|
}
|
|
if _, ok := sc.mutation.DisablePasswordLogin(); !ok {
|
|
return &ValidationError{Name: "disable_password_login", err: errors.New(`db: missing required field "Setting.disable_password_login"`)}
|
|
}
|
|
if _, ok := sc.mutation.EnableDingtalkOauth(); !ok {
|
|
return &ValidationError{Name: "enable_dingtalk_oauth", err: errors.New(`db: missing required field "Setting.enable_dingtalk_oauth"`)}
|
|
}
|
|
if _, ok := sc.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "Setting.created_at"`)}
|
|
}
|
|
if _, ok := sc.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "Setting.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (sc *SettingCreate) sqlSave(ctx context.Context) (*Setting, error) {
|
|
if err := sc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := sc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
|
_node.ID = *id
|
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
sc.mutation.id = &_node.ID
|
|
sc.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (sc *SettingCreate) createSpec() (*Setting, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Setting{config: sc.config}
|
|
_spec = sqlgraph.NewCreateSpec(setting.Table, sqlgraph.NewFieldSpec(setting.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = sc.conflict
|
|
if id, ok := sc.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := sc.mutation.EnableSSO(); ok {
|
|
_spec.SetField(setting.FieldEnableSSO, field.TypeBool, value)
|
|
_node.EnableSSO = value
|
|
}
|
|
if value, ok := sc.mutation.ForceTwoFactorAuth(); ok {
|
|
_spec.SetField(setting.FieldForceTwoFactorAuth, field.TypeBool, value)
|
|
_node.ForceTwoFactorAuth = value
|
|
}
|
|
if value, ok := sc.mutation.DisablePasswordLogin(); ok {
|
|
_spec.SetField(setting.FieldDisablePasswordLogin, field.TypeBool, value)
|
|
_node.DisablePasswordLogin = value
|
|
}
|
|
if value, ok := sc.mutation.EnableDingtalkOauth(); ok {
|
|
_spec.SetField(setting.FieldEnableDingtalkOauth, field.TypeBool, value)
|
|
_node.EnableDingtalkOauth = value
|
|
}
|
|
if value, ok := sc.mutation.DingtalkClientID(); ok {
|
|
_spec.SetField(setting.FieldDingtalkClientID, field.TypeString, value)
|
|
_node.DingtalkClientID = value
|
|
}
|
|
if value, ok := sc.mutation.DingtalkClientSecret(); ok {
|
|
_spec.SetField(setting.FieldDingtalkClientSecret, field.TypeString, value)
|
|
_node.DingtalkClientSecret = value
|
|
}
|
|
if value, ok := sc.mutation.CreatedAt(); ok {
|
|
_spec.SetField(setting.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := sc.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(setting.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Setting.Create().
|
|
// SetEnableSSO(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.SettingUpsert) {
|
|
// SetEnableSSO(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (sc *SettingCreate) OnConflict(opts ...sql.ConflictOption) *SettingUpsertOne {
|
|
sc.conflict = opts
|
|
return &SettingUpsertOne{
|
|
create: sc,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (sc *SettingCreate) OnConflictColumns(columns ...string) *SettingUpsertOne {
|
|
sc.conflict = append(sc.conflict, sql.ConflictColumns(columns...))
|
|
return &SettingUpsertOne{
|
|
create: sc,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// SettingUpsertOne is the builder for "upsert"-ing
|
|
// one Setting node.
|
|
SettingUpsertOne struct {
|
|
create *SettingCreate
|
|
}
|
|
|
|
// SettingUpsert is the "OnConflict" setter.
|
|
SettingUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetEnableSSO sets the "enable_sso" field.
|
|
func (u *SettingUpsert) SetEnableSSO(v bool) *SettingUpsert {
|
|
u.Set(setting.FieldEnableSSO, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnableSSO sets the "enable_sso" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateEnableSSO() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldEnableSSO)
|
|
return u
|
|
}
|
|
|
|
// SetForceTwoFactorAuth sets the "force_two_factor_auth" field.
|
|
func (u *SettingUpsert) SetForceTwoFactorAuth(v bool) *SettingUpsert {
|
|
u.Set(setting.FieldForceTwoFactorAuth, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateForceTwoFactorAuth sets the "force_two_factor_auth" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateForceTwoFactorAuth() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldForceTwoFactorAuth)
|
|
return u
|
|
}
|
|
|
|
// SetDisablePasswordLogin sets the "disable_password_login" field.
|
|
func (u *SettingUpsert) SetDisablePasswordLogin(v bool) *SettingUpsert {
|
|
u.Set(setting.FieldDisablePasswordLogin, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDisablePasswordLogin sets the "disable_password_login" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateDisablePasswordLogin() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldDisablePasswordLogin)
|
|
return u
|
|
}
|
|
|
|
// SetEnableDingtalkOauth sets the "enable_dingtalk_oauth" field.
|
|
func (u *SettingUpsert) SetEnableDingtalkOauth(v bool) *SettingUpsert {
|
|
u.Set(setting.FieldEnableDingtalkOauth, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEnableDingtalkOauth sets the "enable_dingtalk_oauth" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateEnableDingtalkOauth() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldEnableDingtalkOauth)
|
|
return u
|
|
}
|
|
|
|
// SetDingtalkClientID sets the "dingtalk_client_id" field.
|
|
func (u *SettingUpsert) SetDingtalkClientID(v string) *SettingUpsert {
|
|
u.Set(setting.FieldDingtalkClientID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDingtalkClientID sets the "dingtalk_client_id" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateDingtalkClientID() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldDingtalkClientID)
|
|
return u
|
|
}
|
|
|
|
// ClearDingtalkClientID clears the value of the "dingtalk_client_id" field.
|
|
func (u *SettingUpsert) ClearDingtalkClientID() *SettingUpsert {
|
|
u.SetNull(setting.FieldDingtalkClientID)
|
|
return u
|
|
}
|
|
|
|
// SetDingtalkClientSecret sets the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsert) SetDingtalkClientSecret(v string) *SettingUpsert {
|
|
u.Set(setting.FieldDingtalkClientSecret, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDingtalkClientSecret sets the "dingtalk_client_secret" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateDingtalkClientSecret() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldDingtalkClientSecret)
|
|
return u
|
|
}
|
|
|
|
// ClearDingtalkClientSecret clears the value of the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsert) ClearDingtalkClientSecret() *SettingUpsert {
|
|
u.SetNull(setting.FieldDingtalkClientSecret)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *SettingUpsert) SetCreatedAt(v time.Time) *SettingUpsert {
|
|
u.Set(setting.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateCreatedAt() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *SettingUpsert) SetUpdatedAt(v time.Time) *SettingUpsert {
|
|
u.Set(setting.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *SettingUpsert) UpdateUpdatedAt() *SettingUpsert {
|
|
u.SetExcluded(setting.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(setting.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *SettingUpsertOne) UpdateNewValues() *SettingUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
if _, exists := u.create.mutation.ID(); exists {
|
|
s.SetIgnore(setting.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *SettingUpsertOne) Ignore() *SettingUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *SettingUpsertOne) DoNothing() *SettingUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the SettingCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *SettingUpsertOne) Update(set func(*SettingUpsert)) *SettingUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&SettingUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetEnableSSO sets the "enable_sso" field.
|
|
func (u *SettingUpsertOne) SetEnableSSO(v bool) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetEnableSSO(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnableSSO sets the "enable_sso" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateEnableSSO() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateEnableSSO()
|
|
})
|
|
}
|
|
|
|
// SetForceTwoFactorAuth sets the "force_two_factor_auth" field.
|
|
func (u *SettingUpsertOne) SetForceTwoFactorAuth(v bool) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetForceTwoFactorAuth(v)
|
|
})
|
|
}
|
|
|
|
// UpdateForceTwoFactorAuth sets the "force_two_factor_auth" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateForceTwoFactorAuth() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateForceTwoFactorAuth()
|
|
})
|
|
}
|
|
|
|
// SetDisablePasswordLogin sets the "disable_password_login" field.
|
|
func (u *SettingUpsertOne) SetDisablePasswordLogin(v bool) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDisablePasswordLogin(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDisablePasswordLogin sets the "disable_password_login" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateDisablePasswordLogin() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDisablePasswordLogin()
|
|
})
|
|
}
|
|
|
|
// SetEnableDingtalkOauth sets the "enable_dingtalk_oauth" field.
|
|
func (u *SettingUpsertOne) SetEnableDingtalkOauth(v bool) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetEnableDingtalkOauth(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnableDingtalkOauth sets the "enable_dingtalk_oauth" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateEnableDingtalkOauth() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateEnableDingtalkOauth()
|
|
})
|
|
}
|
|
|
|
// SetDingtalkClientID sets the "dingtalk_client_id" field.
|
|
func (u *SettingUpsertOne) SetDingtalkClientID(v string) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDingtalkClientID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDingtalkClientID sets the "dingtalk_client_id" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateDingtalkClientID() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDingtalkClientID()
|
|
})
|
|
}
|
|
|
|
// ClearDingtalkClientID clears the value of the "dingtalk_client_id" field.
|
|
func (u *SettingUpsertOne) ClearDingtalkClientID() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.ClearDingtalkClientID()
|
|
})
|
|
}
|
|
|
|
// SetDingtalkClientSecret sets the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsertOne) SetDingtalkClientSecret(v string) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDingtalkClientSecret(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDingtalkClientSecret sets the "dingtalk_client_secret" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateDingtalkClientSecret() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDingtalkClientSecret()
|
|
})
|
|
}
|
|
|
|
// ClearDingtalkClientSecret clears the value of the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsertOne) ClearDingtalkClientSecret() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.ClearDingtalkClientSecret()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *SettingUpsertOne) SetCreatedAt(v time.Time) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateCreatedAt() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *SettingUpsertOne) SetUpdatedAt(v time.Time) *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *SettingUpsertOne) UpdateUpdatedAt() *SettingUpsertOne {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *SettingUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for SettingCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *SettingUpsertOne) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
func (u *SettingUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: SettingUpsertOne.ID is not supported by MySQL driver. Use SettingUpsertOne.Exec instead")
|
|
}
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *SettingUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// SettingCreateBulk is the builder for creating many Setting entities in bulk.
|
|
type SettingCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*SettingCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the Setting entities in the database.
|
|
func (scb *SettingCreateBulk) Save(ctx context.Context) ([]*Setting, error) {
|
|
if scb.err != nil {
|
|
return nil, scb.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
|
nodes := make([]*Setting, len(scb.builders))
|
|
mutators := make([]Mutator, len(scb.builders))
|
|
for i := range scb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := scb.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*SettingMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = scb.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (scb *SettingCreateBulk) SaveX(ctx context.Context) []*Setting {
|
|
v, err := scb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (scb *SettingCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := scb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (scb *SettingCreateBulk) ExecX(ctx context.Context) {
|
|
if err := scb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Setting.CreateBulk(builders...).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.SettingUpsert) {
|
|
// SetEnableSSO(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (scb *SettingCreateBulk) OnConflict(opts ...sql.ConflictOption) *SettingUpsertBulk {
|
|
scb.conflict = opts
|
|
return &SettingUpsertBulk{
|
|
create: scb,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (scb *SettingCreateBulk) OnConflictColumns(columns ...string) *SettingUpsertBulk {
|
|
scb.conflict = append(scb.conflict, sql.ConflictColumns(columns...))
|
|
return &SettingUpsertBulk{
|
|
create: scb,
|
|
}
|
|
}
|
|
|
|
// SettingUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of Setting nodes.
|
|
type SettingUpsertBulk struct {
|
|
create *SettingCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(setting.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *SettingUpsertBulk) UpdateNewValues() *SettingUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
for _, b := range u.create.builders {
|
|
if _, exists := b.mutation.ID(); exists {
|
|
s.SetIgnore(setting.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Setting.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *SettingUpsertBulk) Ignore() *SettingUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *SettingUpsertBulk) DoNothing() *SettingUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the SettingCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *SettingUpsertBulk) Update(set func(*SettingUpsert)) *SettingUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&SettingUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetEnableSSO sets the "enable_sso" field.
|
|
func (u *SettingUpsertBulk) SetEnableSSO(v bool) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetEnableSSO(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnableSSO sets the "enable_sso" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateEnableSSO() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateEnableSSO()
|
|
})
|
|
}
|
|
|
|
// SetForceTwoFactorAuth sets the "force_two_factor_auth" field.
|
|
func (u *SettingUpsertBulk) SetForceTwoFactorAuth(v bool) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetForceTwoFactorAuth(v)
|
|
})
|
|
}
|
|
|
|
// UpdateForceTwoFactorAuth sets the "force_two_factor_auth" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateForceTwoFactorAuth() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateForceTwoFactorAuth()
|
|
})
|
|
}
|
|
|
|
// SetDisablePasswordLogin sets the "disable_password_login" field.
|
|
func (u *SettingUpsertBulk) SetDisablePasswordLogin(v bool) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDisablePasswordLogin(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDisablePasswordLogin sets the "disable_password_login" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateDisablePasswordLogin() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDisablePasswordLogin()
|
|
})
|
|
}
|
|
|
|
// SetEnableDingtalkOauth sets the "enable_dingtalk_oauth" field.
|
|
func (u *SettingUpsertBulk) SetEnableDingtalkOauth(v bool) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetEnableDingtalkOauth(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEnableDingtalkOauth sets the "enable_dingtalk_oauth" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateEnableDingtalkOauth() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateEnableDingtalkOauth()
|
|
})
|
|
}
|
|
|
|
// SetDingtalkClientID sets the "dingtalk_client_id" field.
|
|
func (u *SettingUpsertBulk) SetDingtalkClientID(v string) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDingtalkClientID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDingtalkClientID sets the "dingtalk_client_id" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateDingtalkClientID() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDingtalkClientID()
|
|
})
|
|
}
|
|
|
|
// ClearDingtalkClientID clears the value of the "dingtalk_client_id" field.
|
|
func (u *SettingUpsertBulk) ClearDingtalkClientID() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.ClearDingtalkClientID()
|
|
})
|
|
}
|
|
|
|
// SetDingtalkClientSecret sets the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsertBulk) SetDingtalkClientSecret(v string) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetDingtalkClientSecret(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDingtalkClientSecret sets the "dingtalk_client_secret" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateDingtalkClientSecret() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateDingtalkClientSecret()
|
|
})
|
|
}
|
|
|
|
// ClearDingtalkClientSecret clears the value of the "dingtalk_client_secret" field.
|
|
func (u *SettingUpsertBulk) ClearDingtalkClientSecret() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.ClearDingtalkClientSecret()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *SettingUpsertBulk) SetCreatedAt(v time.Time) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateCreatedAt() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *SettingUpsertBulk) SetUpdatedAt(v time.Time) *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *SettingUpsertBulk) UpdateUpdatedAt() *SettingUpsertBulk {
|
|
return u.Update(func(s *SettingUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *SettingUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the SettingCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for SettingCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *SettingUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|