1428 lines
41 KiB
Go
1428 lines
41 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/sysuser"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// CpTaskCreate is the builder for creating a CpTask entity.
|
|
type CpTaskCreate struct {
|
|
config
|
|
mutation *CpTaskMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (_c *CpTaskCreate) SetCpUserID(v int64) *CpTaskCreate {
|
|
_c.mutation.SetCpUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *CpTaskCreate) SetUserID(v int64) *CpTaskCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTaskType sets the "task_type" field.
|
|
func (_c *CpTaskCreate) SetTaskType(v cptask.TaskType) *CpTaskCreate {
|
|
_c.mutation.SetTaskType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_c *CpTaskCreate) SetTitle(v string) *CpTaskCreate {
|
|
_c.mutation.SetTitle(v)
|
|
return _c
|
|
}
|
|
|
|
// SetFrequency sets the "frequency" field.
|
|
func (_c *CpTaskCreate) SetFrequency(v int) *CpTaskCreate {
|
|
_c.mutation.SetFrequency(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFrequency sets the "frequency" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableFrequency(v *int) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetFrequency(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTaskStatus sets the "task_status" field.
|
|
func (_c *CpTaskCreate) SetTaskStatus(v cptask.TaskStatus) *CpTaskCreate {
|
|
_c.mutation.SetTaskStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetSuccessCount sets the "success_count" field.
|
|
func (_c *CpTaskCreate) SetSuccessCount(v int) *CpTaskCreate {
|
|
_c.mutation.SetSuccessCount(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSuccessCount sets the "success_count" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableSuccessCount(v *int) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetSuccessCount(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFormData sets the "form_data" field.
|
|
func (_c *CpTaskCreate) SetFormData(v string) *CpTaskCreate {
|
|
_c.mutation.SetFormData(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFormData sets the "form_data" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableFormData(v *string) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetFormData(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStep sets the "step" field.
|
|
func (_c *CpTaskCreate) SetStep(v cptask.Step) *CpTaskCreate {
|
|
_c.mutation.SetStep(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNotificationType sets the "notification_type" field.
|
|
func (_c *CpTaskCreate) SetNotificationType(v cptask.NotificationType) *CpTaskCreate {
|
|
_c.mutation.SetNotificationType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetExecuteHour sets the "execute_hour" field.
|
|
func (_c *CpTaskCreate) SetExecuteHour(v int) *CpTaskCreate {
|
|
_c.mutation.SetExecuteHour(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExecuteHour sets the "execute_hour" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableExecuteHour(v *int) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetExecuteHour(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetExecuteMinute sets the "execute_minute" field.
|
|
func (_c *CpTaskCreate) SetExecuteMinute(v int) *CpTaskCreate {
|
|
_c.mutation.SetExecuteMinute(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableExecuteMinute sets the "execute_minute" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableExecuteMinute(v *int) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetExecuteMinute(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetNextExecuteTime sets the "next_execute_time" field.
|
|
func (_c *CpTaskCreate) SetNextExecuteTime(v int64) *CpTaskCreate {
|
|
_c.mutation.SetNextExecuteTime(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableNextExecuteTime sets the "next_execute_time" field if the given value is not nil.
|
|
func (_c *CpTaskCreate) SetNillableNextExecuteTime(v *int64) *CpTaskCreate {
|
|
if v != nil {
|
|
_c.SetNextExecuteTime(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCpUser sets the "cp_user" edge to the CpUser entity.
|
|
func (_c *CpTaskCreate) SetCpUser(v *CpUser) *CpTaskCreate {
|
|
return _c.SetCpUserID(v.ID)
|
|
}
|
|
|
|
// SetSysUserID sets the "sys_user" edge to the SysUser entity by ID.
|
|
func (_c *CpTaskCreate) SetSysUserID(id int64) *CpTaskCreate {
|
|
_c.mutation.SetSysUserID(id)
|
|
return _c
|
|
}
|
|
|
|
// SetSysUser sets the "sys_user" edge to the SysUser entity.
|
|
func (_c *CpTaskCreate) SetSysUser(v *SysUser) *CpTaskCreate {
|
|
return _c.SetSysUserID(v.ID)
|
|
}
|
|
|
|
// AddCpTaskLogIDs adds the "cp_task_logs" edge to the CpTaskLog entity by IDs.
|
|
func (_c *CpTaskCreate) AddCpTaskLogIDs(ids ...int64) *CpTaskCreate {
|
|
_c.mutation.AddCpTaskLogIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddCpTaskLogs adds the "cp_task_logs" edges to the CpTaskLog entity.
|
|
func (_c *CpTaskCreate) AddCpTaskLogs(v ...*CpTaskLog) *CpTaskCreate {
|
|
ids := make([]int64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddCpTaskLogIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the CpTaskMutation object of the builder.
|
|
func (_c *CpTaskCreate) Mutation() *CpTaskMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the CpTask in the database.
|
|
func (_c *CpTaskCreate) Save(ctx context.Context) (*CpTask, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *CpTaskCreate) SaveX(ctx context.Context) *CpTask {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CpTaskCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CpTaskCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *CpTaskCreate) defaults() {
|
|
if _, ok := _c.mutation.Frequency(); !ok {
|
|
v := cptask.DefaultFrequency
|
|
_c.mutation.SetFrequency(v)
|
|
}
|
|
if _, ok := _c.mutation.SuccessCount(); !ok {
|
|
v := cptask.DefaultSuccessCount
|
|
_c.mutation.SetSuccessCount(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *CpTaskCreate) check() error {
|
|
if _, ok := _c.mutation.CpUserID(); !ok {
|
|
return &ValidationError{Name: "cp_user_id", err: errors.New(`ent: missing required field "CpTask.cp_user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "CpTask.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.TaskType(); !ok {
|
|
return &ValidationError{Name: "task_type", err: errors.New(`ent: missing required field "CpTask.task_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.TaskType(); ok {
|
|
if err := cptask.TaskTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "task_type", err: fmt.Errorf(`ent: validator failed for field "CpTask.task_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Title(); !ok {
|
|
return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "CpTask.title"`)}
|
|
}
|
|
if v, ok := _c.mutation.Title(); ok {
|
|
if err := cptask.TitleValidator(v); err != nil {
|
|
return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "CpTask.title": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Frequency(); !ok {
|
|
return &ValidationError{Name: "frequency", err: errors.New(`ent: missing required field "CpTask.frequency"`)}
|
|
}
|
|
if _, ok := _c.mutation.TaskStatus(); !ok {
|
|
return &ValidationError{Name: "task_status", err: errors.New(`ent: missing required field "CpTask.task_status"`)}
|
|
}
|
|
if v, ok := _c.mutation.TaskStatus(); ok {
|
|
if err := cptask.TaskStatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "task_status", err: fmt.Errorf(`ent: validator failed for field "CpTask.task_status": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.SuccessCount(); !ok {
|
|
return &ValidationError{Name: "success_count", err: errors.New(`ent: missing required field "CpTask.success_count"`)}
|
|
}
|
|
if _, ok := _c.mutation.Step(); !ok {
|
|
return &ValidationError{Name: "step", err: errors.New(`ent: missing required field "CpTask.step"`)}
|
|
}
|
|
if v, ok := _c.mutation.Step(); ok {
|
|
if err := cptask.StepValidator(v); err != nil {
|
|
return &ValidationError{Name: "step", err: fmt.Errorf(`ent: validator failed for field "CpTask.step": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.NotificationType(); !ok {
|
|
return &ValidationError{Name: "notification_type", err: errors.New(`ent: missing required field "CpTask.notification_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.NotificationType(); ok {
|
|
if err := cptask.NotificationTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "notification_type", err: fmt.Errorf(`ent: validator failed for field "CpTask.notification_type": %w`, err)}
|
|
}
|
|
}
|
|
if len(_c.mutation.CpUserIDs()) == 0 {
|
|
return &ValidationError{Name: "cp_user", err: errors.New(`ent: missing required edge "CpTask.cp_user"`)}
|
|
}
|
|
if len(_c.mutation.SysUserIDs()) == 0 {
|
|
return &ValidationError{Name: "sys_user", err: errors.New(`ent: missing required edge "CpTask.sys_user"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *CpTaskCreate) sqlSave(ctx context.Context) (*CpTask, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int64(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *CpTaskCreate) createSpec() (*CpTask, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &CpTask{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(cptask.Table, sqlgraph.NewFieldSpec(cptask.FieldID, field.TypeInt64))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.TaskType(); ok {
|
|
_spec.SetField(cptask.FieldTaskType, field.TypeEnum, value)
|
|
_node.TaskType = value
|
|
}
|
|
if value, ok := _c.mutation.Title(); ok {
|
|
_spec.SetField(cptask.FieldTitle, field.TypeString, value)
|
|
_node.Title = value
|
|
}
|
|
if value, ok := _c.mutation.Frequency(); ok {
|
|
_spec.SetField(cptask.FieldFrequency, field.TypeInt, value)
|
|
_node.Frequency = value
|
|
}
|
|
if value, ok := _c.mutation.TaskStatus(); ok {
|
|
_spec.SetField(cptask.FieldTaskStatus, field.TypeEnum, value)
|
|
_node.TaskStatus = value
|
|
}
|
|
if value, ok := _c.mutation.SuccessCount(); ok {
|
|
_spec.SetField(cptask.FieldSuccessCount, field.TypeInt, value)
|
|
_node.SuccessCount = value
|
|
}
|
|
if value, ok := _c.mutation.FormData(); ok {
|
|
_spec.SetField(cptask.FieldFormData, field.TypeString, value)
|
|
_node.FormData = value
|
|
}
|
|
if value, ok := _c.mutation.Step(); ok {
|
|
_spec.SetField(cptask.FieldStep, field.TypeEnum, value)
|
|
_node.Step = value
|
|
}
|
|
if value, ok := _c.mutation.NotificationType(); ok {
|
|
_spec.SetField(cptask.FieldNotificationType, field.TypeEnum, value)
|
|
_node.NotificationType = value
|
|
}
|
|
if value, ok := _c.mutation.ExecuteHour(); ok {
|
|
_spec.SetField(cptask.FieldExecuteHour, field.TypeInt, value)
|
|
_node.ExecuteHour = &value
|
|
}
|
|
if value, ok := _c.mutation.ExecuteMinute(); ok {
|
|
_spec.SetField(cptask.FieldExecuteMinute, field.TypeInt, value)
|
|
_node.ExecuteMinute = &value
|
|
}
|
|
if value, ok := _c.mutation.NextExecuteTime(); ok {
|
|
_spec.SetField(cptask.FieldNextExecuteTime, field.TypeInt64, value)
|
|
_node.NextExecuteTime = &value
|
|
}
|
|
if nodes := _c.mutation.CpUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptask.CpUserTable,
|
|
Columns: []string{cptask.CpUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cpuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.CpUserID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.SysUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: cptask.SysUserTable,
|
|
Columns: []string{cptask.SysUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.UserID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.CpTaskLogsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: cptask.CpTaskLogsTable,
|
|
Columns: []string{cptask.CpTaskLogsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(cptasklog.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.CpTask.Create().
|
|
// SetCpUserID(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.CpTaskUpsert) {
|
|
// SetCpUserID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *CpTaskCreate) OnConflict(opts ...sql.ConflictOption) *CpTaskUpsertOne {
|
|
_c.conflict = opts
|
|
return &CpTaskUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *CpTaskCreate) OnConflictColumns(columns ...string) *CpTaskUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &CpTaskUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// CpTaskUpsertOne is the builder for "upsert"-ing
|
|
// one CpTask node.
|
|
CpTaskUpsertOne struct {
|
|
create *CpTaskCreate
|
|
}
|
|
|
|
// CpTaskUpsert is the "OnConflict" setter.
|
|
CpTaskUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (u *CpTaskUpsert) SetCpUserID(v int64) *CpTaskUpsert {
|
|
u.Set(cptask.FieldCpUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCpUserID sets the "cp_user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateCpUserID() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldCpUserID)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpTaskUpsert) SetUserID(v int64) *CpTaskUpsert {
|
|
u.Set(cptask.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateUserID() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetTaskType sets the "task_type" field.
|
|
func (u *CpTaskUpsert) SetTaskType(v cptask.TaskType) *CpTaskUpsert {
|
|
u.Set(cptask.FieldTaskType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTaskType sets the "task_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateTaskType() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldTaskType)
|
|
return u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *CpTaskUpsert) SetTitle(v string) *CpTaskUpsert {
|
|
u.Set(cptask.FieldTitle, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateTitle() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldTitle)
|
|
return u
|
|
}
|
|
|
|
// SetFrequency sets the "frequency" field.
|
|
func (u *CpTaskUpsert) SetFrequency(v int) *CpTaskUpsert {
|
|
u.Set(cptask.FieldFrequency, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateFrequency sets the "frequency" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateFrequency() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldFrequency)
|
|
return u
|
|
}
|
|
|
|
// AddFrequency adds v to the "frequency" field.
|
|
func (u *CpTaskUpsert) AddFrequency(v int) *CpTaskUpsert {
|
|
u.Add(cptask.FieldFrequency, v)
|
|
return u
|
|
}
|
|
|
|
// SetTaskStatus sets the "task_status" field.
|
|
func (u *CpTaskUpsert) SetTaskStatus(v cptask.TaskStatus) *CpTaskUpsert {
|
|
u.Set(cptask.FieldTaskStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateTaskStatus() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldTaskStatus)
|
|
return u
|
|
}
|
|
|
|
// SetSuccessCount sets the "success_count" field.
|
|
func (u *CpTaskUpsert) SetSuccessCount(v int) *CpTaskUpsert {
|
|
u.Set(cptask.FieldSuccessCount, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSuccessCount sets the "success_count" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateSuccessCount() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldSuccessCount)
|
|
return u
|
|
}
|
|
|
|
// AddSuccessCount adds v to the "success_count" field.
|
|
func (u *CpTaskUpsert) AddSuccessCount(v int) *CpTaskUpsert {
|
|
u.Add(cptask.FieldSuccessCount, v)
|
|
return u
|
|
}
|
|
|
|
// SetFormData sets the "form_data" field.
|
|
func (u *CpTaskUpsert) SetFormData(v string) *CpTaskUpsert {
|
|
u.Set(cptask.FieldFormData, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateFormData sets the "form_data" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateFormData() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldFormData)
|
|
return u
|
|
}
|
|
|
|
// ClearFormData clears the value of the "form_data" field.
|
|
func (u *CpTaskUpsert) ClearFormData() *CpTaskUpsert {
|
|
u.SetNull(cptask.FieldFormData)
|
|
return u
|
|
}
|
|
|
|
// SetStep sets the "step" field.
|
|
func (u *CpTaskUpsert) SetStep(v cptask.Step) *CpTaskUpsert {
|
|
u.Set(cptask.FieldStep, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStep sets the "step" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateStep() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldStep)
|
|
return u
|
|
}
|
|
|
|
// SetNotificationType sets the "notification_type" field.
|
|
func (u *CpTaskUpsert) SetNotificationType(v cptask.NotificationType) *CpTaskUpsert {
|
|
u.Set(cptask.FieldNotificationType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateNotificationType sets the "notification_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateNotificationType() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldNotificationType)
|
|
return u
|
|
}
|
|
|
|
// SetExecuteHour sets the "execute_hour" field.
|
|
func (u *CpTaskUpsert) SetExecuteHour(v int) *CpTaskUpsert {
|
|
u.Set(cptask.FieldExecuteHour, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExecuteHour sets the "execute_hour" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateExecuteHour() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldExecuteHour)
|
|
return u
|
|
}
|
|
|
|
// AddExecuteHour adds v to the "execute_hour" field.
|
|
func (u *CpTaskUpsert) AddExecuteHour(v int) *CpTaskUpsert {
|
|
u.Add(cptask.FieldExecuteHour, v)
|
|
return u
|
|
}
|
|
|
|
// ClearExecuteHour clears the value of the "execute_hour" field.
|
|
func (u *CpTaskUpsert) ClearExecuteHour() *CpTaskUpsert {
|
|
u.SetNull(cptask.FieldExecuteHour)
|
|
return u
|
|
}
|
|
|
|
// SetExecuteMinute sets the "execute_minute" field.
|
|
func (u *CpTaskUpsert) SetExecuteMinute(v int) *CpTaskUpsert {
|
|
u.Set(cptask.FieldExecuteMinute, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateExecuteMinute sets the "execute_minute" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateExecuteMinute() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldExecuteMinute)
|
|
return u
|
|
}
|
|
|
|
// AddExecuteMinute adds v to the "execute_minute" field.
|
|
func (u *CpTaskUpsert) AddExecuteMinute(v int) *CpTaskUpsert {
|
|
u.Add(cptask.FieldExecuteMinute, v)
|
|
return u
|
|
}
|
|
|
|
// ClearExecuteMinute clears the value of the "execute_minute" field.
|
|
func (u *CpTaskUpsert) ClearExecuteMinute() *CpTaskUpsert {
|
|
u.SetNull(cptask.FieldExecuteMinute)
|
|
return u
|
|
}
|
|
|
|
// SetNextExecuteTime sets the "next_execute_time" field.
|
|
func (u *CpTaskUpsert) SetNextExecuteTime(v int64) *CpTaskUpsert {
|
|
u.Set(cptask.FieldNextExecuteTime, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateNextExecuteTime sets the "next_execute_time" field to the value that was provided on create.
|
|
func (u *CpTaskUpsert) UpdateNextExecuteTime() *CpTaskUpsert {
|
|
u.SetExcluded(cptask.FieldNextExecuteTime)
|
|
return u
|
|
}
|
|
|
|
// AddNextExecuteTime adds v to the "next_execute_time" field.
|
|
func (u *CpTaskUpsert) AddNextExecuteTime(v int64) *CpTaskUpsert {
|
|
u.Add(cptask.FieldNextExecuteTime, v)
|
|
return u
|
|
}
|
|
|
|
// ClearNextExecuteTime clears the value of the "next_execute_time" field.
|
|
func (u *CpTaskUpsert) ClearNextExecuteTime() *CpTaskUpsert {
|
|
u.SetNull(cptask.FieldNextExecuteTime)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *CpTaskUpsertOne) UpdateNewValues() *CpTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *CpTaskUpsertOne) Ignore() *CpTaskUpsertOne {
|
|
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 *CpTaskUpsertOne) DoNothing() *CpTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the CpTaskCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *CpTaskUpsertOne) Update(set func(*CpTaskUpsert)) *CpTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&CpTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (u *CpTaskUpsertOne) SetCpUserID(v int64) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetCpUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCpUserID sets the "cp_user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateCpUserID() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateCpUserID()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpTaskUpsertOne) SetUserID(v int64) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateUserID() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetTaskType sets the "task_type" field.
|
|
func (u *CpTaskUpsertOne) SetTaskType(v cptask.TaskType) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTaskType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskType sets the "task_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateTaskType() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTaskType()
|
|
})
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *CpTaskUpsertOne) SetTitle(v string) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTitle(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateTitle() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTitle()
|
|
})
|
|
}
|
|
|
|
// SetFrequency sets the "frequency" field.
|
|
func (u *CpTaskUpsertOne) SetFrequency(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetFrequency(v)
|
|
})
|
|
}
|
|
|
|
// AddFrequency adds v to the "frequency" field.
|
|
func (u *CpTaskUpsertOne) AddFrequency(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddFrequency(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFrequency sets the "frequency" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateFrequency() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateFrequency()
|
|
})
|
|
}
|
|
|
|
// SetTaskStatus sets the "task_status" field.
|
|
func (u *CpTaskUpsertOne) SetTaskStatus(v cptask.TaskStatus) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTaskStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateTaskStatus() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTaskStatus()
|
|
})
|
|
}
|
|
|
|
// SetSuccessCount sets the "success_count" field.
|
|
func (u *CpTaskUpsertOne) SetSuccessCount(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetSuccessCount(v)
|
|
})
|
|
}
|
|
|
|
// AddSuccessCount adds v to the "success_count" field.
|
|
func (u *CpTaskUpsertOne) AddSuccessCount(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddSuccessCount(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSuccessCount sets the "success_count" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateSuccessCount() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateSuccessCount()
|
|
})
|
|
}
|
|
|
|
// SetFormData sets the "form_data" field.
|
|
func (u *CpTaskUpsertOne) SetFormData(v string) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetFormData(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFormData sets the "form_data" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateFormData() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateFormData()
|
|
})
|
|
}
|
|
|
|
// ClearFormData clears the value of the "form_data" field.
|
|
func (u *CpTaskUpsertOne) ClearFormData() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearFormData()
|
|
})
|
|
}
|
|
|
|
// SetStep sets the "step" field.
|
|
func (u *CpTaskUpsertOne) SetStep(v cptask.Step) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetStep(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStep sets the "step" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateStep() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateStep()
|
|
})
|
|
}
|
|
|
|
// SetNotificationType sets the "notification_type" field.
|
|
func (u *CpTaskUpsertOne) SetNotificationType(v cptask.NotificationType) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetNotificationType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNotificationType sets the "notification_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateNotificationType() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateNotificationType()
|
|
})
|
|
}
|
|
|
|
// SetExecuteHour sets the "execute_hour" field.
|
|
func (u *CpTaskUpsertOne) SetExecuteHour(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetExecuteHour(v)
|
|
})
|
|
}
|
|
|
|
// AddExecuteHour adds v to the "execute_hour" field.
|
|
func (u *CpTaskUpsertOne) AddExecuteHour(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddExecuteHour(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExecuteHour sets the "execute_hour" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateExecuteHour() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateExecuteHour()
|
|
})
|
|
}
|
|
|
|
// ClearExecuteHour clears the value of the "execute_hour" field.
|
|
func (u *CpTaskUpsertOne) ClearExecuteHour() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearExecuteHour()
|
|
})
|
|
}
|
|
|
|
// SetExecuteMinute sets the "execute_minute" field.
|
|
func (u *CpTaskUpsertOne) SetExecuteMinute(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetExecuteMinute(v)
|
|
})
|
|
}
|
|
|
|
// AddExecuteMinute adds v to the "execute_minute" field.
|
|
func (u *CpTaskUpsertOne) AddExecuteMinute(v int) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddExecuteMinute(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExecuteMinute sets the "execute_minute" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateExecuteMinute() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateExecuteMinute()
|
|
})
|
|
}
|
|
|
|
// ClearExecuteMinute clears the value of the "execute_minute" field.
|
|
func (u *CpTaskUpsertOne) ClearExecuteMinute() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearExecuteMinute()
|
|
})
|
|
}
|
|
|
|
// SetNextExecuteTime sets the "next_execute_time" field.
|
|
func (u *CpTaskUpsertOne) SetNextExecuteTime(v int64) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetNextExecuteTime(v)
|
|
})
|
|
}
|
|
|
|
// AddNextExecuteTime adds v to the "next_execute_time" field.
|
|
func (u *CpTaskUpsertOne) AddNextExecuteTime(v int64) *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddNextExecuteTime(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNextExecuteTime sets the "next_execute_time" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertOne) UpdateNextExecuteTime() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateNextExecuteTime()
|
|
})
|
|
}
|
|
|
|
// ClearNextExecuteTime clears the value of the "next_execute_time" field.
|
|
func (u *CpTaskUpsertOne) ClearNextExecuteTime() *CpTaskUpsertOne {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearNextExecuteTime()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *CpTaskUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for CpTaskCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *CpTaskUpsertOne) 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 *CpTaskUpsertOne) ID(ctx context.Context) (id int64, err error) {
|
|
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 *CpTaskUpsertOne) IDX(ctx context.Context) int64 {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// CpTaskCreateBulk is the builder for creating many CpTask entities in bulk.
|
|
type CpTaskCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*CpTaskCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the CpTask entities in the database.
|
|
func (_c *CpTaskCreateBulk) Save(ctx context.Context) ([]*CpTask, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*CpTask, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*CpTaskMutation)
|
|
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, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = _c.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.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
|
|
if specs[i].ID.Value != nil {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int64(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, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *CpTaskCreateBulk) SaveX(ctx context.Context) []*CpTask {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CpTaskCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CpTaskCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.CpTask.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.CpTaskUpsert) {
|
|
// SetCpUserID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *CpTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpTaskUpsertBulk {
|
|
_c.conflict = opts
|
|
return &CpTaskUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *CpTaskCreateBulk) OnConflictColumns(columns ...string) *CpTaskUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &CpTaskUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// CpTaskUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of CpTask nodes.
|
|
type CpTaskUpsertBulk struct {
|
|
create *CpTaskCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *CpTaskUpsertBulk) UpdateNewValues() *CpTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.CpTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *CpTaskUpsertBulk) Ignore() *CpTaskUpsertBulk {
|
|
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 *CpTaskUpsertBulk) DoNothing() *CpTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the CpTaskCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *CpTaskUpsertBulk) Update(set func(*CpTaskUpsert)) *CpTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&CpTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCpUserID sets the "cp_user_id" field.
|
|
func (u *CpTaskUpsertBulk) SetCpUserID(v int64) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetCpUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCpUserID sets the "cp_user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateCpUserID() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateCpUserID()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *CpTaskUpsertBulk) SetUserID(v int64) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateUserID() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetTaskType sets the "task_type" field.
|
|
func (u *CpTaskUpsertBulk) SetTaskType(v cptask.TaskType) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTaskType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskType sets the "task_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateTaskType() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTaskType()
|
|
})
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *CpTaskUpsertBulk) SetTitle(v string) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTitle(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateTitle() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTitle()
|
|
})
|
|
}
|
|
|
|
// SetFrequency sets the "frequency" field.
|
|
func (u *CpTaskUpsertBulk) SetFrequency(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetFrequency(v)
|
|
})
|
|
}
|
|
|
|
// AddFrequency adds v to the "frequency" field.
|
|
func (u *CpTaskUpsertBulk) AddFrequency(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddFrequency(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFrequency sets the "frequency" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateFrequency() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateFrequency()
|
|
})
|
|
}
|
|
|
|
// SetTaskStatus sets the "task_status" field.
|
|
func (u *CpTaskUpsertBulk) SetTaskStatus(v cptask.TaskStatus) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetTaskStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateTaskStatus() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateTaskStatus()
|
|
})
|
|
}
|
|
|
|
// SetSuccessCount sets the "success_count" field.
|
|
func (u *CpTaskUpsertBulk) SetSuccessCount(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetSuccessCount(v)
|
|
})
|
|
}
|
|
|
|
// AddSuccessCount adds v to the "success_count" field.
|
|
func (u *CpTaskUpsertBulk) AddSuccessCount(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddSuccessCount(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSuccessCount sets the "success_count" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateSuccessCount() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateSuccessCount()
|
|
})
|
|
}
|
|
|
|
// SetFormData sets the "form_data" field.
|
|
func (u *CpTaskUpsertBulk) SetFormData(v string) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetFormData(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFormData sets the "form_data" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateFormData() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateFormData()
|
|
})
|
|
}
|
|
|
|
// ClearFormData clears the value of the "form_data" field.
|
|
func (u *CpTaskUpsertBulk) ClearFormData() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearFormData()
|
|
})
|
|
}
|
|
|
|
// SetStep sets the "step" field.
|
|
func (u *CpTaskUpsertBulk) SetStep(v cptask.Step) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetStep(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStep sets the "step" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateStep() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateStep()
|
|
})
|
|
}
|
|
|
|
// SetNotificationType sets the "notification_type" field.
|
|
func (u *CpTaskUpsertBulk) SetNotificationType(v cptask.NotificationType) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetNotificationType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNotificationType sets the "notification_type" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateNotificationType() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateNotificationType()
|
|
})
|
|
}
|
|
|
|
// SetExecuteHour sets the "execute_hour" field.
|
|
func (u *CpTaskUpsertBulk) SetExecuteHour(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetExecuteHour(v)
|
|
})
|
|
}
|
|
|
|
// AddExecuteHour adds v to the "execute_hour" field.
|
|
func (u *CpTaskUpsertBulk) AddExecuteHour(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddExecuteHour(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExecuteHour sets the "execute_hour" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateExecuteHour() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateExecuteHour()
|
|
})
|
|
}
|
|
|
|
// ClearExecuteHour clears the value of the "execute_hour" field.
|
|
func (u *CpTaskUpsertBulk) ClearExecuteHour() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearExecuteHour()
|
|
})
|
|
}
|
|
|
|
// SetExecuteMinute sets the "execute_minute" field.
|
|
func (u *CpTaskUpsertBulk) SetExecuteMinute(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetExecuteMinute(v)
|
|
})
|
|
}
|
|
|
|
// AddExecuteMinute adds v to the "execute_minute" field.
|
|
func (u *CpTaskUpsertBulk) AddExecuteMinute(v int) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddExecuteMinute(v)
|
|
})
|
|
}
|
|
|
|
// UpdateExecuteMinute sets the "execute_minute" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateExecuteMinute() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateExecuteMinute()
|
|
})
|
|
}
|
|
|
|
// ClearExecuteMinute clears the value of the "execute_minute" field.
|
|
func (u *CpTaskUpsertBulk) ClearExecuteMinute() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearExecuteMinute()
|
|
})
|
|
}
|
|
|
|
// SetNextExecuteTime sets the "next_execute_time" field.
|
|
func (u *CpTaskUpsertBulk) SetNextExecuteTime(v int64) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.SetNextExecuteTime(v)
|
|
})
|
|
}
|
|
|
|
// AddNextExecuteTime adds v to the "next_execute_time" field.
|
|
func (u *CpTaskUpsertBulk) AddNextExecuteTime(v int64) *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.AddNextExecuteTime(v)
|
|
})
|
|
}
|
|
|
|
// UpdateNextExecuteTime sets the "next_execute_time" field to the value that was provided on create.
|
|
func (u *CpTaskUpsertBulk) UpdateNextExecuteTime() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.UpdateNextExecuteTime()
|
|
})
|
|
}
|
|
|
|
// ClearNextExecuteTime clears the value of the "next_execute_time" field.
|
|
func (u *CpTaskUpsertBulk) ClearNextExecuteTime() *CpTaskUpsertBulk {
|
|
return u.Update(func(s *CpTaskUpsert) {
|
|
s.ClearNextExecuteTime()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *CpTaskUpsertBulk) 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("ent: OnConflict was set for builder %d. Set it on the CpTaskCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for CpTaskCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *CpTaskUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|