soptask_create.go 39 KB

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