soptask_create.go 37 KB

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