sopstage_create.go 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/custom_types"
  9. "wechat-api/ent/sopnode"
  10. "wechat-api/ent/sopstage"
  11. "wechat-api/ent/soptask"
  12. "entgo.io/ent/dialect/sql"
  13. "entgo.io/ent/dialect/sql/sqlgraph"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // SopStageCreate is the builder for creating a SopStage entity.
  17. type SopStageCreate struct {
  18. config
  19. mutation *SopStageMutation
  20. hooks []Hook
  21. conflict []sql.ConflictOption
  22. }
  23. // SetCreatedAt sets the "created_at" field.
  24. func (ssc *SopStageCreate) SetCreatedAt(t time.Time) *SopStageCreate {
  25. ssc.mutation.SetCreatedAt(t)
  26. return ssc
  27. }
  28. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  29. func (ssc *SopStageCreate) SetNillableCreatedAt(t *time.Time) *SopStageCreate {
  30. if t != nil {
  31. ssc.SetCreatedAt(*t)
  32. }
  33. return ssc
  34. }
  35. // SetUpdatedAt sets the "updated_at" field.
  36. func (ssc *SopStageCreate) SetUpdatedAt(t time.Time) *SopStageCreate {
  37. ssc.mutation.SetUpdatedAt(t)
  38. return ssc
  39. }
  40. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  41. func (ssc *SopStageCreate) SetNillableUpdatedAt(t *time.Time) *SopStageCreate {
  42. if t != nil {
  43. ssc.SetUpdatedAt(*t)
  44. }
  45. return ssc
  46. }
  47. // SetStatus sets the "status" field.
  48. func (ssc *SopStageCreate) SetStatus(u uint8) *SopStageCreate {
  49. ssc.mutation.SetStatus(u)
  50. return ssc
  51. }
  52. // SetNillableStatus sets the "status" field if the given value is not nil.
  53. func (ssc *SopStageCreate) SetNillableStatus(u *uint8) *SopStageCreate {
  54. if u != nil {
  55. ssc.SetStatus(*u)
  56. }
  57. return ssc
  58. }
  59. // SetDeletedAt sets the "deleted_at" field.
  60. func (ssc *SopStageCreate) SetDeletedAt(t time.Time) *SopStageCreate {
  61. ssc.mutation.SetDeletedAt(t)
  62. return ssc
  63. }
  64. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  65. func (ssc *SopStageCreate) SetNillableDeletedAt(t *time.Time) *SopStageCreate {
  66. if t != nil {
  67. ssc.SetDeletedAt(*t)
  68. }
  69. return ssc
  70. }
  71. // SetTaskID sets the "task_id" field.
  72. func (ssc *SopStageCreate) SetTaskID(u uint64) *SopStageCreate {
  73. ssc.mutation.SetTaskID(u)
  74. return ssc
  75. }
  76. // SetName sets the "name" field.
  77. func (ssc *SopStageCreate) SetName(s string) *SopStageCreate {
  78. ssc.mutation.SetName(s)
  79. return ssc
  80. }
  81. // SetNillableName sets the "name" field if the given value is not nil.
  82. func (ssc *SopStageCreate) SetNillableName(s *string) *SopStageCreate {
  83. if s != nil {
  84. ssc.SetName(*s)
  85. }
  86. return ssc
  87. }
  88. // SetConditionType sets the "condition_type" field.
  89. func (ssc *SopStageCreate) SetConditionType(i int) *SopStageCreate {
  90. ssc.mutation.SetConditionType(i)
  91. return ssc
  92. }
  93. // SetNillableConditionType sets the "condition_type" field if the given value is not nil.
  94. func (ssc *SopStageCreate) SetNillableConditionType(i *int) *SopStageCreate {
  95. if i != nil {
  96. ssc.SetConditionType(*i)
  97. }
  98. return ssc
  99. }
  100. // SetConditionOperator sets the "condition_operator" field.
  101. func (ssc *SopStageCreate) SetConditionOperator(i int) *SopStageCreate {
  102. ssc.mutation.SetConditionOperator(i)
  103. return ssc
  104. }
  105. // SetNillableConditionOperator sets the "condition_operator" field if the given value is not nil.
  106. func (ssc *SopStageCreate) SetNillableConditionOperator(i *int) *SopStageCreate {
  107. if i != nil {
  108. ssc.SetConditionOperator(*i)
  109. }
  110. return ssc
  111. }
  112. // SetConditionList sets the "condition_list" field.
  113. func (ssc *SopStageCreate) SetConditionList(ct []custom_types.Condition) *SopStageCreate {
  114. ssc.mutation.SetConditionList(ct)
  115. return ssc
  116. }
  117. // SetActionMessage sets the "action_message" field.
  118. func (ssc *SopStageCreate) SetActionMessage(ct []custom_types.Action) *SopStageCreate {
  119. ssc.mutation.SetActionMessage(ct)
  120. return ssc
  121. }
  122. // SetActionLabel sets the "action_label" field.
  123. func (ssc *SopStageCreate) SetActionLabel(i []int) *SopStageCreate {
  124. ssc.mutation.SetActionLabel(i)
  125. return ssc
  126. }
  127. // SetIndexSort sets the "index_sort" field.
  128. func (ssc *SopStageCreate) SetIndexSort(i int) *SopStageCreate {
  129. ssc.mutation.SetIndexSort(i)
  130. return ssc
  131. }
  132. // SetNillableIndexSort sets the "index_sort" field if the given value is not nil.
  133. func (ssc *SopStageCreate) SetNillableIndexSort(i *int) *SopStageCreate {
  134. if i != nil {
  135. ssc.SetIndexSort(*i)
  136. }
  137. return ssc
  138. }
  139. // SetID sets the "id" field.
  140. func (ssc *SopStageCreate) SetID(u uint64) *SopStageCreate {
  141. ssc.mutation.SetID(u)
  142. return ssc
  143. }
  144. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by ID.
  145. func (ssc *SopStageCreate) SetSopTaskID(id uint64) *SopStageCreate {
  146. ssc.mutation.SetSopTaskID(id)
  147. return ssc
  148. }
  149. // SetSopTask sets the "sop_task" edge to the SopTask entity.
  150. func (ssc *SopStageCreate) SetSopTask(s *SopTask) *SopStageCreate {
  151. return ssc.SetSopTaskID(s.ID)
  152. }
  153. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by IDs.
  154. func (ssc *SopStageCreate) AddStageNodeIDs(ids ...uint64) *SopStageCreate {
  155. ssc.mutation.AddStageNodeIDs(ids...)
  156. return ssc
  157. }
  158. // AddStageNodes adds the "stage_nodes" edges to the SopNode entity.
  159. func (ssc *SopStageCreate) AddStageNodes(s ...*SopNode) *SopStageCreate {
  160. ids := make([]uint64, len(s))
  161. for i := range s {
  162. ids[i] = s[i].ID
  163. }
  164. return ssc.AddStageNodeIDs(ids...)
  165. }
  166. // Mutation returns the SopStageMutation object of the builder.
  167. func (ssc *SopStageCreate) Mutation() *SopStageMutation {
  168. return ssc.mutation
  169. }
  170. // Save creates the SopStage in the database.
  171. func (ssc *SopStageCreate) Save(ctx context.Context) (*SopStage, error) {
  172. if err := ssc.defaults(); err != nil {
  173. return nil, err
  174. }
  175. return withHooks(ctx, ssc.sqlSave, ssc.mutation, ssc.hooks)
  176. }
  177. // SaveX calls Save and panics if Save returns an error.
  178. func (ssc *SopStageCreate) SaveX(ctx context.Context) *SopStage {
  179. v, err := ssc.Save(ctx)
  180. if err != nil {
  181. panic(err)
  182. }
  183. return v
  184. }
  185. // Exec executes the query.
  186. func (ssc *SopStageCreate) Exec(ctx context.Context) error {
  187. _, err := ssc.Save(ctx)
  188. return err
  189. }
  190. // ExecX is like Exec, but panics if an error occurs.
  191. func (ssc *SopStageCreate) ExecX(ctx context.Context) {
  192. if err := ssc.Exec(ctx); err != nil {
  193. panic(err)
  194. }
  195. }
  196. // defaults sets the default values of the builder before save.
  197. func (ssc *SopStageCreate) defaults() error {
  198. if _, ok := ssc.mutation.CreatedAt(); !ok {
  199. if sopstage.DefaultCreatedAt == nil {
  200. return fmt.Errorf("ent: uninitialized sopstage.DefaultCreatedAt (forgotten import ent/runtime?)")
  201. }
  202. v := sopstage.DefaultCreatedAt()
  203. ssc.mutation.SetCreatedAt(v)
  204. }
  205. if _, ok := ssc.mutation.UpdatedAt(); !ok {
  206. if sopstage.DefaultUpdatedAt == nil {
  207. return fmt.Errorf("ent: uninitialized sopstage.DefaultUpdatedAt (forgotten import ent/runtime?)")
  208. }
  209. v := sopstage.DefaultUpdatedAt()
  210. ssc.mutation.SetUpdatedAt(v)
  211. }
  212. if _, ok := ssc.mutation.Status(); !ok {
  213. v := sopstage.DefaultStatus
  214. ssc.mutation.SetStatus(v)
  215. }
  216. if _, ok := ssc.mutation.Name(); !ok {
  217. v := sopstage.DefaultName
  218. ssc.mutation.SetName(v)
  219. }
  220. if _, ok := ssc.mutation.ConditionType(); !ok {
  221. v := sopstage.DefaultConditionType
  222. ssc.mutation.SetConditionType(v)
  223. }
  224. if _, ok := ssc.mutation.ConditionOperator(); !ok {
  225. v := sopstage.DefaultConditionOperator
  226. ssc.mutation.SetConditionOperator(v)
  227. }
  228. if _, ok := ssc.mutation.IndexSort(); !ok {
  229. v := sopstage.DefaultIndexSort
  230. ssc.mutation.SetIndexSort(v)
  231. }
  232. return nil
  233. }
  234. // check runs all checks and user-defined validators on the builder.
  235. func (ssc *SopStageCreate) check() error {
  236. if _, ok := ssc.mutation.CreatedAt(); !ok {
  237. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SopStage.created_at"`)}
  238. }
  239. if _, ok := ssc.mutation.UpdatedAt(); !ok {
  240. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SopStage.updated_at"`)}
  241. }
  242. if _, ok := ssc.mutation.TaskID(); !ok {
  243. return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "SopStage.task_id"`)}
  244. }
  245. if _, ok := ssc.mutation.Name(); !ok {
  246. return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SopStage.name"`)}
  247. }
  248. if _, ok := ssc.mutation.ConditionType(); !ok {
  249. return &ValidationError{Name: "condition_type", err: errors.New(`ent: missing required field "SopStage.condition_type"`)}
  250. }
  251. if _, ok := ssc.mutation.ConditionOperator(); !ok {
  252. return &ValidationError{Name: "condition_operator", err: errors.New(`ent: missing required field "SopStage.condition_operator"`)}
  253. }
  254. if _, ok := ssc.mutation.ConditionList(); !ok {
  255. return &ValidationError{Name: "condition_list", err: errors.New(`ent: missing required field "SopStage.condition_list"`)}
  256. }
  257. if _, ok := ssc.mutation.SopTaskID(); !ok {
  258. return &ValidationError{Name: "sop_task", err: errors.New(`ent: missing required edge "SopStage.sop_task"`)}
  259. }
  260. return nil
  261. }
  262. func (ssc *SopStageCreate) sqlSave(ctx context.Context) (*SopStage, error) {
  263. if err := ssc.check(); err != nil {
  264. return nil, err
  265. }
  266. _node, _spec := ssc.createSpec()
  267. if err := sqlgraph.CreateNode(ctx, ssc.driver, _spec); err != nil {
  268. if sqlgraph.IsConstraintError(err) {
  269. err = &ConstraintError{msg: err.Error(), wrap: err}
  270. }
  271. return nil, err
  272. }
  273. if _spec.ID.Value != _node.ID {
  274. id := _spec.ID.Value.(int64)
  275. _node.ID = uint64(id)
  276. }
  277. ssc.mutation.id = &_node.ID
  278. ssc.mutation.done = true
  279. return _node, nil
  280. }
  281. func (ssc *SopStageCreate) createSpec() (*SopStage, *sqlgraph.CreateSpec) {
  282. var (
  283. _node = &SopStage{config: ssc.config}
  284. _spec = sqlgraph.NewCreateSpec(sopstage.Table, sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64))
  285. )
  286. _spec.OnConflict = ssc.conflict
  287. if id, ok := ssc.mutation.ID(); ok {
  288. _node.ID = id
  289. _spec.ID.Value = id
  290. }
  291. if value, ok := ssc.mutation.CreatedAt(); ok {
  292. _spec.SetField(sopstage.FieldCreatedAt, field.TypeTime, value)
  293. _node.CreatedAt = value
  294. }
  295. if value, ok := ssc.mutation.UpdatedAt(); ok {
  296. _spec.SetField(sopstage.FieldUpdatedAt, field.TypeTime, value)
  297. _node.UpdatedAt = value
  298. }
  299. if value, ok := ssc.mutation.Status(); ok {
  300. _spec.SetField(sopstage.FieldStatus, field.TypeUint8, value)
  301. _node.Status = value
  302. }
  303. if value, ok := ssc.mutation.DeletedAt(); ok {
  304. _spec.SetField(sopstage.FieldDeletedAt, field.TypeTime, value)
  305. _node.DeletedAt = value
  306. }
  307. if value, ok := ssc.mutation.Name(); ok {
  308. _spec.SetField(sopstage.FieldName, field.TypeString, value)
  309. _node.Name = value
  310. }
  311. if value, ok := ssc.mutation.ConditionType(); ok {
  312. _spec.SetField(sopstage.FieldConditionType, field.TypeInt, value)
  313. _node.ConditionType = value
  314. }
  315. if value, ok := ssc.mutation.ConditionOperator(); ok {
  316. _spec.SetField(sopstage.FieldConditionOperator, field.TypeInt, value)
  317. _node.ConditionOperator = value
  318. }
  319. if value, ok := ssc.mutation.ConditionList(); ok {
  320. _spec.SetField(sopstage.FieldConditionList, field.TypeJSON, value)
  321. _node.ConditionList = value
  322. }
  323. if value, ok := ssc.mutation.ActionMessage(); ok {
  324. _spec.SetField(sopstage.FieldActionMessage, field.TypeJSON, value)
  325. _node.ActionMessage = value
  326. }
  327. if value, ok := ssc.mutation.ActionLabel(); ok {
  328. _spec.SetField(sopstage.FieldActionLabel, field.TypeJSON, value)
  329. _node.ActionLabel = value
  330. }
  331. if value, ok := ssc.mutation.IndexSort(); ok {
  332. _spec.SetField(sopstage.FieldIndexSort, field.TypeInt, value)
  333. _node.IndexSort = value
  334. }
  335. if nodes := ssc.mutation.SopTaskIDs(); len(nodes) > 0 {
  336. edge := &sqlgraph.EdgeSpec{
  337. Rel: sqlgraph.M2O,
  338. Inverse: true,
  339. Table: sopstage.SopTaskTable,
  340. Columns: []string{sopstage.SopTaskColumn},
  341. Bidi: false,
  342. Target: &sqlgraph.EdgeTarget{
  343. IDSpec: sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64),
  344. },
  345. }
  346. for _, k := range nodes {
  347. edge.Target.Nodes = append(edge.Target.Nodes, k)
  348. }
  349. _node.TaskID = nodes[0]
  350. _spec.Edges = append(_spec.Edges, edge)
  351. }
  352. if nodes := ssc.mutation.StageNodesIDs(); len(nodes) > 0 {
  353. edge := &sqlgraph.EdgeSpec{
  354. Rel: sqlgraph.O2M,
  355. Inverse: false,
  356. Table: sopstage.StageNodesTable,
  357. Columns: []string{sopstage.StageNodesColumn},
  358. Bidi: false,
  359. Target: &sqlgraph.EdgeTarget{
  360. IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
  361. },
  362. }
  363. for _, k := range nodes {
  364. edge.Target.Nodes = append(edge.Target.Nodes, k)
  365. }
  366. _spec.Edges = append(_spec.Edges, edge)
  367. }
  368. return _node, _spec
  369. }
  370. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  371. // of the `INSERT` statement. For example:
  372. //
  373. // client.SopStage.Create().
  374. // SetCreatedAt(v).
  375. // OnConflict(
  376. // // Update the row with the new values
  377. // // the was proposed for insertion.
  378. // sql.ResolveWithNewValues(),
  379. // ).
  380. // // Override some of the fields with custom
  381. // // update values.
  382. // Update(func(u *ent.SopStageUpsert) {
  383. // SetCreatedAt(v+v).
  384. // }).
  385. // Exec(ctx)
  386. func (ssc *SopStageCreate) OnConflict(opts ...sql.ConflictOption) *SopStageUpsertOne {
  387. ssc.conflict = opts
  388. return &SopStageUpsertOne{
  389. create: ssc,
  390. }
  391. }
  392. // OnConflictColumns calls `OnConflict` and configures the columns
  393. // as conflict target. Using this option is equivalent to using:
  394. //
  395. // client.SopStage.Create().
  396. // OnConflict(sql.ConflictColumns(columns...)).
  397. // Exec(ctx)
  398. func (ssc *SopStageCreate) OnConflictColumns(columns ...string) *SopStageUpsertOne {
  399. ssc.conflict = append(ssc.conflict, sql.ConflictColumns(columns...))
  400. return &SopStageUpsertOne{
  401. create: ssc,
  402. }
  403. }
  404. type (
  405. // SopStageUpsertOne is the builder for "upsert"-ing
  406. // one SopStage node.
  407. SopStageUpsertOne struct {
  408. create *SopStageCreate
  409. }
  410. // SopStageUpsert is the "OnConflict" setter.
  411. SopStageUpsert struct {
  412. *sql.UpdateSet
  413. }
  414. )
  415. // SetUpdatedAt sets the "updated_at" field.
  416. func (u *SopStageUpsert) SetUpdatedAt(v time.Time) *SopStageUpsert {
  417. u.Set(sopstage.FieldUpdatedAt, v)
  418. return u
  419. }
  420. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  421. func (u *SopStageUpsert) UpdateUpdatedAt() *SopStageUpsert {
  422. u.SetExcluded(sopstage.FieldUpdatedAt)
  423. return u
  424. }
  425. // SetStatus sets the "status" field.
  426. func (u *SopStageUpsert) SetStatus(v uint8) *SopStageUpsert {
  427. u.Set(sopstage.FieldStatus, v)
  428. return u
  429. }
  430. // UpdateStatus sets the "status" field to the value that was provided on create.
  431. func (u *SopStageUpsert) UpdateStatus() *SopStageUpsert {
  432. u.SetExcluded(sopstage.FieldStatus)
  433. return u
  434. }
  435. // AddStatus adds v to the "status" field.
  436. func (u *SopStageUpsert) AddStatus(v uint8) *SopStageUpsert {
  437. u.Add(sopstage.FieldStatus, v)
  438. return u
  439. }
  440. // ClearStatus clears the value of the "status" field.
  441. func (u *SopStageUpsert) ClearStatus() *SopStageUpsert {
  442. u.SetNull(sopstage.FieldStatus)
  443. return u
  444. }
  445. // SetDeletedAt sets the "deleted_at" field.
  446. func (u *SopStageUpsert) SetDeletedAt(v time.Time) *SopStageUpsert {
  447. u.Set(sopstage.FieldDeletedAt, v)
  448. return u
  449. }
  450. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  451. func (u *SopStageUpsert) UpdateDeletedAt() *SopStageUpsert {
  452. u.SetExcluded(sopstage.FieldDeletedAt)
  453. return u
  454. }
  455. // ClearDeletedAt clears the value of the "deleted_at" field.
  456. func (u *SopStageUpsert) ClearDeletedAt() *SopStageUpsert {
  457. u.SetNull(sopstage.FieldDeletedAt)
  458. return u
  459. }
  460. // SetTaskID sets the "task_id" field.
  461. func (u *SopStageUpsert) SetTaskID(v uint64) *SopStageUpsert {
  462. u.Set(sopstage.FieldTaskID, v)
  463. return u
  464. }
  465. // UpdateTaskID sets the "task_id" field to the value that was provided on create.
  466. func (u *SopStageUpsert) UpdateTaskID() *SopStageUpsert {
  467. u.SetExcluded(sopstage.FieldTaskID)
  468. return u
  469. }
  470. // SetName sets the "name" field.
  471. func (u *SopStageUpsert) SetName(v string) *SopStageUpsert {
  472. u.Set(sopstage.FieldName, v)
  473. return u
  474. }
  475. // UpdateName sets the "name" field to the value that was provided on create.
  476. func (u *SopStageUpsert) UpdateName() *SopStageUpsert {
  477. u.SetExcluded(sopstage.FieldName)
  478. return u
  479. }
  480. // SetConditionType sets the "condition_type" field.
  481. func (u *SopStageUpsert) SetConditionType(v int) *SopStageUpsert {
  482. u.Set(sopstage.FieldConditionType, v)
  483. return u
  484. }
  485. // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
  486. func (u *SopStageUpsert) UpdateConditionType() *SopStageUpsert {
  487. u.SetExcluded(sopstage.FieldConditionType)
  488. return u
  489. }
  490. // AddConditionType adds v to the "condition_type" field.
  491. func (u *SopStageUpsert) AddConditionType(v int) *SopStageUpsert {
  492. u.Add(sopstage.FieldConditionType, v)
  493. return u
  494. }
  495. // SetConditionOperator sets the "condition_operator" field.
  496. func (u *SopStageUpsert) SetConditionOperator(v int) *SopStageUpsert {
  497. u.Set(sopstage.FieldConditionOperator, v)
  498. return u
  499. }
  500. // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
  501. func (u *SopStageUpsert) UpdateConditionOperator() *SopStageUpsert {
  502. u.SetExcluded(sopstage.FieldConditionOperator)
  503. return u
  504. }
  505. // AddConditionOperator adds v to the "condition_operator" field.
  506. func (u *SopStageUpsert) AddConditionOperator(v int) *SopStageUpsert {
  507. u.Add(sopstage.FieldConditionOperator, v)
  508. return u
  509. }
  510. // SetConditionList sets the "condition_list" field.
  511. func (u *SopStageUpsert) SetConditionList(v []custom_types.Condition) *SopStageUpsert {
  512. u.Set(sopstage.FieldConditionList, v)
  513. return u
  514. }
  515. // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
  516. func (u *SopStageUpsert) UpdateConditionList() *SopStageUpsert {
  517. u.SetExcluded(sopstage.FieldConditionList)
  518. return u
  519. }
  520. // SetActionMessage sets the "action_message" field.
  521. func (u *SopStageUpsert) SetActionMessage(v []custom_types.Action) *SopStageUpsert {
  522. u.Set(sopstage.FieldActionMessage, v)
  523. return u
  524. }
  525. // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
  526. func (u *SopStageUpsert) UpdateActionMessage() *SopStageUpsert {
  527. u.SetExcluded(sopstage.FieldActionMessage)
  528. return u
  529. }
  530. // ClearActionMessage clears the value of the "action_message" field.
  531. func (u *SopStageUpsert) ClearActionMessage() *SopStageUpsert {
  532. u.SetNull(sopstage.FieldActionMessage)
  533. return u
  534. }
  535. // SetActionLabel sets the "action_label" field.
  536. func (u *SopStageUpsert) SetActionLabel(v []int) *SopStageUpsert {
  537. u.Set(sopstage.FieldActionLabel, v)
  538. return u
  539. }
  540. // UpdateActionLabel sets the "action_label" field to the value that was provided on create.
  541. func (u *SopStageUpsert) UpdateActionLabel() *SopStageUpsert {
  542. u.SetExcluded(sopstage.FieldActionLabel)
  543. return u
  544. }
  545. // ClearActionLabel clears the value of the "action_label" field.
  546. func (u *SopStageUpsert) ClearActionLabel() *SopStageUpsert {
  547. u.SetNull(sopstage.FieldActionLabel)
  548. return u
  549. }
  550. // SetIndexSort sets the "index_sort" field.
  551. func (u *SopStageUpsert) SetIndexSort(v int) *SopStageUpsert {
  552. u.Set(sopstage.FieldIndexSort, v)
  553. return u
  554. }
  555. // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
  556. func (u *SopStageUpsert) UpdateIndexSort() *SopStageUpsert {
  557. u.SetExcluded(sopstage.FieldIndexSort)
  558. return u
  559. }
  560. // AddIndexSort adds v to the "index_sort" field.
  561. func (u *SopStageUpsert) AddIndexSort(v int) *SopStageUpsert {
  562. u.Add(sopstage.FieldIndexSort, v)
  563. return u
  564. }
  565. // ClearIndexSort clears the value of the "index_sort" field.
  566. func (u *SopStageUpsert) ClearIndexSort() *SopStageUpsert {
  567. u.SetNull(sopstage.FieldIndexSort)
  568. return u
  569. }
  570. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  571. // Using this option is equivalent to using:
  572. //
  573. // client.SopStage.Create().
  574. // OnConflict(
  575. // sql.ResolveWithNewValues(),
  576. // sql.ResolveWith(func(u *sql.UpdateSet) {
  577. // u.SetIgnore(sopstage.FieldID)
  578. // }),
  579. // ).
  580. // Exec(ctx)
  581. func (u *SopStageUpsertOne) UpdateNewValues() *SopStageUpsertOne {
  582. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  583. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  584. if _, exists := u.create.mutation.ID(); exists {
  585. s.SetIgnore(sopstage.FieldID)
  586. }
  587. if _, exists := u.create.mutation.CreatedAt(); exists {
  588. s.SetIgnore(sopstage.FieldCreatedAt)
  589. }
  590. }))
  591. return u
  592. }
  593. // Ignore sets each column to itself in case of conflict.
  594. // Using this option is equivalent to using:
  595. //
  596. // client.SopStage.Create().
  597. // OnConflict(sql.ResolveWithIgnore()).
  598. // Exec(ctx)
  599. func (u *SopStageUpsertOne) Ignore() *SopStageUpsertOne {
  600. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  601. return u
  602. }
  603. // DoNothing configures the conflict_action to `DO NOTHING`.
  604. // Supported only by SQLite and PostgreSQL.
  605. func (u *SopStageUpsertOne) DoNothing() *SopStageUpsertOne {
  606. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  607. return u
  608. }
  609. // Update allows overriding fields `UPDATE` values. See the SopStageCreate.OnConflict
  610. // documentation for more info.
  611. func (u *SopStageUpsertOne) Update(set func(*SopStageUpsert)) *SopStageUpsertOne {
  612. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  613. set(&SopStageUpsert{UpdateSet: update})
  614. }))
  615. return u
  616. }
  617. // SetUpdatedAt sets the "updated_at" field.
  618. func (u *SopStageUpsertOne) SetUpdatedAt(v time.Time) *SopStageUpsertOne {
  619. return u.Update(func(s *SopStageUpsert) {
  620. s.SetUpdatedAt(v)
  621. })
  622. }
  623. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  624. func (u *SopStageUpsertOne) UpdateUpdatedAt() *SopStageUpsertOne {
  625. return u.Update(func(s *SopStageUpsert) {
  626. s.UpdateUpdatedAt()
  627. })
  628. }
  629. // SetStatus sets the "status" field.
  630. func (u *SopStageUpsertOne) SetStatus(v uint8) *SopStageUpsertOne {
  631. return u.Update(func(s *SopStageUpsert) {
  632. s.SetStatus(v)
  633. })
  634. }
  635. // AddStatus adds v to the "status" field.
  636. func (u *SopStageUpsertOne) AddStatus(v uint8) *SopStageUpsertOne {
  637. return u.Update(func(s *SopStageUpsert) {
  638. s.AddStatus(v)
  639. })
  640. }
  641. // UpdateStatus sets the "status" field to the value that was provided on create.
  642. func (u *SopStageUpsertOne) UpdateStatus() *SopStageUpsertOne {
  643. return u.Update(func(s *SopStageUpsert) {
  644. s.UpdateStatus()
  645. })
  646. }
  647. // ClearStatus clears the value of the "status" field.
  648. func (u *SopStageUpsertOne) ClearStatus() *SopStageUpsertOne {
  649. return u.Update(func(s *SopStageUpsert) {
  650. s.ClearStatus()
  651. })
  652. }
  653. // SetDeletedAt sets the "deleted_at" field.
  654. func (u *SopStageUpsertOne) SetDeletedAt(v time.Time) *SopStageUpsertOne {
  655. return u.Update(func(s *SopStageUpsert) {
  656. s.SetDeletedAt(v)
  657. })
  658. }
  659. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  660. func (u *SopStageUpsertOne) UpdateDeletedAt() *SopStageUpsertOne {
  661. return u.Update(func(s *SopStageUpsert) {
  662. s.UpdateDeletedAt()
  663. })
  664. }
  665. // ClearDeletedAt clears the value of the "deleted_at" field.
  666. func (u *SopStageUpsertOne) ClearDeletedAt() *SopStageUpsertOne {
  667. return u.Update(func(s *SopStageUpsert) {
  668. s.ClearDeletedAt()
  669. })
  670. }
  671. // SetTaskID sets the "task_id" field.
  672. func (u *SopStageUpsertOne) SetTaskID(v uint64) *SopStageUpsertOne {
  673. return u.Update(func(s *SopStageUpsert) {
  674. s.SetTaskID(v)
  675. })
  676. }
  677. // UpdateTaskID sets the "task_id" field to the value that was provided on create.
  678. func (u *SopStageUpsertOne) UpdateTaskID() *SopStageUpsertOne {
  679. return u.Update(func(s *SopStageUpsert) {
  680. s.UpdateTaskID()
  681. })
  682. }
  683. // SetName sets the "name" field.
  684. func (u *SopStageUpsertOne) SetName(v string) *SopStageUpsertOne {
  685. return u.Update(func(s *SopStageUpsert) {
  686. s.SetName(v)
  687. })
  688. }
  689. // UpdateName sets the "name" field to the value that was provided on create.
  690. func (u *SopStageUpsertOne) UpdateName() *SopStageUpsertOne {
  691. return u.Update(func(s *SopStageUpsert) {
  692. s.UpdateName()
  693. })
  694. }
  695. // SetConditionType sets the "condition_type" field.
  696. func (u *SopStageUpsertOne) SetConditionType(v int) *SopStageUpsertOne {
  697. return u.Update(func(s *SopStageUpsert) {
  698. s.SetConditionType(v)
  699. })
  700. }
  701. // AddConditionType adds v to the "condition_type" field.
  702. func (u *SopStageUpsertOne) AddConditionType(v int) *SopStageUpsertOne {
  703. return u.Update(func(s *SopStageUpsert) {
  704. s.AddConditionType(v)
  705. })
  706. }
  707. // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
  708. func (u *SopStageUpsertOne) UpdateConditionType() *SopStageUpsertOne {
  709. return u.Update(func(s *SopStageUpsert) {
  710. s.UpdateConditionType()
  711. })
  712. }
  713. // SetConditionOperator sets the "condition_operator" field.
  714. func (u *SopStageUpsertOne) SetConditionOperator(v int) *SopStageUpsertOne {
  715. return u.Update(func(s *SopStageUpsert) {
  716. s.SetConditionOperator(v)
  717. })
  718. }
  719. // AddConditionOperator adds v to the "condition_operator" field.
  720. func (u *SopStageUpsertOne) AddConditionOperator(v int) *SopStageUpsertOne {
  721. return u.Update(func(s *SopStageUpsert) {
  722. s.AddConditionOperator(v)
  723. })
  724. }
  725. // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
  726. func (u *SopStageUpsertOne) UpdateConditionOperator() *SopStageUpsertOne {
  727. return u.Update(func(s *SopStageUpsert) {
  728. s.UpdateConditionOperator()
  729. })
  730. }
  731. // SetConditionList sets the "condition_list" field.
  732. func (u *SopStageUpsertOne) SetConditionList(v []custom_types.Condition) *SopStageUpsertOne {
  733. return u.Update(func(s *SopStageUpsert) {
  734. s.SetConditionList(v)
  735. })
  736. }
  737. // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
  738. func (u *SopStageUpsertOne) UpdateConditionList() *SopStageUpsertOne {
  739. return u.Update(func(s *SopStageUpsert) {
  740. s.UpdateConditionList()
  741. })
  742. }
  743. // SetActionMessage sets the "action_message" field.
  744. func (u *SopStageUpsertOne) SetActionMessage(v []custom_types.Action) *SopStageUpsertOne {
  745. return u.Update(func(s *SopStageUpsert) {
  746. s.SetActionMessage(v)
  747. })
  748. }
  749. // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
  750. func (u *SopStageUpsertOne) UpdateActionMessage() *SopStageUpsertOne {
  751. return u.Update(func(s *SopStageUpsert) {
  752. s.UpdateActionMessage()
  753. })
  754. }
  755. // ClearActionMessage clears the value of the "action_message" field.
  756. func (u *SopStageUpsertOne) ClearActionMessage() *SopStageUpsertOne {
  757. return u.Update(func(s *SopStageUpsert) {
  758. s.ClearActionMessage()
  759. })
  760. }
  761. // SetActionLabel sets the "action_label" field.
  762. func (u *SopStageUpsertOne) SetActionLabel(v []int) *SopStageUpsertOne {
  763. return u.Update(func(s *SopStageUpsert) {
  764. s.SetActionLabel(v)
  765. })
  766. }
  767. // UpdateActionLabel sets the "action_label" field to the value that was provided on create.
  768. func (u *SopStageUpsertOne) UpdateActionLabel() *SopStageUpsertOne {
  769. return u.Update(func(s *SopStageUpsert) {
  770. s.UpdateActionLabel()
  771. })
  772. }
  773. // ClearActionLabel clears the value of the "action_label" field.
  774. func (u *SopStageUpsertOne) ClearActionLabel() *SopStageUpsertOne {
  775. return u.Update(func(s *SopStageUpsert) {
  776. s.ClearActionLabel()
  777. })
  778. }
  779. // SetIndexSort sets the "index_sort" field.
  780. func (u *SopStageUpsertOne) SetIndexSort(v int) *SopStageUpsertOne {
  781. return u.Update(func(s *SopStageUpsert) {
  782. s.SetIndexSort(v)
  783. })
  784. }
  785. // AddIndexSort adds v to the "index_sort" field.
  786. func (u *SopStageUpsertOne) AddIndexSort(v int) *SopStageUpsertOne {
  787. return u.Update(func(s *SopStageUpsert) {
  788. s.AddIndexSort(v)
  789. })
  790. }
  791. // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
  792. func (u *SopStageUpsertOne) UpdateIndexSort() *SopStageUpsertOne {
  793. return u.Update(func(s *SopStageUpsert) {
  794. s.UpdateIndexSort()
  795. })
  796. }
  797. // ClearIndexSort clears the value of the "index_sort" field.
  798. func (u *SopStageUpsertOne) ClearIndexSort() *SopStageUpsertOne {
  799. return u.Update(func(s *SopStageUpsert) {
  800. s.ClearIndexSort()
  801. })
  802. }
  803. // Exec executes the query.
  804. func (u *SopStageUpsertOne) Exec(ctx context.Context) error {
  805. if len(u.create.conflict) == 0 {
  806. return errors.New("ent: missing options for SopStageCreate.OnConflict")
  807. }
  808. return u.create.Exec(ctx)
  809. }
  810. // ExecX is like Exec, but panics if an error occurs.
  811. func (u *SopStageUpsertOne) ExecX(ctx context.Context) {
  812. if err := u.create.Exec(ctx); err != nil {
  813. panic(err)
  814. }
  815. }
  816. // Exec executes the UPSERT query and returns the inserted/updated ID.
  817. func (u *SopStageUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  818. node, err := u.create.Save(ctx)
  819. if err != nil {
  820. return id, err
  821. }
  822. return node.ID, nil
  823. }
  824. // IDX is like ID, but panics if an error occurs.
  825. func (u *SopStageUpsertOne) IDX(ctx context.Context) uint64 {
  826. id, err := u.ID(ctx)
  827. if err != nil {
  828. panic(err)
  829. }
  830. return id
  831. }
  832. // SopStageCreateBulk is the builder for creating many SopStage entities in bulk.
  833. type SopStageCreateBulk struct {
  834. config
  835. err error
  836. builders []*SopStageCreate
  837. conflict []sql.ConflictOption
  838. }
  839. // Save creates the SopStage entities in the database.
  840. func (sscb *SopStageCreateBulk) Save(ctx context.Context) ([]*SopStage, error) {
  841. if sscb.err != nil {
  842. return nil, sscb.err
  843. }
  844. specs := make([]*sqlgraph.CreateSpec, len(sscb.builders))
  845. nodes := make([]*SopStage, len(sscb.builders))
  846. mutators := make([]Mutator, len(sscb.builders))
  847. for i := range sscb.builders {
  848. func(i int, root context.Context) {
  849. builder := sscb.builders[i]
  850. builder.defaults()
  851. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  852. mutation, ok := m.(*SopStageMutation)
  853. if !ok {
  854. return nil, fmt.Errorf("unexpected mutation type %T", m)
  855. }
  856. if err := builder.check(); err != nil {
  857. return nil, err
  858. }
  859. builder.mutation = mutation
  860. var err error
  861. nodes[i], specs[i] = builder.createSpec()
  862. if i < len(mutators)-1 {
  863. _, err = mutators[i+1].Mutate(root, sscb.builders[i+1].mutation)
  864. } else {
  865. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  866. spec.OnConflict = sscb.conflict
  867. // Invoke the actual operation on the latest mutation in the chain.
  868. if err = sqlgraph.BatchCreate(ctx, sscb.driver, spec); err != nil {
  869. if sqlgraph.IsConstraintError(err) {
  870. err = &ConstraintError{msg: err.Error(), wrap: err}
  871. }
  872. }
  873. }
  874. if err != nil {
  875. return nil, err
  876. }
  877. mutation.id = &nodes[i].ID
  878. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  879. id := specs[i].ID.Value.(int64)
  880. nodes[i].ID = uint64(id)
  881. }
  882. mutation.done = true
  883. return nodes[i], nil
  884. })
  885. for i := len(builder.hooks) - 1; i >= 0; i-- {
  886. mut = builder.hooks[i](mut)
  887. }
  888. mutators[i] = mut
  889. }(i, ctx)
  890. }
  891. if len(mutators) > 0 {
  892. if _, err := mutators[0].Mutate(ctx, sscb.builders[0].mutation); err != nil {
  893. return nil, err
  894. }
  895. }
  896. return nodes, nil
  897. }
  898. // SaveX is like Save, but panics if an error occurs.
  899. func (sscb *SopStageCreateBulk) SaveX(ctx context.Context) []*SopStage {
  900. v, err := sscb.Save(ctx)
  901. if err != nil {
  902. panic(err)
  903. }
  904. return v
  905. }
  906. // Exec executes the query.
  907. func (sscb *SopStageCreateBulk) Exec(ctx context.Context) error {
  908. _, err := sscb.Save(ctx)
  909. return err
  910. }
  911. // ExecX is like Exec, but panics if an error occurs.
  912. func (sscb *SopStageCreateBulk) ExecX(ctx context.Context) {
  913. if err := sscb.Exec(ctx); err != nil {
  914. panic(err)
  915. }
  916. }
  917. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  918. // of the `INSERT` statement. For example:
  919. //
  920. // client.SopStage.CreateBulk(builders...).
  921. // OnConflict(
  922. // // Update the row with the new values
  923. // // the was proposed for insertion.
  924. // sql.ResolveWithNewValues(),
  925. // ).
  926. // // Override some of the fields with custom
  927. // // update values.
  928. // Update(func(u *ent.SopStageUpsert) {
  929. // SetCreatedAt(v+v).
  930. // }).
  931. // Exec(ctx)
  932. func (sscb *SopStageCreateBulk) OnConflict(opts ...sql.ConflictOption) *SopStageUpsertBulk {
  933. sscb.conflict = opts
  934. return &SopStageUpsertBulk{
  935. create: sscb,
  936. }
  937. }
  938. // OnConflictColumns calls `OnConflict` and configures the columns
  939. // as conflict target. Using this option is equivalent to using:
  940. //
  941. // client.SopStage.Create().
  942. // OnConflict(sql.ConflictColumns(columns...)).
  943. // Exec(ctx)
  944. func (sscb *SopStageCreateBulk) OnConflictColumns(columns ...string) *SopStageUpsertBulk {
  945. sscb.conflict = append(sscb.conflict, sql.ConflictColumns(columns...))
  946. return &SopStageUpsertBulk{
  947. create: sscb,
  948. }
  949. }
  950. // SopStageUpsertBulk is the builder for "upsert"-ing
  951. // a bulk of SopStage nodes.
  952. type SopStageUpsertBulk struct {
  953. create *SopStageCreateBulk
  954. }
  955. // UpdateNewValues updates the mutable fields using the new values that
  956. // were set on create. Using this option is equivalent to using:
  957. //
  958. // client.SopStage.Create().
  959. // OnConflict(
  960. // sql.ResolveWithNewValues(),
  961. // sql.ResolveWith(func(u *sql.UpdateSet) {
  962. // u.SetIgnore(sopstage.FieldID)
  963. // }),
  964. // ).
  965. // Exec(ctx)
  966. func (u *SopStageUpsertBulk) UpdateNewValues() *SopStageUpsertBulk {
  967. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  968. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  969. for _, b := range u.create.builders {
  970. if _, exists := b.mutation.ID(); exists {
  971. s.SetIgnore(sopstage.FieldID)
  972. }
  973. if _, exists := b.mutation.CreatedAt(); exists {
  974. s.SetIgnore(sopstage.FieldCreatedAt)
  975. }
  976. }
  977. }))
  978. return u
  979. }
  980. // Ignore sets each column to itself in case of conflict.
  981. // Using this option is equivalent to using:
  982. //
  983. // client.SopStage.Create().
  984. // OnConflict(sql.ResolveWithIgnore()).
  985. // Exec(ctx)
  986. func (u *SopStageUpsertBulk) Ignore() *SopStageUpsertBulk {
  987. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  988. return u
  989. }
  990. // DoNothing configures the conflict_action to `DO NOTHING`.
  991. // Supported only by SQLite and PostgreSQL.
  992. func (u *SopStageUpsertBulk) DoNothing() *SopStageUpsertBulk {
  993. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  994. return u
  995. }
  996. // Update allows overriding fields `UPDATE` values. See the SopStageCreateBulk.OnConflict
  997. // documentation for more info.
  998. func (u *SopStageUpsertBulk) Update(set func(*SopStageUpsert)) *SopStageUpsertBulk {
  999. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1000. set(&SopStageUpsert{UpdateSet: update})
  1001. }))
  1002. return u
  1003. }
  1004. // SetUpdatedAt sets the "updated_at" field.
  1005. func (u *SopStageUpsertBulk) SetUpdatedAt(v time.Time) *SopStageUpsertBulk {
  1006. return u.Update(func(s *SopStageUpsert) {
  1007. s.SetUpdatedAt(v)
  1008. })
  1009. }
  1010. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1011. func (u *SopStageUpsertBulk) UpdateUpdatedAt() *SopStageUpsertBulk {
  1012. return u.Update(func(s *SopStageUpsert) {
  1013. s.UpdateUpdatedAt()
  1014. })
  1015. }
  1016. // SetStatus sets the "status" field.
  1017. func (u *SopStageUpsertBulk) SetStatus(v uint8) *SopStageUpsertBulk {
  1018. return u.Update(func(s *SopStageUpsert) {
  1019. s.SetStatus(v)
  1020. })
  1021. }
  1022. // AddStatus adds v to the "status" field.
  1023. func (u *SopStageUpsertBulk) AddStatus(v uint8) *SopStageUpsertBulk {
  1024. return u.Update(func(s *SopStageUpsert) {
  1025. s.AddStatus(v)
  1026. })
  1027. }
  1028. // UpdateStatus sets the "status" field to the value that was provided on create.
  1029. func (u *SopStageUpsertBulk) UpdateStatus() *SopStageUpsertBulk {
  1030. return u.Update(func(s *SopStageUpsert) {
  1031. s.UpdateStatus()
  1032. })
  1033. }
  1034. // ClearStatus clears the value of the "status" field.
  1035. func (u *SopStageUpsertBulk) ClearStatus() *SopStageUpsertBulk {
  1036. return u.Update(func(s *SopStageUpsert) {
  1037. s.ClearStatus()
  1038. })
  1039. }
  1040. // SetDeletedAt sets the "deleted_at" field.
  1041. func (u *SopStageUpsertBulk) SetDeletedAt(v time.Time) *SopStageUpsertBulk {
  1042. return u.Update(func(s *SopStageUpsert) {
  1043. s.SetDeletedAt(v)
  1044. })
  1045. }
  1046. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1047. func (u *SopStageUpsertBulk) UpdateDeletedAt() *SopStageUpsertBulk {
  1048. return u.Update(func(s *SopStageUpsert) {
  1049. s.UpdateDeletedAt()
  1050. })
  1051. }
  1052. // ClearDeletedAt clears the value of the "deleted_at" field.
  1053. func (u *SopStageUpsertBulk) ClearDeletedAt() *SopStageUpsertBulk {
  1054. return u.Update(func(s *SopStageUpsert) {
  1055. s.ClearDeletedAt()
  1056. })
  1057. }
  1058. // SetTaskID sets the "task_id" field.
  1059. func (u *SopStageUpsertBulk) SetTaskID(v uint64) *SopStageUpsertBulk {
  1060. return u.Update(func(s *SopStageUpsert) {
  1061. s.SetTaskID(v)
  1062. })
  1063. }
  1064. // UpdateTaskID sets the "task_id" field to the value that was provided on create.
  1065. func (u *SopStageUpsertBulk) UpdateTaskID() *SopStageUpsertBulk {
  1066. return u.Update(func(s *SopStageUpsert) {
  1067. s.UpdateTaskID()
  1068. })
  1069. }
  1070. // SetName sets the "name" field.
  1071. func (u *SopStageUpsertBulk) SetName(v string) *SopStageUpsertBulk {
  1072. return u.Update(func(s *SopStageUpsert) {
  1073. s.SetName(v)
  1074. })
  1075. }
  1076. // UpdateName sets the "name" field to the value that was provided on create.
  1077. func (u *SopStageUpsertBulk) UpdateName() *SopStageUpsertBulk {
  1078. return u.Update(func(s *SopStageUpsert) {
  1079. s.UpdateName()
  1080. })
  1081. }
  1082. // SetConditionType sets the "condition_type" field.
  1083. func (u *SopStageUpsertBulk) SetConditionType(v int) *SopStageUpsertBulk {
  1084. return u.Update(func(s *SopStageUpsert) {
  1085. s.SetConditionType(v)
  1086. })
  1087. }
  1088. // AddConditionType adds v to the "condition_type" field.
  1089. func (u *SopStageUpsertBulk) AddConditionType(v int) *SopStageUpsertBulk {
  1090. return u.Update(func(s *SopStageUpsert) {
  1091. s.AddConditionType(v)
  1092. })
  1093. }
  1094. // UpdateConditionType sets the "condition_type" field to the value that was provided on create.
  1095. func (u *SopStageUpsertBulk) UpdateConditionType() *SopStageUpsertBulk {
  1096. return u.Update(func(s *SopStageUpsert) {
  1097. s.UpdateConditionType()
  1098. })
  1099. }
  1100. // SetConditionOperator sets the "condition_operator" field.
  1101. func (u *SopStageUpsertBulk) SetConditionOperator(v int) *SopStageUpsertBulk {
  1102. return u.Update(func(s *SopStageUpsert) {
  1103. s.SetConditionOperator(v)
  1104. })
  1105. }
  1106. // AddConditionOperator adds v to the "condition_operator" field.
  1107. func (u *SopStageUpsertBulk) AddConditionOperator(v int) *SopStageUpsertBulk {
  1108. return u.Update(func(s *SopStageUpsert) {
  1109. s.AddConditionOperator(v)
  1110. })
  1111. }
  1112. // UpdateConditionOperator sets the "condition_operator" field to the value that was provided on create.
  1113. func (u *SopStageUpsertBulk) UpdateConditionOperator() *SopStageUpsertBulk {
  1114. return u.Update(func(s *SopStageUpsert) {
  1115. s.UpdateConditionOperator()
  1116. })
  1117. }
  1118. // SetConditionList sets the "condition_list" field.
  1119. func (u *SopStageUpsertBulk) SetConditionList(v []custom_types.Condition) *SopStageUpsertBulk {
  1120. return u.Update(func(s *SopStageUpsert) {
  1121. s.SetConditionList(v)
  1122. })
  1123. }
  1124. // UpdateConditionList sets the "condition_list" field to the value that was provided on create.
  1125. func (u *SopStageUpsertBulk) UpdateConditionList() *SopStageUpsertBulk {
  1126. return u.Update(func(s *SopStageUpsert) {
  1127. s.UpdateConditionList()
  1128. })
  1129. }
  1130. // SetActionMessage sets the "action_message" field.
  1131. func (u *SopStageUpsertBulk) SetActionMessage(v []custom_types.Action) *SopStageUpsertBulk {
  1132. return u.Update(func(s *SopStageUpsert) {
  1133. s.SetActionMessage(v)
  1134. })
  1135. }
  1136. // UpdateActionMessage sets the "action_message" field to the value that was provided on create.
  1137. func (u *SopStageUpsertBulk) UpdateActionMessage() *SopStageUpsertBulk {
  1138. return u.Update(func(s *SopStageUpsert) {
  1139. s.UpdateActionMessage()
  1140. })
  1141. }
  1142. // ClearActionMessage clears the value of the "action_message" field.
  1143. func (u *SopStageUpsertBulk) ClearActionMessage() *SopStageUpsertBulk {
  1144. return u.Update(func(s *SopStageUpsert) {
  1145. s.ClearActionMessage()
  1146. })
  1147. }
  1148. // SetActionLabel sets the "action_label" field.
  1149. func (u *SopStageUpsertBulk) SetActionLabel(v []int) *SopStageUpsertBulk {
  1150. return u.Update(func(s *SopStageUpsert) {
  1151. s.SetActionLabel(v)
  1152. })
  1153. }
  1154. // UpdateActionLabel sets the "action_label" field to the value that was provided on create.
  1155. func (u *SopStageUpsertBulk) UpdateActionLabel() *SopStageUpsertBulk {
  1156. return u.Update(func(s *SopStageUpsert) {
  1157. s.UpdateActionLabel()
  1158. })
  1159. }
  1160. // ClearActionLabel clears the value of the "action_label" field.
  1161. func (u *SopStageUpsertBulk) ClearActionLabel() *SopStageUpsertBulk {
  1162. return u.Update(func(s *SopStageUpsert) {
  1163. s.ClearActionLabel()
  1164. })
  1165. }
  1166. // SetIndexSort sets the "index_sort" field.
  1167. func (u *SopStageUpsertBulk) SetIndexSort(v int) *SopStageUpsertBulk {
  1168. return u.Update(func(s *SopStageUpsert) {
  1169. s.SetIndexSort(v)
  1170. })
  1171. }
  1172. // AddIndexSort adds v to the "index_sort" field.
  1173. func (u *SopStageUpsertBulk) AddIndexSort(v int) *SopStageUpsertBulk {
  1174. return u.Update(func(s *SopStageUpsert) {
  1175. s.AddIndexSort(v)
  1176. })
  1177. }
  1178. // UpdateIndexSort sets the "index_sort" field to the value that was provided on create.
  1179. func (u *SopStageUpsertBulk) UpdateIndexSort() *SopStageUpsertBulk {
  1180. return u.Update(func(s *SopStageUpsert) {
  1181. s.UpdateIndexSort()
  1182. })
  1183. }
  1184. // ClearIndexSort clears the value of the "index_sort" field.
  1185. func (u *SopStageUpsertBulk) ClearIndexSort() *SopStageUpsertBulk {
  1186. return u.Update(func(s *SopStageUpsert) {
  1187. s.ClearIndexSort()
  1188. })
  1189. }
  1190. // Exec executes the query.
  1191. func (u *SopStageUpsertBulk) Exec(ctx context.Context) error {
  1192. if u.create.err != nil {
  1193. return u.create.err
  1194. }
  1195. for i, b := range u.create.builders {
  1196. if len(b.conflict) != 0 {
  1197. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SopStageCreateBulk instead", i)
  1198. }
  1199. }
  1200. if len(u.create.conflict) == 0 {
  1201. return errors.New("ent: missing options for SopStageCreateBulk.OnConflict")
  1202. }
  1203. return u.create.Exec(ctx)
  1204. }
  1205. // ExecX is like Exec, but panics if an error occurs.
  1206. func (u *SopStageUpsertBulk) ExecX(ctx context.Context) {
  1207. if err := u.create.Exec(ctx); err != nil {
  1208. panic(err)
  1209. }
  1210. }