12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/predicate"
- "wechat-api/ent/sopnode"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/dialect/sql/sqljson"
- "entgo.io/ent/schema/field"
- )
- // SopStageUpdate is the builder for updating SopStage entities.
- type SopStageUpdate struct {
- config
- hooks []Hook
- mutation *SopStageMutation
- }
- // Where appends a list predicates to the SopStageUpdate builder.
- func (ssu *SopStageUpdate) Where(ps ...predicate.SopStage) *SopStageUpdate {
- ssu.mutation.Where(ps...)
- return ssu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ssu *SopStageUpdate) SetUpdatedAt(t time.Time) *SopStageUpdate {
- ssu.mutation.SetUpdatedAt(t)
- return ssu
- }
- // SetStatus sets the "status" field.
- func (ssu *SopStageUpdate) SetStatus(u uint8) *SopStageUpdate {
- ssu.mutation.ResetStatus()
- ssu.mutation.SetStatus(u)
- return ssu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableStatus(u *uint8) *SopStageUpdate {
- if u != nil {
- ssu.SetStatus(*u)
- }
- return ssu
- }
- // AddStatus adds u to the "status" field.
- func (ssu *SopStageUpdate) AddStatus(u int8) *SopStageUpdate {
- ssu.mutation.AddStatus(u)
- return ssu
- }
- // ClearStatus clears the value of the "status" field.
- func (ssu *SopStageUpdate) ClearStatus() *SopStageUpdate {
- ssu.mutation.ClearStatus()
- return ssu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ssu *SopStageUpdate) SetDeletedAt(t time.Time) *SopStageUpdate {
- ssu.mutation.SetDeletedAt(t)
- return ssu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableDeletedAt(t *time.Time) *SopStageUpdate {
- if t != nil {
- ssu.SetDeletedAt(*t)
- }
- return ssu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (ssu *SopStageUpdate) ClearDeletedAt() *SopStageUpdate {
- ssu.mutation.ClearDeletedAt()
- return ssu
- }
- // SetTaskID sets the "task_id" field.
- func (ssu *SopStageUpdate) SetTaskID(u uint64) *SopStageUpdate {
- ssu.mutation.SetTaskID(u)
- return ssu
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableTaskID(u *uint64) *SopStageUpdate {
- if u != nil {
- ssu.SetTaskID(*u)
- }
- return ssu
- }
- // SetName sets the "name" field.
- func (ssu *SopStageUpdate) SetName(s string) *SopStageUpdate {
- ssu.mutation.SetName(s)
- return ssu
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableName(s *string) *SopStageUpdate {
- if s != nil {
- ssu.SetName(*s)
- }
- return ssu
- }
- // SetConditionType sets the "condition_type" field.
- func (ssu *SopStageUpdate) SetConditionType(i int) *SopStageUpdate {
- ssu.mutation.ResetConditionType()
- ssu.mutation.SetConditionType(i)
- return ssu
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableConditionType(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetConditionType(*i)
- }
- return ssu
- }
- // AddConditionType adds i to the "condition_type" field.
- func (ssu *SopStageUpdate) AddConditionType(i int) *SopStageUpdate {
- ssu.mutation.AddConditionType(i)
- return ssu
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (ssu *SopStageUpdate) SetConditionOperator(i int) *SopStageUpdate {
- ssu.mutation.ResetConditionOperator()
- ssu.mutation.SetConditionOperator(i)
- return ssu
- }
- // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableConditionOperator(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetConditionOperator(*i)
- }
- return ssu
- }
- // AddConditionOperator adds i to the "condition_operator" field.
- func (ssu *SopStageUpdate) AddConditionOperator(i int) *SopStageUpdate {
- ssu.mutation.AddConditionOperator(i)
- return ssu
- }
- // SetConditionList sets the "condition_list" field.
- func (ssu *SopStageUpdate) SetConditionList(ct []custom_types.Condition) *SopStageUpdate {
- ssu.mutation.SetConditionList(ct)
- return ssu
- }
- // AppendConditionList appends ct to the "condition_list" field.
- func (ssu *SopStageUpdate) AppendConditionList(ct []custom_types.Condition) *SopStageUpdate {
- ssu.mutation.AppendConditionList(ct)
- return ssu
- }
- // SetActionMessage sets the "action_message" field.
- func (ssu *SopStageUpdate) SetActionMessage(ct []custom_types.Action) *SopStageUpdate {
- ssu.mutation.SetActionMessage(ct)
- return ssu
- }
- // AppendActionMessage appends ct to the "action_message" field.
- func (ssu *SopStageUpdate) AppendActionMessage(ct []custom_types.Action) *SopStageUpdate {
- ssu.mutation.AppendActionMessage(ct)
- return ssu
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (ssu *SopStageUpdate) ClearActionMessage() *SopStageUpdate {
- ssu.mutation.ClearActionMessage()
- return ssu
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (ssu *SopStageUpdate) SetActionLabelAdd(u []uint64) *SopStageUpdate {
- ssu.mutation.SetActionLabelAdd(u)
- return ssu
- }
- // AppendActionLabelAdd appends u to the "action_label_add" field.
- func (ssu *SopStageUpdate) AppendActionLabelAdd(u []uint64) *SopStageUpdate {
- ssu.mutation.AppendActionLabelAdd(u)
- return ssu
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (ssu *SopStageUpdate) ClearActionLabelAdd() *SopStageUpdate {
- ssu.mutation.ClearActionLabelAdd()
- return ssu
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (ssu *SopStageUpdate) SetActionLabelDel(u []uint64) *SopStageUpdate {
- ssu.mutation.SetActionLabelDel(u)
- return ssu
- }
- // AppendActionLabelDel appends u to the "action_label_del" field.
- func (ssu *SopStageUpdate) AppendActionLabelDel(u []uint64) *SopStageUpdate {
- ssu.mutation.AppendActionLabelDel(u)
- return ssu
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (ssu *SopStageUpdate) ClearActionLabelDel() *SopStageUpdate {
- ssu.mutation.ClearActionLabelDel()
- return ssu
- }
- // SetActionForward sets the "action_forward" field.
- func (ssu *SopStageUpdate) SetActionForward(ctf *custom_types.ActionForward) *SopStageUpdate {
- ssu.mutation.SetActionForward(ctf)
- return ssu
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (ssu *SopStageUpdate) ClearActionForward() *SopStageUpdate {
- ssu.mutation.ClearActionForward()
- return ssu
- }
- // SetIndexSort sets the "index_sort" field.
- func (ssu *SopStageUpdate) SetIndexSort(i int) *SopStageUpdate {
- ssu.mutation.ResetIndexSort()
- ssu.mutation.SetIndexSort(i)
- return ssu
- }
- // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
- func (ssu *SopStageUpdate) SetNillableIndexSort(i *int) *SopStageUpdate {
- if i != nil {
- ssu.SetIndexSort(*i)
- }
- return ssu
- }
- // AddIndexSort adds i to the "index_sort" field.
- func (ssu *SopStageUpdate) AddIndexSort(i int) *SopStageUpdate {
- ssu.mutation.AddIndexSort(i)
- return ssu
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (ssu *SopStageUpdate) ClearIndexSort() *SopStageUpdate {
- ssu.mutation.ClearIndexSort()
- return ssu
- }
- // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
- func (ssu *SopStageUpdate) SetSopTaskID(id uint64) *SopStageUpdate {
- ssu.mutation.SetSopTaskID(id)
- return ssu
- }
- // SetSopTask sets the "sop_task" edge to the SopTask entity.
- func (ssu *SopStageUpdate) SetSopTask(s *SopTask) *SopStageUpdate {
- return ssu.SetSopTaskID(s.ID)
- }
- // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
- func (ssu *SopStageUpdate) AddStageNodeIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.AddStageNodeIDs(ids...)
- return ssu
- }
- // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
- func (ssu *SopStageUpdate) AddStageNodes(s ...*SopNode) *SopStageUpdate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssu.AddStageNodeIDs(ids...)
- }
- // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
- func (ssu *SopStageUpdate) AddStageMessageIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.AddStageMessageIDs(ids...)
- return ssu
- }
- // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
- func (ssu *SopStageUpdate) AddStageMessages(m ...*MessageRecords) *SopStageUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssu.AddStageMessageIDs(ids...)
- }
- // Mutation returns the SopStageMutation object of the builder.
- func (ssu *SopStageUpdate) Mutation() *SopStageMutation {
- return ssu.mutation
- }
- // ClearSopTask clears the "sop_task" edge to the SopTask entity.
- func (ssu *SopStageUpdate) ClearSopTask() *SopStageUpdate {
- ssu.mutation.ClearSopTask()
- return ssu
- }
- // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
- func (ssu *SopStageUpdate) ClearStageNodes() *SopStageUpdate {
- ssu.mutation.ClearStageNodes()
- return ssu
- }
- // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
- func (ssu *SopStageUpdate) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.RemoveStageNodeIDs(ids...)
- return ssu
- }
- // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
- func (ssu *SopStageUpdate) RemoveStageNodes(s ...*SopNode) *SopStageUpdate {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssu.RemoveStageNodeIDs(ids...)
- }
- // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
- func (ssu *SopStageUpdate) ClearStageMessages() *SopStageUpdate {
- ssu.mutation.ClearStageMessages()
- return ssu
- }
- // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
- func (ssu *SopStageUpdate) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdate {
- ssu.mutation.RemoveStageMessageIDs(ids...)
- return ssu
- }
- // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
- func (ssu *SopStageUpdate) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssu.RemoveStageMessageIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (ssu *SopStageUpdate) Save(ctx context.Context) (int, error) {
- if err := ssu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, ssu.sqlSave, ssu.mutation, ssu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ssu *SopStageUpdate) SaveX(ctx context.Context) int {
- affected, err := ssu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (ssu *SopStageUpdate) Exec(ctx context.Context) error {
- _, err := ssu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ssu *SopStageUpdate) ExecX(ctx context.Context) {
- if err := ssu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ssu *SopStageUpdate) defaults() error {
- if _, ok := ssu.mutation.UpdatedAt(); !ok {
- if sopstage.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.UpdateDefaultUpdatedAt()
- ssu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ssu *SopStageUpdate) check() error {
- if _, ok := ssu.mutation.SopTaskID(); ssu.mutation.SopTaskCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
- }
- return nil
- }
- func (ssu *SopStageUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := ssu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
- if ps := ssu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := ssu.mutation.UpdatedAt(); ok {
- _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := ssu.mutation.Status(); ok {
- _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := ssu.mutation.AddedStatus(); ok {
- _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if ssu.mutation.StatusCleared() {
- _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
- }
- if value, ok := ssu.mutation.DeletedAt(); ok {
- _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
- }
- if ssu.mutation.DeletedAtCleared() {
- _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := ssu.mutation.Name(); ok {
- _spec.SetField(sopstage.FieldName, field.TypeString, value)
- }
- if value, ok := ssu.mutation.ConditionType(); ok {
- _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedConditionType(); ok {
- _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.ConditionOperator(); ok {
- _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedConditionOperator(); ok {
- _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.ConditionList(); ok {
- _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedConditionList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldConditionList, value)
- })
- }
- if value, ok := ssu.mutation.ActionMessage(); ok {
- _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedActionMessage(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionMessage, value)
- })
- }
- if ssu.mutation.ActionMessageCleared() {
- _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
- }
- if value, ok := ssu.mutation.ActionLabelAdd(); ok {
- _spec.SetField(sopstage.FieldActionLabelAdd, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedActionLabelAdd(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabelAdd, value)
- })
- }
- if ssu.mutation.ActionLabelAddCleared() {
- _spec.ClearField(sopstage.FieldActionLabelAdd, field.TypeJSON)
- }
- if value, ok := ssu.mutation.ActionLabelDel(); ok {
- _spec.SetField(sopstage.FieldActionLabelDel, field.TypeJSON, value)
- }
- if value, ok := ssu.mutation.AppendedActionLabelDel(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabelDel, value)
- })
- }
- if ssu.mutation.ActionLabelDelCleared() {
- _spec.ClearField(sopstage.FieldActionLabelDel, field.TypeJSON)
- }
- if value, ok := ssu.mutation.ActionForward(); ok {
- _spec.SetField(sopstage.FieldActionForward, field.TypeJSON, value)
- }
- if ssu.mutation.ActionForwardCleared() {
- _spec.ClearField(sopstage.FieldActionForward, field.TypeJSON)
- }
- if value, ok := ssu.mutation.IndexSort(); ok {
- _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if value, ok := ssu.mutation.AddedIndexSort(); ok {
- _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if ssu.mutation.IndexSortCleared() {
- _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
- }
- if ssu.mutation.SopTaskCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.SopTaskIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssu.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssu.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.StageNodesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssu.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssu.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssu.mutation.StageMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, ssu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{sopstage.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- ssu.mutation.done = true
- return n, nil
- }
- // SopStageUpdateOne is the builder for updating a single SopStage entity.
- type SopStageUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *SopStageMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ssuo *SopStageUpdateOne) SetUpdatedAt(t time.Time) *SopStageUpdateOne {
- ssuo.mutation.SetUpdatedAt(t)
- return ssuo
- }
- // SetStatus sets the "status" field.
- func (ssuo *SopStageUpdateOne) SetStatus(u uint8) *SopStageUpdateOne {
- ssuo.mutation.ResetStatus()
- ssuo.mutation.SetStatus(u)
- return ssuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableStatus(u *uint8) *SopStageUpdateOne {
- if u != nil {
- ssuo.SetStatus(*u)
- }
- return ssuo
- }
- // AddStatus adds u to the "status" field.
- func (ssuo *SopStageUpdateOne) AddStatus(u int8) *SopStageUpdateOne {
- ssuo.mutation.AddStatus(u)
- return ssuo
- }
- // ClearStatus clears the value of the "status" field.
- func (ssuo *SopStageUpdateOne) ClearStatus() *SopStageUpdateOne {
- ssuo.mutation.ClearStatus()
- return ssuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ssuo *SopStageUpdateOne) SetDeletedAt(t time.Time) *SopStageUpdateOne {
- ssuo.mutation.SetDeletedAt(t)
- return ssuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableDeletedAt(t *time.Time) *SopStageUpdateOne {
- if t != nil {
- ssuo.SetDeletedAt(*t)
- }
- return ssuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (ssuo *SopStageUpdateOne) ClearDeletedAt() *SopStageUpdateOne {
- ssuo.mutation.ClearDeletedAt()
- return ssuo
- }
- // SetTaskID sets the "task_id" field.
- func (ssuo *SopStageUpdateOne) SetTaskID(u uint64) *SopStageUpdateOne {
- ssuo.mutation.SetTaskID(u)
- return ssuo
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableTaskID(u *uint64) *SopStageUpdateOne {
- if u != nil {
- ssuo.SetTaskID(*u)
- }
- return ssuo
- }
- // SetName sets the "name" field.
- func (ssuo *SopStageUpdateOne) SetName(s string) *SopStageUpdateOne {
- ssuo.mutation.SetName(s)
- return ssuo
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableName(s *string) *SopStageUpdateOne {
- if s != nil {
- ssuo.SetName(*s)
- }
- return ssuo
- }
- // SetConditionType sets the "condition_type" field.
- func (ssuo *SopStageUpdateOne) SetConditionType(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetConditionType()
- ssuo.mutation.SetConditionType(i)
- return ssuo
- }
- // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableConditionType(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetConditionType(*i)
- }
- return ssuo
- }
- // AddConditionType adds i to the "condition_type" field.
- func (ssuo *SopStageUpdateOne) AddConditionType(i int) *SopStageUpdateOne {
- ssuo.mutation.AddConditionType(i)
- return ssuo
- }
- // SetConditionOperator sets the "condition_operator" field.
- func (ssuo *SopStageUpdateOne) SetConditionOperator(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetConditionOperator()
- ssuo.mutation.SetConditionOperator(i)
- return ssuo
- }
- // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableConditionOperator(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetConditionOperator(*i)
- }
- return ssuo
- }
- // AddConditionOperator adds i to the "condition_operator" field.
- func (ssuo *SopStageUpdateOne) AddConditionOperator(i int) *SopStageUpdateOne {
- ssuo.mutation.AddConditionOperator(i)
- return ssuo
- }
- // SetConditionList sets the "condition_list" field.
- func (ssuo *SopStageUpdateOne) SetConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
- ssuo.mutation.SetConditionList(ct)
- return ssuo
- }
- // AppendConditionList appends ct to the "condition_list" field.
- func (ssuo *SopStageUpdateOne) AppendConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
- ssuo.mutation.AppendConditionList(ct)
- return ssuo
- }
- // SetActionMessage sets the "action_message" field.
- func (ssuo *SopStageUpdateOne) SetActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
- ssuo.mutation.SetActionMessage(ct)
- return ssuo
- }
- // AppendActionMessage appends ct to the "action_message" field.
- func (ssuo *SopStageUpdateOne) AppendActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
- ssuo.mutation.AppendActionMessage(ct)
- return ssuo
- }
- // ClearActionMessage clears the value of the "action_message" field.
- func (ssuo *SopStageUpdateOne) ClearActionMessage() *SopStageUpdateOne {
- ssuo.mutation.ClearActionMessage()
- return ssuo
- }
- // SetActionLabelAdd sets the "action_label_add" field.
- func (ssuo *SopStageUpdateOne) SetActionLabelAdd(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.SetActionLabelAdd(u)
- return ssuo
- }
- // AppendActionLabelAdd appends u to the "action_label_add" field.
- func (ssuo *SopStageUpdateOne) AppendActionLabelAdd(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.AppendActionLabelAdd(u)
- return ssuo
- }
- // ClearActionLabelAdd clears the value of the "action_label_add" field.
- func (ssuo *SopStageUpdateOne) ClearActionLabelAdd() *SopStageUpdateOne {
- ssuo.mutation.ClearActionLabelAdd()
- return ssuo
- }
- // SetActionLabelDel sets the "action_label_del" field.
- func (ssuo *SopStageUpdateOne) SetActionLabelDel(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.SetActionLabelDel(u)
- return ssuo
- }
- // AppendActionLabelDel appends u to the "action_label_del" field.
- func (ssuo *SopStageUpdateOne) AppendActionLabelDel(u []uint64) *SopStageUpdateOne {
- ssuo.mutation.AppendActionLabelDel(u)
- return ssuo
- }
- // ClearActionLabelDel clears the value of the "action_label_del" field.
- func (ssuo *SopStageUpdateOne) ClearActionLabelDel() *SopStageUpdateOne {
- ssuo.mutation.ClearActionLabelDel()
- return ssuo
- }
- // SetActionForward sets the "action_forward" field.
- func (ssuo *SopStageUpdateOne) SetActionForward(ctf *custom_types.ActionForward) *SopStageUpdateOne {
- ssuo.mutation.SetActionForward(ctf)
- return ssuo
- }
- // ClearActionForward clears the value of the "action_forward" field.
- func (ssuo *SopStageUpdateOne) ClearActionForward() *SopStageUpdateOne {
- ssuo.mutation.ClearActionForward()
- return ssuo
- }
- // SetIndexSort sets the "index_sort" field.
- func (ssuo *SopStageUpdateOne) SetIndexSort(i int) *SopStageUpdateOne {
- ssuo.mutation.ResetIndexSort()
- ssuo.mutation.SetIndexSort(i)
- return ssuo
- }
- // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
- func (ssuo *SopStageUpdateOne) SetNillableIndexSort(i *int) *SopStageUpdateOne {
- if i != nil {
- ssuo.SetIndexSort(*i)
- }
- return ssuo
- }
- // AddIndexSort adds i to the "index_sort" field.
- func (ssuo *SopStageUpdateOne) AddIndexSort(i int) *SopStageUpdateOne {
- ssuo.mutation.AddIndexSort(i)
- return ssuo
- }
- // ClearIndexSort clears the value of the "index_sort" field.
- func (ssuo *SopStageUpdateOne) ClearIndexSort() *SopStageUpdateOne {
- ssuo.mutation.ClearIndexSort()
- return ssuo
- }
- // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
- func (ssuo *SopStageUpdateOne) SetSopTaskID(id uint64) *SopStageUpdateOne {
- ssuo.mutation.SetSopTaskID(id)
- return ssuo
- }
- // SetSopTask sets the "sop_task" edge to the SopTask entity.
- func (ssuo *SopStageUpdateOne) SetSopTask(s *SopTask) *SopStageUpdateOne {
- return ssuo.SetSopTaskID(s.ID)
- }
- // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
- func (ssuo *SopStageUpdateOne) AddStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.AddStageNodeIDs(ids...)
- return ssuo
- }
- // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
- func (ssuo *SopStageUpdateOne) AddStageNodes(s ...*SopNode) *SopStageUpdateOne {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssuo.AddStageNodeIDs(ids...)
- }
- // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
- func (ssuo *SopStageUpdateOne) AddStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.AddStageMessageIDs(ids...)
- return ssuo
- }
- // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
- func (ssuo *SopStageUpdateOne) AddStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssuo.AddStageMessageIDs(ids...)
- }
- // Mutation returns the SopStageMutation object of the builder.
- func (ssuo *SopStageUpdateOne) Mutation() *SopStageMutation {
- return ssuo.mutation
- }
- // ClearSopTask clears the "sop_task" edge to the SopTask entity.
- func (ssuo *SopStageUpdateOne) ClearSopTask() *SopStageUpdateOne {
- ssuo.mutation.ClearSopTask()
- return ssuo
- }
- // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
- func (ssuo *SopStageUpdateOne) ClearStageNodes() *SopStageUpdateOne {
- ssuo.mutation.ClearStageNodes()
- return ssuo
- }
- // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
- func (ssuo *SopStageUpdateOne) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.RemoveStageNodeIDs(ids...)
- return ssuo
- }
- // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
- func (ssuo *SopStageUpdateOne) RemoveStageNodes(s ...*SopNode) *SopStageUpdateOne {
- ids := make([]uint64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return ssuo.RemoveStageNodeIDs(ids...)
- }
- // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
- func (ssuo *SopStageUpdateOne) ClearStageMessages() *SopStageUpdateOne {
- ssuo.mutation.ClearStageMessages()
- return ssuo
- }
- // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
- func (ssuo *SopStageUpdateOne) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
- ssuo.mutation.RemoveStageMessageIDs(ids...)
- return ssuo
- }
- // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
- func (ssuo *SopStageUpdateOne) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return ssuo.RemoveStageMessageIDs(ids...)
- }
- // Where appends a list predicates to the SopStageUpdate builder.
- func (ssuo *SopStageUpdateOne) Where(ps ...predicate.SopStage) *SopStageUpdateOne {
- ssuo.mutation.Where(ps...)
- return ssuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (ssuo *SopStageUpdateOne) Select(field string, fields ...string) *SopStageUpdateOne {
- ssuo.fields = append([]string{field}, fields...)
- return ssuo
- }
- // Save executes the query and returns the updated SopStage entity.
- func (ssuo *SopStageUpdateOne) Save(ctx context.Context) (*SopStage, error) {
- if err := ssuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ssuo.sqlSave, ssuo.mutation, ssuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ssuo *SopStageUpdateOne) SaveX(ctx context.Context) *SopStage {
- node, err := ssuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (ssuo *SopStageUpdateOne) Exec(ctx context.Context) error {
- _, err := ssuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ssuo *SopStageUpdateOne) ExecX(ctx context.Context) {
- if err := ssuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ssuo *SopStageUpdateOne) defaults() error {
- if _, ok := ssuo.mutation.UpdatedAt(); !ok {
- if sopstage.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized sopstage.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := sopstage.UpdateDefaultUpdatedAt()
- ssuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ssuo *SopStageUpdateOne) check() error {
- if _, ok := ssuo.mutation.SopTaskID(); ssuo.mutation.SopTaskCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
- }
- return nil
- }
- func (ssuo *SopStageUpdateOne) sqlSave(ctx context.Context) (_node *SopStage, err error) {
- if err := ssuo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
- id, ok := ssuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SopStage.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := ssuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, sopstage.FieldID)
- for _, f := range fields {
- if !sopstage.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != sopstage.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := ssuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := ssuo.mutation.UpdatedAt(); ok {
- _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := ssuo.mutation.Status(); ok {
- _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := ssuo.mutation.AddedStatus(); ok {
- _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
- }
- if ssuo.mutation.StatusCleared() {
- _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
- }
- if value, ok := ssuo.mutation.DeletedAt(); ok {
- _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
- }
- if ssuo.mutation.DeletedAtCleared() {
- _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := ssuo.mutation.Name(); ok {
- _spec.SetField(sopstage.FieldName, field.TypeString, value)
- }
- if value, ok := ssuo.mutation.ConditionType(); ok {
- _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedConditionType(); ok {
- _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.ConditionOperator(); ok {
- _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedConditionOperator(); ok {
- _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.ConditionList(); ok {
- _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedConditionList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldConditionList, value)
- })
- }
- if value, ok := ssuo.mutation.ActionMessage(); ok {
- _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedActionMessage(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionMessage, value)
- })
- }
- if ssuo.mutation.ActionMessageCleared() {
- _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.ActionLabelAdd(); ok {
- _spec.SetField(sopstage.FieldActionLabelAdd, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedActionLabelAdd(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabelAdd, value)
- })
- }
- if ssuo.mutation.ActionLabelAddCleared() {
- _spec.ClearField(sopstage.FieldActionLabelAdd, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.ActionLabelDel(); ok {
- _spec.SetField(sopstage.FieldActionLabelDel, field.TypeJSON, value)
- }
- if value, ok := ssuo.mutation.AppendedActionLabelDel(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, sopstage.FieldActionLabelDel, value)
- })
- }
- if ssuo.mutation.ActionLabelDelCleared() {
- _spec.ClearField(sopstage.FieldActionLabelDel, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.ActionForward(); ok {
- _spec.SetField(sopstage.FieldActionForward, field.TypeJSON, value)
- }
- if ssuo.mutation.ActionForwardCleared() {
- _spec.ClearField(sopstage.FieldActionForward, field.TypeJSON)
- }
- if value, ok := ssuo.mutation.IndexSort(); ok {
- _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if value, ok := ssuo.mutation.AddedIndexSort(); ok {
- _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
- }
- if ssuo.mutation.IndexSortCleared() {
- _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
- }
- if ssuo.mutation.SopTaskCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.SopTaskIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: sopstage.SopTaskTable,
- Columns: []string{sopstage.SopTaskColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssuo.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssuo.mutation.StageNodesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.StageNodesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageNodesTable,
- Columns: []string{sopstage.StageNodesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if ssuo.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssuo.mutation.StageMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := ssuo.mutation.StageMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: sopstage.StageMessagesTable,
- Columns: []string{sopstage.StageMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &SopStage{config: ssuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, ssuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{sopstage.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- ssuo.mutation.done = true
- return _node, nil
- }
|