1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/employee"
- "wechat-api/ent/predicate"
- "wechat-api/ent/tutorial"
- "wechat-api/ent/workexperience"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // EmployeeUpdate is the builder for updating Employee entities.
- type EmployeeUpdate struct {
- config
- hooks []Hook
- mutation *EmployeeMutation
- }
- // Where appends a list predicates to the EmployeeUpdate builder.
- func (eu *EmployeeUpdate) Where(ps ...predicate.Employee) *EmployeeUpdate {
- eu.mutation.Where(ps...)
- return eu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (eu *EmployeeUpdate) SetUpdatedAt(t time.Time) *EmployeeUpdate {
- eu.mutation.SetUpdatedAt(t)
- return eu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (eu *EmployeeUpdate) SetDeletedAt(t time.Time) *EmployeeUpdate {
- eu.mutation.SetDeletedAt(t)
- return eu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableDeletedAt(t *time.Time) *EmployeeUpdate {
- if t != nil {
- eu.SetDeletedAt(*t)
- }
- return eu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (eu *EmployeeUpdate) ClearDeletedAt() *EmployeeUpdate {
- eu.mutation.ClearDeletedAt()
- return eu
- }
- // SetTitle sets the "title" field.
- func (eu *EmployeeUpdate) SetTitle(s string) *EmployeeUpdate {
- eu.mutation.SetTitle(s)
- return eu
- }
- // SetNillableTitle sets the "title" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableTitle(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetTitle(*s)
- }
- return eu
- }
- // SetAvatar sets the "avatar" field.
- func (eu *EmployeeUpdate) SetAvatar(s string) *EmployeeUpdate {
- eu.mutation.SetAvatar(s)
- return eu
- }
- // SetNillableAvatar sets the "avatar" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableAvatar(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetAvatar(*s)
- }
- return eu
- }
- // SetTags sets the "tags" field.
- func (eu *EmployeeUpdate) SetTags(s string) *EmployeeUpdate {
- eu.mutation.SetTags(s)
- return eu
- }
- // SetNillableTags sets the "tags" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableTags(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetTags(*s)
- }
- return eu
- }
- // SetHireCount sets the "hire_count" field.
- func (eu *EmployeeUpdate) SetHireCount(i int) *EmployeeUpdate {
- eu.mutation.ResetHireCount()
- eu.mutation.SetHireCount(i)
- return eu
- }
- // SetNillableHireCount sets the "hire_count" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableHireCount(i *int) *EmployeeUpdate {
- if i != nil {
- eu.SetHireCount(*i)
- }
- return eu
- }
- // AddHireCount adds i to the "hire_count" field.
- func (eu *EmployeeUpdate) AddHireCount(i int) *EmployeeUpdate {
- eu.mutation.AddHireCount(i)
- return eu
- }
- // SetServiceCount sets the "service_count" field.
- func (eu *EmployeeUpdate) SetServiceCount(i int) *EmployeeUpdate {
- eu.mutation.ResetServiceCount()
- eu.mutation.SetServiceCount(i)
- return eu
- }
- // SetNillableServiceCount sets the "service_count" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableServiceCount(i *int) *EmployeeUpdate {
- if i != nil {
- eu.SetServiceCount(*i)
- }
- return eu
- }
- // AddServiceCount adds i to the "service_count" field.
- func (eu *EmployeeUpdate) AddServiceCount(i int) *EmployeeUpdate {
- eu.mutation.AddServiceCount(i)
- return eu
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (eu *EmployeeUpdate) SetAchievementCount(i int) *EmployeeUpdate {
- eu.mutation.ResetAchievementCount()
- eu.mutation.SetAchievementCount(i)
- return eu
- }
- // SetNillableAchievementCount sets the "achievement_count" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableAchievementCount(i *int) *EmployeeUpdate {
- if i != nil {
- eu.SetAchievementCount(*i)
- }
- return eu
- }
- // AddAchievementCount adds i to the "achievement_count" field.
- func (eu *EmployeeUpdate) AddAchievementCount(i int) *EmployeeUpdate {
- eu.mutation.AddAchievementCount(i)
- return eu
- }
- // SetIntro sets the "intro" field.
- func (eu *EmployeeUpdate) SetIntro(s string) *EmployeeUpdate {
- eu.mutation.SetIntro(s)
- return eu
- }
- // SetNillableIntro sets the "intro" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableIntro(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetIntro(*s)
- }
- return eu
- }
- // SetEstimate sets the "estimate" field.
- func (eu *EmployeeUpdate) SetEstimate(s string) *EmployeeUpdate {
- eu.mutation.SetEstimate(s)
- return eu
- }
- // SetNillableEstimate sets the "estimate" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableEstimate(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetEstimate(*s)
- }
- return eu
- }
- // SetSkill sets the "skill" field.
- func (eu *EmployeeUpdate) SetSkill(s string) *EmployeeUpdate {
- eu.mutation.SetSkill(s)
- return eu
- }
- // SetNillableSkill sets the "skill" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableSkill(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetSkill(*s)
- }
- return eu
- }
- // SetAbilityType sets the "ability_type" field.
- func (eu *EmployeeUpdate) SetAbilityType(s string) *EmployeeUpdate {
- eu.mutation.SetAbilityType(s)
- return eu
- }
- // SetNillableAbilityType sets the "ability_type" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableAbilityType(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetAbilityType(*s)
- }
- return eu
- }
- // SetScene sets the "scene" field.
- func (eu *EmployeeUpdate) SetScene(s string) *EmployeeUpdate {
- eu.mutation.SetScene(s)
- return eu
- }
- // SetNillableScene sets the "scene" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableScene(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetScene(*s)
- }
- return eu
- }
- // SetSwitchIn sets the "switch_in" field.
- func (eu *EmployeeUpdate) SetSwitchIn(s string) *EmployeeUpdate {
- eu.mutation.SetSwitchIn(s)
- return eu
- }
- // SetNillableSwitchIn sets the "switch_in" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableSwitchIn(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetSwitchIn(*s)
- }
- return eu
- }
- // SetVideoURL sets the "video_url" field.
- func (eu *EmployeeUpdate) SetVideoURL(s string) *EmployeeUpdate {
- eu.mutation.SetVideoURL(s)
- return eu
- }
- // SetNillableVideoURL sets the "video_url" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableVideoURL(s *string) *EmployeeUpdate {
- if s != nil {
- eu.SetVideoURL(*s)
- }
- return eu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (eu *EmployeeUpdate) SetOrganizationID(u uint64) *EmployeeUpdate {
- eu.mutation.ResetOrganizationID()
- eu.mutation.SetOrganizationID(u)
- return eu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableOrganizationID(u *uint64) *EmployeeUpdate {
- if u != nil {
- eu.SetOrganizationID(*u)
- }
- return eu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (eu *EmployeeUpdate) AddOrganizationID(u int64) *EmployeeUpdate {
- eu.mutation.AddOrganizationID(u)
- return eu
- }
- // SetCategoryID sets the "category_id" field.
- func (eu *EmployeeUpdate) SetCategoryID(u uint64) *EmployeeUpdate {
- eu.mutation.ResetCategoryID()
- eu.mutation.SetCategoryID(u)
- return eu
- }
- // SetNillableCategoryID sets the "category_id" field if the given value is not nil.
- func (eu *EmployeeUpdate) SetNillableCategoryID(u *uint64) *EmployeeUpdate {
- if u != nil {
- eu.SetCategoryID(*u)
- }
- return eu
- }
- // AddCategoryID adds u to the "category_id" field.
- func (eu *EmployeeUpdate) AddCategoryID(u int64) *EmployeeUpdate {
- eu.mutation.AddCategoryID(u)
- return eu
- }
- // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by IDs.
- func (eu *EmployeeUpdate) AddEmWorkExperienceIDs(ids ...uint64) *EmployeeUpdate {
- eu.mutation.AddEmWorkExperienceIDs(ids...)
- return eu
- }
- // AddEmWorkExperiences adds the "em_work_experiences" edges to the WorkExperience entity.
- func (eu *EmployeeUpdate) AddEmWorkExperiences(w ...*WorkExperience) *EmployeeUpdate {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return eu.AddEmWorkExperienceIDs(ids...)
- }
- // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by IDs.
- func (eu *EmployeeUpdate) AddEmTutorialIDs(ids ...uint64) *EmployeeUpdate {
- eu.mutation.AddEmTutorialIDs(ids...)
- return eu
- }
- // AddEmTutorial adds the "em_tutorial" edges to the Tutorial entity.
- func (eu *EmployeeUpdate) AddEmTutorial(t ...*Tutorial) *EmployeeUpdate {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return eu.AddEmTutorialIDs(ids...)
- }
- // Mutation returns the EmployeeMutation object of the builder.
- func (eu *EmployeeUpdate) Mutation() *EmployeeMutation {
- return eu.mutation
- }
- // ClearEmWorkExperiences clears all "em_work_experiences" edges to the WorkExperience entity.
- func (eu *EmployeeUpdate) ClearEmWorkExperiences() *EmployeeUpdate {
- eu.mutation.ClearEmWorkExperiences()
- return eu
- }
- // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to WorkExperience entities by IDs.
- func (eu *EmployeeUpdate) RemoveEmWorkExperienceIDs(ids ...uint64) *EmployeeUpdate {
- eu.mutation.RemoveEmWorkExperienceIDs(ids...)
- return eu
- }
- // RemoveEmWorkExperiences removes "em_work_experiences" edges to WorkExperience entities.
- func (eu *EmployeeUpdate) RemoveEmWorkExperiences(w ...*WorkExperience) *EmployeeUpdate {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return eu.RemoveEmWorkExperienceIDs(ids...)
- }
- // ClearEmTutorial clears all "em_tutorial" edges to the Tutorial entity.
- func (eu *EmployeeUpdate) ClearEmTutorial() *EmployeeUpdate {
- eu.mutation.ClearEmTutorial()
- return eu
- }
- // RemoveEmTutorialIDs removes the "em_tutorial" edge to Tutorial entities by IDs.
- func (eu *EmployeeUpdate) RemoveEmTutorialIDs(ids ...uint64) *EmployeeUpdate {
- eu.mutation.RemoveEmTutorialIDs(ids...)
- return eu
- }
- // RemoveEmTutorial removes "em_tutorial" edges to Tutorial entities.
- func (eu *EmployeeUpdate) RemoveEmTutorial(t ...*Tutorial) *EmployeeUpdate {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return eu.RemoveEmTutorialIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (eu *EmployeeUpdate) Save(ctx context.Context) (int, error) {
- if err := eu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, eu.sqlSave, eu.mutation, eu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (eu *EmployeeUpdate) SaveX(ctx context.Context) int {
- affected, err := eu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (eu *EmployeeUpdate) Exec(ctx context.Context) error {
- _, err := eu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (eu *EmployeeUpdate) ExecX(ctx context.Context) {
- if err := eu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (eu *EmployeeUpdate) defaults() error {
- if _, ok := eu.mutation.UpdatedAt(); !ok {
- if employee.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized employee.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := employee.UpdateDefaultUpdatedAt()
- eu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (eu *EmployeeUpdate) check() error {
- if v, ok := eu.mutation.Title(); ok {
- if err := employee.TitleValidator(v); err != nil {
- return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)}
- }
- }
- if v, ok := eu.mutation.Avatar(); ok {
- if err := employee.AvatarValidator(v); err != nil {
- return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
- }
- }
- if v, ok := eu.mutation.Tags(); ok {
- if err := employee.TagsValidator(v); err != nil {
- return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
- }
- }
- if v, ok := eu.mutation.HireCount(); ok {
- if err := employee.HireCountValidator(v); err != nil {
- return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)}
- }
- }
- if v, ok := eu.mutation.ServiceCount(); ok {
- if err := employee.ServiceCountValidator(v); err != nil {
- return &ValidationError{Name: "service_count", err: fmt.Errorf(`ent: validator failed for field "Employee.service_count": %w`, err)}
- }
- }
- if v, ok := eu.mutation.AchievementCount(); ok {
- if err := employee.AchievementCountValidator(v); err != nil {
- return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)}
- }
- }
- if v, ok := eu.mutation.Intro(); ok {
- if err := employee.IntroValidator(v); err != nil {
- return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
- }
- }
- if v, ok := eu.mutation.Estimate(); ok {
- if err := employee.EstimateValidator(v); err != nil {
- return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
- }
- }
- if v, ok := eu.mutation.Skill(); ok {
- if err := employee.SkillValidator(v); err != nil {
- return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
- }
- }
- if v, ok := eu.mutation.VideoURL(); ok {
- if err := employee.VideoURLValidator(v); err != nil {
- return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
- }
- }
- if v, ok := eu.mutation.OrganizationID(); ok {
- if err := employee.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)}
- }
- }
- if v, ok := eu.mutation.CategoryID(); ok {
- if err := employee.CategoryIDValidator(v); err != nil {
- return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Employee.category_id": %w`, err)}
- }
- }
- return nil
- }
- func (eu *EmployeeUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := eu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(employee.Table, employee.Columns, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64))
- if ps := eu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := eu.mutation.UpdatedAt(); ok {
- _spec.SetField(employee.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := eu.mutation.DeletedAt(); ok {
- _spec.SetField(employee.FieldDeletedAt, field.TypeTime, value)
- }
- if eu.mutation.DeletedAtCleared() {
- _spec.ClearField(employee.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := eu.mutation.Title(); ok {
- _spec.SetField(employee.FieldTitle, field.TypeString, value)
- }
- if value, ok := eu.mutation.Avatar(); ok {
- _spec.SetField(employee.FieldAvatar, field.TypeString, value)
- }
- if value, ok := eu.mutation.Tags(); ok {
- _spec.SetField(employee.FieldTags, field.TypeString, value)
- }
- if value, ok := eu.mutation.HireCount(); ok {
- _spec.SetField(employee.FieldHireCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.AddedHireCount(); ok {
- _spec.AddField(employee.FieldHireCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.ServiceCount(); ok {
- _spec.SetField(employee.FieldServiceCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.AddedServiceCount(); ok {
- _spec.AddField(employee.FieldServiceCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.AchievementCount(); ok {
- _spec.SetField(employee.FieldAchievementCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.AddedAchievementCount(); ok {
- _spec.AddField(employee.FieldAchievementCount, field.TypeInt, value)
- }
- if value, ok := eu.mutation.Intro(); ok {
- _spec.SetField(employee.FieldIntro, field.TypeString, value)
- }
- if value, ok := eu.mutation.Estimate(); ok {
- _spec.SetField(employee.FieldEstimate, field.TypeString, value)
- }
- if value, ok := eu.mutation.Skill(); ok {
- _spec.SetField(employee.FieldSkill, field.TypeString, value)
- }
- if value, ok := eu.mutation.AbilityType(); ok {
- _spec.SetField(employee.FieldAbilityType, field.TypeString, value)
- }
- if value, ok := eu.mutation.Scene(); ok {
- _spec.SetField(employee.FieldScene, field.TypeString, value)
- }
- if value, ok := eu.mutation.SwitchIn(); ok {
- _spec.SetField(employee.FieldSwitchIn, field.TypeString, value)
- }
- if value, ok := eu.mutation.VideoURL(); ok {
- _spec.SetField(employee.FieldVideoURL, field.TypeString, value)
- }
- if value, ok := eu.mutation.OrganizationID(); ok {
- _spec.SetField(employee.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := eu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(employee.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := eu.mutation.CategoryID(); ok {
- _spec.SetField(employee.FieldCategoryID, field.TypeUint64, value)
- }
- if value, ok := eu.mutation.AddedCategoryID(); ok {
- _spec.AddField(employee.FieldCategoryID, field.TypeUint64, value)
- }
- if eu.mutation.EmWorkExperiencesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := eu.mutation.RemovedEmWorkExperiencesIDs(); len(nodes) > 0 && !eu.mutation.EmWorkExperiencesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := eu.mutation.EmWorkExperiencesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if eu.mutation.EmTutorialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := eu.mutation.RemovedEmTutorialIDs(); len(nodes) > 0 && !eu.mutation.EmTutorialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := eu.mutation.EmTutorialIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{employee.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- eu.mutation.done = true
- return n, nil
- }
- // EmployeeUpdateOne is the builder for updating a single Employee entity.
- type EmployeeUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *EmployeeMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (euo *EmployeeUpdateOne) SetUpdatedAt(t time.Time) *EmployeeUpdateOne {
- euo.mutation.SetUpdatedAt(t)
- return euo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (euo *EmployeeUpdateOne) SetDeletedAt(t time.Time) *EmployeeUpdateOne {
- euo.mutation.SetDeletedAt(t)
- return euo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableDeletedAt(t *time.Time) *EmployeeUpdateOne {
- if t != nil {
- euo.SetDeletedAt(*t)
- }
- return euo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (euo *EmployeeUpdateOne) ClearDeletedAt() *EmployeeUpdateOne {
- euo.mutation.ClearDeletedAt()
- return euo
- }
- // SetTitle sets the "title" field.
- func (euo *EmployeeUpdateOne) SetTitle(s string) *EmployeeUpdateOne {
- euo.mutation.SetTitle(s)
- return euo
- }
- // SetNillableTitle sets the "title" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableTitle(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetTitle(*s)
- }
- return euo
- }
- // SetAvatar sets the "avatar" field.
- func (euo *EmployeeUpdateOne) SetAvatar(s string) *EmployeeUpdateOne {
- euo.mutation.SetAvatar(s)
- return euo
- }
- // SetNillableAvatar sets the "avatar" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableAvatar(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetAvatar(*s)
- }
- return euo
- }
- // SetTags sets the "tags" field.
- func (euo *EmployeeUpdateOne) SetTags(s string) *EmployeeUpdateOne {
- euo.mutation.SetTags(s)
- return euo
- }
- // SetNillableTags sets the "tags" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableTags(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetTags(*s)
- }
- return euo
- }
- // SetHireCount sets the "hire_count" field.
- func (euo *EmployeeUpdateOne) SetHireCount(i int) *EmployeeUpdateOne {
- euo.mutation.ResetHireCount()
- euo.mutation.SetHireCount(i)
- return euo
- }
- // SetNillableHireCount sets the "hire_count" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableHireCount(i *int) *EmployeeUpdateOne {
- if i != nil {
- euo.SetHireCount(*i)
- }
- return euo
- }
- // AddHireCount adds i to the "hire_count" field.
- func (euo *EmployeeUpdateOne) AddHireCount(i int) *EmployeeUpdateOne {
- euo.mutation.AddHireCount(i)
- return euo
- }
- // SetServiceCount sets the "service_count" field.
- func (euo *EmployeeUpdateOne) SetServiceCount(i int) *EmployeeUpdateOne {
- euo.mutation.ResetServiceCount()
- euo.mutation.SetServiceCount(i)
- return euo
- }
- // SetNillableServiceCount sets the "service_count" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableServiceCount(i *int) *EmployeeUpdateOne {
- if i != nil {
- euo.SetServiceCount(*i)
- }
- return euo
- }
- // AddServiceCount adds i to the "service_count" field.
- func (euo *EmployeeUpdateOne) AddServiceCount(i int) *EmployeeUpdateOne {
- euo.mutation.AddServiceCount(i)
- return euo
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (euo *EmployeeUpdateOne) SetAchievementCount(i int) *EmployeeUpdateOne {
- euo.mutation.ResetAchievementCount()
- euo.mutation.SetAchievementCount(i)
- return euo
- }
- // SetNillableAchievementCount sets the "achievement_count" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableAchievementCount(i *int) *EmployeeUpdateOne {
- if i != nil {
- euo.SetAchievementCount(*i)
- }
- return euo
- }
- // AddAchievementCount adds i to the "achievement_count" field.
- func (euo *EmployeeUpdateOne) AddAchievementCount(i int) *EmployeeUpdateOne {
- euo.mutation.AddAchievementCount(i)
- return euo
- }
- // SetIntro sets the "intro" field.
- func (euo *EmployeeUpdateOne) SetIntro(s string) *EmployeeUpdateOne {
- euo.mutation.SetIntro(s)
- return euo
- }
- // SetNillableIntro sets the "intro" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableIntro(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetIntro(*s)
- }
- return euo
- }
- // SetEstimate sets the "estimate" field.
- func (euo *EmployeeUpdateOne) SetEstimate(s string) *EmployeeUpdateOne {
- euo.mutation.SetEstimate(s)
- return euo
- }
- // SetNillableEstimate sets the "estimate" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableEstimate(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetEstimate(*s)
- }
- return euo
- }
- // SetSkill sets the "skill" field.
- func (euo *EmployeeUpdateOne) SetSkill(s string) *EmployeeUpdateOne {
- euo.mutation.SetSkill(s)
- return euo
- }
- // SetNillableSkill sets the "skill" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableSkill(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetSkill(*s)
- }
- return euo
- }
- // SetAbilityType sets the "ability_type" field.
- func (euo *EmployeeUpdateOne) SetAbilityType(s string) *EmployeeUpdateOne {
- euo.mutation.SetAbilityType(s)
- return euo
- }
- // SetNillableAbilityType sets the "ability_type" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableAbilityType(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetAbilityType(*s)
- }
- return euo
- }
- // SetScene sets the "scene" field.
- func (euo *EmployeeUpdateOne) SetScene(s string) *EmployeeUpdateOne {
- euo.mutation.SetScene(s)
- return euo
- }
- // SetNillableScene sets the "scene" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableScene(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetScene(*s)
- }
- return euo
- }
- // SetSwitchIn sets the "switch_in" field.
- func (euo *EmployeeUpdateOne) SetSwitchIn(s string) *EmployeeUpdateOne {
- euo.mutation.SetSwitchIn(s)
- return euo
- }
- // SetNillableSwitchIn sets the "switch_in" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableSwitchIn(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetSwitchIn(*s)
- }
- return euo
- }
- // SetVideoURL sets the "video_url" field.
- func (euo *EmployeeUpdateOne) SetVideoURL(s string) *EmployeeUpdateOne {
- euo.mutation.SetVideoURL(s)
- return euo
- }
- // SetNillableVideoURL sets the "video_url" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableVideoURL(s *string) *EmployeeUpdateOne {
- if s != nil {
- euo.SetVideoURL(*s)
- }
- return euo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (euo *EmployeeUpdateOne) SetOrganizationID(u uint64) *EmployeeUpdateOne {
- euo.mutation.ResetOrganizationID()
- euo.mutation.SetOrganizationID(u)
- return euo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableOrganizationID(u *uint64) *EmployeeUpdateOne {
- if u != nil {
- euo.SetOrganizationID(*u)
- }
- return euo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (euo *EmployeeUpdateOne) AddOrganizationID(u int64) *EmployeeUpdateOne {
- euo.mutation.AddOrganizationID(u)
- return euo
- }
- // SetCategoryID sets the "category_id" field.
- func (euo *EmployeeUpdateOne) SetCategoryID(u uint64) *EmployeeUpdateOne {
- euo.mutation.ResetCategoryID()
- euo.mutation.SetCategoryID(u)
- return euo
- }
- // SetNillableCategoryID sets the "category_id" field if the given value is not nil.
- func (euo *EmployeeUpdateOne) SetNillableCategoryID(u *uint64) *EmployeeUpdateOne {
- if u != nil {
- euo.SetCategoryID(*u)
- }
- return euo
- }
- // AddCategoryID adds u to the "category_id" field.
- func (euo *EmployeeUpdateOne) AddCategoryID(u int64) *EmployeeUpdateOne {
- euo.mutation.AddCategoryID(u)
- return euo
- }
- // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by IDs.
- func (euo *EmployeeUpdateOne) AddEmWorkExperienceIDs(ids ...uint64) *EmployeeUpdateOne {
- euo.mutation.AddEmWorkExperienceIDs(ids...)
- return euo
- }
- // AddEmWorkExperiences adds the "em_work_experiences" edges to the WorkExperience entity.
- func (euo *EmployeeUpdateOne) AddEmWorkExperiences(w ...*WorkExperience) *EmployeeUpdateOne {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return euo.AddEmWorkExperienceIDs(ids...)
- }
- // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by IDs.
- func (euo *EmployeeUpdateOne) AddEmTutorialIDs(ids ...uint64) *EmployeeUpdateOne {
- euo.mutation.AddEmTutorialIDs(ids...)
- return euo
- }
- // AddEmTutorial adds the "em_tutorial" edges to the Tutorial entity.
- func (euo *EmployeeUpdateOne) AddEmTutorial(t ...*Tutorial) *EmployeeUpdateOne {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return euo.AddEmTutorialIDs(ids...)
- }
- // Mutation returns the EmployeeMutation object of the builder.
- func (euo *EmployeeUpdateOne) Mutation() *EmployeeMutation {
- return euo.mutation
- }
- // ClearEmWorkExperiences clears all "em_work_experiences" edges to the WorkExperience entity.
- func (euo *EmployeeUpdateOne) ClearEmWorkExperiences() *EmployeeUpdateOne {
- euo.mutation.ClearEmWorkExperiences()
- return euo
- }
- // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to WorkExperience entities by IDs.
- func (euo *EmployeeUpdateOne) RemoveEmWorkExperienceIDs(ids ...uint64) *EmployeeUpdateOne {
- euo.mutation.RemoveEmWorkExperienceIDs(ids...)
- return euo
- }
- // RemoveEmWorkExperiences removes "em_work_experiences" edges to WorkExperience entities.
- func (euo *EmployeeUpdateOne) RemoveEmWorkExperiences(w ...*WorkExperience) *EmployeeUpdateOne {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return euo.RemoveEmWorkExperienceIDs(ids...)
- }
- // ClearEmTutorial clears all "em_tutorial" edges to the Tutorial entity.
- func (euo *EmployeeUpdateOne) ClearEmTutorial() *EmployeeUpdateOne {
- euo.mutation.ClearEmTutorial()
- return euo
- }
- // RemoveEmTutorialIDs removes the "em_tutorial" edge to Tutorial entities by IDs.
- func (euo *EmployeeUpdateOne) RemoveEmTutorialIDs(ids ...uint64) *EmployeeUpdateOne {
- euo.mutation.RemoveEmTutorialIDs(ids...)
- return euo
- }
- // RemoveEmTutorial removes "em_tutorial" edges to Tutorial entities.
- func (euo *EmployeeUpdateOne) RemoveEmTutorial(t ...*Tutorial) *EmployeeUpdateOne {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return euo.RemoveEmTutorialIDs(ids...)
- }
- // Where appends a list predicates to the EmployeeUpdate builder.
- func (euo *EmployeeUpdateOne) Where(ps ...predicate.Employee) *EmployeeUpdateOne {
- euo.mutation.Where(ps...)
- return euo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (euo *EmployeeUpdateOne) Select(field string, fields ...string) *EmployeeUpdateOne {
- euo.fields = append([]string{field}, fields...)
- return euo
- }
- // Save executes the query and returns the updated Employee entity.
- func (euo *EmployeeUpdateOne) Save(ctx context.Context) (*Employee, error) {
- if err := euo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, euo.sqlSave, euo.mutation, euo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (euo *EmployeeUpdateOne) SaveX(ctx context.Context) *Employee {
- node, err := euo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (euo *EmployeeUpdateOne) Exec(ctx context.Context) error {
- _, err := euo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (euo *EmployeeUpdateOne) ExecX(ctx context.Context) {
- if err := euo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (euo *EmployeeUpdateOne) defaults() error {
- if _, ok := euo.mutation.UpdatedAt(); !ok {
- if employee.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized employee.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := employee.UpdateDefaultUpdatedAt()
- euo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (euo *EmployeeUpdateOne) check() error {
- if v, ok := euo.mutation.Title(); ok {
- if err := employee.TitleValidator(v); err != nil {
- return &ValidationError{Name: "title", err: fmt.Errorf(`ent: validator failed for field "Employee.title": %w`, err)}
- }
- }
- if v, ok := euo.mutation.Avatar(); ok {
- if err := employee.AvatarValidator(v); err != nil {
- return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "Employee.avatar": %w`, err)}
- }
- }
- if v, ok := euo.mutation.Tags(); ok {
- if err := employee.TagsValidator(v); err != nil {
- return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Employee.tags": %w`, err)}
- }
- }
- if v, ok := euo.mutation.HireCount(); ok {
- if err := employee.HireCountValidator(v); err != nil {
- return &ValidationError{Name: "hire_count", err: fmt.Errorf(`ent: validator failed for field "Employee.hire_count": %w`, err)}
- }
- }
- if v, ok := euo.mutation.ServiceCount(); ok {
- if err := employee.ServiceCountValidator(v); err != nil {
- return &ValidationError{Name: "service_count", err: fmt.Errorf(`ent: validator failed for field "Employee.service_count": %w`, err)}
- }
- }
- if v, ok := euo.mutation.AchievementCount(); ok {
- if err := employee.AchievementCountValidator(v); err != nil {
- return &ValidationError{Name: "achievement_count", err: fmt.Errorf(`ent: validator failed for field "Employee.achievement_count": %w`, err)}
- }
- }
- if v, ok := euo.mutation.Intro(); ok {
- if err := employee.IntroValidator(v); err != nil {
- return &ValidationError{Name: "intro", err: fmt.Errorf(`ent: validator failed for field "Employee.intro": %w`, err)}
- }
- }
- if v, ok := euo.mutation.Estimate(); ok {
- if err := employee.EstimateValidator(v); err != nil {
- return &ValidationError{Name: "estimate", err: fmt.Errorf(`ent: validator failed for field "Employee.estimate": %w`, err)}
- }
- }
- if v, ok := euo.mutation.Skill(); ok {
- if err := employee.SkillValidator(v); err != nil {
- return &ValidationError{Name: "skill", err: fmt.Errorf(`ent: validator failed for field "Employee.skill": %w`, err)}
- }
- }
- if v, ok := euo.mutation.VideoURL(); ok {
- if err := employee.VideoURLValidator(v); err != nil {
- return &ValidationError{Name: "video_url", err: fmt.Errorf(`ent: validator failed for field "Employee.video_url": %w`, err)}
- }
- }
- if v, ok := euo.mutation.OrganizationID(); ok {
- if err := employee.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Employee.organization_id": %w`, err)}
- }
- }
- if v, ok := euo.mutation.CategoryID(); ok {
- if err := employee.CategoryIDValidator(v); err != nil {
- return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Employee.category_id": %w`, err)}
- }
- }
- return nil
- }
- func (euo *EmployeeUpdateOne) sqlSave(ctx context.Context) (_node *Employee, err error) {
- if err := euo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(employee.Table, employee.Columns, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64))
- id, ok := euo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Employee.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := euo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, employee.FieldID)
- for _, f := range fields {
- if !employee.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != employee.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := euo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := euo.mutation.UpdatedAt(); ok {
- _spec.SetField(employee.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := euo.mutation.DeletedAt(); ok {
- _spec.SetField(employee.FieldDeletedAt, field.TypeTime, value)
- }
- if euo.mutation.DeletedAtCleared() {
- _spec.ClearField(employee.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := euo.mutation.Title(); ok {
- _spec.SetField(employee.FieldTitle, field.TypeString, value)
- }
- if value, ok := euo.mutation.Avatar(); ok {
- _spec.SetField(employee.FieldAvatar, field.TypeString, value)
- }
- if value, ok := euo.mutation.Tags(); ok {
- _spec.SetField(employee.FieldTags, field.TypeString, value)
- }
- if value, ok := euo.mutation.HireCount(); ok {
- _spec.SetField(employee.FieldHireCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.AddedHireCount(); ok {
- _spec.AddField(employee.FieldHireCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.ServiceCount(); ok {
- _spec.SetField(employee.FieldServiceCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.AddedServiceCount(); ok {
- _spec.AddField(employee.FieldServiceCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.AchievementCount(); ok {
- _spec.SetField(employee.FieldAchievementCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.AddedAchievementCount(); ok {
- _spec.AddField(employee.FieldAchievementCount, field.TypeInt, value)
- }
- if value, ok := euo.mutation.Intro(); ok {
- _spec.SetField(employee.FieldIntro, field.TypeString, value)
- }
- if value, ok := euo.mutation.Estimate(); ok {
- _spec.SetField(employee.FieldEstimate, field.TypeString, value)
- }
- if value, ok := euo.mutation.Skill(); ok {
- _spec.SetField(employee.FieldSkill, field.TypeString, value)
- }
- if value, ok := euo.mutation.AbilityType(); ok {
- _spec.SetField(employee.FieldAbilityType, field.TypeString, value)
- }
- if value, ok := euo.mutation.Scene(); ok {
- _spec.SetField(employee.FieldScene, field.TypeString, value)
- }
- if value, ok := euo.mutation.SwitchIn(); ok {
- _spec.SetField(employee.FieldSwitchIn, field.TypeString, value)
- }
- if value, ok := euo.mutation.VideoURL(); ok {
- _spec.SetField(employee.FieldVideoURL, field.TypeString, value)
- }
- if value, ok := euo.mutation.OrganizationID(); ok {
- _spec.SetField(employee.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := euo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(employee.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := euo.mutation.CategoryID(); ok {
- _spec.SetField(employee.FieldCategoryID, field.TypeUint64, value)
- }
- if value, ok := euo.mutation.AddedCategoryID(); ok {
- _spec.AddField(employee.FieldCategoryID, field.TypeUint64, value)
- }
- if euo.mutation.EmWorkExperiencesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := euo.mutation.RemovedEmWorkExperiencesIDs(); len(nodes) > 0 && !euo.mutation.EmWorkExperiencesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := euo.mutation.EmWorkExperiencesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmWorkExperiencesTable,
- Columns: []string{employee.EmWorkExperiencesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(workexperience.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if euo.mutation.EmTutorialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := euo.mutation.RemovedEmTutorialIDs(); len(nodes) > 0 && !euo.mutation.EmTutorialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := euo.mutation.EmTutorialIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: employee.EmTutorialTable,
- Columns: []string{employee.EmTutorialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(tutorial.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &Employee{config: euo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, euo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{employee.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- euo.mutation.done = true
- return _node, nil
- }
|