708 lines
21 KiB
Go
708 lines
21 KiB
Go
// ENT数据库文件,请勿编辑。
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"likedream-goframe/internal/ent/cptask"
|
|
"likedream-goframe/internal/ent/cptasklog"
|
|
"likedream-goframe/internal/ent/cpuser"
|
|
"likedream-goframe/internal/ent/internal"
|
|
"likedream-goframe/internal/ent/predicate"
|
|
"likedream-goframe/internal/ent/sysuser"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// CpTaskLogUpdate is the builder for updating CpTaskLog entities.
|
|
type CpTaskLogUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *CpTaskLogMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the CpTaskLogUpdate builder.
|
|
func (_u *CpTaskLogUpdate) Where(ps ...predicate.CpTaskLog) *CpTaskLogUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetCpTaskID sets the "cp_task_id" field.
|
|
func (_u *CpTaskLogUpdate) SetCpTaskID(v int64) *CpTaskLogUpdate {
|
|
_u.mutation.SetCpTaskID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCpTaskID sets the "cp_task_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableCpTaskID(v *int64) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetCpTaskID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSystemUserID sets the "system_user_id" field.
|
|
func (_u *CpTaskLogUpdate) SetSystemUserID(v int64) *CpTaskLogUpdate {
|
|
_u.mutation.SetSystemUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSystemUserID sets the "system_user_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableSystemUserID(v *int64) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetSystemUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (_u *CpTaskLogUpdate) SetCpUserID(v int64) *CpTaskLogUpdate {
|
|
_u.mutation.SetCpUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCpUserID sets the "cp_user_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableCpUserID(v *int64) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetCpUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsSuccess sets the "is_success" field.
|
|
func (_u *CpTaskLogUpdate) SetIsSuccess(v bool) *CpTaskLogUpdate {
|
|
_u.mutation.SetIsSuccess(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsSuccess sets the "is_success" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableIsSuccess(v *bool) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetIsSuccess(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMessage sets the "error_message" field.
|
|
func (_u *CpTaskLogUpdate) SetErrorMessage(v string) *CpTaskLogUpdate {
|
|
_u.mutation.SetErrorMessage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableErrorMessage(v *string) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetErrorMessage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearErrorMessage clears the value of the "error_message" field.
|
|
func (_u *CpTaskLogUpdate) ClearErrorMessage() *CpTaskLogUpdate {
|
|
_u.mutation.ClearErrorMessage()
|
|
return _u
|
|
}
|
|
|
|
// SetRealName sets the "real_name" field.
|
|
func (_u *CpTaskLogUpdate) SetRealName(v string) *CpTaskLogUpdate {
|
|
_u.mutation.SetRealName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRealName sets the "real_name" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdate) SetNillableRealName(v *string) *CpTaskLogUpdate {
|
|
if v != nil {
|
|
_u.SetRealName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRealName clears the value of the "real_name" field.
|
|
func (_u *CpTaskLogUpdate) ClearRealName() *CpTaskLogUpdate {
|
|
_u.mutation.ClearRealName()
|
|
return _u
|
|
}
|
|
|
|
// SetCpTask sets the "cp_task" edge to the CpTask entity.
|
|
func (_u *CpTaskLogUpdate) SetCpTask(v *CpTask) *CpTaskLogUpdate {
|
|
return _u.SetCpTaskID(v.ID)
|
|
}
|
|
|
|
// SetSystemUser sets the "system_user" edge to the SysUser entity.
|
|
func (_u *CpTaskLogUpdate) SetSystemUser(v *SysUser) *CpTaskLogUpdate {
|
|
return _u.SetSystemUserID(v.ID)
|
|
}
|
|
|
|
// SetCpUser sets the "cp_user" edge to the CpUser entity.
|
|
func (_u *CpTaskLogUpdate) SetCpUser(v *CpUser) *CpTaskLogUpdate {
|
|
return _u.SetCpUserID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the CpTaskLogMutation object of the builder.
|
|
func (_u *CpTaskLogUpdate) Mutation() *CpTaskLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCpTask clears the "cp_task" edge to the CpTask entity.
|
|
func (_u *CpTaskLogUpdate) ClearCpTask() *CpTaskLogUpdate {
|
|
_u.mutation.ClearCpTask()
|
|
return _u
|
|
}
|
|
|
|
// ClearSystemUser clears the "system_user" edge to the SysUser entity.
|
|
func (_u *CpTaskLogUpdate) ClearSystemUser() *CpTaskLogUpdate {
|
|
_u.mutation.ClearSystemUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearCpUser clears the "cp_user" edge to the CpUser entity.
|
|
func (_u *CpTaskLogUpdate) ClearCpUser() *CpTaskLogUpdate {
|
|
_u.mutation.ClearCpUser()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *CpTaskLogUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *CpTaskLogUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *CpTaskLogUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *CpTaskLogUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *CpTaskLogUpdate) check() error {
|
|
if _u.mutation.CpTaskCleared() && len(_u.mutation.CpTaskIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.cp_task"`)
|
|
}
|
|
if _u.mutation.SystemUserCleared() && len(_u.mutation.SystemUserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.system_user"`)
|
|
}
|
|
if _u.mutation.CpUserCleared() && len(_u.mutation.CpUserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.cp_user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *CpTaskLogUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CpTaskLogUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *CpTaskLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(cptasklog.Table, cptasklog.Columns, sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.IsSuccess(); ok {
|
|
_spec.SetField(cptasklog.FieldIsSuccess, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMessage(); ok {
|
|
_spec.SetField(cptasklog.FieldErrorMessage, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ErrorMessageCleared() {
|
|
_spec.ClearField(cptasklog.FieldErrorMessage, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.RealName(); ok {
|
|
_spec.SetField(cptasklog.FieldRealName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RealNameCleared() {
|
|
_spec.ClearField(cptasklog.FieldRealName, field.TypeString)
|
|
}
|
|
if _u.mutation.CpTaskCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpTaskTable,
|
|
Columns: []string{cptasklog.CpTaskColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpTaskIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpTaskTable,
|
|
Columns: []string{cptasklog.CpTaskColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SystemUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.SystemUserTable,
|
|
Columns: []string{cptasklog.SystemUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SystemUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.SystemUserTable,
|
|
Columns: []string{cptasklog.SystemUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.CpUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpUserTable,
|
|
Columns: []string{cptasklog.CpUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpUserTable,
|
|
Columns: []string{cptasklog.CpUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.Node.Schema = _u.schemaConfig.CpTaskLog
|
|
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{cptasklog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// CpTaskLogUpdateOne is the builder for updating a single CpTaskLog entity.
|
|
type CpTaskLogUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *CpTaskLogMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetCpTaskID sets the "cp_task_id" field.
|
|
func (_u *CpTaskLogUpdateOne) SetCpTaskID(v int64) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetCpTaskID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCpTaskID sets the "cp_task_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableCpTaskID(v *int64) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetCpTaskID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSystemUserID sets the "system_user_id" field.
|
|
func (_u *CpTaskLogUpdateOne) SetSystemUserID(v int64) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetSystemUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSystemUserID sets the "system_user_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableSystemUserID(v *int64) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetSystemUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (_u *CpTaskLogUpdateOne) SetCpUserID(v int64) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetCpUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCpUserID sets the "cp_user_id" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableCpUserID(v *int64) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetCpUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsSuccess sets the "is_success" field.
|
|
func (_u *CpTaskLogUpdateOne) SetIsSuccess(v bool) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetIsSuccess(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsSuccess sets the "is_success" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableIsSuccess(v *bool) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsSuccess(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMessage sets the "error_message" field.
|
|
func (_u *CpTaskLogUpdateOne) SetErrorMessage(v string) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetErrorMessage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableErrorMessage(v *string) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetErrorMessage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearErrorMessage clears the value of the "error_message" field.
|
|
func (_u *CpTaskLogUpdateOne) ClearErrorMessage() *CpTaskLogUpdateOne {
|
|
_u.mutation.ClearErrorMessage()
|
|
return _u
|
|
}
|
|
|
|
// SetRealName sets the "real_name" field.
|
|
func (_u *CpTaskLogUpdateOne) SetRealName(v string) *CpTaskLogUpdateOne {
|
|
_u.mutation.SetRealName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRealName sets the "real_name" field if the given value is not nil.
|
|
func (_u *CpTaskLogUpdateOne) SetNillableRealName(v *string) *CpTaskLogUpdateOne {
|
|
if v != nil {
|
|
_u.SetRealName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRealName clears the value of the "real_name" field.
|
|
func (_u *CpTaskLogUpdateOne) ClearRealName() *CpTaskLogUpdateOne {
|
|
_u.mutation.ClearRealName()
|
|
return _u
|
|
}
|
|
|
|
// SetCpTask sets the "cp_task" edge to the CpTask entity.
|
|
func (_u *CpTaskLogUpdateOne) SetCpTask(v *CpTask) *CpTaskLogUpdateOne {
|
|
return _u.SetCpTaskID(v.ID)
|
|
}
|
|
|
|
// SetSystemUser sets the "system_user" edge to the SysUser entity.
|
|
func (_u *CpTaskLogUpdateOne) SetSystemUser(v *SysUser) *CpTaskLogUpdateOne {
|
|
return _u.SetSystemUserID(v.ID)
|
|
}
|
|
|
|
// SetCpUser sets the "cp_user" edge to the CpUser entity.
|
|
func (_u *CpTaskLogUpdateOne) SetCpUser(v *CpUser) *CpTaskLogUpdateOne {
|
|
return _u.SetCpUserID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the CpTaskLogMutation object of the builder.
|
|
func (_u *CpTaskLogUpdateOne) Mutation() *CpTaskLogMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearCpTask clears the "cp_task" edge to the CpTask entity.
|
|
func (_u *CpTaskLogUpdateOne) ClearCpTask() *CpTaskLogUpdateOne {
|
|
_u.mutation.ClearCpTask()
|
|
return _u
|
|
}
|
|
|
|
// ClearSystemUser clears the "system_user" edge to the SysUser entity.
|
|
func (_u *CpTaskLogUpdateOne) ClearSystemUser() *CpTaskLogUpdateOne {
|
|
_u.mutation.ClearSystemUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearCpUser clears the "cp_user" edge to the CpUser entity.
|
|
func (_u *CpTaskLogUpdateOne) ClearCpUser() *CpTaskLogUpdateOne {
|
|
_u.mutation.ClearCpUser()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the CpTaskLogUpdate builder.
|
|
func (_u *CpTaskLogUpdateOne) Where(ps ...predicate.CpTaskLog) *CpTaskLogUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *CpTaskLogUpdateOne) Select(field string, fields ...string) *CpTaskLogUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated CpTaskLog entity.
|
|
func (_u *CpTaskLogUpdateOne) Save(ctx context.Context) (*CpTaskLog, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *CpTaskLogUpdateOne) SaveX(ctx context.Context) *CpTaskLog {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *CpTaskLogUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *CpTaskLogUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *CpTaskLogUpdateOne) check() error {
|
|
if _u.mutation.CpTaskCleared() && len(_u.mutation.CpTaskIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.cp_task"`)
|
|
}
|
|
if _u.mutation.SystemUserCleared() && len(_u.mutation.SystemUserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.system_user"`)
|
|
}
|
|
if _u.mutation.CpUserCleared() && len(_u.mutation.CpUserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "CpTaskLog.cp_user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *CpTaskLogUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CpTaskLogUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *CpTaskLogUpdateOne) sqlSave(ctx context.Context) (_node *CpTaskLog, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(cptasklog.Table, cptasklog.Columns, sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CpTaskLog.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, cptasklog.FieldID)
|
|
for _, f := range fields {
|
|
if !cptasklog.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != cptasklog.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.IsSuccess(); ok {
|
|
_spec.SetField(cptasklog.FieldIsSuccess, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMessage(); ok {
|
|
_spec.SetField(cptasklog.FieldErrorMessage, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ErrorMessageCleared() {
|
|
_spec.ClearField(cptasklog.FieldErrorMessage, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.RealName(); ok {
|
|
_spec.SetField(cptasklog.FieldRealName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RealNameCleared() {
|
|
_spec.ClearField(cptasklog.FieldRealName, field.TypeString)
|
|
}
|
|
if _u.mutation.CpTaskCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpTaskTable,
|
|
Columns: []string{cptasklog.CpTaskColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpTaskIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpTaskTable,
|
|
Columns: []string{cptasklog.CpTaskColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.SystemUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.SystemUserTable,
|
|
Columns: []string{cptasklog.SystemUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.SystemUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.SystemUserTable,
|
|
Columns: []string{cptasklog.SystemUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.CpUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpUserTable,
|
|
Columns: []string{cptasklog.CpUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.CpUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptasklog.CpUserTable,
|
|
Columns: []string{cptasklog.CpUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
edge.Schema = _u.schemaConfig.CpTaskLog
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.Node.Schema = _u.schemaConfig.CpTaskLog
|
|
ctx = internal.NewSchemaConfigContext(ctx, _u.schemaConfig)
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &CpTaskLog{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{cptasklog.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|