123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/batchmsg"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // BatchMsgCreate is the builder for creating a BatchMsg entity.
- type BatchMsgCreate struct {
- config
- mutation *BatchMsgMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (bmc *BatchMsgCreate) SetCreatedAt(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetCreatedAt(t)
- return bmc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableCreatedAt(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetCreatedAt(*t)
- }
- return bmc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (bmc *BatchMsgCreate) SetUpdatedAt(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetUpdatedAt(t)
- return bmc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableUpdatedAt(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetUpdatedAt(*t)
- }
- return bmc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (bmc *BatchMsgCreate) SetDeletedAt(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetDeletedAt(t)
- return bmc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableDeletedAt(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetDeletedAt(*t)
- }
- return bmc
- }
- // SetStatus sets the "status" field.
- func (bmc *BatchMsgCreate) SetStatus(u uint8) *BatchMsgCreate {
- bmc.mutation.SetStatus(u)
- return bmc
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableStatus(u *uint8) *BatchMsgCreate {
- if u != nil {
- bmc.SetStatus(*u)
- }
- return bmc
- }
- // SetBatchNo sets the "batch_no" field.
- func (bmc *BatchMsgCreate) SetBatchNo(s string) *BatchMsgCreate {
- bmc.mutation.SetBatchNo(s)
- return bmc
- }
- // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableBatchNo(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetBatchNo(*s)
- }
- return bmc
- }
- // SetTaskName sets the "task_name" field.
- func (bmc *BatchMsgCreate) SetTaskName(s string) *BatchMsgCreate {
- bmc.mutation.SetTaskName(s)
- return bmc
- }
- // SetNillableTaskName sets the "task_name" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTaskName(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetTaskName(*s)
- }
- return bmc
- }
- // SetFromwxid sets the "fromwxid" field.
- func (bmc *BatchMsgCreate) SetFromwxid(s string) *BatchMsgCreate {
- bmc.mutation.SetFromwxid(s)
- return bmc
- }
- // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableFromwxid(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetFromwxid(*s)
- }
- return bmc
- }
- // SetMsg sets the "msg" field.
- func (bmc *BatchMsgCreate) SetMsg(s string) *BatchMsgCreate {
- bmc.mutation.SetMsg(s)
- return bmc
- }
- // SetNillableMsg sets the "msg" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableMsg(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetMsg(*s)
- }
- return bmc
- }
- // SetTag sets the "tag" field.
- func (bmc *BatchMsgCreate) SetTag(s string) *BatchMsgCreate {
- bmc.mutation.SetTag(s)
- return bmc
- }
- // SetNillableTag sets the "tag" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTag(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetTag(*s)
- }
- return bmc
- }
- // SetTagids sets the "tagids" field.
- func (bmc *BatchMsgCreate) SetTagids(s string) *BatchMsgCreate {
- bmc.mutation.SetTagids(s)
- return bmc
- }
- // SetNillableTagids sets the "tagids" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTagids(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetTagids(*s)
- }
- return bmc
- }
- // SetTotal sets the "total" field.
- func (bmc *BatchMsgCreate) SetTotal(i int32) *BatchMsgCreate {
- bmc.mutation.SetTotal(i)
- return bmc
- }
- // SetNillableTotal sets the "total" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTotal(i *int32) *BatchMsgCreate {
- if i != nil {
- bmc.SetTotal(*i)
- }
- return bmc
- }
- // SetSuccess sets the "success" field.
- func (bmc *BatchMsgCreate) SetSuccess(i int32) *BatchMsgCreate {
- bmc.mutation.SetSuccess(i)
- return bmc
- }
- // SetNillableSuccess sets the "success" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableSuccess(i *int32) *BatchMsgCreate {
- if i != nil {
- bmc.SetSuccess(*i)
- }
- return bmc
- }
- // SetFail sets the "fail" field.
- func (bmc *BatchMsgCreate) SetFail(i int32) *BatchMsgCreate {
- bmc.mutation.SetFail(i)
- return bmc
- }
- // SetNillableFail sets the "fail" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableFail(i *int32) *BatchMsgCreate {
- if i != nil {
- bmc.SetFail(*i)
- }
- return bmc
- }
- // SetStartTime sets the "start_time" field.
- func (bmc *BatchMsgCreate) SetStartTime(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetStartTime(t)
- return bmc
- }
- // SetNillableStartTime sets the "start_time" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableStartTime(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetStartTime(*t)
- }
- return bmc
- }
- // SetStopTime sets the "stop_time" field.
- func (bmc *BatchMsgCreate) SetStopTime(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetStopTime(t)
- return bmc
- }
- // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableStopTime(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetStopTime(*t)
- }
- return bmc
- }
- // SetSendTime sets the "send_time" field.
- func (bmc *BatchMsgCreate) SetSendTime(t time.Time) *BatchMsgCreate {
- bmc.mutation.SetSendTime(t)
- return bmc
- }
- // SetNillableSendTime sets the "send_time" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableSendTime(t *time.Time) *BatchMsgCreate {
- if t != nil {
- bmc.SetSendTime(*t)
- }
- return bmc
- }
- // SetType sets the "type" field.
- func (bmc *BatchMsgCreate) SetType(i int32) *BatchMsgCreate {
- bmc.mutation.SetType(i)
- return bmc
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableType(i *int32) *BatchMsgCreate {
- if i != nil {
- bmc.SetType(*i)
- }
- return bmc
- }
- // SetOrganizationID sets the "organization_id" field.
- func (bmc *BatchMsgCreate) SetOrganizationID(u uint64) *BatchMsgCreate {
- bmc.mutation.SetOrganizationID(u)
- return bmc
- }
- // SetCtype sets the "ctype" field.
- func (bmc *BatchMsgCreate) SetCtype(u uint64) *BatchMsgCreate {
- bmc.mutation.SetCtype(u)
- return bmc
- }
- // SetNillableCtype sets the "ctype" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableCtype(u *uint64) *BatchMsgCreate {
- if u != nil {
- bmc.SetCtype(*u)
- }
- return bmc
- }
- // SetCc sets the "cc" field.
- func (bmc *BatchMsgCreate) SetCc(s string) *BatchMsgCreate {
- bmc.mutation.SetCc(s)
- return bmc
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableCc(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetCc(*s)
- }
- return bmc
- }
- // SetPhone sets the "phone" field.
- func (bmc *BatchMsgCreate) SetPhone(s string) *BatchMsgCreate {
- bmc.mutation.SetPhone(s)
- return bmc
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillablePhone(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetPhone(*s)
- }
- return bmc
- }
- // SetTemplateName sets the "template_name" field.
- func (bmc *BatchMsgCreate) SetTemplateName(s string) *BatchMsgCreate {
- bmc.mutation.SetTemplateName(s)
- return bmc
- }
- // SetNillableTemplateName sets the "template_name" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTemplateName(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetTemplateName(*s)
- }
- return bmc
- }
- // SetTemplateCode sets the "template_code" field.
- func (bmc *BatchMsgCreate) SetTemplateCode(s string) *BatchMsgCreate {
- bmc.mutation.SetTemplateCode(s)
- return bmc
- }
- // SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableTemplateCode(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetTemplateCode(*s)
- }
- return bmc
- }
- // SetLang sets the "lang" field.
- func (bmc *BatchMsgCreate) SetLang(s string) *BatchMsgCreate {
- bmc.mutation.SetLang(s)
- return bmc
- }
- // SetNillableLang sets the "lang" field if the given value is not nil.
- func (bmc *BatchMsgCreate) SetNillableLang(s *string) *BatchMsgCreate {
- if s != nil {
- bmc.SetLang(*s)
- }
- return bmc
- }
- // SetID sets the "id" field.
- func (bmc *BatchMsgCreate) SetID(u uint64) *BatchMsgCreate {
- bmc.mutation.SetID(u)
- return bmc
- }
- // Mutation returns the BatchMsgMutation object of the builder.
- func (bmc *BatchMsgCreate) Mutation() *BatchMsgMutation {
- return bmc.mutation
- }
- // Save creates the BatchMsg in the database.
- func (bmc *BatchMsgCreate) Save(ctx context.Context) (*BatchMsg, error) {
- if err := bmc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, bmc.sqlSave, bmc.mutation, bmc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (bmc *BatchMsgCreate) SaveX(ctx context.Context) *BatchMsg {
- v, err := bmc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (bmc *BatchMsgCreate) Exec(ctx context.Context) error {
- _, err := bmc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (bmc *BatchMsgCreate) ExecX(ctx context.Context) {
- if err := bmc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (bmc *BatchMsgCreate) defaults() error {
- if _, ok := bmc.mutation.CreatedAt(); !ok {
- if batchmsg.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized batchmsg.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := batchmsg.DefaultCreatedAt()
- bmc.mutation.SetCreatedAt(v)
- }
- if _, ok := bmc.mutation.UpdatedAt(); !ok {
- if batchmsg.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized batchmsg.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := batchmsg.DefaultUpdatedAt()
- bmc.mutation.SetUpdatedAt(v)
- }
- if _, ok := bmc.mutation.TaskName(); !ok {
- v := batchmsg.DefaultTaskName
- bmc.mutation.SetTaskName(v)
- }
- if _, ok := bmc.mutation.Ctype(); !ok {
- v := batchmsg.DefaultCtype
- bmc.mutation.SetCtype(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (bmc *BatchMsgCreate) check() error {
- if _, ok := bmc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "BatchMsg.created_at"`)}
- }
- if _, ok := bmc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "BatchMsg.updated_at"`)}
- }
- if _, ok := bmc.mutation.OrganizationID(); !ok {
- return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "BatchMsg.organization_id"`)}
- }
- if v, ok := bmc.mutation.OrganizationID(); ok {
- if err := batchmsg.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
- }
- }
- if _, ok := bmc.mutation.Ctype(); !ok {
- return &ValidationError{Name: "ctype", err: errors.New(`ent: missing required field "BatchMsg.ctype"`)}
- }
- return nil
- }
- func (bmc *BatchMsgCreate) sqlSave(ctx context.Context) (*BatchMsg, error) {
- if err := bmc.check(); err != nil {
- return nil, err
- }
- _node, _spec := bmc.createSpec()
- if err := sqlgraph.CreateNode(ctx, bmc.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)
- }
- bmc.mutation.id = &_node.ID
- bmc.mutation.done = true
- return _node, nil
- }
- func (bmc *BatchMsgCreate) createSpec() (*BatchMsg, *sqlgraph.CreateSpec) {
- var (
- _node = &BatchMsg{config: bmc.config}
- _spec = sqlgraph.NewCreateSpec(batchmsg.Table, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = bmc.conflict
- if id, ok := bmc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := bmc.mutation.CreatedAt(); ok {
- _spec.SetField(batchmsg.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := bmc.mutation.UpdatedAt(); ok {
- _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := bmc.mutation.DeletedAt(); ok {
- _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := bmc.mutation.Status(); ok {
- _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
- _node.Status = value
- }
- if value, ok := bmc.mutation.BatchNo(); ok {
- _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
- _node.BatchNo = value
- }
- if value, ok := bmc.mutation.TaskName(); ok {
- _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
- _node.TaskName = value
- }
- if value, ok := bmc.mutation.Fromwxid(); ok {
- _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
- _node.Fromwxid = value
- }
- if value, ok := bmc.mutation.Msg(); ok {
- _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
- _node.Msg = value
- }
- if value, ok := bmc.mutation.Tag(); ok {
- _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
- _node.Tag = value
- }
- if value, ok := bmc.mutation.Tagids(); ok {
- _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
- _node.Tagids = value
- }
- if value, ok := bmc.mutation.Total(); ok {
- _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
- _node.Total = value
- }
- if value, ok := bmc.mutation.Success(); ok {
- _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
- _node.Success = value
- }
- if value, ok := bmc.mutation.Fail(); ok {
- _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
- _node.Fail = value
- }
- if value, ok := bmc.mutation.StartTime(); ok {
- _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
- _node.StartTime = value
- }
- if value, ok := bmc.mutation.StopTime(); ok {
- _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
- _node.StopTime = value
- }
- if value, ok := bmc.mutation.SendTime(); ok {
- _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
- _node.SendTime = value
- }
- if value, ok := bmc.mutation.GetType(); ok {
- _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
- _node.Type = value
- }
- if value, ok := bmc.mutation.OrganizationID(); ok {
- _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := bmc.mutation.Ctype(); ok {
- _spec.SetField(batchmsg.FieldCtype, field.TypeUint64, value)
- _node.Ctype = value
- }
- if value, ok := bmc.mutation.Cc(); ok {
- _spec.SetField(batchmsg.FieldCc, field.TypeString, value)
- _node.Cc = value
- }
- if value, ok := bmc.mutation.Phone(); ok {
- _spec.SetField(batchmsg.FieldPhone, field.TypeString, value)
- _node.Phone = value
- }
- if value, ok := bmc.mutation.TemplateName(); ok {
- _spec.SetField(batchmsg.FieldTemplateName, field.TypeString, value)
- _node.TemplateName = value
- }
- if value, ok := bmc.mutation.TemplateCode(); ok {
- _spec.SetField(batchmsg.FieldTemplateCode, field.TypeString, value)
- _node.TemplateCode = value
- }
- if value, ok := bmc.mutation.Lang(); ok {
- _spec.SetField(batchmsg.FieldLang, field.TypeString, value)
- _node.Lang = value
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.BatchMsg.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.BatchMsgUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (bmc *BatchMsgCreate) OnConflict(opts ...sql.ConflictOption) *BatchMsgUpsertOne {
- bmc.conflict = opts
- return &BatchMsgUpsertOne{
- create: bmc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.BatchMsg.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (bmc *BatchMsgCreate) OnConflictColumns(columns ...string) *BatchMsgUpsertOne {
- bmc.conflict = append(bmc.conflict, sql.ConflictColumns(columns...))
- return &BatchMsgUpsertOne{
- create: bmc,
- }
- }
- type (
- // BatchMsgUpsertOne is the builder for "upsert"-ing
- // one BatchMsg node.
- BatchMsgUpsertOne struct {
- create *BatchMsgCreate
- }
- // BatchMsgUpsert is the "OnConflict" setter.
- BatchMsgUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *BatchMsgUpsert) SetUpdatedAt(v time.Time) *BatchMsgUpsert {
- u.Set(batchmsg.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateUpdatedAt() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *BatchMsgUpsert) SetDeletedAt(v time.Time) *BatchMsgUpsert {
- u.Set(batchmsg.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateDeletedAt() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *BatchMsgUpsert) ClearDeletedAt() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldDeletedAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *BatchMsgUpsert) SetStatus(v uint8) *BatchMsgUpsert {
- u.Set(batchmsg.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateStatus() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldStatus)
- return u
- }
- // AddStatus adds v to the "status" field.
- func (u *BatchMsgUpsert) AddStatus(v uint8) *BatchMsgUpsert {
- u.Add(batchmsg.FieldStatus, v)
- return u
- }
- // ClearStatus clears the value of the "status" field.
- func (u *BatchMsgUpsert) ClearStatus() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldStatus)
- return u
- }
- // SetBatchNo sets the "batch_no" field.
- func (u *BatchMsgUpsert) SetBatchNo(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldBatchNo, v)
- return u
- }
- // UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateBatchNo() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldBatchNo)
- return u
- }
- // ClearBatchNo clears the value of the "batch_no" field.
- func (u *BatchMsgUpsert) ClearBatchNo() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldBatchNo)
- return u
- }
- // SetTaskName sets the "task_name" field.
- func (u *BatchMsgUpsert) SetTaskName(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTaskName, v)
- return u
- }
- // UpdateTaskName sets the "task_name" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTaskName() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTaskName)
- return u
- }
- // ClearTaskName clears the value of the "task_name" field.
- func (u *BatchMsgUpsert) ClearTaskName() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTaskName)
- return u
- }
- // SetFromwxid sets the "fromwxid" field.
- func (u *BatchMsgUpsert) SetFromwxid(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldFromwxid, v)
- return u
- }
- // UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateFromwxid() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldFromwxid)
- return u
- }
- // ClearFromwxid clears the value of the "fromwxid" field.
- func (u *BatchMsgUpsert) ClearFromwxid() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldFromwxid)
- return u
- }
- // SetMsg sets the "msg" field.
- func (u *BatchMsgUpsert) SetMsg(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldMsg, v)
- return u
- }
- // UpdateMsg sets the "msg" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateMsg() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldMsg)
- return u
- }
- // ClearMsg clears the value of the "msg" field.
- func (u *BatchMsgUpsert) ClearMsg() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldMsg)
- return u
- }
- // SetTag sets the "tag" field.
- func (u *BatchMsgUpsert) SetTag(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTag, v)
- return u
- }
- // UpdateTag sets the "tag" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTag() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTag)
- return u
- }
- // ClearTag clears the value of the "tag" field.
- func (u *BatchMsgUpsert) ClearTag() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTag)
- return u
- }
- // SetTagids sets the "tagids" field.
- func (u *BatchMsgUpsert) SetTagids(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTagids, v)
- return u
- }
- // UpdateTagids sets the "tagids" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTagids() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTagids)
- return u
- }
- // ClearTagids clears the value of the "tagids" field.
- func (u *BatchMsgUpsert) ClearTagids() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTagids)
- return u
- }
- // SetTotal sets the "total" field.
- func (u *BatchMsgUpsert) SetTotal(v int32) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTotal, v)
- return u
- }
- // UpdateTotal sets the "total" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTotal() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTotal)
- return u
- }
- // AddTotal adds v to the "total" field.
- func (u *BatchMsgUpsert) AddTotal(v int32) *BatchMsgUpsert {
- u.Add(batchmsg.FieldTotal, v)
- return u
- }
- // ClearTotal clears the value of the "total" field.
- func (u *BatchMsgUpsert) ClearTotal() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTotal)
- return u
- }
- // SetSuccess sets the "success" field.
- func (u *BatchMsgUpsert) SetSuccess(v int32) *BatchMsgUpsert {
- u.Set(batchmsg.FieldSuccess, v)
- return u
- }
- // UpdateSuccess sets the "success" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateSuccess() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldSuccess)
- return u
- }
- // AddSuccess adds v to the "success" field.
- func (u *BatchMsgUpsert) AddSuccess(v int32) *BatchMsgUpsert {
- u.Add(batchmsg.FieldSuccess, v)
- return u
- }
- // ClearSuccess clears the value of the "success" field.
- func (u *BatchMsgUpsert) ClearSuccess() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldSuccess)
- return u
- }
- // SetFail sets the "fail" field.
- func (u *BatchMsgUpsert) SetFail(v int32) *BatchMsgUpsert {
- u.Set(batchmsg.FieldFail, v)
- return u
- }
- // UpdateFail sets the "fail" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateFail() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldFail)
- return u
- }
- // AddFail adds v to the "fail" field.
- func (u *BatchMsgUpsert) AddFail(v int32) *BatchMsgUpsert {
- u.Add(batchmsg.FieldFail, v)
- return u
- }
- // ClearFail clears the value of the "fail" field.
- func (u *BatchMsgUpsert) ClearFail() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldFail)
- return u
- }
- // SetStartTime sets the "start_time" field.
- func (u *BatchMsgUpsert) SetStartTime(v time.Time) *BatchMsgUpsert {
- u.Set(batchmsg.FieldStartTime, v)
- return u
- }
- // UpdateStartTime sets the "start_time" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateStartTime() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldStartTime)
- return u
- }
- // ClearStartTime clears the value of the "start_time" field.
- func (u *BatchMsgUpsert) ClearStartTime() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldStartTime)
- return u
- }
- // SetStopTime sets the "stop_time" field.
- func (u *BatchMsgUpsert) SetStopTime(v time.Time) *BatchMsgUpsert {
- u.Set(batchmsg.FieldStopTime, v)
- return u
- }
- // UpdateStopTime sets the "stop_time" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateStopTime() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldStopTime)
- return u
- }
- // ClearStopTime clears the value of the "stop_time" field.
- func (u *BatchMsgUpsert) ClearStopTime() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldStopTime)
- return u
- }
- // SetSendTime sets the "send_time" field.
- func (u *BatchMsgUpsert) SetSendTime(v time.Time) *BatchMsgUpsert {
- u.Set(batchmsg.FieldSendTime, v)
- return u
- }
- // UpdateSendTime sets the "send_time" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateSendTime() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldSendTime)
- return u
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (u *BatchMsgUpsert) ClearSendTime() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldSendTime)
- return u
- }
- // SetType sets the "type" field.
- func (u *BatchMsgUpsert) SetType(v int32) *BatchMsgUpsert {
- u.Set(batchmsg.FieldType, v)
- return u
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateType() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldType)
- return u
- }
- // AddType adds v to the "type" field.
- func (u *BatchMsgUpsert) AddType(v int32) *BatchMsgUpsert {
- u.Add(batchmsg.FieldType, v)
- return u
- }
- // ClearType clears the value of the "type" field.
- func (u *BatchMsgUpsert) ClearType() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldType)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *BatchMsgUpsert) SetOrganizationID(v uint64) *BatchMsgUpsert {
- u.Set(batchmsg.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateOrganizationID() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *BatchMsgUpsert) AddOrganizationID(v uint64) *BatchMsgUpsert {
- u.Add(batchmsg.FieldOrganizationID, v)
- return u
- }
- // SetCtype sets the "ctype" field.
- func (u *BatchMsgUpsert) SetCtype(v uint64) *BatchMsgUpsert {
- u.Set(batchmsg.FieldCtype, v)
- return u
- }
- // UpdateCtype sets the "ctype" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateCtype() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldCtype)
- return u
- }
- // AddCtype adds v to the "ctype" field.
- func (u *BatchMsgUpsert) AddCtype(v uint64) *BatchMsgUpsert {
- u.Add(batchmsg.FieldCtype, v)
- return u
- }
- // SetCc sets the "cc" field.
- func (u *BatchMsgUpsert) SetCc(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldCc, v)
- return u
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateCc() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldCc)
- return u
- }
- // ClearCc clears the value of the "cc" field.
- func (u *BatchMsgUpsert) ClearCc() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldCc)
- return u
- }
- // SetPhone sets the "phone" field.
- func (u *BatchMsgUpsert) SetPhone(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldPhone, v)
- return u
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdatePhone() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldPhone)
- return u
- }
- // ClearPhone clears the value of the "phone" field.
- func (u *BatchMsgUpsert) ClearPhone() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldPhone)
- return u
- }
- // SetTemplateName sets the "template_name" field.
- func (u *BatchMsgUpsert) SetTemplateName(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTemplateName, v)
- return u
- }
- // UpdateTemplateName sets the "template_name" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTemplateName() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTemplateName)
- return u
- }
- // ClearTemplateName clears the value of the "template_name" field.
- func (u *BatchMsgUpsert) ClearTemplateName() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTemplateName)
- return u
- }
- // SetTemplateCode sets the "template_code" field.
- func (u *BatchMsgUpsert) SetTemplateCode(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldTemplateCode, v)
- return u
- }
- // UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateTemplateCode() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldTemplateCode)
- return u
- }
- // ClearTemplateCode clears the value of the "template_code" field.
- func (u *BatchMsgUpsert) ClearTemplateCode() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldTemplateCode)
- return u
- }
- // SetLang sets the "lang" field.
- func (u *BatchMsgUpsert) SetLang(v string) *BatchMsgUpsert {
- u.Set(batchmsg.FieldLang, v)
- return u
- }
- // UpdateLang sets the "lang" field to the value that was provided on create.
- func (u *BatchMsgUpsert) UpdateLang() *BatchMsgUpsert {
- u.SetExcluded(batchmsg.FieldLang)
- return u
- }
- // ClearLang clears the value of the "lang" field.
- func (u *BatchMsgUpsert) ClearLang() *BatchMsgUpsert {
- u.SetNull(batchmsg.FieldLang)
- 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.BatchMsg.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(batchmsg.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *BatchMsgUpsertOne) UpdateNewValues() *BatchMsgUpsertOne {
- 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(batchmsg.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(batchmsg.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.BatchMsg.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *BatchMsgUpsertOne) Ignore() *BatchMsgUpsertOne {
- 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 *BatchMsgUpsertOne) DoNothing() *BatchMsgUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the BatchMsgCreate.OnConflict
- // documentation for more info.
- func (u *BatchMsgUpsertOne) Update(set func(*BatchMsgUpsert)) *BatchMsgUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&BatchMsgUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *BatchMsgUpsertOne) SetUpdatedAt(v time.Time) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateUpdatedAt() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *BatchMsgUpsertOne) SetDeletedAt(v time.Time) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateDeletedAt() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *BatchMsgUpsertOne) ClearDeletedAt() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *BatchMsgUpsertOne) SetStatus(v uint8) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *BatchMsgUpsertOne) AddStatus(v uint8) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateStatus() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *BatchMsgUpsertOne) ClearStatus() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStatus()
- })
- }
- // SetBatchNo sets the "batch_no" field.
- func (u *BatchMsgUpsertOne) SetBatchNo(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetBatchNo(v)
- })
- }
- // UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateBatchNo() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateBatchNo()
- })
- }
- // ClearBatchNo clears the value of the "batch_no" field.
- func (u *BatchMsgUpsertOne) ClearBatchNo() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearBatchNo()
- })
- }
- // SetTaskName sets the "task_name" field.
- func (u *BatchMsgUpsertOne) SetTaskName(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTaskName(v)
- })
- }
- // UpdateTaskName sets the "task_name" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTaskName() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTaskName()
- })
- }
- // ClearTaskName clears the value of the "task_name" field.
- func (u *BatchMsgUpsertOne) ClearTaskName() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTaskName()
- })
- }
- // SetFromwxid sets the "fromwxid" field.
- func (u *BatchMsgUpsertOne) SetFromwxid(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetFromwxid(v)
- })
- }
- // UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateFromwxid() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateFromwxid()
- })
- }
- // ClearFromwxid clears the value of the "fromwxid" field.
- func (u *BatchMsgUpsertOne) ClearFromwxid() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearFromwxid()
- })
- }
- // SetMsg sets the "msg" field.
- func (u *BatchMsgUpsertOne) SetMsg(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetMsg(v)
- })
- }
- // UpdateMsg sets the "msg" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateMsg() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateMsg()
- })
- }
- // ClearMsg clears the value of the "msg" field.
- func (u *BatchMsgUpsertOne) ClearMsg() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearMsg()
- })
- }
- // SetTag sets the "tag" field.
- func (u *BatchMsgUpsertOne) SetTag(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTag(v)
- })
- }
- // UpdateTag sets the "tag" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTag() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTag()
- })
- }
- // ClearTag clears the value of the "tag" field.
- func (u *BatchMsgUpsertOne) ClearTag() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTag()
- })
- }
- // SetTagids sets the "tagids" field.
- func (u *BatchMsgUpsertOne) SetTagids(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTagids(v)
- })
- }
- // UpdateTagids sets the "tagids" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTagids() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTagids()
- })
- }
- // ClearTagids clears the value of the "tagids" field.
- func (u *BatchMsgUpsertOne) ClearTagids() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTagids()
- })
- }
- // SetTotal sets the "total" field.
- func (u *BatchMsgUpsertOne) SetTotal(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTotal(v)
- })
- }
- // AddTotal adds v to the "total" field.
- func (u *BatchMsgUpsertOne) AddTotal(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddTotal(v)
- })
- }
- // UpdateTotal sets the "total" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTotal() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTotal()
- })
- }
- // ClearTotal clears the value of the "total" field.
- func (u *BatchMsgUpsertOne) ClearTotal() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTotal()
- })
- }
- // SetSuccess sets the "success" field.
- func (u *BatchMsgUpsertOne) SetSuccess(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetSuccess(v)
- })
- }
- // AddSuccess adds v to the "success" field.
- func (u *BatchMsgUpsertOne) AddSuccess(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddSuccess(v)
- })
- }
- // UpdateSuccess sets the "success" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateSuccess() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateSuccess()
- })
- }
- // ClearSuccess clears the value of the "success" field.
- func (u *BatchMsgUpsertOne) ClearSuccess() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearSuccess()
- })
- }
- // SetFail sets the "fail" field.
- func (u *BatchMsgUpsertOne) SetFail(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetFail(v)
- })
- }
- // AddFail adds v to the "fail" field.
- func (u *BatchMsgUpsertOne) AddFail(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddFail(v)
- })
- }
- // UpdateFail sets the "fail" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateFail() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateFail()
- })
- }
- // ClearFail clears the value of the "fail" field.
- func (u *BatchMsgUpsertOne) ClearFail() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearFail()
- })
- }
- // SetStartTime sets the "start_time" field.
- func (u *BatchMsgUpsertOne) SetStartTime(v time.Time) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStartTime(v)
- })
- }
- // UpdateStartTime sets the "start_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateStartTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStartTime()
- })
- }
- // ClearStartTime clears the value of the "start_time" field.
- func (u *BatchMsgUpsertOne) ClearStartTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStartTime()
- })
- }
- // SetStopTime sets the "stop_time" field.
- func (u *BatchMsgUpsertOne) SetStopTime(v time.Time) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStopTime(v)
- })
- }
- // UpdateStopTime sets the "stop_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateStopTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStopTime()
- })
- }
- // ClearStopTime clears the value of the "stop_time" field.
- func (u *BatchMsgUpsertOne) ClearStopTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStopTime()
- })
- }
- // SetSendTime sets the "send_time" field.
- func (u *BatchMsgUpsertOne) SetSendTime(v time.Time) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetSendTime(v)
- })
- }
- // UpdateSendTime sets the "send_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateSendTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateSendTime()
- })
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (u *BatchMsgUpsertOne) ClearSendTime() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearSendTime()
- })
- }
- // SetType sets the "type" field.
- func (u *BatchMsgUpsertOne) SetType(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *BatchMsgUpsertOne) AddType(v int32) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateType() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateType()
- })
- }
- // ClearType clears the value of the "type" field.
- func (u *BatchMsgUpsertOne) ClearType() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearType()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *BatchMsgUpsertOne) SetOrganizationID(v uint64) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *BatchMsgUpsertOne) AddOrganizationID(v uint64) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateOrganizationID() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetCtype sets the "ctype" field.
- func (u *BatchMsgUpsertOne) SetCtype(v uint64) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetCtype(v)
- })
- }
- // AddCtype adds v to the "ctype" field.
- func (u *BatchMsgUpsertOne) AddCtype(v uint64) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddCtype(v)
- })
- }
- // UpdateCtype sets the "ctype" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateCtype() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateCtype()
- })
- }
- // SetCc sets the "cc" field.
- func (u *BatchMsgUpsertOne) SetCc(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetCc(v)
- })
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateCc() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateCc()
- })
- }
- // ClearCc clears the value of the "cc" field.
- func (u *BatchMsgUpsertOne) ClearCc() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearCc()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *BatchMsgUpsertOne) SetPhone(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdatePhone() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdatePhone()
- })
- }
- // ClearPhone clears the value of the "phone" field.
- func (u *BatchMsgUpsertOne) ClearPhone() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearPhone()
- })
- }
- // SetTemplateName sets the "template_name" field.
- func (u *BatchMsgUpsertOne) SetTemplateName(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTemplateName(v)
- })
- }
- // UpdateTemplateName sets the "template_name" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTemplateName() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTemplateName()
- })
- }
- // ClearTemplateName clears the value of the "template_name" field.
- func (u *BatchMsgUpsertOne) ClearTemplateName() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTemplateName()
- })
- }
- // SetTemplateCode sets the "template_code" field.
- func (u *BatchMsgUpsertOne) SetTemplateCode(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTemplateCode(v)
- })
- }
- // UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateTemplateCode() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTemplateCode()
- })
- }
- // ClearTemplateCode clears the value of the "template_code" field.
- func (u *BatchMsgUpsertOne) ClearTemplateCode() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTemplateCode()
- })
- }
- // SetLang sets the "lang" field.
- func (u *BatchMsgUpsertOne) SetLang(v string) *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetLang(v)
- })
- }
- // UpdateLang sets the "lang" field to the value that was provided on create.
- func (u *BatchMsgUpsertOne) UpdateLang() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateLang()
- })
- }
- // ClearLang clears the value of the "lang" field.
- func (u *BatchMsgUpsertOne) ClearLang() *BatchMsgUpsertOne {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearLang()
- })
- }
- // Exec executes the query.
- func (u *BatchMsgUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for BatchMsgCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *BatchMsgUpsertOne) 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 *BatchMsgUpsertOne) 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 *BatchMsgUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // BatchMsgCreateBulk is the builder for creating many BatchMsg entities in bulk.
- type BatchMsgCreateBulk struct {
- config
- err error
- builders []*BatchMsgCreate
- conflict []sql.ConflictOption
- }
- // Save creates the BatchMsg entities in the database.
- func (bmcb *BatchMsgCreateBulk) Save(ctx context.Context) ([]*BatchMsg, error) {
- if bmcb.err != nil {
- return nil, bmcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(bmcb.builders))
- nodes := make([]*BatchMsg, len(bmcb.builders))
- mutators := make([]Mutator, len(bmcb.builders))
- for i := range bmcb.builders {
- func(i int, root context.Context) {
- builder := bmcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*BatchMsgMutation)
- 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, bmcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = bmcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, bmcb.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, bmcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (bmcb *BatchMsgCreateBulk) SaveX(ctx context.Context) []*BatchMsg {
- v, err := bmcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (bmcb *BatchMsgCreateBulk) Exec(ctx context.Context) error {
- _, err := bmcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (bmcb *BatchMsgCreateBulk) ExecX(ctx context.Context) {
- if err := bmcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.BatchMsg.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.BatchMsgUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (bmcb *BatchMsgCreateBulk) OnConflict(opts ...sql.ConflictOption) *BatchMsgUpsertBulk {
- bmcb.conflict = opts
- return &BatchMsgUpsertBulk{
- create: bmcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.BatchMsg.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (bmcb *BatchMsgCreateBulk) OnConflictColumns(columns ...string) *BatchMsgUpsertBulk {
- bmcb.conflict = append(bmcb.conflict, sql.ConflictColumns(columns...))
- return &BatchMsgUpsertBulk{
- create: bmcb,
- }
- }
- // BatchMsgUpsertBulk is the builder for "upsert"-ing
- // a bulk of BatchMsg nodes.
- type BatchMsgUpsertBulk struct {
- create *BatchMsgCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.BatchMsg.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(batchmsg.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *BatchMsgUpsertBulk) UpdateNewValues() *BatchMsgUpsertBulk {
- 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(batchmsg.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(batchmsg.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.BatchMsg.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *BatchMsgUpsertBulk) Ignore() *BatchMsgUpsertBulk {
- 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 *BatchMsgUpsertBulk) DoNothing() *BatchMsgUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the BatchMsgCreateBulk.OnConflict
- // documentation for more info.
- func (u *BatchMsgUpsertBulk) Update(set func(*BatchMsgUpsert)) *BatchMsgUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&BatchMsgUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *BatchMsgUpsertBulk) SetUpdatedAt(v time.Time) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateUpdatedAt() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *BatchMsgUpsertBulk) SetDeletedAt(v time.Time) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateDeletedAt() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *BatchMsgUpsertBulk) ClearDeletedAt() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *BatchMsgUpsertBulk) SetStatus(v uint8) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStatus(v)
- })
- }
- // AddStatus adds v to the "status" field.
- func (u *BatchMsgUpsertBulk) AddStatus(v uint8) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateStatus() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStatus()
- })
- }
- // ClearStatus clears the value of the "status" field.
- func (u *BatchMsgUpsertBulk) ClearStatus() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStatus()
- })
- }
- // SetBatchNo sets the "batch_no" field.
- func (u *BatchMsgUpsertBulk) SetBatchNo(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetBatchNo(v)
- })
- }
- // UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateBatchNo() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateBatchNo()
- })
- }
- // ClearBatchNo clears the value of the "batch_no" field.
- func (u *BatchMsgUpsertBulk) ClearBatchNo() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearBatchNo()
- })
- }
- // SetTaskName sets the "task_name" field.
- func (u *BatchMsgUpsertBulk) SetTaskName(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTaskName(v)
- })
- }
- // UpdateTaskName sets the "task_name" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTaskName() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTaskName()
- })
- }
- // ClearTaskName clears the value of the "task_name" field.
- func (u *BatchMsgUpsertBulk) ClearTaskName() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTaskName()
- })
- }
- // SetFromwxid sets the "fromwxid" field.
- func (u *BatchMsgUpsertBulk) SetFromwxid(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetFromwxid(v)
- })
- }
- // UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateFromwxid() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateFromwxid()
- })
- }
- // ClearFromwxid clears the value of the "fromwxid" field.
- func (u *BatchMsgUpsertBulk) ClearFromwxid() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearFromwxid()
- })
- }
- // SetMsg sets the "msg" field.
- func (u *BatchMsgUpsertBulk) SetMsg(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetMsg(v)
- })
- }
- // UpdateMsg sets the "msg" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateMsg() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateMsg()
- })
- }
- // ClearMsg clears the value of the "msg" field.
- func (u *BatchMsgUpsertBulk) ClearMsg() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearMsg()
- })
- }
- // SetTag sets the "tag" field.
- func (u *BatchMsgUpsertBulk) SetTag(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTag(v)
- })
- }
- // UpdateTag sets the "tag" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTag() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTag()
- })
- }
- // ClearTag clears the value of the "tag" field.
- func (u *BatchMsgUpsertBulk) ClearTag() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTag()
- })
- }
- // SetTagids sets the "tagids" field.
- func (u *BatchMsgUpsertBulk) SetTagids(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTagids(v)
- })
- }
- // UpdateTagids sets the "tagids" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTagids() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTagids()
- })
- }
- // ClearTagids clears the value of the "tagids" field.
- func (u *BatchMsgUpsertBulk) ClearTagids() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTagids()
- })
- }
- // SetTotal sets the "total" field.
- func (u *BatchMsgUpsertBulk) SetTotal(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTotal(v)
- })
- }
- // AddTotal adds v to the "total" field.
- func (u *BatchMsgUpsertBulk) AddTotal(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddTotal(v)
- })
- }
- // UpdateTotal sets the "total" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTotal() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTotal()
- })
- }
- // ClearTotal clears the value of the "total" field.
- func (u *BatchMsgUpsertBulk) ClearTotal() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTotal()
- })
- }
- // SetSuccess sets the "success" field.
- func (u *BatchMsgUpsertBulk) SetSuccess(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetSuccess(v)
- })
- }
- // AddSuccess adds v to the "success" field.
- func (u *BatchMsgUpsertBulk) AddSuccess(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddSuccess(v)
- })
- }
- // UpdateSuccess sets the "success" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateSuccess() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateSuccess()
- })
- }
- // ClearSuccess clears the value of the "success" field.
- func (u *BatchMsgUpsertBulk) ClearSuccess() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearSuccess()
- })
- }
- // SetFail sets the "fail" field.
- func (u *BatchMsgUpsertBulk) SetFail(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetFail(v)
- })
- }
- // AddFail adds v to the "fail" field.
- func (u *BatchMsgUpsertBulk) AddFail(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddFail(v)
- })
- }
- // UpdateFail sets the "fail" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateFail() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateFail()
- })
- }
- // ClearFail clears the value of the "fail" field.
- func (u *BatchMsgUpsertBulk) ClearFail() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearFail()
- })
- }
- // SetStartTime sets the "start_time" field.
- func (u *BatchMsgUpsertBulk) SetStartTime(v time.Time) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStartTime(v)
- })
- }
- // UpdateStartTime sets the "start_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateStartTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStartTime()
- })
- }
- // ClearStartTime clears the value of the "start_time" field.
- func (u *BatchMsgUpsertBulk) ClearStartTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStartTime()
- })
- }
- // SetStopTime sets the "stop_time" field.
- func (u *BatchMsgUpsertBulk) SetStopTime(v time.Time) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetStopTime(v)
- })
- }
- // UpdateStopTime sets the "stop_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateStopTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateStopTime()
- })
- }
- // ClearStopTime clears the value of the "stop_time" field.
- func (u *BatchMsgUpsertBulk) ClearStopTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearStopTime()
- })
- }
- // SetSendTime sets the "send_time" field.
- func (u *BatchMsgUpsertBulk) SetSendTime(v time.Time) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetSendTime(v)
- })
- }
- // UpdateSendTime sets the "send_time" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateSendTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateSendTime()
- })
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (u *BatchMsgUpsertBulk) ClearSendTime() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearSendTime()
- })
- }
- // SetType sets the "type" field.
- func (u *BatchMsgUpsertBulk) SetType(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetType(v)
- })
- }
- // AddType adds v to the "type" field.
- func (u *BatchMsgUpsertBulk) AddType(v int32) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddType(v)
- })
- }
- // UpdateType sets the "type" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateType() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateType()
- })
- }
- // ClearType clears the value of the "type" field.
- func (u *BatchMsgUpsertBulk) ClearType() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearType()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *BatchMsgUpsertBulk) SetOrganizationID(v uint64) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *BatchMsgUpsertBulk) AddOrganizationID(v uint64) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateOrganizationID() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetCtype sets the "ctype" field.
- func (u *BatchMsgUpsertBulk) SetCtype(v uint64) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetCtype(v)
- })
- }
- // AddCtype adds v to the "ctype" field.
- func (u *BatchMsgUpsertBulk) AddCtype(v uint64) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.AddCtype(v)
- })
- }
- // UpdateCtype sets the "ctype" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateCtype() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateCtype()
- })
- }
- // SetCc sets the "cc" field.
- func (u *BatchMsgUpsertBulk) SetCc(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetCc(v)
- })
- }
- // UpdateCc sets the "cc" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateCc() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateCc()
- })
- }
- // ClearCc clears the value of the "cc" field.
- func (u *BatchMsgUpsertBulk) ClearCc() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearCc()
- })
- }
- // SetPhone sets the "phone" field.
- func (u *BatchMsgUpsertBulk) SetPhone(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetPhone(v)
- })
- }
- // UpdatePhone sets the "phone" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdatePhone() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdatePhone()
- })
- }
- // ClearPhone clears the value of the "phone" field.
- func (u *BatchMsgUpsertBulk) ClearPhone() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearPhone()
- })
- }
- // SetTemplateName sets the "template_name" field.
- func (u *BatchMsgUpsertBulk) SetTemplateName(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTemplateName(v)
- })
- }
- // UpdateTemplateName sets the "template_name" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTemplateName() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTemplateName()
- })
- }
- // ClearTemplateName clears the value of the "template_name" field.
- func (u *BatchMsgUpsertBulk) ClearTemplateName() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTemplateName()
- })
- }
- // SetTemplateCode sets the "template_code" field.
- func (u *BatchMsgUpsertBulk) SetTemplateCode(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetTemplateCode(v)
- })
- }
- // UpdateTemplateCode sets the "template_code" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateTemplateCode() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateTemplateCode()
- })
- }
- // ClearTemplateCode clears the value of the "template_code" field.
- func (u *BatchMsgUpsertBulk) ClearTemplateCode() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearTemplateCode()
- })
- }
- // SetLang sets the "lang" field.
- func (u *BatchMsgUpsertBulk) SetLang(v string) *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.SetLang(v)
- })
- }
- // UpdateLang sets the "lang" field to the value that was provided on create.
- func (u *BatchMsgUpsertBulk) UpdateLang() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.UpdateLang()
- })
- }
- // ClearLang clears the value of the "lang" field.
- func (u *BatchMsgUpsertBulk) ClearLang() *BatchMsgUpsertBulk {
- return u.Update(func(s *BatchMsgUpsert) {
- s.ClearLang()
- })
- }
- // Exec executes the query.
- func (u *BatchMsgUpsertBulk) 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 BatchMsgCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for BatchMsgCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *BatchMsgUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|