workexperience_update.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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/predicate"
  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. // WorkExperienceUpdate is the builder for updating WorkExperience entities.
  16. type WorkExperienceUpdate struct {
  17. config
  18. hooks []Hook
  19. mutation *WorkExperienceMutation
  20. }
  21. // Where appends a list predicates to the WorkExperienceUpdate builder.
  22. func (weu *WorkExperienceUpdate) Where(ps ...predicate.WorkExperience) *WorkExperienceUpdate {
  23. weu.mutation.Where(ps...)
  24. return weu
  25. }
  26. // SetUpdatedAt sets the "updated_at" field.
  27. func (weu *WorkExperienceUpdate) SetUpdatedAt(t time.Time) *WorkExperienceUpdate {
  28. weu.mutation.SetUpdatedAt(t)
  29. return weu
  30. }
  31. // SetDeletedAt sets the "deleted_at" field.
  32. func (weu *WorkExperienceUpdate) SetDeletedAt(t time.Time) *WorkExperienceUpdate {
  33. weu.mutation.SetDeletedAt(t)
  34. return weu
  35. }
  36. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  37. func (weu *WorkExperienceUpdate) SetNillableDeletedAt(t *time.Time) *WorkExperienceUpdate {
  38. if t != nil {
  39. weu.SetDeletedAt(*t)
  40. }
  41. return weu
  42. }
  43. // ClearDeletedAt clears the value of the "deleted_at" field.
  44. func (weu *WorkExperienceUpdate) ClearDeletedAt() *WorkExperienceUpdate {
  45. weu.mutation.ClearDeletedAt()
  46. return weu
  47. }
  48. // SetEmployeeID sets the "employee_id" field.
  49. func (weu *WorkExperienceUpdate) SetEmployeeID(u uint64) *WorkExperienceUpdate {
  50. weu.mutation.SetEmployeeID(u)
  51. return weu
  52. }
  53. // SetNillableEmployeeID sets the "employee_id" field if the given value is not nil.
  54. func (weu *WorkExperienceUpdate) SetNillableEmployeeID(u *uint64) *WorkExperienceUpdate {
  55. if u != nil {
  56. weu.SetEmployeeID(*u)
  57. }
  58. return weu
  59. }
  60. // SetStartDate sets the "start_date" field.
  61. func (weu *WorkExperienceUpdate) SetStartDate(t time.Time) *WorkExperienceUpdate {
  62. weu.mutation.SetStartDate(t)
  63. return weu
  64. }
  65. // SetNillableStartDate sets the "start_date" field if the given value is not nil.
  66. func (weu *WorkExperienceUpdate) SetNillableStartDate(t *time.Time) *WorkExperienceUpdate {
  67. if t != nil {
  68. weu.SetStartDate(*t)
  69. }
  70. return weu
  71. }
  72. // SetEndDate sets the "end_date" field.
  73. func (weu *WorkExperienceUpdate) SetEndDate(t time.Time) *WorkExperienceUpdate {
  74. weu.mutation.SetEndDate(t)
  75. return weu
  76. }
  77. // SetNillableEndDate sets the "end_date" field if the given value is not nil.
  78. func (weu *WorkExperienceUpdate) SetNillableEndDate(t *time.Time) *WorkExperienceUpdate {
  79. if t != nil {
  80. weu.SetEndDate(*t)
  81. }
  82. return weu
  83. }
  84. // SetCompany sets the "company" field.
  85. func (weu *WorkExperienceUpdate) SetCompany(s string) *WorkExperienceUpdate {
  86. weu.mutation.SetCompany(s)
  87. return weu
  88. }
  89. // SetNillableCompany sets the "company" field if the given value is not nil.
  90. func (weu *WorkExperienceUpdate) SetNillableCompany(s *string) *WorkExperienceUpdate {
  91. if s != nil {
  92. weu.SetCompany(*s)
  93. }
  94. return weu
  95. }
  96. // SetExperience sets the "experience" field.
  97. func (weu *WorkExperienceUpdate) SetExperience(s string) *WorkExperienceUpdate {
  98. weu.mutation.SetExperience(s)
  99. return weu
  100. }
  101. // SetNillableExperience sets the "experience" field if the given value is not nil.
  102. func (weu *WorkExperienceUpdate) SetNillableExperience(s *string) *WorkExperienceUpdate {
  103. if s != nil {
  104. weu.SetExperience(*s)
  105. }
  106. return weu
  107. }
  108. // SetOrganizationID sets the "organization_id" field.
  109. func (weu *WorkExperienceUpdate) SetOrganizationID(u uint64) *WorkExperienceUpdate {
  110. weu.mutation.ResetOrganizationID()
  111. weu.mutation.SetOrganizationID(u)
  112. return weu
  113. }
  114. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  115. func (weu *WorkExperienceUpdate) SetNillableOrganizationID(u *uint64) *WorkExperienceUpdate {
  116. if u != nil {
  117. weu.SetOrganizationID(*u)
  118. }
  119. return weu
  120. }
  121. // AddOrganizationID adds u to the "organization_id" field.
  122. func (weu *WorkExperienceUpdate) AddOrganizationID(u int64) *WorkExperienceUpdate {
  123. weu.mutation.AddOrganizationID(u)
  124. return weu
  125. }
  126. // SetEmployee sets the "employee" edge to the Employee entity.
  127. func (weu *WorkExperienceUpdate) SetEmployee(e *Employee) *WorkExperienceUpdate {
  128. return weu.SetEmployeeID(e.ID)
  129. }
  130. // Mutation returns the WorkExperienceMutation object of the builder.
  131. func (weu *WorkExperienceUpdate) Mutation() *WorkExperienceMutation {
  132. return weu.mutation
  133. }
  134. // ClearEmployee clears the "employee" edge to the Employee entity.
  135. func (weu *WorkExperienceUpdate) ClearEmployee() *WorkExperienceUpdate {
  136. weu.mutation.ClearEmployee()
  137. return weu
  138. }
  139. // Save executes the query and returns the number of nodes affected by the update operation.
  140. func (weu *WorkExperienceUpdate) Save(ctx context.Context) (int, error) {
  141. if err := weu.defaults(); err != nil {
  142. return 0, err
  143. }
  144. return withHooks(ctx, weu.sqlSave, weu.mutation, weu.hooks)
  145. }
  146. // SaveX is like Save, but panics if an error occurs.
  147. func (weu *WorkExperienceUpdate) SaveX(ctx context.Context) int {
  148. affected, err := weu.Save(ctx)
  149. if err != nil {
  150. panic(err)
  151. }
  152. return affected
  153. }
  154. // Exec executes the query.
  155. func (weu *WorkExperienceUpdate) Exec(ctx context.Context) error {
  156. _, err := weu.Save(ctx)
  157. return err
  158. }
  159. // ExecX is like Exec, but panics if an error occurs.
  160. func (weu *WorkExperienceUpdate) ExecX(ctx context.Context) {
  161. if err := weu.Exec(ctx); err != nil {
  162. panic(err)
  163. }
  164. }
  165. // defaults sets the default values of the builder before save.
  166. func (weu *WorkExperienceUpdate) defaults() error {
  167. if _, ok := weu.mutation.UpdatedAt(); !ok {
  168. if workexperience.UpdateDefaultUpdatedAt == nil {
  169. return fmt.Errorf("ent: uninitialized workexperience.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  170. }
  171. v := workexperience.UpdateDefaultUpdatedAt()
  172. weu.mutation.SetUpdatedAt(v)
  173. }
  174. return nil
  175. }
  176. // check runs all checks and user-defined validators on the builder.
  177. func (weu *WorkExperienceUpdate) check() error {
  178. if _, ok := weu.mutation.EmployeeID(); weu.mutation.EmployeeCleared() && !ok {
  179. return errors.New(`ent: clearing a required unique edge "WorkExperience.employee"`)
  180. }
  181. return nil
  182. }
  183. func (weu *WorkExperienceUpdate) sqlSave(ctx context.Context) (n int, err error) {
  184. if err := weu.check(); err != nil {
  185. return n, err
  186. }
  187. _spec := sqlgraph.NewUpdateSpec(workexperience.Table, workexperience.Columns, sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64))
  188. if ps := weu.mutation.predicates; len(ps) > 0 {
  189. _spec.Predicate = func(selector *sql.Selector) {
  190. for i := range ps {
  191. ps[i](selector)
  192. }
  193. }
  194. }
  195. if value, ok := weu.mutation.UpdatedAt(); ok {
  196. _spec.SetField(workexperience.FieldUpdatedAt, field.TypeTime, value)
  197. }
  198. if value, ok := weu.mutation.DeletedAt(); ok {
  199. _spec.SetField(workexperience.FieldDeletedAt, field.TypeTime, value)
  200. }
  201. if weu.mutation.DeletedAtCleared() {
  202. _spec.ClearField(workexperience.FieldDeletedAt, field.TypeTime)
  203. }
  204. if value, ok := weu.mutation.StartDate(); ok {
  205. _spec.SetField(workexperience.FieldStartDate, field.TypeTime, value)
  206. }
  207. if value, ok := weu.mutation.EndDate(); ok {
  208. _spec.SetField(workexperience.FieldEndDate, field.TypeTime, value)
  209. }
  210. if value, ok := weu.mutation.Company(); ok {
  211. _spec.SetField(workexperience.FieldCompany, field.TypeString, value)
  212. }
  213. if value, ok := weu.mutation.Experience(); ok {
  214. _spec.SetField(workexperience.FieldExperience, field.TypeString, value)
  215. }
  216. if value, ok := weu.mutation.OrganizationID(); ok {
  217. _spec.SetField(workexperience.FieldOrganizationID, field.TypeUint64, value)
  218. }
  219. if value, ok := weu.mutation.AddedOrganizationID(); ok {
  220. _spec.AddField(workexperience.FieldOrganizationID, field.TypeUint64, value)
  221. }
  222. if weu.mutation.EmployeeCleared() {
  223. edge := &sqlgraph.EdgeSpec{
  224. Rel: sqlgraph.M2O,
  225. Inverse: true,
  226. Table: workexperience.EmployeeTable,
  227. Columns: []string{workexperience.EmployeeColumn},
  228. Bidi: false,
  229. Target: &sqlgraph.EdgeTarget{
  230. IDSpec: sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64),
  231. },
  232. }
  233. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  234. }
  235. if nodes := weu.mutation.EmployeeIDs(); len(nodes) > 0 {
  236. edge := &sqlgraph.EdgeSpec{
  237. Rel: sqlgraph.M2O,
  238. Inverse: true,
  239. Table: workexperience.EmployeeTable,
  240. Columns: []string{workexperience.EmployeeColumn},
  241. Bidi: false,
  242. Target: &sqlgraph.EdgeTarget{
  243. IDSpec: sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64),
  244. },
  245. }
  246. for _, k := range nodes {
  247. edge.Target.Nodes = append(edge.Target.Nodes, k)
  248. }
  249. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  250. }
  251. if n, err = sqlgraph.UpdateNodes(ctx, weu.driver, _spec); err != nil {
  252. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  253. err = &NotFoundError{workexperience.Label}
  254. } else if sqlgraph.IsConstraintError(err) {
  255. err = &ConstraintError{msg: err.Error(), wrap: err}
  256. }
  257. return 0, err
  258. }
  259. weu.mutation.done = true
  260. return n, nil
  261. }
  262. // WorkExperienceUpdateOne is the builder for updating a single WorkExperience entity.
  263. type WorkExperienceUpdateOne struct {
  264. config
  265. fields []string
  266. hooks []Hook
  267. mutation *WorkExperienceMutation
  268. }
  269. // SetUpdatedAt sets the "updated_at" field.
  270. func (weuo *WorkExperienceUpdateOne) SetUpdatedAt(t time.Time) *WorkExperienceUpdateOne {
  271. weuo.mutation.SetUpdatedAt(t)
  272. return weuo
  273. }
  274. // SetDeletedAt sets the "deleted_at" field.
  275. func (weuo *WorkExperienceUpdateOne) SetDeletedAt(t time.Time) *WorkExperienceUpdateOne {
  276. weuo.mutation.SetDeletedAt(t)
  277. return weuo
  278. }
  279. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  280. func (weuo *WorkExperienceUpdateOne) SetNillableDeletedAt(t *time.Time) *WorkExperienceUpdateOne {
  281. if t != nil {
  282. weuo.SetDeletedAt(*t)
  283. }
  284. return weuo
  285. }
  286. // ClearDeletedAt clears the value of the "deleted_at" field.
  287. func (weuo *WorkExperienceUpdateOne) ClearDeletedAt() *WorkExperienceUpdateOne {
  288. weuo.mutation.ClearDeletedAt()
  289. return weuo
  290. }
  291. // SetEmployeeID sets the "employee_id" field.
  292. func (weuo *WorkExperienceUpdateOne) SetEmployeeID(u uint64) *WorkExperienceUpdateOne {
  293. weuo.mutation.SetEmployeeID(u)
  294. return weuo
  295. }
  296. // SetNillableEmployeeID sets the "employee_id" field if the given value is not nil.
  297. func (weuo *WorkExperienceUpdateOne) SetNillableEmployeeID(u *uint64) *WorkExperienceUpdateOne {
  298. if u != nil {
  299. weuo.SetEmployeeID(*u)
  300. }
  301. return weuo
  302. }
  303. // SetStartDate sets the "start_date" field.
  304. func (weuo *WorkExperienceUpdateOne) SetStartDate(t time.Time) *WorkExperienceUpdateOne {
  305. weuo.mutation.SetStartDate(t)
  306. return weuo
  307. }
  308. // SetNillableStartDate sets the "start_date" field if the given value is not nil.
  309. func (weuo *WorkExperienceUpdateOne) SetNillableStartDate(t *time.Time) *WorkExperienceUpdateOne {
  310. if t != nil {
  311. weuo.SetStartDate(*t)
  312. }
  313. return weuo
  314. }
  315. // SetEndDate sets the "end_date" field.
  316. func (weuo *WorkExperienceUpdateOne) SetEndDate(t time.Time) *WorkExperienceUpdateOne {
  317. weuo.mutation.SetEndDate(t)
  318. return weuo
  319. }
  320. // SetNillableEndDate sets the "end_date" field if the given value is not nil.
  321. func (weuo *WorkExperienceUpdateOne) SetNillableEndDate(t *time.Time) *WorkExperienceUpdateOne {
  322. if t != nil {
  323. weuo.SetEndDate(*t)
  324. }
  325. return weuo
  326. }
  327. // SetCompany sets the "company" field.
  328. func (weuo *WorkExperienceUpdateOne) SetCompany(s string) *WorkExperienceUpdateOne {
  329. weuo.mutation.SetCompany(s)
  330. return weuo
  331. }
  332. // SetNillableCompany sets the "company" field if the given value is not nil.
  333. func (weuo *WorkExperienceUpdateOne) SetNillableCompany(s *string) *WorkExperienceUpdateOne {
  334. if s != nil {
  335. weuo.SetCompany(*s)
  336. }
  337. return weuo
  338. }
  339. // SetExperience sets the "experience" field.
  340. func (weuo *WorkExperienceUpdateOne) SetExperience(s string) *WorkExperienceUpdateOne {
  341. weuo.mutation.SetExperience(s)
  342. return weuo
  343. }
  344. // SetNillableExperience sets the "experience" field if the given value is not nil.
  345. func (weuo *WorkExperienceUpdateOne) SetNillableExperience(s *string) *WorkExperienceUpdateOne {
  346. if s != nil {
  347. weuo.SetExperience(*s)
  348. }
  349. return weuo
  350. }
  351. // SetOrganizationID sets the "organization_id" field.
  352. func (weuo *WorkExperienceUpdateOne) SetOrganizationID(u uint64) *WorkExperienceUpdateOne {
  353. weuo.mutation.ResetOrganizationID()
  354. weuo.mutation.SetOrganizationID(u)
  355. return weuo
  356. }
  357. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  358. func (weuo *WorkExperienceUpdateOne) SetNillableOrganizationID(u *uint64) *WorkExperienceUpdateOne {
  359. if u != nil {
  360. weuo.SetOrganizationID(*u)
  361. }
  362. return weuo
  363. }
  364. // AddOrganizationID adds u to the "organization_id" field.
  365. func (weuo *WorkExperienceUpdateOne) AddOrganizationID(u int64) *WorkExperienceUpdateOne {
  366. weuo.mutation.AddOrganizationID(u)
  367. return weuo
  368. }
  369. // SetEmployee sets the "employee" edge to the Employee entity.
  370. func (weuo *WorkExperienceUpdateOne) SetEmployee(e *Employee) *WorkExperienceUpdateOne {
  371. return weuo.SetEmployeeID(e.ID)
  372. }
  373. // Mutation returns the WorkExperienceMutation object of the builder.
  374. func (weuo *WorkExperienceUpdateOne) Mutation() *WorkExperienceMutation {
  375. return weuo.mutation
  376. }
  377. // ClearEmployee clears the "employee" edge to the Employee entity.
  378. func (weuo *WorkExperienceUpdateOne) ClearEmployee() *WorkExperienceUpdateOne {
  379. weuo.mutation.ClearEmployee()
  380. return weuo
  381. }
  382. // Where appends a list predicates to the WorkExperienceUpdate builder.
  383. func (weuo *WorkExperienceUpdateOne) Where(ps ...predicate.WorkExperience) *WorkExperienceUpdateOne {
  384. weuo.mutation.Where(ps...)
  385. return weuo
  386. }
  387. // Select allows selecting one or more fields (columns) of the returned entity.
  388. // The default is selecting all fields defined in the entity schema.
  389. func (weuo *WorkExperienceUpdateOne) Select(field string, fields ...string) *WorkExperienceUpdateOne {
  390. weuo.fields = append([]string{field}, fields...)
  391. return weuo
  392. }
  393. // Save executes the query and returns the updated WorkExperience entity.
  394. func (weuo *WorkExperienceUpdateOne) Save(ctx context.Context) (*WorkExperience, error) {
  395. if err := weuo.defaults(); err != nil {
  396. return nil, err
  397. }
  398. return withHooks(ctx, weuo.sqlSave, weuo.mutation, weuo.hooks)
  399. }
  400. // SaveX is like Save, but panics if an error occurs.
  401. func (weuo *WorkExperienceUpdateOne) SaveX(ctx context.Context) *WorkExperience {
  402. node, err := weuo.Save(ctx)
  403. if err != nil {
  404. panic(err)
  405. }
  406. return node
  407. }
  408. // Exec executes the query on the entity.
  409. func (weuo *WorkExperienceUpdateOne) Exec(ctx context.Context) error {
  410. _, err := weuo.Save(ctx)
  411. return err
  412. }
  413. // ExecX is like Exec, but panics if an error occurs.
  414. func (weuo *WorkExperienceUpdateOne) ExecX(ctx context.Context) {
  415. if err := weuo.Exec(ctx); err != nil {
  416. panic(err)
  417. }
  418. }
  419. // defaults sets the default values of the builder before save.
  420. func (weuo *WorkExperienceUpdateOne) defaults() error {
  421. if _, ok := weuo.mutation.UpdatedAt(); !ok {
  422. if workexperience.UpdateDefaultUpdatedAt == nil {
  423. return fmt.Errorf("ent: uninitialized workexperience.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  424. }
  425. v := workexperience.UpdateDefaultUpdatedAt()
  426. weuo.mutation.SetUpdatedAt(v)
  427. }
  428. return nil
  429. }
  430. // check runs all checks and user-defined validators on the builder.
  431. func (weuo *WorkExperienceUpdateOne) check() error {
  432. if _, ok := weuo.mutation.EmployeeID(); weuo.mutation.EmployeeCleared() && !ok {
  433. return errors.New(`ent: clearing a required unique edge "WorkExperience.employee"`)
  434. }
  435. return nil
  436. }
  437. func (weuo *WorkExperienceUpdateOne) sqlSave(ctx context.Context) (_node *WorkExperience, err error) {
  438. if err := weuo.check(); err != nil {
  439. return _node, err
  440. }
  441. _spec := sqlgraph.NewUpdateSpec(workexperience.Table, workexperience.Columns, sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64))
  442. id, ok := weuo.mutation.ID()
  443. if !ok {
  444. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "WorkExperience.id" for update`)}
  445. }
  446. _spec.Node.ID.Value = id
  447. if fields := weuo.fields; len(fields) > 0 {
  448. _spec.Node.Columns = make([]string, 0, len(fields))
  449. _spec.Node.Columns = append(_spec.Node.Columns, workexperience.FieldID)
  450. for _, f := range fields {
  451. if !workexperience.ValidColumn(f) {
  452. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  453. }
  454. if f != workexperience.FieldID {
  455. _spec.Node.Columns = append(_spec.Node.Columns, f)
  456. }
  457. }
  458. }
  459. if ps := weuo.mutation.predicates; len(ps) > 0 {
  460. _spec.Predicate = func(selector *sql.Selector) {
  461. for i := range ps {
  462. ps[i](selector)
  463. }
  464. }
  465. }
  466. if value, ok := weuo.mutation.UpdatedAt(); ok {
  467. _spec.SetField(workexperience.FieldUpdatedAt, field.TypeTime, value)
  468. }
  469. if value, ok := weuo.mutation.DeletedAt(); ok {
  470. _spec.SetField(workexperience.FieldDeletedAt, field.TypeTime, value)
  471. }
  472. if weuo.mutation.DeletedAtCleared() {
  473. _spec.ClearField(workexperience.FieldDeletedAt, field.TypeTime)
  474. }
  475. if value, ok := weuo.mutation.StartDate(); ok {
  476. _spec.SetField(workexperience.FieldStartDate, field.TypeTime, value)
  477. }
  478. if value, ok := weuo.mutation.EndDate(); ok {
  479. _spec.SetField(workexperience.FieldEndDate, field.TypeTime, value)
  480. }
  481. if value, ok := weuo.mutation.Company(); ok {
  482. _spec.SetField(workexperience.FieldCompany, field.TypeString, value)
  483. }
  484. if value, ok := weuo.mutation.Experience(); ok {
  485. _spec.SetField(workexperience.FieldExperience, field.TypeString, value)
  486. }
  487. if value, ok := weuo.mutation.OrganizationID(); ok {
  488. _spec.SetField(workexperience.FieldOrganizationID, field.TypeUint64, value)
  489. }
  490. if value, ok := weuo.mutation.AddedOrganizationID(); ok {
  491. _spec.AddField(workexperience.FieldOrganizationID, field.TypeUint64, value)
  492. }
  493. if weuo.mutation.EmployeeCleared() {
  494. edge := &sqlgraph.EdgeSpec{
  495. Rel: sqlgraph.M2O,
  496. Inverse: true,
  497. Table: workexperience.EmployeeTable,
  498. Columns: []string{workexperience.EmployeeColumn},
  499. Bidi: false,
  500. Target: &sqlgraph.EdgeTarget{
  501. IDSpec: sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64),
  502. },
  503. }
  504. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  505. }
  506. if nodes := weuo.mutation.EmployeeIDs(); len(nodes) > 0 {
  507. edge := &sqlgraph.EdgeSpec{
  508. Rel: sqlgraph.M2O,
  509. Inverse: true,
  510. Table: workexperience.EmployeeTable,
  511. Columns: []string{workexperience.EmployeeColumn},
  512. Bidi: false,
  513. Target: &sqlgraph.EdgeTarget{
  514. IDSpec: sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64),
  515. },
  516. }
  517. for _, k := range nodes {
  518. edge.Target.Nodes = append(edge.Target.Nodes, k)
  519. }
  520. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  521. }
  522. _node = &WorkExperience{config: weuo.config}
  523. _spec.Assign = _node.assignValues
  524. _spec.ScanValues = _node.scanValues
  525. if err = sqlgraph.UpdateNode(ctx, weuo.driver, _spec); err != nil {
  526. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  527. err = &NotFoundError{workexperience.Label}
  528. } else if sqlgraph.IsConstraintError(err) {
  529. err = &ConstraintError{msg: err.Error(), wrap: err}
  530. }
  531. return nil, err
  532. }
  533. weuo.mutation.done = true
  534. return _node, nil
  535. }