client.go 152 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "log"
  8. "reflect"
  9. "wechat-api/ent/migrate"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/agentbase"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/employee"
  18. "wechat-api/ent/employeeconfig"
  19. "wechat-api/ent/label"
  20. "wechat-api/ent/labelrelationship"
  21. "wechat-api/ent/message"
  22. "wechat-api/ent/messagerecords"
  23. "wechat-api/ent/msg"
  24. "wechat-api/ent/server"
  25. "wechat-api/ent/sopnode"
  26. "wechat-api/ent/sopstage"
  27. "wechat-api/ent/soptask"
  28. "wechat-api/ent/token"
  29. "wechat-api/ent/tutorial"
  30. "wechat-api/ent/workexperience"
  31. "wechat-api/ent/wx"
  32. "wechat-api/ent/wxcard"
  33. "wechat-api/ent/wxcarduser"
  34. "wechat-api/ent/wxcardvisit"
  35. "entgo.io/ent"
  36. "entgo.io/ent/dialect"
  37. "entgo.io/ent/dialect/sql"
  38. "entgo.io/ent/dialect/sql/sqlgraph"
  39. stdsql "database/sql"
  40. )
  41. // Client is the client that holds all ent builders.
  42. type Client struct {
  43. config
  44. // Schema is the client for creating, migrating and dropping schema.
  45. Schema *migrate.Schema
  46. // Agent is the client for interacting with the Agent builders.
  47. Agent *AgentClient
  48. // AgentBase is the client for interacting with the AgentBase builders.
  49. AgentBase *AgentBaseClient
  50. // BatchMsg is the client for interacting with the BatchMsg builders.
  51. BatchMsg *BatchMsgClient
  52. // Category is the client for interacting with the Category builders.
  53. Category *CategoryClient
  54. // ChatRecords is the client for interacting with the ChatRecords builders.
  55. ChatRecords *ChatRecordsClient
  56. // ChatSession is the client for interacting with the ChatSession builders.
  57. ChatSession *ChatSessionClient
  58. // Contact is the client for interacting with the Contact builders.
  59. Contact *ContactClient
  60. // Employee is the client for interacting with the Employee builders.
  61. Employee *EmployeeClient
  62. // EmployeeConfig is the client for interacting with the EmployeeConfig builders.
  63. EmployeeConfig *EmployeeConfigClient
  64. // Label is the client for interacting with the Label builders.
  65. Label *LabelClient
  66. // LabelRelationship is the client for interacting with the LabelRelationship builders.
  67. LabelRelationship *LabelRelationshipClient
  68. // Message is the client for interacting with the Message builders.
  69. Message *MessageClient
  70. // MessageRecords is the client for interacting with the MessageRecords builders.
  71. MessageRecords *MessageRecordsClient
  72. // Msg is the client for interacting with the Msg builders.
  73. Msg *MsgClient
  74. // Server is the client for interacting with the Server builders.
  75. Server *ServerClient
  76. // SopNode is the client for interacting with the SopNode builders.
  77. SopNode *SopNodeClient
  78. // SopStage is the client for interacting with the SopStage builders.
  79. SopStage *SopStageClient
  80. // SopTask is the client for interacting with the SopTask builders.
  81. SopTask *SopTaskClient
  82. // Token is the client for interacting with the Token builders.
  83. Token *TokenClient
  84. // Tutorial is the client for interacting with the Tutorial builders.
  85. Tutorial *TutorialClient
  86. // WorkExperience is the client for interacting with the WorkExperience builders.
  87. WorkExperience *WorkExperienceClient
  88. // Wx is the client for interacting with the Wx builders.
  89. Wx *WxClient
  90. // WxCard is the client for interacting with the WxCard builders.
  91. WxCard *WxCardClient
  92. // WxCardUser is the client for interacting with the WxCardUser builders.
  93. WxCardUser *WxCardUserClient
  94. // WxCardVisit is the client for interacting with the WxCardVisit builders.
  95. WxCardVisit *WxCardVisitClient
  96. }
  97. // NewClient creates a new client configured with the given options.
  98. func NewClient(opts ...Option) *Client {
  99. client := &Client{config: newConfig(opts...)}
  100. client.init()
  101. return client
  102. }
  103. func (c *Client) init() {
  104. c.Schema = migrate.NewSchema(c.driver)
  105. c.Agent = NewAgentClient(c.config)
  106. c.AgentBase = NewAgentBaseClient(c.config)
  107. c.BatchMsg = NewBatchMsgClient(c.config)
  108. c.Category = NewCategoryClient(c.config)
  109. c.ChatRecords = NewChatRecordsClient(c.config)
  110. c.ChatSession = NewChatSessionClient(c.config)
  111. c.Contact = NewContactClient(c.config)
  112. c.Employee = NewEmployeeClient(c.config)
  113. c.EmployeeConfig = NewEmployeeConfigClient(c.config)
  114. c.Label = NewLabelClient(c.config)
  115. c.LabelRelationship = NewLabelRelationshipClient(c.config)
  116. c.Message = NewMessageClient(c.config)
  117. c.MessageRecords = NewMessageRecordsClient(c.config)
  118. c.Msg = NewMsgClient(c.config)
  119. c.Server = NewServerClient(c.config)
  120. c.SopNode = NewSopNodeClient(c.config)
  121. c.SopStage = NewSopStageClient(c.config)
  122. c.SopTask = NewSopTaskClient(c.config)
  123. c.Token = NewTokenClient(c.config)
  124. c.Tutorial = NewTutorialClient(c.config)
  125. c.WorkExperience = NewWorkExperienceClient(c.config)
  126. c.Wx = NewWxClient(c.config)
  127. c.WxCard = NewWxCardClient(c.config)
  128. c.WxCardUser = NewWxCardUserClient(c.config)
  129. c.WxCardVisit = NewWxCardVisitClient(c.config)
  130. }
  131. type (
  132. // config is the configuration for the client and its builder.
  133. config struct {
  134. // driver used for executing database requests.
  135. driver dialect.Driver
  136. // debug enable a debug logging.
  137. debug bool
  138. // log used for logging on debug mode.
  139. log func(...any)
  140. // hooks to execute on mutations.
  141. hooks *hooks
  142. // interceptors to execute on queries.
  143. inters *inters
  144. }
  145. // Option function to configure the client.
  146. Option func(*config)
  147. )
  148. // newConfig creates a new config for the client.
  149. func newConfig(opts ...Option) config {
  150. cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
  151. cfg.options(opts...)
  152. return cfg
  153. }
  154. // options applies the options on the config object.
  155. func (c *config) options(opts ...Option) {
  156. for _, opt := range opts {
  157. opt(c)
  158. }
  159. if c.debug {
  160. c.driver = dialect.Debug(c.driver, c.log)
  161. }
  162. }
  163. // Debug enables debug logging on the ent.Driver.
  164. func Debug() Option {
  165. return func(c *config) {
  166. c.debug = true
  167. }
  168. }
  169. // Log sets the logging function for debug mode.
  170. func Log(fn func(...any)) Option {
  171. return func(c *config) {
  172. c.log = fn
  173. }
  174. }
  175. // Driver configures the client driver.
  176. func Driver(driver dialect.Driver) Option {
  177. return func(c *config) {
  178. c.driver = driver
  179. }
  180. }
  181. // Open opens a database/sql.DB specified by the driver name and
  182. // the data source name, and returns a new client attached to it.
  183. // Optional parameters can be added for configuring the client.
  184. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
  185. switch driverName {
  186. case dialect.MySQL, dialect.Postgres, dialect.SQLite:
  187. drv, err := sql.Open(driverName, dataSourceName)
  188. if err != nil {
  189. return nil, err
  190. }
  191. return NewClient(append(options, Driver(drv))...), nil
  192. default:
  193. return nil, fmt.Errorf("unsupported driver: %q", driverName)
  194. }
  195. }
  196. // ErrTxStarted is returned when trying to start a new transaction from a transactional client.
  197. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
  198. // Tx returns a new transactional client. The provided context
  199. // is used until the transaction is committed or rolled back.
  200. func (c *Client) Tx(ctx context.Context) (*Tx, error) {
  201. if _, ok := c.driver.(*txDriver); ok {
  202. return nil, ErrTxStarted
  203. }
  204. tx, err := newTx(ctx, c.driver)
  205. if err != nil {
  206. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  207. }
  208. cfg := c.config
  209. cfg.driver = tx
  210. return &Tx{
  211. ctx: ctx,
  212. config: cfg,
  213. Agent: NewAgentClient(cfg),
  214. AgentBase: NewAgentBaseClient(cfg),
  215. BatchMsg: NewBatchMsgClient(cfg),
  216. Category: NewCategoryClient(cfg),
  217. ChatRecords: NewChatRecordsClient(cfg),
  218. ChatSession: NewChatSessionClient(cfg),
  219. Contact: NewContactClient(cfg),
  220. Employee: NewEmployeeClient(cfg),
  221. EmployeeConfig: NewEmployeeConfigClient(cfg),
  222. Label: NewLabelClient(cfg),
  223. LabelRelationship: NewLabelRelationshipClient(cfg),
  224. Message: NewMessageClient(cfg),
  225. MessageRecords: NewMessageRecordsClient(cfg),
  226. Msg: NewMsgClient(cfg),
  227. Server: NewServerClient(cfg),
  228. SopNode: NewSopNodeClient(cfg),
  229. SopStage: NewSopStageClient(cfg),
  230. SopTask: NewSopTaskClient(cfg),
  231. Token: NewTokenClient(cfg),
  232. Tutorial: NewTutorialClient(cfg),
  233. WorkExperience: NewWorkExperienceClient(cfg),
  234. Wx: NewWxClient(cfg),
  235. WxCard: NewWxCardClient(cfg),
  236. WxCardUser: NewWxCardUserClient(cfg),
  237. WxCardVisit: NewWxCardVisitClient(cfg),
  238. }, nil
  239. }
  240. // BeginTx returns a transactional client with specified options.
  241. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
  242. if _, ok := c.driver.(*txDriver); ok {
  243. return nil, errors.New("ent: cannot start a transaction within a transaction")
  244. }
  245. tx, err := c.driver.(interface {
  246. BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
  247. }).BeginTx(ctx, opts)
  248. if err != nil {
  249. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  250. }
  251. cfg := c.config
  252. cfg.driver = &txDriver{tx: tx, drv: c.driver}
  253. return &Tx{
  254. ctx: ctx,
  255. config: cfg,
  256. Agent: NewAgentClient(cfg),
  257. AgentBase: NewAgentBaseClient(cfg),
  258. BatchMsg: NewBatchMsgClient(cfg),
  259. Category: NewCategoryClient(cfg),
  260. ChatRecords: NewChatRecordsClient(cfg),
  261. ChatSession: NewChatSessionClient(cfg),
  262. Contact: NewContactClient(cfg),
  263. Employee: NewEmployeeClient(cfg),
  264. EmployeeConfig: NewEmployeeConfigClient(cfg),
  265. Label: NewLabelClient(cfg),
  266. LabelRelationship: NewLabelRelationshipClient(cfg),
  267. Message: NewMessageClient(cfg),
  268. MessageRecords: NewMessageRecordsClient(cfg),
  269. Msg: NewMsgClient(cfg),
  270. Server: NewServerClient(cfg),
  271. SopNode: NewSopNodeClient(cfg),
  272. SopStage: NewSopStageClient(cfg),
  273. SopTask: NewSopTaskClient(cfg),
  274. Token: NewTokenClient(cfg),
  275. Tutorial: NewTutorialClient(cfg),
  276. WorkExperience: NewWorkExperienceClient(cfg),
  277. Wx: NewWxClient(cfg),
  278. WxCard: NewWxCardClient(cfg),
  279. WxCardUser: NewWxCardUserClient(cfg),
  280. WxCardVisit: NewWxCardVisitClient(cfg),
  281. }, nil
  282. }
  283. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
  284. //
  285. // client.Debug().
  286. // Agent.
  287. // Query().
  288. // Count(ctx)
  289. func (c *Client) Debug() *Client {
  290. if c.debug {
  291. return c
  292. }
  293. cfg := c.config
  294. cfg.driver = dialect.Debug(c.driver, c.log)
  295. client := &Client{config: cfg}
  296. client.init()
  297. return client
  298. }
  299. // Close closes the database connection and prevents new queries from starting.
  300. func (c *Client) Close() error {
  301. return c.driver.Close()
  302. }
  303. // Use adds the mutation hooks to all the entity clients.
  304. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
  305. func (c *Client) Use(hooks ...Hook) {
  306. for _, n := range []interface{ Use(...Hook) }{
  307. c.Agent, c.AgentBase, c.BatchMsg, c.Category, c.ChatRecords, c.ChatSession,
  308. c.Contact, c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship,
  309. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  310. c.Token, c.Tutorial, c.WorkExperience, c.Wx, c.WxCard, c.WxCardUser,
  311. c.WxCardVisit,
  312. } {
  313. n.Use(hooks...)
  314. }
  315. }
  316. // Intercept adds the query interceptors to all the entity clients.
  317. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
  318. func (c *Client) Intercept(interceptors ...Interceptor) {
  319. for _, n := range []interface{ Intercept(...Interceptor) }{
  320. c.Agent, c.AgentBase, c.BatchMsg, c.Category, c.ChatRecords, c.ChatSession,
  321. c.Contact, c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship,
  322. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  323. c.Token, c.Tutorial, c.WorkExperience, c.Wx, c.WxCard, c.WxCardUser,
  324. c.WxCardVisit,
  325. } {
  326. n.Intercept(interceptors...)
  327. }
  328. }
  329. // Mutate implements the ent.Mutator interface.
  330. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
  331. switch m := m.(type) {
  332. case *AgentMutation:
  333. return c.Agent.mutate(ctx, m)
  334. case *AgentBaseMutation:
  335. return c.AgentBase.mutate(ctx, m)
  336. case *BatchMsgMutation:
  337. return c.BatchMsg.mutate(ctx, m)
  338. case *CategoryMutation:
  339. return c.Category.mutate(ctx, m)
  340. case *ChatRecordsMutation:
  341. return c.ChatRecords.mutate(ctx, m)
  342. case *ChatSessionMutation:
  343. return c.ChatSession.mutate(ctx, m)
  344. case *ContactMutation:
  345. return c.Contact.mutate(ctx, m)
  346. case *EmployeeMutation:
  347. return c.Employee.mutate(ctx, m)
  348. case *EmployeeConfigMutation:
  349. return c.EmployeeConfig.mutate(ctx, m)
  350. case *LabelMutation:
  351. return c.Label.mutate(ctx, m)
  352. case *LabelRelationshipMutation:
  353. return c.LabelRelationship.mutate(ctx, m)
  354. case *MessageMutation:
  355. return c.Message.mutate(ctx, m)
  356. case *MessageRecordsMutation:
  357. return c.MessageRecords.mutate(ctx, m)
  358. case *MsgMutation:
  359. return c.Msg.mutate(ctx, m)
  360. case *ServerMutation:
  361. return c.Server.mutate(ctx, m)
  362. case *SopNodeMutation:
  363. return c.SopNode.mutate(ctx, m)
  364. case *SopStageMutation:
  365. return c.SopStage.mutate(ctx, m)
  366. case *SopTaskMutation:
  367. return c.SopTask.mutate(ctx, m)
  368. case *TokenMutation:
  369. return c.Token.mutate(ctx, m)
  370. case *TutorialMutation:
  371. return c.Tutorial.mutate(ctx, m)
  372. case *WorkExperienceMutation:
  373. return c.WorkExperience.mutate(ctx, m)
  374. case *WxMutation:
  375. return c.Wx.mutate(ctx, m)
  376. case *WxCardMutation:
  377. return c.WxCard.mutate(ctx, m)
  378. case *WxCardUserMutation:
  379. return c.WxCardUser.mutate(ctx, m)
  380. case *WxCardVisitMutation:
  381. return c.WxCardVisit.mutate(ctx, m)
  382. default:
  383. return nil, fmt.Errorf("ent: unknown mutation type %T", m)
  384. }
  385. }
  386. // AgentClient is a client for the Agent schema.
  387. type AgentClient struct {
  388. config
  389. }
  390. // NewAgentClient returns a client for the Agent from the given config.
  391. func NewAgentClient(c config) *AgentClient {
  392. return &AgentClient{config: c}
  393. }
  394. // Use adds a list of mutation hooks to the hooks stack.
  395. // A call to `Use(f, g, h)` equals to `agent.Hooks(f(g(h())))`.
  396. func (c *AgentClient) Use(hooks ...Hook) {
  397. c.hooks.Agent = append(c.hooks.Agent, hooks...)
  398. }
  399. // Intercept adds a list of query interceptors to the interceptors stack.
  400. // A call to `Intercept(f, g, h)` equals to `agent.Intercept(f(g(h())))`.
  401. func (c *AgentClient) Intercept(interceptors ...Interceptor) {
  402. c.inters.Agent = append(c.inters.Agent, interceptors...)
  403. }
  404. // Create returns a builder for creating a Agent entity.
  405. func (c *AgentClient) Create() *AgentCreate {
  406. mutation := newAgentMutation(c.config, OpCreate)
  407. return &AgentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  408. }
  409. // CreateBulk returns a builder for creating a bulk of Agent entities.
  410. func (c *AgentClient) CreateBulk(builders ...*AgentCreate) *AgentCreateBulk {
  411. return &AgentCreateBulk{config: c.config, builders: builders}
  412. }
  413. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  414. // a builder and applies setFunc on it.
  415. func (c *AgentClient) MapCreateBulk(slice any, setFunc func(*AgentCreate, int)) *AgentCreateBulk {
  416. rv := reflect.ValueOf(slice)
  417. if rv.Kind() != reflect.Slice {
  418. return &AgentCreateBulk{err: fmt.Errorf("calling to AgentClient.MapCreateBulk with wrong type %T, need slice", slice)}
  419. }
  420. builders := make([]*AgentCreate, rv.Len())
  421. for i := 0; i < rv.Len(); i++ {
  422. builders[i] = c.Create()
  423. setFunc(builders[i], i)
  424. }
  425. return &AgentCreateBulk{config: c.config, builders: builders}
  426. }
  427. // Update returns an update builder for Agent.
  428. func (c *AgentClient) Update() *AgentUpdate {
  429. mutation := newAgentMutation(c.config, OpUpdate)
  430. return &AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  431. }
  432. // UpdateOne returns an update builder for the given entity.
  433. func (c *AgentClient) UpdateOne(a *Agent) *AgentUpdateOne {
  434. mutation := newAgentMutation(c.config, OpUpdateOne, withAgent(a))
  435. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  436. }
  437. // UpdateOneID returns an update builder for the given id.
  438. func (c *AgentClient) UpdateOneID(id uint64) *AgentUpdateOne {
  439. mutation := newAgentMutation(c.config, OpUpdateOne, withAgentID(id))
  440. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  441. }
  442. // Delete returns a delete builder for Agent.
  443. func (c *AgentClient) Delete() *AgentDelete {
  444. mutation := newAgentMutation(c.config, OpDelete)
  445. return &AgentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  446. }
  447. // DeleteOne returns a builder for deleting the given entity.
  448. func (c *AgentClient) DeleteOne(a *Agent) *AgentDeleteOne {
  449. return c.DeleteOneID(a.ID)
  450. }
  451. // DeleteOneID returns a builder for deleting the given entity by its id.
  452. func (c *AgentClient) DeleteOneID(id uint64) *AgentDeleteOne {
  453. builder := c.Delete().Where(agent.ID(id))
  454. builder.mutation.id = &id
  455. builder.mutation.op = OpDeleteOne
  456. return &AgentDeleteOne{builder}
  457. }
  458. // Query returns a query builder for Agent.
  459. func (c *AgentClient) Query() *AgentQuery {
  460. return &AgentQuery{
  461. config: c.config,
  462. ctx: &QueryContext{Type: TypeAgent},
  463. inters: c.Interceptors(),
  464. }
  465. }
  466. // Get returns a Agent entity by its id.
  467. func (c *AgentClient) Get(ctx context.Context, id uint64) (*Agent, error) {
  468. return c.Query().Where(agent.ID(id)).Only(ctx)
  469. }
  470. // GetX is like Get, but panics if an error occurs.
  471. func (c *AgentClient) GetX(ctx context.Context, id uint64) *Agent {
  472. obj, err := c.Get(ctx, id)
  473. if err != nil {
  474. panic(err)
  475. }
  476. return obj
  477. }
  478. // QueryWxAgent queries the wx_agent edge of a Agent.
  479. func (c *AgentClient) QueryWxAgent(a *Agent) *WxQuery {
  480. query := (&WxClient{config: c.config}).Query()
  481. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  482. id := a.ID
  483. step := sqlgraph.NewStep(
  484. sqlgraph.From(agent.Table, agent.FieldID, id),
  485. sqlgraph.To(wx.Table, wx.FieldID),
  486. sqlgraph.Edge(sqlgraph.O2M, false, agent.WxAgentTable, agent.WxAgentColumn),
  487. )
  488. fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
  489. return fromV, nil
  490. }
  491. return query
  492. }
  493. // Hooks returns the client hooks.
  494. func (c *AgentClient) Hooks() []Hook {
  495. hooks := c.hooks.Agent
  496. return append(hooks[:len(hooks):len(hooks)], agent.Hooks[:]...)
  497. }
  498. // Interceptors returns the client interceptors.
  499. func (c *AgentClient) Interceptors() []Interceptor {
  500. inters := c.inters.Agent
  501. return append(inters[:len(inters):len(inters)], agent.Interceptors[:]...)
  502. }
  503. func (c *AgentClient) mutate(ctx context.Context, m *AgentMutation) (Value, error) {
  504. switch m.Op() {
  505. case OpCreate:
  506. return (&AgentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  507. case OpUpdate:
  508. return (&AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  509. case OpUpdateOne:
  510. return (&AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  511. case OpDelete, OpDeleteOne:
  512. return (&AgentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  513. default:
  514. return nil, fmt.Errorf("ent: unknown Agent mutation op: %q", m.Op())
  515. }
  516. }
  517. // AgentBaseClient is a client for the AgentBase schema.
  518. type AgentBaseClient struct {
  519. config
  520. }
  521. // NewAgentBaseClient returns a client for the AgentBase from the given config.
  522. func NewAgentBaseClient(c config) *AgentBaseClient {
  523. return &AgentBaseClient{config: c}
  524. }
  525. // Use adds a list of mutation hooks to the hooks stack.
  526. // A call to `Use(f, g, h)` equals to `agentbase.Hooks(f(g(h())))`.
  527. func (c *AgentBaseClient) Use(hooks ...Hook) {
  528. c.hooks.AgentBase = append(c.hooks.AgentBase, hooks...)
  529. }
  530. // Intercept adds a list of query interceptors to the interceptors stack.
  531. // A call to `Intercept(f, g, h)` equals to `agentbase.Intercept(f(g(h())))`.
  532. func (c *AgentBaseClient) Intercept(interceptors ...Interceptor) {
  533. c.inters.AgentBase = append(c.inters.AgentBase, interceptors...)
  534. }
  535. // Create returns a builder for creating a AgentBase entity.
  536. func (c *AgentBaseClient) Create() *AgentBaseCreate {
  537. mutation := newAgentBaseMutation(c.config, OpCreate)
  538. return &AgentBaseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  539. }
  540. // CreateBulk returns a builder for creating a bulk of AgentBase entities.
  541. func (c *AgentBaseClient) CreateBulk(builders ...*AgentBaseCreate) *AgentBaseCreateBulk {
  542. return &AgentBaseCreateBulk{config: c.config, builders: builders}
  543. }
  544. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  545. // a builder and applies setFunc on it.
  546. func (c *AgentBaseClient) MapCreateBulk(slice any, setFunc func(*AgentBaseCreate, int)) *AgentBaseCreateBulk {
  547. rv := reflect.ValueOf(slice)
  548. if rv.Kind() != reflect.Slice {
  549. return &AgentBaseCreateBulk{err: fmt.Errorf("calling to AgentBaseClient.MapCreateBulk with wrong type %T, need slice", slice)}
  550. }
  551. builders := make([]*AgentBaseCreate, rv.Len())
  552. for i := 0; i < rv.Len(); i++ {
  553. builders[i] = c.Create()
  554. setFunc(builders[i], i)
  555. }
  556. return &AgentBaseCreateBulk{config: c.config, builders: builders}
  557. }
  558. // Update returns an update builder for AgentBase.
  559. func (c *AgentBaseClient) Update() *AgentBaseUpdate {
  560. mutation := newAgentBaseMutation(c.config, OpUpdate)
  561. return &AgentBaseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  562. }
  563. // UpdateOne returns an update builder for the given entity.
  564. func (c *AgentBaseClient) UpdateOne(ab *AgentBase) *AgentBaseUpdateOne {
  565. mutation := newAgentBaseMutation(c.config, OpUpdateOne, withAgentBase(ab))
  566. return &AgentBaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  567. }
  568. // UpdateOneID returns an update builder for the given id.
  569. func (c *AgentBaseClient) UpdateOneID(id string) *AgentBaseUpdateOne {
  570. mutation := newAgentBaseMutation(c.config, OpUpdateOne, withAgentBaseID(id))
  571. return &AgentBaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  572. }
  573. // Delete returns a delete builder for AgentBase.
  574. func (c *AgentBaseClient) Delete() *AgentBaseDelete {
  575. mutation := newAgentBaseMutation(c.config, OpDelete)
  576. return &AgentBaseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  577. }
  578. // DeleteOne returns a builder for deleting the given entity.
  579. func (c *AgentBaseClient) DeleteOne(ab *AgentBase) *AgentBaseDeleteOne {
  580. return c.DeleteOneID(ab.ID)
  581. }
  582. // DeleteOneID returns a builder for deleting the given entity by its id.
  583. func (c *AgentBaseClient) DeleteOneID(id string) *AgentBaseDeleteOne {
  584. builder := c.Delete().Where(agentbase.ID(id))
  585. builder.mutation.id = &id
  586. builder.mutation.op = OpDeleteOne
  587. return &AgentBaseDeleteOne{builder}
  588. }
  589. // Query returns a query builder for AgentBase.
  590. func (c *AgentBaseClient) Query() *AgentBaseQuery {
  591. return &AgentBaseQuery{
  592. config: c.config,
  593. ctx: &QueryContext{Type: TypeAgentBase},
  594. inters: c.Interceptors(),
  595. }
  596. }
  597. // Get returns a AgentBase entity by its id.
  598. func (c *AgentBaseClient) Get(ctx context.Context, id string) (*AgentBase, error) {
  599. return c.Query().Where(agentbase.ID(id)).Only(ctx)
  600. }
  601. // GetX is like Get, but panics if an error occurs.
  602. func (c *AgentBaseClient) GetX(ctx context.Context, id string) *AgentBase {
  603. obj, err := c.Get(ctx, id)
  604. if err != nil {
  605. panic(err)
  606. }
  607. return obj
  608. }
  609. // QueryWxAgent queries the wx_agent edge of a AgentBase.
  610. func (c *AgentBaseClient) QueryWxAgent(ab *AgentBase) *WxQuery {
  611. query := (&WxClient{config: c.config}).Query()
  612. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  613. id := ab.ID
  614. step := sqlgraph.NewStep(
  615. sqlgraph.From(agentbase.Table, agentbase.FieldID, id),
  616. sqlgraph.To(wx.Table, wx.FieldID),
  617. sqlgraph.Edge(sqlgraph.O2M, false, agentbase.WxAgentTable, agentbase.WxAgentColumn),
  618. )
  619. fromV = sqlgraph.Neighbors(ab.driver.Dialect(), step)
  620. return fromV, nil
  621. }
  622. return query
  623. }
  624. // Hooks returns the client hooks.
  625. func (c *AgentBaseClient) Hooks() []Hook {
  626. return c.hooks.AgentBase
  627. }
  628. // Interceptors returns the client interceptors.
  629. func (c *AgentBaseClient) Interceptors() []Interceptor {
  630. return c.inters.AgentBase
  631. }
  632. func (c *AgentBaseClient) mutate(ctx context.Context, m *AgentBaseMutation) (Value, error) {
  633. switch m.Op() {
  634. case OpCreate:
  635. return (&AgentBaseCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  636. case OpUpdate:
  637. return (&AgentBaseUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  638. case OpUpdateOne:
  639. return (&AgentBaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  640. case OpDelete, OpDeleteOne:
  641. return (&AgentBaseDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  642. default:
  643. return nil, fmt.Errorf("ent: unknown AgentBase mutation op: %q", m.Op())
  644. }
  645. }
  646. // BatchMsgClient is a client for the BatchMsg schema.
  647. type BatchMsgClient struct {
  648. config
  649. }
  650. // NewBatchMsgClient returns a client for the BatchMsg from the given config.
  651. func NewBatchMsgClient(c config) *BatchMsgClient {
  652. return &BatchMsgClient{config: c}
  653. }
  654. // Use adds a list of mutation hooks to the hooks stack.
  655. // A call to `Use(f, g, h)` equals to `batchmsg.Hooks(f(g(h())))`.
  656. func (c *BatchMsgClient) Use(hooks ...Hook) {
  657. c.hooks.BatchMsg = append(c.hooks.BatchMsg, hooks...)
  658. }
  659. // Intercept adds a list of query interceptors to the interceptors stack.
  660. // A call to `Intercept(f, g, h)` equals to `batchmsg.Intercept(f(g(h())))`.
  661. func (c *BatchMsgClient) Intercept(interceptors ...Interceptor) {
  662. c.inters.BatchMsg = append(c.inters.BatchMsg, interceptors...)
  663. }
  664. // Create returns a builder for creating a BatchMsg entity.
  665. func (c *BatchMsgClient) Create() *BatchMsgCreate {
  666. mutation := newBatchMsgMutation(c.config, OpCreate)
  667. return &BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  668. }
  669. // CreateBulk returns a builder for creating a bulk of BatchMsg entities.
  670. func (c *BatchMsgClient) CreateBulk(builders ...*BatchMsgCreate) *BatchMsgCreateBulk {
  671. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  672. }
  673. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  674. // a builder and applies setFunc on it.
  675. func (c *BatchMsgClient) MapCreateBulk(slice any, setFunc func(*BatchMsgCreate, int)) *BatchMsgCreateBulk {
  676. rv := reflect.ValueOf(slice)
  677. if rv.Kind() != reflect.Slice {
  678. return &BatchMsgCreateBulk{err: fmt.Errorf("calling to BatchMsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  679. }
  680. builders := make([]*BatchMsgCreate, rv.Len())
  681. for i := 0; i < rv.Len(); i++ {
  682. builders[i] = c.Create()
  683. setFunc(builders[i], i)
  684. }
  685. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  686. }
  687. // Update returns an update builder for BatchMsg.
  688. func (c *BatchMsgClient) Update() *BatchMsgUpdate {
  689. mutation := newBatchMsgMutation(c.config, OpUpdate)
  690. return &BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  691. }
  692. // UpdateOne returns an update builder for the given entity.
  693. func (c *BatchMsgClient) UpdateOne(bm *BatchMsg) *BatchMsgUpdateOne {
  694. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsg(bm))
  695. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  696. }
  697. // UpdateOneID returns an update builder for the given id.
  698. func (c *BatchMsgClient) UpdateOneID(id uint64) *BatchMsgUpdateOne {
  699. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsgID(id))
  700. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  701. }
  702. // Delete returns a delete builder for BatchMsg.
  703. func (c *BatchMsgClient) Delete() *BatchMsgDelete {
  704. mutation := newBatchMsgMutation(c.config, OpDelete)
  705. return &BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  706. }
  707. // DeleteOne returns a builder for deleting the given entity.
  708. func (c *BatchMsgClient) DeleteOne(bm *BatchMsg) *BatchMsgDeleteOne {
  709. return c.DeleteOneID(bm.ID)
  710. }
  711. // DeleteOneID returns a builder for deleting the given entity by its id.
  712. func (c *BatchMsgClient) DeleteOneID(id uint64) *BatchMsgDeleteOne {
  713. builder := c.Delete().Where(batchmsg.ID(id))
  714. builder.mutation.id = &id
  715. builder.mutation.op = OpDeleteOne
  716. return &BatchMsgDeleteOne{builder}
  717. }
  718. // Query returns a query builder for BatchMsg.
  719. func (c *BatchMsgClient) Query() *BatchMsgQuery {
  720. return &BatchMsgQuery{
  721. config: c.config,
  722. ctx: &QueryContext{Type: TypeBatchMsg},
  723. inters: c.Interceptors(),
  724. }
  725. }
  726. // Get returns a BatchMsg entity by its id.
  727. func (c *BatchMsgClient) Get(ctx context.Context, id uint64) (*BatchMsg, error) {
  728. return c.Query().Where(batchmsg.ID(id)).Only(ctx)
  729. }
  730. // GetX is like Get, but panics if an error occurs.
  731. func (c *BatchMsgClient) GetX(ctx context.Context, id uint64) *BatchMsg {
  732. obj, err := c.Get(ctx, id)
  733. if err != nil {
  734. panic(err)
  735. }
  736. return obj
  737. }
  738. // Hooks returns the client hooks.
  739. func (c *BatchMsgClient) Hooks() []Hook {
  740. hooks := c.hooks.BatchMsg
  741. return append(hooks[:len(hooks):len(hooks)], batchmsg.Hooks[:]...)
  742. }
  743. // Interceptors returns the client interceptors.
  744. func (c *BatchMsgClient) Interceptors() []Interceptor {
  745. inters := c.inters.BatchMsg
  746. return append(inters[:len(inters):len(inters)], batchmsg.Interceptors[:]...)
  747. }
  748. func (c *BatchMsgClient) mutate(ctx context.Context, m *BatchMsgMutation) (Value, error) {
  749. switch m.Op() {
  750. case OpCreate:
  751. return (&BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  752. case OpUpdate:
  753. return (&BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  754. case OpUpdateOne:
  755. return (&BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  756. case OpDelete, OpDeleteOne:
  757. return (&BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  758. default:
  759. return nil, fmt.Errorf("ent: unknown BatchMsg mutation op: %q", m.Op())
  760. }
  761. }
  762. // CategoryClient is a client for the Category schema.
  763. type CategoryClient struct {
  764. config
  765. }
  766. // NewCategoryClient returns a client for the Category from the given config.
  767. func NewCategoryClient(c config) *CategoryClient {
  768. return &CategoryClient{config: c}
  769. }
  770. // Use adds a list of mutation hooks to the hooks stack.
  771. // A call to `Use(f, g, h)` equals to `category.Hooks(f(g(h())))`.
  772. func (c *CategoryClient) Use(hooks ...Hook) {
  773. c.hooks.Category = append(c.hooks.Category, hooks...)
  774. }
  775. // Intercept adds a list of query interceptors to the interceptors stack.
  776. // A call to `Intercept(f, g, h)` equals to `category.Intercept(f(g(h())))`.
  777. func (c *CategoryClient) Intercept(interceptors ...Interceptor) {
  778. c.inters.Category = append(c.inters.Category, interceptors...)
  779. }
  780. // Create returns a builder for creating a Category entity.
  781. func (c *CategoryClient) Create() *CategoryCreate {
  782. mutation := newCategoryMutation(c.config, OpCreate)
  783. return &CategoryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  784. }
  785. // CreateBulk returns a builder for creating a bulk of Category entities.
  786. func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreateBulk {
  787. return &CategoryCreateBulk{config: c.config, builders: builders}
  788. }
  789. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  790. // a builder and applies setFunc on it.
  791. func (c *CategoryClient) MapCreateBulk(slice any, setFunc func(*CategoryCreate, int)) *CategoryCreateBulk {
  792. rv := reflect.ValueOf(slice)
  793. if rv.Kind() != reflect.Slice {
  794. return &CategoryCreateBulk{err: fmt.Errorf("calling to CategoryClient.MapCreateBulk with wrong type %T, need slice", slice)}
  795. }
  796. builders := make([]*CategoryCreate, rv.Len())
  797. for i := 0; i < rv.Len(); i++ {
  798. builders[i] = c.Create()
  799. setFunc(builders[i], i)
  800. }
  801. return &CategoryCreateBulk{config: c.config, builders: builders}
  802. }
  803. // Update returns an update builder for Category.
  804. func (c *CategoryClient) Update() *CategoryUpdate {
  805. mutation := newCategoryMutation(c.config, OpUpdate)
  806. return &CategoryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  807. }
  808. // UpdateOne returns an update builder for the given entity.
  809. func (c *CategoryClient) UpdateOne(ca *Category) *CategoryUpdateOne {
  810. mutation := newCategoryMutation(c.config, OpUpdateOne, withCategory(ca))
  811. return &CategoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  812. }
  813. // UpdateOneID returns an update builder for the given id.
  814. func (c *CategoryClient) UpdateOneID(id uint64) *CategoryUpdateOne {
  815. mutation := newCategoryMutation(c.config, OpUpdateOne, withCategoryID(id))
  816. return &CategoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  817. }
  818. // Delete returns a delete builder for Category.
  819. func (c *CategoryClient) Delete() *CategoryDelete {
  820. mutation := newCategoryMutation(c.config, OpDelete)
  821. return &CategoryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  822. }
  823. // DeleteOne returns a builder for deleting the given entity.
  824. func (c *CategoryClient) DeleteOne(ca *Category) *CategoryDeleteOne {
  825. return c.DeleteOneID(ca.ID)
  826. }
  827. // DeleteOneID returns a builder for deleting the given entity by its id.
  828. func (c *CategoryClient) DeleteOneID(id uint64) *CategoryDeleteOne {
  829. builder := c.Delete().Where(category.ID(id))
  830. builder.mutation.id = &id
  831. builder.mutation.op = OpDeleteOne
  832. return &CategoryDeleteOne{builder}
  833. }
  834. // Query returns a query builder for Category.
  835. func (c *CategoryClient) Query() *CategoryQuery {
  836. return &CategoryQuery{
  837. config: c.config,
  838. ctx: &QueryContext{Type: TypeCategory},
  839. inters: c.Interceptors(),
  840. }
  841. }
  842. // Get returns a Category entity by its id.
  843. func (c *CategoryClient) Get(ctx context.Context, id uint64) (*Category, error) {
  844. return c.Query().Where(category.ID(id)).Only(ctx)
  845. }
  846. // GetX is like Get, but panics if an error occurs.
  847. func (c *CategoryClient) GetX(ctx context.Context, id uint64) *Category {
  848. obj, err := c.Get(ctx, id)
  849. if err != nil {
  850. panic(err)
  851. }
  852. return obj
  853. }
  854. // Hooks returns the client hooks.
  855. func (c *CategoryClient) Hooks() []Hook {
  856. hooks := c.hooks.Category
  857. return append(hooks[:len(hooks):len(hooks)], category.Hooks[:]...)
  858. }
  859. // Interceptors returns the client interceptors.
  860. func (c *CategoryClient) Interceptors() []Interceptor {
  861. inters := c.inters.Category
  862. return append(inters[:len(inters):len(inters)], category.Interceptors[:]...)
  863. }
  864. func (c *CategoryClient) mutate(ctx context.Context, m *CategoryMutation) (Value, error) {
  865. switch m.Op() {
  866. case OpCreate:
  867. return (&CategoryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  868. case OpUpdate:
  869. return (&CategoryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  870. case OpUpdateOne:
  871. return (&CategoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  872. case OpDelete, OpDeleteOne:
  873. return (&CategoryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  874. default:
  875. return nil, fmt.Errorf("ent: unknown Category mutation op: %q", m.Op())
  876. }
  877. }
  878. // ChatRecordsClient is a client for the ChatRecords schema.
  879. type ChatRecordsClient struct {
  880. config
  881. }
  882. // NewChatRecordsClient returns a client for the ChatRecords from the given config.
  883. func NewChatRecordsClient(c config) *ChatRecordsClient {
  884. return &ChatRecordsClient{config: c}
  885. }
  886. // Use adds a list of mutation hooks to the hooks stack.
  887. // A call to `Use(f, g, h)` equals to `chatrecords.Hooks(f(g(h())))`.
  888. func (c *ChatRecordsClient) Use(hooks ...Hook) {
  889. c.hooks.ChatRecords = append(c.hooks.ChatRecords, hooks...)
  890. }
  891. // Intercept adds a list of query interceptors to the interceptors stack.
  892. // A call to `Intercept(f, g, h)` equals to `chatrecords.Intercept(f(g(h())))`.
  893. func (c *ChatRecordsClient) Intercept(interceptors ...Interceptor) {
  894. c.inters.ChatRecords = append(c.inters.ChatRecords, interceptors...)
  895. }
  896. // Create returns a builder for creating a ChatRecords entity.
  897. func (c *ChatRecordsClient) Create() *ChatRecordsCreate {
  898. mutation := newChatRecordsMutation(c.config, OpCreate)
  899. return &ChatRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  900. }
  901. // CreateBulk returns a builder for creating a bulk of ChatRecords entities.
  902. func (c *ChatRecordsClient) CreateBulk(builders ...*ChatRecordsCreate) *ChatRecordsCreateBulk {
  903. return &ChatRecordsCreateBulk{config: c.config, builders: builders}
  904. }
  905. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  906. // a builder and applies setFunc on it.
  907. func (c *ChatRecordsClient) MapCreateBulk(slice any, setFunc func(*ChatRecordsCreate, int)) *ChatRecordsCreateBulk {
  908. rv := reflect.ValueOf(slice)
  909. if rv.Kind() != reflect.Slice {
  910. return &ChatRecordsCreateBulk{err: fmt.Errorf("calling to ChatRecordsClient.MapCreateBulk with wrong type %T, need slice", slice)}
  911. }
  912. builders := make([]*ChatRecordsCreate, rv.Len())
  913. for i := 0; i < rv.Len(); i++ {
  914. builders[i] = c.Create()
  915. setFunc(builders[i], i)
  916. }
  917. return &ChatRecordsCreateBulk{config: c.config, builders: builders}
  918. }
  919. // Update returns an update builder for ChatRecords.
  920. func (c *ChatRecordsClient) Update() *ChatRecordsUpdate {
  921. mutation := newChatRecordsMutation(c.config, OpUpdate)
  922. return &ChatRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  923. }
  924. // UpdateOne returns an update builder for the given entity.
  925. func (c *ChatRecordsClient) UpdateOne(cr *ChatRecords) *ChatRecordsUpdateOne {
  926. mutation := newChatRecordsMutation(c.config, OpUpdateOne, withChatRecords(cr))
  927. return &ChatRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  928. }
  929. // UpdateOneID returns an update builder for the given id.
  930. func (c *ChatRecordsClient) UpdateOneID(id uint64) *ChatRecordsUpdateOne {
  931. mutation := newChatRecordsMutation(c.config, OpUpdateOne, withChatRecordsID(id))
  932. return &ChatRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  933. }
  934. // Delete returns a delete builder for ChatRecords.
  935. func (c *ChatRecordsClient) Delete() *ChatRecordsDelete {
  936. mutation := newChatRecordsMutation(c.config, OpDelete)
  937. return &ChatRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  938. }
  939. // DeleteOne returns a builder for deleting the given entity.
  940. func (c *ChatRecordsClient) DeleteOne(cr *ChatRecords) *ChatRecordsDeleteOne {
  941. return c.DeleteOneID(cr.ID)
  942. }
  943. // DeleteOneID returns a builder for deleting the given entity by its id.
  944. func (c *ChatRecordsClient) DeleteOneID(id uint64) *ChatRecordsDeleteOne {
  945. builder := c.Delete().Where(chatrecords.ID(id))
  946. builder.mutation.id = &id
  947. builder.mutation.op = OpDeleteOne
  948. return &ChatRecordsDeleteOne{builder}
  949. }
  950. // Query returns a query builder for ChatRecords.
  951. func (c *ChatRecordsClient) Query() *ChatRecordsQuery {
  952. return &ChatRecordsQuery{
  953. config: c.config,
  954. ctx: &QueryContext{Type: TypeChatRecords},
  955. inters: c.Interceptors(),
  956. }
  957. }
  958. // Get returns a ChatRecords entity by its id.
  959. func (c *ChatRecordsClient) Get(ctx context.Context, id uint64) (*ChatRecords, error) {
  960. return c.Query().Where(chatrecords.ID(id)).Only(ctx)
  961. }
  962. // GetX is like Get, but panics if an error occurs.
  963. func (c *ChatRecordsClient) GetX(ctx context.Context, id uint64) *ChatRecords {
  964. obj, err := c.Get(ctx, id)
  965. if err != nil {
  966. panic(err)
  967. }
  968. return obj
  969. }
  970. // Hooks returns the client hooks.
  971. func (c *ChatRecordsClient) Hooks() []Hook {
  972. hooks := c.hooks.ChatRecords
  973. return append(hooks[:len(hooks):len(hooks)], chatrecords.Hooks[:]...)
  974. }
  975. // Interceptors returns the client interceptors.
  976. func (c *ChatRecordsClient) Interceptors() []Interceptor {
  977. inters := c.inters.ChatRecords
  978. return append(inters[:len(inters):len(inters)], chatrecords.Interceptors[:]...)
  979. }
  980. func (c *ChatRecordsClient) mutate(ctx context.Context, m *ChatRecordsMutation) (Value, error) {
  981. switch m.Op() {
  982. case OpCreate:
  983. return (&ChatRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  984. case OpUpdate:
  985. return (&ChatRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  986. case OpUpdateOne:
  987. return (&ChatRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  988. case OpDelete, OpDeleteOne:
  989. return (&ChatRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  990. default:
  991. return nil, fmt.Errorf("ent: unknown ChatRecords mutation op: %q", m.Op())
  992. }
  993. }
  994. // ChatSessionClient is a client for the ChatSession schema.
  995. type ChatSessionClient struct {
  996. config
  997. }
  998. // NewChatSessionClient returns a client for the ChatSession from the given config.
  999. func NewChatSessionClient(c config) *ChatSessionClient {
  1000. return &ChatSessionClient{config: c}
  1001. }
  1002. // Use adds a list of mutation hooks to the hooks stack.
  1003. // A call to `Use(f, g, h)` equals to `chatsession.Hooks(f(g(h())))`.
  1004. func (c *ChatSessionClient) Use(hooks ...Hook) {
  1005. c.hooks.ChatSession = append(c.hooks.ChatSession, hooks...)
  1006. }
  1007. // Intercept adds a list of query interceptors to the interceptors stack.
  1008. // A call to `Intercept(f, g, h)` equals to `chatsession.Intercept(f(g(h())))`.
  1009. func (c *ChatSessionClient) Intercept(interceptors ...Interceptor) {
  1010. c.inters.ChatSession = append(c.inters.ChatSession, interceptors...)
  1011. }
  1012. // Create returns a builder for creating a ChatSession entity.
  1013. func (c *ChatSessionClient) Create() *ChatSessionCreate {
  1014. mutation := newChatSessionMutation(c.config, OpCreate)
  1015. return &ChatSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1016. }
  1017. // CreateBulk returns a builder for creating a bulk of ChatSession entities.
  1018. func (c *ChatSessionClient) CreateBulk(builders ...*ChatSessionCreate) *ChatSessionCreateBulk {
  1019. return &ChatSessionCreateBulk{config: c.config, builders: builders}
  1020. }
  1021. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1022. // a builder and applies setFunc on it.
  1023. func (c *ChatSessionClient) MapCreateBulk(slice any, setFunc func(*ChatSessionCreate, int)) *ChatSessionCreateBulk {
  1024. rv := reflect.ValueOf(slice)
  1025. if rv.Kind() != reflect.Slice {
  1026. return &ChatSessionCreateBulk{err: fmt.Errorf("calling to ChatSessionClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1027. }
  1028. builders := make([]*ChatSessionCreate, rv.Len())
  1029. for i := 0; i < rv.Len(); i++ {
  1030. builders[i] = c.Create()
  1031. setFunc(builders[i], i)
  1032. }
  1033. return &ChatSessionCreateBulk{config: c.config, builders: builders}
  1034. }
  1035. // Update returns an update builder for ChatSession.
  1036. func (c *ChatSessionClient) Update() *ChatSessionUpdate {
  1037. mutation := newChatSessionMutation(c.config, OpUpdate)
  1038. return &ChatSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1039. }
  1040. // UpdateOne returns an update builder for the given entity.
  1041. func (c *ChatSessionClient) UpdateOne(cs *ChatSession) *ChatSessionUpdateOne {
  1042. mutation := newChatSessionMutation(c.config, OpUpdateOne, withChatSession(cs))
  1043. return &ChatSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1044. }
  1045. // UpdateOneID returns an update builder for the given id.
  1046. func (c *ChatSessionClient) UpdateOneID(id uint64) *ChatSessionUpdateOne {
  1047. mutation := newChatSessionMutation(c.config, OpUpdateOne, withChatSessionID(id))
  1048. return &ChatSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1049. }
  1050. // Delete returns a delete builder for ChatSession.
  1051. func (c *ChatSessionClient) Delete() *ChatSessionDelete {
  1052. mutation := newChatSessionMutation(c.config, OpDelete)
  1053. return &ChatSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1054. }
  1055. // DeleteOne returns a builder for deleting the given entity.
  1056. func (c *ChatSessionClient) DeleteOne(cs *ChatSession) *ChatSessionDeleteOne {
  1057. return c.DeleteOneID(cs.ID)
  1058. }
  1059. // DeleteOneID returns a builder for deleting the given entity by its id.
  1060. func (c *ChatSessionClient) DeleteOneID(id uint64) *ChatSessionDeleteOne {
  1061. builder := c.Delete().Where(chatsession.ID(id))
  1062. builder.mutation.id = &id
  1063. builder.mutation.op = OpDeleteOne
  1064. return &ChatSessionDeleteOne{builder}
  1065. }
  1066. // Query returns a query builder for ChatSession.
  1067. func (c *ChatSessionClient) Query() *ChatSessionQuery {
  1068. return &ChatSessionQuery{
  1069. config: c.config,
  1070. ctx: &QueryContext{Type: TypeChatSession},
  1071. inters: c.Interceptors(),
  1072. }
  1073. }
  1074. // Get returns a ChatSession entity by its id.
  1075. func (c *ChatSessionClient) Get(ctx context.Context, id uint64) (*ChatSession, error) {
  1076. return c.Query().Where(chatsession.ID(id)).Only(ctx)
  1077. }
  1078. // GetX is like Get, but panics if an error occurs.
  1079. func (c *ChatSessionClient) GetX(ctx context.Context, id uint64) *ChatSession {
  1080. obj, err := c.Get(ctx, id)
  1081. if err != nil {
  1082. panic(err)
  1083. }
  1084. return obj
  1085. }
  1086. // Hooks returns the client hooks.
  1087. func (c *ChatSessionClient) Hooks() []Hook {
  1088. hooks := c.hooks.ChatSession
  1089. return append(hooks[:len(hooks):len(hooks)], chatsession.Hooks[:]...)
  1090. }
  1091. // Interceptors returns the client interceptors.
  1092. func (c *ChatSessionClient) Interceptors() []Interceptor {
  1093. inters := c.inters.ChatSession
  1094. return append(inters[:len(inters):len(inters)], chatsession.Interceptors[:]...)
  1095. }
  1096. func (c *ChatSessionClient) mutate(ctx context.Context, m *ChatSessionMutation) (Value, error) {
  1097. switch m.Op() {
  1098. case OpCreate:
  1099. return (&ChatSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1100. case OpUpdate:
  1101. return (&ChatSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1102. case OpUpdateOne:
  1103. return (&ChatSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1104. case OpDelete, OpDeleteOne:
  1105. return (&ChatSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1106. default:
  1107. return nil, fmt.Errorf("ent: unknown ChatSession mutation op: %q", m.Op())
  1108. }
  1109. }
  1110. // ContactClient is a client for the Contact schema.
  1111. type ContactClient struct {
  1112. config
  1113. }
  1114. // NewContactClient returns a client for the Contact from the given config.
  1115. func NewContactClient(c config) *ContactClient {
  1116. return &ContactClient{config: c}
  1117. }
  1118. // Use adds a list of mutation hooks to the hooks stack.
  1119. // A call to `Use(f, g, h)` equals to `contact.Hooks(f(g(h())))`.
  1120. func (c *ContactClient) Use(hooks ...Hook) {
  1121. c.hooks.Contact = append(c.hooks.Contact, hooks...)
  1122. }
  1123. // Intercept adds a list of query interceptors to the interceptors stack.
  1124. // A call to `Intercept(f, g, h)` equals to `contact.Intercept(f(g(h())))`.
  1125. func (c *ContactClient) Intercept(interceptors ...Interceptor) {
  1126. c.inters.Contact = append(c.inters.Contact, interceptors...)
  1127. }
  1128. // Create returns a builder for creating a Contact entity.
  1129. func (c *ContactClient) Create() *ContactCreate {
  1130. mutation := newContactMutation(c.config, OpCreate)
  1131. return &ContactCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1132. }
  1133. // CreateBulk returns a builder for creating a bulk of Contact entities.
  1134. func (c *ContactClient) CreateBulk(builders ...*ContactCreate) *ContactCreateBulk {
  1135. return &ContactCreateBulk{config: c.config, builders: builders}
  1136. }
  1137. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1138. // a builder and applies setFunc on it.
  1139. func (c *ContactClient) MapCreateBulk(slice any, setFunc func(*ContactCreate, int)) *ContactCreateBulk {
  1140. rv := reflect.ValueOf(slice)
  1141. if rv.Kind() != reflect.Slice {
  1142. return &ContactCreateBulk{err: fmt.Errorf("calling to ContactClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1143. }
  1144. builders := make([]*ContactCreate, rv.Len())
  1145. for i := 0; i < rv.Len(); i++ {
  1146. builders[i] = c.Create()
  1147. setFunc(builders[i], i)
  1148. }
  1149. return &ContactCreateBulk{config: c.config, builders: builders}
  1150. }
  1151. // Update returns an update builder for Contact.
  1152. func (c *ContactClient) Update() *ContactUpdate {
  1153. mutation := newContactMutation(c.config, OpUpdate)
  1154. return &ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1155. }
  1156. // UpdateOne returns an update builder for the given entity.
  1157. func (c *ContactClient) UpdateOne(co *Contact) *ContactUpdateOne {
  1158. mutation := newContactMutation(c.config, OpUpdateOne, withContact(co))
  1159. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1160. }
  1161. // UpdateOneID returns an update builder for the given id.
  1162. func (c *ContactClient) UpdateOneID(id uint64) *ContactUpdateOne {
  1163. mutation := newContactMutation(c.config, OpUpdateOne, withContactID(id))
  1164. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1165. }
  1166. // Delete returns a delete builder for Contact.
  1167. func (c *ContactClient) Delete() *ContactDelete {
  1168. mutation := newContactMutation(c.config, OpDelete)
  1169. return &ContactDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1170. }
  1171. // DeleteOne returns a builder for deleting the given entity.
  1172. func (c *ContactClient) DeleteOne(co *Contact) *ContactDeleteOne {
  1173. return c.DeleteOneID(co.ID)
  1174. }
  1175. // DeleteOneID returns a builder for deleting the given entity by its id.
  1176. func (c *ContactClient) DeleteOneID(id uint64) *ContactDeleteOne {
  1177. builder := c.Delete().Where(contact.ID(id))
  1178. builder.mutation.id = &id
  1179. builder.mutation.op = OpDeleteOne
  1180. return &ContactDeleteOne{builder}
  1181. }
  1182. // Query returns a query builder for Contact.
  1183. func (c *ContactClient) Query() *ContactQuery {
  1184. return &ContactQuery{
  1185. config: c.config,
  1186. ctx: &QueryContext{Type: TypeContact},
  1187. inters: c.Interceptors(),
  1188. }
  1189. }
  1190. // Get returns a Contact entity by its id.
  1191. func (c *ContactClient) Get(ctx context.Context, id uint64) (*Contact, error) {
  1192. return c.Query().Where(contact.ID(id)).Only(ctx)
  1193. }
  1194. // GetX is like Get, but panics if an error occurs.
  1195. func (c *ContactClient) GetX(ctx context.Context, id uint64) *Contact {
  1196. obj, err := c.Get(ctx, id)
  1197. if err != nil {
  1198. panic(err)
  1199. }
  1200. return obj
  1201. }
  1202. // QueryContactRelationships queries the contact_relationships edge of a Contact.
  1203. func (c *ContactClient) QueryContactRelationships(co *Contact) *LabelRelationshipQuery {
  1204. query := (&LabelRelationshipClient{config: c.config}).Query()
  1205. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1206. id := co.ID
  1207. step := sqlgraph.NewStep(
  1208. sqlgraph.From(contact.Table, contact.FieldID, id),
  1209. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  1210. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactRelationshipsTable, contact.ContactRelationshipsColumn),
  1211. )
  1212. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  1213. return fromV, nil
  1214. }
  1215. return query
  1216. }
  1217. // QueryContactMessages queries the contact_messages edge of a Contact.
  1218. func (c *ContactClient) QueryContactMessages(co *Contact) *MessageRecordsQuery {
  1219. query := (&MessageRecordsClient{config: c.config}).Query()
  1220. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1221. id := co.ID
  1222. step := sqlgraph.NewStep(
  1223. sqlgraph.From(contact.Table, contact.FieldID, id),
  1224. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  1225. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactMessagesTable, contact.ContactMessagesColumn),
  1226. )
  1227. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  1228. return fromV, nil
  1229. }
  1230. return query
  1231. }
  1232. // Hooks returns the client hooks.
  1233. func (c *ContactClient) Hooks() []Hook {
  1234. hooks := c.hooks.Contact
  1235. return append(hooks[:len(hooks):len(hooks)], contact.Hooks[:]...)
  1236. }
  1237. // Interceptors returns the client interceptors.
  1238. func (c *ContactClient) Interceptors() []Interceptor {
  1239. inters := c.inters.Contact
  1240. return append(inters[:len(inters):len(inters)], contact.Interceptors[:]...)
  1241. }
  1242. func (c *ContactClient) mutate(ctx context.Context, m *ContactMutation) (Value, error) {
  1243. switch m.Op() {
  1244. case OpCreate:
  1245. return (&ContactCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1246. case OpUpdate:
  1247. return (&ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1248. case OpUpdateOne:
  1249. return (&ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1250. case OpDelete, OpDeleteOne:
  1251. return (&ContactDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1252. default:
  1253. return nil, fmt.Errorf("ent: unknown Contact mutation op: %q", m.Op())
  1254. }
  1255. }
  1256. // EmployeeClient is a client for the Employee schema.
  1257. type EmployeeClient struct {
  1258. config
  1259. }
  1260. // NewEmployeeClient returns a client for the Employee from the given config.
  1261. func NewEmployeeClient(c config) *EmployeeClient {
  1262. return &EmployeeClient{config: c}
  1263. }
  1264. // Use adds a list of mutation hooks to the hooks stack.
  1265. // A call to `Use(f, g, h)` equals to `employee.Hooks(f(g(h())))`.
  1266. func (c *EmployeeClient) Use(hooks ...Hook) {
  1267. c.hooks.Employee = append(c.hooks.Employee, hooks...)
  1268. }
  1269. // Intercept adds a list of query interceptors to the interceptors stack.
  1270. // A call to `Intercept(f, g, h)` equals to `employee.Intercept(f(g(h())))`.
  1271. func (c *EmployeeClient) Intercept(interceptors ...Interceptor) {
  1272. c.inters.Employee = append(c.inters.Employee, interceptors...)
  1273. }
  1274. // Create returns a builder for creating a Employee entity.
  1275. func (c *EmployeeClient) Create() *EmployeeCreate {
  1276. mutation := newEmployeeMutation(c.config, OpCreate)
  1277. return &EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1278. }
  1279. // CreateBulk returns a builder for creating a bulk of Employee entities.
  1280. func (c *EmployeeClient) CreateBulk(builders ...*EmployeeCreate) *EmployeeCreateBulk {
  1281. return &EmployeeCreateBulk{config: c.config, builders: builders}
  1282. }
  1283. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1284. // a builder and applies setFunc on it.
  1285. func (c *EmployeeClient) MapCreateBulk(slice any, setFunc func(*EmployeeCreate, int)) *EmployeeCreateBulk {
  1286. rv := reflect.ValueOf(slice)
  1287. if rv.Kind() != reflect.Slice {
  1288. return &EmployeeCreateBulk{err: fmt.Errorf("calling to EmployeeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1289. }
  1290. builders := make([]*EmployeeCreate, rv.Len())
  1291. for i := 0; i < rv.Len(); i++ {
  1292. builders[i] = c.Create()
  1293. setFunc(builders[i], i)
  1294. }
  1295. return &EmployeeCreateBulk{config: c.config, builders: builders}
  1296. }
  1297. // Update returns an update builder for Employee.
  1298. func (c *EmployeeClient) Update() *EmployeeUpdate {
  1299. mutation := newEmployeeMutation(c.config, OpUpdate)
  1300. return &EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1301. }
  1302. // UpdateOne returns an update builder for the given entity.
  1303. func (c *EmployeeClient) UpdateOne(e *Employee) *EmployeeUpdateOne {
  1304. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployee(e))
  1305. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1306. }
  1307. // UpdateOneID returns an update builder for the given id.
  1308. func (c *EmployeeClient) UpdateOneID(id uint64) *EmployeeUpdateOne {
  1309. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployeeID(id))
  1310. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1311. }
  1312. // Delete returns a delete builder for Employee.
  1313. func (c *EmployeeClient) Delete() *EmployeeDelete {
  1314. mutation := newEmployeeMutation(c.config, OpDelete)
  1315. return &EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1316. }
  1317. // DeleteOne returns a builder for deleting the given entity.
  1318. func (c *EmployeeClient) DeleteOne(e *Employee) *EmployeeDeleteOne {
  1319. return c.DeleteOneID(e.ID)
  1320. }
  1321. // DeleteOneID returns a builder for deleting the given entity by its id.
  1322. func (c *EmployeeClient) DeleteOneID(id uint64) *EmployeeDeleteOne {
  1323. builder := c.Delete().Where(employee.ID(id))
  1324. builder.mutation.id = &id
  1325. builder.mutation.op = OpDeleteOne
  1326. return &EmployeeDeleteOne{builder}
  1327. }
  1328. // Query returns a query builder for Employee.
  1329. func (c *EmployeeClient) Query() *EmployeeQuery {
  1330. return &EmployeeQuery{
  1331. config: c.config,
  1332. ctx: &QueryContext{Type: TypeEmployee},
  1333. inters: c.Interceptors(),
  1334. }
  1335. }
  1336. // Get returns a Employee entity by its id.
  1337. func (c *EmployeeClient) Get(ctx context.Context, id uint64) (*Employee, error) {
  1338. return c.Query().Where(employee.ID(id)).Only(ctx)
  1339. }
  1340. // GetX is like Get, but panics if an error occurs.
  1341. func (c *EmployeeClient) GetX(ctx context.Context, id uint64) *Employee {
  1342. obj, err := c.Get(ctx, id)
  1343. if err != nil {
  1344. panic(err)
  1345. }
  1346. return obj
  1347. }
  1348. // QueryEmWorkExperiences queries the em_work_experiences edge of a Employee.
  1349. func (c *EmployeeClient) QueryEmWorkExperiences(e *Employee) *WorkExperienceQuery {
  1350. query := (&WorkExperienceClient{config: c.config}).Query()
  1351. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1352. id := e.ID
  1353. step := sqlgraph.NewStep(
  1354. sqlgraph.From(employee.Table, employee.FieldID, id),
  1355. sqlgraph.To(workexperience.Table, workexperience.FieldID),
  1356. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmWorkExperiencesTable, employee.EmWorkExperiencesColumn),
  1357. )
  1358. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  1359. return fromV, nil
  1360. }
  1361. return query
  1362. }
  1363. // QueryEmTutorial queries the em_tutorial edge of a Employee.
  1364. func (c *EmployeeClient) QueryEmTutorial(e *Employee) *TutorialQuery {
  1365. query := (&TutorialClient{config: c.config}).Query()
  1366. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1367. id := e.ID
  1368. step := sqlgraph.NewStep(
  1369. sqlgraph.From(employee.Table, employee.FieldID, id),
  1370. sqlgraph.To(tutorial.Table, tutorial.FieldID),
  1371. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmTutorialTable, employee.EmTutorialColumn),
  1372. )
  1373. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  1374. return fromV, nil
  1375. }
  1376. return query
  1377. }
  1378. // Hooks returns the client hooks.
  1379. func (c *EmployeeClient) Hooks() []Hook {
  1380. hooks := c.hooks.Employee
  1381. return append(hooks[:len(hooks):len(hooks)], employee.Hooks[:]...)
  1382. }
  1383. // Interceptors returns the client interceptors.
  1384. func (c *EmployeeClient) Interceptors() []Interceptor {
  1385. inters := c.inters.Employee
  1386. return append(inters[:len(inters):len(inters)], employee.Interceptors[:]...)
  1387. }
  1388. func (c *EmployeeClient) mutate(ctx context.Context, m *EmployeeMutation) (Value, error) {
  1389. switch m.Op() {
  1390. case OpCreate:
  1391. return (&EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1392. case OpUpdate:
  1393. return (&EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1394. case OpUpdateOne:
  1395. return (&EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1396. case OpDelete, OpDeleteOne:
  1397. return (&EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1398. default:
  1399. return nil, fmt.Errorf("ent: unknown Employee mutation op: %q", m.Op())
  1400. }
  1401. }
  1402. // EmployeeConfigClient is a client for the EmployeeConfig schema.
  1403. type EmployeeConfigClient struct {
  1404. config
  1405. }
  1406. // NewEmployeeConfigClient returns a client for the EmployeeConfig from the given config.
  1407. func NewEmployeeConfigClient(c config) *EmployeeConfigClient {
  1408. return &EmployeeConfigClient{config: c}
  1409. }
  1410. // Use adds a list of mutation hooks to the hooks stack.
  1411. // A call to `Use(f, g, h)` equals to `employeeconfig.Hooks(f(g(h())))`.
  1412. func (c *EmployeeConfigClient) Use(hooks ...Hook) {
  1413. c.hooks.EmployeeConfig = append(c.hooks.EmployeeConfig, hooks...)
  1414. }
  1415. // Intercept adds a list of query interceptors to the interceptors stack.
  1416. // A call to `Intercept(f, g, h)` equals to `employeeconfig.Intercept(f(g(h())))`.
  1417. func (c *EmployeeConfigClient) Intercept(interceptors ...Interceptor) {
  1418. c.inters.EmployeeConfig = append(c.inters.EmployeeConfig, interceptors...)
  1419. }
  1420. // Create returns a builder for creating a EmployeeConfig entity.
  1421. func (c *EmployeeConfigClient) Create() *EmployeeConfigCreate {
  1422. mutation := newEmployeeConfigMutation(c.config, OpCreate)
  1423. return &EmployeeConfigCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1424. }
  1425. // CreateBulk returns a builder for creating a bulk of EmployeeConfig entities.
  1426. func (c *EmployeeConfigClient) CreateBulk(builders ...*EmployeeConfigCreate) *EmployeeConfigCreateBulk {
  1427. return &EmployeeConfigCreateBulk{config: c.config, builders: builders}
  1428. }
  1429. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1430. // a builder and applies setFunc on it.
  1431. func (c *EmployeeConfigClient) MapCreateBulk(slice any, setFunc func(*EmployeeConfigCreate, int)) *EmployeeConfigCreateBulk {
  1432. rv := reflect.ValueOf(slice)
  1433. if rv.Kind() != reflect.Slice {
  1434. return &EmployeeConfigCreateBulk{err: fmt.Errorf("calling to EmployeeConfigClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1435. }
  1436. builders := make([]*EmployeeConfigCreate, rv.Len())
  1437. for i := 0; i < rv.Len(); i++ {
  1438. builders[i] = c.Create()
  1439. setFunc(builders[i], i)
  1440. }
  1441. return &EmployeeConfigCreateBulk{config: c.config, builders: builders}
  1442. }
  1443. // Update returns an update builder for EmployeeConfig.
  1444. func (c *EmployeeConfigClient) Update() *EmployeeConfigUpdate {
  1445. mutation := newEmployeeConfigMutation(c.config, OpUpdate)
  1446. return &EmployeeConfigUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1447. }
  1448. // UpdateOne returns an update builder for the given entity.
  1449. func (c *EmployeeConfigClient) UpdateOne(ec *EmployeeConfig) *EmployeeConfigUpdateOne {
  1450. mutation := newEmployeeConfigMutation(c.config, OpUpdateOne, withEmployeeConfig(ec))
  1451. return &EmployeeConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1452. }
  1453. // UpdateOneID returns an update builder for the given id.
  1454. func (c *EmployeeConfigClient) UpdateOneID(id uint64) *EmployeeConfigUpdateOne {
  1455. mutation := newEmployeeConfigMutation(c.config, OpUpdateOne, withEmployeeConfigID(id))
  1456. return &EmployeeConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1457. }
  1458. // Delete returns a delete builder for EmployeeConfig.
  1459. func (c *EmployeeConfigClient) Delete() *EmployeeConfigDelete {
  1460. mutation := newEmployeeConfigMutation(c.config, OpDelete)
  1461. return &EmployeeConfigDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1462. }
  1463. // DeleteOne returns a builder for deleting the given entity.
  1464. func (c *EmployeeConfigClient) DeleteOne(ec *EmployeeConfig) *EmployeeConfigDeleteOne {
  1465. return c.DeleteOneID(ec.ID)
  1466. }
  1467. // DeleteOneID returns a builder for deleting the given entity by its id.
  1468. func (c *EmployeeConfigClient) DeleteOneID(id uint64) *EmployeeConfigDeleteOne {
  1469. builder := c.Delete().Where(employeeconfig.ID(id))
  1470. builder.mutation.id = &id
  1471. builder.mutation.op = OpDeleteOne
  1472. return &EmployeeConfigDeleteOne{builder}
  1473. }
  1474. // Query returns a query builder for EmployeeConfig.
  1475. func (c *EmployeeConfigClient) Query() *EmployeeConfigQuery {
  1476. return &EmployeeConfigQuery{
  1477. config: c.config,
  1478. ctx: &QueryContext{Type: TypeEmployeeConfig},
  1479. inters: c.Interceptors(),
  1480. }
  1481. }
  1482. // Get returns a EmployeeConfig entity by its id.
  1483. func (c *EmployeeConfigClient) Get(ctx context.Context, id uint64) (*EmployeeConfig, error) {
  1484. return c.Query().Where(employeeconfig.ID(id)).Only(ctx)
  1485. }
  1486. // GetX is like Get, but panics if an error occurs.
  1487. func (c *EmployeeConfigClient) GetX(ctx context.Context, id uint64) *EmployeeConfig {
  1488. obj, err := c.Get(ctx, id)
  1489. if err != nil {
  1490. panic(err)
  1491. }
  1492. return obj
  1493. }
  1494. // Hooks returns the client hooks.
  1495. func (c *EmployeeConfigClient) Hooks() []Hook {
  1496. hooks := c.hooks.EmployeeConfig
  1497. return append(hooks[:len(hooks):len(hooks)], employeeconfig.Hooks[:]...)
  1498. }
  1499. // Interceptors returns the client interceptors.
  1500. func (c *EmployeeConfigClient) Interceptors() []Interceptor {
  1501. inters := c.inters.EmployeeConfig
  1502. return append(inters[:len(inters):len(inters)], employeeconfig.Interceptors[:]...)
  1503. }
  1504. func (c *EmployeeConfigClient) mutate(ctx context.Context, m *EmployeeConfigMutation) (Value, error) {
  1505. switch m.Op() {
  1506. case OpCreate:
  1507. return (&EmployeeConfigCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1508. case OpUpdate:
  1509. return (&EmployeeConfigUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1510. case OpUpdateOne:
  1511. return (&EmployeeConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1512. case OpDelete, OpDeleteOne:
  1513. return (&EmployeeConfigDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1514. default:
  1515. return nil, fmt.Errorf("ent: unknown EmployeeConfig mutation op: %q", m.Op())
  1516. }
  1517. }
  1518. // LabelClient is a client for the Label schema.
  1519. type LabelClient struct {
  1520. config
  1521. }
  1522. // NewLabelClient returns a client for the Label from the given config.
  1523. func NewLabelClient(c config) *LabelClient {
  1524. return &LabelClient{config: c}
  1525. }
  1526. // Use adds a list of mutation hooks to the hooks stack.
  1527. // A call to `Use(f, g, h)` equals to `label.Hooks(f(g(h())))`.
  1528. func (c *LabelClient) Use(hooks ...Hook) {
  1529. c.hooks.Label = append(c.hooks.Label, hooks...)
  1530. }
  1531. // Intercept adds a list of query interceptors to the interceptors stack.
  1532. // A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
  1533. func (c *LabelClient) Intercept(interceptors ...Interceptor) {
  1534. c.inters.Label = append(c.inters.Label, interceptors...)
  1535. }
  1536. // Create returns a builder for creating a Label entity.
  1537. func (c *LabelClient) Create() *LabelCreate {
  1538. mutation := newLabelMutation(c.config, OpCreate)
  1539. return &LabelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1540. }
  1541. // CreateBulk returns a builder for creating a bulk of Label entities.
  1542. func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk {
  1543. return &LabelCreateBulk{config: c.config, builders: builders}
  1544. }
  1545. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1546. // a builder and applies setFunc on it.
  1547. func (c *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk {
  1548. rv := reflect.ValueOf(slice)
  1549. if rv.Kind() != reflect.Slice {
  1550. return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1551. }
  1552. builders := make([]*LabelCreate, rv.Len())
  1553. for i := 0; i < rv.Len(); i++ {
  1554. builders[i] = c.Create()
  1555. setFunc(builders[i], i)
  1556. }
  1557. return &LabelCreateBulk{config: c.config, builders: builders}
  1558. }
  1559. // Update returns an update builder for Label.
  1560. func (c *LabelClient) Update() *LabelUpdate {
  1561. mutation := newLabelMutation(c.config, OpUpdate)
  1562. return &LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1563. }
  1564. // UpdateOne returns an update builder for the given entity.
  1565. func (c *LabelClient) UpdateOne(l *Label) *LabelUpdateOne {
  1566. mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(l))
  1567. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1568. }
  1569. // UpdateOneID returns an update builder for the given id.
  1570. func (c *LabelClient) UpdateOneID(id uint64) *LabelUpdateOne {
  1571. mutation := newLabelMutation(c.config, OpUpdateOne, withLabelID(id))
  1572. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1573. }
  1574. // Delete returns a delete builder for Label.
  1575. func (c *LabelClient) Delete() *LabelDelete {
  1576. mutation := newLabelMutation(c.config, OpDelete)
  1577. return &LabelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1578. }
  1579. // DeleteOne returns a builder for deleting the given entity.
  1580. func (c *LabelClient) DeleteOne(l *Label) *LabelDeleteOne {
  1581. return c.DeleteOneID(l.ID)
  1582. }
  1583. // DeleteOneID returns a builder for deleting the given entity by its id.
  1584. func (c *LabelClient) DeleteOneID(id uint64) *LabelDeleteOne {
  1585. builder := c.Delete().Where(label.ID(id))
  1586. builder.mutation.id = &id
  1587. builder.mutation.op = OpDeleteOne
  1588. return &LabelDeleteOne{builder}
  1589. }
  1590. // Query returns a query builder for Label.
  1591. func (c *LabelClient) Query() *LabelQuery {
  1592. return &LabelQuery{
  1593. config: c.config,
  1594. ctx: &QueryContext{Type: TypeLabel},
  1595. inters: c.Interceptors(),
  1596. }
  1597. }
  1598. // Get returns a Label entity by its id.
  1599. func (c *LabelClient) Get(ctx context.Context, id uint64) (*Label, error) {
  1600. return c.Query().Where(label.ID(id)).Only(ctx)
  1601. }
  1602. // GetX is like Get, but panics if an error occurs.
  1603. func (c *LabelClient) GetX(ctx context.Context, id uint64) *Label {
  1604. obj, err := c.Get(ctx, id)
  1605. if err != nil {
  1606. panic(err)
  1607. }
  1608. return obj
  1609. }
  1610. // QueryLabelRelationships queries the label_relationships edge of a Label.
  1611. func (c *LabelClient) QueryLabelRelationships(l *Label) *LabelRelationshipQuery {
  1612. query := (&LabelRelationshipClient{config: c.config}).Query()
  1613. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1614. id := l.ID
  1615. step := sqlgraph.NewStep(
  1616. sqlgraph.From(label.Table, label.FieldID, id),
  1617. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  1618. sqlgraph.Edge(sqlgraph.O2M, false, label.LabelRelationshipsTable, label.LabelRelationshipsColumn),
  1619. )
  1620. fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
  1621. return fromV, nil
  1622. }
  1623. return query
  1624. }
  1625. // Hooks returns the client hooks.
  1626. func (c *LabelClient) Hooks() []Hook {
  1627. return c.hooks.Label
  1628. }
  1629. // Interceptors returns the client interceptors.
  1630. func (c *LabelClient) Interceptors() []Interceptor {
  1631. return c.inters.Label
  1632. }
  1633. func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
  1634. switch m.Op() {
  1635. case OpCreate:
  1636. return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1637. case OpUpdate:
  1638. return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1639. case OpUpdateOne:
  1640. return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1641. case OpDelete, OpDeleteOne:
  1642. return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1643. default:
  1644. return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
  1645. }
  1646. }
  1647. // LabelRelationshipClient is a client for the LabelRelationship schema.
  1648. type LabelRelationshipClient struct {
  1649. config
  1650. }
  1651. // NewLabelRelationshipClient returns a client for the LabelRelationship from the given config.
  1652. func NewLabelRelationshipClient(c config) *LabelRelationshipClient {
  1653. return &LabelRelationshipClient{config: c}
  1654. }
  1655. // Use adds a list of mutation hooks to the hooks stack.
  1656. // A call to `Use(f, g, h)` equals to `labelrelationship.Hooks(f(g(h())))`.
  1657. func (c *LabelRelationshipClient) Use(hooks ...Hook) {
  1658. c.hooks.LabelRelationship = append(c.hooks.LabelRelationship, hooks...)
  1659. }
  1660. // Intercept adds a list of query interceptors to the interceptors stack.
  1661. // A call to `Intercept(f, g, h)` equals to `labelrelationship.Intercept(f(g(h())))`.
  1662. func (c *LabelRelationshipClient) Intercept(interceptors ...Interceptor) {
  1663. c.inters.LabelRelationship = append(c.inters.LabelRelationship, interceptors...)
  1664. }
  1665. // Create returns a builder for creating a LabelRelationship entity.
  1666. func (c *LabelRelationshipClient) Create() *LabelRelationshipCreate {
  1667. mutation := newLabelRelationshipMutation(c.config, OpCreate)
  1668. return &LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1669. }
  1670. // CreateBulk returns a builder for creating a bulk of LabelRelationship entities.
  1671. func (c *LabelRelationshipClient) CreateBulk(builders ...*LabelRelationshipCreate) *LabelRelationshipCreateBulk {
  1672. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1673. }
  1674. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1675. // a builder and applies setFunc on it.
  1676. func (c *LabelRelationshipClient) MapCreateBulk(slice any, setFunc func(*LabelRelationshipCreate, int)) *LabelRelationshipCreateBulk {
  1677. rv := reflect.ValueOf(slice)
  1678. if rv.Kind() != reflect.Slice {
  1679. return &LabelRelationshipCreateBulk{err: fmt.Errorf("calling to LabelRelationshipClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1680. }
  1681. builders := make([]*LabelRelationshipCreate, rv.Len())
  1682. for i := 0; i < rv.Len(); i++ {
  1683. builders[i] = c.Create()
  1684. setFunc(builders[i], i)
  1685. }
  1686. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1687. }
  1688. // Update returns an update builder for LabelRelationship.
  1689. func (c *LabelRelationshipClient) Update() *LabelRelationshipUpdate {
  1690. mutation := newLabelRelationshipMutation(c.config, OpUpdate)
  1691. return &LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1692. }
  1693. // UpdateOne returns an update builder for the given entity.
  1694. func (c *LabelRelationshipClient) UpdateOne(lr *LabelRelationship) *LabelRelationshipUpdateOne {
  1695. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationship(lr))
  1696. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1697. }
  1698. // UpdateOneID returns an update builder for the given id.
  1699. func (c *LabelRelationshipClient) UpdateOneID(id uint64) *LabelRelationshipUpdateOne {
  1700. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationshipID(id))
  1701. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1702. }
  1703. // Delete returns a delete builder for LabelRelationship.
  1704. func (c *LabelRelationshipClient) Delete() *LabelRelationshipDelete {
  1705. mutation := newLabelRelationshipMutation(c.config, OpDelete)
  1706. return &LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1707. }
  1708. // DeleteOne returns a builder for deleting the given entity.
  1709. func (c *LabelRelationshipClient) DeleteOne(lr *LabelRelationship) *LabelRelationshipDeleteOne {
  1710. return c.DeleteOneID(lr.ID)
  1711. }
  1712. // DeleteOneID returns a builder for deleting the given entity by its id.
  1713. func (c *LabelRelationshipClient) DeleteOneID(id uint64) *LabelRelationshipDeleteOne {
  1714. builder := c.Delete().Where(labelrelationship.ID(id))
  1715. builder.mutation.id = &id
  1716. builder.mutation.op = OpDeleteOne
  1717. return &LabelRelationshipDeleteOne{builder}
  1718. }
  1719. // Query returns a query builder for LabelRelationship.
  1720. func (c *LabelRelationshipClient) Query() *LabelRelationshipQuery {
  1721. return &LabelRelationshipQuery{
  1722. config: c.config,
  1723. ctx: &QueryContext{Type: TypeLabelRelationship},
  1724. inters: c.Interceptors(),
  1725. }
  1726. }
  1727. // Get returns a LabelRelationship entity by its id.
  1728. func (c *LabelRelationshipClient) Get(ctx context.Context, id uint64) (*LabelRelationship, error) {
  1729. return c.Query().Where(labelrelationship.ID(id)).Only(ctx)
  1730. }
  1731. // GetX is like Get, but panics if an error occurs.
  1732. func (c *LabelRelationshipClient) GetX(ctx context.Context, id uint64) *LabelRelationship {
  1733. obj, err := c.Get(ctx, id)
  1734. if err != nil {
  1735. panic(err)
  1736. }
  1737. return obj
  1738. }
  1739. // QueryContacts queries the contacts edge of a LabelRelationship.
  1740. func (c *LabelRelationshipClient) QueryContacts(lr *LabelRelationship) *ContactQuery {
  1741. query := (&ContactClient{config: c.config}).Query()
  1742. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1743. id := lr.ID
  1744. step := sqlgraph.NewStep(
  1745. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1746. sqlgraph.To(contact.Table, contact.FieldID),
  1747. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.ContactsTable, labelrelationship.ContactsColumn),
  1748. )
  1749. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1750. return fromV, nil
  1751. }
  1752. return query
  1753. }
  1754. // QueryLabels queries the labels edge of a LabelRelationship.
  1755. func (c *LabelRelationshipClient) QueryLabels(lr *LabelRelationship) *LabelQuery {
  1756. query := (&LabelClient{config: c.config}).Query()
  1757. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1758. id := lr.ID
  1759. step := sqlgraph.NewStep(
  1760. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1761. sqlgraph.To(label.Table, label.FieldID),
  1762. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.LabelsTable, labelrelationship.LabelsColumn),
  1763. )
  1764. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1765. return fromV, nil
  1766. }
  1767. return query
  1768. }
  1769. // Hooks returns the client hooks.
  1770. func (c *LabelRelationshipClient) Hooks() []Hook {
  1771. hooks := c.hooks.LabelRelationship
  1772. return append(hooks[:len(hooks):len(hooks)], labelrelationship.Hooks[:]...)
  1773. }
  1774. // Interceptors returns the client interceptors.
  1775. func (c *LabelRelationshipClient) Interceptors() []Interceptor {
  1776. inters := c.inters.LabelRelationship
  1777. return append(inters[:len(inters):len(inters)], labelrelationship.Interceptors[:]...)
  1778. }
  1779. func (c *LabelRelationshipClient) mutate(ctx context.Context, m *LabelRelationshipMutation) (Value, error) {
  1780. switch m.Op() {
  1781. case OpCreate:
  1782. return (&LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1783. case OpUpdate:
  1784. return (&LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1785. case OpUpdateOne:
  1786. return (&LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1787. case OpDelete, OpDeleteOne:
  1788. return (&LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1789. default:
  1790. return nil, fmt.Errorf("ent: unknown LabelRelationship mutation op: %q", m.Op())
  1791. }
  1792. }
  1793. // MessageClient is a client for the Message schema.
  1794. type MessageClient struct {
  1795. config
  1796. }
  1797. // NewMessageClient returns a client for the Message from the given config.
  1798. func NewMessageClient(c config) *MessageClient {
  1799. return &MessageClient{config: c}
  1800. }
  1801. // Use adds a list of mutation hooks to the hooks stack.
  1802. // A call to `Use(f, g, h)` equals to `message.Hooks(f(g(h())))`.
  1803. func (c *MessageClient) Use(hooks ...Hook) {
  1804. c.hooks.Message = append(c.hooks.Message, hooks...)
  1805. }
  1806. // Intercept adds a list of query interceptors to the interceptors stack.
  1807. // A call to `Intercept(f, g, h)` equals to `message.Intercept(f(g(h())))`.
  1808. func (c *MessageClient) Intercept(interceptors ...Interceptor) {
  1809. c.inters.Message = append(c.inters.Message, interceptors...)
  1810. }
  1811. // Create returns a builder for creating a Message entity.
  1812. func (c *MessageClient) Create() *MessageCreate {
  1813. mutation := newMessageMutation(c.config, OpCreate)
  1814. return &MessageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1815. }
  1816. // CreateBulk returns a builder for creating a bulk of Message entities.
  1817. func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBulk {
  1818. return &MessageCreateBulk{config: c.config, builders: builders}
  1819. }
  1820. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1821. // a builder and applies setFunc on it.
  1822. func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk {
  1823. rv := reflect.ValueOf(slice)
  1824. if rv.Kind() != reflect.Slice {
  1825. return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1826. }
  1827. builders := make([]*MessageCreate, rv.Len())
  1828. for i := 0; i < rv.Len(); i++ {
  1829. builders[i] = c.Create()
  1830. setFunc(builders[i], i)
  1831. }
  1832. return &MessageCreateBulk{config: c.config, builders: builders}
  1833. }
  1834. // Update returns an update builder for Message.
  1835. func (c *MessageClient) Update() *MessageUpdate {
  1836. mutation := newMessageMutation(c.config, OpUpdate)
  1837. return &MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1838. }
  1839. // UpdateOne returns an update builder for the given entity.
  1840. func (c *MessageClient) UpdateOne(m *Message) *MessageUpdateOne {
  1841. mutation := newMessageMutation(c.config, OpUpdateOne, withMessage(m))
  1842. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1843. }
  1844. // UpdateOneID returns an update builder for the given id.
  1845. func (c *MessageClient) UpdateOneID(id int) *MessageUpdateOne {
  1846. mutation := newMessageMutation(c.config, OpUpdateOne, withMessageID(id))
  1847. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1848. }
  1849. // Delete returns a delete builder for Message.
  1850. func (c *MessageClient) Delete() *MessageDelete {
  1851. mutation := newMessageMutation(c.config, OpDelete)
  1852. return &MessageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1853. }
  1854. // DeleteOne returns a builder for deleting the given entity.
  1855. func (c *MessageClient) DeleteOne(m *Message) *MessageDeleteOne {
  1856. return c.DeleteOneID(m.ID)
  1857. }
  1858. // DeleteOneID returns a builder for deleting the given entity by its id.
  1859. func (c *MessageClient) DeleteOneID(id int) *MessageDeleteOne {
  1860. builder := c.Delete().Where(message.ID(id))
  1861. builder.mutation.id = &id
  1862. builder.mutation.op = OpDeleteOne
  1863. return &MessageDeleteOne{builder}
  1864. }
  1865. // Query returns a query builder for Message.
  1866. func (c *MessageClient) Query() *MessageQuery {
  1867. return &MessageQuery{
  1868. config: c.config,
  1869. ctx: &QueryContext{Type: TypeMessage},
  1870. inters: c.Interceptors(),
  1871. }
  1872. }
  1873. // Get returns a Message entity by its id.
  1874. func (c *MessageClient) Get(ctx context.Context, id int) (*Message, error) {
  1875. return c.Query().Where(message.ID(id)).Only(ctx)
  1876. }
  1877. // GetX is like Get, but panics if an error occurs.
  1878. func (c *MessageClient) GetX(ctx context.Context, id int) *Message {
  1879. obj, err := c.Get(ctx, id)
  1880. if err != nil {
  1881. panic(err)
  1882. }
  1883. return obj
  1884. }
  1885. // Hooks returns the client hooks.
  1886. func (c *MessageClient) Hooks() []Hook {
  1887. return c.hooks.Message
  1888. }
  1889. // Interceptors returns the client interceptors.
  1890. func (c *MessageClient) Interceptors() []Interceptor {
  1891. return c.inters.Message
  1892. }
  1893. func (c *MessageClient) mutate(ctx context.Context, m *MessageMutation) (Value, error) {
  1894. switch m.Op() {
  1895. case OpCreate:
  1896. return (&MessageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1897. case OpUpdate:
  1898. return (&MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1899. case OpUpdateOne:
  1900. return (&MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1901. case OpDelete, OpDeleteOne:
  1902. return (&MessageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1903. default:
  1904. return nil, fmt.Errorf("ent: unknown Message mutation op: %q", m.Op())
  1905. }
  1906. }
  1907. // MessageRecordsClient is a client for the MessageRecords schema.
  1908. type MessageRecordsClient struct {
  1909. config
  1910. }
  1911. // NewMessageRecordsClient returns a client for the MessageRecords from the given config.
  1912. func NewMessageRecordsClient(c config) *MessageRecordsClient {
  1913. return &MessageRecordsClient{config: c}
  1914. }
  1915. // Use adds a list of mutation hooks to the hooks stack.
  1916. // A call to `Use(f, g, h)` equals to `messagerecords.Hooks(f(g(h())))`.
  1917. func (c *MessageRecordsClient) Use(hooks ...Hook) {
  1918. c.hooks.MessageRecords = append(c.hooks.MessageRecords, hooks...)
  1919. }
  1920. // Intercept adds a list of query interceptors to the interceptors stack.
  1921. // A call to `Intercept(f, g, h)` equals to `messagerecords.Intercept(f(g(h())))`.
  1922. func (c *MessageRecordsClient) Intercept(interceptors ...Interceptor) {
  1923. c.inters.MessageRecords = append(c.inters.MessageRecords, interceptors...)
  1924. }
  1925. // Create returns a builder for creating a MessageRecords entity.
  1926. func (c *MessageRecordsClient) Create() *MessageRecordsCreate {
  1927. mutation := newMessageRecordsMutation(c.config, OpCreate)
  1928. return &MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1929. }
  1930. // CreateBulk returns a builder for creating a bulk of MessageRecords entities.
  1931. func (c *MessageRecordsClient) CreateBulk(builders ...*MessageRecordsCreate) *MessageRecordsCreateBulk {
  1932. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1933. }
  1934. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1935. // a builder and applies setFunc on it.
  1936. func (c *MessageRecordsClient) MapCreateBulk(slice any, setFunc func(*MessageRecordsCreate, int)) *MessageRecordsCreateBulk {
  1937. rv := reflect.ValueOf(slice)
  1938. if rv.Kind() != reflect.Slice {
  1939. return &MessageRecordsCreateBulk{err: fmt.Errorf("calling to MessageRecordsClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1940. }
  1941. builders := make([]*MessageRecordsCreate, rv.Len())
  1942. for i := 0; i < rv.Len(); i++ {
  1943. builders[i] = c.Create()
  1944. setFunc(builders[i], i)
  1945. }
  1946. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1947. }
  1948. // Update returns an update builder for MessageRecords.
  1949. func (c *MessageRecordsClient) Update() *MessageRecordsUpdate {
  1950. mutation := newMessageRecordsMutation(c.config, OpUpdate)
  1951. return &MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1952. }
  1953. // UpdateOne returns an update builder for the given entity.
  1954. func (c *MessageRecordsClient) UpdateOne(mr *MessageRecords) *MessageRecordsUpdateOne {
  1955. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecords(mr))
  1956. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1957. }
  1958. // UpdateOneID returns an update builder for the given id.
  1959. func (c *MessageRecordsClient) UpdateOneID(id uint64) *MessageRecordsUpdateOne {
  1960. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecordsID(id))
  1961. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1962. }
  1963. // Delete returns a delete builder for MessageRecords.
  1964. func (c *MessageRecordsClient) Delete() *MessageRecordsDelete {
  1965. mutation := newMessageRecordsMutation(c.config, OpDelete)
  1966. return &MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1967. }
  1968. // DeleteOne returns a builder for deleting the given entity.
  1969. func (c *MessageRecordsClient) DeleteOne(mr *MessageRecords) *MessageRecordsDeleteOne {
  1970. return c.DeleteOneID(mr.ID)
  1971. }
  1972. // DeleteOneID returns a builder for deleting the given entity by its id.
  1973. func (c *MessageRecordsClient) DeleteOneID(id uint64) *MessageRecordsDeleteOne {
  1974. builder := c.Delete().Where(messagerecords.ID(id))
  1975. builder.mutation.id = &id
  1976. builder.mutation.op = OpDeleteOne
  1977. return &MessageRecordsDeleteOne{builder}
  1978. }
  1979. // Query returns a query builder for MessageRecords.
  1980. func (c *MessageRecordsClient) Query() *MessageRecordsQuery {
  1981. return &MessageRecordsQuery{
  1982. config: c.config,
  1983. ctx: &QueryContext{Type: TypeMessageRecords},
  1984. inters: c.Interceptors(),
  1985. }
  1986. }
  1987. // Get returns a MessageRecords entity by its id.
  1988. func (c *MessageRecordsClient) Get(ctx context.Context, id uint64) (*MessageRecords, error) {
  1989. return c.Query().Where(messagerecords.ID(id)).Only(ctx)
  1990. }
  1991. // GetX is like Get, but panics if an error occurs.
  1992. func (c *MessageRecordsClient) GetX(ctx context.Context, id uint64) *MessageRecords {
  1993. obj, err := c.Get(ctx, id)
  1994. if err != nil {
  1995. panic(err)
  1996. }
  1997. return obj
  1998. }
  1999. // QuerySopStage queries the sop_stage edge of a MessageRecords.
  2000. func (c *MessageRecordsClient) QuerySopStage(mr *MessageRecords) *SopStageQuery {
  2001. query := (&SopStageClient{config: c.config}).Query()
  2002. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2003. id := mr.ID
  2004. step := sqlgraph.NewStep(
  2005. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2006. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2007. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopStageTable, messagerecords.SopStageColumn),
  2008. )
  2009. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2010. return fromV, nil
  2011. }
  2012. return query
  2013. }
  2014. // QuerySopNode queries the sop_node edge of a MessageRecords.
  2015. func (c *MessageRecordsClient) QuerySopNode(mr *MessageRecords) *SopNodeQuery {
  2016. query := (&SopNodeClient{config: c.config}).Query()
  2017. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2018. id := mr.ID
  2019. step := sqlgraph.NewStep(
  2020. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2021. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  2022. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopNodeTable, messagerecords.SopNodeColumn),
  2023. )
  2024. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2025. return fromV, nil
  2026. }
  2027. return query
  2028. }
  2029. // QueryMessageContact queries the message_contact edge of a MessageRecords.
  2030. func (c *MessageRecordsClient) QueryMessageContact(mr *MessageRecords) *ContactQuery {
  2031. query := (&ContactClient{config: c.config}).Query()
  2032. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2033. id := mr.ID
  2034. step := sqlgraph.NewStep(
  2035. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2036. sqlgraph.To(contact.Table, contact.FieldID),
  2037. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.MessageContactTable, messagerecords.MessageContactColumn),
  2038. )
  2039. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2040. return fromV, nil
  2041. }
  2042. return query
  2043. }
  2044. // Hooks returns the client hooks.
  2045. func (c *MessageRecordsClient) Hooks() []Hook {
  2046. return c.hooks.MessageRecords
  2047. }
  2048. // Interceptors returns the client interceptors.
  2049. func (c *MessageRecordsClient) Interceptors() []Interceptor {
  2050. return c.inters.MessageRecords
  2051. }
  2052. func (c *MessageRecordsClient) mutate(ctx context.Context, m *MessageRecordsMutation) (Value, error) {
  2053. switch m.Op() {
  2054. case OpCreate:
  2055. return (&MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2056. case OpUpdate:
  2057. return (&MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2058. case OpUpdateOne:
  2059. return (&MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2060. case OpDelete, OpDeleteOne:
  2061. return (&MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2062. default:
  2063. return nil, fmt.Errorf("ent: unknown MessageRecords mutation op: %q", m.Op())
  2064. }
  2065. }
  2066. // MsgClient is a client for the Msg schema.
  2067. type MsgClient struct {
  2068. config
  2069. }
  2070. // NewMsgClient returns a client for the Msg from the given config.
  2071. func NewMsgClient(c config) *MsgClient {
  2072. return &MsgClient{config: c}
  2073. }
  2074. // Use adds a list of mutation hooks to the hooks stack.
  2075. // A call to `Use(f, g, h)` equals to `msg.Hooks(f(g(h())))`.
  2076. func (c *MsgClient) Use(hooks ...Hook) {
  2077. c.hooks.Msg = append(c.hooks.Msg, hooks...)
  2078. }
  2079. // Intercept adds a list of query interceptors to the interceptors stack.
  2080. // A call to `Intercept(f, g, h)` equals to `msg.Intercept(f(g(h())))`.
  2081. func (c *MsgClient) Intercept(interceptors ...Interceptor) {
  2082. c.inters.Msg = append(c.inters.Msg, interceptors...)
  2083. }
  2084. // Create returns a builder for creating a Msg entity.
  2085. func (c *MsgClient) Create() *MsgCreate {
  2086. mutation := newMsgMutation(c.config, OpCreate)
  2087. return &MsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2088. }
  2089. // CreateBulk returns a builder for creating a bulk of Msg entities.
  2090. func (c *MsgClient) CreateBulk(builders ...*MsgCreate) *MsgCreateBulk {
  2091. return &MsgCreateBulk{config: c.config, builders: builders}
  2092. }
  2093. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2094. // a builder and applies setFunc on it.
  2095. func (c *MsgClient) MapCreateBulk(slice any, setFunc func(*MsgCreate, int)) *MsgCreateBulk {
  2096. rv := reflect.ValueOf(slice)
  2097. if rv.Kind() != reflect.Slice {
  2098. return &MsgCreateBulk{err: fmt.Errorf("calling to MsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2099. }
  2100. builders := make([]*MsgCreate, rv.Len())
  2101. for i := 0; i < rv.Len(); i++ {
  2102. builders[i] = c.Create()
  2103. setFunc(builders[i], i)
  2104. }
  2105. return &MsgCreateBulk{config: c.config, builders: builders}
  2106. }
  2107. // Update returns an update builder for Msg.
  2108. func (c *MsgClient) Update() *MsgUpdate {
  2109. mutation := newMsgMutation(c.config, OpUpdate)
  2110. return &MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2111. }
  2112. // UpdateOne returns an update builder for the given entity.
  2113. func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
  2114. mutation := newMsgMutation(c.config, OpUpdateOne, withMsg(m))
  2115. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2116. }
  2117. // UpdateOneID returns an update builder for the given id.
  2118. func (c *MsgClient) UpdateOneID(id uint64) *MsgUpdateOne {
  2119. mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
  2120. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2121. }
  2122. // Delete returns a delete builder for Msg.
  2123. func (c *MsgClient) Delete() *MsgDelete {
  2124. mutation := newMsgMutation(c.config, OpDelete)
  2125. return &MsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2126. }
  2127. // DeleteOne returns a builder for deleting the given entity.
  2128. func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
  2129. return c.DeleteOneID(m.ID)
  2130. }
  2131. // DeleteOneID returns a builder for deleting the given entity by its id.
  2132. func (c *MsgClient) DeleteOneID(id uint64) *MsgDeleteOne {
  2133. builder := c.Delete().Where(msg.ID(id))
  2134. builder.mutation.id = &id
  2135. builder.mutation.op = OpDeleteOne
  2136. return &MsgDeleteOne{builder}
  2137. }
  2138. // Query returns a query builder for Msg.
  2139. func (c *MsgClient) Query() *MsgQuery {
  2140. return &MsgQuery{
  2141. config: c.config,
  2142. ctx: &QueryContext{Type: TypeMsg},
  2143. inters: c.Interceptors(),
  2144. }
  2145. }
  2146. // Get returns a Msg entity by its id.
  2147. func (c *MsgClient) Get(ctx context.Context, id uint64) (*Msg, error) {
  2148. return c.Query().Where(msg.ID(id)).Only(ctx)
  2149. }
  2150. // GetX is like Get, but panics if an error occurs.
  2151. func (c *MsgClient) GetX(ctx context.Context, id uint64) *Msg {
  2152. obj, err := c.Get(ctx, id)
  2153. if err != nil {
  2154. panic(err)
  2155. }
  2156. return obj
  2157. }
  2158. // Hooks returns the client hooks.
  2159. func (c *MsgClient) Hooks() []Hook {
  2160. hooks := c.hooks.Msg
  2161. return append(hooks[:len(hooks):len(hooks)], msg.Hooks[:]...)
  2162. }
  2163. // Interceptors returns the client interceptors.
  2164. func (c *MsgClient) Interceptors() []Interceptor {
  2165. inters := c.inters.Msg
  2166. return append(inters[:len(inters):len(inters)], msg.Interceptors[:]...)
  2167. }
  2168. func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
  2169. switch m.Op() {
  2170. case OpCreate:
  2171. return (&MsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2172. case OpUpdate:
  2173. return (&MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2174. case OpUpdateOne:
  2175. return (&MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2176. case OpDelete, OpDeleteOne:
  2177. return (&MsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2178. default:
  2179. return nil, fmt.Errorf("ent: unknown Msg mutation op: %q", m.Op())
  2180. }
  2181. }
  2182. // ServerClient is a client for the Server schema.
  2183. type ServerClient struct {
  2184. config
  2185. }
  2186. // NewServerClient returns a client for the Server from the given config.
  2187. func NewServerClient(c config) *ServerClient {
  2188. return &ServerClient{config: c}
  2189. }
  2190. // Use adds a list of mutation hooks to the hooks stack.
  2191. // A call to `Use(f, g, h)` equals to `server.Hooks(f(g(h())))`.
  2192. func (c *ServerClient) Use(hooks ...Hook) {
  2193. c.hooks.Server = append(c.hooks.Server, hooks...)
  2194. }
  2195. // Intercept adds a list of query interceptors to the interceptors stack.
  2196. // A call to `Intercept(f, g, h)` equals to `server.Intercept(f(g(h())))`.
  2197. func (c *ServerClient) Intercept(interceptors ...Interceptor) {
  2198. c.inters.Server = append(c.inters.Server, interceptors...)
  2199. }
  2200. // Create returns a builder for creating a Server entity.
  2201. func (c *ServerClient) Create() *ServerCreate {
  2202. mutation := newServerMutation(c.config, OpCreate)
  2203. return &ServerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2204. }
  2205. // CreateBulk returns a builder for creating a bulk of Server entities.
  2206. func (c *ServerClient) CreateBulk(builders ...*ServerCreate) *ServerCreateBulk {
  2207. return &ServerCreateBulk{config: c.config, builders: builders}
  2208. }
  2209. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2210. // a builder and applies setFunc on it.
  2211. func (c *ServerClient) MapCreateBulk(slice any, setFunc func(*ServerCreate, int)) *ServerCreateBulk {
  2212. rv := reflect.ValueOf(slice)
  2213. if rv.Kind() != reflect.Slice {
  2214. return &ServerCreateBulk{err: fmt.Errorf("calling to ServerClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2215. }
  2216. builders := make([]*ServerCreate, rv.Len())
  2217. for i := 0; i < rv.Len(); i++ {
  2218. builders[i] = c.Create()
  2219. setFunc(builders[i], i)
  2220. }
  2221. return &ServerCreateBulk{config: c.config, builders: builders}
  2222. }
  2223. // Update returns an update builder for Server.
  2224. func (c *ServerClient) Update() *ServerUpdate {
  2225. mutation := newServerMutation(c.config, OpUpdate)
  2226. return &ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2227. }
  2228. // UpdateOne returns an update builder for the given entity.
  2229. func (c *ServerClient) UpdateOne(s *Server) *ServerUpdateOne {
  2230. mutation := newServerMutation(c.config, OpUpdateOne, withServer(s))
  2231. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2232. }
  2233. // UpdateOneID returns an update builder for the given id.
  2234. func (c *ServerClient) UpdateOneID(id uint64) *ServerUpdateOne {
  2235. mutation := newServerMutation(c.config, OpUpdateOne, withServerID(id))
  2236. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2237. }
  2238. // Delete returns a delete builder for Server.
  2239. func (c *ServerClient) Delete() *ServerDelete {
  2240. mutation := newServerMutation(c.config, OpDelete)
  2241. return &ServerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2242. }
  2243. // DeleteOne returns a builder for deleting the given entity.
  2244. func (c *ServerClient) DeleteOne(s *Server) *ServerDeleteOne {
  2245. return c.DeleteOneID(s.ID)
  2246. }
  2247. // DeleteOneID returns a builder for deleting the given entity by its id.
  2248. func (c *ServerClient) DeleteOneID(id uint64) *ServerDeleteOne {
  2249. builder := c.Delete().Where(server.ID(id))
  2250. builder.mutation.id = &id
  2251. builder.mutation.op = OpDeleteOne
  2252. return &ServerDeleteOne{builder}
  2253. }
  2254. // Query returns a query builder for Server.
  2255. func (c *ServerClient) Query() *ServerQuery {
  2256. return &ServerQuery{
  2257. config: c.config,
  2258. ctx: &QueryContext{Type: TypeServer},
  2259. inters: c.Interceptors(),
  2260. }
  2261. }
  2262. // Get returns a Server entity by its id.
  2263. func (c *ServerClient) Get(ctx context.Context, id uint64) (*Server, error) {
  2264. return c.Query().Where(server.ID(id)).Only(ctx)
  2265. }
  2266. // GetX is like Get, but panics if an error occurs.
  2267. func (c *ServerClient) GetX(ctx context.Context, id uint64) *Server {
  2268. obj, err := c.Get(ctx, id)
  2269. if err != nil {
  2270. panic(err)
  2271. }
  2272. return obj
  2273. }
  2274. // QueryWxs queries the wxs edge of a Server.
  2275. func (c *ServerClient) QueryWxs(s *Server) *WxQuery {
  2276. query := (&WxClient{config: c.config}).Query()
  2277. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2278. id := s.ID
  2279. step := sqlgraph.NewStep(
  2280. sqlgraph.From(server.Table, server.FieldID, id),
  2281. sqlgraph.To(wx.Table, wx.FieldID),
  2282. sqlgraph.Edge(sqlgraph.O2M, false, server.WxsTable, server.WxsColumn),
  2283. )
  2284. fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
  2285. return fromV, nil
  2286. }
  2287. return query
  2288. }
  2289. // Hooks returns the client hooks.
  2290. func (c *ServerClient) Hooks() []Hook {
  2291. hooks := c.hooks.Server
  2292. return append(hooks[:len(hooks):len(hooks)], server.Hooks[:]...)
  2293. }
  2294. // Interceptors returns the client interceptors.
  2295. func (c *ServerClient) Interceptors() []Interceptor {
  2296. inters := c.inters.Server
  2297. return append(inters[:len(inters):len(inters)], server.Interceptors[:]...)
  2298. }
  2299. func (c *ServerClient) mutate(ctx context.Context, m *ServerMutation) (Value, error) {
  2300. switch m.Op() {
  2301. case OpCreate:
  2302. return (&ServerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2303. case OpUpdate:
  2304. return (&ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2305. case OpUpdateOne:
  2306. return (&ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2307. case OpDelete, OpDeleteOne:
  2308. return (&ServerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2309. default:
  2310. return nil, fmt.Errorf("ent: unknown Server mutation op: %q", m.Op())
  2311. }
  2312. }
  2313. // SopNodeClient is a client for the SopNode schema.
  2314. type SopNodeClient struct {
  2315. config
  2316. }
  2317. // NewSopNodeClient returns a client for the SopNode from the given config.
  2318. func NewSopNodeClient(c config) *SopNodeClient {
  2319. return &SopNodeClient{config: c}
  2320. }
  2321. // Use adds a list of mutation hooks to the hooks stack.
  2322. // A call to `Use(f, g, h)` equals to `sopnode.Hooks(f(g(h())))`.
  2323. func (c *SopNodeClient) Use(hooks ...Hook) {
  2324. c.hooks.SopNode = append(c.hooks.SopNode, hooks...)
  2325. }
  2326. // Intercept adds a list of query interceptors to the interceptors stack.
  2327. // A call to `Intercept(f, g, h)` equals to `sopnode.Intercept(f(g(h())))`.
  2328. func (c *SopNodeClient) Intercept(interceptors ...Interceptor) {
  2329. c.inters.SopNode = append(c.inters.SopNode, interceptors...)
  2330. }
  2331. // Create returns a builder for creating a SopNode entity.
  2332. func (c *SopNodeClient) Create() *SopNodeCreate {
  2333. mutation := newSopNodeMutation(c.config, OpCreate)
  2334. return &SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2335. }
  2336. // CreateBulk returns a builder for creating a bulk of SopNode entities.
  2337. func (c *SopNodeClient) CreateBulk(builders ...*SopNodeCreate) *SopNodeCreateBulk {
  2338. return &SopNodeCreateBulk{config: c.config, builders: builders}
  2339. }
  2340. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2341. // a builder and applies setFunc on it.
  2342. func (c *SopNodeClient) MapCreateBulk(slice any, setFunc func(*SopNodeCreate, int)) *SopNodeCreateBulk {
  2343. rv := reflect.ValueOf(slice)
  2344. if rv.Kind() != reflect.Slice {
  2345. return &SopNodeCreateBulk{err: fmt.Errorf("calling to SopNodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2346. }
  2347. builders := make([]*SopNodeCreate, rv.Len())
  2348. for i := 0; i < rv.Len(); i++ {
  2349. builders[i] = c.Create()
  2350. setFunc(builders[i], i)
  2351. }
  2352. return &SopNodeCreateBulk{config: c.config, builders: builders}
  2353. }
  2354. // Update returns an update builder for SopNode.
  2355. func (c *SopNodeClient) Update() *SopNodeUpdate {
  2356. mutation := newSopNodeMutation(c.config, OpUpdate)
  2357. return &SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2358. }
  2359. // UpdateOne returns an update builder for the given entity.
  2360. func (c *SopNodeClient) UpdateOne(sn *SopNode) *SopNodeUpdateOne {
  2361. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNode(sn))
  2362. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2363. }
  2364. // UpdateOneID returns an update builder for the given id.
  2365. func (c *SopNodeClient) UpdateOneID(id uint64) *SopNodeUpdateOne {
  2366. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNodeID(id))
  2367. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2368. }
  2369. // Delete returns a delete builder for SopNode.
  2370. func (c *SopNodeClient) Delete() *SopNodeDelete {
  2371. mutation := newSopNodeMutation(c.config, OpDelete)
  2372. return &SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2373. }
  2374. // DeleteOne returns a builder for deleting the given entity.
  2375. func (c *SopNodeClient) DeleteOne(sn *SopNode) *SopNodeDeleteOne {
  2376. return c.DeleteOneID(sn.ID)
  2377. }
  2378. // DeleteOneID returns a builder for deleting the given entity by its id.
  2379. func (c *SopNodeClient) DeleteOneID(id uint64) *SopNodeDeleteOne {
  2380. builder := c.Delete().Where(sopnode.ID(id))
  2381. builder.mutation.id = &id
  2382. builder.mutation.op = OpDeleteOne
  2383. return &SopNodeDeleteOne{builder}
  2384. }
  2385. // Query returns a query builder for SopNode.
  2386. func (c *SopNodeClient) Query() *SopNodeQuery {
  2387. return &SopNodeQuery{
  2388. config: c.config,
  2389. ctx: &QueryContext{Type: TypeSopNode},
  2390. inters: c.Interceptors(),
  2391. }
  2392. }
  2393. // Get returns a SopNode entity by its id.
  2394. func (c *SopNodeClient) Get(ctx context.Context, id uint64) (*SopNode, error) {
  2395. return c.Query().Where(sopnode.ID(id)).Only(ctx)
  2396. }
  2397. // GetX is like Get, but panics if an error occurs.
  2398. func (c *SopNodeClient) GetX(ctx context.Context, id uint64) *SopNode {
  2399. obj, err := c.Get(ctx, id)
  2400. if err != nil {
  2401. panic(err)
  2402. }
  2403. return obj
  2404. }
  2405. // QuerySopStage queries the sop_stage edge of a SopNode.
  2406. func (c *SopNodeClient) QuerySopStage(sn *SopNode) *SopStageQuery {
  2407. query := (&SopStageClient{config: c.config}).Query()
  2408. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2409. id := sn.ID
  2410. step := sqlgraph.NewStep(
  2411. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  2412. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2413. sqlgraph.Edge(sqlgraph.M2O, true, sopnode.SopStageTable, sopnode.SopStageColumn),
  2414. )
  2415. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  2416. return fromV, nil
  2417. }
  2418. return query
  2419. }
  2420. // QueryNodeMessages queries the node_messages edge of a SopNode.
  2421. func (c *SopNodeClient) QueryNodeMessages(sn *SopNode) *MessageRecordsQuery {
  2422. query := (&MessageRecordsClient{config: c.config}).Query()
  2423. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2424. id := sn.ID
  2425. step := sqlgraph.NewStep(
  2426. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  2427. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  2428. sqlgraph.Edge(sqlgraph.O2M, false, sopnode.NodeMessagesTable, sopnode.NodeMessagesColumn),
  2429. )
  2430. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  2431. return fromV, nil
  2432. }
  2433. return query
  2434. }
  2435. // Hooks returns the client hooks.
  2436. func (c *SopNodeClient) Hooks() []Hook {
  2437. hooks := c.hooks.SopNode
  2438. return append(hooks[:len(hooks):len(hooks)], sopnode.Hooks[:]...)
  2439. }
  2440. // Interceptors returns the client interceptors.
  2441. func (c *SopNodeClient) Interceptors() []Interceptor {
  2442. inters := c.inters.SopNode
  2443. return append(inters[:len(inters):len(inters)], sopnode.Interceptors[:]...)
  2444. }
  2445. func (c *SopNodeClient) mutate(ctx context.Context, m *SopNodeMutation) (Value, error) {
  2446. switch m.Op() {
  2447. case OpCreate:
  2448. return (&SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2449. case OpUpdate:
  2450. return (&SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2451. case OpUpdateOne:
  2452. return (&SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2453. case OpDelete, OpDeleteOne:
  2454. return (&SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2455. default:
  2456. return nil, fmt.Errorf("ent: unknown SopNode mutation op: %q", m.Op())
  2457. }
  2458. }
  2459. // SopStageClient is a client for the SopStage schema.
  2460. type SopStageClient struct {
  2461. config
  2462. }
  2463. // NewSopStageClient returns a client for the SopStage from the given config.
  2464. func NewSopStageClient(c config) *SopStageClient {
  2465. return &SopStageClient{config: c}
  2466. }
  2467. // Use adds a list of mutation hooks to the hooks stack.
  2468. // A call to `Use(f, g, h)` equals to `sopstage.Hooks(f(g(h())))`.
  2469. func (c *SopStageClient) Use(hooks ...Hook) {
  2470. c.hooks.SopStage = append(c.hooks.SopStage, hooks...)
  2471. }
  2472. // Intercept adds a list of query interceptors to the interceptors stack.
  2473. // A call to `Intercept(f, g, h)` equals to `sopstage.Intercept(f(g(h())))`.
  2474. func (c *SopStageClient) Intercept(interceptors ...Interceptor) {
  2475. c.inters.SopStage = append(c.inters.SopStage, interceptors...)
  2476. }
  2477. // Create returns a builder for creating a SopStage entity.
  2478. func (c *SopStageClient) Create() *SopStageCreate {
  2479. mutation := newSopStageMutation(c.config, OpCreate)
  2480. return &SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2481. }
  2482. // CreateBulk returns a builder for creating a bulk of SopStage entities.
  2483. func (c *SopStageClient) CreateBulk(builders ...*SopStageCreate) *SopStageCreateBulk {
  2484. return &SopStageCreateBulk{config: c.config, builders: builders}
  2485. }
  2486. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2487. // a builder and applies setFunc on it.
  2488. func (c *SopStageClient) MapCreateBulk(slice any, setFunc func(*SopStageCreate, int)) *SopStageCreateBulk {
  2489. rv := reflect.ValueOf(slice)
  2490. if rv.Kind() != reflect.Slice {
  2491. return &SopStageCreateBulk{err: fmt.Errorf("calling to SopStageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2492. }
  2493. builders := make([]*SopStageCreate, rv.Len())
  2494. for i := 0; i < rv.Len(); i++ {
  2495. builders[i] = c.Create()
  2496. setFunc(builders[i], i)
  2497. }
  2498. return &SopStageCreateBulk{config: c.config, builders: builders}
  2499. }
  2500. // Update returns an update builder for SopStage.
  2501. func (c *SopStageClient) Update() *SopStageUpdate {
  2502. mutation := newSopStageMutation(c.config, OpUpdate)
  2503. return &SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2504. }
  2505. // UpdateOne returns an update builder for the given entity.
  2506. func (c *SopStageClient) UpdateOne(ss *SopStage) *SopStageUpdateOne {
  2507. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStage(ss))
  2508. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2509. }
  2510. // UpdateOneID returns an update builder for the given id.
  2511. func (c *SopStageClient) UpdateOneID(id uint64) *SopStageUpdateOne {
  2512. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStageID(id))
  2513. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2514. }
  2515. // Delete returns a delete builder for SopStage.
  2516. func (c *SopStageClient) Delete() *SopStageDelete {
  2517. mutation := newSopStageMutation(c.config, OpDelete)
  2518. return &SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2519. }
  2520. // DeleteOne returns a builder for deleting the given entity.
  2521. func (c *SopStageClient) DeleteOne(ss *SopStage) *SopStageDeleteOne {
  2522. return c.DeleteOneID(ss.ID)
  2523. }
  2524. // DeleteOneID returns a builder for deleting the given entity by its id.
  2525. func (c *SopStageClient) DeleteOneID(id uint64) *SopStageDeleteOne {
  2526. builder := c.Delete().Where(sopstage.ID(id))
  2527. builder.mutation.id = &id
  2528. builder.mutation.op = OpDeleteOne
  2529. return &SopStageDeleteOne{builder}
  2530. }
  2531. // Query returns a query builder for SopStage.
  2532. func (c *SopStageClient) Query() *SopStageQuery {
  2533. return &SopStageQuery{
  2534. config: c.config,
  2535. ctx: &QueryContext{Type: TypeSopStage},
  2536. inters: c.Interceptors(),
  2537. }
  2538. }
  2539. // Get returns a SopStage entity by its id.
  2540. func (c *SopStageClient) Get(ctx context.Context, id uint64) (*SopStage, error) {
  2541. return c.Query().Where(sopstage.ID(id)).Only(ctx)
  2542. }
  2543. // GetX is like Get, but panics if an error occurs.
  2544. func (c *SopStageClient) GetX(ctx context.Context, id uint64) *SopStage {
  2545. obj, err := c.Get(ctx, id)
  2546. if err != nil {
  2547. panic(err)
  2548. }
  2549. return obj
  2550. }
  2551. // QuerySopTask queries the sop_task edge of a SopStage.
  2552. func (c *SopStageClient) QuerySopTask(ss *SopStage) *SopTaskQuery {
  2553. query := (&SopTaskClient{config: c.config}).Query()
  2554. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2555. id := ss.ID
  2556. step := sqlgraph.NewStep(
  2557. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  2558. sqlgraph.To(soptask.Table, soptask.FieldID),
  2559. sqlgraph.Edge(sqlgraph.M2O, true, sopstage.SopTaskTable, sopstage.SopTaskColumn),
  2560. )
  2561. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  2562. return fromV, nil
  2563. }
  2564. return query
  2565. }
  2566. // QueryStageNodes queries the stage_nodes edge of a SopStage.
  2567. func (c *SopStageClient) QueryStageNodes(ss *SopStage) *SopNodeQuery {
  2568. query := (&SopNodeClient{config: c.config}).Query()
  2569. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2570. id := ss.ID
  2571. step := sqlgraph.NewStep(
  2572. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  2573. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  2574. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageNodesTable, sopstage.StageNodesColumn),
  2575. )
  2576. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  2577. return fromV, nil
  2578. }
  2579. return query
  2580. }
  2581. // QueryStageMessages queries the stage_messages edge of a SopStage.
  2582. func (c *SopStageClient) QueryStageMessages(ss *SopStage) *MessageRecordsQuery {
  2583. query := (&MessageRecordsClient{config: c.config}).Query()
  2584. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2585. id := ss.ID
  2586. step := sqlgraph.NewStep(
  2587. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  2588. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  2589. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageMessagesTable, sopstage.StageMessagesColumn),
  2590. )
  2591. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  2592. return fromV, nil
  2593. }
  2594. return query
  2595. }
  2596. // Hooks returns the client hooks.
  2597. func (c *SopStageClient) Hooks() []Hook {
  2598. hooks := c.hooks.SopStage
  2599. return append(hooks[:len(hooks):len(hooks)], sopstage.Hooks[:]...)
  2600. }
  2601. // Interceptors returns the client interceptors.
  2602. func (c *SopStageClient) Interceptors() []Interceptor {
  2603. inters := c.inters.SopStage
  2604. return append(inters[:len(inters):len(inters)], sopstage.Interceptors[:]...)
  2605. }
  2606. func (c *SopStageClient) mutate(ctx context.Context, m *SopStageMutation) (Value, error) {
  2607. switch m.Op() {
  2608. case OpCreate:
  2609. return (&SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2610. case OpUpdate:
  2611. return (&SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2612. case OpUpdateOne:
  2613. return (&SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2614. case OpDelete, OpDeleteOne:
  2615. return (&SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2616. default:
  2617. return nil, fmt.Errorf("ent: unknown SopStage mutation op: %q", m.Op())
  2618. }
  2619. }
  2620. // SopTaskClient is a client for the SopTask schema.
  2621. type SopTaskClient struct {
  2622. config
  2623. }
  2624. // NewSopTaskClient returns a client for the SopTask from the given config.
  2625. func NewSopTaskClient(c config) *SopTaskClient {
  2626. return &SopTaskClient{config: c}
  2627. }
  2628. // Use adds a list of mutation hooks to the hooks stack.
  2629. // A call to `Use(f, g, h)` equals to `soptask.Hooks(f(g(h())))`.
  2630. func (c *SopTaskClient) Use(hooks ...Hook) {
  2631. c.hooks.SopTask = append(c.hooks.SopTask, hooks...)
  2632. }
  2633. // Intercept adds a list of query interceptors to the interceptors stack.
  2634. // A call to `Intercept(f, g, h)` equals to `soptask.Intercept(f(g(h())))`.
  2635. func (c *SopTaskClient) Intercept(interceptors ...Interceptor) {
  2636. c.inters.SopTask = append(c.inters.SopTask, interceptors...)
  2637. }
  2638. // Create returns a builder for creating a SopTask entity.
  2639. func (c *SopTaskClient) Create() *SopTaskCreate {
  2640. mutation := newSopTaskMutation(c.config, OpCreate)
  2641. return &SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2642. }
  2643. // CreateBulk returns a builder for creating a bulk of SopTask entities.
  2644. func (c *SopTaskClient) CreateBulk(builders ...*SopTaskCreate) *SopTaskCreateBulk {
  2645. return &SopTaskCreateBulk{config: c.config, builders: builders}
  2646. }
  2647. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2648. // a builder and applies setFunc on it.
  2649. func (c *SopTaskClient) MapCreateBulk(slice any, setFunc func(*SopTaskCreate, int)) *SopTaskCreateBulk {
  2650. rv := reflect.ValueOf(slice)
  2651. if rv.Kind() != reflect.Slice {
  2652. return &SopTaskCreateBulk{err: fmt.Errorf("calling to SopTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2653. }
  2654. builders := make([]*SopTaskCreate, rv.Len())
  2655. for i := 0; i < rv.Len(); i++ {
  2656. builders[i] = c.Create()
  2657. setFunc(builders[i], i)
  2658. }
  2659. return &SopTaskCreateBulk{config: c.config, builders: builders}
  2660. }
  2661. // Update returns an update builder for SopTask.
  2662. func (c *SopTaskClient) Update() *SopTaskUpdate {
  2663. mutation := newSopTaskMutation(c.config, OpUpdate)
  2664. return &SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2665. }
  2666. // UpdateOne returns an update builder for the given entity.
  2667. func (c *SopTaskClient) UpdateOne(st *SopTask) *SopTaskUpdateOne {
  2668. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTask(st))
  2669. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2670. }
  2671. // UpdateOneID returns an update builder for the given id.
  2672. func (c *SopTaskClient) UpdateOneID(id uint64) *SopTaskUpdateOne {
  2673. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTaskID(id))
  2674. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2675. }
  2676. // Delete returns a delete builder for SopTask.
  2677. func (c *SopTaskClient) Delete() *SopTaskDelete {
  2678. mutation := newSopTaskMutation(c.config, OpDelete)
  2679. return &SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2680. }
  2681. // DeleteOne returns a builder for deleting the given entity.
  2682. func (c *SopTaskClient) DeleteOne(st *SopTask) *SopTaskDeleteOne {
  2683. return c.DeleteOneID(st.ID)
  2684. }
  2685. // DeleteOneID returns a builder for deleting the given entity by its id.
  2686. func (c *SopTaskClient) DeleteOneID(id uint64) *SopTaskDeleteOne {
  2687. builder := c.Delete().Where(soptask.ID(id))
  2688. builder.mutation.id = &id
  2689. builder.mutation.op = OpDeleteOne
  2690. return &SopTaskDeleteOne{builder}
  2691. }
  2692. // Query returns a query builder for SopTask.
  2693. func (c *SopTaskClient) Query() *SopTaskQuery {
  2694. return &SopTaskQuery{
  2695. config: c.config,
  2696. ctx: &QueryContext{Type: TypeSopTask},
  2697. inters: c.Interceptors(),
  2698. }
  2699. }
  2700. // Get returns a SopTask entity by its id.
  2701. func (c *SopTaskClient) Get(ctx context.Context, id uint64) (*SopTask, error) {
  2702. return c.Query().Where(soptask.ID(id)).Only(ctx)
  2703. }
  2704. // GetX is like Get, but panics if an error occurs.
  2705. func (c *SopTaskClient) GetX(ctx context.Context, id uint64) *SopTask {
  2706. obj, err := c.Get(ctx, id)
  2707. if err != nil {
  2708. panic(err)
  2709. }
  2710. return obj
  2711. }
  2712. // QueryTaskStages queries the task_stages edge of a SopTask.
  2713. func (c *SopTaskClient) QueryTaskStages(st *SopTask) *SopStageQuery {
  2714. query := (&SopStageClient{config: c.config}).Query()
  2715. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2716. id := st.ID
  2717. step := sqlgraph.NewStep(
  2718. sqlgraph.From(soptask.Table, soptask.FieldID, id),
  2719. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2720. sqlgraph.Edge(sqlgraph.O2M, false, soptask.TaskStagesTable, soptask.TaskStagesColumn),
  2721. )
  2722. fromV = sqlgraph.Neighbors(st.driver.Dialect(), step)
  2723. return fromV, nil
  2724. }
  2725. return query
  2726. }
  2727. // Hooks returns the client hooks.
  2728. func (c *SopTaskClient) Hooks() []Hook {
  2729. hooks := c.hooks.SopTask
  2730. return append(hooks[:len(hooks):len(hooks)], soptask.Hooks[:]...)
  2731. }
  2732. // Interceptors returns the client interceptors.
  2733. func (c *SopTaskClient) Interceptors() []Interceptor {
  2734. inters := c.inters.SopTask
  2735. return append(inters[:len(inters):len(inters)], soptask.Interceptors[:]...)
  2736. }
  2737. func (c *SopTaskClient) mutate(ctx context.Context, m *SopTaskMutation) (Value, error) {
  2738. switch m.Op() {
  2739. case OpCreate:
  2740. return (&SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2741. case OpUpdate:
  2742. return (&SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2743. case OpUpdateOne:
  2744. return (&SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2745. case OpDelete, OpDeleteOne:
  2746. return (&SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2747. default:
  2748. return nil, fmt.Errorf("ent: unknown SopTask mutation op: %q", m.Op())
  2749. }
  2750. }
  2751. // TokenClient is a client for the Token schema.
  2752. type TokenClient struct {
  2753. config
  2754. }
  2755. // NewTokenClient returns a client for the Token from the given config.
  2756. func NewTokenClient(c config) *TokenClient {
  2757. return &TokenClient{config: c}
  2758. }
  2759. // Use adds a list of mutation hooks to the hooks stack.
  2760. // A call to `Use(f, g, h)` equals to `token.Hooks(f(g(h())))`.
  2761. func (c *TokenClient) Use(hooks ...Hook) {
  2762. c.hooks.Token = append(c.hooks.Token, hooks...)
  2763. }
  2764. // Intercept adds a list of query interceptors to the interceptors stack.
  2765. // A call to `Intercept(f, g, h)` equals to `token.Intercept(f(g(h())))`.
  2766. func (c *TokenClient) Intercept(interceptors ...Interceptor) {
  2767. c.inters.Token = append(c.inters.Token, interceptors...)
  2768. }
  2769. // Create returns a builder for creating a Token entity.
  2770. func (c *TokenClient) Create() *TokenCreate {
  2771. mutation := newTokenMutation(c.config, OpCreate)
  2772. return &TokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2773. }
  2774. // CreateBulk returns a builder for creating a bulk of Token entities.
  2775. func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk {
  2776. return &TokenCreateBulk{config: c.config, builders: builders}
  2777. }
  2778. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2779. // a builder and applies setFunc on it.
  2780. func (c *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk {
  2781. rv := reflect.ValueOf(slice)
  2782. if rv.Kind() != reflect.Slice {
  2783. return &TokenCreateBulk{err: fmt.Errorf("calling to TokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2784. }
  2785. builders := make([]*TokenCreate, rv.Len())
  2786. for i := 0; i < rv.Len(); i++ {
  2787. builders[i] = c.Create()
  2788. setFunc(builders[i], i)
  2789. }
  2790. return &TokenCreateBulk{config: c.config, builders: builders}
  2791. }
  2792. // Update returns an update builder for Token.
  2793. func (c *TokenClient) Update() *TokenUpdate {
  2794. mutation := newTokenMutation(c.config, OpUpdate)
  2795. return &TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2796. }
  2797. // UpdateOne returns an update builder for the given entity.
  2798. func (c *TokenClient) UpdateOne(t *Token) *TokenUpdateOne {
  2799. mutation := newTokenMutation(c.config, OpUpdateOne, withToken(t))
  2800. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2801. }
  2802. // UpdateOneID returns an update builder for the given id.
  2803. func (c *TokenClient) UpdateOneID(id uint64) *TokenUpdateOne {
  2804. mutation := newTokenMutation(c.config, OpUpdateOne, withTokenID(id))
  2805. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2806. }
  2807. // Delete returns a delete builder for Token.
  2808. func (c *TokenClient) Delete() *TokenDelete {
  2809. mutation := newTokenMutation(c.config, OpDelete)
  2810. return &TokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2811. }
  2812. // DeleteOne returns a builder for deleting the given entity.
  2813. func (c *TokenClient) DeleteOne(t *Token) *TokenDeleteOne {
  2814. return c.DeleteOneID(t.ID)
  2815. }
  2816. // DeleteOneID returns a builder for deleting the given entity by its id.
  2817. func (c *TokenClient) DeleteOneID(id uint64) *TokenDeleteOne {
  2818. builder := c.Delete().Where(token.ID(id))
  2819. builder.mutation.id = &id
  2820. builder.mutation.op = OpDeleteOne
  2821. return &TokenDeleteOne{builder}
  2822. }
  2823. // Query returns a query builder for Token.
  2824. func (c *TokenClient) Query() *TokenQuery {
  2825. return &TokenQuery{
  2826. config: c.config,
  2827. ctx: &QueryContext{Type: TypeToken},
  2828. inters: c.Interceptors(),
  2829. }
  2830. }
  2831. // Get returns a Token entity by its id.
  2832. func (c *TokenClient) Get(ctx context.Context, id uint64) (*Token, error) {
  2833. return c.Query().Where(token.ID(id)).Only(ctx)
  2834. }
  2835. // GetX is like Get, but panics if an error occurs.
  2836. func (c *TokenClient) GetX(ctx context.Context, id uint64) *Token {
  2837. obj, err := c.Get(ctx, id)
  2838. if err != nil {
  2839. panic(err)
  2840. }
  2841. return obj
  2842. }
  2843. // Hooks returns the client hooks.
  2844. func (c *TokenClient) Hooks() []Hook {
  2845. hooks := c.hooks.Token
  2846. return append(hooks[:len(hooks):len(hooks)], token.Hooks[:]...)
  2847. }
  2848. // Interceptors returns the client interceptors.
  2849. func (c *TokenClient) Interceptors() []Interceptor {
  2850. inters := c.inters.Token
  2851. return append(inters[:len(inters):len(inters)], token.Interceptors[:]...)
  2852. }
  2853. func (c *TokenClient) mutate(ctx context.Context, m *TokenMutation) (Value, error) {
  2854. switch m.Op() {
  2855. case OpCreate:
  2856. return (&TokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2857. case OpUpdate:
  2858. return (&TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2859. case OpUpdateOne:
  2860. return (&TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2861. case OpDelete, OpDeleteOne:
  2862. return (&TokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2863. default:
  2864. return nil, fmt.Errorf("ent: unknown Token mutation op: %q", m.Op())
  2865. }
  2866. }
  2867. // TutorialClient is a client for the Tutorial schema.
  2868. type TutorialClient struct {
  2869. config
  2870. }
  2871. // NewTutorialClient returns a client for the Tutorial from the given config.
  2872. func NewTutorialClient(c config) *TutorialClient {
  2873. return &TutorialClient{config: c}
  2874. }
  2875. // Use adds a list of mutation hooks to the hooks stack.
  2876. // A call to `Use(f, g, h)` equals to `tutorial.Hooks(f(g(h())))`.
  2877. func (c *TutorialClient) Use(hooks ...Hook) {
  2878. c.hooks.Tutorial = append(c.hooks.Tutorial, hooks...)
  2879. }
  2880. // Intercept adds a list of query interceptors to the interceptors stack.
  2881. // A call to `Intercept(f, g, h)` equals to `tutorial.Intercept(f(g(h())))`.
  2882. func (c *TutorialClient) Intercept(interceptors ...Interceptor) {
  2883. c.inters.Tutorial = append(c.inters.Tutorial, interceptors...)
  2884. }
  2885. // Create returns a builder for creating a Tutorial entity.
  2886. func (c *TutorialClient) Create() *TutorialCreate {
  2887. mutation := newTutorialMutation(c.config, OpCreate)
  2888. return &TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2889. }
  2890. // CreateBulk returns a builder for creating a bulk of Tutorial entities.
  2891. func (c *TutorialClient) CreateBulk(builders ...*TutorialCreate) *TutorialCreateBulk {
  2892. return &TutorialCreateBulk{config: c.config, builders: builders}
  2893. }
  2894. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2895. // a builder and applies setFunc on it.
  2896. func (c *TutorialClient) MapCreateBulk(slice any, setFunc func(*TutorialCreate, int)) *TutorialCreateBulk {
  2897. rv := reflect.ValueOf(slice)
  2898. if rv.Kind() != reflect.Slice {
  2899. return &TutorialCreateBulk{err: fmt.Errorf("calling to TutorialClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2900. }
  2901. builders := make([]*TutorialCreate, rv.Len())
  2902. for i := 0; i < rv.Len(); i++ {
  2903. builders[i] = c.Create()
  2904. setFunc(builders[i], i)
  2905. }
  2906. return &TutorialCreateBulk{config: c.config, builders: builders}
  2907. }
  2908. // Update returns an update builder for Tutorial.
  2909. func (c *TutorialClient) Update() *TutorialUpdate {
  2910. mutation := newTutorialMutation(c.config, OpUpdate)
  2911. return &TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2912. }
  2913. // UpdateOne returns an update builder for the given entity.
  2914. func (c *TutorialClient) UpdateOne(t *Tutorial) *TutorialUpdateOne {
  2915. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorial(t))
  2916. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2917. }
  2918. // UpdateOneID returns an update builder for the given id.
  2919. func (c *TutorialClient) UpdateOneID(id uint64) *TutorialUpdateOne {
  2920. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorialID(id))
  2921. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2922. }
  2923. // Delete returns a delete builder for Tutorial.
  2924. func (c *TutorialClient) Delete() *TutorialDelete {
  2925. mutation := newTutorialMutation(c.config, OpDelete)
  2926. return &TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2927. }
  2928. // DeleteOne returns a builder for deleting the given entity.
  2929. func (c *TutorialClient) DeleteOne(t *Tutorial) *TutorialDeleteOne {
  2930. return c.DeleteOneID(t.ID)
  2931. }
  2932. // DeleteOneID returns a builder for deleting the given entity by its id.
  2933. func (c *TutorialClient) DeleteOneID(id uint64) *TutorialDeleteOne {
  2934. builder := c.Delete().Where(tutorial.ID(id))
  2935. builder.mutation.id = &id
  2936. builder.mutation.op = OpDeleteOne
  2937. return &TutorialDeleteOne{builder}
  2938. }
  2939. // Query returns a query builder for Tutorial.
  2940. func (c *TutorialClient) Query() *TutorialQuery {
  2941. return &TutorialQuery{
  2942. config: c.config,
  2943. ctx: &QueryContext{Type: TypeTutorial},
  2944. inters: c.Interceptors(),
  2945. }
  2946. }
  2947. // Get returns a Tutorial entity by its id.
  2948. func (c *TutorialClient) Get(ctx context.Context, id uint64) (*Tutorial, error) {
  2949. return c.Query().Where(tutorial.ID(id)).Only(ctx)
  2950. }
  2951. // GetX is like Get, but panics if an error occurs.
  2952. func (c *TutorialClient) GetX(ctx context.Context, id uint64) *Tutorial {
  2953. obj, err := c.Get(ctx, id)
  2954. if err != nil {
  2955. panic(err)
  2956. }
  2957. return obj
  2958. }
  2959. // QueryEmployee queries the employee edge of a Tutorial.
  2960. func (c *TutorialClient) QueryEmployee(t *Tutorial) *EmployeeQuery {
  2961. query := (&EmployeeClient{config: c.config}).Query()
  2962. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2963. id := t.ID
  2964. step := sqlgraph.NewStep(
  2965. sqlgraph.From(tutorial.Table, tutorial.FieldID, id),
  2966. sqlgraph.To(employee.Table, employee.FieldID),
  2967. sqlgraph.Edge(sqlgraph.M2O, true, tutorial.EmployeeTable, tutorial.EmployeeColumn),
  2968. )
  2969. fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
  2970. return fromV, nil
  2971. }
  2972. return query
  2973. }
  2974. // Hooks returns the client hooks.
  2975. func (c *TutorialClient) Hooks() []Hook {
  2976. hooks := c.hooks.Tutorial
  2977. return append(hooks[:len(hooks):len(hooks)], tutorial.Hooks[:]...)
  2978. }
  2979. // Interceptors returns the client interceptors.
  2980. func (c *TutorialClient) Interceptors() []Interceptor {
  2981. inters := c.inters.Tutorial
  2982. return append(inters[:len(inters):len(inters)], tutorial.Interceptors[:]...)
  2983. }
  2984. func (c *TutorialClient) mutate(ctx context.Context, m *TutorialMutation) (Value, error) {
  2985. switch m.Op() {
  2986. case OpCreate:
  2987. return (&TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2988. case OpUpdate:
  2989. return (&TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2990. case OpUpdateOne:
  2991. return (&TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2992. case OpDelete, OpDeleteOne:
  2993. return (&TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2994. default:
  2995. return nil, fmt.Errorf("ent: unknown Tutorial mutation op: %q", m.Op())
  2996. }
  2997. }
  2998. // WorkExperienceClient is a client for the WorkExperience schema.
  2999. type WorkExperienceClient struct {
  3000. config
  3001. }
  3002. // NewWorkExperienceClient returns a client for the WorkExperience from the given config.
  3003. func NewWorkExperienceClient(c config) *WorkExperienceClient {
  3004. return &WorkExperienceClient{config: c}
  3005. }
  3006. // Use adds a list of mutation hooks to the hooks stack.
  3007. // A call to `Use(f, g, h)` equals to `workexperience.Hooks(f(g(h())))`.
  3008. func (c *WorkExperienceClient) Use(hooks ...Hook) {
  3009. c.hooks.WorkExperience = append(c.hooks.WorkExperience, hooks...)
  3010. }
  3011. // Intercept adds a list of query interceptors to the interceptors stack.
  3012. // A call to `Intercept(f, g, h)` equals to `workexperience.Intercept(f(g(h())))`.
  3013. func (c *WorkExperienceClient) Intercept(interceptors ...Interceptor) {
  3014. c.inters.WorkExperience = append(c.inters.WorkExperience, interceptors...)
  3015. }
  3016. // Create returns a builder for creating a WorkExperience entity.
  3017. func (c *WorkExperienceClient) Create() *WorkExperienceCreate {
  3018. mutation := newWorkExperienceMutation(c.config, OpCreate)
  3019. return &WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3020. }
  3021. // CreateBulk returns a builder for creating a bulk of WorkExperience entities.
  3022. func (c *WorkExperienceClient) CreateBulk(builders ...*WorkExperienceCreate) *WorkExperienceCreateBulk {
  3023. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  3024. }
  3025. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3026. // a builder and applies setFunc on it.
  3027. func (c *WorkExperienceClient) MapCreateBulk(slice any, setFunc func(*WorkExperienceCreate, int)) *WorkExperienceCreateBulk {
  3028. rv := reflect.ValueOf(slice)
  3029. if rv.Kind() != reflect.Slice {
  3030. return &WorkExperienceCreateBulk{err: fmt.Errorf("calling to WorkExperienceClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3031. }
  3032. builders := make([]*WorkExperienceCreate, rv.Len())
  3033. for i := 0; i < rv.Len(); i++ {
  3034. builders[i] = c.Create()
  3035. setFunc(builders[i], i)
  3036. }
  3037. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  3038. }
  3039. // Update returns an update builder for WorkExperience.
  3040. func (c *WorkExperienceClient) Update() *WorkExperienceUpdate {
  3041. mutation := newWorkExperienceMutation(c.config, OpUpdate)
  3042. return &WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3043. }
  3044. // UpdateOne returns an update builder for the given entity.
  3045. func (c *WorkExperienceClient) UpdateOne(we *WorkExperience) *WorkExperienceUpdateOne {
  3046. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperience(we))
  3047. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3048. }
  3049. // UpdateOneID returns an update builder for the given id.
  3050. func (c *WorkExperienceClient) UpdateOneID(id uint64) *WorkExperienceUpdateOne {
  3051. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperienceID(id))
  3052. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3053. }
  3054. // Delete returns a delete builder for WorkExperience.
  3055. func (c *WorkExperienceClient) Delete() *WorkExperienceDelete {
  3056. mutation := newWorkExperienceMutation(c.config, OpDelete)
  3057. return &WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3058. }
  3059. // DeleteOne returns a builder for deleting the given entity.
  3060. func (c *WorkExperienceClient) DeleteOne(we *WorkExperience) *WorkExperienceDeleteOne {
  3061. return c.DeleteOneID(we.ID)
  3062. }
  3063. // DeleteOneID returns a builder for deleting the given entity by its id.
  3064. func (c *WorkExperienceClient) DeleteOneID(id uint64) *WorkExperienceDeleteOne {
  3065. builder := c.Delete().Where(workexperience.ID(id))
  3066. builder.mutation.id = &id
  3067. builder.mutation.op = OpDeleteOne
  3068. return &WorkExperienceDeleteOne{builder}
  3069. }
  3070. // Query returns a query builder for WorkExperience.
  3071. func (c *WorkExperienceClient) Query() *WorkExperienceQuery {
  3072. return &WorkExperienceQuery{
  3073. config: c.config,
  3074. ctx: &QueryContext{Type: TypeWorkExperience},
  3075. inters: c.Interceptors(),
  3076. }
  3077. }
  3078. // Get returns a WorkExperience entity by its id.
  3079. func (c *WorkExperienceClient) Get(ctx context.Context, id uint64) (*WorkExperience, error) {
  3080. return c.Query().Where(workexperience.ID(id)).Only(ctx)
  3081. }
  3082. // GetX is like Get, but panics if an error occurs.
  3083. func (c *WorkExperienceClient) GetX(ctx context.Context, id uint64) *WorkExperience {
  3084. obj, err := c.Get(ctx, id)
  3085. if err != nil {
  3086. panic(err)
  3087. }
  3088. return obj
  3089. }
  3090. // QueryEmployee queries the employee edge of a WorkExperience.
  3091. func (c *WorkExperienceClient) QueryEmployee(we *WorkExperience) *EmployeeQuery {
  3092. query := (&EmployeeClient{config: c.config}).Query()
  3093. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3094. id := we.ID
  3095. step := sqlgraph.NewStep(
  3096. sqlgraph.From(workexperience.Table, workexperience.FieldID, id),
  3097. sqlgraph.To(employee.Table, employee.FieldID),
  3098. sqlgraph.Edge(sqlgraph.M2O, true, workexperience.EmployeeTable, workexperience.EmployeeColumn),
  3099. )
  3100. fromV = sqlgraph.Neighbors(we.driver.Dialect(), step)
  3101. return fromV, nil
  3102. }
  3103. return query
  3104. }
  3105. // Hooks returns the client hooks.
  3106. func (c *WorkExperienceClient) Hooks() []Hook {
  3107. hooks := c.hooks.WorkExperience
  3108. return append(hooks[:len(hooks):len(hooks)], workexperience.Hooks[:]...)
  3109. }
  3110. // Interceptors returns the client interceptors.
  3111. func (c *WorkExperienceClient) Interceptors() []Interceptor {
  3112. inters := c.inters.WorkExperience
  3113. return append(inters[:len(inters):len(inters)], workexperience.Interceptors[:]...)
  3114. }
  3115. func (c *WorkExperienceClient) mutate(ctx context.Context, m *WorkExperienceMutation) (Value, error) {
  3116. switch m.Op() {
  3117. case OpCreate:
  3118. return (&WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3119. case OpUpdate:
  3120. return (&WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3121. case OpUpdateOne:
  3122. return (&WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3123. case OpDelete, OpDeleteOne:
  3124. return (&WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3125. default:
  3126. return nil, fmt.Errorf("ent: unknown WorkExperience mutation op: %q", m.Op())
  3127. }
  3128. }
  3129. // WxClient is a client for the Wx schema.
  3130. type WxClient struct {
  3131. config
  3132. }
  3133. // NewWxClient returns a client for the Wx from the given config.
  3134. func NewWxClient(c config) *WxClient {
  3135. return &WxClient{config: c}
  3136. }
  3137. // Use adds a list of mutation hooks to the hooks stack.
  3138. // A call to `Use(f, g, h)` equals to `wx.Hooks(f(g(h())))`.
  3139. func (c *WxClient) Use(hooks ...Hook) {
  3140. c.hooks.Wx = append(c.hooks.Wx, hooks...)
  3141. }
  3142. // Intercept adds a list of query interceptors to the interceptors stack.
  3143. // A call to `Intercept(f, g, h)` equals to `wx.Intercept(f(g(h())))`.
  3144. func (c *WxClient) Intercept(interceptors ...Interceptor) {
  3145. c.inters.Wx = append(c.inters.Wx, interceptors...)
  3146. }
  3147. // Create returns a builder for creating a Wx entity.
  3148. func (c *WxClient) Create() *WxCreate {
  3149. mutation := newWxMutation(c.config, OpCreate)
  3150. return &WxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3151. }
  3152. // CreateBulk returns a builder for creating a bulk of Wx entities.
  3153. func (c *WxClient) CreateBulk(builders ...*WxCreate) *WxCreateBulk {
  3154. return &WxCreateBulk{config: c.config, builders: builders}
  3155. }
  3156. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3157. // a builder and applies setFunc on it.
  3158. func (c *WxClient) MapCreateBulk(slice any, setFunc func(*WxCreate, int)) *WxCreateBulk {
  3159. rv := reflect.ValueOf(slice)
  3160. if rv.Kind() != reflect.Slice {
  3161. return &WxCreateBulk{err: fmt.Errorf("calling to WxClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3162. }
  3163. builders := make([]*WxCreate, rv.Len())
  3164. for i := 0; i < rv.Len(); i++ {
  3165. builders[i] = c.Create()
  3166. setFunc(builders[i], i)
  3167. }
  3168. return &WxCreateBulk{config: c.config, builders: builders}
  3169. }
  3170. // Update returns an update builder for Wx.
  3171. func (c *WxClient) Update() *WxUpdate {
  3172. mutation := newWxMutation(c.config, OpUpdate)
  3173. return &WxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3174. }
  3175. // UpdateOne returns an update builder for the given entity.
  3176. func (c *WxClient) UpdateOne(w *Wx) *WxUpdateOne {
  3177. mutation := newWxMutation(c.config, OpUpdateOne, withWx(w))
  3178. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3179. }
  3180. // UpdateOneID returns an update builder for the given id.
  3181. func (c *WxClient) UpdateOneID(id uint64) *WxUpdateOne {
  3182. mutation := newWxMutation(c.config, OpUpdateOne, withWxID(id))
  3183. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3184. }
  3185. // Delete returns a delete builder for Wx.
  3186. func (c *WxClient) Delete() *WxDelete {
  3187. mutation := newWxMutation(c.config, OpDelete)
  3188. return &WxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3189. }
  3190. // DeleteOne returns a builder for deleting the given entity.
  3191. func (c *WxClient) DeleteOne(w *Wx) *WxDeleteOne {
  3192. return c.DeleteOneID(w.ID)
  3193. }
  3194. // DeleteOneID returns a builder for deleting the given entity by its id.
  3195. func (c *WxClient) DeleteOneID(id uint64) *WxDeleteOne {
  3196. builder := c.Delete().Where(wx.ID(id))
  3197. builder.mutation.id = &id
  3198. builder.mutation.op = OpDeleteOne
  3199. return &WxDeleteOne{builder}
  3200. }
  3201. // Query returns a query builder for Wx.
  3202. func (c *WxClient) Query() *WxQuery {
  3203. return &WxQuery{
  3204. config: c.config,
  3205. ctx: &QueryContext{Type: TypeWx},
  3206. inters: c.Interceptors(),
  3207. }
  3208. }
  3209. // Get returns a Wx entity by its id.
  3210. func (c *WxClient) Get(ctx context.Context, id uint64) (*Wx, error) {
  3211. return c.Query().Where(wx.ID(id)).Only(ctx)
  3212. }
  3213. // GetX is like Get, but panics if an error occurs.
  3214. func (c *WxClient) GetX(ctx context.Context, id uint64) *Wx {
  3215. obj, err := c.Get(ctx, id)
  3216. if err != nil {
  3217. panic(err)
  3218. }
  3219. return obj
  3220. }
  3221. // QueryServer queries the server edge of a Wx.
  3222. func (c *WxClient) QueryServer(w *Wx) *ServerQuery {
  3223. query := (&ServerClient{config: c.config}).Query()
  3224. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3225. id := w.ID
  3226. step := sqlgraph.NewStep(
  3227. sqlgraph.From(wx.Table, wx.FieldID, id),
  3228. sqlgraph.To(server.Table, server.FieldID),
  3229. sqlgraph.Edge(sqlgraph.M2O, true, wx.ServerTable, wx.ServerColumn),
  3230. )
  3231. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  3232. return fromV, nil
  3233. }
  3234. return query
  3235. }
  3236. // QueryAgent queries the agent edge of a Wx.
  3237. func (c *WxClient) QueryAgent(w *Wx) *AgentQuery {
  3238. query := (&AgentClient{config: c.config}).Query()
  3239. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3240. id := w.ID
  3241. step := sqlgraph.NewStep(
  3242. sqlgraph.From(wx.Table, wx.FieldID, id),
  3243. sqlgraph.To(agent.Table, agent.FieldID),
  3244. sqlgraph.Edge(sqlgraph.M2O, true, wx.AgentTable, wx.AgentColumn),
  3245. )
  3246. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  3247. return fromV, nil
  3248. }
  3249. return query
  3250. }
  3251. // Hooks returns the client hooks.
  3252. func (c *WxClient) Hooks() []Hook {
  3253. hooks := c.hooks.Wx
  3254. return append(hooks[:len(hooks):len(hooks)], wx.Hooks[:]...)
  3255. }
  3256. // Interceptors returns the client interceptors.
  3257. func (c *WxClient) Interceptors() []Interceptor {
  3258. inters := c.inters.Wx
  3259. return append(inters[:len(inters):len(inters)], wx.Interceptors[:]...)
  3260. }
  3261. func (c *WxClient) mutate(ctx context.Context, m *WxMutation) (Value, error) {
  3262. switch m.Op() {
  3263. case OpCreate:
  3264. return (&WxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3265. case OpUpdate:
  3266. return (&WxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3267. case OpUpdateOne:
  3268. return (&WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3269. case OpDelete, OpDeleteOne:
  3270. return (&WxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3271. default:
  3272. return nil, fmt.Errorf("ent: unknown Wx mutation op: %q", m.Op())
  3273. }
  3274. }
  3275. // WxCardClient is a client for the WxCard schema.
  3276. type WxCardClient struct {
  3277. config
  3278. }
  3279. // NewWxCardClient returns a client for the WxCard from the given config.
  3280. func NewWxCardClient(c config) *WxCardClient {
  3281. return &WxCardClient{config: c}
  3282. }
  3283. // Use adds a list of mutation hooks to the hooks stack.
  3284. // A call to `Use(f, g, h)` equals to `wxcard.Hooks(f(g(h())))`.
  3285. func (c *WxCardClient) Use(hooks ...Hook) {
  3286. c.hooks.WxCard = append(c.hooks.WxCard, hooks...)
  3287. }
  3288. // Intercept adds a list of query interceptors to the interceptors stack.
  3289. // A call to `Intercept(f, g, h)` equals to `wxcard.Intercept(f(g(h())))`.
  3290. func (c *WxCardClient) Intercept(interceptors ...Interceptor) {
  3291. c.inters.WxCard = append(c.inters.WxCard, interceptors...)
  3292. }
  3293. // Create returns a builder for creating a WxCard entity.
  3294. func (c *WxCardClient) Create() *WxCardCreate {
  3295. mutation := newWxCardMutation(c.config, OpCreate)
  3296. return &WxCardCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3297. }
  3298. // CreateBulk returns a builder for creating a bulk of WxCard entities.
  3299. func (c *WxCardClient) CreateBulk(builders ...*WxCardCreate) *WxCardCreateBulk {
  3300. return &WxCardCreateBulk{config: c.config, builders: builders}
  3301. }
  3302. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3303. // a builder and applies setFunc on it.
  3304. func (c *WxCardClient) MapCreateBulk(slice any, setFunc func(*WxCardCreate, int)) *WxCardCreateBulk {
  3305. rv := reflect.ValueOf(slice)
  3306. if rv.Kind() != reflect.Slice {
  3307. return &WxCardCreateBulk{err: fmt.Errorf("calling to WxCardClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3308. }
  3309. builders := make([]*WxCardCreate, rv.Len())
  3310. for i := 0; i < rv.Len(); i++ {
  3311. builders[i] = c.Create()
  3312. setFunc(builders[i], i)
  3313. }
  3314. return &WxCardCreateBulk{config: c.config, builders: builders}
  3315. }
  3316. // Update returns an update builder for WxCard.
  3317. func (c *WxCardClient) Update() *WxCardUpdate {
  3318. mutation := newWxCardMutation(c.config, OpUpdate)
  3319. return &WxCardUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3320. }
  3321. // UpdateOne returns an update builder for the given entity.
  3322. func (c *WxCardClient) UpdateOne(wc *WxCard) *WxCardUpdateOne {
  3323. mutation := newWxCardMutation(c.config, OpUpdateOne, withWxCard(wc))
  3324. return &WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3325. }
  3326. // UpdateOneID returns an update builder for the given id.
  3327. func (c *WxCardClient) UpdateOneID(id uint64) *WxCardUpdateOne {
  3328. mutation := newWxCardMutation(c.config, OpUpdateOne, withWxCardID(id))
  3329. return &WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3330. }
  3331. // Delete returns a delete builder for WxCard.
  3332. func (c *WxCardClient) Delete() *WxCardDelete {
  3333. mutation := newWxCardMutation(c.config, OpDelete)
  3334. return &WxCardDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3335. }
  3336. // DeleteOne returns a builder for deleting the given entity.
  3337. func (c *WxCardClient) DeleteOne(wc *WxCard) *WxCardDeleteOne {
  3338. return c.DeleteOneID(wc.ID)
  3339. }
  3340. // DeleteOneID returns a builder for deleting the given entity by its id.
  3341. func (c *WxCardClient) DeleteOneID(id uint64) *WxCardDeleteOne {
  3342. builder := c.Delete().Where(wxcard.ID(id))
  3343. builder.mutation.id = &id
  3344. builder.mutation.op = OpDeleteOne
  3345. return &WxCardDeleteOne{builder}
  3346. }
  3347. // Query returns a query builder for WxCard.
  3348. func (c *WxCardClient) Query() *WxCardQuery {
  3349. return &WxCardQuery{
  3350. config: c.config,
  3351. ctx: &QueryContext{Type: TypeWxCard},
  3352. inters: c.Interceptors(),
  3353. }
  3354. }
  3355. // Get returns a WxCard entity by its id.
  3356. func (c *WxCardClient) Get(ctx context.Context, id uint64) (*WxCard, error) {
  3357. return c.Query().Where(wxcard.ID(id)).Only(ctx)
  3358. }
  3359. // GetX is like Get, but panics if an error occurs.
  3360. func (c *WxCardClient) GetX(ctx context.Context, id uint64) *WxCard {
  3361. obj, err := c.Get(ctx, id)
  3362. if err != nil {
  3363. panic(err)
  3364. }
  3365. return obj
  3366. }
  3367. // Hooks returns the client hooks.
  3368. func (c *WxCardClient) Hooks() []Hook {
  3369. hooks := c.hooks.WxCard
  3370. return append(hooks[:len(hooks):len(hooks)], wxcard.Hooks[:]...)
  3371. }
  3372. // Interceptors returns the client interceptors.
  3373. func (c *WxCardClient) Interceptors() []Interceptor {
  3374. inters := c.inters.WxCard
  3375. return append(inters[:len(inters):len(inters)], wxcard.Interceptors[:]...)
  3376. }
  3377. func (c *WxCardClient) mutate(ctx context.Context, m *WxCardMutation) (Value, error) {
  3378. switch m.Op() {
  3379. case OpCreate:
  3380. return (&WxCardCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3381. case OpUpdate:
  3382. return (&WxCardUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3383. case OpUpdateOne:
  3384. return (&WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3385. case OpDelete, OpDeleteOne:
  3386. return (&WxCardDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3387. default:
  3388. return nil, fmt.Errorf("ent: unknown WxCard mutation op: %q", m.Op())
  3389. }
  3390. }
  3391. // WxCardUserClient is a client for the WxCardUser schema.
  3392. type WxCardUserClient struct {
  3393. config
  3394. }
  3395. // NewWxCardUserClient returns a client for the WxCardUser from the given config.
  3396. func NewWxCardUserClient(c config) *WxCardUserClient {
  3397. return &WxCardUserClient{config: c}
  3398. }
  3399. // Use adds a list of mutation hooks to the hooks stack.
  3400. // A call to `Use(f, g, h)` equals to `wxcarduser.Hooks(f(g(h())))`.
  3401. func (c *WxCardUserClient) Use(hooks ...Hook) {
  3402. c.hooks.WxCardUser = append(c.hooks.WxCardUser, hooks...)
  3403. }
  3404. // Intercept adds a list of query interceptors to the interceptors stack.
  3405. // A call to `Intercept(f, g, h)` equals to `wxcarduser.Intercept(f(g(h())))`.
  3406. func (c *WxCardUserClient) Intercept(interceptors ...Interceptor) {
  3407. c.inters.WxCardUser = append(c.inters.WxCardUser, interceptors...)
  3408. }
  3409. // Create returns a builder for creating a WxCardUser entity.
  3410. func (c *WxCardUserClient) Create() *WxCardUserCreate {
  3411. mutation := newWxCardUserMutation(c.config, OpCreate)
  3412. return &WxCardUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3413. }
  3414. // CreateBulk returns a builder for creating a bulk of WxCardUser entities.
  3415. func (c *WxCardUserClient) CreateBulk(builders ...*WxCardUserCreate) *WxCardUserCreateBulk {
  3416. return &WxCardUserCreateBulk{config: c.config, builders: builders}
  3417. }
  3418. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3419. // a builder and applies setFunc on it.
  3420. func (c *WxCardUserClient) MapCreateBulk(slice any, setFunc func(*WxCardUserCreate, int)) *WxCardUserCreateBulk {
  3421. rv := reflect.ValueOf(slice)
  3422. if rv.Kind() != reflect.Slice {
  3423. return &WxCardUserCreateBulk{err: fmt.Errorf("calling to WxCardUserClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3424. }
  3425. builders := make([]*WxCardUserCreate, rv.Len())
  3426. for i := 0; i < rv.Len(); i++ {
  3427. builders[i] = c.Create()
  3428. setFunc(builders[i], i)
  3429. }
  3430. return &WxCardUserCreateBulk{config: c.config, builders: builders}
  3431. }
  3432. // Update returns an update builder for WxCardUser.
  3433. func (c *WxCardUserClient) Update() *WxCardUserUpdate {
  3434. mutation := newWxCardUserMutation(c.config, OpUpdate)
  3435. return &WxCardUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3436. }
  3437. // UpdateOne returns an update builder for the given entity.
  3438. func (c *WxCardUserClient) UpdateOne(wcu *WxCardUser) *WxCardUserUpdateOne {
  3439. mutation := newWxCardUserMutation(c.config, OpUpdateOne, withWxCardUser(wcu))
  3440. return &WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3441. }
  3442. // UpdateOneID returns an update builder for the given id.
  3443. func (c *WxCardUserClient) UpdateOneID(id uint64) *WxCardUserUpdateOne {
  3444. mutation := newWxCardUserMutation(c.config, OpUpdateOne, withWxCardUserID(id))
  3445. return &WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3446. }
  3447. // Delete returns a delete builder for WxCardUser.
  3448. func (c *WxCardUserClient) Delete() *WxCardUserDelete {
  3449. mutation := newWxCardUserMutation(c.config, OpDelete)
  3450. return &WxCardUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3451. }
  3452. // DeleteOne returns a builder for deleting the given entity.
  3453. func (c *WxCardUserClient) DeleteOne(wcu *WxCardUser) *WxCardUserDeleteOne {
  3454. return c.DeleteOneID(wcu.ID)
  3455. }
  3456. // DeleteOneID returns a builder for deleting the given entity by its id.
  3457. func (c *WxCardUserClient) DeleteOneID(id uint64) *WxCardUserDeleteOne {
  3458. builder := c.Delete().Where(wxcarduser.ID(id))
  3459. builder.mutation.id = &id
  3460. builder.mutation.op = OpDeleteOne
  3461. return &WxCardUserDeleteOne{builder}
  3462. }
  3463. // Query returns a query builder for WxCardUser.
  3464. func (c *WxCardUserClient) Query() *WxCardUserQuery {
  3465. return &WxCardUserQuery{
  3466. config: c.config,
  3467. ctx: &QueryContext{Type: TypeWxCardUser},
  3468. inters: c.Interceptors(),
  3469. }
  3470. }
  3471. // Get returns a WxCardUser entity by its id.
  3472. func (c *WxCardUserClient) Get(ctx context.Context, id uint64) (*WxCardUser, error) {
  3473. return c.Query().Where(wxcarduser.ID(id)).Only(ctx)
  3474. }
  3475. // GetX is like Get, but panics if an error occurs.
  3476. func (c *WxCardUserClient) GetX(ctx context.Context, id uint64) *WxCardUser {
  3477. obj, err := c.Get(ctx, id)
  3478. if err != nil {
  3479. panic(err)
  3480. }
  3481. return obj
  3482. }
  3483. // Hooks returns the client hooks.
  3484. func (c *WxCardUserClient) Hooks() []Hook {
  3485. hooks := c.hooks.WxCardUser
  3486. return append(hooks[:len(hooks):len(hooks)], wxcarduser.Hooks[:]...)
  3487. }
  3488. // Interceptors returns the client interceptors.
  3489. func (c *WxCardUserClient) Interceptors() []Interceptor {
  3490. inters := c.inters.WxCardUser
  3491. return append(inters[:len(inters):len(inters)], wxcarduser.Interceptors[:]...)
  3492. }
  3493. func (c *WxCardUserClient) mutate(ctx context.Context, m *WxCardUserMutation) (Value, error) {
  3494. switch m.Op() {
  3495. case OpCreate:
  3496. return (&WxCardUserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3497. case OpUpdate:
  3498. return (&WxCardUserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3499. case OpUpdateOne:
  3500. return (&WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3501. case OpDelete, OpDeleteOne:
  3502. return (&WxCardUserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3503. default:
  3504. return nil, fmt.Errorf("ent: unknown WxCardUser mutation op: %q", m.Op())
  3505. }
  3506. }
  3507. // WxCardVisitClient is a client for the WxCardVisit schema.
  3508. type WxCardVisitClient struct {
  3509. config
  3510. }
  3511. // NewWxCardVisitClient returns a client for the WxCardVisit from the given config.
  3512. func NewWxCardVisitClient(c config) *WxCardVisitClient {
  3513. return &WxCardVisitClient{config: c}
  3514. }
  3515. // Use adds a list of mutation hooks to the hooks stack.
  3516. // A call to `Use(f, g, h)` equals to `wxcardvisit.Hooks(f(g(h())))`.
  3517. func (c *WxCardVisitClient) Use(hooks ...Hook) {
  3518. c.hooks.WxCardVisit = append(c.hooks.WxCardVisit, hooks...)
  3519. }
  3520. // Intercept adds a list of query interceptors to the interceptors stack.
  3521. // A call to `Intercept(f, g, h)` equals to `wxcardvisit.Intercept(f(g(h())))`.
  3522. func (c *WxCardVisitClient) Intercept(interceptors ...Interceptor) {
  3523. c.inters.WxCardVisit = append(c.inters.WxCardVisit, interceptors...)
  3524. }
  3525. // Create returns a builder for creating a WxCardVisit entity.
  3526. func (c *WxCardVisitClient) Create() *WxCardVisitCreate {
  3527. mutation := newWxCardVisitMutation(c.config, OpCreate)
  3528. return &WxCardVisitCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3529. }
  3530. // CreateBulk returns a builder for creating a bulk of WxCardVisit entities.
  3531. func (c *WxCardVisitClient) CreateBulk(builders ...*WxCardVisitCreate) *WxCardVisitCreateBulk {
  3532. return &WxCardVisitCreateBulk{config: c.config, builders: builders}
  3533. }
  3534. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3535. // a builder and applies setFunc on it.
  3536. func (c *WxCardVisitClient) MapCreateBulk(slice any, setFunc func(*WxCardVisitCreate, int)) *WxCardVisitCreateBulk {
  3537. rv := reflect.ValueOf(slice)
  3538. if rv.Kind() != reflect.Slice {
  3539. return &WxCardVisitCreateBulk{err: fmt.Errorf("calling to WxCardVisitClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3540. }
  3541. builders := make([]*WxCardVisitCreate, rv.Len())
  3542. for i := 0; i < rv.Len(); i++ {
  3543. builders[i] = c.Create()
  3544. setFunc(builders[i], i)
  3545. }
  3546. return &WxCardVisitCreateBulk{config: c.config, builders: builders}
  3547. }
  3548. // Update returns an update builder for WxCardVisit.
  3549. func (c *WxCardVisitClient) Update() *WxCardVisitUpdate {
  3550. mutation := newWxCardVisitMutation(c.config, OpUpdate)
  3551. return &WxCardVisitUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3552. }
  3553. // UpdateOne returns an update builder for the given entity.
  3554. func (c *WxCardVisitClient) UpdateOne(wcv *WxCardVisit) *WxCardVisitUpdateOne {
  3555. mutation := newWxCardVisitMutation(c.config, OpUpdateOne, withWxCardVisit(wcv))
  3556. return &WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3557. }
  3558. // UpdateOneID returns an update builder for the given id.
  3559. func (c *WxCardVisitClient) UpdateOneID(id uint64) *WxCardVisitUpdateOne {
  3560. mutation := newWxCardVisitMutation(c.config, OpUpdateOne, withWxCardVisitID(id))
  3561. return &WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3562. }
  3563. // Delete returns a delete builder for WxCardVisit.
  3564. func (c *WxCardVisitClient) Delete() *WxCardVisitDelete {
  3565. mutation := newWxCardVisitMutation(c.config, OpDelete)
  3566. return &WxCardVisitDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3567. }
  3568. // DeleteOne returns a builder for deleting the given entity.
  3569. func (c *WxCardVisitClient) DeleteOne(wcv *WxCardVisit) *WxCardVisitDeleteOne {
  3570. return c.DeleteOneID(wcv.ID)
  3571. }
  3572. // DeleteOneID returns a builder for deleting the given entity by its id.
  3573. func (c *WxCardVisitClient) DeleteOneID(id uint64) *WxCardVisitDeleteOne {
  3574. builder := c.Delete().Where(wxcardvisit.ID(id))
  3575. builder.mutation.id = &id
  3576. builder.mutation.op = OpDeleteOne
  3577. return &WxCardVisitDeleteOne{builder}
  3578. }
  3579. // Query returns a query builder for WxCardVisit.
  3580. func (c *WxCardVisitClient) Query() *WxCardVisitQuery {
  3581. return &WxCardVisitQuery{
  3582. config: c.config,
  3583. ctx: &QueryContext{Type: TypeWxCardVisit},
  3584. inters: c.Interceptors(),
  3585. }
  3586. }
  3587. // Get returns a WxCardVisit entity by its id.
  3588. func (c *WxCardVisitClient) Get(ctx context.Context, id uint64) (*WxCardVisit, error) {
  3589. return c.Query().Where(wxcardvisit.ID(id)).Only(ctx)
  3590. }
  3591. // GetX is like Get, but panics if an error occurs.
  3592. func (c *WxCardVisitClient) GetX(ctx context.Context, id uint64) *WxCardVisit {
  3593. obj, err := c.Get(ctx, id)
  3594. if err != nil {
  3595. panic(err)
  3596. }
  3597. return obj
  3598. }
  3599. // Hooks returns the client hooks.
  3600. func (c *WxCardVisitClient) Hooks() []Hook {
  3601. hooks := c.hooks.WxCardVisit
  3602. return append(hooks[:len(hooks):len(hooks)], wxcardvisit.Hooks[:]...)
  3603. }
  3604. // Interceptors returns the client interceptors.
  3605. func (c *WxCardVisitClient) Interceptors() []Interceptor {
  3606. inters := c.inters.WxCardVisit
  3607. return append(inters[:len(inters):len(inters)], wxcardvisit.Interceptors[:]...)
  3608. }
  3609. func (c *WxCardVisitClient) mutate(ctx context.Context, m *WxCardVisitMutation) (Value, error) {
  3610. switch m.Op() {
  3611. case OpCreate:
  3612. return (&WxCardVisitCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3613. case OpUpdate:
  3614. return (&WxCardVisitUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3615. case OpUpdateOne:
  3616. return (&WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3617. case OpDelete, OpDeleteOne:
  3618. return (&WxCardVisitDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3619. default:
  3620. return nil, fmt.Errorf("ent: unknown WxCardVisit mutation op: %q", m.Op())
  3621. }
  3622. }
  3623. // hooks and interceptors per client, for fast access.
  3624. type (
  3625. hooks struct {
  3626. Agent, AgentBase, BatchMsg, Category, ChatRecords, ChatSession, Contact,
  3627. Employee, EmployeeConfig, Label, LabelRelationship, Message, MessageRecords,
  3628. Msg, Server, SopNode, SopStage, SopTask, Token, Tutorial, WorkExperience, Wx,
  3629. WxCard, WxCardUser, WxCardVisit []ent.Hook
  3630. }
  3631. inters struct {
  3632. Agent, AgentBase, BatchMsg, Category, ChatRecords, ChatSession, Contact,
  3633. Employee, EmployeeConfig, Label, LabelRelationship, Message, MessageRecords,
  3634. Msg, Server, SopNode, SopStage, SopTask, Token, Tutorial, WorkExperience, Wx,
  3635. WxCard, WxCardUser, WxCardVisit []ent.Interceptor
  3636. }
  3637. )
  3638. // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
  3639. // See, database/sql#DB.ExecContext for more information.
  3640. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
  3641. ex, ok := c.driver.(interface {
  3642. ExecContext(context.Context, string, ...any) (stdsql.Result, error)
  3643. })
  3644. if !ok {
  3645. return nil, fmt.Errorf("Driver.ExecContext is not supported")
  3646. }
  3647. return ex.ExecContext(ctx, query, args...)
  3648. }
  3649. // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
  3650. // See, database/sql#DB.QueryContext for more information.
  3651. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
  3652. q, ok := c.driver.(interface {
  3653. QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
  3654. })
  3655. if !ok {
  3656. return nil, fmt.Errorf("Driver.QueryContext is not supported")
  3657. }
  3658. return q.QueryContext(ctx, query, args...)
  3659. }