soptask_create.go 39 KB

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