employee_create.go 52 KB

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