123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/employee"
- "wechat-api/ent/tutorial"
- "wechat-api/ent/workexperience"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // EmployeeCreate is the builder for creating a Employee entity.
- type EmployeeCreate struct {
- config
- mutation *EmployeeMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (ec *EmployeeCreate) SetCreatedAt(t time.Time) *EmployeeCreate {
- ec.mutation.SetCreatedAt(t)
- return ec
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableCreatedAt(t *time.Time) *EmployeeCreate {
- if t != nil {
- ec.SetCreatedAt(*t)
- }
- return ec
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (ec *EmployeeCreate) SetUpdatedAt(t time.Time) *EmployeeCreate {
- ec.mutation.SetUpdatedAt(t)
- return ec
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableUpdatedAt(t *time.Time) *EmployeeCreate {
- if t != nil {
- ec.SetUpdatedAt(*t)
- }
- return ec
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (ec *EmployeeCreate) SetDeletedAt(t time.Time) *EmployeeCreate {
- ec.mutation.SetDeletedAt(t)
- return ec
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableDeletedAt(t *time.Time) *EmployeeCreate {
- if t != nil {
- ec.SetDeletedAt(*t)
- }
- return ec
- }
- // SetTitle sets the "title" field.
- func (ec *EmployeeCreate) SetTitle(s string) *EmployeeCreate {
- ec.mutation.SetTitle(s)
- return ec
- }
- // SetAvatar sets the "avatar" field.
- func (ec *EmployeeCreate) SetAvatar(s string) *EmployeeCreate {
- ec.mutation.SetAvatar(s)
- return ec
- }
- // SetTags sets the "tags" field.
- func (ec *EmployeeCreate) SetTags(s string) *EmployeeCreate {
- ec.mutation.SetTags(s)
- return ec
- }
- // SetHireCount sets the "hire_count" field.
- func (ec *EmployeeCreate) SetHireCount(i int) *EmployeeCreate {
- ec.mutation.SetHireCount(i)
- return ec
- }
- // SetNillableHireCount sets the "hire_count" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableHireCount(i *int) *EmployeeCreate {
- if i != nil {
- ec.SetHireCount(*i)
- }
- return ec
- }
- // SetServiceCount sets the "service_count" field.
- func (ec *EmployeeCreate) SetServiceCount(i int) *EmployeeCreate {
- ec.mutation.SetServiceCount(i)
- return ec
- }
- // SetNillableServiceCount sets the "service_count" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableServiceCount(i *int) *EmployeeCreate {
- if i != nil {
- ec.SetServiceCount(*i)
- }
- return ec
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (ec *EmployeeCreate) SetAchievementCount(i int) *EmployeeCreate {
- ec.mutation.SetAchievementCount(i)
- return ec
- }
- // SetNillableAchievementCount sets the "achievement_count" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableAchievementCount(i *int) *EmployeeCreate {
- if i != nil {
- ec.SetAchievementCount(*i)
- }
- return ec
- }
- // SetIntro sets the "intro" field.
- func (ec *EmployeeCreate) SetIntro(s string) *EmployeeCreate {
- ec.mutation.SetIntro(s)
- return ec
- }
- // SetNillableIntro sets the "intro" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableIntro(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetIntro(*s)
- }
- return ec
- }
- // SetEstimate sets the "estimate" field.
- func (ec *EmployeeCreate) SetEstimate(s string) *EmployeeCreate {
- ec.mutation.SetEstimate(s)
- return ec
- }
- // SetNillableEstimate sets the "estimate" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableEstimate(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetEstimate(*s)
- }
- return ec
- }
- // SetSkill sets the "skill" field.
- func (ec *EmployeeCreate) SetSkill(s string) *EmployeeCreate {
- ec.mutation.SetSkill(s)
- return ec
- }
- // SetNillableSkill sets the "skill" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableSkill(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetSkill(*s)
- }
- return ec
- }
- // SetAbilityType sets the "ability_type" field.
- func (ec *EmployeeCreate) SetAbilityType(s string) *EmployeeCreate {
- ec.mutation.SetAbilityType(s)
- return ec
- }
- // SetNillableAbilityType sets the "ability_type" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableAbilityType(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetAbilityType(*s)
- }
- return ec
- }
- // SetScene sets the "scene" field.
- func (ec *EmployeeCreate) SetScene(s string) *EmployeeCreate {
- ec.mutation.SetScene(s)
- return ec
- }
- // SetNillableScene sets the "scene" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableScene(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetScene(*s)
- }
- return ec
- }
- // SetSwitchIn sets the "switch_in" field.
- func (ec *EmployeeCreate) SetSwitchIn(s string) *EmployeeCreate {
- ec.mutation.SetSwitchIn(s)
- return ec
- }
- // SetNillableSwitchIn sets the "switch_in" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableSwitchIn(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetSwitchIn(*s)
- }
- return ec
- }
- // SetVideoURL sets the "video_url" field.
- func (ec *EmployeeCreate) SetVideoURL(s string) *EmployeeCreate {
- ec.mutation.SetVideoURL(s)
- return ec
- }
- // SetNillableVideoURL sets the "video_url" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableVideoURL(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetVideoURL(*s)
- }
- return ec
- }
- // SetOrganizationID sets the "organization_id" field.
- func (ec *EmployeeCreate) SetOrganizationID(u uint64) *EmployeeCreate {
- ec.mutation.SetOrganizationID(u)
- return ec
- }
- // SetCategoryID sets the "category_id" field.
- func (ec *EmployeeCreate) SetCategoryID(u uint64) *EmployeeCreate {
- ec.mutation.SetCategoryID(u)
- return ec
- }
- // SetAPIBase sets the "api_base" field.
- func (ec *EmployeeCreate) SetAPIBase(s string) *EmployeeCreate {
- ec.mutation.SetAPIBase(s)
- return ec
- }
- // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableAPIBase(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetAPIBase(*s)
- }
- return ec
- }
- // SetAPIKey sets the "api_key" field.
- func (ec *EmployeeCreate) SetAPIKey(s string) *EmployeeCreate {
- ec.mutation.SetAPIKey(s)
- return ec
- }
- // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableAPIKey(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetAPIKey(*s)
- }
- return ec
- }
- // SetAiInfo sets the "ai_info" field.
- func (ec *EmployeeCreate) SetAiInfo(s string) *EmployeeCreate {
- ec.mutation.SetAiInfo(s)
- return ec
- }
- // SetNillableAiInfo sets the "ai_info" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableAiInfo(s *string) *EmployeeCreate {
- if s != nil {
- ec.SetAiInfo(*s)
- }
- return ec
- }
- // SetIsVip sets the "is_vip" field.
- func (ec *EmployeeCreate) SetIsVip(i int) *EmployeeCreate {
- ec.mutation.SetIsVip(i)
- return ec
- }
- // SetNillableIsVip sets the "is_vip" field if the given value is not nil.
- func (ec *EmployeeCreate) SetNillableIsVip(i *int) *EmployeeCreate {
- if i != nil {
- ec.SetIsVip(*i)
- }
- return ec
- }
- // SetChatURL sets the "chat_url" field.
- func (ec *EmployeeCreate) SetChatURL(s string) *EmployeeCreate {
- ec.mutation.SetChatURL(s)
- return ec
- }
- // SetID sets the "id" field.
- func (ec *EmployeeCreate) SetID(u uint64) *EmployeeCreate {
- ec.mutation.SetID(u)
- return ec
- }
- // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by IDs.
- func (ec *EmployeeCreate) AddEmWorkExperienceIDs(ids ...uint64) *EmployeeCreate {
- ec.mutation.AddEmWorkExperienceIDs(ids...)
- return ec
- }
- // AddEmWorkExperiences adds the "em_work_experiences" edges to the WorkExperience entity.
- func (ec *EmployeeCreate) AddEmWorkExperiences(w ...*WorkExperience) *EmployeeCreate {
- ids := make([]uint64, len(w))
- for i := range w {
- ids[i] = w[i].ID
- }
- return ec.AddEmWorkExperienceIDs(ids...)
- }
- // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by IDs.
- func (ec *EmployeeCreate) AddEmTutorialIDs(ids ...uint64) *EmployeeCreate {
- ec.mutation.AddEmTutorialIDs(ids...)
- return ec
- }
- // AddEmTutorial adds the "em_tutorial" edges to the Tutorial entity.
- func (ec *EmployeeCreate) AddEmTutorial(t ...*Tutorial) *EmployeeCreate {
- ids := make([]uint64, len(t))
- for i := range t {
- ids[i] = t[i].ID
- }
- return ec.AddEmTutorialIDs(ids...)
- }
- // Mutation returns the EmployeeMutation object of the builder.
- func (ec *EmployeeCreate) Mutation() *EmployeeMutation {
- return ec.mutation
- }
- // Save creates the Employee in the database.
- func (ec *EmployeeCreate) Save(ctx context.Context) (*Employee, error) {
- if err := ec.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, ec.sqlSave, ec.mutation, ec.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (ec *EmployeeCreate) SaveX(ctx context.Context) *Employee {
- v, err := ec.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ec *EmployeeCreate) Exec(ctx context.Context) error {
- _, err := ec.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ec *EmployeeCreate) ExecX(ctx context.Context) {
- if err := ec.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (ec *EmployeeCreate) defaults() error {
- if _, ok := ec.mutation.CreatedAt(); !ok {
- if employee.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized employee.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := employee.DefaultCreatedAt()
- ec.mutation.SetCreatedAt(v)
- }
- if _, ok := ec.mutation.UpdatedAt(); !ok {
- if employee.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized employee.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := employee.DefaultUpdatedAt()
- ec.mutation.SetUpdatedAt(v)
- }
- if _, ok := ec.mutation.HireCount(); !ok {
- v := employee.DefaultHireCount
- ec.mutation.SetHireCount(v)
- }
- if _, ok := ec.mutation.ServiceCount(); !ok {
- v := employee.DefaultServiceCount
- ec.mutation.SetServiceCount(v)
- }
- if _, ok := ec.mutation.AchievementCount(); !ok {
- v := employee.DefaultAchievementCount
- ec.mutation.SetAchievementCount(v)
- }
- if _, ok := ec.mutation.Intro(); !ok {
- v := employee.DefaultIntro
- ec.mutation.SetIntro(v)
- }
- if _, ok := ec.mutation.Estimate(); !ok {
- v := employee.DefaultEstimate
- ec.mutation.SetEstimate(v)
- }
- if _, ok := ec.mutation.Skill(); !ok {
- v := employee.DefaultSkill
- ec.mutation.SetSkill(v)
- }
- if _, ok := ec.mutation.AbilityType(); !ok {
- v := employee.DefaultAbilityType
- ec.mutation.SetAbilityType(v)
- }
- if _, ok := ec.mutation.Scene(); !ok {
- v := employee.DefaultScene
- ec.mutation.SetScene(v)
- }
- if _, ok := ec.mutation.SwitchIn(); !ok {
- v := employee.DefaultSwitchIn
- ec.mutation.SetSwitchIn(v)
- }
- if _, ok := ec.mutation.VideoURL(); !ok {
- v := employee.DefaultVideoURL
- ec.mutation.SetVideoURL(v)
- }
- if _, ok := ec.mutation.APIBase(); !ok {
- v := employee.DefaultAPIBase
- ec.mutation.SetAPIBase(v)
- }
- if _, ok := ec.mutation.APIKey(); !ok {
- v := employee.DefaultAPIKey
- ec.mutation.SetAPIKey(v)
- }
- if _, ok := ec.mutation.IsVip(); !ok {
- v := employee.DefaultIsVip
- ec.mutation.SetIsVip(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (ec *EmployeeCreate) check() error {
- if _, ok := ec.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Employee.created_at"`)}
- }
- if _, ok := ec.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Employee.updated_at"`)}
- }
- if _, ok := ec.mutation.Title(); !ok {
- return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Employee.title"`)}
- }
- if v, ok := ec.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 _, ok := ec.mutation.Avatar(); !ok {
- return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "Employee.avatar"`)}
- }
- if _, ok := ec.mutation.Tags(); !ok {
- return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "Employee.tags"`)}
- }
- if _, ok := ec.mutation.HireCount(); !ok {
- return &ValidationError{Name: "hire_count", err: errors.New(`ent: missing required field "Employee.hire_count"`)}
- }
- if v, ok := ec.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 _, ok := ec.mutation.ServiceCount(); !ok {
- return &ValidationError{Name: "service_count", err: errors.New(`ent: missing required field "Employee.service_count"`)}
- }
- if v, ok := ec.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 _, ok := ec.mutation.AchievementCount(); !ok {
- return &ValidationError{Name: "achievement_count", err: errors.New(`ent: missing required field "Employee.achievement_count"`)}
- }
- if v, ok := ec.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 _, ok := ec.mutation.Intro(); !ok {
- return &ValidationError{Name: "intro", err: errors.New(`ent: missing required field "Employee.intro"`)}
- }
- if _, ok := ec.mutation.Estimate(); !ok {
- return &ValidationError{Name: "estimate", err: errors.New(`ent: missing required field "Employee.estimate"`)}
- }
- if _, ok := ec.mutation.Skill(); !ok {
- return &ValidationError{Name: "skill", err: errors.New(`ent: missing required field "Employee.skill"`)}
- }
- if _, ok := ec.mutation.AbilityType(); !ok {
- return &ValidationError{Name: "ability_type", err: errors.New(`ent: missing required field "Employee.ability_type"`)}
- }
- if _, ok := ec.mutation.Scene(); !ok {
- return &ValidationError{Name: "scene", err: errors.New(`ent: missing required field "Employee.scene"`)}
- }
- if _, ok := ec.mutation.SwitchIn(); !ok {
- return &ValidationError{Name: "switch_in", err: errors.New(`ent: missing required field "Employee.switch_in"`)}
- }
- if _, ok := ec.mutation.VideoURL(); !ok {
- return &ValidationError{Name: "video_url", err: errors.New(`ent: missing required field "Employee.video_url"`)}
- }
- if _, ok := ec.mutation.OrganizationID(); !ok {
- return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Employee.organization_id"`)}
- }
- if v, ok := ec.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 _, ok := ec.mutation.CategoryID(); !ok {
- return &ValidationError{Name: "category_id", err: errors.New(`ent: missing required field "Employee.category_id"`)}
- }
- if v, ok := ec.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)}
- }
- }
- if _, ok := ec.mutation.APIBase(); !ok {
- return &ValidationError{Name: "api_base", err: errors.New(`ent: missing required field "Employee.api_base"`)}
- }
- if _, ok := ec.mutation.APIKey(); !ok {
- return &ValidationError{Name: "api_key", err: errors.New(`ent: missing required field "Employee.api_key"`)}
- }
- if _, ok := ec.mutation.IsVip(); !ok {
- return &ValidationError{Name: "is_vip", err: errors.New(`ent: missing required field "Employee.is_vip"`)}
- }
- if _, ok := ec.mutation.ChatURL(); !ok {
- return &ValidationError{Name: "chat_url", err: errors.New(`ent: missing required field "Employee.chat_url"`)}
- }
- return nil
- }
- func (ec *EmployeeCreate) sqlSave(ctx context.Context) (*Employee, error) {
- if err := ec.check(); err != nil {
- return nil, err
- }
- _node, _spec := ec.createSpec()
- if err := sqlgraph.CreateNode(ctx, ec.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- if _spec.ID.Value != _node.ID {
- id := _spec.ID.Value.(int64)
- _node.ID = uint64(id)
- }
- ec.mutation.id = &_node.ID
- ec.mutation.done = true
- return _node, nil
- }
- func (ec *EmployeeCreate) createSpec() (*Employee, *sqlgraph.CreateSpec) {
- var (
- _node = &Employee{config: ec.config}
- _spec = sqlgraph.NewCreateSpec(employee.Table, sqlgraph.NewFieldSpec(employee.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = ec.conflict
- if id, ok := ec.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := ec.mutation.CreatedAt(); ok {
- _spec.SetField(employee.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := ec.mutation.UpdatedAt(); ok {
- _spec.SetField(employee.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := ec.mutation.DeletedAt(); ok {
- _spec.SetField(employee.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := ec.mutation.Title(); ok {
- _spec.SetField(employee.FieldTitle, field.TypeString, value)
- _node.Title = value
- }
- if value, ok := ec.mutation.Avatar(); ok {
- _spec.SetField(employee.FieldAvatar, field.TypeString, value)
- _node.Avatar = value
- }
- if value, ok := ec.mutation.Tags(); ok {
- _spec.SetField(employee.FieldTags, field.TypeString, value)
- _node.Tags = value
- }
- if value, ok := ec.mutation.HireCount(); ok {
- _spec.SetField(employee.FieldHireCount, field.TypeInt, value)
- _node.HireCount = value
- }
- if value, ok := ec.mutation.ServiceCount(); ok {
- _spec.SetField(employee.FieldServiceCount, field.TypeInt, value)
- _node.ServiceCount = value
- }
- if value, ok := ec.mutation.AchievementCount(); ok {
- _spec.SetField(employee.FieldAchievementCount, field.TypeInt, value)
- _node.AchievementCount = value
- }
- if value, ok := ec.mutation.Intro(); ok {
- _spec.SetField(employee.FieldIntro, field.TypeString, value)
- _node.Intro = value
- }
- if value, ok := ec.mutation.Estimate(); ok {
- _spec.SetField(employee.FieldEstimate, field.TypeString, value)
- _node.Estimate = value
- }
- if value, ok := ec.mutation.Skill(); ok {
- _spec.SetField(employee.FieldSkill, field.TypeString, value)
- _node.Skill = value
- }
- if value, ok := ec.mutation.AbilityType(); ok {
- _spec.SetField(employee.FieldAbilityType, field.TypeString, value)
- _node.AbilityType = value
- }
- if value, ok := ec.mutation.Scene(); ok {
- _spec.SetField(employee.FieldScene, field.TypeString, value)
- _node.Scene = value
- }
- if value, ok := ec.mutation.SwitchIn(); ok {
- _spec.SetField(employee.FieldSwitchIn, field.TypeString, value)
- _node.SwitchIn = value
- }
- if value, ok := ec.mutation.VideoURL(); ok {
- _spec.SetField(employee.FieldVideoURL, field.TypeString, value)
- _node.VideoURL = value
- }
- if value, ok := ec.mutation.OrganizationID(); ok {
- _spec.SetField(employee.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := ec.mutation.CategoryID(); ok {
- _spec.SetField(employee.FieldCategoryID, field.TypeUint64, value)
- _node.CategoryID = value
- }
- if value, ok := ec.mutation.APIBase(); ok {
- _spec.SetField(employee.FieldAPIBase, field.TypeString, value)
- _node.APIBase = value
- }
- if value, ok := ec.mutation.APIKey(); ok {
- _spec.SetField(employee.FieldAPIKey, field.TypeString, value)
- _node.APIKey = value
- }
- if value, ok := ec.mutation.AiInfo(); ok {
- _spec.SetField(employee.FieldAiInfo, field.TypeString, value)
- _node.AiInfo = value
- }
- if value, ok := ec.mutation.IsVip(); ok {
- _spec.SetField(employee.FieldIsVip, field.TypeInt, value)
- _node.IsVip = value
- }
- if value, ok := ec.mutation.ChatURL(); ok {
- _spec.SetField(employee.FieldChatURL, field.TypeString, value)
- _node.ChatURL = value
- }
- if nodes := ec.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 = append(_spec.Edges, edge)
- }
- if nodes := ec.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 = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Employee.Create().
- // SetCreatedAt(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.EmployeeUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ec *EmployeeCreate) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertOne {
- ec.conflict = opts
- return &EmployeeUpsertOne{
- create: ec,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ec *EmployeeCreate) OnConflictColumns(columns ...string) *EmployeeUpsertOne {
- ec.conflict = append(ec.conflict, sql.ConflictColumns(columns...))
- return &EmployeeUpsertOne{
- create: ec,
- }
- }
- type (
- // EmployeeUpsertOne is the builder for "upsert"-ing
- // one Employee node.
- EmployeeUpsertOne struct {
- create *EmployeeCreate
- }
- // EmployeeUpsert is the "OnConflict" setter.
- EmployeeUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *EmployeeUpsert) SetUpdatedAt(v time.Time) *EmployeeUpsert {
- u.Set(employee.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateUpdatedAt() *EmployeeUpsert {
- u.SetExcluded(employee.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *EmployeeUpsert) SetDeletedAt(v time.Time) *EmployeeUpsert {
- u.Set(employee.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateDeletedAt() *EmployeeUpsert {
- u.SetExcluded(employee.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *EmployeeUpsert) ClearDeletedAt() *EmployeeUpsert {
- u.SetNull(employee.FieldDeletedAt)
- return u
- }
- // SetTitle sets the "title" field.
- func (u *EmployeeUpsert) SetTitle(v string) *EmployeeUpsert {
- u.Set(employee.FieldTitle, v)
- return u
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateTitle() *EmployeeUpsert {
- u.SetExcluded(employee.FieldTitle)
- return u
- }
- // SetAvatar sets the "avatar" field.
- func (u *EmployeeUpsert) SetAvatar(v string) *EmployeeUpsert {
- u.Set(employee.FieldAvatar, v)
- return u
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAvatar() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAvatar)
- return u
- }
- // SetTags sets the "tags" field.
- func (u *EmployeeUpsert) SetTags(v string) *EmployeeUpsert {
- u.Set(employee.FieldTags, v)
- return u
- }
- // UpdateTags sets the "tags" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateTags() *EmployeeUpsert {
- u.SetExcluded(employee.FieldTags)
- return u
- }
- // SetHireCount sets the "hire_count" field.
- func (u *EmployeeUpsert) SetHireCount(v int) *EmployeeUpsert {
- u.Set(employee.FieldHireCount, v)
- return u
- }
- // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateHireCount() *EmployeeUpsert {
- u.SetExcluded(employee.FieldHireCount)
- return u
- }
- // AddHireCount adds v to the "hire_count" field.
- func (u *EmployeeUpsert) AddHireCount(v int) *EmployeeUpsert {
- u.Add(employee.FieldHireCount, v)
- return u
- }
- // SetServiceCount sets the "service_count" field.
- func (u *EmployeeUpsert) SetServiceCount(v int) *EmployeeUpsert {
- u.Set(employee.FieldServiceCount, v)
- return u
- }
- // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateServiceCount() *EmployeeUpsert {
- u.SetExcluded(employee.FieldServiceCount)
- return u
- }
- // AddServiceCount adds v to the "service_count" field.
- func (u *EmployeeUpsert) AddServiceCount(v int) *EmployeeUpsert {
- u.Add(employee.FieldServiceCount, v)
- return u
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (u *EmployeeUpsert) SetAchievementCount(v int) *EmployeeUpsert {
- u.Set(employee.FieldAchievementCount, v)
- return u
- }
- // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAchievementCount() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAchievementCount)
- return u
- }
- // AddAchievementCount adds v to the "achievement_count" field.
- func (u *EmployeeUpsert) AddAchievementCount(v int) *EmployeeUpsert {
- u.Add(employee.FieldAchievementCount, v)
- return u
- }
- // SetIntro sets the "intro" field.
- func (u *EmployeeUpsert) SetIntro(v string) *EmployeeUpsert {
- u.Set(employee.FieldIntro, v)
- return u
- }
- // UpdateIntro sets the "intro" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateIntro() *EmployeeUpsert {
- u.SetExcluded(employee.FieldIntro)
- return u
- }
- // SetEstimate sets the "estimate" field.
- func (u *EmployeeUpsert) SetEstimate(v string) *EmployeeUpsert {
- u.Set(employee.FieldEstimate, v)
- return u
- }
- // UpdateEstimate sets the "estimate" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateEstimate() *EmployeeUpsert {
- u.SetExcluded(employee.FieldEstimate)
- return u
- }
- // SetSkill sets the "skill" field.
- func (u *EmployeeUpsert) SetSkill(v string) *EmployeeUpsert {
- u.Set(employee.FieldSkill, v)
- return u
- }
- // UpdateSkill sets the "skill" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateSkill() *EmployeeUpsert {
- u.SetExcluded(employee.FieldSkill)
- return u
- }
- // SetAbilityType sets the "ability_type" field.
- func (u *EmployeeUpsert) SetAbilityType(v string) *EmployeeUpsert {
- u.Set(employee.FieldAbilityType, v)
- return u
- }
- // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAbilityType() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAbilityType)
- return u
- }
- // SetScene sets the "scene" field.
- func (u *EmployeeUpsert) SetScene(v string) *EmployeeUpsert {
- u.Set(employee.FieldScene, v)
- return u
- }
- // UpdateScene sets the "scene" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateScene() *EmployeeUpsert {
- u.SetExcluded(employee.FieldScene)
- return u
- }
- // SetSwitchIn sets the "switch_in" field.
- func (u *EmployeeUpsert) SetSwitchIn(v string) *EmployeeUpsert {
- u.Set(employee.FieldSwitchIn, v)
- return u
- }
- // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateSwitchIn() *EmployeeUpsert {
- u.SetExcluded(employee.FieldSwitchIn)
- return u
- }
- // SetVideoURL sets the "video_url" field.
- func (u *EmployeeUpsert) SetVideoURL(v string) *EmployeeUpsert {
- u.Set(employee.FieldVideoURL, v)
- return u
- }
- // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateVideoURL() *EmployeeUpsert {
- u.SetExcluded(employee.FieldVideoURL)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *EmployeeUpsert) SetOrganizationID(v uint64) *EmployeeUpsert {
- u.Set(employee.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateOrganizationID() *EmployeeUpsert {
- u.SetExcluded(employee.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *EmployeeUpsert) AddOrganizationID(v uint64) *EmployeeUpsert {
- u.Add(employee.FieldOrganizationID, v)
- return u
- }
- // SetCategoryID sets the "category_id" field.
- func (u *EmployeeUpsert) SetCategoryID(v uint64) *EmployeeUpsert {
- u.Set(employee.FieldCategoryID, v)
- return u
- }
- // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateCategoryID() *EmployeeUpsert {
- u.SetExcluded(employee.FieldCategoryID)
- return u
- }
- // AddCategoryID adds v to the "category_id" field.
- func (u *EmployeeUpsert) AddCategoryID(v uint64) *EmployeeUpsert {
- u.Add(employee.FieldCategoryID, v)
- return u
- }
- // SetAPIBase sets the "api_base" field.
- func (u *EmployeeUpsert) SetAPIBase(v string) *EmployeeUpsert {
- u.Set(employee.FieldAPIBase, v)
- return u
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAPIBase() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAPIBase)
- return u
- }
- // SetAPIKey sets the "api_key" field.
- func (u *EmployeeUpsert) SetAPIKey(v string) *EmployeeUpsert {
- u.Set(employee.FieldAPIKey, v)
- return u
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAPIKey() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAPIKey)
- return u
- }
- // SetAiInfo sets the "ai_info" field.
- func (u *EmployeeUpsert) SetAiInfo(v string) *EmployeeUpsert {
- u.Set(employee.FieldAiInfo, v)
- return u
- }
- // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateAiInfo() *EmployeeUpsert {
- u.SetExcluded(employee.FieldAiInfo)
- return u
- }
- // ClearAiInfo clears the value of the "ai_info" field.
- func (u *EmployeeUpsert) ClearAiInfo() *EmployeeUpsert {
- u.SetNull(employee.FieldAiInfo)
- return u
- }
- // SetIsVip sets the "is_vip" field.
- func (u *EmployeeUpsert) SetIsVip(v int) *EmployeeUpsert {
- u.Set(employee.FieldIsVip, v)
- return u
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateIsVip() *EmployeeUpsert {
- u.SetExcluded(employee.FieldIsVip)
- return u
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *EmployeeUpsert) AddIsVip(v int) *EmployeeUpsert {
- u.Add(employee.FieldIsVip, v)
- return u
- }
- // SetChatURL sets the "chat_url" field.
- func (u *EmployeeUpsert) SetChatURL(v string) *EmployeeUpsert {
- u.Set(employee.FieldChatURL, v)
- return u
- }
- // UpdateChatURL sets the "chat_url" field to the value that was provided on create.
- func (u *EmployeeUpsert) UpdateChatURL() *EmployeeUpsert {
- u.SetExcluded(employee.FieldChatURL)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
- // Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(employee.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *EmployeeUpsertOne) UpdateNewValues() *EmployeeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- if _, exists := u.create.mutation.ID(); exists {
- s.SetIgnore(employee.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(employee.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *EmployeeUpsertOne) Ignore() *EmployeeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *EmployeeUpsertOne) DoNothing() *EmployeeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the EmployeeCreate.OnConflict
- // documentation for more info.
- func (u *EmployeeUpsertOne) Update(set func(*EmployeeUpsert)) *EmployeeUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&EmployeeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *EmployeeUpsertOne) SetUpdatedAt(v time.Time) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateUpdatedAt() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *EmployeeUpsertOne) SetDeletedAt(v time.Time) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateDeletedAt() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *EmployeeUpsertOne) ClearDeletedAt() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTitle sets the "title" field.
- func (u *EmployeeUpsertOne) SetTitle(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetTitle(v)
- })
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateTitle() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateTitle()
- })
- }
- // SetAvatar sets the "avatar" field.
- func (u *EmployeeUpsertOne) SetAvatar(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAvatar(v)
- })
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAvatar() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAvatar()
- })
- }
- // SetTags sets the "tags" field.
- func (u *EmployeeUpsertOne) SetTags(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetTags(v)
- })
- }
- // UpdateTags sets the "tags" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateTags() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateTags()
- })
- }
- // SetHireCount sets the "hire_count" field.
- func (u *EmployeeUpsertOne) SetHireCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetHireCount(v)
- })
- }
- // AddHireCount adds v to the "hire_count" field.
- func (u *EmployeeUpsertOne) AddHireCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddHireCount(v)
- })
- }
- // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateHireCount() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateHireCount()
- })
- }
- // SetServiceCount sets the "service_count" field.
- func (u *EmployeeUpsertOne) SetServiceCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetServiceCount(v)
- })
- }
- // AddServiceCount adds v to the "service_count" field.
- func (u *EmployeeUpsertOne) AddServiceCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddServiceCount(v)
- })
- }
- // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateServiceCount() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateServiceCount()
- })
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (u *EmployeeUpsertOne) SetAchievementCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAchievementCount(v)
- })
- }
- // AddAchievementCount adds v to the "achievement_count" field.
- func (u *EmployeeUpsertOne) AddAchievementCount(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddAchievementCount(v)
- })
- }
- // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAchievementCount() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAchievementCount()
- })
- }
- // SetIntro sets the "intro" field.
- func (u *EmployeeUpsertOne) SetIntro(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetIntro(v)
- })
- }
- // UpdateIntro sets the "intro" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateIntro() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateIntro()
- })
- }
- // SetEstimate sets the "estimate" field.
- func (u *EmployeeUpsertOne) SetEstimate(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetEstimate(v)
- })
- }
- // UpdateEstimate sets the "estimate" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateEstimate() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateEstimate()
- })
- }
- // SetSkill sets the "skill" field.
- func (u *EmployeeUpsertOne) SetSkill(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetSkill(v)
- })
- }
- // UpdateSkill sets the "skill" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateSkill() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateSkill()
- })
- }
- // SetAbilityType sets the "ability_type" field.
- func (u *EmployeeUpsertOne) SetAbilityType(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAbilityType(v)
- })
- }
- // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAbilityType() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAbilityType()
- })
- }
- // SetScene sets the "scene" field.
- func (u *EmployeeUpsertOne) SetScene(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetScene(v)
- })
- }
- // UpdateScene sets the "scene" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateScene() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateScene()
- })
- }
- // SetSwitchIn sets the "switch_in" field.
- func (u *EmployeeUpsertOne) SetSwitchIn(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetSwitchIn(v)
- })
- }
- // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateSwitchIn() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateSwitchIn()
- })
- }
- // SetVideoURL sets the "video_url" field.
- func (u *EmployeeUpsertOne) SetVideoURL(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetVideoURL(v)
- })
- }
- // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateVideoURL() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateVideoURL()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *EmployeeUpsertOne) SetOrganizationID(v uint64) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *EmployeeUpsertOne) AddOrganizationID(v uint64) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateOrganizationID() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetCategoryID sets the "category_id" field.
- func (u *EmployeeUpsertOne) SetCategoryID(v uint64) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetCategoryID(v)
- })
- }
- // AddCategoryID adds v to the "category_id" field.
- func (u *EmployeeUpsertOne) AddCategoryID(v uint64) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddCategoryID(v)
- })
- }
- // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateCategoryID() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateCategoryID()
- })
- }
- // SetAPIBase sets the "api_base" field.
- func (u *EmployeeUpsertOne) SetAPIBase(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAPIBase(v)
- })
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAPIBase() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAPIBase()
- })
- }
- // SetAPIKey sets the "api_key" field.
- func (u *EmployeeUpsertOne) SetAPIKey(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAPIKey(v)
- })
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAPIKey() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAPIKey()
- })
- }
- // SetAiInfo sets the "ai_info" field.
- func (u *EmployeeUpsertOne) SetAiInfo(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAiInfo(v)
- })
- }
- // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateAiInfo() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAiInfo()
- })
- }
- // ClearAiInfo clears the value of the "ai_info" field.
- func (u *EmployeeUpsertOne) ClearAiInfo() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.ClearAiInfo()
- })
- }
- // SetIsVip sets the "is_vip" field.
- func (u *EmployeeUpsertOne) SetIsVip(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetIsVip(v)
- })
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *EmployeeUpsertOne) AddIsVip(v int) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddIsVip(v)
- })
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateIsVip() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateIsVip()
- })
- }
- // SetChatURL sets the "chat_url" field.
- func (u *EmployeeUpsertOne) SetChatURL(v string) *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetChatURL(v)
- })
- }
- // UpdateChatURL sets the "chat_url" field to the value that was provided on create.
- func (u *EmployeeUpsertOne) UpdateChatURL() *EmployeeUpsertOne {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateChatURL()
- })
- }
- // Exec executes the query.
- func (u *EmployeeUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for EmployeeCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *EmployeeUpsertOne) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // Exec executes the UPSERT query and returns the inserted/updated ID.
- func (u *EmployeeUpsertOne) ID(ctx context.Context) (id uint64, err error) {
- node, err := u.create.Save(ctx)
- if err != nil {
- return id, err
- }
- return node.ID, nil
- }
- // IDX is like ID, but panics if an error occurs.
- func (u *EmployeeUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // EmployeeCreateBulk is the builder for creating many Employee entities in bulk.
- type EmployeeCreateBulk struct {
- config
- err error
- builders []*EmployeeCreate
- conflict []sql.ConflictOption
- }
- // Save creates the Employee entities in the database.
- func (ecb *EmployeeCreateBulk) Save(ctx context.Context) ([]*Employee, error) {
- if ecb.err != nil {
- return nil, ecb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(ecb.builders))
- nodes := make([]*Employee, len(ecb.builders))
- mutators := make([]Mutator, len(ecb.builders))
- for i := range ecb.builders {
- func(i int, root context.Context) {
- builder := ecb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*EmployeeMutation)
- if !ok {
- return nil, fmt.Errorf("unexpected mutation type %T", m)
- }
- if err := builder.check(); err != nil {
- return nil, err
- }
- builder.mutation = mutation
- var err error
- nodes[i], specs[i] = builder.createSpec()
- if i < len(mutators)-1 {
- _, err = mutators[i+1].Mutate(root, ecb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = ecb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, ecb.driver, spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- }
- }
- if err != nil {
- return nil, err
- }
- mutation.id = &nodes[i].ID
- if specs[i].ID.Value != nil && nodes[i].ID == 0 {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = uint64(id)
- }
- mutation.done = true
- return nodes[i], nil
- })
- for i := len(builder.hooks) - 1; i >= 0; i-- {
- mut = builder.hooks[i](mut)
- }
- mutators[i] = mut
- }(i, ctx)
- }
- if len(mutators) > 0 {
- if _, err := mutators[0].Mutate(ctx, ecb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (ecb *EmployeeCreateBulk) SaveX(ctx context.Context) []*Employee {
- v, err := ecb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (ecb *EmployeeCreateBulk) Exec(ctx context.Context) error {
- _, err := ecb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (ecb *EmployeeCreateBulk) ExecX(ctx context.Context) {
- if err := ecb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.Employee.CreateBulk(builders...).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.EmployeeUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (ecb *EmployeeCreateBulk) OnConflict(opts ...sql.ConflictOption) *EmployeeUpsertBulk {
- ecb.conflict = opts
- return &EmployeeUpsertBulk{
- create: ecb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (ecb *EmployeeCreateBulk) OnConflictColumns(columns ...string) *EmployeeUpsertBulk {
- ecb.conflict = append(ecb.conflict, sql.ConflictColumns(columns...))
- return &EmployeeUpsertBulk{
- create: ecb,
- }
- }
- // EmployeeUpsertBulk is the builder for "upsert"-ing
- // a bulk of Employee nodes.
- type EmployeeUpsertBulk struct {
- create *EmployeeCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(employee.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *EmployeeUpsertBulk) UpdateNewValues() *EmployeeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- for _, b := range u.create.builders {
- if _, exists := b.mutation.ID(); exists {
- s.SetIgnore(employee.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(employee.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.Employee.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *EmployeeUpsertBulk) Ignore() *EmployeeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *EmployeeUpsertBulk) DoNothing() *EmployeeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the EmployeeCreateBulk.OnConflict
- // documentation for more info.
- func (u *EmployeeUpsertBulk) Update(set func(*EmployeeUpsert)) *EmployeeUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&EmployeeUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *EmployeeUpsertBulk) SetUpdatedAt(v time.Time) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateUpdatedAt() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *EmployeeUpsertBulk) SetDeletedAt(v time.Time) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateDeletedAt() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *EmployeeUpsertBulk) ClearDeletedAt() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTitle sets the "title" field.
- func (u *EmployeeUpsertBulk) SetTitle(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetTitle(v)
- })
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateTitle() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateTitle()
- })
- }
- // SetAvatar sets the "avatar" field.
- func (u *EmployeeUpsertBulk) SetAvatar(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAvatar(v)
- })
- }
- // UpdateAvatar sets the "avatar" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAvatar() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAvatar()
- })
- }
- // SetTags sets the "tags" field.
- func (u *EmployeeUpsertBulk) SetTags(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetTags(v)
- })
- }
- // UpdateTags sets the "tags" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateTags() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateTags()
- })
- }
- // SetHireCount sets the "hire_count" field.
- func (u *EmployeeUpsertBulk) SetHireCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetHireCount(v)
- })
- }
- // AddHireCount adds v to the "hire_count" field.
- func (u *EmployeeUpsertBulk) AddHireCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddHireCount(v)
- })
- }
- // UpdateHireCount sets the "hire_count" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateHireCount() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateHireCount()
- })
- }
- // SetServiceCount sets the "service_count" field.
- func (u *EmployeeUpsertBulk) SetServiceCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetServiceCount(v)
- })
- }
- // AddServiceCount adds v to the "service_count" field.
- func (u *EmployeeUpsertBulk) AddServiceCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddServiceCount(v)
- })
- }
- // UpdateServiceCount sets the "service_count" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateServiceCount() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateServiceCount()
- })
- }
- // SetAchievementCount sets the "achievement_count" field.
- func (u *EmployeeUpsertBulk) SetAchievementCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAchievementCount(v)
- })
- }
- // AddAchievementCount adds v to the "achievement_count" field.
- func (u *EmployeeUpsertBulk) AddAchievementCount(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddAchievementCount(v)
- })
- }
- // UpdateAchievementCount sets the "achievement_count" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAchievementCount() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAchievementCount()
- })
- }
- // SetIntro sets the "intro" field.
- func (u *EmployeeUpsertBulk) SetIntro(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetIntro(v)
- })
- }
- // UpdateIntro sets the "intro" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateIntro() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateIntro()
- })
- }
- // SetEstimate sets the "estimate" field.
- func (u *EmployeeUpsertBulk) SetEstimate(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetEstimate(v)
- })
- }
- // UpdateEstimate sets the "estimate" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateEstimate() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateEstimate()
- })
- }
- // SetSkill sets the "skill" field.
- func (u *EmployeeUpsertBulk) SetSkill(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetSkill(v)
- })
- }
- // UpdateSkill sets the "skill" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateSkill() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateSkill()
- })
- }
- // SetAbilityType sets the "ability_type" field.
- func (u *EmployeeUpsertBulk) SetAbilityType(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAbilityType(v)
- })
- }
- // UpdateAbilityType sets the "ability_type" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAbilityType() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAbilityType()
- })
- }
- // SetScene sets the "scene" field.
- func (u *EmployeeUpsertBulk) SetScene(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetScene(v)
- })
- }
- // UpdateScene sets the "scene" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateScene() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateScene()
- })
- }
- // SetSwitchIn sets the "switch_in" field.
- func (u *EmployeeUpsertBulk) SetSwitchIn(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetSwitchIn(v)
- })
- }
- // UpdateSwitchIn sets the "switch_in" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateSwitchIn() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateSwitchIn()
- })
- }
- // SetVideoURL sets the "video_url" field.
- func (u *EmployeeUpsertBulk) SetVideoURL(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetVideoURL(v)
- })
- }
- // UpdateVideoURL sets the "video_url" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateVideoURL() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateVideoURL()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *EmployeeUpsertBulk) SetOrganizationID(v uint64) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *EmployeeUpsertBulk) AddOrganizationID(v uint64) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateOrganizationID() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetCategoryID sets the "category_id" field.
- func (u *EmployeeUpsertBulk) SetCategoryID(v uint64) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetCategoryID(v)
- })
- }
- // AddCategoryID adds v to the "category_id" field.
- func (u *EmployeeUpsertBulk) AddCategoryID(v uint64) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddCategoryID(v)
- })
- }
- // UpdateCategoryID sets the "category_id" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateCategoryID() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateCategoryID()
- })
- }
- // SetAPIBase sets the "api_base" field.
- func (u *EmployeeUpsertBulk) SetAPIBase(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAPIBase(v)
- })
- }
- // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAPIBase() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAPIBase()
- })
- }
- // SetAPIKey sets the "api_key" field.
- func (u *EmployeeUpsertBulk) SetAPIKey(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAPIKey(v)
- })
- }
- // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAPIKey() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAPIKey()
- })
- }
- // SetAiInfo sets the "ai_info" field.
- func (u *EmployeeUpsertBulk) SetAiInfo(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetAiInfo(v)
- })
- }
- // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateAiInfo() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateAiInfo()
- })
- }
- // ClearAiInfo clears the value of the "ai_info" field.
- func (u *EmployeeUpsertBulk) ClearAiInfo() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.ClearAiInfo()
- })
- }
- // SetIsVip sets the "is_vip" field.
- func (u *EmployeeUpsertBulk) SetIsVip(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetIsVip(v)
- })
- }
- // AddIsVip adds v to the "is_vip" field.
- func (u *EmployeeUpsertBulk) AddIsVip(v int) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.AddIsVip(v)
- })
- }
- // UpdateIsVip sets the "is_vip" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateIsVip() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateIsVip()
- })
- }
- // SetChatURL sets the "chat_url" field.
- func (u *EmployeeUpsertBulk) SetChatURL(v string) *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.SetChatURL(v)
- })
- }
- // UpdateChatURL sets the "chat_url" field to the value that was provided on create.
- func (u *EmployeeUpsertBulk) UpdateChatURL() *EmployeeUpsertBulk {
- return u.Update(func(s *EmployeeUpsert) {
- s.UpdateChatURL()
- })
- }
- // Exec executes the query.
- func (u *EmployeeUpsertBulk) Exec(ctx context.Context) error {
- if u.create.err != nil {
- return u.create.err
- }
- for i, b := range u.create.builders {
- if len(b.conflict) != 0 {
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the EmployeeCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for EmployeeCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *EmployeeUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|