sopstage_update.go 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/dialect/sql/sqljson"
  11. "entgo.io/ent/schema/field"
  12. "github.com/suyuan32/simple-admin-job/ent/custom_types"
  13. "github.com/suyuan32/simple-admin-job/ent/messagerecords"
  14. "github.com/suyuan32/simple-admin-job/ent/predicate"
  15. "github.com/suyuan32/simple-admin-job/ent/sopnode"
  16. "github.com/suyuan32/simple-admin-job/ent/sopstage"
  17. "github.com/suyuan32/simple-admin-job/ent/soptask"
  18. )
  19. // SopStageUpdate is the builder for updating SopStage entities.
  20. type SopStageUpdate struct {
  21. config
  22. hooks []Hook
  23. mutation *SopStageMutation
  24. }
  25. // Where appends a list predicates to the SopStageUpdate builder.
  26. func (ssu *SopStageUpdate) Where(ps ...predicate.SopStage) *SopStageUpdate {
  27. ssu.mutation.Where(ps...)
  28. return ssu
  29. }
  30. // SetUpdatedAt sets the "updated_at" field.
  31. func (ssu *SopStageUpdate) SetUpdatedAt(t time.Time) *SopStageUpdate {
  32. ssu.mutation.SetUpdatedAt(t)
  33. return ssu
  34. }
  35. // SetStatus sets the "status" field.
  36. func (ssu *SopStageUpdate) SetStatus(u uint8) *SopStageUpdate {
  37. ssu.mutation.ResetStatus()
  38. ssu.mutation.SetStatus(u)
  39. return ssu
  40. }
  41. // SetNillableStatus sets the "status" field if the given value is not nil.
  42. func (ssu *SopStageUpdate) SetNillableStatus(u *uint8) *SopStageUpdate {
  43. if u != nil {
  44. ssu.SetStatus(*u)
  45. }
  46. return ssu
  47. }
  48. // AddStatus adds u to the "status" field.
  49. func (ssu *SopStageUpdate) AddStatus(u int8) *SopStageUpdate {
  50. ssu.mutation.AddStatus(u)
  51. return ssu
  52. }
  53. // ClearStatus clears the value of the "status" field.
  54. func (ssu *SopStageUpdate) ClearStatus() *SopStageUpdate {
  55. ssu.mutation.ClearStatus()
  56. return ssu
  57. }
  58. // SetTaskID sets the "task_id" field.
  59. func (ssu *SopStageUpdate) SetTaskID(u uint64) *SopStageUpdate {
  60. ssu.mutation.SetTaskID(u)
  61. return ssu
  62. }
  63. // SetNillableTaskID sets the "task_id" field if the given value is not nil.
  64. func (ssu *SopStageUpdate) SetNillableTaskID(u *uint64) *SopStageUpdate {
  65. if u != nil {
  66. ssu.SetTaskID(*u)
  67. }
  68. return ssu
  69. }
  70. // SetName sets the "name" field.
  71. func (ssu *SopStageUpdate) SetName(s string) *SopStageUpdate {
  72. ssu.mutation.SetName(s)
  73. return ssu
  74. }
  75. // SetNillableName sets the "name" field if the given value is not nil.
  76. func (ssu *SopStageUpdate) SetNillableName(s *string) *SopStageUpdate {
  77. if s != nil {
  78. ssu.SetName(*s)
  79. }
  80. return ssu
  81. }
  82. // SetConditionType sets the "condition_type" field.
  83. func (ssu *SopStageUpdate) SetConditionType(i int) *SopStageUpdate {
  84. ssu.mutation.ResetConditionType()
  85. ssu.mutation.SetConditionType(i)
  86. return ssu
  87. }
  88. // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
  89. func (ssu *SopStageUpdate) SetNillableConditionType(i *int) *SopStageUpdate {
  90. if i != nil {
  91. ssu.SetConditionType(*i)
  92. }
  93. return ssu
  94. }
  95. // AddConditionType adds i to the "condition_type" field.
  96. func (ssu *SopStageUpdate) AddConditionType(i int) *SopStageUpdate {
  97. ssu.mutation.AddConditionType(i)
  98. return ssu
  99. }
  100. // SetConditionOperator sets the "condition_operator" field.
  101. func (ssu *SopStageUpdate) SetConditionOperator(i int) *SopStageUpdate {
  102. ssu.mutation.ResetConditionOperator()
  103. ssu.mutation.SetConditionOperator(i)
  104. return ssu
  105. }
  106. // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
  107. func (ssu *SopStageUpdate) SetNillableConditionOperator(i *int) *SopStageUpdate {
  108. if i != nil {
  109. ssu.SetConditionOperator(*i)
  110. }
  111. return ssu
  112. }
  113. // AddConditionOperator adds i to the "condition_operator" field.
  114. func (ssu *SopStageUpdate) AddConditionOperator(i int) *SopStageUpdate {
  115. ssu.mutation.AddConditionOperator(i)
  116. return ssu
  117. }
  118. // SetConditionList sets the "condition_list" field.
  119. func (ssu *SopStageUpdate) SetConditionList(ct []custom_types.Condition) *SopStageUpdate {
  120. ssu.mutation.SetConditionList(ct)
  121. return ssu
  122. }
  123. // AppendConditionList appends ct to the "condition_list" field.
  124. func (ssu *SopStageUpdate) AppendConditionList(ct []custom_types.Condition) *SopStageUpdate {
  125. ssu.mutation.AppendConditionList(ct)
  126. return ssu
  127. }
  128. // SetActionMessage sets the "action_message" field.
  129. func (ssu *SopStageUpdate) SetActionMessage(ct []custom_types.Action) *SopStageUpdate {
  130. ssu.mutation.SetActionMessage(ct)
  131. return ssu
  132. }
  133. // AppendActionMessage appends ct to the "action_message" field.
  134. func (ssu *SopStageUpdate) AppendActionMessage(ct []custom_types.Action) *SopStageUpdate {
  135. ssu.mutation.AppendActionMessage(ct)
  136. return ssu
  137. }
  138. // ClearActionMessage clears the value of the "action_message" field.
  139. func (ssu *SopStageUpdate) ClearActionMessage() *SopStageUpdate {
  140. ssu.mutation.ClearActionMessage()
  141. return ssu
  142. }
  143. // SetActionLabel sets the "action_label" field.
  144. func (ssu *SopStageUpdate) SetActionLabel(u []uint64) *SopStageUpdate {
  145. ssu.mutation.SetActionLabel(u)
  146. return ssu
  147. }
  148. // AppendActionLabel appends u to the "action_label" field.
  149. func (ssu *SopStageUpdate) AppendActionLabel(u []uint64) *SopStageUpdate {
  150. ssu.mutation.AppendActionLabel(u)
  151. return ssu
  152. }
  153. // ClearActionLabel clears the value of the "action_label" field.
  154. func (ssu *SopStageUpdate) ClearActionLabel() *SopStageUpdate {
  155. ssu.mutation.ClearActionLabel()
  156. return ssu
  157. }
  158. // SetIndexSort sets the "index_sort" field.
  159. func (ssu *SopStageUpdate) SetIndexSort(i int) *SopStageUpdate {
  160. ssu.mutation.ResetIndexSort()
  161. ssu.mutation.SetIndexSort(i)
  162. return ssu
  163. }
  164. // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
  165. func (ssu *SopStageUpdate) SetNillableIndexSort(i *int) *SopStageUpdate {
  166. if i != nil {
  167. ssu.SetIndexSort(*i)
  168. }
  169. return ssu
  170. }
  171. // AddIndexSort adds i to the "index_sort" field.
  172. func (ssu *SopStageUpdate) AddIndexSort(i int) *SopStageUpdate {
  173. ssu.mutation.AddIndexSort(i)
  174. return ssu
  175. }
  176. // ClearIndexSort clears the value of the "index_sort" field.
  177. func (ssu *SopStageUpdate) ClearIndexSort() *SopStageUpdate {
  178. ssu.mutation.ClearIndexSort()
  179. return ssu
  180. }
  181. // SetDeletedAt sets the "deleted_at" field.
  182. func (ssu *SopStageUpdate) SetDeletedAt(t time.Time) *SopStageUpdate {
  183. ssu.mutation.SetDeletedAt(t)
  184. return ssu
  185. }
  186. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  187. func (ssu *SopStageUpdate) SetNillableDeletedAt(t *time.Time) *SopStageUpdate {
  188. if t != nil {
  189. ssu.SetDeletedAt(*t)
  190. }
  191. return ssu
  192. }
  193. // ClearDeletedAt clears the value of the "deleted_at" field.
  194. func (ssu *SopStageUpdate) ClearDeletedAt() *SopStageUpdate {
  195. ssu.mutation.ClearDeletedAt()
  196. return ssu
  197. }
  198. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
  199. func (ssu *SopStageUpdate) SetSopTaskID(id uint64) *SopStageUpdate {
  200. ssu.mutation.SetSopTaskID(id)
  201. return ssu
  202. }
  203. // SetSopTask sets the "sop_task" edge to the SopTask entity.
  204. func (ssu *SopStageUpdate) SetSopTask(s *SopTask) *SopStageUpdate {
  205. return ssu.SetSopTaskID(s.ID)
  206. }
  207. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
  208. func (ssu *SopStageUpdate) AddStageNodeIDs(ids ...uint64) *SopStageUpdate {
  209. ssu.mutation.AddStageNodeIDs(ids...)
  210. return ssu
  211. }
  212. // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
  213. func (ssu *SopStageUpdate) AddStageNodes(s ...*SopNode) *SopStageUpdate {
  214. ids := make([]uint64, len(s))
  215. for i := range s {
  216. ids[i] = s[i].ID
  217. }
  218. return ssu.AddStageNodeIDs(ids...)
  219. }
  220. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
  221. func (ssu *SopStageUpdate) AddStageMessageIDs(ids ...uint64) *SopStageUpdate {
  222. ssu.mutation.AddStageMessageIDs(ids...)
  223. return ssu
  224. }
  225. // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
  226. func (ssu *SopStageUpdate) AddStageMessages(m ...*MessageRecords) *SopStageUpdate {
  227. ids := make([]uint64, len(m))
  228. for i := range m {
  229. ids[i] = m[i].ID
  230. }
  231. return ssu.AddStageMessageIDs(ids...)
  232. }
  233. // Mutation returns the SopStageMutation object of the builder.
  234. func (ssu *SopStageUpdate) Mutation() *SopStageMutation {
  235. return ssu.mutation
  236. }
  237. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  238. func (ssu *SopStageUpdate) ClearSopTask() *SopStageUpdate {
  239. ssu.mutation.ClearSopTask()
  240. return ssu
  241. }
  242. // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
  243. func (ssu *SopStageUpdate) ClearStageNodes() *SopStageUpdate {
  244. ssu.mutation.ClearStageNodes()
  245. return ssu
  246. }
  247. // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
  248. func (ssu *SopStageUpdate) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdate {
  249. ssu.mutation.RemoveStageNodeIDs(ids...)
  250. return ssu
  251. }
  252. // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
  253. func (ssu *SopStageUpdate) RemoveStageNodes(s ...*SopNode) *SopStageUpdate {
  254. ids := make([]uint64, len(s))
  255. for i := range s {
  256. ids[i] = s[i].ID
  257. }
  258. return ssu.RemoveStageNodeIDs(ids...)
  259. }
  260. // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
  261. func (ssu *SopStageUpdate) ClearStageMessages() *SopStageUpdate {
  262. ssu.mutation.ClearStageMessages()
  263. return ssu
  264. }
  265. // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
  266. func (ssu *SopStageUpdate) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdate {
  267. ssu.mutation.RemoveStageMessageIDs(ids...)
  268. return ssu
  269. }
  270. // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
  271. func (ssu *SopStageUpdate) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdate {
  272. ids := make([]uint64, len(m))
  273. for i := range m {
  274. ids[i] = m[i].ID
  275. }
  276. return ssu.RemoveStageMessageIDs(ids...)
  277. }
  278. // Save executes the query and returns the number of nodes affected by the update operation.
  279. func (ssu *SopStageUpdate) Save(ctx context.Context) (int, error) {
  280. ssu.defaults()
  281. return withHooks(ctx, ssu.sqlSave, ssu.mutation, ssu.hooks)
  282. }
  283. // SaveX is like Save, but panics if an error occurs.
  284. func (ssu *SopStageUpdate) SaveX(ctx context.Context) int {
  285. affected, err := ssu.Save(ctx)
  286. if err != nil {
  287. panic(err)
  288. }
  289. return affected
  290. }
  291. // Exec executes the query.
  292. func (ssu *SopStageUpdate) Exec(ctx context.Context) error {
  293. _, err := ssu.Save(ctx)
  294. return err
  295. }
  296. // ExecX is like Exec, but panics if an error occurs.
  297. func (ssu *SopStageUpdate) ExecX(ctx context.Context) {
  298. if err := ssu.Exec(ctx); err != nil {
  299. panic(err)
  300. }
  301. }
  302. // defaults sets the default values of the builder before save.
  303. func (ssu *SopStageUpdate) defaults() {
  304. if _, ok := ssu.mutation.UpdatedAt(); !ok {
  305. v := sopstage.UpdateDefaultUpdatedAt()
  306. ssu.mutation.SetUpdatedAt(v)
  307. }
  308. }
  309. // check runs all checks and user-defined validators on the builder.
  310. func (ssu *SopStageUpdate) check() error {
  311. if _, ok := ssu.mutation.SopTaskID(); ssu.mutation.SopTaskCleared() && !ok {
  312. return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
  313. }
  314. return nil
  315. }
  316. func (ssu *SopStageUpdate) sqlSave(ctx context.Context) (n int, err error) {
  317. if err := ssu.check(); err != nil {
  318. return n, err
  319. }
  320. _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
  321. if ps := ssu.mutation.predicates; len(ps) > 0 {
  322. _spec.Predicate = func(selector *sql.Selector) {
  323. for i := range ps {
  324. ps[i](selector)
  325. }
  326. }
  327. }
  328. if value, ok := ssu.mutation.UpdatedAt(); ok {
  329. _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
  330. }
  331. if value, ok := ssu.mutation.Status(); ok {
  332. _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
  333. }
  334. if value, ok := ssu.mutation.AddedStatus(); ok {
  335. _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
  336. }
  337. if ssu.mutation.StatusCleared() {
  338. _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
  339. }
  340. if value, ok := ssu.mutation.Name(); ok {
  341. _spec.SetField(sopstage.FieldName, field.TypeString, value)
  342. }
  343. if value, ok := ssu.mutation.ConditionType(); ok {
  344. _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
  345. }
  346. if value, ok := ssu.mutation.AddedConditionType(); ok {
  347. _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
  348. }
  349. if value, ok := ssu.mutation.ConditionOperator(); ok {
  350. _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
  351. }
  352. if value, ok := ssu.mutation.AddedConditionOperator(); ok {
  353. _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
  354. }
  355. if value, ok := ssu.mutation.ConditionList(); ok {
  356. _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
  357. }
  358. if value, ok := ssu.mutation.AppendedConditionList(); ok {
  359. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  360. sqljson.Append(u, sopstage.FieldConditionList, value)
  361. })
  362. }
  363. if value, ok := ssu.mutation.ActionMessage(); ok {
  364. _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
  365. }
  366. if value, ok := ssu.mutation.AppendedActionMessage(); ok {
  367. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  368. sqljson.Append(u, sopstage.FieldActionMessage, value)
  369. })
  370. }
  371. if ssu.mutation.ActionMessageCleared() {
  372. _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
  373. }
  374. if value, ok := ssu.mutation.ActionLabel(); ok {
  375. _spec.SetField(sopstage.FieldActionLabel, field.TypeJSON, value)
  376. }
  377. if value, ok := ssu.mutation.AppendedActionLabel(); ok {
  378. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  379. sqljson.Append(u, sopstage.FieldActionLabel, value)
  380. })
  381. }
  382. if ssu.mutation.ActionLabelCleared() {
  383. _spec.ClearField(sopstage.FieldActionLabel, field.TypeJSON)
  384. }
  385. if value, ok := ssu.mutation.IndexSort(); ok {
  386. _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
  387. }
  388. if value, ok := ssu.mutation.AddedIndexSort(); ok {
  389. _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
  390. }
  391. if ssu.mutation.IndexSortCleared() {
  392. _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
  393. }
  394. if value, ok := ssu.mutation.DeletedAt(); ok {
  395. _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
  396. }
  397. if ssu.mutation.DeletedAtCleared() {
  398. _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
  399. }
  400. if ssu.mutation.SopTaskCleared() {
  401. edge := &sqlgraph.EdgeSpec{
  402. Rel: sqlgraph.M2O,
  403. Inverse: true,
  404. Table: sopstage.SopTaskTable,
  405. Columns: []string{sopstage.SopTaskColumn},
  406. Bidi: false,
  407. Target: &sqlgraph.EdgeTarget{
  408. IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
  409. },
  410. }
  411. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  412. }
  413. if nodes := ssu.mutation.SopTaskIDs(); len(nodes) > 0 {
  414. edge := &sqlgraph.EdgeSpec{
  415. Rel: sqlgraph.M2O,
  416. Inverse: true,
  417. Table: sopstage.SopTaskTable,
  418. Columns: []string{sopstage.SopTaskColumn},
  419. Bidi: false,
  420. Target: &sqlgraph.EdgeTarget{
  421. IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
  422. },
  423. }
  424. for _, k := range nodes {
  425. edge.Target.Nodes = append(edge.Target.Nodes, k)
  426. }
  427. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  428. }
  429. if ssu.mutation.StageNodesCleared() {
  430. edge := &sqlgraph.EdgeSpec{
  431. Rel: sqlgraph.O2M,
  432. Inverse: false,
  433. Table: sopstage.StageNodesTable,
  434. Columns: []string{sopstage.StageNodesColumn},
  435. Bidi: false,
  436. Target: &sqlgraph.EdgeTarget{
  437. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  438. },
  439. }
  440. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  441. }
  442. if nodes := ssu.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssu.mutation.StageNodesCleared() {
  443. edge := &sqlgraph.EdgeSpec{
  444. Rel: sqlgraph.O2M,
  445. Inverse: false,
  446. Table: sopstage.StageNodesTable,
  447. Columns: []string{sopstage.StageNodesColumn},
  448. Bidi: false,
  449. Target: &sqlgraph.EdgeTarget{
  450. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  451. },
  452. }
  453. for _, k := range nodes {
  454. edge.Target.Nodes = append(edge.Target.Nodes, k)
  455. }
  456. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  457. }
  458. if nodes := ssu.mutation.StageNodesIDs(); len(nodes) > 0 {
  459. edge := &sqlgraph.EdgeSpec{
  460. Rel: sqlgraph.O2M,
  461. Inverse: false,
  462. Table: sopstage.StageNodesTable,
  463. Columns: []string{sopstage.StageNodesColumn},
  464. Bidi: false,
  465. Target: &sqlgraph.EdgeTarget{
  466. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  467. },
  468. }
  469. for _, k := range nodes {
  470. edge.Target.Nodes = append(edge.Target.Nodes, k)
  471. }
  472. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  473. }
  474. if ssu.mutation.StageMessagesCleared() {
  475. edge := &sqlgraph.EdgeSpec{
  476. Rel: sqlgraph.O2M,
  477. Inverse: false,
  478. Table: sopstage.StageMessagesTable,
  479. Columns: []string{sopstage.StageMessagesColumn},
  480. Bidi: false,
  481. Target: &sqlgraph.EdgeTarget{
  482. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  483. },
  484. }
  485. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  486. }
  487. if nodes := ssu.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssu.mutation.StageMessagesCleared() {
  488. edge := &sqlgraph.EdgeSpec{
  489. Rel: sqlgraph.O2M,
  490. Inverse: false,
  491. Table: sopstage.StageMessagesTable,
  492. Columns: []string{sopstage.StageMessagesColumn},
  493. Bidi: false,
  494. Target: &sqlgraph.EdgeTarget{
  495. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  496. },
  497. }
  498. for _, k := range nodes {
  499. edge.Target.Nodes = append(edge.Target.Nodes, k)
  500. }
  501. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  502. }
  503. if nodes := ssu.mutation.StageMessagesIDs(); len(nodes) > 0 {
  504. edge := &sqlgraph.EdgeSpec{
  505. Rel: sqlgraph.O2M,
  506. Inverse: false,
  507. Table: sopstage.StageMessagesTable,
  508. Columns: []string{sopstage.StageMessagesColumn},
  509. Bidi: false,
  510. Target: &sqlgraph.EdgeTarget{
  511. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  512. },
  513. }
  514. for _, k := range nodes {
  515. edge.Target.Nodes = append(edge.Target.Nodes, k)
  516. }
  517. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  518. }
  519. if n, err = sqlgraph.UpdateNodes(ctx, ssu.driver, _spec); err != nil {
  520. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  521. err = &NotFoundError{sopstage.Label}
  522. } else if sqlgraph.IsConstraintError(err) {
  523. err = &ConstraintError{msg: err.Error(), wrap: err}
  524. }
  525. return 0, err
  526. }
  527. ssu.mutation.done = true
  528. return n, nil
  529. }
  530. // SopStageUpdateOne is the builder for updating a single SopStage entity.
  531. type SopStageUpdateOne struct {
  532. config
  533. fields []string
  534. hooks []Hook
  535. mutation *SopStageMutation
  536. }
  537. // SetUpdatedAt sets the "updated_at" field.
  538. func (ssuo *SopStageUpdateOne) SetUpdatedAt(t time.Time) *SopStageUpdateOne {
  539. ssuo.mutation.SetUpdatedAt(t)
  540. return ssuo
  541. }
  542. // SetStatus sets the "status" field.
  543. func (ssuo *SopStageUpdateOne) SetStatus(u uint8) *SopStageUpdateOne {
  544. ssuo.mutation.ResetStatus()
  545. ssuo.mutation.SetStatus(u)
  546. return ssuo
  547. }
  548. // SetNillableStatus sets the "status" field if the given value is not nil.
  549. func (ssuo *SopStageUpdateOne) SetNillableStatus(u *uint8) *SopStageUpdateOne {
  550. if u != nil {
  551. ssuo.SetStatus(*u)
  552. }
  553. return ssuo
  554. }
  555. // AddStatus adds u to the "status" field.
  556. func (ssuo *SopStageUpdateOne) AddStatus(u int8) *SopStageUpdateOne {
  557. ssuo.mutation.AddStatus(u)
  558. return ssuo
  559. }
  560. // ClearStatus clears the value of the "status" field.
  561. func (ssuo *SopStageUpdateOne) ClearStatus() *SopStageUpdateOne {
  562. ssuo.mutation.ClearStatus()
  563. return ssuo
  564. }
  565. // SetTaskID sets the "task_id" field.
  566. func (ssuo *SopStageUpdateOne) SetTaskID(u uint64) *SopStageUpdateOne {
  567. ssuo.mutation.SetTaskID(u)
  568. return ssuo
  569. }
  570. // SetNillableTaskID sets the "task_id" field if the given value is not nil.
  571. func (ssuo *SopStageUpdateOne) SetNillableTaskID(u *uint64) *SopStageUpdateOne {
  572. if u != nil {
  573. ssuo.SetTaskID(*u)
  574. }
  575. return ssuo
  576. }
  577. // SetName sets the "name" field.
  578. func (ssuo *SopStageUpdateOne) SetName(s string) *SopStageUpdateOne {
  579. ssuo.mutation.SetName(s)
  580. return ssuo
  581. }
  582. // SetNillableName sets the "name" field if the given value is not nil.
  583. func (ssuo *SopStageUpdateOne) SetNillableName(s *string) *SopStageUpdateOne {
  584. if s != nil {
  585. ssuo.SetName(*s)
  586. }
  587. return ssuo
  588. }
  589. // SetConditionType sets the "condition_type" field.
  590. func (ssuo *SopStageUpdateOne) SetConditionType(i int) *SopStageUpdateOne {
  591. ssuo.mutation.ResetConditionType()
  592. ssuo.mutation.SetConditionType(i)
  593. return ssuo
  594. }
  595. // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
  596. func (ssuo *SopStageUpdateOne) SetNillableConditionType(i *int) *SopStageUpdateOne {
  597. if i != nil {
  598. ssuo.SetConditionType(*i)
  599. }
  600. return ssuo
  601. }
  602. // AddConditionType adds i to the "condition_type" field.
  603. func (ssuo *SopStageUpdateOne) AddConditionType(i int) *SopStageUpdateOne {
  604. ssuo.mutation.AddConditionType(i)
  605. return ssuo
  606. }
  607. // SetConditionOperator sets the "condition_operator" field.
  608. func (ssuo *SopStageUpdateOne) SetConditionOperator(i int) *SopStageUpdateOne {
  609. ssuo.mutation.ResetConditionOperator()
  610. ssuo.mutation.SetConditionOperator(i)
  611. return ssuo
  612. }
  613. // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
  614. func (ssuo *SopStageUpdateOne) SetNillableConditionOperator(i *int) *SopStageUpdateOne {
  615. if i != nil {
  616. ssuo.SetConditionOperator(*i)
  617. }
  618. return ssuo
  619. }
  620. // AddConditionOperator adds i to the "condition_operator" field.
  621. func (ssuo *SopStageUpdateOne) AddConditionOperator(i int) *SopStageUpdateOne {
  622. ssuo.mutation.AddConditionOperator(i)
  623. return ssuo
  624. }
  625. // SetConditionList sets the "condition_list" field.
  626. func (ssuo *SopStageUpdateOne) SetConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
  627. ssuo.mutation.SetConditionList(ct)
  628. return ssuo
  629. }
  630. // AppendConditionList appends ct to the "condition_list" field.
  631. func (ssuo *SopStageUpdateOne) AppendConditionList(ct []custom_types.Condition) *SopStageUpdateOne {
  632. ssuo.mutation.AppendConditionList(ct)
  633. return ssuo
  634. }
  635. // SetActionMessage sets the "action_message" field.
  636. func (ssuo *SopStageUpdateOne) SetActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
  637. ssuo.mutation.SetActionMessage(ct)
  638. return ssuo
  639. }
  640. // AppendActionMessage appends ct to the "action_message" field.
  641. func (ssuo *SopStageUpdateOne) AppendActionMessage(ct []custom_types.Action) *SopStageUpdateOne {
  642. ssuo.mutation.AppendActionMessage(ct)
  643. return ssuo
  644. }
  645. // ClearActionMessage clears the value of the "action_message" field.
  646. func (ssuo *SopStageUpdateOne) ClearActionMessage() *SopStageUpdateOne {
  647. ssuo.mutation.ClearActionMessage()
  648. return ssuo
  649. }
  650. // SetActionLabel sets the "action_label" field.
  651. func (ssuo *SopStageUpdateOne) SetActionLabel(u []uint64) *SopStageUpdateOne {
  652. ssuo.mutation.SetActionLabel(u)
  653. return ssuo
  654. }
  655. // AppendActionLabel appends u to the "action_label" field.
  656. func (ssuo *SopStageUpdateOne) AppendActionLabel(u []uint64) *SopStageUpdateOne {
  657. ssuo.mutation.AppendActionLabel(u)
  658. return ssuo
  659. }
  660. // ClearActionLabel clears the value of the "action_label" field.
  661. func (ssuo *SopStageUpdateOne) ClearActionLabel() *SopStageUpdateOne {
  662. ssuo.mutation.ClearActionLabel()
  663. return ssuo
  664. }
  665. // SetIndexSort sets the "index_sort" field.
  666. func (ssuo *SopStageUpdateOne) SetIndexSort(i int) *SopStageUpdateOne {
  667. ssuo.mutation.ResetIndexSort()
  668. ssuo.mutation.SetIndexSort(i)
  669. return ssuo
  670. }
  671. // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
  672. func (ssuo *SopStageUpdateOne) SetNillableIndexSort(i *int) *SopStageUpdateOne {
  673. if i != nil {
  674. ssuo.SetIndexSort(*i)
  675. }
  676. return ssuo
  677. }
  678. // AddIndexSort adds i to the "index_sort" field.
  679. func (ssuo *SopStageUpdateOne) AddIndexSort(i int) *SopStageUpdateOne {
  680. ssuo.mutation.AddIndexSort(i)
  681. return ssuo
  682. }
  683. // ClearIndexSort clears the value of the "index_sort" field.
  684. func (ssuo *SopStageUpdateOne) ClearIndexSort() *SopStageUpdateOne {
  685. ssuo.mutation.ClearIndexSort()
  686. return ssuo
  687. }
  688. // SetDeletedAt sets the "deleted_at" field.
  689. func (ssuo *SopStageUpdateOne) SetDeletedAt(t time.Time) *SopStageUpdateOne {
  690. ssuo.mutation.SetDeletedAt(t)
  691. return ssuo
  692. }
  693. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  694. func (ssuo *SopStageUpdateOne) SetNillableDeletedAt(t *time.Time) *SopStageUpdateOne {
  695. if t != nil {
  696. ssuo.SetDeletedAt(*t)
  697. }
  698. return ssuo
  699. }
  700. // ClearDeletedAt clears the value of the "deleted_at" field.
  701. func (ssuo *SopStageUpdateOne) ClearDeletedAt() *SopStageUpdateOne {
  702. ssuo.mutation.ClearDeletedAt()
  703. return ssuo
  704. }
  705. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
  706. func (ssuo *SopStageUpdateOne) SetSopTaskID(id uint64) *SopStageUpdateOne {
  707. ssuo.mutation.SetSopTaskID(id)
  708. return ssuo
  709. }
  710. // SetSopTask sets the "sop_task" edge to the SopTask entity.
  711. func (ssuo *SopStageUpdateOne) SetSopTask(s *SopTask) *SopStageUpdateOne {
  712. return ssuo.SetSopTaskID(s.ID)
  713. }
  714. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
  715. func (ssuo *SopStageUpdateOne) AddStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
  716. ssuo.mutation.AddStageNodeIDs(ids...)
  717. return ssuo
  718. }
  719. // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
  720. func (ssuo *SopStageUpdateOne) AddStageNodes(s ...*SopNode) *SopStageUpdateOne {
  721. ids := make([]uint64, len(s))
  722. for i := range s {
  723. ids[i] = s[i].ID
  724. }
  725. return ssuo.AddStageNodeIDs(ids...)
  726. }
  727. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by IDs.
  728. func (ssuo *SopStageUpdateOne) AddStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
  729. ssuo.mutation.AddStageMessageIDs(ids...)
  730. return ssuo
  731. }
  732. // AddStageMessages adds the "stage_messages" edges to the MessageRecords entity.
  733. func (ssuo *SopStageUpdateOne) AddStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
  734. ids := make([]uint64, len(m))
  735. for i := range m {
  736. ids[i] = m[i].ID
  737. }
  738. return ssuo.AddStageMessageIDs(ids...)
  739. }
  740. // Mutation returns the SopStageMutation object of the builder.
  741. func (ssuo *SopStageUpdateOne) Mutation() *SopStageMutation {
  742. return ssuo.mutation
  743. }
  744. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  745. func (ssuo *SopStageUpdateOne) ClearSopTask() *SopStageUpdateOne {
  746. ssuo.mutation.ClearSopTask()
  747. return ssuo
  748. }
  749. // ClearStageNodes clears all "stage_nodes" edges to the SopNode entity.
  750. func (ssuo *SopStageUpdateOne) ClearStageNodes() *SopStageUpdateOne {
  751. ssuo.mutation.ClearStageNodes()
  752. return ssuo
  753. }
  754. // RemoveStageNodeIDs removes the "stage_nodes" edge to SopNode entities by IDs.
  755. func (ssuo *SopStageUpdateOne) RemoveStageNodeIDs(ids ...uint64) *SopStageUpdateOne {
  756. ssuo.mutation.RemoveStageNodeIDs(ids...)
  757. return ssuo
  758. }
  759. // RemoveStageNodes removes "stage_nodes" edges to SopNode entities.
  760. func (ssuo *SopStageUpdateOne) RemoveStageNodes(s ...*SopNode) *SopStageUpdateOne {
  761. ids := make([]uint64, len(s))
  762. for i := range s {
  763. ids[i] = s[i].ID
  764. }
  765. return ssuo.RemoveStageNodeIDs(ids...)
  766. }
  767. // ClearStageMessages clears all "stage_messages" edges to the MessageRecords entity.
  768. func (ssuo *SopStageUpdateOne) ClearStageMessages() *SopStageUpdateOne {
  769. ssuo.mutation.ClearStageMessages()
  770. return ssuo
  771. }
  772. // RemoveStageMessageIDs removes the "stage_messages" edge to MessageRecords entities by IDs.
  773. func (ssuo *SopStageUpdateOne) RemoveStageMessageIDs(ids ...uint64) *SopStageUpdateOne {
  774. ssuo.mutation.RemoveStageMessageIDs(ids...)
  775. return ssuo
  776. }
  777. // RemoveStageMessages removes "stage_messages" edges to MessageRecords entities.
  778. func (ssuo *SopStageUpdateOne) RemoveStageMessages(m ...*MessageRecords) *SopStageUpdateOne {
  779. ids := make([]uint64, len(m))
  780. for i := range m {
  781. ids[i] = m[i].ID
  782. }
  783. return ssuo.RemoveStageMessageIDs(ids...)
  784. }
  785. // Where appends a list predicates to the SopStageUpdate builder.
  786. func (ssuo *SopStageUpdateOne) Where(ps ...predicate.SopStage) *SopStageUpdateOne {
  787. ssuo.mutation.Where(ps...)
  788. return ssuo
  789. }
  790. // Select allows selecting one or more fields (columns) of the returned entity.
  791. // The default is selecting all fields defined in the entity schema.
  792. func (ssuo *SopStageUpdateOne) Select(field string, fields ...string) *SopStageUpdateOne {
  793. ssuo.fields = append([]string{field}, fields...)
  794. return ssuo
  795. }
  796. // Save executes the query and returns the updated SopStage entity.
  797. func (ssuo *SopStageUpdateOne) Save(ctx context.Context) (*SopStage, error) {
  798. ssuo.defaults()
  799. return withHooks(ctx, ssuo.sqlSave, ssuo.mutation, ssuo.hooks)
  800. }
  801. // SaveX is like Save, but panics if an error occurs.
  802. func (ssuo *SopStageUpdateOne) SaveX(ctx context.Context) *SopStage {
  803. node, err := ssuo.Save(ctx)
  804. if err != nil {
  805. panic(err)
  806. }
  807. return node
  808. }
  809. // Exec executes the query on the entity.
  810. func (ssuo *SopStageUpdateOne) Exec(ctx context.Context) error {
  811. _, err := ssuo.Save(ctx)
  812. return err
  813. }
  814. // ExecX is like Exec, but panics if an error occurs.
  815. func (ssuo *SopStageUpdateOne) ExecX(ctx context.Context) {
  816. if err := ssuo.Exec(ctx); err != nil {
  817. panic(err)
  818. }
  819. }
  820. // defaults sets the default values of the builder before save.
  821. func (ssuo *SopStageUpdateOne) defaults() {
  822. if _, ok := ssuo.mutation.UpdatedAt(); !ok {
  823. v := sopstage.UpdateDefaultUpdatedAt()
  824. ssuo.mutation.SetUpdatedAt(v)
  825. }
  826. }
  827. // check runs all checks and user-defined validators on the builder.
  828. func (ssuo *SopStageUpdateOne) check() error {
  829. if _, ok := ssuo.mutation.SopTaskID(); ssuo.mutation.SopTaskCleared() && !ok {
  830. return errors.New(`ent: clearing a required unique edge "SopStage.sop_task"`)
  831. }
  832. return nil
  833. }
  834. func (ssuo *SopStageUpdateOne) sqlSave(ctx context.Context) (_node *SopStage, err error) {
  835. if err := ssuo.check(); err != nil {
  836. return _node, err
  837. }
  838. _spec := sqlgraph.NewUpdateSpec(sopstage.Table, sopstage.Columns, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
  839. id, ok := ssuo.mutation.ID()
  840. if !ok {
  841. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SopStage.id" for update`)}
  842. }
  843. _spec.Node.ID.Value = id
  844. if fields := ssuo.fields; len(fields) > 0 {
  845. _spec.Node.Columns = make([]string, 0, len(fields))
  846. _spec.Node.Columns = append(_spec.Node.Columns, sopstage.FieldID)
  847. for _, f := range fields {
  848. if !sopstage.ValidColumn(f) {
  849. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  850. }
  851. if f != sopstage.FieldID {
  852. _spec.Node.Columns = append(_spec.Node.Columns, f)
  853. }
  854. }
  855. }
  856. if ps := ssuo.mutation.predicates; len(ps) > 0 {
  857. _spec.Predicate = func(selector *sql.Selector) {
  858. for i := range ps {
  859. ps[i](selector)
  860. }
  861. }
  862. }
  863. if value, ok := ssuo.mutation.UpdatedAt(); ok {
  864. _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
  865. }
  866. if value, ok := ssuo.mutation.Status(); ok {
  867. _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
  868. }
  869. if value, ok := ssuo.mutation.AddedStatus(); ok {
  870. _spec.AddField(sopstage.FieldStatus, field.TypeUint8, value)
  871. }
  872. if ssuo.mutation.StatusCleared() {
  873. _spec.ClearField(sopstage.FieldStatus, field.TypeUint8)
  874. }
  875. if value, ok := ssuo.mutation.Name(); ok {
  876. _spec.SetField(sopstage.FieldName, field.TypeString, value)
  877. }
  878. if value, ok := ssuo.mutation.ConditionType(); ok {
  879. _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
  880. }
  881. if value, ok := ssuo.mutation.AddedConditionType(); ok {
  882. _spec.AddField(sopstage.FieldConditionType, field.TypeInt, value)
  883. }
  884. if value, ok := ssuo.mutation.ConditionOperator(); ok {
  885. _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
  886. }
  887. if value, ok := ssuo.mutation.AddedConditionOperator(); ok {
  888. _spec.AddField(sopstage.FieldConditionOperator, field.TypeInt, value)
  889. }
  890. if value, ok := ssuo.mutation.ConditionList(); ok {
  891. _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
  892. }
  893. if value, ok := ssuo.mutation.AppendedConditionList(); ok {
  894. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  895. sqljson.Append(u, sopstage.FieldConditionList, value)
  896. })
  897. }
  898. if value, ok := ssuo.mutation.ActionMessage(); ok {
  899. _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
  900. }
  901. if value, ok := ssuo.mutation.AppendedActionMessage(); ok {
  902. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  903. sqljson.Append(u, sopstage.FieldActionMessage, value)
  904. })
  905. }
  906. if ssuo.mutation.ActionMessageCleared() {
  907. _spec.ClearField(sopstage.FieldActionMessage, field.TypeJSON)
  908. }
  909. if value, ok := ssuo.mutation.ActionLabel(); ok {
  910. _spec.SetField(sopstage.FieldActionLabel, field.TypeJSON, value)
  911. }
  912. if value, ok := ssuo.mutation.AppendedActionLabel(); ok {
  913. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  914. sqljson.Append(u, sopstage.FieldActionLabel, value)
  915. })
  916. }
  917. if ssuo.mutation.ActionLabelCleared() {
  918. _spec.ClearField(sopstage.FieldActionLabel, field.TypeJSON)
  919. }
  920. if value, ok := ssuo.mutation.IndexSort(); ok {
  921. _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
  922. }
  923. if value, ok := ssuo.mutation.AddedIndexSort(); ok {
  924. _spec.AddField(sopstage.FieldIndexSort, field.TypeInt, value)
  925. }
  926. if ssuo.mutation.IndexSortCleared() {
  927. _spec.ClearField(sopstage.FieldIndexSort, field.TypeInt)
  928. }
  929. if value, ok := ssuo.mutation.DeletedAt(); ok {
  930. _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
  931. }
  932. if ssuo.mutation.DeletedAtCleared() {
  933. _spec.ClearField(sopstage.FieldDeletedAt, field.TypeTime)
  934. }
  935. if ssuo.mutation.SopTaskCleared() {
  936. edge := &sqlgraph.EdgeSpec{
  937. Rel: sqlgraph.M2O,
  938. Inverse: true,
  939. Table: sopstage.SopTaskTable,
  940. Columns: []string{sopstage.SopTaskColumn},
  941. Bidi: false,
  942. Target: &sqlgraph.EdgeTarget{
  943. IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
  944. },
  945. }
  946. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  947. }
  948. if nodes := ssuo.mutation.SopTaskIDs(); len(nodes) > 0 {
  949. edge := &sqlgraph.EdgeSpec{
  950. Rel: sqlgraph.M2O,
  951. Inverse: true,
  952. Table: sopstage.SopTaskTable,
  953. Columns: []string{sopstage.SopTaskColumn},
  954. Bidi: false,
  955. Target: &sqlgraph.EdgeTarget{
  956. IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
  957. },
  958. }
  959. for _, k := range nodes {
  960. edge.Target.Nodes = append(edge.Target.Nodes, k)
  961. }
  962. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  963. }
  964. if ssuo.mutation.StageNodesCleared() {
  965. edge := &sqlgraph.EdgeSpec{
  966. Rel: sqlgraph.O2M,
  967. Inverse: false,
  968. Table: sopstage.StageNodesTable,
  969. Columns: []string{sopstage.StageNodesColumn},
  970. Bidi: false,
  971. Target: &sqlgraph.EdgeTarget{
  972. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  973. },
  974. }
  975. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  976. }
  977. if nodes := ssuo.mutation.RemovedStageNodesIDs(); len(nodes) > 0 && !ssuo.mutation.StageNodesCleared() {
  978. edge := &sqlgraph.EdgeSpec{
  979. Rel: sqlgraph.O2M,
  980. Inverse: false,
  981. Table: sopstage.StageNodesTable,
  982. Columns: []string{sopstage.StageNodesColumn},
  983. Bidi: false,
  984. Target: &sqlgraph.EdgeTarget{
  985. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  986. },
  987. }
  988. for _, k := range nodes {
  989. edge.Target.Nodes = append(edge.Target.Nodes, k)
  990. }
  991. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  992. }
  993. if nodes := ssuo.mutation.StageNodesIDs(); len(nodes) > 0 {
  994. edge := &sqlgraph.EdgeSpec{
  995. Rel: sqlgraph.O2M,
  996. Inverse: false,
  997. Table: sopstage.StageNodesTable,
  998. Columns: []string{sopstage.StageNodesColumn},
  999. Bidi: false,
  1000. Target: &sqlgraph.EdgeTarget{
  1001. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  1002. },
  1003. }
  1004. for _, k := range nodes {
  1005. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1006. }
  1007. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1008. }
  1009. if ssuo.mutation.StageMessagesCleared() {
  1010. edge := &sqlgraph.EdgeSpec{
  1011. Rel: sqlgraph.O2M,
  1012. Inverse: false,
  1013. Table: sopstage.StageMessagesTable,
  1014. Columns: []string{sopstage.StageMessagesColumn},
  1015. Bidi: false,
  1016. Target: &sqlgraph.EdgeTarget{
  1017. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1018. },
  1019. }
  1020. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1021. }
  1022. if nodes := ssuo.mutation.RemovedStageMessagesIDs(); len(nodes) > 0 && !ssuo.mutation.StageMessagesCleared() {
  1023. edge := &sqlgraph.EdgeSpec{
  1024. Rel: sqlgraph.O2M,
  1025. Inverse: false,
  1026. Table: sopstage.StageMessagesTable,
  1027. Columns: []string{sopstage.StageMessagesColumn},
  1028. Bidi: false,
  1029. Target: &sqlgraph.EdgeTarget{
  1030. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1031. },
  1032. }
  1033. for _, k := range nodes {
  1034. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1035. }
  1036. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1037. }
  1038. if nodes := ssuo.mutation.StageMessagesIDs(); len(nodes) > 0 {
  1039. edge := &sqlgraph.EdgeSpec{
  1040. Rel: sqlgraph.O2M,
  1041. Inverse: false,
  1042. Table: sopstage.StageMessagesTable,
  1043. Columns: []string{sopstage.StageMessagesColumn},
  1044. Bidi: false,
  1045. Target: &sqlgraph.EdgeTarget{
  1046. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1047. },
  1048. }
  1049. for _, k := range nodes {
  1050. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1051. }
  1052. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1053. }
  1054. _node = &SopStage{config: ssuo.config}
  1055. _spec.Assign = _node.assignValues
  1056. _spec.ScanValues = _node.scanValues
  1057. if err = sqlgraph.UpdateNode(ctx, ssuo.driver, _spec); err != nil {
  1058. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1059. err = &NotFoundError{sopstage.Label}
  1060. } else if sqlgraph.IsConstraintError(err) {
  1061. err = &ConstraintError{msg: err.Error(), wrap: err}
  1062. }
  1063. return nil, err
  1064. }
  1065. ssuo.mutation.done = true
  1066. return _node, nil
  1067. }