soptask_create.go 34 KB

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