employee_create.go 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  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/employee"
  9. "wechat-api/ent/tutorial"
  10. "wechat-api/ent/workexperience"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/schema/field"
  14. )
  15. // EmployeeCreate is the builder for creating a Employee entity.
  16. type EmployeeCreate struct {
  17. config
  18. mutation *EmployeeMutation
  19. hooks []Hook
  20. conflict []sql.ConflictOption
  21. }
  22. // SetCreatedAt sets the "created_at" field.
  23. func (ec *EmployeeCreate) SetCreatedAt(t time.Time) *EmployeeCreate {
  24. ec.mutation.SetCreatedAt(t)
  25. return ec
  26. }
  27. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  28. func (ec *EmployeeCreate) SetNillableCreatedAt(t *time.Time) *EmployeeCreate {
  29. if t != nil {
  30. ec.SetCreatedAt(*t)
  31. }
  32. return ec
  33. }
  34. // SetUpdatedAt sets the "updated_at" field.
  35. func (ec *EmployeeCreate) SetUpdatedAt(t time.Time) *EmployeeCreate {
  36. ec.mutation.SetUpdatedAt(t)
  37. return ec
  38. }
  39. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  40. func (ec *EmployeeCreate) SetNillableUpdatedAt(t *time.Time) *EmployeeCreate {
  41. if t != nil {
  42. ec.SetUpdatedAt(*t)
  43. }
  44. return ec
  45. }
  46. // SetDeletedAt sets the "deleted_at" field.
  47. func (ec *EmployeeCreate) SetDeletedAt(t time.Time) *EmployeeCreate {
  48. ec.mutation.SetDeletedAt(t)
  49. return ec
  50. }
  51. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  52. func (ec *EmployeeCreate) SetNillableDeletedAt(t *time.Time) *EmployeeCreate {
  53. if t != nil {
  54. ec.SetDeletedAt(*t)
  55. }
  56. return ec
  57. }
  58. // SetTitle sets the "title" field.
  59. func (ec *EmployeeCreate) SetTitle(s string) *EmployeeCreate {
  60. ec.mutation.SetTitle(s)
  61. return ec
  62. }
  63. // SetAvatar sets the "avatar" field.
  64. func (ec *EmployeeCreate) SetAvatar(s string) *EmployeeCreate {
  65. ec.mutation.SetAvatar(s)
  66. return ec
  67. }
  68. // SetTags sets the "tags" field.
  69. func (ec *EmployeeCreate) SetTags(s string) *EmployeeCreate {
  70. ec.mutation.SetTags(s)
  71. return ec
  72. }
  73. // SetHireCount sets the "hire_count" field.
  74. func (ec *EmployeeCreate) SetHireCount(i int) *EmployeeCreate {
  75. ec.mutation.SetHireCount(i)
  76. return ec
  77. }
  78. // SetNillableHireCount sets the "hire_count" field if the given value is not nil.
  79. func (ec *EmployeeCreate) SetNillableHireCount(i *int) *EmployeeCreate {
  80. if i != nil {
  81. ec.SetHireCount(*i)
  82. }
  83. return ec
  84. }
  85. // SetServiceCount sets the "service_count" field.
  86. func (ec *EmployeeCreate) SetServiceCount(i int) *EmployeeCreate {
  87. ec.mutation.SetServiceCount(i)
  88. return ec
  89. }
  90. // SetNillableServiceCount sets the "service_count" field if the given value is not nil.
  91. func (ec *EmployeeCreate) SetNillableServiceCount(i *int) *EmployeeCreate {
  92. if i != nil {
  93. ec.SetServiceCount(*i)
  94. }
  95. return ec
  96. }
  97. // SetAchievementCount sets the "achievement_count" field.
  98. func (ec *EmployeeCreate) SetAchievementCount(i int) *EmployeeCreate {
  99. ec.mutation.SetAchievementCount(i)
  100. return ec
  101. }
  102. // SetNillableAchievementCount sets the "achievement_count" field if the given value is not nil.
  103. func (ec *EmployeeCreate) SetNillableAchievementCount(i *int) *EmployeeCreate {
  104. if i != nil {
  105. ec.SetAchievementCount(*i)
  106. }
  107. return ec
  108. }
  109. // SetIntro sets the "intro" field.
  110. func (ec *EmployeeCreate) SetIntro(s string) *EmployeeCreate {
  111. ec.mutation.SetIntro(s)
  112. return ec
  113. }
  114. // SetNillableIntro sets the "intro" field if the given value is not nil.
  115. func (ec *EmployeeCreate) SetNillableIntro(s *string) *EmployeeCreate {
  116. if s != nil {
  117. ec.SetIntro(*s)
  118. }
  119. return ec
  120. }
  121. // SetEstimate sets the "estimate" field.
  122. func (ec *EmployeeCreate) SetEstimate(s string) *EmployeeCreate {
  123. ec.mutation.SetEstimate(s)
  124. return ec
  125. }
  126. // SetNillableEstimate sets the "estimate" field if the given value is not nil.
  127. func (ec *EmployeeCreate) SetNillableEstimate(s *string) *EmployeeCreate {
  128. if s != nil {
  129. ec.SetEstimate(*s)
  130. }
  131. return ec
  132. }
  133. // SetSkill sets the "skill" field.
  134. func (ec *EmployeeCreate) SetSkill(s string) *EmployeeCreate {
  135. ec.mutation.SetSkill(s)
  136. return ec
  137. }
  138. // SetNillableSkill sets the "skill" field if the given value is not nil.
  139. func (ec *EmployeeCreate) SetNillableSkill(s *string) *EmployeeCreate {
  140. if s != nil {
  141. ec.SetSkill(*s)
  142. }
  143. return ec
  144. }
  145. // SetAbilityType sets the "ability_type" field.
  146. func (ec *EmployeeCreate) SetAbilityType(s string) *EmployeeCreate {
  147. ec.mutation.SetAbilityType(s)
  148. return ec
  149. }
  150. // SetNillableAbilityType sets the "ability_type" field if the given value is not nil.
  151. func (ec *EmployeeCreate) SetNillableAbilityType(s *string) *EmployeeCreate {
  152. if s != nil {
  153. ec.SetAbilityType(*s)
  154. }
  155. return ec
  156. }
  157. // SetScene sets the "scene" field.
  158. func (ec *EmployeeCreate) SetScene(s string) *EmployeeCreate {
  159. ec.mutation.SetScene(s)
  160. return ec
  161. }
  162. // SetNillableScene sets the "scene" field if the given value is not nil.
  163. func (ec *EmployeeCreate) SetNillableScene(s *string) *EmployeeCreate {
  164. if s != nil {
  165. ec.SetScene(*s)
  166. }
  167. return ec
  168. }
  169. // SetSwitchIn sets the "switch_in" field.
  170. func (ec *EmployeeCreate) SetSwitchIn(s string) *EmployeeCreate {
  171. ec.mutation.SetSwitchIn(s)
  172. return ec
  173. }
  174. // SetNillableSwitchIn sets the "switch_in" field if the given value is not nil.
  175. func (ec *EmployeeCreate) SetNillableSwitchIn(s *string) *EmployeeCreate {
  176. if s != nil {
  177. ec.SetSwitchIn(*s)
  178. }
  179. return ec
  180. }
  181. // SetVideoURL sets the "video_url" field.
  182. func (ec *EmployeeCreate) SetVideoURL(s string) *EmployeeCreate {
  183. ec.mutation.SetVideoURL(s)
  184. return ec
  185. }
  186. // SetNillableVideoURL sets the "video_url" field if the given value is not nil.
  187. func (ec *EmployeeCreate) SetNillableVideoURL(s *string) *EmployeeCreate {
  188. if s != nil {
  189. ec.SetVideoURL(*s)
  190. }
  191. return ec
  192. }
  193. // SetOrganizationID sets the "organization_id" field.
  194. func (ec *EmployeeCreate) SetOrganizationID(u uint64) *EmployeeCreate {
  195. ec.mutation.SetOrganizationID(u)
  196. return ec
  197. }
  198. // SetCategoryID sets the "category_id" field.
  199. func (ec *EmployeeCreate) SetCategoryID(u uint64) *EmployeeCreate {
  200. ec.mutation.SetCategoryID(u)
  201. return ec
  202. }
  203. // SetAPIBase sets the "api_base" field.
  204. func (ec *EmployeeCreate) SetAPIBase(s string) *EmployeeCreate {
  205. ec.mutation.SetAPIBase(s)
  206. return ec
  207. }
  208. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  209. func (ec *EmployeeCreate) SetNillableAPIBase(s *string) *EmployeeCreate {
  210. if s != nil {
  211. ec.SetAPIBase(*s)
  212. }
  213. return ec
  214. }
  215. // SetAPIKey sets the "api_key" field.
  216. func (ec *EmployeeCreate) SetAPIKey(s string) *EmployeeCreate {
  217. ec.mutation.SetAPIKey(s)
  218. return ec
  219. }
  220. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  221. func (ec *EmployeeCreate) SetNillableAPIKey(s *string) *EmployeeCreate {
  222. if s != nil {
  223. ec.SetAPIKey(*s)
  224. }
  225. return ec
  226. }
  227. // SetID sets the "id" field.
  228. func (ec *EmployeeCreate) SetID(u uint64) *EmployeeCreate {
  229. ec.mutation.SetID(u)
  230. return ec
  231. }
  232. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by IDs.
  233. func (ec *EmployeeCreate) AddEmWorkExperienceIDs(ids ...uint64) *EmployeeCreate {
  234. ec.mutation.AddEmWorkExperienceIDs(ids...)
  235. return ec
  236. }
  237. // AddEmWorkExperiences adds the "em_work_experiences" edges to the WorkExperience entity.
  238. func (ec *EmployeeCreate) AddEmWorkExperiences(w ...*WorkExperience) *EmployeeCreate {
  239. ids := make([]uint64, len(w))
  240. for i := range w {
  241. ids[i] = w[i].ID
  242. }
  243. return ec.AddEmWorkExperienceIDs(ids...)
  244. }
  245. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by IDs.
  246. func (ec *EmployeeCreate) AddEmTutorialIDs(ids ...uint64) *EmployeeCreate {
  247. ec.mutation.AddEmTutorialIDs(ids...)
  248. return ec
  249. }
  250. // AddEmTutorial adds the "em_tutorial" edges to the Tutorial entity.
  251. func (ec *EmployeeCreate) AddEmTutorial(t ...*Tutorial) *EmployeeCreate {
  252. ids := make([]uint64, len(t))
  253. for i := range t {
  254. ids[i] = t[i].ID
  255. }
  256. return ec.AddEmTutorialIDs(ids...)
  257. }
  258. // Mutation returns the EmployeeMutation object of the builder.
  259. func (ec *EmployeeCreate) Mutation() *EmployeeMutation {
  260. return ec.mutation
  261. }
  262. // Save creates the Employee in the database.
  263. func (ec *EmployeeCreate) Save(ctx context.Context) (*Employee, error) {
  264. if err := ec.defaults(); err != nil {
  265. return nil, err
  266. }
  267. return withHooks(ctx, ec.sqlSave, ec.mutation, ec.hooks)
  268. }
  269. // SaveX calls Save and panics if Save returns an error.
  270. func (ec *EmployeeCreate) SaveX(ctx context.Context) *Employee {
  271. v, err := ec.Save(ctx)
  272. if err != nil {
  273. panic(err)
  274. }
  275. return v
  276. }
  277. // Exec executes the query.
  278. func (ec *EmployeeCreate) Exec(ctx context.Context) error {
  279. _, err := ec.Save(ctx)
  280. return err
  281. }
  282. // ExecX is like Exec, but panics if an error occurs.
  283. func (ec *EmployeeCreate) ExecX(ctx context.Context) {
  284. if err := ec.Exec(ctx); err != nil {
  285. panic(err)
  286. }
  287. }
  288. // defaults sets the default values of the builder before save.
  289. func (ec *EmployeeCreate) defaults() error {
  290. if _, ok := ec.mutation.CreatedAt(); !ok {
  291. if employee.DefaultCreatedAt == nil {
  292. return fmt.Errorf("ent: uninitialized employee.DefaultCreatedAt (forgotten import ent/runtime?)")
  293. }
  294. v := employee.DefaultCreatedAt()
  295. ec.mutation.SetCreatedAt(v)
  296. }
  297. if _, ok := ec.mutation.UpdatedAt(); !ok {
  298. if employee.DefaultUpdatedAt == nil {
  299. return fmt.Errorf("ent: uninitialized employee.DefaultUpdatedAt (forgotten import ent/runtime?)")
  300. }
  301. v := employee.DefaultUpdatedAt()
  302. ec.mutation.SetUpdatedAt(v)
  303. }
  304. if _, ok := ec.mutation.HireCount(); !ok {
  305. v := employee.DefaultHireCount
  306. ec.mutation.SetHireCount(v)
  307. }
  308. if _, ok := ec.mutation.ServiceCount(); !ok {
  309. v := employee.DefaultServiceCount
  310. ec.mutation.SetServiceCount(v)
  311. }
  312. if _, ok := ec.mutation.AchievementCount(); !ok {
  313. v := employee.DefaultAchievementCount
  314. ec.mutation.SetAchievementCount(v)
  315. }
  316. if _, ok := ec.mutation.Intro(); !ok {
  317. v := employee.DefaultIntro
  318. ec.mutation.SetIntro(v)
  319. }
  320. if _, ok := ec.mutation.Estimate(); !ok {
  321. v := employee.DefaultEstimate
  322. ec.mutation.SetEstimate(v)
  323. }
  324. if _, ok := ec.mutation.Skill(); !ok {
  325. v := employee.DefaultSkill
  326. ec.mutation.SetSkill(v)
  327. }
  328. if _, ok := ec.mutation.AbilityType(); !ok {
  329. v := employee.DefaultAbilityType
  330. ec.mutation.SetAbilityType(v)
  331. }
  332. if _, ok := ec.mutation.Scene(); !ok {
  333. v := employee.DefaultScene
  334. ec.mutation.SetScene(v)
  335. }
  336. if _, ok := ec.mutation.SwitchIn(); !ok {
  337. v := employee.DefaultSwitchIn
  338. ec.mutation.SetSwitchIn(v)
  339. }
  340. if _, ok := ec.mutation.VideoURL(); !ok {
  341. v := employee.DefaultVideoURL
  342. ec.mutation.SetVideoURL(v)
  343. }
  344. if _, ok := ec.mutation.APIBase(); !ok {
  345. v := employee.DefaultAPIBase
  346. ec.mutation.SetAPIBase(v)
  347. }
  348. if _, ok := ec.mutation.APIKey(); !ok {
  349. v := employee.DefaultAPIKey
  350. ec.mutation.SetAPIKey(v)
  351. }
  352. return nil
  353. }
  354. // check runs all checks and user-defined validators on the builder.
  355. func (ec *EmployeeCreate) check() error {
  356. if _, ok := ec.mutation.CreatedAt(); !ok {
  357. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Employee.created_at"`)}
  358. }
  359. if _, ok := ec.mutation.UpdatedAt(); !ok {
  360. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Employee.updated_at"`)}
  361. }
  362. if _, ok := ec.mutation.Title(); !ok {
  363. return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Employee.title"`)}
  364. }
  365. if v, ok := ec.mutation.Title(); ok {
  366. if err := employee.TitleValidator(v); err != nil {
  367. return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)}
  368. }
  369. }
  370. if _, ok := ec.mutation.Avatar(); !ok {
  371. return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "Employee.avatar"`)}
  372. }
  373. if v, ok := ec.mutation.Avatar(); ok {
  374. if err := employee.AvatarValidator(v); err != nil {
  375. return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
  376. }
  377. }
  378. if _, ok := ec.mutation.Tags(); !ok {
  379. return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "Employee.tags"`)}
  380. }
  381. if v, ok := ec.mutation.Tags(); ok {
  382. if err := employee.TagsValidator(v); err != nil {
  383. return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
  384. }
  385. }
  386. if _, ok := ec.mutation.HireCount(); !ok {
  387. return &ValidationError{Name: "hire_count", err: errors.New(`ent: missing required field "Employee.hire_count"`)}
  388. }
  389. if v, ok := ec.mutation.HireCount(); ok {
  390. if err := employee.HireCountValidator(v); err != nil {
  391. return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)}
  392. }
  393. }
  394. if _, ok := ec.mutation.ServiceCount(); !ok {
  395. return &ValidationError{Name: "service_count", err: errors.New(`ent: missing required field "Employee.service_count"`)}
  396. }
  397. if v, ok := ec.mutation.ServiceCount(); ok {
  398. if err := employee.ServiceCountValidator(v); err != nil {
  399. return &ValidationError{Name: "service_count", err: fmt.Errorf(`ent: validator failed for field "Employee.service_count": %w`, err)}
  400. }
  401. }
  402. if _, ok := ec.mutation.AchievementCount(); !ok {
  403. return &ValidationError{Name: "achievement_count", err: errors.New(`ent: missing required field "Employee.achievement_count"`)}
  404. }
  405. if v, ok := ec.mutation.AchievementCount(); ok {
  406. if err := employee.AchievementCountValidator(v); err != nil {
  407. return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)}
  408. }
  409. }
  410. if _, ok := ec.mutation.Intro(); !ok {
  411. return &ValidationError{Name: "intro", err: errors.New(`ent: missing required field "Employee.intro"`)}
  412. }
  413. if v, ok := ec.mutation.Intro(); ok {
  414. if err := employee.IntroValidator(v); err != nil {
  415. return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
  416. }
  417. }
  418. if _, ok := ec.mutation.Estimate(); !ok {
  419. return &ValidationError{Name: "estimate", err: errors.New(`ent: missing required field "Employee.estimate"`)}
  420. }
  421. if v, ok := ec.mutation.Estimate(); ok {
  422. if err := employee.EstimateValidator(v); err != nil {
  423. return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
  424. }
  425. }
  426. if _, ok := ec.mutation.Skill(); !ok {
  427. return &ValidationError{Name: "skill", err: errors.New(`ent: missing required field "Employee.skill"`)}
  428. }
  429. if v, ok := ec.mutation.Skill(); ok {
  430. if err := employee.SkillValidator(v); err != nil {
  431. return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
  432. }
  433. }
  434. if _, ok := ec.mutation.AbilityType(); !ok {
  435. return &ValidationError{Name: "ability_type", err: errors.New(`ent: missing required field "Employee.ability_type"`)}
  436. }
  437. if _, ok := ec.mutation.Scene(); !ok {
  438. return &ValidationError{Name: "scene", err: errors.New(`ent: missing required field "Employee.scene"`)}
  439. }
  440. if _, ok := ec.mutation.SwitchIn(); !ok {
  441. return &ValidationError{Name: "switch_in", err: errors.New(`ent: missing required field "Employee.switch_in"`)}
  442. }
  443. if _, ok := ec.mutation.VideoURL(); !ok {
  444. return &ValidationError{Name: "video_url", err: errors.New(`ent: missing required field "Employee.video_url"`)}
  445. }
  446. if v, ok := ec.mutation.VideoURL(); ok {
  447. if err := employee.VideoURLValidator(v); err != nil {
  448. return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
  449. }
  450. }
  451. if _, ok := ec.mutation.OrganizationID(); !ok {
  452. return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Employee.organization_id"`)}
  453. }
  454. if v, ok := ec.mutation.OrganizationID(); ok {
  455. if err := employee.OrganizationIDValidator(v); err != nil {
  456. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)}
  457. }
  458. }
  459. if _, ok := ec.mutation.CategoryID(); !ok {
  460. return &ValidationError{Name: "category_id", err: errors.New(`ent: missing required field "Employee.category_id"`)}
  461. }
  462. if v, ok := ec.mutation.CategoryID(); ok {
  463. if err := employee.CategoryIDValidator(v); err != nil {
  464. return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Employee.category_id": %w`, err)}
  465. }
  466. }
  467. if _, ok := ec.mutation.APIBase(); !ok {
  468. return &ValidationError{Name: "api_base", err: errors.New(`ent: missing required field "Employee.api_base"`)}
  469. }
  470. if _, ok := ec.mutation.APIKey(); !ok {
  471. return &ValidationError{Name: "api_key", err: errors.New(`ent: missing required field "Employee.api_key"`)}
  472. }
  473. return nil
  474. }
  475. func (ec *EmployeeCreate) sqlSave(ctx context.Context) (*Employee, error) {
  476. if err := ec.check(); err != nil {
  477. return nil, err
  478. }
  479. _node, _spec := ec.createSpec()
  480. if err := sqlgraph.CreateNode(ctx, ec.driver, _spec); err != nil {
  481. if sqlgraph.IsConstraintError(err) {
  482. err = &ConstraintError{msg: err.Error(), wrap: err}
  483. }
  484. return nil, err
  485. }
  486. if _spec.ID.Value != _node.ID {
  487. id := _spec.ID.Value.(int64)
  488. _node.ID = uint64(id)
  489. }
  490. ec.mutation.id = &_node.ID
  491. ec.mutation.done = true
  492. return _node, nil
  493. }
  494. func (ec *EmployeeCreate) createSpec() (*Employee, *sqlgraph.CreateSpec) {
  495. var (
  496. _node = &Employee{config: ec.config}
  497. _spec = sqlgraph.NewCreateSpec(employee.Table, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64))
  498. )
  499. _spec.OnConflict = ec.conflict
  500. if id, ok := ec.mutation.ID(); ok {
  501. _node.ID = id
  502. _spec.ID.Value = id
  503. }
  504. if value, ok := ec.mutation.CreatedAt(); ok {
  505. _spec.SetField(employee.FieldCreatedAt, field.TypeTime, value)
  506. _node.CreatedAt = value
  507. }
  508. if value, ok := ec.mutation.UpdatedAt(); ok {
  509. _spec.SetField(employee.FieldUpdatedAt, field.TypeTime, value)
  510. _node.UpdatedAt = value
  511. }
  512. if value, ok := ec.mutation.DeletedAt(); ok {
  513. _spec.SetField(employee.FieldDeletedAt, field.TypeTime, value)
  514. _node.DeletedAt = value
  515. }
  516. if value, ok := ec.mutation.Title(); ok {
  517. _spec.SetField(employee.FieldTitle, field.TypeString, value)
  518. _node.Title = value
  519. }
  520. if value, ok := ec.mutation.Avatar(); ok {
  521. _spec.SetField(employee.FieldAvatar, field.TypeString, value)
  522. _node.Avatar = value
  523. }
  524. if value, ok := ec.mutation.Tags(); ok {
  525. _spec.SetField(employee.FieldTags, field.TypeString, value)
  526. _node.Tags = value
  527. }
  528. if value, ok := ec.mutation.HireCount(); ok {
  529. _spec.SetField(employee.FieldHireCount, field.TypeInt, value)
  530. _node.HireCount = value
  531. }
  532. if value, ok := ec.mutation.ServiceCount(); ok {
  533. _spec.SetField(employee.FieldServiceCount, field.TypeInt, value)
  534. _node.ServiceCount = value
  535. }
  536. if value, ok := ec.mutation.AchievementCount(); ok {
  537. _spec.SetField(employee.FieldAchievementCount, field.TypeInt, value)
  538. _node.AchievementCount = value
  539. }
  540. if value, ok := ec.mutation.Intro(); ok {
  541. _spec.SetField(employee.FieldIntro, field.TypeString, value)
  542. _node.Intro = value
  543. }
  544. if value, ok := ec.mutation.Estimate(); ok {
  545. _spec.SetField(employee.FieldEstimate, field.TypeString, value)
  546. _node.Estimate = value
  547. }
  548. if value, ok := ec.mutation.Skill(); ok {
  549. _spec.SetField(employee.FieldSkill, field.TypeString, value)
  550. _node.Skill = value
  551. }
  552. if value, ok := ec.mutation.AbilityType(); ok {
  553. _spec.SetField(employee.FieldAbilityType, field.TypeString, value)
  554. _node.AbilityType = value
  555. }
  556. if value, ok := ec.mutation.Scene(); ok {
  557. _spec.SetField(employee.FieldScene, field.TypeString, value)
  558. _node.Scene = value
  559. }
  560. if value, ok := ec.mutation.SwitchIn(); ok {
  561. _spec.SetField(employee.FieldSwitchIn, field.TypeString, value)
  562. _node.SwitchIn = value
  563. }
  564. if value, ok := ec.mutation.VideoURL(); ok {
  565. _spec.SetField(employee.FieldVideoURL, field.TypeString, value)
  566. _node.VideoURL = value
  567. }
  568. if value, ok := ec.mutation.OrganizationID(); ok {
  569. _spec.SetField(employee.FieldOrganizationID, field.TypeUint64, value)
  570. _node.OrganizationID = value
  571. }
  572. if value, ok := ec.mutation.CategoryID(); ok {
  573. _spec.SetField(employee.FieldCategoryID, field.TypeUint64, value)
  574. _node.CategoryID = value
  575. }
  576. if value, ok := ec.mutation.APIBase(); ok {
  577. _spec.SetField(employee.FieldAPIBase, field.TypeString, value)
  578. _node.APIBase = value
  579. }
  580. if value, ok := ec.mutation.APIKey(); ok {
  581. _spec.SetField(employee.FieldAPIKey, field.TypeString, value)
  582. _node.APIKey = value
  583. }
  584. if nodes := ec.mutation.EmWorkExperiencesIDs(); len(nodes) > 0 {
  585. edge := &sqlgraph.EdgeSpec{
  586. Rel: sqlgraph.O2M,
  587. Inverse: false,
  588. Table: employee.EmWorkExperiencesTable,
  589. Columns: []string{employee.EmWorkExperiencesColumn},
  590. Bidi: false,
  591. Target: &sqlgraph.EdgeTarget{
  592. IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
  593. },
  594. }
  595. for _, k := range nodes {
  596. edge.Target.Nodes = append(edge.Target.Nodes, k)
  597. }
  598. _spec.Edges = append(_spec.Edges, edge)
  599. }
  600. if nodes := ec.mutation.EmTutorialIDs(); len(nodes) > 0 {
  601. edge := &sqlgraph.EdgeSpec{
  602. Rel: sqlgraph.O2M,
  603. Inverse: false,
  604. Table: employee.EmTutorialTable,
  605. Columns: []string{employee.EmTutorialColumn},
  606. Bidi: false,
  607. Target: &sqlgraph.EdgeTarget{
  608. IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
  609. },
  610. }
  611. for _, k := range nodes {
  612. edge.Target.Nodes = append(edge.Target.Nodes, k)
  613. }
  614. _spec.Edges = append(_spec.Edges, edge)
  615. }
  616. return _node, _spec
  617. }
  618. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  619. // of the `INSERT` statement. For example:
  620. //
  621. // client.Employee.Create().
  622. // SetCreatedAt(v).
  623. // OnConflict(
  624. // // Update the row with the new values
  625. // // the was proposed for insertion.
  626. // sql.ResolveWithNewValues(),
  627. // ).
  628. // // Override some of the fields with custom
  629. // // update values.
  630. // Update(func(u *ent.EmployeeUpsert) {
  631. // SetCreatedAt(v+v).
  632. // }).
  633. // Exec(ctx)
  634. func (ec *EmployeeCreate) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertOne {
  635. ec.conflict = opts
  636. return &EmployeeUpsertOne{
  637. create: ec,
  638. }
  639. }
  640. // OnConflictColumns calls `OnConflict` and configures the columns
  641. // as conflict target. Using this option is equivalent to using:
  642. //
  643. // client.Employee.Create().
  644. // OnConflict(sql.ConflictColumns(columns...)).
  645. // Exec(ctx)
  646. func (ec *EmployeeCreate) OnConflictColumns(columns ...string) *EmployeeUpsertOne {
  647. ec.conflict = append(ec.conflict, sql.ConflictColumns(columns...))
  648. return &EmployeeUpsertOne{
  649. create: ec,
  650. }
  651. }
  652. type (
  653. // EmployeeUpsertOne is the builder for "upsert"-ing
  654. // one Employee node.
  655. EmployeeUpsertOne struct {
  656. create *EmployeeCreate
  657. }
  658. // EmployeeUpsert is the "OnConflict" setter.
  659. EmployeeUpsert struct {
  660. *sql.UpdateSet
  661. }
  662. )
  663. // SetUpdatedAt sets the "updated_at" field.
  664. func (u *EmployeeUpsert) SetUpdatedAt(v time.Time) *EmployeeUpsert {
  665. u.Set(employee.FieldUpdatedAt, v)
  666. return u
  667. }
  668. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  669. func (u *EmployeeUpsert) UpdateUpdatedAt() *EmployeeUpsert {
  670. u.SetExcluded(employee.FieldUpdatedAt)
  671. return u
  672. }
  673. // SetDeletedAt sets the "deleted_at" field.
  674. func (u *EmployeeUpsert) SetDeletedAt(v time.Time) *EmployeeUpsert {
  675. u.Set(employee.FieldDeletedAt, v)
  676. return u
  677. }
  678. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  679. func (u *EmployeeUpsert) UpdateDeletedAt() *EmployeeUpsert {
  680. u.SetExcluded(employee.FieldDeletedAt)
  681. return u
  682. }
  683. // ClearDeletedAt clears the value of the "deleted_at" field.
  684. func (u *EmployeeUpsert) ClearDeletedAt() *EmployeeUpsert {
  685. u.SetNull(employee.FieldDeletedAt)
  686. return u
  687. }
  688. // SetTitle sets the "title" field.
  689. func (u *EmployeeUpsert) SetTitle(v string) *EmployeeUpsert {
  690. u.Set(employee.FieldTitle, v)
  691. return u
  692. }
  693. // UpdateTitle sets the "title" field to the value that was provided on create.
  694. func (u *EmployeeUpsert) UpdateTitle() *EmployeeUpsert {
  695. u.SetExcluded(employee.FieldTitle)
  696. return u
  697. }
  698. // SetAvatar sets the "avatar" field.
  699. func (u *EmployeeUpsert) SetAvatar(v string) *EmployeeUpsert {
  700. u.Set(employee.FieldAvatar, v)
  701. return u
  702. }
  703. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  704. func (u *EmployeeUpsert) UpdateAvatar() *EmployeeUpsert {
  705. u.SetExcluded(employee.FieldAvatar)
  706. return u
  707. }
  708. // SetTags sets the "tags" field.
  709. func (u *EmployeeUpsert) SetTags(v string) *EmployeeUpsert {
  710. u.Set(employee.FieldTags, v)
  711. return u
  712. }
  713. // UpdateTags sets the "tags" field to the value that was provided on create.
  714. func (u *EmployeeUpsert) UpdateTags() *EmployeeUpsert {
  715. u.SetExcluded(employee.FieldTags)
  716. return u
  717. }
  718. // SetHireCount sets the "hire_count" field.
  719. func (u *EmployeeUpsert) SetHireCount(v int) *EmployeeUpsert {
  720. u.Set(employee.FieldHireCount, v)
  721. return u
  722. }
  723. // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
  724. func (u *EmployeeUpsert) UpdateHireCount() *EmployeeUpsert {
  725. u.SetExcluded(employee.FieldHireCount)
  726. return u
  727. }
  728. // AddHireCount adds v to the "hire_count" field.
  729. func (u *EmployeeUpsert) AddHireCount(v int) *EmployeeUpsert {
  730. u.Add(employee.FieldHireCount, v)
  731. return u
  732. }
  733. // SetServiceCount sets the "service_count" field.
  734. func (u *EmployeeUpsert) SetServiceCount(v int) *EmployeeUpsert {
  735. u.Set(employee.FieldServiceCount, v)
  736. return u
  737. }
  738. // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
  739. func (u *EmployeeUpsert) UpdateServiceCount() *EmployeeUpsert {
  740. u.SetExcluded(employee.FieldServiceCount)
  741. return u
  742. }
  743. // AddServiceCount adds v to the "service_count" field.
  744. func (u *EmployeeUpsert) AddServiceCount(v int) *EmployeeUpsert {
  745. u.Add(employee.FieldServiceCount, v)
  746. return u
  747. }
  748. // SetAchievementCount sets the "achievement_count" field.
  749. func (u *EmployeeUpsert) SetAchievementCount(v int) *EmployeeUpsert {
  750. u.Set(employee.FieldAchievementCount, v)
  751. return u
  752. }
  753. // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
  754. func (u *EmployeeUpsert) UpdateAchievementCount() *EmployeeUpsert {
  755. u.SetExcluded(employee.FieldAchievementCount)
  756. return u
  757. }
  758. // AddAchievementCount adds v to the "achievement_count" field.
  759. func (u *EmployeeUpsert) AddAchievementCount(v int) *EmployeeUpsert {
  760. u.Add(employee.FieldAchievementCount, v)
  761. return u
  762. }
  763. // SetIntro sets the "intro" field.
  764. func (u *EmployeeUpsert) SetIntro(v string) *EmployeeUpsert {
  765. u.Set(employee.FieldIntro, v)
  766. return u
  767. }
  768. // UpdateIntro sets the "intro" field to the value that was provided on create.
  769. func (u *EmployeeUpsert) UpdateIntro() *EmployeeUpsert {
  770. u.SetExcluded(employee.FieldIntro)
  771. return u
  772. }
  773. // SetEstimate sets the "estimate" field.
  774. func (u *EmployeeUpsert) SetEstimate(v string) *EmployeeUpsert {
  775. u.Set(employee.FieldEstimate, v)
  776. return u
  777. }
  778. // UpdateEstimate sets the "estimate" field to the value that was provided on create.
  779. func (u *EmployeeUpsert) UpdateEstimate() *EmployeeUpsert {
  780. u.SetExcluded(employee.FieldEstimate)
  781. return u
  782. }
  783. // SetSkill sets the "skill" field.
  784. func (u *EmployeeUpsert) SetSkill(v string) *EmployeeUpsert {
  785. u.Set(employee.FieldSkill, v)
  786. return u
  787. }
  788. // UpdateSkill sets the "skill" field to the value that was provided on create.
  789. func (u *EmployeeUpsert) UpdateSkill() *EmployeeUpsert {
  790. u.SetExcluded(employee.FieldSkill)
  791. return u
  792. }
  793. // SetAbilityType sets the "ability_type" field.
  794. func (u *EmployeeUpsert) SetAbilityType(v string) *EmployeeUpsert {
  795. u.Set(employee.FieldAbilityType, v)
  796. return u
  797. }
  798. // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
  799. func (u *EmployeeUpsert) UpdateAbilityType() *EmployeeUpsert {
  800. u.SetExcluded(employee.FieldAbilityType)
  801. return u
  802. }
  803. // SetScene sets the "scene" field.
  804. func (u *EmployeeUpsert) SetScene(v string) *EmployeeUpsert {
  805. u.Set(employee.FieldScene, v)
  806. return u
  807. }
  808. // UpdateScene sets the "scene" field to the value that was provided on create.
  809. func (u *EmployeeUpsert) UpdateScene() *EmployeeUpsert {
  810. u.SetExcluded(employee.FieldScene)
  811. return u
  812. }
  813. // SetSwitchIn sets the "switch_in" field.
  814. func (u *EmployeeUpsert) SetSwitchIn(v string) *EmployeeUpsert {
  815. u.Set(employee.FieldSwitchIn, v)
  816. return u
  817. }
  818. // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
  819. func (u *EmployeeUpsert) UpdateSwitchIn() *EmployeeUpsert {
  820. u.SetExcluded(employee.FieldSwitchIn)
  821. return u
  822. }
  823. // SetVideoURL sets the "video_url" field.
  824. func (u *EmployeeUpsert) SetVideoURL(v string) *EmployeeUpsert {
  825. u.Set(employee.FieldVideoURL, v)
  826. return u
  827. }
  828. // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
  829. func (u *EmployeeUpsert) UpdateVideoURL() *EmployeeUpsert {
  830. u.SetExcluded(employee.FieldVideoURL)
  831. return u
  832. }
  833. // SetOrganizationID sets the "organization_id" field.
  834. func (u *EmployeeUpsert) SetOrganizationID(v uint64) *EmployeeUpsert {
  835. u.Set(employee.FieldOrganizationID, v)
  836. return u
  837. }
  838. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  839. func (u *EmployeeUpsert) UpdateOrganizationID() *EmployeeUpsert {
  840. u.SetExcluded(employee.FieldOrganizationID)
  841. return u
  842. }
  843. // AddOrganizationID adds v to the "organization_id" field.
  844. func (u *EmployeeUpsert) AddOrganizationID(v uint64) *EmployeeUpsert {
  845. u.Add(employee.FieldOrganizationID, v)
  846. return u
  847. }
  848. // SetCategoryID sets the "category_id" field.
  849. func (u *EmployeeUpsert) SetCategoryID(v uint64) *EmployeeUpsert {
  850. u.Set(employee.FieldCategoryID, v)
  851. return u
  852. }
  853. // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
  854. func (u *EmployeeUpsert) UpdateCategoryID() *EmployeeUpsert {
  855. u.SetExcluded(employee.FieldCategoryID)
  856. return u
  857. }
  858. // AddCategoryID adds v to the "category_id" field.
  859. func (u *EmployeeUpsert) AddCategoryID(v uint64) *EmployeeUpsert {
  860. u.Add(employee.FieldCategoryID, v)
  861. return u
  862. }
  863. // SetAPIBase sets the "api_base" field.
  864. func (u *EmployeeUpsert) SetAPIBase(v string) *EmployeeUpsert {
  865. u.Set(employee.FieldAPIBase, v)
  866. return u
  867. }
  868. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  869. func (u *EmployeeUpsert) UpdateAPIBase() *EmployeeUpsert {
  870. u.SetExcluded(employee.FieldAPIBase)
  871. return u
  872. }
  873. // SetAPIKey sets the "api_key" field.
  874. func (u *EmployeeUpsert) SetAPIKey(v string) *EmployeeUpsert {
  875. u.Set(employee.FieldAPIKey, v)
  876. return u
  877. }
  878. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  879. func (u *EmployeeUpsert) UpdateAPIKey() *EmployeeUpsert {
  880. u.SetExcluded(employee.FieldAPIKey)
  881. return u
  882. }
  883. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  884. // Using this option is equivalent to using:
  885. //
  886. // client.Employee.Create().
  887. // OnConflict(
  888. // sql.ResolveWithNewValues(),
  889. // sql.ResolveWith(func(u *sql.UpdateSet) {
  890. // u.SetIgnore(employee.FieldID)
  891. // }),
  892. // ).
  893. // Exec(ctx)
  894. func (u *EmployeeUpsertOne) UpdateNewValues() *EmployeeUpsertOne {
  895. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  896. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  897. if _, exists := u.create.mutation.ID(); exists {
  898. s.SetIgnore(employee.FieldID)
  899. }
  900. if _, exists := u.create.mutation.CreatedAt(); exists {
  901. s.SetIgnore(employee.FieldCreatedAt)
  902. }
  903. }))
  904. return u
  905. }
  906. // Ignore sets each column to itself in case of conflict.
  907. // Using this option is equivalent to using:
  908. //
  909. // client.Employee.Create().
  910. // OnConflict(sql.ResolveWithIgnore()).
  911. // Exec(ctx)
  912. func (u *EmployeeUpsertOne) Ignore() *EmployeeUpsertOne {
  913. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  914. return u
  915. }
  916. // DoNothing configures the conflict_action to `DO NOTHING`.
  917. // Supported only by SQLite and PostgreSQL.
  918. func (u *EmployeeUpsertOne) DoNothing() *EmployeeUpsertOne {
  919. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  920. return u
  921. }
  922. // Update allows overriding fields `UPDATE` values. See the EmployeeCreate.OnConflict
  923. // documentation for more info.
  924. func (u *EmployeeUpsertOne) Update(set func(*EmployeeUpsert)) *EmployeeUpsertOne {
  925. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  926. set(&EmployeeUpsert{UpdateSet: update})
  927. }))
  928. return u
  929. }
  930. // SetUpdatedAt sets the "updated_at" field.
  931. func (u *EmployeeUpsertOne) SetUpdatedAt(v time.Time) *EmployeeUpsertOne {
  932. return u.Update(func(s *EmployeeUpsert) {
  933. s.SetUpdatedAt(v)
  934. })
  935. }
  936. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  937. func (u *EmployeeUpsertOne) UpdateUpdatedAt() *EmployeeUpsertOne {
  938. return u.Update(func(s *EmployeeUpsert) {
  939. s.UpdateUpdatedAt()
  940. })
  941. }
  942. // SetDeletedAt sets the "deleted_at" field.
  943. func (u *EmployeeUpsertOne) SetDeletedAt(v time.Time) *EmployeeUpsertOne {
  944. return u.Update(func(s *EmployeeUpsert) {
  945. s.SetDeletedAt(v)
  946. })
  947. }
  948. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  949. func (u *EmployeeUpsertOne) UpdateDeletedAt() *EmployeeUpsertOne {
  950. return u.Update(func(s *EmployeeUpsert) {
  951. s.UpdateDeletedAt()
  952. })
  953. }
  954. // ClearDeletedAt clears the value of the "deleted_at" field.
  955. func (u *EmployeeUpsertOne) ClearDeletedAt() *EmployeeUpsertOne {
  956. return u.Update(func(s *EmployeeUpsert) {
  957. s.ClearDeletedAt()
  958. })
  959. }
  960. // SetTitle sets the "title" field.
  961. func (u *EmployeeUpsertOne) SetTitle(v string) *EmployeeUpsertOne {
  962. return u.Update(func(s *EmployeeUpsert) {
  963. s.SetTitle(v)
  964. })
  965. }
  966. // UpdateTitle sets the "title" field to the value that was provided on create.
  967. func (u *EmployeeUpsertOne) UpdateTitle() *EmployeeUpsertOne {
  968. return u.Update(func(s *EmployeeUpsert) {
  969. s.UpdateTitle()
  970. })
  971. }
  972. // SetAvatar sets the "avatar" field.
  973. func (u *EmployeeUpsertOne) SetAvatar(v string) *EmployeeUpsertOne {
  974. return u.Update(func(s *EmployeeUpsert) {
  975. s.SetAvatar(v)
  976. })
  977. }
  978. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  979. func (u *EmployeeUpsertOne) UpdateAvatar() *EmployeeUpsertOne {
  980. return u.Update(func(s *EmployeeUpsert) {
  981. s.UpdateAvatar()
  982. })
  983. }
  984. // SetTags sets the "tags" field.
  985. func (u *EmployeeUpsertOne) SetTags(v string) *EmployeeUpsertOne {
  986. return u.Update(func(s *EmployeeUpsert) {
  987. s.SetTags(v)
  988. })
  989. }
  990. // UpdateTags sets the "tags" field to the value that was provided on create.
  991. func (u *EmployeeUpsertOne) UpdateTags() *EmployeeUpsertOne {
  992. return u.Update(func(s *EmployeeUpsert) {
  993. s.UpdateTags()
  994. })
  995. }
  996. // SetHireCount sets the "hire_count" field.
  997. func (u *EmployeeUpsertOne) SetHireCount(v int) *EmployeeUpsertOne {
  998. return u.Update(func(s *EmployeeUpsert) {
  999. s.SetHireCount(v)
  1000. })
  1001. }
  1002. // AddHireCount adds v to the "hire_count" field.
  1003. func (u *EmployeeUpsertOne) AddHireCount(v int) *EmployeeUpsertOne {
  1004. return u.Update(func(s *EmployeeUpsert) {
  1005. s.AddHireCount(v)
  1006. })
  1007. }
  1008. // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
  1009. func (u *EmployeeUpsertOne) UpdateHireCount() *EmployeeUpsertOne {
  1010. return u.Update(func(s *EmployeeUpsert) {
  1011. s.UpdateHireCount()
  1012. })
  1013. }
  1014. // SetServiceCount sets the "service_count" field.
  1015. func (u *EmployeeUpsertOne) SetServiceCount(v int) *EmployeeUpsertOne {
  1016. return u.Update(func(s *EmployeeUpsert) {
  1017. s.SetServiceCount(v)
  1018. })
  1019. }
  1020. // AddServiceCount adds v to the "service_count" field.
  1021. func (u *EmployeeUpsertOne) AddServiceCount(v int) *EmployeeUpsertOne {
  1022. return u.Update(func(s *EmployeeUpsert) {
  1023. s.AddServiceCount(v)
  1024. })
  1025. }
  1026. // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
  1027. func (u *EmployeeUpsertOne) UpdateServiceCount() *EmployeeUpsertOne {
  1028. return u.Update(func(s *EmployeeUpsert) {
  1029. s.UpdateServiceCount()
  1030. })
  1031. }
  1032. // SetAchievementCount sets the "achievement_count" field.
  1033. func (u *EmployeeUpsertOne) SetAchievementCount(v int) *EmployeeUpsertOne {
  1034. return u.Update(func(s *EmployeeUpsert) {
  1035. s.SetAchievementCount(v)
  1036. })
  1037. }
  1038. // AddAchievementCount adds v to the "achievement_count" field.
  1039. func (u *EmployeeUpsertOne) AddAchievementCount(v int) *EmployeeUpsertOne {
  1040. return u.Update(func(s *EmployeeUpsert) {
  1041. s.AddAchievementCount(v)
  1042. })
  1043. }
  1044. // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
  1045. func (u *EmployeeUpsertOne) UpdateAchievementCount() *EmployeeUpsertOne {
  1046. return u.Update(func(s *EmployeeUpsert) {
  1047. s.UpdateAchievementCount()
  1048. })
  1049. }
  1050. // SetIntro sets the "intro" field.
  1051. func (u *EmployeeUpsertOne) SetIntro(v string) *EmployeeUpsertOne {
  1052. return u.Update(func(s *EmployeeUpsert) {
  1053. s.SetIntro(v)
  1054. })
  1055. }
  1056. // UpdateIntro sets the "intro" field to the value that was provided on create.
  1057. func (u *EmployeeUpsertOne) UpdateIntro() *EmployeeUpsertOne {
  1058. return u.Update(func(s *EmployeeUpsert) {
  1059. s.UpdateIntro()
  1060. })
  1061. }
  1062. // SetEstimate sets the "estimate" field.
  1063. func (u *EmployeeUpsertOne) SetEstimate(v string) *EmployeeUpsertOne {
  1064. return u.Update(func(s *EmployeeUpsert) {
  1065. s.SetEstimate(v)
  1066. })
  1067. }
  1068. // UpdateEstimate sets the "estimate" field to the value that was provided on create.
  1069. func (u *EmployeeUpsertOne) UpdateEstimate() *EmployeeUpsertOne {
  1070. return u.Update(func(s *EmployeeUpsert) {
  1071. s.UpdateEstimate()
  1072. })
  1073. }
  1074. // SetSkill sets the "skill" field.
  1075. func (u *EmployeeUpsertOne) SetSkill(v string) *EmployeeUpsertOne {
  1076. return u.Update(func(s *EmployeeUpsert) {
  1077. s.SetSkill(v)
  1078. })
  1079. }
  1080. // UpdateSkill sets the "skill" field to the value that was provided on create.
  1081. func (u *EmployeeUpsertOne) UpdateSkill() *EmployeeUpsertOne {
  1082. return u.Update(func(s *EmployeeUpsert) {
  1083. s.UpdateSkill()
  1084. })
  1085. }
  1086. // SetAbilityType sets the "ability_type" field.
  1087. func (u *EmployeeUpsertOne) SetAbilityType(v string) *EmployeeUpsertOne {
  1088. return u.Update(func(s *EmployeeUpsert) {
  1089. s.SetAbilityType(v)
  1090. })
  1091. }
  1092. // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
  1093. func (u *EmployeeUpsertOne) UpdateAbilityType() *EmployeeUpsertOne {
  1094. return u.Update(func(s *EmployeeUpsert) {
  1095. s.UpdateAbilityType()
  1096. })
  1097. }
  1098. // SetScene sets the "scene" field.
  1099. func (u *EmployeeUpsertOne) SetScene(v string) *EmployeeUpsertOne {
  1100. return u.Update(func(s *EmployeeUpsert) {
  1101. s.SetScene(v)
  1102. })
  1103. }
  1104. // UpdateScene sets the "scene" field to the value that was provided on create.
  1105. func (u *EmployeeUpsertOne) UpdateScene() *EmployeeUpsertOne {
  1106. return u.Update(func(s *EmployeeUpsert) {
  1107. s.UpdateScene()
  1108. })
  1109. }
  1110. // SetSwitchIn sets the "switch_in" field.
  1111. func (u *EmployeeUpsertOne) SetSwitchIn(v string) *EmployeeUpsertOne {
  1112. return u.Update(func(s *EmployeeUpsert) {
  1113. s.SetSwitchIn(v)
  1114. })
  1115. }
  1116. // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
  1117. func (u *EmployeeUpsertOne) UpdateSwitchIn() *EmployeeUpsertOne {
  1118. return u.Update(func(s *EmployeeUpsert) {
  1119. s.UpdateSwitchIn()
  1120. })
  1121. }
  1122. // SetVideoURL sets the "video_url" field.
  1123. func (u *EmployeeUpsertOne) SetVideoURL(v string) *EmployeeUpsertOne {
  1124. return u.Update(func(s *EmployeeUpsert) {
  1125. s.SetVideoURL(v)
  1126. })
  1127. }
  1128. // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
  1129. func (u *EmployeeUpsertOne) UpdateVideoURL() *EmployeeUpsertOne {
  1130. return u.Update(func(s *EmployeeUpsert) {
  1131. s.UpdateVideoURL()
  1132. })
  1133. }
  1134. // SetOrganizationID sets the "organization_id" field.
  1135. func (u *EmployeeUpsertOne) SetOrganizationID(v uint64) *EmployeeUpsertOne {
  1136. return u.Update(func(s *EmployeeUpsert) {
  1137. s.SetOrganizationID(v)
  1138. })
  1139. }
  1140. // AddOrganizationID adds v to the "organization_id" field.
  1141. func (u *EmployeeUpsertOne) AddOrganizationID(v uint64) *EmployeeUpsertOne {
  1142. return u.Update(func(s *EmployeeUpsert) {
  1143. s.AddOrganizationID(v)
  1144. })
  1145. }
  1146. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1147. func (u *EmployeeUpsertOne) UpdateOrganizationID() *EmployeeUpsertOne {
  1148. return u.Update(func(s *EmployeeUpsert) {
  1149. s.UpdateOrganizationID()
  1150. })
  1151. }
  1152. // SetCategoryID sets the "category_id" field.
  1153. func (u *EmployeeUpsertOne) SetCategoryID(v uint64) *EmployeeUpsertOne {
  1154. return u.Update(func(s *EmployeeUpsert) {
  1155. s.SetCategoryID(v)
  1156. })
  1157. }
  1158. // AddCategoryID adds v to the "category_id" field.
  1159. func (u *EmployeeUpsertOne) AddCategoryID(v uint64) *EmployeeUpsertOne {
  1160. return u.Update(func(s *EmployeeUpsert) {
  1161. s.AddCategoryID(v)
  1162. })
  1163. }
  1164. // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
  1165. func (u *EmployeeUpsertOne) UpdateCategoryID() *EmployeeUpsertOne {
  1166. return u.Update(func(s *EmployeeUpsert) {
  1167. s.UpdateCategoryID()
  1168. })
  1169. }
  1170. // SetAPIBase sets the "api_base" field.
  1171. func (u *EmployeeUpsertOne) SetAPIBase(v string) *EmployeeUpsertOne {
  1172. return u.Update(func(s *EmployeeUpsert) {
  1173. s.SetAPIBase(v)
  1174. })
  1175. }
  1176. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1177. func (u *EmployeeUpsertOne) UpdateAPIBase() *EmployeeUpsertOne {
  1178. return u.Update(func(s *EmployeeUpsert) {
  1179. s.UpdateAPIBase()
  1180. })
  1181. }
  1182. // SetAPIKey sets the "api_key" field.
  1183. func (u *EmployeeUpsertOne) SetAPIKey(v string) *EmployeeUpsertOne {
  1184. return u.Update(func(s *EmployeeUpsert) {
  1185. s.SetAPIKey(v)
  1186. })
  1187. }
  1188. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1189. func (u *EmployeeUpsertOne) UpdateAPIKey() *EmployeeUpsertOne {
  1190. return u.Update(func(s *EmployeeUpsert) {
  1191. s.UpdateAPIKey()
  1192. })
  1193. }
  1194. // Exec executes the query.
  1195. func (u *EmployeeUpsertOne) Exec(ctx context.Context) error {
  1196. if len(u.create.conflict) == 0 {
  1197. return errors.New("ent: missing options for EmployeeCreate.OnConflict")
  1198. }
  1199. return u.create.Exec(ctx)
  1200. }
  1201. // ExecX is like Exec, but panics if an error occurs.
  1202. func (u *EmployeeUpsertOne) ExecX(ctx context.Context) {
  1203. if err := u.create.Exec(ctx); err != nil {
  1204. panic(err)
  1205. }
  1206. }
  1207. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1208. func (u *EmployeeUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1209. node, err := u.create.Save(ctx)
  1210. if err != nil {
  1211. return id, err
  1212. }
  1213. return node.ID, nil
  1214. }
  1215. // IDX is like ID, but panics if an error occurs.
  1216. func (u *EmployeeUpsertOne) IDX(ctx context.Context) uint64 {
  1217. id, err := u.ID(ctx)
  1218. if err != nil {
  1219. panic(err)
  1220. }
  1221. return id
  1222. }
  1223. // EmployeeCreateBulk is the builder for creating many Employee entities in bulk.
  1224. type EmployeeCreateBulk struct {
  1225. config
  1226. err error
  1227. builders []*EmployeeCreate
  1228. conflict []sql.ConflictOption
  1229. }
  1230. // Save creates the Employee entities in the database.
  1231. func (ecb *EmployeeCreateBulk) Save(ctx context.Context) ([]*Employee, error) {
  1232. if ecb.err != nil {
  1233. return nil, ecb.err
  1234. }
  1235. specs := make([]*sqlgraph.CreateSpec, len(ecb.builders))
  1236. nodes := make([]*Employee, len(ecb.builders))
  1237. mutators := make([]Mutator, len(ecb.builders))
  1238. for i := range ecb.builders {
  1239. func(i int, root context.Context) {
  1240. builder := ecb.builders[i]
  1241. builder.defaults()
  1242. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1243. mutation, ok := m.(*EmployeeMutation)
  1244. if !ok {
  1245. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1246. }
  1247. if err := builder.check(); err != nil {
  1248. return nil, err
  1249. }
  1250. builder.mutation = mutation
  1251. var err error
  1252. nodes[i], specs[i] = builder.createSpec()
  1253. if i < len(mutators)-1 {
  1254. _, err = mutators[i+1].Mutate(root, ecb.builders[i+1].mutation)
  1255. } else {
  1256. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1257. spec.OnConflict = ecb.conflict
  1258. // Invoke the actual operation on the latest mutation in the chain.
  1259. if err = sqlgraph.BatchCreate(ctx, ecb.driver, spec); err != nil {
  1260. if sqlgraph.IsConstraintError(err) {
  1261. err = &ConstraintError{msg: err.Error(), wrap: err}
  1262. }
  1263. }
  1264. }
  1265. if err != nil {
  1266. return nil, err
  1267. }
  1268. mutation.id = &nodes[i].ID
  1269. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1270. id := specs[i].ID.Value.(int64)
  1271. nodes[i].ID = uint64(id)
  1272. }
  1273. mutation.done = true
  1274. return nodes[i], nil
  1275. })
  1276. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1277. mut = builder.hooks[i](mut)
  1278. }
  1279. mutators[i] = mut
  1280. }(i, ctx)
  1281. }
  1282. if len(mutators) > 0 {
  1283. if _, err := mutators[0].Mutate(ctx, ecb.builders[0].mutation); err != nil {
  1284. return nil, err
  1285. }
  1286. }
  1287. return nodes, nil
  1288. }
  1289. // SaveX is like Save, but panics if an error occurs.
  1290. func (ecb *EmployeeCreateBulk) SaveX(ctx context.Context) []*Employee {
  1291. v, err := ecb.Save(ctx)
  1292. if err != nil {
  1293. panic(err)
  1294. }
  1295. return v
  1296. }
  1297. // Exec executes the query.
  1298. func (ecb *EmployeeCreateBulk) Exec(ctx context.Context) error {
  1299. _, err := ecb.Save(ctx)
  1300. return err
  1301. }
  1302. // ExecX is like Exec, but panics if an error occurs.
  1303. func (ecb *EmployeeCreateBulk) ExecX(ctx context.Context) {
  1304. if err := ecb.Exec(ctx); err != nil {
  1305. panic(err)
  1306. }
  1307. }
  1308. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1309. // of the `INSERT` statement. For example:
  1310. //
  1311. // client.Employee.CreateBulk(builders...).
  1312. // OnConflict(
  1313. // // Update the row with the new values
  1314. // // the was proposed for insertion.
  1315. // sql.ResolveWithNewValues(),
  1316. // ).
  1317. // // Override some of the fields with custom
  1318. // // update values.
  1319. // Update(func(u *ent.EmployeeUpsert) {
  1320. // SetCreatedAt(v+v).
  1321. // }).
  1322. // Exec(ctx)
  1323. func (ecb *EmployeeCreateBulk) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertBulk {
  1324. ecb.conflict = opts
  1325. return &EmployeeUpsertBulk{
  1326. create: ecb,
  1327. }
  1328. }
  1329. // OnConflictColumns calls `OnConflict` and configures the columns
  1330. // as conflict target. Using this option is equivalent to using:
  1331. //
  1332. // client.Employee.Create().
  1333. // OnConflict(sql.ConflictColumns(columns...)).
  1334. // Exec(ctx)
  1335. func (ecb *EmployeeCreateBulk) OnConflictColumns(columns ...string) *EmployeeUpsertBulk {
  1336. ecb.conflict = append(ecb.conflict, sql.ConflictColumns(columns...))
  1337. return &EmployeeUpsertBulk{
  1338. create: ecb,
  1339. }
  1340. }
  1341. // EmployeeUpsertBulk is the builder for "upsert"-ing
  1342. // a bulk of Employee nodes.
  1343. type EmployeeUpsertBulk struct {
  1344. create *EmployeeCreateBulk
  1345. }
  1346. // UpdateNewValues updates the mutable fields using the new values that
  1347. // were set on create. Using this option is equivalent to using:
  1348. //
  1349. // client.Employee.Create().
  1350. // OnConflict(
  1351. // sql.ResolveWithNewValues(),
  1352. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1353. // u.SetIgnore(employee.FieldID)
  1354. // }),
  1355. // ).
  1356. // Exec(ctx)
  1357. func (u *EmployeeUpsertBulk) UpdateNewValues() *EmployeeUpsertBulk {
  1358. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1359. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1360. for _, b := range u.create.builders {
  1361. if _, exists := b.mutation.ID(); exists {
  1362. s.SetIgnore(employee.FieldID)
  1363. }
  1364. if _, exists := b.mutation.CreatedAt(); exists {
  1365. s.SetIgnore(employee.FieldCreatedAt)
  1366. }
  1367. }
  1368. }))
  1369. return u
  1370. }
  1371. // Ignore sets each column to itself in case of conflict.
  1372. // Using this option is equivalent to using:
  1373. //
  1374. // client.Employee.Create().
  1375. // OnConflict(sql.ResolveWithIgnore()).
  1376. // Exec(ctx)
  1377. func (u *EmployeeUpsertBulk) Ignore() *EmployeeUpsertBulk {
  1378. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1379. return u
  1380. }
  1381. // DoNothing configures the conflict_action to `DO NOTHING`.
  1382. // Supported only by SQLite and PostgreSQL.
  1383. func (u *EmployeeUpsertBulk) DoNothing() *EmployeeUpsertBulk {
  1384. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1385. return u
  1386. }
  1387. // Update allows overriding fields `UPDATE` values. See the EmployeeCreateBulk.OnConflict
  1388. // documentation for more info.
  1389. func (u *EmployeeUpsertBulk) Update(set func(*EmployeeUpsert)) *EmployeeUpsertBulk {
  1390. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1391. set(&EmployeeUpsert{UpdateSet: update})
  1392. }))
  1393. return u
  1394. }
  1395. // SetUpdatedAt sets the "updated_at" field.
  1396. func (u *EmployeeUpsertBulk) SetUpdatedAt(v time.Time) *EmployeeUpsertBulk {
  1397. return u.Update(func(s *EmployeeUpsert) {
  1398. s.SetUpdatedAt(v)
  1399. })
  1400. }
  1401. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1402. func (u *EmployeeUpsertBulk) UpdateUpdatedAt() *EmployeeUpsertBulk {
  1403. return u.Update(func(s *EmployeeUpsert) {
  1404. s.UpdateUpdatedAt()
  1405. })
  1406. }
  1407. // SetDeletedAt sets the "deleted_at" field.
  1408. func (u *EmployeeUpsertBulk) SetDeletedAt(v time.Time) *EmployeeUpsertBulk {
  1409. return u.Update(func(s *EmployeeUpsert) {
  1410. s.SetDeletedAt(v)
  1411. })
  1412. }
  1413. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1414. func (u *EmployeeUpsertBulk) UpdateDeletedAt() *EmployeeUpsertBulk {
  1415. return u.Update(func(s *EmployeeUpsert) {
  1416. s.UpdateDeletedAt()
  1417. })
  1418. }
  1419. // ClearDeletedAt clears the value of the "deleted_at" field.
  1420. func (u *EmployeeUpsertBulk) ClearDeletedAt() *EmployeeUpsertBulk {
  1421. return u.Update(func(s *EmployeeUpsert) {
  1422. s.ClearDeletedAt()
  1423. })
  1424. }
  1425. // SetTitle sets the "title" field.
  1426. func (u *EmployeeUpsertBulk) SetTitle(v string) *EmployeeUpsertBulk {
  1427. return u.Update(func(s *EmployeeUpsert) {
  1428. s.SetTitle(v)
  1429. })
  1430. }
  1431. // UpdateTitle sets the "title" field to the value that was provided on create.
  1432. func (u *EmployeeUpsertBulk) UpdateTitle() *EmployeeUpsertBulk {
  1433. return u.Update(func(s *EmployeeUpsert) {
  1434. s.UpdateTitle()
  1435. })
  1436. }
  1437. // SetAvatar sets the "avatar" field.
  1438. func (u *EmployeeUpsertBulk) SetAvatar(v string) *EmployeeUpsertBulk {
  1439. return u.Update(func(s *EmployeeUpsert) {
  1440. s.SetAvatar(v)
  1441. })
  1442. }
  1443. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  1444. func (u *EmployeeUpsertBulk) UpdateAvatar() *EmployeeUpsertBulk {
  1445. return u.Update(func(s *EmployeeUpsert) {
  1446. s.UpdateAvatar()
  1447. })
  1448. }
  1449. // SetTags sets the "tags" field.
  1450. func (u *EmployeeUpsertBulk) SetTags(v string) *EmployeeUpsertBulk {
  1451. return u.Update(func(s *EmployeeUpsert) {
  1452. s.SetTags(v)
  1453. })
  1454. }
  1455. // UpdateTags sets the "tags" field to the value that was provided on create.
  1456. func (u *EmployeeUpsertBulk) UpdateTags() *EmployeeUpsertBulk {
  1457. return u.Update(func(s *EmployeeUpsert) {
  1458. s.UpdateTags()
  1459. })
  1460. }
  1461. // SetHireCount sets the "hire_count" field.
  1462. func (u *EmployeeUpsertBulk) SetHireCount(v int) *EmployeeUpsertBulk {
  1463. return u.Update(func(s *EmployeeUpsert) {
  1464. s.SetHireCount(v)
  1465. })
  1466. }
  1467. // AddHireCount adds v to the "hire_count" field.
  1468. func (u *EmployeeUpsertBulk) AddHireCount(v int) *EmployeeUpsertBulk {
  1469. return u.Update(func(s *EmployeeUpsert) {
  1470. s.AddHireCount(v)
  1471. })
  1472. }
  1473. // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
  1474. func (u *EmployeeUpsertBulk) UpdateHireCount() *EmployeeUpsertBulk {
  1475. return u.Update(func(s *EmployeeUpsert) {
  1476. s.UpdateHireCount()
  1477. })
  1478. }
  1479. // SetServiceCount sets the "service_count" field.
  1480. func (u *EmployeeUpsertBulk) SetServiceCount(v int) *EmployeeUpsertBulk {
  1481. return u.Update(func(s *EmployeeUpsert) {
  1482. s.SetServiceCount(v)
  1483. })
  1484. }
  1485. // AddServiceCount adds v to the "service_count" field.
  1486. func (u *EmployeeUpsertBulk) AddServiceCount(v int) *EmployeeUpsertBulk {
  1487. return u.Update(func(s *EmployeeUpsert) {
  1488. s.AddServiceCount(v)
  1489. })
  1490. }
  1491. // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
  1492. func (u *EmployeeUpsertBulk) UpdateServiceCount() *EmployeeUpsertBulk {
  1493. return u.Update(func(s *EmployeeUpsert) {
  1494. s.UpdateServiceCount()
  1495. })
  1496. }
  1497. // SetAchievementCount sets the "achievement_count" field.
  1498. func (u *EmployeeUpsertBulk) SetAchievementCount(v int) *EmployeeUpsertBulk {
  1499. return u.Update(func(s *EmployeeUpsert) {
  1500. s.SetAchievementCount(v)
  1501. })
  1502. }
  1503. // AddAchievementCount adds v to the "achievement_count" field.
  1504. func (u *EmployeeUpsertBulk) AddAchievementCount(v int) *EmployeeUpsertBulk {
  1505. return u.Update(func(s *EmployeeUpsert) {
  1506. s.AddAchievementCount(v)
  1507. })
  1508. }
  1509. // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
  1510. func (u *EmployeeUpsertBulk) UpdateAchievementCount() *EmployeeUpsertBulk {
  1511. return u.Update(func(s *EmployeeUpsert) {
  1512. s.UpdateAchievementCount()
  1513. })
  1514. }
  1515. // SetIntro sets the "intro" field.
  1516. func (u *EmployeeUpsertBulk) SetIntro(v string) *EmployeeUpsertBulk {
  1517. return u.Update(func(s *EmployeeUpsert) {
  1518. s.SetIntro(v)
  1519. })
  1520. }
  1521. // UpdateIntro sets the "intro" field to the value that was provided on create.
  1522. func (u *EmployeeUpsertBulk) UpdateIntro() *EmployeeUpsertBulk {
  1523. return u.Update(func(s *EmployeeUpsert) {
  1524. s.UpdateIntro()
  1525. })
  1526. }
  1527. // SetEstimate sets the "estimate" field.
  1528. func (u *EmployeeUpsertBulk) SetEstimate(v string) *EmployeeUpsertBulk {
  1529. return u.Update(func(s *EmployeeUpsert) {
  1530. s.SetEstimate(v)
  1531. })
  1532. }
  1533. // UpdateEstimate sets the "estimate" field to the value that was provided on create.
  1534. func (u *EmployeeUpsertBulk) UpdateEstimate() *EmployeeUpsertBulk {
  1535. return u.Update(func(s *EmployeeUpsert) {
  1536. s.UpdateEstimate()
  1537. })
  1538. }
  1539. // SetSkill sets the "skill" field.
  1540. func (u *EmployeeUpsertBulk) SetSkill(v string) *EmployeeUpsertBulk {
  1541. return u.Update(func(s *EmployeeUpsert) {
  1542. s.SetSkill(v)
  1543. })
  1544. }
  1545. // UpdateSkill sets the "skill" field to the value that was provided on create.
  1546. func (u *EmployeeUpsertBulk) UpdateSkill() *EmployeeUpsertBulk {
  1547. return u.Update(func(s *EmployeeUpsert) {
  1548. s.UpdateSkill()
  1549. })
  1550. }
  1551. // SetAbilityType sets the "ability_type" field.
  1552. func (u *EmployeeUpsertBulk) SetAbilityType(v string) *EmployeeUpsertBulk {
  1553. return u.Update(func(s *EmployeeUpsert) {
  1554. s.SetAbilityType(v)
  1555. })
  1556. }
  1557. // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
  1558. func (u *EmployeeUpsertBulk) UpdateAbilityType() *EmployeeUpsertBulk {
  1559. return u.Update(func(s *EmployeeUpsert) {
  1560. s.UpdateAbilityType()
  1561. })
  1562. }
  1563. // SetScene sets the "scene" field.
  1564. func (u *EmployeeUpsertBulk) SetScene(v string) *EmployeeUpsertBulk {
  1565. return u.Update(func(s *EmployeeUpsert) {
  1566. s.SetScene(v)
  1567. })
  1568. }
  1569. // UpdateScene sets the "scene" field to the value that was provided on create.
  1570. func (u *EmployeeUpsertBulk) UpdateScene() *EmployeeUpsertBulk {
  1571. return u.Update(func(s *EmployeeUpsert) {
  1572. s.UpdateScene()
  1573. })
  1574. }
  1575. // SetSwitchIn sets the "switch_in" field.
  1576. func (u *EmployeeUpsertBulk) SetSwitchIn(v string) *EmployeeUpsertBulk {
  1577. return u.Update(func(s *EmployeeUpsert) {
  1578. s.SetSwitchIn(v)
  1579. })
  1580. }
  1581. // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
  1582. func (u *EmployeeUpsertBulk) UpdateSwitchIn() *EmployeeUpsertBulk {
  1583. return u.Update(func(s *EmployeeUpsert) {
  1584. s.UpdateSwitchIn()
  1585. })
  1586. }
  1587. // SetVideoURL sets the "video_url" field.
  1588. func (u *EmployeeUpsertBulk) SetVideoURL(v string) *EmployeeUpsertBulk {
  1589. return u.Update(func(s *EmployeeUpsert) {
  1590. s.SetVideoURL(v)
  1591. })
  1592. }
  1593. // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
  1594. func (u *EmployeeUpsertBulk) UpdateVideoURL() *EmployeeUpsertBulk {
  1595. return u.Update(func(s *EmployeeUpsert) {
  1596. s.UpdateVideoURL()
  1597. })
  1598. }
  1599. // SetOrganizationID sets the "organization_id" field.
  1600. func (u *EmployeeUpsertBulk) SetOrganizationID(v uint64) *EmployeeUpsertBulk {
  1601. return u.Update(func(s *EmployeeUpsert) {
  1602. s.SetOrganizationID(v)
  1603. })
  1604. }
  1605. // AddOrganizationID adds v to the "organization_id" field.
  1606. func (u *EmployeeUpsertBulk) AddOrganizationID(v uint64) *EmployeeUpsertBulk {
  1607. return u.Update(func(s *EmployeeUpsert) {
  1608. s.AddOrganizationID(v)
  1609. })
  1610. }
  1611. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1612. func (u *EmployeeUpsertBulk) UpdateOrganizationID() *EmployeeUpsertBulk {
  1613. return u.Update(func(s *EmployeeUpsert) {
  1614. s.UpdateOrganizationID()
  1615. })
  1616. }
  1617. // SetCategoryID sets the "category_id" field.
  1618. func (u *EmployeeUpsertBulk) SetCategoryID(v uint64) *EmployeeUpsertBulk {
  1619. return u.Update(func(s *EmployeeUpsert) {
  1620. s.SetCategoryID(v)
  1621. })
  1622. }
  1623. // AddCategoryID adds v to the "category_id" field.
  1624. func (u *EmployeeUpsertBulk) AddCategoryID(v uint64) *EmployeeUpsertBulk {
  1625. return u.Update(func(s *EmployeeUpsert) {
  1626. s.AddCategoryID(v)
  1627. })
  1628. }
  1629. // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
  1630. func (u *EmployeeUpsertBulk) UpdateCategoryID() *EmployeeUpsertBulk {
  1631. return u.Update(func(s *EmployeeUpsert) {
  1632. s.UpdateCategoryID()
  1633. })
  1634. }
  1635. // SetAPIBase sets the "api_base" field.
  1636. func (u *EmployeeUpsertBulk) SetAPIBase(v string) *EmployeeUpsertBulk {
  1637. return u.Update(func(s *EmployeeUpsert) {
  1638. s.SetAPIBase(v)
  1639. })
  1640. }
  1641. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1642. func (u *EmployeeUpsertBulk) UpdateAPIBase() *EmployeeUpsertBulk {
  1643. return u.Update(func(s *EmployeeUpsert) {
  1644. s.UpdateAPIBase()
  1645. })
  1646. }
  1647. // SetAPIKey sets the "api_key" field.
  1648. func (u *EmployeeUpsertBulk) SetAPIKey(v string) *EmployeeUpsertBulk {
  1649. return u.Update(func(s *EmployeeUpsert) {
  1650. s.SetAPIKey(v)
  1651. })
  1652. }
  1653. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1654. func (u *EmployeeUpsertBulk) UpdateAPIKey() *EmployeeUpsertBulk {
  1655. return u.Update(func(s *EmployeeUpsert) {
  1656. s.UpdateAPIKey()
  1657. })
  1658. }
  1659. // Exec executes the query.
  1660. func (u *EmployeeUpsertBulk) Exec(ctx context.Context) error {
  1661. if u.create.err != nil {
  1662. return u.create.err
  1663. }
  1664. for i, b := range u.create.builders {
  1665. if len(b.conflict) != 0 {
  1666. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the EmployeeCreateBulk instead", i)
  1667. }
  1668. }
  1669. if len(u.create.conflict) == 0 {
  1670. return errors.New("ent: missing options for EmployeeCreateBulk.OnConflict")
  1671. }
  1672. return u.create.Exec(ctx)
  1673. }
  1674. // ExecX is like Exec, but panics if an error occurs.
  1675. func (u *EmployeeUpsertBulk) ExecX(ctx context.Context) {
  1676. if err := u.create.Exec(ctx); err != nil {
  1677. panic(err)
  1678. }
  1679. }