mutation.go 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "wechat-api/ent/xunji"
  53. "entgo.io/ent"
  54. "entgo.io/ent/dialect/sql"
  55. )
  56. const (
  57. // Operation types.
  58. OpCreate = ent.OpCreate
  59. OpDelete = ent.OpDelete
  60. OpDeleteOne = ent.OpDeleteOne
  61. OpUpdate = ent.OpUpdate
  62. OpUpdateOne = ent.OpUpdateOne
  63. // Node types.
  64. TypeAgent = "Agent"
  65. TypeAgentBase = "AgentBase"
  66. TypeAliyunAvatar = "AliyunAvatar"
  67. TypeAllocAgent = "AllocAgent"
  68. TypeApiKey = "ApiKey"
  69. TypeBatchMsg = "BatchMsg"
  70. TypeCategory = "Category"
  71. TypeChatRecords = "ChatRecords"
  72. TypeChatSession = "ChatSession"
  73. TypeContact = "Contact"
  74. TypeCreditBalance = "CreditBalance"
  75. TypeCreditUsage = "CreditUsage"
  76. TypeEmployee = "Employee"
  77. TypeEmployeeConfig = "EmployeeConfig"
  78. TypeLabel = "Label"
  79. TypeLabelRelationship = "LabelRelationship"
  80. TypeLabelTagging = "LabelTagging"
  81. TypeMessage = "Message"
  82. TypeMessageRecords = "MessageRecords"
  83. TypeMsg = "Msg"
  84. TypePayRecharge = "PayRecharge"
  85. TypeServer = "Server"
  86. TypeSopNode = "SopNode"
  87. TypeSopStage = "SopStage"
  88. TypeSopTask = "SopTask"
  89. TypeToken = "Token"
  90. TypeTutorial = "Tutorial"
  91. TypeUsageDetail = "UsageDetail"
  92. TypeUsageStatisticDay = "UsageStatisticDay"
  93. TypeUsageStatisticHour = "UsageStatisticHour"
  94. TypeUsageStatisticMonth = "UsageStatisticMonth"
  95. TypeUsageTotal = "UsageTotal"
  96. TypeWhatsapp = "Whatsapp"
  97. TypeWhatsappChannel = "WhatsappChannel"
  98. TypeWorkExperience = "WorkExperience"
  99. TypeWpChatroom = "WpChatroom"
  100. TypeWpChatroomMember = "WpChatroomMember"
  101. TypeWx = "Wx"
  102. TypeWxCard = "WxCard"
  103. TypeWxCardUser = "WxCardUser"
  104. TypeWxCardVisit = "WxCardVisit"
  105. TypeXunji = "Xunji"
  106. )
  107. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  108. type AgentMutation struct {
  109. config
  110. op Op
  111. typ string
  112. id *uint64
  113. created_at *time.Time
  114. updated_at *time.Time
  115. deleted_at *time.Time
  116. name *string
  117. role *string
  118. status *int
  119. addstatus *int
  120. background *string
  121. examples *string
  122. organization_id *uint64
  123. addorganization_id *int64
  124. dataset_id *string
  125. collection_id *string
  126. clearedFields map[string]struct{}
  127. wx_agent map[uint64]struct{}
  128. removedwx_agent map[uint64]struct{}
  129. clearedwx_agent bool
  130. token_agent map[uint64]struct{}
  131. removedtoken_agent map[uint64]struct{}
  132. clearedtoken_agent bool
  133. wa_agent map[uint64]struct{}
  134. removedwa_agent map[uint64]struct{}
  135. clearedwa_agent bool
  136. key_agent map[uint64]struct{}
  137. removedkey_agent map[uint64]struct{}
  138. clearedkey_agent bool
  139. done bool
  140. oldValue func(context.Context) (*Agent, error)
  141. predicates []predicate.Agent
  142. }
  143. var _ ent.Mutation = (*AgentMutation)(nil)
  144. // agentOption allows management of the mutation configuration using functional options.
  145. type agentOption func(*AgentMutation)
  146. // newAgentMutation creates new mutation for the Agent entity.
  147. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  148. m := &AgentMutation{
  149. config: c,
  150. op: op,
  151. typ: TypeAgent,
  152. clearedFields: make(map[string]struct{}),
  153. }
  154. for _, opt := range opts {
  155. opt(m)
  156. }
  157. return m
  158. }
  159. // withAgentID sets the ID field of the mutation.
  160. func withAgentID(id uint64) agentOption {
  161. return func(m *AgentMutation) {
  162. var (
  163. err error
  164. once sync.Once
  165. value *Agent
  166. )
  167. m.oldValue = func(ctx context.Context) (*Agent, error) {
  168. once.Do(func() {
  169. if m.done {
  170. err = errors.New("querying old values post mutation is not allowed")
  171. } else {
  172. value, err = m.Client().Agent.Get(ctx, id)
  173. }
  174. })
  175. return value, err
  176. }
  177. m.id = &id
  178. }
  179. }
  180. // withAgent sets the old Agent of the mutation.
  181. func withAgent(node *Agent) agentOption {
  182. return func(m *AgentMutation) {
  183. m.oldValue = func(context.Context) (*Agent, error) {
  184. return node, nil
  185. }
  186. m.id = &node.ID
  187. }
  188. }
  189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  190. // executed in a transaction (ent.Tx), a transactional client is returned.
  191. func (m AgentMutation) Client() *Client {
  192. client := &Client{config: m.config}
  193. client.init()
  194. return client
  195. }
  196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  197. // it returns an error otherwise.
  198. func (m AgentMutation) Tx() (*Tx, error) {
  199. if _, ok := m.driver.(*txDriver); !ok {
  200. return nil, errors.New("ent: mutation is not running in a transaction")
  201. }
  202. tx := &Tx{config: m.config}
  203. tx.init()
  204. return tx, nil
  205. }
  206. // SetID sets the value of the id field. Note that this
  207. // operation is only accepted on creation of Agent entities.
  208. func (m *AgentMutation) SetID(id uint64) {
  209. m.id = &id
  210. }
  211. // ID returns the ID value in the mutation. Note that the ID is only available
  212. // if it was provided to the builder or after it was returned from the database.
  213. func (m *AgentMutation) ID() (id uint64, exists bool) {
  214. if m.id == nil {
  215. return
  216. }
  217. return *m.id, true
  218. }
  219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  220. // That means, if the mutation is applied within a transaction with an isolation level such
  221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  222. // or updated by the mutation.
  223. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  224. switch {
  225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  226. id, exists := m.ID()
  227. if exists {
  228. return []uint64{id}, nil
  229. }
  230. fallthrough
  231. case m.op.Is(OpUpdate | OpDelete):
  232. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  233. default:
  234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  235. }
  236. }
  237. // SetCreatedAt sets the "created_at" field.
  238. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  239. m.created_at = &t
  240. }
  241. // CreatedAt returns the value of the "created_at" field in the mutation.
  242. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  243. v := m.created_at
  244. if v == nil {
  245. return
  246. }
  247. return *v, true
  248. }
  249. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  250. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  252. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  253. if !m.op.Is(OpUpdateOne) {
  254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  255. }
  256. if m.id == nil || m.oldValue == nil {
  257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  258. }
  259. oldValue, err := m.oldValue(ctx)
  260. if err != nil {
  261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  262. }
  263. return oldValue.CreatedAt, nil
  264. }
  265. // ResetCreatedAt resets all changes to the "created_at" field.
  266. func (m *AgentMutation) ResetCreatedAt() {
  267. m.created_at = nil
  268. }
  269. // SetUpdatedAt sets the "updated_at" field.
  270. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  271. m.updated_at = &t
  272. }
  273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  274. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  275. v := m.updated_at
  276. if v == nil {
  277. return
  278. }
  279. return *v, true
  280. }
  281. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  282. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  284. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  285. if !m.op.Is(OpUpdateOne) {
  286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  287. }
  288. if m.id == nil || m.oldValue == nil {
  289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  290. }
  291. oldValue, err := m.oldValue(ctx)
  292. if err != nil {
  293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  294. }
  295. return oldValue.UpdatedAt, nil
  296. }
  297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  298. func (m *AgentMutation) ResetUpdatedAt() {
  299. m.updated_at = nil
  300. }
  301. // SetDeletedAt sets the "deleted_at" field.
  302. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  303. m.deleted_at = &t
  304. }
  305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  306. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  307. v := m.deleted_at
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  326. }
  327. return oldValue.DeletedAt, nil
  328. }
  329. // ClearDeletedAt clears the value of the "deleted_at" field.
  330. func (m *AgentMutation) ClearDeletedAt() {
  331. m.deleted_at = nil
  332. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  333. }
  334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  335. func (m *AgentMutation) DeletedAtCleared() bool {
  336. _, ok := m.clearedFields[agent.FieldDeletedAt]
  337. return ok
  338. }
  339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  340. func (m *AgentMutation) ResetDeletedAt() {
  341. m.deleted_at = nil
  342. delete(m.clearedFields, agent.FieldDeletedAt)
  343. }
  344. // SetName sets the "name" field.
  345. func (m *AgentMutation) SetName(s string) {
  346. m.name = &s
  347. }
  348. // Name returns the value of the "name" field in the mutation.
  349. func (m *AgentMutation) Name() (r string, exists bool) {
  350. v := m.name
  351. if v == nil {
  352. return
  353. }
  354. return *v, true
  355. }
  356. // OldName returns the old "name" field's value of the Agent entity.
  357. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  359. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  360. if !m.op.Is(OpUpdateOne) {
  361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  362. }
  363. if m.id == nil || m.oldValue == nil {
  364. return v, errors.New("OldName requires an ID field in the mutation")
  365. }
  366. oldValue, err := m.oldValue(ctx)
  367. if err != nil {
  368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  369. }
  370. return oldValue.Name, nil
  371. }
  372. // ResetName resets all changes to the "name" field.
  373. func (m *AgentMutation) ResetName() {
  374. m.name = nil
  375. }
  376. // SetRole sets the "role" field.
  377. func (m *AgentMutation) SetRole(s string) {
  378. m.role = &s
  379. }
  380. // Role returns the value of the "role" field in the mutation.
  381. func (m *AgentMutation) Role() (r string, exists bool) {
  382. v := m.role
  383. if v == nil {
  384. return
  385. }
  386. return *v, true
  387. }
  388. // OldRole returns the old "role" field's value of the Agent entity.
  389. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  391. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  392. if !m.op.Is(OpUpdateOne) {
  393. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  394. }
  395. if m.id == nil || m.oldValue == nil {
  396. return v, errors.New("OldRole requires an ID field in the mutation")
  397. }
  398. oldValue, err := m.oldValue(ctx)
  399. if err != nil {
  400. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  401. }
  402. return oldValue.Role, nil
  403. }
  404. // ResetRole resets all changes to the "role" field.
  405. func (m *AgentMutation) ResetRole() {
  406. m.role = nil
  407. }
  408. // SetStatus sets the "status" field.
  409. func (m *AgentMutation) SetStatus(i int) {
  410. m.status = &i
  411. m.addstatus = nil
  412. }
  413. // Status returns the value of the "status" field in the mutation.
  414. func (m *AgentMutation) Status() (r int, exists bool) {
  415. v := m.status
  416. if v == nil {
  417. return
  418. }
  419. return *v, true
  420. }
  421. // OldStatus returns the old "status" field's value of the Agent entity.
  422. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  424. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  425. if !m.op.Is(OpUpdateOne) {
  426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  427. }
  428. if m.id == nil || m.oldValue == nil {
  429. return v, errors.New("OldStatus requires an ID field in the mutation")
  430. }
  431. oldValue, err := m.oldValue(ctx)
  432. if err != nil {
  433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  434. }
  435. return oldValue.Status, nil
  436. }
  437. // AddStatus adds i to the "status" field.
  438. func (m *AgentMutation) AddStatus(i int) {
  439. if m.addstatus != nil {
  440. *m.addstatus += i
  441. } else {
  442. m.addstatus = &i
  443. }
  444. }
  445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  446. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  447. v := m.addstatus
  448. if v == nil {
  449. return
  450. }
  451. return *v, true
  452. }
  453. // ClearStatus clears the value of the "status" field.
  454. func (m *AgentMutation) ClearStatus() {
  455. m.status = nil
  456. m.addstatus = nil
  457. m.clearedFields[agent.FieldStatus] = struct{}{}
  458. }
  459. // StatusCleared returns if the "status" field was cleared in this mutation.
  460. func (m *AgentMutation) StatusCleared() bool {
  461. _, ok := m.clearedFields[agent.FieldStatus]
  462. return ok
  463. }
  464. // ResetStatus resets all changes to the "status" field.
  465. func (m *AgentMutation) ResetStatus() {
  466. m.status = nil
  467. m.addstatus = nil
  468. delete(m.clearedFields, agent.FieldStatus)
  469. }
  470. // SetBackground sets the "background" field.
  471. func (m *AgentMutation) SetBackground(s string) {
  472. m.background = &s
  473. }
  474. // Background returns the value of the "background" field in the mutation.
  475. func (m *AgentMutation) Background() (r string, exists bool) {
  476. v := m.background
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldBackground returns the old "background" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldBackground requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  495. }
  496. return oldValue.Background, nil
  497. }
  498. // ClearBackground clears the value of the "background" field.
  499. func (m *AgentMutation) ClearBackground() {
  500. m.background = nil
  501. m.clearedFields[agent.FieldBackground] = struct{}{}
  502. }
  503. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  504. func (m *AgentMutation) BackgroundCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldBackground]
  506. return ok
  507. }
  508. // ResetBackground resets all changes to the "background" field.
  509. func (m *AgentMutation) ResetBackground() {
  510. m.background = nil
  511. delete(m.clearedFields, agent.FieldBackground)
  512. }
  513. // SetExamples sets the "examples" field.
  514. func (m *AgentMutation) SetExamples(s string) {
  515. m.examples = &s
  516. }
  517. // Examples returns the value of the "examples" field in the mutation.
  518. func (m *AgentMutation) Examples() (r string, exists bool) {
  519. v := m.examples
  520. if v == nil {
  521. return
  522. }
  523. return *v, true
  524. }
  525. // OldExamples returns the old "examples" field's value of the Agent entity.
  526. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  528. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  529. if !m.op.Is(OpUpdateOne) {
  530. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  531. }
  532. if m.id == nil || m.oldValue == nil {
  533. return v, errors.New("OldExamples requires an ID field in the mutation")
  534. }
  535. oldValue, err := m.oldValue(ctx)
  536. if err != nil {
  537. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  538. }
  539. return oldValue.Examples, nil
  540. }
  541. // ClearExamples clears the value of the "examples" field.
  542. func (m *AgentMutation) ClearExamples() {
  543. m.examples = nil
  544. m.clearedFields[agent.FieldExamples] = struct{}{}
  545. }
  546. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  547. func (m *AgentMutation) ExamplesCleared() bool {
  548. _, ok := m.clearedFields[agent.FieldExamples]
  549. return ok
  550. }
  551. // ResetExamples resets all changes to the "examples" field.
  552. func (m *AgentMutation) ResetExamples() {
  553. m.examples = nil
  554. delete(m.clearedFields, agent.FieldExamples)
  555. }
  556. // SetOrganizationID sets the "organization_id" field.
  557. func (m *AgentMutation) SetOrganizationID(u uint64) {
  558. m.organization_id = &u
  559. m.addorganization_id = nil
  560. }
  561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  562. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  563. v := m.organization_id
  564. if v == nil {
  565. return
  566. }
  567. return *v, true
  568. }
  569. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  570. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  572. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  573. if !m.op.Is(OpUpdateOne) {
  574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  575. }
  576. if m.id == nil || m.oldValue == nil {
  577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  578. }
  579. oldValue, err := m.oldValue(ctx)
  580. if err != nil {
  581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  582. }
  583. return oldValue.OrganizationID, nil
  584. }
  585. // AddOrganizationID adds u to the "organization_id" field.
  586. func (m *AgentMutation) AddOrganizationID(u int64) {
  587. if m.addorganization_id != nil {
  588. *m.addorganization_id += u
  589. } else {
  590. m.addorganization_id = &u
  591. }
  592. }
  593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  594. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  595. v := m.addorganization_id
  596. if v == nil {
  597. return
  598. }
  599. return *v, true
  600. }
  601. // ResetOrganizationID resets all changes to the "organization_id" field.
  602. func (m *AgentMutation) ResetOrganizationID() {
  603. m.organization_id = nil
  604. m.addorganization_id = nil
  605. }
  606. // SetDatasetID sets the "dataset_id" field.
  607. func (m *AgentMutation) SetDatasetID(s string) {
  608. m.dataset_id = &s
  609. }
  610. // DatasetID returns the value of the "dataset_id" field in the mutation.
  611. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  612. v := m.dataset_id
  613. if v == nil {
  614. return
  615. }
  616. return *v, true
  617. }
  618. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  619. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  621. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  622. if !m.op.Is(OpUpdateOne) {
  623. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  624. }
  625. if m.id == nil || m.oldValue == nil {
  626. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  627. }
  628. oldValue, err := m.oldValue(ctx)
  629. if err != nil {
  630. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  631. }
  632. return oldValue.DatasetID, nil
  633. }
  634. // ResetDatasetID resets all changes to the "dataset_id" field.
  635. func (m *AgentMutation) ResetDatasetID() {
  636. m.dataset_id = nil
  637. }
  638. // SetCollectionID sets the "collection_id" field.
  639. func (m *AgentMutation) SetCollectionID(s string) {
  640. m.collection_id = &s
  641. }
  642. // CollectionID returns the value of the "collection_id" field in the mutation.
  643. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  644. v := m.collection_id
  645. if v == nil {
  646. return
  647. }
  648. return *v, true
  649. }
  650. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  651. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  653. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  654. if !m.op.Is(OpUpdateOne) {
  655. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  656. }
  657. if m.id == nil || m.oldValue == nil {
  658. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  659. }
  660. oldValue, err := m.oldValue(ctx)
  661. if err != nil {
  662. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  663. }
  664. return oldValue.CollectionID, nil
  665. }
  666. // ResetCollectionID resets all changes to the "collection_id" field.
  667. func (m *AgentMutation) ResetCollectionID() {
  668. m.collection_id = nil
  669. }
  670. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  671. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  672. if m.wx_agent == nil {
  673. m.wx_agent = make(map[uint64]struct{})
  674. }
  675. for i := range ids {
  676. m.wx_agent[ids[i]] = struct{}{}
  677. }
  678. }
  679. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  680. func (m *AgentMutation) ClearWxAgent() {
  681. m.clearedwx_agent = true
  682. }
  683. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  684. func (m *AgentMutation) WxAgentCleared() bool {
  685. return m.clearedwx_agent
  686. }
  687. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  688. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  689. if m.removedwx_agent == nil {
  690. m.removedwx_agent = make(map[uint64]struct{})
  691. }
  692. for i := range ids {
  693. delete(m.wx_agent, ids[i])
  694. m.removedwx_agent[ids[i]] = struct{}{}
  695. }
  696. }
  697. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  698. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  699. for id := range m.removedwx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  705. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  706. for id := range m.wx_agent {
  707. ids = append(ids, id)
  708. }
  709. return
  710. }
  711. // ResetWxAgent resets all changes to the "wx_agent" edge.
  712. func (m *AgentMutation) ResetWxAgent() {
  713. m.wx_agent = nil
  714. m.clearedwx_agent = false
  715. m.removedwx_agent = nil
  716. }
  717. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  718. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  719. if m.token_agent == nil {
  720. m.token_agent = make(map[uint64]struct{})
  721. }
  722. for i := range ids {
  723. m.token_agent[ids[i]] = struct{}{}
  724. }
  725. }
  726. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  727. func (m *AgentMutation) ClearTokenAgent() {
  728. m.clearedtoken_agent = true
  729. }
  730. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  731. func (m *AgentMutation) TokenAgentCleared() bool {
  732. return m.clearedtoken_agent
  733. }
  734. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  735. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  736. if m.removedtoken_agent == nil {
  737. m.removedtoken_agent = make(map[uint64]struct{})
  738. }
  739. for i := range ids {
  740. delete(m.token_agent, ids[i])
  741. m.removedtoken_agent[ids[i]] = struct{}{}
  742. }
  743. }
  744. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  745. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  746. for id := range m.removedtoken_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  752. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  753. for id := range m.token_agent {
  754. ids = append(ids, id)
  755. }
  756. return
  757. }
  758. // ResetTokenAgent resets all changes to the "token_agent" edge.
  759. func (m *AgentMutation) ResetTokenAgent() {
  760. m.token_agent = nil
  761. m.clearedtoken_agent = false
  762. m.removedtoken_agent = nil
  763. }
  764. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  765. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  766. if m.wa_agent == nil {
  767. m.wa_agent = make(map[uint64]struct{})
  768. }
  769. for i := range ids {
  770. m.wa_agent[ids[i]] = struct{}{}
  771. }
  772. }
  773. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  774. func (m *AgentMutation) ClearWaAgent() {
  775. m.clearedwa_agent = true
  776. }
  777. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  778. func (m *AgentMutation) WaAgentCleared() bool {
  779. return m.clearedwa_agent
  780. }
  781. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  782. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  783. if m.removedwa_agent == nil {
  784. m.removedwa_agent = make(map[uint64]struct{})
  785. }
  786. for i := range ids {
  787. delete(m.wa_agent, ids[i])
  788. m.removedwa_agent[ids[i]] = struct{}{}
  789. }
  790. }
  791. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  792. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  793. for id := range m.removedwa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  799. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  800. for id := range m.wa_agent {
  801. ids = append(ids, id)
  802. }
  803. return
  804. }
  805. // ResetWaAgent resets all changes to the "wa_agent" edge.
  806. func (m *AgentMutation) ResetWaAgent() {
  807. m.wa_agent = nil
  808. m.clearedwa_agent = false
  809. m.removedwa_agent = nil
  810. }
  811. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  812. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  813. if m.key_agent == nil {
  814. m.key_agent = make(map[uint64]struct{})
  815. }
  816. for i := range ids {
  817. m.key_agent[ids[i]] = struct{}{}
  818. }
  819. }
  820. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  821. func (m *AgentMutation) ClearKeyAgent() {
  822. m.clearedkey_agent = true
  823. }
  824. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  825. func (m *AgentMutation) KeyAgentCleared() bool {
  826. return m.clearedkey_agent
  827. }
  828. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  829. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  830. if m.removedkey_agent == nil {
  831. m.removedkey_agent = make(map[uint64]struct{})
  832. }
  833. for i := range ids {
  834. delete(m.key_agent, ids[i])
  835. m.removedkey_agent[ids[i]] = struct{}{}
  836. }
  837. }
  838. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  839. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  840. for id := range m.removedkey_agent {
  841. ids = append(ids, id)
  842. }
  843. return
  844. }
  845. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  846. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  847. for id := range m.key_agent {
  848. ids = append(ids, id)
  849. }
  850. return
  851. }
  852. // ResetKeyAgent resets all changes to the "key_agent" edge.
  853. func (m *AgentMutation) ResetKeyAgent() {
  854. m.key_agent = nil
  855. m.clearedkey_agent = false
  856. m.removedkey_agent = nil
  857. }
  858. // Where appends a list predicates to the AgentMutation builder.
  859. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  860. m.predicates = append(m.predicates, ps...)
  861. }
  862. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  863. // users can use type-assertion to append predicates that do not depend on any generated package.
  864. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  865. p := make([]predicate.Agent, len(ps))
  866. for i := range ps {
  867. p[i] = ps[i]
  868. }
  869. m.Where(p...)
  870. }
  871. // Op returns the operation name.
  872. func (m *AgentMutation) Op() Op {
  873. return m.op
  874. }
  875. // SetOp allows setting the mutation operation.
  876. func (m *AgentMutation) SetOp(op Op) {
  877. m.op = op
  878. }
  879. // Type returns the node type of this mutation (Agent).
  880. func (m *AgentMutation) Type() string {
  881. return m.typ
  882. }
  883. // Fields returns all fields that were changed during this mutation. Note that in
  884. // order to get all numeric fields that were incremented/decremented, call
  885. // AddedFields().
  886. func (m *AgentMutation) Fields() []string {
  887. fields := make([]string, 0, 11)
  888. if m.created_at != nil {
  889. fields = append(fields, agent.FieldCreatedAt)
  890. }
  891. if m.updated_at != nil {
  892. fields = append(fields, agent.FieldUpdatedAt)
  893. }
  894. if m.deleted_at != nil {
  895. fields = append(fields, agent.FieldDeletedAt)
  896. }
  897. if m.name != nil {
  898. fields = append(fields, agent.FieldName)
  899. }
  900. if m.role != nil {
  901. fields = append(fields, agent.FieldRole)
  902. }
  903. if m.status != nil {
  904. fields = append(fields, agent.FieldStatus)
  905. }
  906. if m.background != nil {
  907. fields = append(fields, agent.FieldBackground)
  908. }
  909. if m.examples != nil {
  910. fields = append(fields, agent.FieldExamples)
  911. }
  912. if m.organization_id != nil {
  913. fields = append(fields, agent.FieldOrganizationID)
  914. }
  915. if m.dataset_id != nil {
  916. fields = append(fields, agent.FieldDatasetID)
  917. }
  918. if m.collection_id != nil {
  919. fields = append(fields, agent.FieldCollectionID)
  920. }
  921. return fields
  922. }
  923. // Field returns the value of a field with the given name. The second boolean
  924. // return value indicates that this field was not set, or was not defined in the
  925. // schema.
  926. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  927. switch name {
  928. case agent.FieldCreatedAt:
  929. return m.CreatedAt()
  930. case agent.FieldUpdatedAt:
  931. return m.UpdatedAt()
  932. case agent.FieldDeletedAt:
  933. return m.DeletedAt()
  934. case agent.FieldName:
  935. return m.Name()
  936. case agent.FieldRole:
  937. return m.Role()
  938. case agent.FieldStatus:
  939. return m.Status()
  940. case agent.FieldBackground:
  941. return m.Background()
  942. case agent.FieldExamples:
  943. return m.Examples()
  944. case agent.FieldOrganizationID:
  945. return m.OrganizationID()
  946. case agent.FieldDatasetID:
  947. return m.DatasetID()
  948. case agent.FieldCollectionID:
  949. return m.CollectionID()
  950. }
  951. return nil, false
  952. }
  953. // OldField returns the old value of the field from the database. An error is
  954. // returned if the mutation operation is not UpdateOne, or the query to the
  955. // database failed.
  956. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  957. switch name {
  958. case agent.FieldCreatedAt:
  959. return m.OldCreatedAt(ctx)
  960. case agent.FieldUpdatedAt:
  961. return m.OldUpdatedAt(ctx)
  962. case agent.FieldDeletedAt:
  963. return m.OldDeletedAt(ctx)
  964. case agent.FieldName:
  965. return m.OldName(ctx)
  966. case agent.FieldRole:
  967. return m.OldRole(ctx)
  968. case agent.FieldStatus:
  969. return m.OldStatus(ctx)
  970. case agent.FieldBackground:
  971. return m.OldBackground(ctx)
  972. case agent.FieldExamples:
  973. return m.OldExamples(ctx)
  974. case agent.FieldOrganizationID:
  975. return m.OldOrganizationID(ctx)
  976. case agent.FieldDatasetID:
  977. return m.OldDatasetID(ctx)
  978. case agent.FieldCollectionID:
  979. return m.OldCollectionID(ctx)
  980. }
  981. return nil, fmt.Errorf("unknown Agent field %s", name)
  982. }
  983. // SetField sets the value of a field with the given name. It returns an error if
  984. // the field is not defined in the schema, or if the type mismatched the field
  985. // type.
  986. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  987. switch name {
  988. case agent.FieldCreatedAt:
  989. v, ok := value.(time.Time)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetCreatedAt(v)
  994. return nil
  995. case agent.FieldUpdatedAt:
  996. v, ok := value.(time.Time)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetUpdatedAt(v)
  1001. return nil
  1002. case agent.FieldDeletedAt:
  1003. v, ok := value.(time.Time)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetDeletedAt(v)
  1008. return nil
  1009. case agent.FieldName:
  1010. v, ok := value.(string)
  1011. if !ok {
  1012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1013. }
  1014. m.SetName(v)
  1015. return nil
  1016. case agent.FieldRole:
  1017. v, ok := value.(string)
  1018. if !ok {
  1019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1020. }
  1021. m.SetRole(v)
  1022. return nil
  1023. case agent.FieldStatus:
  1024. v, ok := value.(int)
  1025. if !ok {
  1026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1027. }
  1028. m.SetStatus(v)
  1029. return nil
  1030. case agent.FieldBackground:
  1031. v, ok := value.(string)
  1032. if !ok {
  1033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1034. }
  1035. m.SetBackground(v)
  1036. return nil
  1037. case agent.FieldExamples:
  1038. v, ok := value.(string)
  1039. if !ok {
  1040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1041. }
  1042. m.SetExamples(v)
  1043. return nil
  1044. case agent.FieldOrganizationID:
  1045. v, ok := value.(uint64)
  1046. if !ok {
  1047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1048. }
  1049. m.SetOrganizationID(v)
  1050. return nil
  1051. case agent.FieldDatasetID:
  1052. v, ok := value.(string)
  1053. if !ok {
  1054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1055. }
  1056. m.SetDatasetID(v)
  1057. return nil
  1058. case agent.FieldCollectionID:
  1059. v, ok := value.(string)
  1060. if !ok {
  1061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1062. }
  1063. m.SetCollectionID(v)
  1064. return nil
  1065. }
  1066. return fmt.Errorf("unknown Agent field %s", name)
  1067. }
  1068. // AddedFields returns all numeric fields that were incremented/decremented during
  1069. // this mutation.
  1070. func (m *AgentMutation) AddedFields() []string {
  1071. var fields []string
  1072. if m.addstatus != nil {
  1073. fields = append(fields, agent.FieldStatus)
  1074. }
  1075. if m.addorganization_id != nil {
  1076. fields = append(fields, agent.FieldOrganizationID)
  1077. }
  1078. return fields
  1079. }
  1080. // AddedField returns the numeric value that was incremented/decremented on a field
  1081. // with the given name. The second boolean return value indicates that this field
  1082. // was not set, or was not defined in the schema.
  1083. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1084. switch name {
  1085. case agent.FieldStatus:
  1086. return m.AddedStatus()
  1087. case agent.FieldOrganizationID:
  1088. return m.AddedOrganizationID()
  1089. }
  1090. return nil, false
  1091. }
  1092. // AddField adds the value to the field with the given name. It returns an error if
  1093. // the field is not defined in the schema, or if the type mismatched the field
  1094. // type.
  1095. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1096. switch name {
  1097. case agent.FieldStatus:
  1098. v, ok := value.(int)
  1099. if !ok {
  1100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1101. }
  1102. m.AddStatus(v)
  1103. return nil
  1104. case agent.FieldOrganizationID:
  1105. v, ok := value.(int64)
  1106. if !ok {
  1107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1108. }
  1109. m.AddOrganizationID(v)
  1110. return nil
  1111. }
  1112. return fmt.Errorf("unknown Agent numeric field %s", name)
  1113. }
  1114. // ClearedFields returns all nullable fields that were cleared during this
  1115. // mutation.
  1116. func (m *AgentMutation) ClearedFields() []string {
  1117. var fields []string
  1118. if m.FieldCleared(agent.FieldDeletedAt) {
  1119. fields = append(fields, agent.FieldDeletedAt)
  1120. }
  1121. if m.FieldCleared(agent.FieldStatus) {
  1122. fields = append(fields, agent.FieldStatus)
  1123. }
  1124. if m.FieldCleared(agent.FieldBackground) {
  1125. fields = append(fields, agent.FieldBackground)
  1126. }
  1127. if m.FieldCleared(agent.FieldExamples) {
  1128. fields = append(fields, agent.FieldExamples)
  1129. }
  1130. return fields
  1131. }
  1132. // FieldCleared returns a boolean indicating if a field with the given name was
  1133. // cleared in this mutation.
  1134. func (m *AgentMutation) FieldCleared(name string) bool {
  1135. _, ok := m.clearedFields[name]
  1136. return ok
  1137. }
  1138. // ClearField clears the value of the field with the given name. It returns an
  1139. // error if the field is not defined in the schema.
  1140. func (m *AgentMutation) ClearField(name string) error {
  1141. switch name {
  1142. case agent.FieldDeletedAt:
  1143. m.ClearDeletedAt()
  1144. return nil
  1145. case agent.FieldStatus:
  1146. m.ClearStatus()
  1147. return nil
  1148. case agent.FieldBackground:
  1149. m.ClearBackground()
  1150. return nil
  1151. case agent.FieldExamples:
  1152. m.ClearExamples()
  1153. return nil
  1154. }
  1155. return fmt.Errorf("unknown Agent nullable field %s", name)
  1156. }
  1157. // ResetField resets all changes in the mutation for the field with the given name.
  1158. // It returns an error if the field is not defined in the schema.
  1159. func (m *AgentMutation) ResetField(name string) error {
  1160. switch name {
  1161. case agent.FieldCreatedAt:
  1162. m.ResetCreatedAt()
  1163. return nil
  1164. case agent.FieldUpdatedAt:
  1165. m.ResetUpdatedAt()
  1166. return nil
  1167. case agent.FieldDeletedAt:
  1168. m.ResetDeletedAt()
  1169. return nil
  1170. case agent.FieldName:
  1171. m.ResetName()
  1172. return nil
  1173. case agent.FieldRole:
  1174. m.ResetRole()
  1175. return nil
  1176. case agent.FieldStatus:
  1177. m.ResetStatus()
  1178. return nil
  1179. case agent.FieldBackground:
  1180. m.ResetBackground()
  1181. return nil
  1182. case agent.FieldExamples:
  1183. m.ResetExamples()
  1184. return nil
  1185. case agent.FieldOrganizationID:
  1186. m.ResetOrganizationID()
  1187. return nil
  1188. case agent.FieldDatasetID:
  1189. m.ResetDatasetID()
  1190. return nil
  1191. case agent.FieldCollectionID:
  1192. m.ResetCollectionID()
  1193. return nil
  1194. }
  1195. return fmt.Errorf("unknown Agent field %s", name)
  1196. }
  1197. // AddedEdges returns all edge names that were set/added in this mutation.
  1198. func (m *AgentMutation) AddedEdges() []string {
  1199. edges := make([]string, 0, 4)
  1200. if m.wx_agent != nil {
  1201. edges = append(edges, agent.EdgeWxAgent)
  1202. }
  1203. if m.token_agent != nil {
  1204. edges = append(edges, agent.EdgeTokenAgent)
  1205. }
  1206. if m.wa_agent != nil {
  1207. edges = append(edges, agent.EdgeWaAgent)
  1208. }
  1209. if m.key_agent != nil {
  1210. edges = append(edges, agent.EdgeKeyAgent)
  1211. }
  1212. return edges
  1213. }
  1214. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1215. // name in this mutation.
  1216. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1217. switch name {
  1218. case agent.EdgeWxAgent:
  1219. ids := make([]ent.Value, 0, len(m.wx_agent))
  1220. for id := range m.wx_agent {
  1221. ids = append(ids, id)
  1222. }
  1223. return ids
  1224. case agent.EdgeTokenAgent:
  1225. ids := make([]ent.Value, 0, len(m.token_agent))
  1226. for id := range m.token_agent {
  1227. ids = append(ids, id)
  1228. }
  1229. return ids
  1230. case agent.EdgeWaAgent:
  1231. ids := make([]ent.Value, 0, len(m.wa_agent))
  1232. for id := range m.wa_agent {
  1233. ids = append(ids, id)
  1234. }
  1235. return ids
  1236. case agent.EdgeKeyAgent:
  1237. ids := make([]ent.Value, 0, len(m.key_agent))
  1238. for id := range m.key_agent {
  1239. ids = append(ids, id)
  1240. }
  1241. return ids
  1242. }
  1243. return nil
  1244. }
  1245. // RemovedEdges returns all edge names that were removed in this mutation.
  1246. func (m *AgentMutation) RemovedEdges() []string {
  1247. edges := make([]string, 0, 4)
  1248. if m.removedwx_agent != nil {
  1249. edges = append(edges, agent.EdgeWxAgent)
  1250. }
  1251. if m.removedtoken_agent != nil {
  1252. edges = append(edges, agent.EdgeTokenAgent)
  1253. }
  1254. if m.removedwa_agent != nil {
  1255. edges = append(edges, agent.EdgeWaAgent)
  1256. }
  1257. if m.removedkey_agent != nil {
  1258. edges = append(edges, agent.EdgeKeyAgent)
  1259. }
  1260. return edges
  1261. }
  1262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1263. // the given name in this mutation.
  1264. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1265. switch name {
  1266. case agent.EdgeWxAgent:
  1267. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1268. for id := range m.removedwx_agent {
  1269. ids = append(ids, id)
  1270. }
  1271. return ids
  1272. case agent.EdgeTokenAgent:
  1273. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1274. for id := range m.removedtoken_agent {
  1275. ids = append(ids, id)
  1276. }
  1277. return ids
  1278. case agent.EdgeWaAgent:
  1279. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1280. for id := range m.removedwa_agent {
  1281. ids = append(ids, id)
  1282. }
  1283. return ids
  1284. case agent.EdgeKeyAgent:
  1285. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1286. for id := range m.removedkey_agent {
  1287. ids = append(ids, id)
  1288. }
  1289. return ids
  1290. }
  1291. return nil
  1292. }
  1293. // ClearedEdges returns all edge names that were cleared in this mutation.
  1294. func (m *AgentMutation) ClearedEdges() []string {
  1295. edges := make([]string, 0, 4)
  1296. if m.clearedwx_agent {
  1297. edges = append(edges, agent.EdgeWxAgent)
  1298. }
  1299. if m.clearedtoken_agent {
  1300. edges = append(edges, agent.EdgeTokenAgent)
  1301. }
  1302. if m.clearedwa_agent {
  1303. edges = append(edges, agent.EdgeWaAgent)
  1304. }
  1305. if m.clearedkey_agent {
  1306. edges = append(edges, agent.EdgeKeyAgent)
  1307. }
  1308. return edges
  1309. }
  1310. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1311. // was cleared in this mutation.
  1312. func (m *AgentMutation) EdgeCleared(name string) bool {
  1313. switch name {
  1314. case agent.EdgeWxAgent:
  1315. return m.clearedwx_agent
  1316. case agent.EdgeTokenAgent:
  1317. return m.clearedtoken_agent
  1318. case agent.EdgeWaAgent:
  1319. return m.clearedwa_agent
  1320. case agent.EdgeKeyAgent:
  1321. return m.clearedkey_agent
  1322. }
  1323. return false
  1324. }
  1325. // ClearEdge clears the value of the edge with the given name. It returns an error
  1326. // if that edge is not defined in the schema.
  1327. func (m *AgentMutation) ClearEdge(name string) error {
  1328. switch name {
  1329. }
  1330. return fmt.Errorf("unknown Agent unique edge %s", name)
  1331. }
  1332. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1333. // It returns an error if the edge is not defined in the schema.
  1334. func (m *AgentMutation) ResetEdge(name string) error {
  1335. switch name {
  1336. case agent.EdgeWxAgent:
  1337. m.ResetWxAgent()
  1338. return nil
  1339. case agent.EdgeTokenAgent:
  1340. m.ResetTokenAgent()
  1341. return nil
  1342. case agent.EdgeWaAgent:
  1343. m.ResetWaAgent()
  1344. return nil
  1345. case agent.EdgeKeyAgent:
  1346. m.ResetKeyAgent()
  1347. return nil
  1348. }
  1349. return fmt.Errorf("unknown Agent edge %s", name)
  1350. }
  1351. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1352. type AgentBaseMutation struct {
  1353. config
  1354. op Op
  1355. typ string
  1356. id *string
  1357. q *string
  1358. a *string
  1359. chunk_index *uint64
  1360. addchunk_index *int64
  1361. indexes *[]string
  1362. appendindexes []string
  1363. dataset_id *string
  1364. collection_id *string
  1365. source_name *string
  1366. can_write *[]bool
  1367. appendcan_write []bool
  1368. is_owner *[]bool
  1369. appendis_owner []bool
  1370. clearedFields map[string]struct{}
  1371. wx_agent map[uint64]struct{}
  1372. removedwx_agent map[uint64]struct{}
  1373. clearedwx_agent bool
  1374. done bool
  1375. oldValue func(context.Context) (*AgentBase, error)
  1376. predicates []predicate.AgentBase
  1377. }
  1378. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1379. // agentbaseOption allows management of the mutation configuration using functional options.
  1380. type agentbaseOption func(*AgentBaseMutation)
  1381. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1382. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1383. m := &AgentBaseMutation{
  1384. config: c,
  1385. op: op,
  1386. typ: TypeAgentBase,
  1387. clearedFields: make(map[string]struct{}),
  1388. }
  1389. for _, opt := range opts {
  1390. opt(m)
  1391. }
  1392. return m
  1393. }
  1394. // withAgentBaseID sets the ID field of the mutation.
  1395. func withAgentBaseID(id string) agentbaseOption {
  1396. return func(m *AgentBaseMutation) {
  1397. var (
  1398. err error
  1399. once sync.Once
  1400. value *AgentBase
  1401. )
  1402. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1403. once.Do(func() {
  1404. if m.done {
  1405. err = errors.New("querying old values post mutation is not allowed")
  1406. } else {
  1407. value, err = m.Client().AgentBase.Get(ctx, id)
  1408. }
  1409. })
  1410. return value, err
  1411. }
  1412. m.id = &id
  1413. }
  1414. }
  1415. // withAgentBase sets the old AgentBase of the mutation.
  1416. func withAgentBase(node *AgentBase) agentbaseOption {
  1417. return func(m *AgentBaseMutation) {
  1418. m.oldValue = func(context.Context) (*AgentBase, error) {
  1419. return node, nil
  1420. }
  1421. m.id = &node.ID
  1422. }
  1423. }
  1424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1425. // executed in a transaction (ent.Tx), a transactional client is returned.
  1426. func (m AgentBaseMutation) Client() *Client {
  1427. client := &Client{config: m.config}
  1428. client.init()
  1429. return client
  1430. }
  1431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1432. // it returns an error otherwise.
  1433. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1434. if _, ok := m.driver.(*txDriver); !ok {
  1435. return nil, errors.New("ent: mutation is not running in a transaction")
  1436. }
  1437. tx := &Tx{config: m.config}
  1438. tx.init()
  1439. return tx, nil
  1440. }
  1441. // SetID sets the value of the id field. Note that this
  1442. // operation is only accepted on creation of AgentBase entities.
  1443. func (m *AgentBaseMutation) SetID(id string) {
  1444. m.id = &id
  1445. }
  1446. // ID returns the ID value in the mutation. Note that the ID is only available
  1447. // if it was provided to the builder or after it was returned from the database.
  1448. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1449. if m.id == nil {
  1450. return
  1451. }
  1452. return *m.id, true
  1453. }
  1454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1455. // That means, if the mutation is applied within a transaction with an isolation level such
  1456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1457. // or updated by the mutation.
  1458. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1459. switch {
  1460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1461. id, exists := m.ID()
  1462. if exists {
  1463. return []string{id}, nil
  1464. }
  1465. fallthrough
  1466. case m.op.Is(OpUpdate | OpDelete):
  1467. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1468. default:
  1469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1470. }
  1471. }
  1472. // SetQ sets the "q" field.
  1473. func (m *AgentBaseMutation) SetQ(s string) {
  1474. m.q = &s
  1475. }
  1476. // Q returns the value of the "q" field in the mutation.
  1477. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1478. v := m.q
  1479. if v == nil {
  1480. return
  1481. }
  1482. return *v, true
  1483. }
  1484. // OldQ returns the old "q" field's value of the AgentBase entity.
  1485. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1487. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1488. if !m.op.Is(OpUpdateOne) {
  1489. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1490. }
  1491. if m.id == nil || m.oldValue == nil {
  1492. return v, errors.New("OldQ requires an ID field in the mutation")
  1493. }
  1494. oldValue, err := m.oldValue(ctx)
  1495. if err != nil {
  1496. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1497. }
  1498. return oldValue.Q, nil
  1499. }
  1500. // ClearQ clears the value of the "q" field.
  1501. func (m *AgentBaseMutation) ClearQ() {
  1502. m.q = nil
  1503. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1504. }
  1505. // QCleared returns if the "q" field was cleared in this mutation.
  1506. func (m *AgentBaseMutation) QCleared() bool {
  1507. _, ok := m.clearedFields[agentbase.FieldQ]
  1508. return ok
  1509. }
  1510. // ResetQ resets all changes to the "q" field.
  1511. func (m *AgentBaseMutation) ResetQ() {
  1512. m.q = nil
  1513. delete(m.clearedFields, agentbase.FieldQ)
  1514. }
  1515. // SetA sets the "a" field.
  1516. func (m *AgentBaseMutation) SetA(s string) {
  1517. m.a = &s
  1518. }
  1519. // A returns the value of the "a" field in the mutation.
  1520. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1521. v := m.a
  1522. if v == nil {
  1523. return
  1524. }
  1525. return *v, true
  1526. }
  1527. // OldA returns the old "a" field's value of the AgentBase entity.
  1528. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1530. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1531. if !m.op.Is(OpUpdateOne) {
  1532. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1533. }
  1534. if m.id == nil || m.oldValue == nil {
  1535. return v, errors.New("OldA requires an ID field in the mutation")
  1536. }
  1537. oldValue, err := m.oldValue(ctx)
  1538. if err != nil {
  1539. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1540. }
  1541. return oldValue.A, nil
  1542. }
  1543. // ClearA clears the value of the "a" field.
  1544. func (m *AgentBaseMutation) ClearA() {
  1545. m.a = nil
  1546. m.clearedFields[agentbase.FieldA] = struct{}{}
  1547. }
  1548. // ACleared returns if the "a" field was cleared in this mutation.
  1549. func (m *AgentBaseMutation) ACleared() bool {
  1550. _, ok := m.clearedFields[agentbase.FieldA]
  1551. return ok
  1552. }
  1553. // ResetA resets all changes to the "a" field.
  1554. func (m *AgentBaseMutation) ResetA() {
  1555. m.a = nil
  1556. delete(m.clearedFields, agentbase.FieldA)
  1557. }
  1558. // SetChunkIndex sets the "chunk_index" field.
  1559. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1560. m.chunk_index = &u
  1561. m.addchunk_index = nil
  1562. }
  1563. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1564. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1565. v := m.chunk_index
  1566. if v == nil {
  1567. return
  1568. }
  1569. return *v, true
  1570. }
  1571. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1572. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1574. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1575. if !m.op.Is(OpUpdateOne) {
  1576. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1577. }
  1578. if m.id == nil || m.oldValue == nil {
  1579. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1580. }
  1581. oldValue, err := m.oldValue(ctx)
  1582. if err != nil {
  1583. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1584. }
  1585. return oldValue.ChunkIndex, nil
  1586. }
  1587. // AddChunkIndex adds u to the "chunk_index" field.
  1588. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1589. if m.addchunk_index != nil {
  1590. *m.addchunk_index += u
  1591. } else {
  1592. m.addchunk_index = &u
  1593. }
  1594. }
  1595. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1596. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1597. v := m.addchunk_index
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1604. func (m *AgentBaseMutation) ResetChunkIndex() {
  1605. m.chunk_index = nil
  1606. m.addchunk_index = nil
  1607. }
  1608. // SetIndexes sets the "indexes" field.
  1609. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1610. m.indexes = &s
  1611. m.appendindexes = nil
  1612. }
  1613. // Indexes returns the value of the "indexes" field in the mutation.
  1614. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1615. v := m.indexes
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1622. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1634. }
  1635. return oldValue.Indexes, nil
  1636. }
  1637. // AppendIndexes adds s to the "indexes" field.
  1638. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1639. m.appendindexes = append(m.appendindexes, s...)
  1640. }
  1641. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1642. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1643. if len(m.appendindexes) == 0 {
  1644. return nil, false
  1645. }
  1646. return m.appendindexes, true
  1647. }
  1648. // ClearIndexes clears the value of the "indexes" field.
  1649. func (m *AgentBaseMutation) ClearIndexes() {
  1650. m.indexes = nil
  1651. m.appendindexes = nil
  1652. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1653. }
  1654. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1655. func (m *AgentBaseMutation) IndexesCleared() bool {
  1656. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1657. return ok
  1658. }
  1659. // ResetIndexes resets all changes to the "indexes" field.
  1660. func (m *AgentBaseMutation) ResetIndexes() {
  1661. m.indexes = nil
  1662. m.appendindexes = nil
  1663. delete(m.clearedFields, agentbase.FieldIndexes)
  1664. }
  1665. // SetDatasetID sets the "dataset_id" field.
  1666. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1667. m.dataset_id = &s
  1668. }
  1669. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1670. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1671. v := m.dataset_id
  1672. if v == nil {
  1673. return
  1674. }
  1675. return *v, true
  1676. }
  1677. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1678. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1680. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1681. if !m.op.Is(OpUpdateOne) {
  1682. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1683. }
  1684. if m.id == nil || m.oldValue == nil {
  1685. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1686. }
  1687. oldValue, err := m.oldValue(ctx)
  1688. if err != nil {
  1689. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1690. }
  1691. return oldValue.DatasetID, nil
  1692. }
  1693. // ClearDatasetID clears the value of the "dataset_id" field.
  1694. func (m *AgentBaseMutation) ClearDatasetID() {
  1695. m.dataset_id = nil
  1696. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1697. }
  1698. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1699. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1700. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1701. return ok
  1702. }
  1703. // ResetDatasetID resets all changes to the "dataset_id" field.
  1704. func (m *AgentBaseMutation) ResetDatasetID() {
  1705. m.dataset_id = nil
  1706. delete(m.clearedFields, agentbase.FieldDatasetID)
  1707. }
  1708. // SetCollectionID sets the "collection_id" field.
  1709. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1710. m.collection_id = &s
  1711. }
  1712. // CollectionID returns the value of the "collection_id" field in the mutation.
  1713. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1714. v := m.collection_id
  1715. if v == nil {
  1716. return
  1717. }
  1718. return *v, true
  1719. }
  1720. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1721. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1723. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1724. if !m.op.Is(OpUpdateOne) {
  1725. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1726. }
  1727. if m.id == nil || m.oldValue == nil {
  1728. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1729. }
  1730. oldValue, err := m.oldValue(ctx)
  1731. if err != nil {
  1732. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1733. }
  1734. return oldValue.CollectionID, nil
  1735. }
  1736. // ClearCollectionID clears the value of the "collection_id" field.
  1737. func (m *AgentBaseMutation) ClearCollectionID() {
  1738. m.collection_id = nil
  1739. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1740. }
  1741. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1742. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1743. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1744. return ok
  1745. }
  1746. // ResetCollectionID resets all changes to the "collection_id" field.
  1747. func (m *AgentBaseMutation) ResetCollectionID() {
  1748. m.collection_id = nil
  1749. delete(m.clearedFields, agentbase.FieldCollectionID)
  1750. }
  1751. // SetSourceName sets the "source_name" field.
  1752. func (m *AgentBaseMutation) SetSourceName(s string) {
  1753. m.source_name = &s
  1754. }
  1755. // SourceName returns the value of the "source_name" field in the mutation.
  1756. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1757. v := m.source_name
  1758. if v == nil {
  1759. return
  1760. }
  1761. return *v, true
  1762. }
  1763. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1764. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1766. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1767. if !m.op.Is(OpUpdateOne) {
  1768. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1769. }
  1770. if m.id == nil || m.oldValue == nil {
  1771. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1772. }
  1773. oldValue, err := m.oldValue(ctx)
  1774. if err != nil {
  1775. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1776. }
  1777. return oldValue.SourceName, nil
  1778. }
  1779. // ClearSourceName clears the value of the "source_name" field.
  1780. func (m *AgentBaseMutation) ClearSourceName() {
  1781. m.source_name = nil
  1782. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1783. }
  1784. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1785. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1786. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1787. return ok
  1788. }
  1789. // ResetSourceName resets all changes to the "source_name" field.
  1790. func (m *AgentBaseMutation) ResetSourceName() {
  1791. m.source_name = nil
  1792. delete(m.clearedFields, agentbase.FieldSourceName)
  1793. }
  1794. // SetCanWrite sets the "can_write" field.
  1795. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1796. m.can_write = &b
  1797. m.appendcan_write = nil
  1798. }
  1799. // CanWrite returns the value of the "can_write" field in the mutation.
  1800. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1801. v := m.can_write
  1802. if v == nil {
  1803. return
  1804. }
  1805. return *v, true
  1806. }
  1807. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1808. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1810. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1811. if !m.op.Is(OpUpdateOne) {
  1812. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1813. }
  1814. if m.id == nil || m.oldValue == nil {
  1815. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1816. }
  1817. oldValue, err := m.oldValue(ctx)
  1818. if err != nil {
  1819. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1820. }
  1821. return oldValue.CanWrite, nil
  1822. }
  1823. // AppendCanWrite adds b to the "can_write" field.
  1824. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1825. m.appendcan_write = append(m.appendcan_write, b...)
  1826. }
  1827. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1828. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1829. if len(m.appendcan_write) == 0 {
  1830. return nil, false
  1831. }
  1832. return m.appendcan_write, true
  1833. }
  1834. // ClearCanWrite clears the value of the "can_write" field.
  1835. func (m *AgentBaseMutation) ClearCanWrite() {
  1836. m.can_write = nil
  1837. m.appendcan_write = nil
  1838. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1839. }
  1840. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1841. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1842. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1843. return ok
  1844. }
  1845. // ResetCanWrite resets all changes to the "can_write" field.
  1846. func (m *AgentBaseMutation) ResetCanWrite() {
  1847. m.can_write = nil
  1848. m.appendcan_write = nil
  1849. delete(m.clearedFields, agentbase.FieldCanWrite)
  1850. }
  1851. // SetIsOwner sets the "is_owner" field.
  1852. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1853. m.is_owner = &b
  1854. m.appendis_owner = nil
  1855. }
  1856. // IsOwner returns the value of the "is_owner" field in the mutation.
  1857. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1858. v := m.is_owner
  1859. if v == nil {
  1860. return
  1861. }
  1862. return *v, true
  1863. }
  1864. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1865. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1867. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1868. if !m.op.Is(OpUpdateOne) {
  1869. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1870. }
  1871. if m.id == nil || m.oldValue == nil {
  1872. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1873. }
  1874. oldValue, err := m.oldValue(ctx)
  1875. if err != nil {
  1876. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1877. }
  1878. return oldValue.IsOwner, nil
  1879. }
  1880. // AppendIsOwner adds b to the "is_owner" field.
  1881. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1882. m.appendis_owner = append(m.appendis_owner, b...)
  1883. }
  1884. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1885. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1886. if len(m.appendis_owner) == 0 {
  1887. return nil, false
  1888. }
  1889. return m.appendis_owner, true
  1890. }
  1891. // ClearIsOwner clears the value of the "is_owner" field.
  1892. func (m *AgentBaseMutation) ClearIsOwner() {
  1893. m.is_owner = nil
  1894. m.appendis_owner = nil
  1895. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1896. }
  1897. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1898. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1899. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1900. return ok
  1901. }
  1902. // ResetIsOwner resets all changes to the "is_owner" field.
  1903. func (m *AgentBaseMutation) ResetIsOwner() {
  1904. m.is_owner = nil
  1905. m.appendis_owner = nil
  1906. delete(m.clearedFields, agentbase.FieldIsOwner)
  1907. }
  1908. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1909. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1910. if m.wx_agent == nil {
  1911. m.wx_agent = make(map[uint64]struct{})
  1912. }
  1913. for i := range ids {
  1914. m.wx_agent[ids[i]] = struct{}{}
  1915. }
  1916. }
  1917. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1918. func (m *AgentBaseMutation) ClearWxAgent() {
  1919. m.clearedwx_agent = true
  1920. }
  1921. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1922. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1923. return m.clearedwx_agent
  1924. }
  1925. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1926. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1927. if m.removedwx_agent == nil {
  1928. m.removedwx_agent = make(map[uint64]struct{})
  1929. }
  1930. for i := range ids {
  1931. delete(m.wx_agent, ids[i])
  1932. m.removedwx_agent[ids[i]] = struct{}{}
  1933. }
  1934. }
  1935. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1936. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1937. for id := range m.removedwx_agent {
  1938. ids = append(ids, id)
  1939. }
  1940. return
  1941. }
  1942. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1943. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1944. for id := range m.wx_agent {
  1945. ids = append(ids, id)
  1946. }
  1947. return
  1948. }
  1949. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1950. func (m *AgentBaseMutation) ResetWxAgent() {
  1951. m.wx_agent = nil
  1952. m.clearedwx_agent = false
  1953. m.removedwx_agent = nil
  1954. }
  1955. // Where appends a list predicates to the AgentBaseMutation builder.
  1956. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1957. m.predicates = append(m.predicates, ps...)
  1958. }
  1959. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1960. // users can use type-assertion to append predicates that do not depend on any generated package.
  1961. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1962. p := make([]predicate.AgentBase, len(ps))
  1963. for i := range ps {
  1964. p[i] = ps[i]
  1965. }
  1966. m.Where(p...)
  1967. }
  1968. // Op returns the operation name.
  1969. func (m *AgentBaseMutation) Op() Op {
  1970. return m.op
  1971. }
  1972. // SetOp allows setting the mutation operation.
  1973. func (m *AgentBaseMutation) SetOp(op Op) {
  1974. m.op = op
  1975. }
  1976. // Type returns the node type of this mutation (AgentBase).
  1977. func (m *AgentBaseMutation) Type() string {
  1978. return m.typ
  1979. }
  1980. // Fields returns all fields that were changed during this mutation. Note that in
  1981. // order to get all numeric fields that were incremented/decremented, call
  1982. // AddedFields().
  1983. func (m *AgentBaseMutation) Fields() []string {
  1984. fields := make([]string, 0, 9)
  1985. if m.q != nil {
  1986. fields = append(fields, agentbase.FieldQ)
  1987. }
  1988. if m.a != nil {
  1989. fields = append(fields, agentbase.FieldA)
  1990. }
  1991. if m.chunk_index != nil {
  1992. fields = append(fields, agentbase.FieldChunkIndex)
  1993. }
  1994. if m.indexes != nil {
  1995. fields = append(fields, agentbase.FieldIndexes)
  1996. }
  1997. if m.dataset_id != nil {
  1998. fields = append(fields, agentbase.FieldDatasetID)
  1999. }
  2000. if m.collection_id != nil {
  2001. fields = append(fields, agentbase.FieldCollectionID)
  2002. }
  2003. if m.source_name != nil {
  2004. fields = append(fields, agentbase.FieldSourceName)
  2005. }
  2006. if m.can_write != nil {
  2007. fields = append(fields, agentbase.FieldCanWrite)
  2008. }
  2009. if m.is_owner != nil {
  2010. fields = append(fields, agentbase.FieldIsOwner)
  2011. }
  2012. return fields
  2013. }
  2014. // Field returns the value of a field with the given name. The second boolean
  2015. // return value indicates that this field was not set, or was not defined in the
  2016. // schema.
  2017. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2018. switch name {
  2019. case agentbase.FieldQ:
  2020. return m.Q()
  2021. case agentbase.FieldA:
  2022. return m.A()
  2023. case agentbase.FieldChunkIndex:
  2024. return m.ChunkIndex()
  2025. case agentbase.FieldIndexes:
  2026. return m.Indexes()
  2027. case agentbase.FieldDatasetID:
  2028. return m.DatasetID()
  2029. case agentbase.FieldCollectionID:
  2030. return m.CollectionID()
  2031. case agentbase.FieldSourceName:
  2032. return m.SourceName()
  2033. case agentbase.FieldCanWrite:
  2034. return m.CanWrite()
  2035. case agentbase.FieldIsOwner:
  2036. return m.IsOwner()
  2037. }
  2038. return nil, false
  2039. }
  2040. // OldField returns the old value of the field from the database. An error is
  2041. // returned if the mutation operation is not UpdateOne, or the query to the
  2042. // database failed.
  2043. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. return m.OldQ(ctx)
  2047. case agentbase.FieldA:
  2048. return m.OldA(ctx)
  2049. case agentbase.FieldChunkIndex:
  2050. return m.OldChunkIndex(ctx)
  2051. case agentbase.FieldIndexes:
  2052. return m.OldIndexes(ctx)
  2053. case agentbase.FieldDatasetID:
  2054. return m.OldDatasetID(ctx)
  2055. case agentbase.FieldCollectionID:
  2056. return m.OldCollectionID(ctx)
  2057. case agentbase.FieldSourceName:
  2058. return m.OldSourceName(ctx)
  2059. case agentbase.FieldCanWrite:
  2060. return m.OldCanWrite(ctx)
  2061. case agentbase.FieldIsOwner:
  2062. return m.OldIsOwner(ctx)
  2063. }
  2064. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2065. }
  2066. // SetField sets the value of a field with the given name. It returns an error if
  2067. // the field is not defined in the schema, or if the type mismatched the field
  2068. // type.
  2069. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2070. switch name {
  2071. case agentbase.FieldQ:
  2072. v, ok := value.(string)
  2073. if !ok {
  2074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2075. }
  2076. m.SetQ(v)
  2077. return nil
  2078. case agentbase.FieldA:
  2079. v, ok := value.(string)
  2080. if !ok {
  2081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2082. }
  2083. m.SetA(v)
  2084. return nil
  2085. case agentbase.FieldChunkIndex:
  2086. v, ok := value.(uint64)
  2087. if !ok {
  2088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2089. }
  2090. m.SetChunkIndex(v)
  2091. return nil
  2092. case agentbase.FieldIndexes:
  2093. v, ok := value.([]string)
  2094. if !ok {
  2095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2096. }
  2097. m.SetIndexes(v)
  2098. return nil
  2099. case agentbase.FieldDatasetID:
  2100. v, ok := value.(string)
  2101. if !ok {
  2102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2103. }
  2104. m.SetDatasetID(v)
  2105. return nil
  2106. case agentbase.FieldCollectionID:
  2107. v, ok := value.(string)
  2108. if !ok {
  2109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2110. }
  2111. m.SetCollectionID(v)
  2112. return nil
  2113. case agentbase.FieldSourceName:
  2114. v, ok := value.(string)
  2115. if !ok {
  2116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2117. }
  2118. m.SetSourceName(v)
  2119. return nil
  2120. case agentbase.FieldCanWrite:
  2121. v, ok := value.([]bool)
  2122. if !ok {
  2123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2124. }
  2125. m.SetCanWrite(v)
  2126. return nil
  2127. case agentbase.FieldIsOwner:
  2128. v, ok := value.([]bool)
  2129. if !ok {
  2130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2131. }
  2132. m.SetIsOwner(v)
  2133. return nil
  2134. }
  2135. return fmt.Errorf("unknown AgentBase field %s", name)
  2136. }
  2137. // AddedFields returns all numeric fields that were incremented/decremented during
  2138. // this mutation.
  2139. func (m *AgentBaseMutation) AddedFields() []string {
  2140. var fields []string
  2141. if m.addchunk_index != nil {
  2142. fields = append(fields, agentbase.FieldChunkIndex)
  2143. }
  2144. return fields
  2145. }
  2146. // AddedField returns the numeric value that was incremented/decremented on a field
  2147. // with the given name. The second boolean return value indicates that this field
  2148. // was not set, or was not defined in the schema.
  2149. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case agentbase.FieldChunkIndex:
  2152. return m.AddedChunkIndex()
  2153. }
  2154. return nil, false
  2155. }
  2156. // AddField adds the value to the field with the given name. It returns an error if
  2157. // the field is not defined in the schema, or if the type mismatched the field
  2158. // type.
  2159. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2160. switch name {
  2161. case agentbase.FieldChunkIndex:
  2162. v, ok := value.(int64)
  2163. if !ok {
  2164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2165. }
  2166. m.AddChunkIndex(v)
  2167. return nil
  2168. }
  2169. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2170. }
  2171. // ClearedFields returns all nullable fields that were cleared during this
  2172. // mutation.
  2173. func (m *AgentBaseMutation) ClearedFields() []string {
  2174. var fields []string
  2175. if m.FieldCleared(agentbase.FieldQ) {
  2176. fields = append(fields, agentbase.FieldQ)
  2177. }
  2178. if m.FieldCleared(agentbase.FieldA) {
  2179. fields = append(fields, agentbase.FieldA)
  2180. }
  2181. if m.FieldCleared(agentbase.FieldIndexes) {
  2182. fields = append(fields, agentbase.FieldIndexes)
  2183. }
  2184. if m.FieldCleared(agentbase.FieldDatasetID) {
  2185. fields = append(fields, agentbase.FieldDatasetID)
  2186. }
  2187. if m.FieldCleared(agentbase.FieldCollectionID) {
  2188. fields = append(fields, agentbase.FieldCollectionID)
  2189. }
  2190. if m.FieldCleared(agentbase.FieldSourceName) {
  2191. fields = append(fields, agentbase.FieldSourceName)
  2192. }
  2193. if m.FieldCleared(agentbase.FieldCanWrite) {
  2194. fields = append(fields, agentbase.FieldCanWrite)
  2195. }
  2196. if m.FieldCleared(agentbase.FieldIsOwner) {
  2197. fields = append(fields, agentbase.FieldIsOwner)
  2198. }
  2199. return fields
  2200. }
  2201. // FieldCleared returns a boolean indicating if a field with the given name was
  2202. // cleared in this mutation.
  2203. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2204. _, ok := m.clearedFields[name]
  2205. return ok
  2206. }
  2207. // ClearField clears the value of the field with the given name. It returns an
  2208. // error if the field is not defined in the schema.
  2209. func (m *AgentBaseMutation) ClearField(name string) error {
  2210. switch name {
  2211. case agentbase.FieldQ:
  2212. m.ClearQ()
  2213. return nil
  2214. case agentbase.FieldA:
  2215. m.ClearA()
  2216. return nil
  2217. case agentbase.FieldIndexes:
  2218. m.ClearIndexes()
  2219. return nil
  2220. case agentbase.FieldDatasetID:
  2221. m.ClearDatasetID()
  2222. return nil
  2223. case agentbase.FieldCollectionID:
  2224. m.ClearCollectionID()
  2225. return nil
  2226. case agentbase.FieldSourceName:
  2227. m.ClearSourceName()
  2228. return nil
  2229. case agentbase.FieldCanWrite:
  2230. m.ClearCanWrite()
  2231. return nil
  2232. case agentbase.FieldIsOwner:
  2233. m.ClearIsOwner()
  2234. return nil
  2235. }
  2236. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2237. }
  2238. // ResetField resets all changes in the mutation for the field with the given name.
  2239. // It returns an error if the field is not defined in the schema.
  2240. func (m *AgentBaseMutation) ResetField(name string) error {
  2241. switch name {
  2242. case agentbase.FieldQ:
  2243. m.ResetQ()
  2244. return nil
  2245. case agentbase.FieldA:
  2246. m.ResetA()
  2247. return nil
  2248. case agentbase.FieldChunkIndex:
  2249. m.ResetChunkIndex()
  2250. return nil
  2251. case agentbase.FieldIndexes:
  2252. m.ResetIndexes()
  2253. return nil
  2254. case agentbase.FieldDatasetID:
  2255. m.ResetDatasetID()
  2256. return nil
  2257. case agentbase.FieldCollectionID:
  2258. m.ResetCollectionID()
  2259. return nil
  2260. case agentbase.FieldSourceName:
  2261. m.ResetSourceName()
  2262. return nil
  2263. case agentbase.FieldCanWrite:
  2264. m.ResetCanWrite()
  2265. return nil
  2266. case agentbase.FieldIsOwner:
  2267. m.ResetIsOwner()
  2268. return nil
  2269. }
  2270. return fmt.Errorf("unknown AgentBase field %s", name)
  2271. }
  2272. // AddedEdges returns all edge names that were set/added in this mutation.
  2273. func (m *AgentBaseMutation) AddedEdges() []string {
  2274. edges := make([]string, 0, 1)
  2275. if m.wx_agent != nil {
  2276. edges = append(edges, agentbase.EdgeWxAgent)
  2277. }
  2278. return edges
  2279. }
  2280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2281. // name in this mutation.
  2282. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2283. switch name {
  2284. case agentbase.EdgeWxAgent:
  2285. ids := make([]ent.Value, 0, len(m.wx_agent))
  2286. for id := range m.wx_agent {
  2287. ids = append(ids, id)
  2288. }
  2289. return ids
  2290. }
  2291. return nil
  2292. }
  2293. // RemovedEdges returns all edge names that were removed in this mutation.
  2294. func (m *AgentBaseMutation) RemovedEdges() []string {
  2295. edges := make([]string, 0, 1)
  2296. if m.removedwx_agent != nil {
  2297. edges = append(edges, agentbase.EdgeWxAgent)
  2298. }
  2299. return edges
  2300. }
  2301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2302. // the given name in this mutation.
  2303. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2304. switch name {
  2305. case agentbase.EdgeWxAgent:
  2306. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2307. for id := range m.removedwx_agent {
  2308. ids = append(ids, id)
  2309. }
  2310. return ids
  2311. }
  2312. return nil
  2313. }
  2314. // ClearedEdges returns all edge names that were cleared in this mutation.
  2315. func (m *AgentBaseMutation) ClearedEdges() []string {
  2316. edges := make([]string, 0, 1)
  2317. if m.clearedwx_agent {
  2318. edges = append(edges, agentbase.EdgeWxAgent)
  2319. }
  2320. return edges
  2321. }
  2322. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2323. // was cleared in this mutation.
  2324. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2325. switch name {
  2326. case agentbase.EdgeWxAgent:
  2327. return m.clearedwx_agent
  2328. }
  2329. return false
  2330. }
  2331. // ClearEdge clears the value of the edge with the given name. It returns an error
  2332. // if that edge is not defined in the schema.
  2333. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2334. switch name {
  2335. }
  2336. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2337. }
  2338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2339. // It returns an error if the edge is not defined in the schema.
  2340. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2341. switch name {
  2342. case agentbase.EdgeWxAgent:
  2343. m.ResetWxAgent()
  2344. return nil
  2345. }
  2346. return fmt.Errorf("unknown AgentBase edge %s", name)
  2347. }
  2348. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2349. type AliyunAvatarMutation struct {
  2350. config
  2351. op Op
  2352. typ string
  2353. id *uint64
  2354. created_at *time.Time
  2355. updated_at *time.Time
  2356. deleted_at *time.Time
  2357. user_id *uint64
  2358. adduser_id *int64
  2359. biz_id *string
  2360. access_key_id *string
  2361. access_key_secret *string
  2362. app_id *string
  2363. tenant_id *uint64
  2364. addtenant_id *int64
  2365. response *string
  2366. token *string
  2367. session_id *string
  2368. clearedFields map[string]struct{}
  2369. done bool
  2370. oldValue func(context.Context) (*AliyunAvatar, error)
  2371. predicates []predicate.AliyunAvatar
  2372. }
  2373. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2374. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2375. type aliyunavatarOption func(*AliyunAvatarMutation)
  2376. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2377. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2378. m := &AliyunAvatarMutation{
  2379. config: c,
  2380. op: op,
  2381. typ: TypeAliyunAvatar,
  2382. clearedFields: make(map[string]struct{}),
  2383. }
  2384. for _, opt := range opts {
  2385. opt(m)
  2386. }
  2387. return m
  2388. }
  2389. // withAliyunAvatarID sets the ID field of the mutation.
  2390. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2391. return func(m *AliyunAvatarMutation) {
  2392. var (
  2393. err error
  2394. once sync.Once
  2395. value *AliyunAvatar
  2396. )
  2397. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2398. once.Do(func() {
  2399. if m.done {
  2400. err = errors.New("querying old values post mutation is not allowed")
  2401. } else {
  2402. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2403. }
  2404. })
  2405. return value, err
  2406. }
  2407. m.id = &id
  2408. }
  2409. }
  2410. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2411. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2412. return func(m *AliyunAvatarMutation) {
  2413. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2414. return node, nil
  2415. }
  2416. m.id = &node.ID
  2417. }
  2418. }
  2419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2420. // executed in a transaction (ent.Tx), a transactional client is returned.
  2421. func (m AliyunAvatarMutation) Client() *Client {
  2422. client := &Client{config: m.config}
  2423. client.init()
  2424. return client
  2425. }
  2426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2427. // it returns an error otherwise.
  2428. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2429. if _, ok := m.driver.(*txDriver); !ok {
  2430. return nil, errors.New("ent: mutation is not running in a transaction")
  2431. }
  2432. tx := &Tx{config: m.config}
  2433. tx.init()
  2434. return tx, nil
  2435. }
  2436. // SetID sets the value of the id field. Note that this
  2437. // operation is only accepted on creation of AliyunAvatar entities.
  2438. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2439. m.id = &id
  2440. }
  2441. // ID returns the ID value in the mutation. Note that the ID is only available
  2442. // if it was provided to the builder or after it was returned from the database.
  2443. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2444. if m.id == nil {
  2445. return
  2446. }
  2447. return *m.id, true
  2448. }
  2449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2450. // That means, if the mutation is applied within a transaction with an isolation level such
  2451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2452. // or updated by the mutation.
  2453. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2454. switch {
  2455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2456. id, exists := m.ID()
  2457. if exists {
  2458. return []uint64{id}, nil
  2459. }
  2460. fallthrough
  2461. case m.op.Is(OpUpdate | OpDelete):
  2462. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2463. default:
  2464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2465. }
  2466. }
  2467. // SetCreatedAt sets the "created_at" field.
  2468. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2469. m.created_at = &t
  2470. }
  2471. // CreatedAt returns the value of the "created_at" field in the mutation.
  2472. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2473. v := m.created_at
  2474. if v == nil {
  2475. return
  2476. }
  2477. return *v, true
  2478. }
  2479. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2480. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2482. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2483. if !m.op.Is(OpUpdateOne) {
  2484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2485. }
  2486. if m.id == nil || m.oldValue == nil {
  2487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2488. }
  2489. oldValue, err := m.oldValue(ctx)
  2490. if err != nil {
  2491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2492. }
  2493. return oldValue.CreatedAt, nil
  2494. }
  2495. // ResetCreatedAt resets all changes to the "created_at" field.
  2496. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2497. m.created_at = nil
  2498. }
  2499. // SetUpdatedAt sets the "updated_at" field.
  2500. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2501. m.updated_at = &t
  2502. }
  2503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2504. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2505. v := m.updated_at
  2506. if v == nil {
  2507. return
  2508. }
  2509. return *v, true
  2510. }
  2511. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2512. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2514. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2515. if !m.op.Is(OpUpdateOne) {
  2516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2517. }
  2518. if m.id == nil || m.oldValue == nil {
  2519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2520. }
  2521. oldValue, err := m.oldValue(ctx)
  2522. if err != nil {
  2523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2524. }
  2525. return oldValue.UpdatedAt, nil
  2526. }
  2527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2528. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2529. m.updated_at = nil
  2530. }
  2531. // SetDeletedAt sets the "deleted_at" field.
  2532. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2533. m.deleted_at = &t
  2534. }
  2535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2536. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2537. v := m.deleted_at
  2538. if v == nil {
  2539. return
  2540. }
  2541. return *v, true
  2542. }
  2543. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2544. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2546. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2547. if !m.op.Is(OpUpdateOne) {
  2548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2549. }
  2550. if m.id == nil || m.oldValue == nil {
  2551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2552. }
  2553. oldValue, err := m.oldValue(ctx)
  2554. if err != nil {
  2555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2556. }
  2557. return oldValue.DeletedAt, nil
  2558. }
  2559. // ClearDeletedAt clears the value of the "deleted_at" field.
  2560. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2561. m.deleted_at = nil
  2562. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2563. }
  2564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2565. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2566. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2567. return ok
  2568. }
  2569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2570. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2571. m.deleted_at = nil
  2572. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2573. }
  2574. // SetUserID sets the "user_id" field.
  2575. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2576. m.user_id = &u
  2577. m.adduser_id = nil
  2578. }
  2579. // UserID returns the value of the "user_id" field in the mutation.
  2580. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2581. v := m.user_id
  2582. if v == nil {
  2583. return
  2584. }
  2585. return *v, true
  2586. }
  2587. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2588. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2590. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2591. if !m.op.Is(OpUpdateOne) {
  2592. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2593. }
  2594. if m.id == nil || m.oldValue == nil {
  2595. return v, errors.New("OldUserID requires an ID field in the mutation")
  2596. }
  2597. oldValue, err := m.oldValue(ctx)
  2598. if err != nil {
  2599. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2600. }
  2601. return oldValue.UserID, nil
  2602. }
  2603. // AddUserID adds u to the "user_id" field.
  2604. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2605. if m.adduser_id != nil {
  2606. *m.adduser_id += u
  2607. } else {
  2608. m.adduser_id = &u
  2609. }
  2610. }
  2611. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2612. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2613. v := m.adduser_id
  2614. if v == nil {
  2615. return
  2616. }
  2617. return *v, true
  2618. }
  2619. // ResetUserID resets all changes to the "user_id" field.
  2620. func (m *AliyunAvatarMutation) ResetUserID() {
  2621. m.user_id = nil
  2622. m.adduser_id = nil
  2623. }
  2624. // SetBizID sets the "biz_id" field.
  2625. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2626. m.biz_id = &s
  2627. }
  2628. // BizID returns the value of the "biz_id" field in the mutation.
  2629. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2630. v := m.biz_id
  2631. if v == nil {
  2632. return
  2633. }
  2634. return *v, true
  2635. }
  2636. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2637. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2639. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2640. if !m.op.Is(OpUpdateOne) {
  2641. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2642. }
  2643. if m.id == nil || m.oldValue == nil {
  2644. return v, errors.New("OldBizID requires an ID field in the mutation")
  2645. }
  2646. oldValue, err := m.oldValue(ctx)
  2647. if err != nil {
  2648. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2649. }
  2650. return oldValue.BizID, nil
  2651. }
  2652. // ResetBizID resets all changes to the "biz_id" field.
  2653. func (m *AliyunAvatarMutation) ResetBizID() {
  2654. m.biz_id = nil
  2655. }
  2656. // SetAccessKeyID sets the "access_key_id" field.
  2657. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2658. m.access_key_id = &s
  2659. }
  2660. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2661. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2662. v := m.access_key_id
  2663. if v == nil {
  2664. return
  2665. }
  2666. return *v, true
  2667. }
  2668. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2669. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2671. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2672. if !m.op.Is(OpUpdateOne) {
  2673. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2674. }
  2675. if m.id == nil || m.oldValue == nil {
  2676. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2677. }
  2678. oldValue, err := m.oldValue(ctx)
  2679. if err != nil {
  2680. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2681. }
  2682. return oldValue.AccessKeyID, nil
  2683. }
  2684. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2685. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2686. m.access_key_id = nil
  2687. }
  2688. // SetAccessKeySecret sets the "access_key_secret" field.
  2689. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2690. m.access_key_secret = &s
  2691. }
  2692. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2693. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2694. v := m.access_key_secret
  2695. if v == nil {
  2696. return
  2697. }
  2698. return *v, true
  2699. }
  2700. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2701. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2703. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2704. if !m.op.Is(OpUpdateOne) {
  2705. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2706. }
  2707. if m.id == nil || m.oldValue == nil {
  2708. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2709. }
  2710. oldValue, err := m.oldValue(ctx)
  2711. if err != nil {
  2712. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2713. }
  2714. return oldValue.AccessKeySecret, nil
  2715. }
  2716. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2717. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2718. m.access_key_secret = nil
  2719. }
  2720. // SetAppID sets the "app_id" field.
  2721. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2722. m.app_id = &s
  2723. }
  2724. // AppID returns the value of the "app_id" field in the mutation.
  2725. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2726. v := m.app_id
  2727. if v == nil {
  2728. return
  2729. }
  2730. return *v, true
  2731. }
  2732. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2733. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2735. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2736. if !m.op.Is(OpUpdateOne) {
  2737. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2738. }
  2739. if m.id == nil || m.oldValue == nil {
  2740. return v, errors.New("OldAppID requires an ID field in the mutation")
  2741. }
  2742. oldValue, err := m.oldValue(ctx)
  2743. if err != nil {
  2744. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2745. }
  2746. return oldValue.AppID, nil
  2747. }
  2748. // ClearAppID clears the value of the "app_id" field.
  2749. func (m *AliyunAvatarMutation) ClearAppID() {
  2750. m.app_id = nil
  2751. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2752. }
  2753. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2754. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2755. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2756. return ok
  2757. }
  2758. // ResetAppID resets all changes to the "app_id" field.
  2759. func (m *AliyunAvatarMutation) ResetAppID() {
  2760. m.app_id = nil
  2761. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2762. }
  2763. // SetTenantID sets the "tenant_id" field.
  2764. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2765. m.tenant_id = &u
  2766. m.addtenant_id = nil
  2767. }
  2768. // TenantID returns the value of the "tenant_id" field in the mutation.
  2769. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2770. v := m.tenant_id
  2771. if v == nil {
  2772. return
  2773. }
  2774. return *v, true
  2775. }
  2776. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2777. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2779. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2780. if !m.op.Is(OpUpdateOne) {
  2781. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2782. }
  2783. if m.id == nil || m.oldValue == nil {
  2784. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2785. }
  2786. oldValue, err := m.oldValue(ctx)
  2787. if err != nil {
  2788. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2789. }
  2790. return oldValue.TenantID, nil
  2791. }
  2792. // AddTenantID adds u to the "tenant_id" field.
  2793. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2794. if m.addtenant_id != nil {
  2795. *m.addtenant_id += u
  2796. } else {
  2797. m.addtenant_id = &u
  2798. }
  2799. }
  2800. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2801. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2802. v := m.addtenant_id
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // ResetTenantID resets all changes to the "tenant_id" field.
  2809. func (m *AliyunAvatarMutation) ResetTenantID() {
  2810. m.tenant_id = nil
  2811. m.addtenant_id = nil
  2812. }
  2813. // SetResponse sets the "response" field.
  2814. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2815. m.response = &s
  2816. }
  2817. // Response returns the value of the "response" field in the mutation.
  2818. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2819. v := m.response
  2820. if v == nil {
  2821. return
  2822. }
  2823. return *v, true
  2824. }
  2825. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2826. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2828. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2829. if !m.op.Is(OpUpdateOne) {
  2830. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2831. }
  2832. if m.id == nil || m.oldValue == nil {
  2833. return v, errors.New("OldResponse requires an ID field in the mutation")
  2834. }
  2835. oldValue, err := m.oldValue(ctx)
  2836. if err != nil {
  2837. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2838. }
  2839. return oldValue.Response, nil
  2840. }
  2841. // ResetResponse resets all changes to the "response" field.
  2842. func (m *AliyunAvatarMutation) ResetResponse() {
  2843. m.response = nil
  2844. }
  2845. // SetToken sets the "token" field.
  2846. func (m *AliyunAvatarMutation) SetToken(s string) {
  2847. m.token = &s
  2848. }
  2849. // Token returns the value of the "token" field in the mutation.
  2850. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2851. v := m.token
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2858. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2860. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2861. if !m.op.Is(OpUpdateOne) {
  2862. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2863. }
  2864. if m.id == nil || m.oldValue == nil {
  2865. return v, errors.New("OldToken requires an ID field in the mutation")
  2866. }
  2867. oldValue, err := m.oldValue(ctx)
  2868. if err != nil {
  2869. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2870. }
  2871. return oldValue.Token, nil
  2872. }
  2873. // ResetToken resets all changes to the "token" field.
  2874. func (m *AliyunAvatarMutation) ResetToken() {
  2875. m.token = nil
  2876. }
  2877. // SetSessionID sets the "session_id" field.
  2878. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2879. m.session_id = &s
  2880. }
  2881. // SessionID returns the value of the "session_id" field in the mutation.
  2882. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2883. v := m.session_id
  2884. if v == nil {
  2885. return
  2886. }
  2887. return *v, true
  2888. }
  2889. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2890. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2892. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2893. if !m.op.Is(OpUpdateOne) {
  2894. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2895. }
  2896. if m.id == nil || m.oldValue == nil {
  2897. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2898. }
  2899. oldValue, err := m.oldValue(ctx)
  2900. if err != nil {
  2901. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2902. }
  2903. return oldValue.SessionID, nil
  2904. }
  2905. // ResetSessionID resets all changes to the "session_id" field.
  2906. func (m *AliyunAvatarMutation) ResetSessionID() {
  2907. m.session_id = nil
  2908. }
  2909. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2910. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2911. m.predicates = append(m.predicates, ps...)
  2912. }
  2913. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2914. // users can use type-assertion to append predicates that do not depend on any generated package.
  2915. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2916. p := make([]predicate.AliyunAvatar, len(ps))
  2917. for i := range ps {
  2918. p[i] = ps[i]
  2919. }
  2920. m.Where(p...)
  2921. }
  2922. // Op returns the operation name.
  2923. func (m *AliyunAvatarMutation) Op() Op {
  2924. return m.op
  2925. }
  2926. // SetOp allows setting the mutation operation.
  2927. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2928. m.op = op
  2929. }
  2930. // Type returns the node type of this mutation (AliyunAvatar).
  2931. func (m *AliyunAvatarMutation) Type() string {
  2932. return m.typ
  2933. }
  2934. // Fields returns all fields that were changed during this mutation. Note that in
  2935. // order to get all numeric fields that were incremented/decremented, call
  2936. // AddedFields().
  2937. func (m *AliyunAvatarMutation) Fields() []string {
  2938. fields := make([]string, 0, 12)
  2939. if m.created_at != nil {
  2940. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2941. }
  2942. if m.updated_at != nil {
  2943. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2944. }
  2945. if m.deleted_at != nil {
  2946. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2947. }
  2948. if m.user_id != nil {
  2949. fields = append(fields, aliyunavatar.FieldUserID)
  2950. }
  2951. if m.biz_id != nil {
  2952. fields = append(fields, aliyunavatar.FieldBizID)
  2953. }
  2954. if m.access_key_id != nil {
  2955. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2956. }
  2957. if m.access_key_secret != nil {
  2958. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2959. }
  2960. if m.app_id != nil {
  2961. fields = append(fields, aliyunavatar.FieldAppID)
  2962. }
  2963. if m.tenant_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldTenantID)
  2965. }
  2966. if m.response != nil {
  2967. fields = append(fields, aliyunavatar.FieldResponse)
  2968. }
  2969. if m.token != nil {
  2970. fields = append(fields, aliyunavatar.FieldToken)
  2971. }
  2972. if m.session_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldSessionID)
  2974. }
  2975. return fields
  2976. }
  2977. // Field returns the value of a field with the given name. The second boolean
  2978. // return value indicates that this field was not set, or was not defined in the
  2979. // schema.
  2980. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldCreatedAt:
  2983. return m.CreatedAt()
  2984. case aliyunavatar.FieldUpdatedAt:
  2985. return m.UpdatedAt()
  2986. case aliyunavatar.FieldDeletedAt:
  2987. return m.DeletedAt()
  2988. case aliyunavatar.FieldUserID:
  2989. return m.UserID()
  2990. case aliyunavatar.FieldBizID:
  2991. return m.BizID()
  2992. case aliyunavatar.FieldAccessKeyID:
  2993. return m.AccessKeyID()
  2994. case aliyunavatar.FieldAccessKeySecret:
  2995. return m.AccessKeySecret()
  2996. case aliyunavatar.FieldAppID:
  2997. return m.AppID()
  2998. case aliyunavatar.FieldTenantID:
  2999. return m.TenantID()
  3000. case aliyunavatar.FieldResponse:
  3001. return m.Response()
  3002. case aliyunavatar.FieldToken:
  3003. return m.Token()
  3004. case aliyunavatar.FieldSessionID:
  3005. return m.SessionID()
  3006. }
  3007. return nil, false
  3008. }
  3009. // OldField returns the old value of the field from the database. An error is
  3010. // returned if the mutation operation is not UpdateOne, or the query to the
  3011. // database failed.
  3012. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3013. switch name {
  3014. case aliyunavatar.FieldCreatedAt:
  3015. return m.OldCreatedAt(ctx)
  3016. case aliyunavatar.FieldUpdatedAt:
  3017. return m.OldUpdatedAt(ctx)
  3018. case aliyunavatar.FieldDeletedAt:
  3019. return m.OldDeletedAt(ctx)
  3020. case aliyunavatar.FieldUserID:
  3021. return m.OldUserID(ctx)
  3022. case aliyunavatar.FieldBizID:
  3023. return m.OldBizID(ctx)
  3024. case aliyunavatar.FieldAccessKeyID:
  3025. return m.OldAccessKeyID(ctx)
  3026. case aliyunavatar.FieldAccessKeySecret:
  3027. return m.OldAccessKeySecret(ctx)
  3028. case aliyunavatar.FieldAppID:
  3029. return m.OldAppID(ctx)
  3030. case aliyunavatar.FieldTenantID:
  3031. return m.OldTenantID(ctx)
  3032. case aliyunavatar.FieldResponse:
  3033. return m.OldResponse(ctx)
  3034. case aliyunavatar.FieldToken:
  3035. return m.OldToken(ctx)
  3036. case aliyunavatar.FieldSessionID:
  3037. return m.OldSessionID(ctx)
  3038. }
  3039. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3040. }
  3041. // SetField sets the value of a field with the given name. It returns an error if
  3042. // the field is not defined in the schema, or if the type mismatched the field
  3043. // type.
  3044. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. v, ok := value.(time.Time)
  3048. if !ok {
  3049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3050. }
  3051. m.SetCreatedAt(v)
  3052. return nil
  3053. case aliyunavatar.FieldUpdatedAt:
  3054. v, ok := value.(time.Time)
  3055. if !ok {
  3056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3057. }
  3058. m.SetUpdatedAt(v)
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetDeletedAt(v)
  3066. return nil
  3067. case aliyunavatar.FieldUserID:
  3068. v, ok := value.(uint64)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUserID(v)
  3073. return nil
  3074. case aliyunavatar.FieldBizID:
  3075. v, ok := value.(string)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetBizID(v)
  3080. return nil
  3081. case aliyunavatar.FieldAccessKeyID:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetAccessKeyID(v)
  3087. return nil
  3088. case aliyunavatar.FieldAccessKeySecret:
  3089. v, ok := value.(string)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetAccessKeySecret(v)
  3094. return nil
  3095. case aliyunavatar.FieldAppID:
  3096. v, ok := value.(string)
  3097. if !ok {
  3098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3099. }
  3100. m.SetAppID(v)
  3101. return nil
  3102. case aliyunavatar.FieldTenantID:
  3103. v, ok := value.(uint64)
  3104. if !ok {
  3105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3106. }
  3107. m.SetTenantID(v)
  3108. return nil
  3109. case aliyunavatar.FieldResponse:
  3110. v, ok := value.(string)
  3111. if !ok {
  3112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3113. }
  3114. m.SetResponse(v)
  3115. return nil
  3116. case aliyunavatar.FieldToken:
  3117. v, ok := value.(string)
  3118. if !ok {
  3119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3120. }
  3121. m.SetToken(v)
  3122. return nil
  3123. case aliyunavatar.FieldSessionID:
  3124. v, ok := value.(string)
  3125. if !ok {
  3126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3127. }
  3128. m.SetSessionID(v)
  3129. return nil
  3130. }
  3131. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3132. }
  3133. // AddedFields returns all numeric fields that were incremented/decremented during
  3134. // this mutation.
  3135. func (m *AliyunAvatarMutation) AddedFields() []string {
  3136. var fields []string
  3137. if m.adduser_id != nil {
  3138. fields = append(fields, aliyunavatar.FieldUserID)
  3139. }
  3140. if m.addtenant_id != nil {
  3141. fields = append(fields, aliyunavatar.FieldTenantID)
  3142. }
  3143. return fields
  3144. }
  3145. // AddedField returns the numeric value that was incremented/decremented on a field
  3146. // with the given name. The second boolean return value indicates that this field
  3147. // was not set, or was not defined in the schema.
  3148. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3149. switch name {
  3150. case aliyunavatar.FieldUserID:
  3151. return m.AddedUserID()
  3152. case aliyunavatar.FieldTenantID:
  3153. return m.AddedTenantID()
  3154. }
  3155. return nil, false
  3156. }
  3157. // AddField adds the value to the field with the given name. It returns an error if
  3158. // the field is not defined in the schema, or if the type mismatched the field
  3159. // type.
  3160. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3161. switch name {
  3162. case aliyunavatar.FieldUserID:
  3163. v, ok := value.(int64)
  3164. if !ok {
  3165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3166. }
  3167. m.AddUserID(v)
  3168. return nil
  3169. case aliyunavatar.FieldTenantID:
  3170. v, ok := value.(int64)
  3171. if !ok {
  3172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3173. }
  3174. m.AddTenantID(v)
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3178. }
  3179. // ClearedFields returns all nullable fields that were cleared during this
  3180. // mutation.
  3181. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3182. var fields []string
  3183. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3184. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3185. }
  3186. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3187. fields = append(fields, aliyunavatar.FieldAppID)
  3188. }
  3189. return fields
  3190. }
  3191. // FieldCleared returns a boolean indicating if a field with the given name was
  3192. // cleared in this mutation.
  3193. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3194. _, ok := m.clearedFields[name]
  3195. return ok
  3196. }
  3197. // ClearField clears the value of the field with the given name. It returns an
  3198. // error if the field is not defined in the schema.
  3199. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3200. switch name {
  3201. case aliyunavatar.FieldDeletedAt:
  3202. m.ClearDeletedAt()
  3203. return nil
  3204. case aliyunavatar.FieldAppID:
  3205. m.ClearAppID()
  3206. return nil
  3207. }
  3208. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3209. }
  3210. // ResetField resets all changes in the mutation for the field with the given name.
  3211. // It returns an error if the field is not defined in the schema.
  3212. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3213. switch name {
  3214. case aliyunavatar.FieldCreatedAt:
  3215. m.ResetCreatedAt()
  3216. return nil
  3217. case aliyunavatar.FieldUpdatedAt:
  3218. m.ResetUpdatedAt()
  3219. return nil
  3220. case aliyunavatar.FieldDeletedAt:
  3221. m.ResetDeletedAt()
  3222. return nil
  3223. case aliyunavatar.FieldUserID:
  3224. m.ResetUserID()
  3225. return nil
  3226. case aliyunavatar.FieldBizID:
  3227. m.ResetBizID()
  3228. return nil
  3229. case aliyunavatar.FieldAccessKeyID:
  3230. m.ResetAccessKeyID()
  3231. return nil
  3232. case aliyunavatar.FieldAccessKeySecret:
  3233. m.ResetAccessKeySecret()
  3234. return nil
  3235. case aliyunavatar.FieldAppID:
  3236. m.ResetAppID()
  3237. return nil
  3238. case aliyunavatar.FieldTenantID:
  3239. m.ResetTenantID()
  3240. return nil
  3241. case aliyunavatar.FieldResponse:
  3242. m.ResetResponse()
  3243. return nil
  3244. case aliyunavatar.FieldToken:
  3245. m.ResetToken()
  3246. return nil
  3247. case aliyunavatar.FieldSessionID:
  3248. m.ResetSessionID()
  3249. return nil
  3250. }
  3251. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3252. }
  3253. // AddedEdges returns all edge names that were set/added in this mutation.
  3254. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3255. edges := make([]string, 0, 0)
  3256. return edges
  3257. }
  3258. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3259. // name in this mutation.
  3260. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3261. return nil
  3262. }
  3263. // RemovedEdges returns all edge names that were removed in this mutation.
  3264. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3265. edges := make([]string, 0, 0)
  3266. return edges
  3267. }
  3268. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3269. // the given name in this mutation.
  3270. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3271. return nil
  3272. }
  3273. // ClearedEdges returns all edge names that were cleared in this mutation.
  3274. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3275. edges := make([]string, 0, 0)
  3276. return edges
  3277. }
  3278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3279. // was cleared in this mutation.
  3280. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3281. return false
  3282. }
  3283. // ClearEdge clears the value of the edge with the given name. It returns an error
  3284. // if that edge is not defined in the schema.
  3285. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3286. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3287. }
  3288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3289. // It returns an error if the edge is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3291. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3292. }
  3293. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3294. type AllocAgentMutation struct {
  3295. config
  3296. op Op
  3297. typ string
  3298. id *uint64
  3299. created_at *time.Time
  3300. updated_at *time.Time
  3301. deleted_at *time.Time
  3302. user_id *string
  3303. organization_id *uint64
  3304. addorganization_id *int64
  3305. agents *[]uint64
  3306. appendagents []uint64
  3307. status *int
  3308. addstatus *int
  3309. clearedFields map[string]struct{}
  3310. done bool
  3311. oldValue func(context.Context) (*AllocAgent, error)
  3312. predicates []predicate.AllocAgent
  3313. }
  3314. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3315. // allocagentOption allows management of the mutation configuration using functional options.
  3316. type allocagentOption func(*AllocAgentMutation)
  3317. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3318. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3319. m := &AllocAgentMutation{
  3320. config: c,
  3321. op: op,
  3322. typ: TypeAllocAgent,
  3323. clearedFields: make(map[string]struct{}),
  3324. }
  3325. for _, opt := range opts {
  3326. opt(m)
  3327. }
  3328. return m
  3329. }
  3330. // withAllocAgentID sets the ID field of the mutation.
  3331. func withAllocAgentID(id uint64) allocagentOption {
  3332. return func(m *AllocAgentMutation) {
  3333. var (
  3334. err error
  3335. once sync.Once
  3336. value *AllocAgent
  3337. )
  3338. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3339. once.Do(func() {
  3340. if m.done {
  3341. err = errors.New("querying old values post mutation is not allowed")
  3342. } else {
  3343. value, err = m.Client().AllocAgent.Get(ctx, id)
  3344. }
  3345. })
  3346. return value, err
  3347. }
  3348. m.id = &id
  3349. }
  3350. }
  3351. // withAllocAgent sets the old AllocAgent of the mutation.
  3352. func withAllocAgent(node *AllocAgent) allocagentOption {
  3353. return func(m *AllocAgentMutation) {
  3354. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3355. return node, nil
  3356. }
  3357. m.id = &node.ID
  3358. }
  3359. }
  3360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3361. // executed in a transaction (ent.Tx), a transactional client is returned.
  3362. func (m AllocAgentMutation) Client() *Client {
  3363. client := &Client{config: m.config}
  3364. client.init()
  3365. return client
  3366. }
  3367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3368. // it returns an error otherwise.
  3369. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3370. if _, ok := m.driver.(*txDriver); !ok {
  3371. return nil, errors.New("ent: mutation is not running in a transaction")
  3372. }
  3373. tx := &Tx{config: m.config}
  3374. tx.init()
  3375. return tx, nil
  3376. }
  3377. // SetID sets the value of the id field. Note that this
  3378. // operation is only accepted on creation of AllocAgent entities.
  3379. func (m *AllocAgentMutation) SetID(id uint64) {
  3380. m.id = &id
  3381. }
  3382. // ID returns the ID value in the mutation. Note that the ID is only available
  3383. // if it was provided to the builder or after it was returned from the database.
  3384. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3385. if m.id == nil {
  3386. return
  3387. }
  3388. return *m.id, true
  3389. }
  3390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3391. // That means, if the mutation is applied within a transaction with an isolation level such
  3392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3393. // or updated by the mutation.
  3394. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3395. switch {
  3396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3397. id, exists := m.ID()
  3398. if exists {
  3399. return []uint64{id}, nil
  3400. }
  3401. fallthrough
  3402. case m.op.Is(OpUpdate | OpDelete):
  3403. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3404. default:
  3405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3406. }
  3407. }
  3408. // SetCreatedAt sets the "created_at" field.
  3409. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3410. m.created_at = &t
  3411. }
  3412. // CreatedAt returns the value of the "created_at" field in the mutation.
  3413. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3414. v := m.created_at
  3415. if v == nil {
  3416. return
  3417. }
  3418. return *v, true
  3419. }
  3420. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3421. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3423. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3424. if !m.op.Is(OpUpdateOne) {
  3425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3426. }
  3427. if m.id == nil || m.oldValue == nil {
  3428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3429. }
  3430. oldValue, err := m.oldValue(ctx)
  3431. if err != nil {
  3432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3433. }
  3434. return oldValue.CreatedAt, nil
  3435. }
  3436. // ResetCreatedAt resets all changes to the "created_at" field.
  3437. func (m *AllocAgentMutation) ResetCreatedAt() {
  3438. m.created_at = nil
  3439. }
  3440. // SetUpdatedAt sets the "updated_at" field.
  3441. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3442. m.updated_at = &t
  3443. }
  3444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3445. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3446. v := m.updated_at
  3447. if v == nil {
  3448. return
  3449. }
  3450. return *v, true
  3451. }
  3452. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3453. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3455. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3456. if !m.op.Is(OpUpdateOne) {
  3457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3458. }
  3459. if m.id == nil || m.oldValue == nil {
  3460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3461. }
  3462. oldValue, err := m.oldValue(ctx)
  3463. if err != nil {
  3464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3465. }
  3466. return oldValue.UpdatedAt, nil
  3467. }
  3468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3469. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3470. m.updated_at = nil
  3471. }
  3472. // SetDeletedAt sets the "deleted_at" field.
  3473. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3474. m.deleted_at = &t
  3475. }
  3476. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3477. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3478. v := m.deleted_at
  3479. if v == nil {
  3480. return
  3481. }
  3482. return *v, true
  3483. }
  3484. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3485. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3487. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3488. if !m.op.Is(OpUpdateOne) {
  3489. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3490. }
  3491. if m.id == nil || m.oldValue == nil {
  3492. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3493. }
  3494. oldValue, err := m.oldValue(ctx)
  3495. if err != nil {
  3496. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3497. }
  3498. return oldValue.DeletedAt, nil
  3499. }
  3500. // ClearDeletedAt clears the value of the "deleted_at" field.
  3501. func (m *AllocAgentMutation) ClearDeletedAt() {
  3502. m.deleted_at = nil
  3503. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3504. }
  3505. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3506. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3507. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3508. return ok
  3509. }
  3510. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3511. func (m *AllocAgentMutation) ResetDeletedAt() {
  3512. m.deleted_at = nil
  3513. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3514. }
  3515. // SetUserID sets the "user_id" field.
  3516. func (m *AllocAgentMutation) SetUserID(s string) {
  3517. m.user_id = &s
  3518. }
  3519. // UserID returns the value of the "user_id" field in the mutation.
  3520. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3521. v := m.user_id
  3522. if v == nil {
  3523. return
  3524. }
  3525. return *v, true
  3526. }
  3527. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3528. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3530. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3531. if !m.op.Is(OpUpdateOne) {
  3532. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3533. }
  3534. if m.id == nil || m.oldValue == nil {
  3535. return v, errors.New("OldUserID requires an ID field in the mutation")
  3536. }
  3537. oldValue, err := m.oldValue(ctx)
  3538. if err != nil {
  3539. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3540. }
  3541. return oldValue.UserID, nil
  3542. }
  3543. // ClearUserID clears the value of the "user_id" field.
  3544. func (m *AllocAgentMutation) ClearUserID() {
  3545. m.user_id = nil
  3546. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3547. }
  3548. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3549. func (m *AllocAgentMutation) UserIDCleared() bool {
  3550. _, ok := m.clearedFields[allocagent.FieldUserID]
  3551. return ok
  3552. }
  3553. // ResetUserID resets all changes to the "user_id" field.
  3554. func (m *AllocAgentMutation) ResetUserID() {
  3555. m.user_id = nil
  3556. delete(m.clearedFields, allocagent.FieldUserID)
  3557. }
  3558. // SetOrganizationID sets the "organization_id" field.
  3559. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3560. m.organization_id = &u
  3561. m.addorganization_id = nil
  3562. }
  3563. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3564. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3565. v := m.organization_id
  3566. if v == nil {
  3567. return
  3568. }
  3569. return *v, true
  3570. }
  3571. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3572. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3574. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3575. if !m.op.Is(OpUpdateOne) {
  3576. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3577. }
  3578. if m.id == nil || m.oldValue == nil {
  3579. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3580. }
  3581. oldValue, err := m.oldValue(ctx)
  3582. if err != nil {
  3583. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3584. }
  3585. return oldValue.OrganizationID, nil
  3586. }
  3587. // AddOrganizationID adds u to the "organization_id" field.
  3588. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3589. if m.addorganization_id != nil {
  3590. *m.addorganization_id += u
  3591. } else {
  3592. m.addorganization_id = &u
  3593. }
  3594. }
  3595. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3596. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3597. v := m.addorganization_id
  3598. if v == nil {
  3599. return
  3600. }
  3601. return *v, true
  3602. }
  3603. // ClearOrganizationID clears the value of the "organization_id" field.
  3604. func (m *AllocAgentMutation) ClearOrganizationID() {
  3605. m.organization_id = nil
  3606. m.addorganization_id = nil
  3607. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3608. }
  3609. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3610. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3611. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3612. return ok
  3613. }
  3614. // ResetOrganizationID resets all changes to the "organization_id" field.
  3615. func (m *AllocAgentMutation) ResetOrganizationID() {
  3616. m.organization_id = nil
  3617. m.addorganization_id = nil
  3618. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3619. }
  3620. // SetAgents sets the "agents" field.
  3621. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3622. m.agents = &u
  3623. m.appendagents = nil
  3624. }
  3625. // Agents returns the value of the "agents" field in the mutation.
  3626. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3627. v := m.agents
  3628. if v == nil {
  3629. return
  3630. }
  3631. return *v, true
  3632. }
  3633. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3634. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3636. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3637. if !m.op.Is(OpUpdateOne) {
  3638. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3639. }
  3640. if m.id == nil || m.oldValue == nil {
  3641. return v, errors.New("OldAgents requires an ID field in the mutation")
  3642. }
  3643. oldValue, err := m.oldValue(ctx)
  3644. if err != nil {
  3645. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3646. }
  3647. return oldValue.Agents, nil
  3648. }
  3649. // AppendAgents adds u to the "agents" field.
  3650. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3651. m.appendagents = append(m.appendagents, u...)
  3652. }
  3653. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3654. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3655. if len(m.appendagents) == 0 {
  3656. return nil, false
  3657. }
  3658. return m.appendagents, true
  3659. }
  3660. // ResetAgents resets all changes to the "agents" field.
  3661. func (m *AllocAgentMutation) ResetAgents() {
  3662. m.agents = nil
  3663. m.appendagents = nil
  3664. }
  3665. // SetStatus sets the "status" field.
  3666. func (m *AllocAgentMutation) SetStatus(i int) {
  3667. m.status = &i
  3668. m.addstatus = nil
  3669. }
  3670. // Status returns the value of the "status" field in the mutation.
  3671. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3672. v := m.status
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3679. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldStatus requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3691. }
  3692. return oldValue.Status, nil
  3693. }
  3694. // AddStatus adds i to the "status" field.
  3695. func (m *AllocAgentMutation) AddStatus(i int) {
  3696. if m.addstatus != nil {
  3697. *m.addstatus += i
  3698. } else {
  3699. m.addstatus = &i
  3700. }
  3701. }
  3702. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3703. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3704. v := m.addstatus
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearStatus clears the value of the "status" field.
  3711. func (m *AllocAgentMutation) ClearStatus() {
  3712. m.status = nil
  3713. m.addstatus = nil
  3714. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3715. }
  3716. // StatusCleared returns if the "status" field was cleared in this mutation.
  3717. func (m *AllocAgentMutation) StatusCleared() bool {
  3718. _, ok := m.clearedFields[allocagent.FieldStatus]
  3719. return ok
  3720. }
  3721. // ResetStatus resets all changes to the "status" field.
  3722. func (m *AllocAgentMutation) ResetStatus() {
  3723. m.status = nil
  3724. m.addstatus = nil
  3725. delete(m.clearedFields, allocagent.FieldStatus)
  3726. }
  3727. // Where appends a list predicates to the AllocAgentMutation builder.
  3728. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3729. m.predicates = append(m.predicates, ps...)
  3730. }
  3731. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3732. // users can use type-assertion to append predicates that do not depend on any generated package.
  3733. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3734. p := make([]predicate.AllocAgent, len(ps))
  3735. for i := range ps {
  3736. p[i] = ps[i]
  3737. }
  3738. m.Where(p...)
  3739. }
  3740. // Op returns the operation name.
  3741. func (m *AllocAgentMutation) Op() Op {
  3742. return m.op
  3743. }
  3744. // SetOp allows setting the mutation operation.
  3745. func (m *AllocAgentMutation) SetOp(op Op) {
  3746. m.op = op
  3747. }
  3748. // Type returns the node type of this mutation (AllocAgent).
  3749. func (m *AllocAgentMutation) Type() string {
  3750. return m.typ
  3751. }
  3752. // Fields returns all fields that were changed during this mutation. Note that in
  3753. // order to get all numeric fields that were incremented/decremented, call
  3754. // AddedFields().
  3755. func (m *AllocAgentMutation) Fields() []string {
  3756. fields := make([]string, 0, 7)
  3757. if m.created_at != nil {
  3758. fields = append(fields, allocagent.FieldCreatedAt)
  3759. }
  3760. if m.updated_at != nil {
  3761. fields = append(fields, allocagent.FieldUpdatedAt)
  3762. }
  3763. if m.deleted_at != nil {
  3764. fields = append(fields, allocagent.FieldDeletedAt)
  3765. }
  3766. if m.user_id != nil {
  3767. fields = append(fields, allocagent.FieldUserID)
  3768. }
  3769. if m.organization_id != nil {
  3770. fields = append(fields, allocagent.FieldOrganizationID)
  3771. }
  3772. if m.agents != nil {
  3773. fields = append(fields, allocagent.FieldAgents)
  3774. }
  3775. if m.status != nil {
  3776. fields = append(fields, allocagent.FieldStatus)
  3777. }
  3778. return fields
  3779. }
  3780. // Field returns the value of a field with the given name. The second boolean
  3781. // return value indicates that this field was not set, or was not defined in the
  3782. // schema.
  3783. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3784. switch name {
  3785. case allocagent.FieldCreatedAt:
  3786. return m.CreatedAt()
  3787. case allocagent.FieldUpdatedAt:
  3788. return m.UpdatedAt()
  3789. case allocagent.FieldDeletedAt:
  3790. return m.DeletedAt()
  3791. case allocagent.FieldUserID:
  3792. return m.UserID()
  3793. case allocagent.FieldOrganizationID:
  3794. return m.OrganizationID()
  3795. case allocagent.FieldAgents:
  3796. return m.Agents()
  3797. case allocagent.FieldStatus:
  3798. return m.Status()
  3799. }
  3800. return nil, false
  3801. }
  3802. // OldField returns the old value of the field from the database. An error is
  3803. // returned if the mutation operation is not UpdateOne, or the query to the
  3804. // database failed.
  3805. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3806. switch name {
  3807. case allocagent.FieldCreatedAt:
  3808. return m.OldCreatedAt(ctx)
  3809. case allocagent.FieldUpdatedAt:
  3810. return m.OldUpdatedAt(ctx)
  3811. case allocagent.FieldDeletedAt:
  3812. return m.OldDeletedAt(ctx)
  3813. case allocagent.FieldUserID:
  3814. return m.OldUserID(ctx)
  3815. case allocagent.FieldOrganizationID:
  3816. return m.OldOrganizationID(ctx)
  3817. case allocagent.FieldAgents:
  3818. return m.OldAgents(ctx)
  3819. case allocagent.FieldStatus:
  3820. return m.OldStatus(ctx)
  3821. }
  3822. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3823. }
  3824. // SetField sets the value of a field with the given name. It returns an error if
  3825. // the field is not defined in the schema, or if the type mismatched the field
  3826. // type.
  3827. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3828. switch name {
  3829. case allocagent.FieldCreatedAt:
  3830. v, ok := value.(time.Time)
  3831. if !ok {
  3832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3833. }
  3834. m.SetCreatedAt(v)
  3835. return nil
  3836. case allocagent.FieldUpdatedAt:
  3837. v, ok := value.(time.Time)
  3838. if !ok {
  3839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3840. }
  3841. m.SetUpdatedAt(v)
  3842. return nil
  3843. case allocagent.FieldDeletedAt:
  3844. v, ok := value.(time.Time)
  3845. if !ok {
  3846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3847. }
  3848. m.SetDeletedAt(v)
  3849. return nil
  3850. case allocagent.FieldUserID:
  3851. v, ok := value.(string)
  3852. if !ok {
  3853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3854. }
  3855. m.SetUserID(v)
  3856. return nil
  3857. case allocagent.FieldOrganizationID:
  3858. v, ok := value.(uint64)
  3859. if !ok {
  3860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3861. }
  3862. m.SetOrganizationID(v)
  3863. return nil
  3864. case allocagent.FieldAgents:
  3865. v, ok := value.([]uint64)
  3866. if !ok {
  3867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3868. }
  3869. m.SetAgents(v)
  3870. return nil
  3871. case allocagent.FieldStatus:
  3872. v, ok := value.(int)
  3873. if !ok {
  3874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3875. }
  3876. m.SetStatus(v)
  3877. return nil
  3878. }
  3879. return fmt.Errorf("unknown AllocAgent field %s", name)
  3880. }
  3881. // AddedFields returns all numeric fields that were incremented/decremented during
  3882. // this mutation.
  3883. func (m *AllocAgentMutation) AddedFields() []string {
  3884. var fields []string
  3885. if m.addorganization_id != nil {
  3886. fields = append(fields, allocagent.FieldOrganizationID)
  3887. }
  3888. if m.addstatus != nil {
  3889. fields = append(fields, allocagent.FieldStatus)
  3890. }
  3891. return fields
  3892. }
  3893. // AddedField returns the numeric value that was incremented/decremented on a field
  3894. // with the given name. The second boolean return value indicates that this field
  3895. // was not set, or was not defined in the schema.
  3896. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3897. switch name {
  3898. case allocagent.FieldOrganizationID:
  3899. return m.AddedOrganizationID()
  3900. case allocagent.FieldStatus:
  3901. return m.AddedStatus()
  3902. }
  3903. return nil, false
  3904. }
  3905. // AddField adds the value to the field with the given name. It returns an error if
  3906. // the field is not defined in the schema, or if the type mismatched the field
  3907. // type.
  3908. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3909. switch name {
  3910. case allocagent.FieldOrganizationID:
  3911. v, ok := value.(int64)
  3912. if !ok {
  3913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3914. }
  3915. m.AddOrganizationID(v)
  3916. return nil
  3917. case allocagent.FieldStatus:
  3918. v, ok := value.(int)
  3919. if !ok {
  3920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3921. }
  3922. m.AddStatus(v)
  3923. return nil
  3924. }
  3925. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3926. }
  3927. // ClearedFields returns all nullable fields that were cleared during this
  3928. // mutation.
  3929. func (m *AllocAgentMutation) ClearedFields() []string {
  3930. var fields []string
  3931. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3932. fields = append(fields, allocagent.FieldDeletedAt)
  3933. }
  3934. if m.FieldCleared(allocagent.FieldUserID) {
  3935. fields = append(fields, allocagent.FieldUserID)
  3936. }
  3937. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3938. fields = append(fields, allocagent.FieldOrganizationID)
  3939. }
  3940. if m.FieldCleared(allocagent.FieldStatus) {
  3941. fields = append(fields, allocagent.FieldStatus)
  3942. }
  3943. return fields
  3944. }
  3945. // FieldCleared returns a boolean indicating if a field with the given name was
  3946. // cleared in this mutation.
  3947. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3948. _, ok := m.clearedFields[name]
  3949. return ok
  3950. }
  3951. // ClearField clears the value of the field with the given name. It returns an
  3952. // error if the field is not defined in the schema.
  3953. func (m *AllocAgentMutation) ClearField(name string) error {
  3954. switch name {
  3955. case allocagent.FieldDeletedAt:
  3956. m.ClearDeletedAt()
  3957. return nil
  3958. case allocagent.FieldUserID:
  3959. m.ClearUserID()
  3960. return nil
  3961. case allocagent.FieldOrganizationID:
  3962. m.ClearOrganizationID()
  3963. return nil
  3964. case allocagent.FieldStatus:
  3965. m.ClearStatus()
  3966. return nil
  3967. }
  3968. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3969. }
  3970. // ResetField resets all changes in the mutation for the field with the given name.
  3971. // It returns an error if the field is not defined in the schema.
  3972. func (m *AllocAgentMutation) ResetField(name string) error {
  3973. switch name {
  3974. case allocagent.FieldCreatedAt:
  3975. m.ResetCreatedAt()
  3976. return nil
  3977. case allocagent.FieldUpdatedAt:
  3978. m.ResetUpdatedAt()
  3979. return nil
  3980. case allocagent.FieldDeletedAt:
  3981. m.ResetDeletedAt()
  3982. return nil
  3983. case allocagent.FieldUserID:
  3984. m.ResetUserID()
  3985. return nil
  3986. case allocagent.FieldOrganizationID:
  3987. m.ResetOrganizationID()
  3988. return nil
  3989. case allocagent.FieldAgents:
  3990. m.ResetAgents()
  3991. return nil
  3992. case allocagent.FieldStatus:
  3993. m.ResetStatus()
  3994. return nil
  3995. }
  3996. return fmt.Errorf("unknown AllocAgent field %s", name)
  3997. }
  3998. // AddedEdges returns all edge names that were set/added in this mutation.
  3999. func (m *AllocAgentMutation) AddedEdges() []string {
  4000. edges := make([]string, 0, 0)
  4001. return edges
  4002. }
  4003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4004. // name in this mutation.
  4005. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4006. return nil
  4007. }
  4008. // RemovedEdges returns all edge names that were removed in this mutation.
  4009. func (m *AllocAgentMutation) RemovedEdges() []string {
  4010. edges := make([]string, 0, 0)
  4011. return edges
  4012. }
  4013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4014. // the given name in this mutation.
  4015. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4016. return nil
  4017. }
  4018. // ClearedEdges returns all edge names that were cleared in this mutation.
  4019. func (m *AllocAgentMutation) ClearedEdges() []string {
  4020. edges := make([]string, 0, 0)
  4021. return edges
  4022. }
  4023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4024. // was cleared in this mutation.
  4025. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4026. return false
  4027. }
  4028. // ClearEdge clears the value of the edge with the given name. It returns an error
  4029. // if that edge is not defined in the schema.
  4030. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4031. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4032. }
  4033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4034. // It returns an error if the edge is not defined in the schema.
  4035. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4036. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4037. }
  4038. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4039. type ApiKeyMutation struct {
  4040. config
  4041. op Op
  4042. typ string
  4043. id *uint64
  4044. created_at *time.Time
  4045. updated_at *time.Time
  4046. deleted_at *time.Time
  4047. title *string
  4048. key *string
  4049. organization_id *uint64
  4050. addorganization_id *int64
  4051. custom_agent_base *string
  4052. custom_agent_key *string
  4053. openai_base *string
  4054. openai_key *string
  4055. clearedFields map[string]struct{}
  4056. agent *uint64
  4057. clearedagent bool
  4058. done bool
  4059. oldValue func(context.Context) (*ApiKey, error)
  4060. predicates []predicate.ApiKey
  4061. }
  4062. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4063. // apikeyOption allows management of the mutation configuration using functional options.
  4064. type apikeyOption func(*ApiKeyMutation)
  4065. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4066. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4067. m := &ApiKeyMutation{
  4068. config: c,
  4069. op: op,
  4070. typ: TypeApiKey,
  4071. clearedFields: make(map[string]struct{}),
  4072. }
  4073. for _, opt := range opts {
  4074. opt(m)
  4075. }
  4076. return m
  4077. }
  4078. // withApiKeyID sets the ID field of the mutation.
  4079. func withApiKeyID(id uint64) apikeyOption {
  4080. return func(m *ApiKeyMutation) {
  4081. var (
  4082. err error
  4083. once sync.Once
  4084. value *ApiKey
  4085. )
  4086. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4087. once.Do(func() {
  4088. if m.done {
  4089. err = errors.New("querying old values post mutation is not allowed")
  4090. } else {
  4091. value, err = m.Client().ApiKey.Get(ctx, id)
  4092. }
  4093. })
  4094. return value, err
  4095. }
  4096. m.id = &id
  4097. }
  4098. }
  4099. // withApiKey sets the old ApiKey of the mutation.
  4100. func withApiKey(node *ApiKey) apikeyOption {
  4101. return func(m *ApiKeyMutation) {
  4102. m.oldValue = func(context.Context) (*ApiKey, error) {
  4103. return node, nil
  4104. }
  4105. m.id = &node.ID
  4106. }
  4107. }
  4108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4109. // executed in a transaction (ent.Tx), a transactional client is returned.
  4110. func (m ApiKeyMutation) Client() *Client {
  4111. client := &Client{config: m.config}
  4112. client.init()
  4113. return client
  4114. }
  4115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4116. // it returns an error otherwise.
  4117. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4118. if _, ok := m.driver.(*txDriver); !ok {
  4119. return nil, errors.New("ent: mutation is not running in a transaction")
  4120. }
  4121. tx := &Tx{config: m.config}
  4122. tx.init()
  4123. return tx, nil
  4124. }
  4125. // SetID sets the value of the id field. Note that this
  4126. // operation is only accepted on creation of ApiKey entities.
  4127. func (m *ApiKeyMutation) SetID(id uint64) {
  4128. m.id = &id
  4129. }
  4130. // ID returns the ID value in the mutation. Note that the ID is only available
  4131. // if it was provided to the builder or after it was returned from the database.
  4132. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4133. if m.id == nil {
  4134. return
  4135. }
  4136. return *m.id, true
  4137. }
  4138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4139. // That means, if the mutation is applied within a transaction with an isolation level such
  4140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4141. // or updated by the mutation.
  4142. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4143. switch {
  4144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4145. id, exists := m.ID()
  4146. if exists {
  4147. return []uint64{id}, nil
  4148. }
  4149. fallthrough
  4150. case m.op.Is(OpUpdate | OpDelete):
  4151. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4152. default:
  4153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4154. }
  4155. }
  4156. // SetCreatedAt sets the "created_at" field.
  4157. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4158. m.created_at = &t
  4159. }
  4160. // CreatedAt returns the value of the "created_at" field in the mutation.
  4161. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4162. v := m.created_at
  4163. if v == nil {
  4164. return
  4165. }
  4166. return *v, true
  4167. }
  4168. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4169. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4171. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4172. if !m.op.Is(OpUpdateOne) {
  4173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4174. }
  4175. if m.id == nil || m.oldValue == nil {
  4176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4177. }
  4178. oldValue, err := m.oldValue(ctx)
  4179. if err != nil {
  4180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4181. }
  4182. return oldValue.CreatedAt, nil
  4183. }
  4184. // ResetCreatedAt resets all changes to the "created_at" field.
  4185. func (m *ApiKeyMutation) ResetCreatedAt() {
  4186. m.created_at = nil
  4187. }
  4188. // SetUpdatedAt sets the "updated_at" field.
  4189. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4190. m.updated_at = &t
  4191. }
  4192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4193. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4194. v := m.updated_at
  4195. if v == nil {
  4196. return
  4197. }
  4198. return *v, true
  4199. }
  4200. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4201. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4203. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4204. if !m.op.Is(OpUpdateOne) {
  4205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4206. }
  4207. if m.id == nil || m.oldValue == nil {
  4208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4209. }
  4210. oldValue, err := m.oldValue(ctx)
  4211. if err != nil {
  4212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4213. }
  4214. return oldValue.UpdatedAt, nil
  4215. }
  4216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4217. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4218. m.updated_at = nil
  4219. }
  4220. // SetDeletedAt sets the "deleted_at" field.
  4221. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4222. m.deleted_at = &t
  4223. }
  4224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4225. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4226. v := m.deleted_at
  4227. if v == nil {
  4228. return
  4229. }
  4230. return *v, true
  4231. }
  4232. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4233. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4235. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4236. if !m.op.Is(OpUpdateOne) {
  4237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4238. }
  4239. if m.id == nil || m.oldValue == nil {
  4240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4241. }
  4242. oldValue, err := m.oldValue(ctx)
  4243. if err != nil {
  4244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4245. }
  4246. return oldValue.DeletedAt, nil
  4247. }
  4248. // ClearDeletedAt clears the value of the "deleted_at" field.
  4249. func (m *ApiKeyMutation) ClearDeletedAt() {
  4250. m.deleted_at = nil
  4251. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4252. }
  4253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4254. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4255. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4256. return ok
  4257. }
  4258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4259. func (m *ApiKeyMutation) ResetDeletedAt() {
  4260. m.deleted_at = nil
  4261. delete(m.clearedFields, apikey.FieldDeletedAt)
  4262. }
  4263. // SetTitle sets the "title" field.
  4264. func (m *ApiKeyMutation) SetTitle(s string) {
  4265. m.title = &s
  4266. }
  4267. // Title returns the value of the "title" field in the mutation.
  4268. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4269. v := m.title
  4270. if v == nil {
  4271. return
  4272. }
  4273. return *v, true
  4274. }
  4275. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4276. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4278. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4279. if !m.op.Is(OpUpdateOne) {
  4280. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4281. }
  4282. if m.id == nil || m.oldValue == nil {
  4283. return v, errors.New("OldTitle requires an ID field in the mutation")
  4284. }
  4285. oldValue, err := m.oldValue(ctx)
  4286. if err != nil {
  4287. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4288. }
  4289. return oldValue.Title, nil
  4290. }
  4291. // ClearTitle clears the value of the "title" field.
  4292. func (m *ApiKeyMutation) ClearTitle() {
  4293. m.title = nil
  4294. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4295. }
  4296. // TitleCleared returns if the "title" field was cleared in this mutation.
  4297. func (m *ApiKeyMutation) TitleCleared() bool {
  4298. _, ok := m.clearedFields[apikey.FieldTitle]
  4299. return ok
  4300. }
  4301. // ResetTitle resets all changes to the "title" field.
  4302. func (m *ApiKeyMutation) ResetTitle() {
  4303. m.title = nil
  4304. delete(m.clearedFields, apikey.FieldTitle)
  4305. }
  4306. // SetKey sets the "key" field.
  4307. func (m *ApiKeyMutation) SetKey(s string) {
  4308. m.key = &s
  4309. }
  4310. // Key returns the value of the "key" field in the mutation.
  4311. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4312. v := m.key
  4313. if v == nil {
  4314. return
  4315. }
  4316. return *v, true
  4317. }
  4318. // OldKey returns the old "key" field's value of the ApiKey entity.
  4319. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4321. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4322. if !m.op.Is(OpUpdateOne) {
  4323. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4324. }
  4325. if m.id == nil || m.oldValue == nil {
  4326. return v, errors.New("OldKey requires an ID field in the mutation")
  4327. }
  4328. oldValue, err := m.oldValue(ctx)
  4329. if err != nil {
  4330. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4331. }
  4332. return oldValue.Key, nil
  4333. }
  4334. // ClearKey clears the value of the "key" field.
  4335. func (m *ApiKeyMutation) ClearKey() {
  4336. m.key = nil
  4337. m.clearedFields[apikey.FieldKey] = struct{}{}
  4338. }
  4339. // KeyCleared returns if the "key" field was cleared in this mutation.
  4340. func (m *ApiKeyMutation) KeyCleared() bool {
  4341. _, ok := m.clearedFields[apikey.FieldKey]
  4342. return ok
  4343. }
  4344. // ResetKey resets all changes to the "key" field.
  4345. func (m *ApiKeyMutation) ResetKey() {
  4346. m.key = nil
  4347. delete(m.clearedFields, apikey.FieldKey)
  4348. }
  4349. // SetOrganizationID sets the "organization_id" field.
  4350. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4351. m.organization_id = &u
  4352. m.addorganization_id = nil
  4353. }
  4354. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4355. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4356. v := m.organization_id
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4363. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4375. }
  4376. return oldValue.OrganizationID, nil
  4377. }
  4378. // AddOrganizationID adds u to the "organization_id" field.
  4379. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4380. if m.addorganization_id != nil {
  4381. *m.addorganization_id += u
  4382. } else {
  4383. m.addorganization_id = &u
  4384. }
  4385. }
  4386. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4387. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4388. v := m.addorganization_id
  4389. if v == nil {
  4390. return
  4391. }
  4392. return *v, true
  4393. }
  4394. // ResetOrganizationID resets all changes to the "organization_id" field.
  4395. func (m *ApiKeyMutation) ResetOrganizationID() {
  4396. m.organization_id = nil
  4397. m.addorganization_id = nil
  4398. }
  4399. // SetAgentID sets the "agent_id" field.
  4400. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4401. m.agent = &u
  4402. }
  4403. // AgentID returns the value of the "agent_id" field in the mutation.
  4404. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4405. v := m.agent
  4406. if v == nil {
  4407. return
  4408. }
  4409. return *v, true
  4410. }
  4411. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4412. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4414. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4415. if !m.op.Is(OpUpdateOne) {
  4416. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4417. }
  4418. if m.id == nil || m.oldValue == nil {
  4419. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4420. }
  4421. oldValue, err := m.oldValue(ctx)
  4422. if err != nil {
  4423. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4424. }
  4425. return oldValue.AgentID, nil
  4426. }
  4427. // ResetAgentID resets all changes to the "agent_id" field.
  4428. func (m *ApiKeyMutation) ResetAgentID() {
  4429. m.agent = nil
  4430. }
  4431. // SetCustomAgentBase sets the "custom_agent_base" field.
  4432. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4433. m.custom_agent_base = &s
  4434. }
  4435. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4436. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4437. v := m.custom_agent_base
  4438. if v == nil {
  4439. return
  4440. }
  4441. return *v, true
  4442. }
  4443. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4444. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4446. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4447. if !m.op.Is(OpUpdateOne) {
  4448. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4449. }
  4450. if m.id == nil || m.oldValue == nil {
  4451. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4452. }
  4453. oldValue, err := m.oldValue(ctx)
  4454. if err != nil {
  4455. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4456. }
  4457. return oldValue.CustomAgentBase, nil
  4458. }
  4459. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4460. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4461. m.custom_agent_base = nil
  4462. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4463. }
  4464. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4465. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4466. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4467. return ok
  4468. }
  4469. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4470. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4471. m.custom_agent_base = nil
  4472. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4473. }
  4474. // SetCustomAgentKey sets the "custom_agent_key" field.
  4475. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4476. m.custom_agent_key = &s
  4477. }
  4478. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4479. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4480. v := m.custom_agent_key
  4481. if v == nil {
  4482. return
  4483. }
  4484. return *v, true
  4485. }
  4486. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4487. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4489. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4490. if !m.op.Is(OpUpdateOne) {
  4491. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4492. }
  4493. if m.id == nil || m.oldValue == nil {
  4494. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4495. }
  4496. oldValue, err := m.oldValue(ctx)
  4497. if err != nil {
  4498. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4499. }
  4500. return oldValue.CustomAgentKey, nil
  4501. }
  4502. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4503. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4504. m.custom_agent_key = nil
  4505. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4506. }
  4507. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4508. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4509. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4510. return ok
  4511. }
  4512. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4513. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4514. m.custom_agent_key = nil
  4515. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4516. }
  4517. // SetOpenaiBase sets the "openai_base" field.
  4518. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4519. m.openai_base = &s
  4520. }
  4521. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4522. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4523. v := m.openai_base
  4524. if v == nil {
  4525. return
  4526. }
  4527. return *v, true
  4528. }
  4529. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4530. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4532. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4533. if !m.op.Is(OpUpdateOne) {
  4534. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4535. }
  4536. if m.id == nil || m.oldValue == nil {
  4537. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4538. }
  4539. oldValue, err := m.oldValue(ctx)
  4540. if err != nil {
  4541. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4542. }
  4543. return oldValue.OpenaiBase, nil
  4544. }
  4545. // ClearOpenaiBase clears the value of the "openai_base" field.
  4546. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4547. m.openai_base = nil
  4548. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4549. }
  4550. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4551. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4552. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4553. return ok
  4554. }
  4555. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4556. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4557. m.openai_base = nil
  4558. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4559. }
  4560. // SetOpenaiKey sets the "openai_key" field.
  4561. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4562. m.openai_key = &s
  4563. }
  4564. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4565. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4566. v := m.openai_key
  4567. if v == nil {
  4568. return
  4569. }
  4570. return *v, true
  4571. }
  4572. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4573. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4575. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4576. if !m.op.Is(OpUpdateOne) {
  4577. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4578. }
  4579. if m.id == nil || m.oldValue == nil {
  4580. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4581. }
  4582. oldValue, err := m.oldValue(ctx)
  4583. if err != nil {
  4584. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4585. }
  4586. return oldValue.OpenaiKey, nil
  4587. }
  4588. // ClearOpenaiKey clears the value of the "openai_key" field.
  4589. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4590. m.openai_key = nil
  4591. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4592. }
  4593. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4594. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4595. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4596. return ok
  4597. }
  4598. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4599. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4600. m.openai_key = nil
  4601. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4602. }
  4603. // ClearAgent clears the "agent" edge to the Agent entity.
  4604. func (m *ApiKeyMutation) ClearAgent() {
  4605. m.clearedagent = true
  4606. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4607. }
  4608. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4609. func (m *ApiKeyMutation) AgentCleared() bool {
  4610. return m.clearedagent
  4611. }
  4612. // AgentIDs returns the "agent" edge IDs in the mutation.
  4613. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4614. // AgentID instead. It exists only for internal usage by the builders.
  4615. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4616. if id := m.agent; id != nil {
  4617. ids = append(ids, *id)
  4618. }
  4619. return
  4620. }
  4621. // ResetAgent resets all changes to the "agent" edge.
  4622. func (m *ApiKeyMutation) ResetAgent() {
  4623. m.agent = nil
  4624. m.clearedagent = false
  4625. }
  4626. // Where appends a list predicates to the ApiKeyMutation builder.
  4627. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4628. m.predicates = append(m.predicates, ps...)
  4629. }
  4630. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4631. // users can use type-assertion to append predicates that do not depend on any generated package.
  4632. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4633. p := make([]predicate.ApiKey, len(ps))
  4634. for i := range ps {
  4635. p[i] = ps[i]
  4636. }
  4637. m.Where(p...)
  4638. }
  4639. // Op returns the operation name.
  4640. func (m *ApiKeyMutation) Op() Op {
  4641. return m.op
  4642. }
  4643. // SetOp allows setting the mutation operation.
  4644. func (m *ApiKeyMutation) SetOp(op Op) {
  4645. m.op = op
  4646. }
  4647. // Type returns the node type of this mutation (ApiKey).
  4648. func (m *ApiKeyMutation) Type() string {
  4649. return m.typ
  4650. }
  4651. // Fields returns all fields that were changed during this mutation. Note that in
  4652. // order to get all numeric fields that were incremented/decremented, call
  4653. // AddedFields().
  4654. func (m *ApiKeyMutation) Fields() []string {
  4655. fields := make([]string, 0, 11)
  4656. if m.created_at != nil {
  4657. fields = append(fields, apikey.FieldCreatedAt)
  4658. }
  4659. if m.updated_at != nil {
  4660. fields = append(fields, apikey.FieldUpdatedAt)
  4661. }
  4662. if m.deleted_at != nil {
  4663. fields = append(fields, apikey.FieldDeletedAt)
  4664. }
  4665. if m.title != nil {
  4666. fields = append(fields, apikey.FieldTitle)
  4667. }
  4668. if m.key != nil {
  4669. fields = append(fields, apikey.FieldKey)
  4670. }
  4671. if m.organization_id != nil {
  4672. fields = append(fields, apikey.FieldOrganizationID)
  4673. }
  4674. if m.agent != nil {
  4675. fields = append(fields, apikey.FieldAgentID)
  4676. }
  4677. if m.custom_agent_base != nil {
  4678. fields = append(fields, apikey.FieldCustomAgentBase)
  4679. }
  4680. if m.custom_agent_key != nil {
  4681. fields = append(fields, apikey.FieldCustomAgentKey)
  4682. }
  4683. if m.openai_base != nil {
  4684. fields = append(fields, apikey.FieldOpenaiBase)
  4685. }
  4686. if m.openai_key != nil {
  4687. fields = append(fields, apikey.FieldOpenaiKey)
  4688. }
  4689. return fields
  4690. }
  4691. // Field returns the value of a field with the given name. The second boolean
  4692. // return value indicates that this field was not set, or was not defined in the
  4693. // schema.
  4694. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4695. switch name {
  4696. case apikey.FieldCreatedAt:
  4697. return m.CreatedAt()
  4698. case apikey.FieldUpdatedAt:
  4699. return m.UpdatedAt()
  4700. case apikey.FieldDeletedAt:
  4701. return m.DeletedAt()
  4702. case apikey.FieldTitle:
  4703. return m.Title()
  4704. case apikey.FieldKey:
  4705. return m.Key()
  4706. case apikey.FieldOrganizationID:
  4707. return m.OrganizationID()
  4708. case apikey.FieldAgentID:
  4709. return m.AgentID()
  4710. case apikey.FieldCustomAgentBase:
  4711. return m.CustomAgentBase()
  4712. case apikey.FieldCustomAgentKey:
  4713. return m.CustomAgentKey()
  4714. case apikey.FieldOpenaiBase:
  4715. return m.OpenaiBase()
  4716. case apikey.FieldOpenaiKey:
  4717. return m.OpenaiKey()
  4718. }
  4719. return nil, false
  4720. }
  4721. // OldField returns the old value of the field from the database. An error is
  4722. // returned if the mutation operation is not UpdateOne, or the query to the
  4723. // database failed.
  4724. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4725. switch name {
  4726. case apikey.FieldCreatedAt:
  4727. return m.OldCreatedAt(ctx)
  4728. case apikey.FieldUpdatedAt:
  4729. return m.OldUpdatedAt(ctx)
  4730. case apikey.FieldDeletedAt:
  4731. return m.OldDeletedAt(ctx)
  4732. case apikey.FieldTitle:
  4733. return m.OldTitle(ctx)
  4734. case apikey.FieldKey:
  4735. return m.OldKey(ctx)
  4736. case apikey.FieldOrganizationID:
  4737. return m.OldOrganizationID(ctx)
  4738. case apikey.FieldAgentID:
  4739. return m.OldAgentID(ctx)
  4740. case apikey.FieldCustomAgentBase:
  4741. return m.OldCustomAgentBase(ctx)
  4742. case apikey.FieldCustomAgentKey:
  4743. return m.OldCustomAgentKey(ctx)
  4744. case apikey.FieldOpenaiBase:
  4745. return m.OldOpenaiBase(ctx)
  4746. case apikey.FieldOpenaiKey:
  4747. return m.OldOpenaiKey(ctx)
  4748. }
  4749. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4750. }
  4751. // SetField sets the value of a field with the given name. It returns an error if
  4752. // the field is not defined in the schema, or if the type mismatched the field
  4753. // type.
  4754. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4755. switch name {
  4756. case apikey.FieldCreatedAt:
  4757. v, ok := value.(time.Time)
  4758. if !ok {
  4759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4760. }
  4761. m.SetCreatedAt(v)
  4762. return nil
  4763. case apikey.FieldUpdatedAt:
  4764. v, ok := value.(time.Time)
  4765. if !ok {
  4766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4767. }
  4768. m.SetUpdatedAt(v)
  4769. return nil
  4770. case apikey.FieldDeletedAt:
  4771. v, ok := value.(time.Time)
  4772. if !ok {
  4773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4774. }
  4775. m.SetDeletedAt(v)
  4776. return nil
  4777. case apikey.FieldTitle:
  4778. v, ok := value.(string)
  4779. if !ok {
  4780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4781. }
  4782. m.SetTitle(v)
  4783. return nil
  4784. case apikey.FieldKey:
  4785. v, ok := value.(string)
  4786. if !ok {
  4787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4788. }
  4789. m.SetKey(v)
  4790. return nil
  4791. case apikey.FieldOrganizationID:
  4792. v, ok := value.(uint64)
  4793. if !ok {
  4794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4795. }
  4796. m.SetOrganizationID(v)
  4797. return nil
  4798. case apikey.FieldAgentID:
  4799. v, ok := value.(uint64)
  4800. if !ok {
  4801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4802. }
  4803. m.SetAgentID(v)
  4804. return nil
  4805. case apikey.FieldCustomAgentBase:
  4806. v, ok := value.(string)
  4807. if !ok {
  4808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4809. }
  4810. m.SetCustomAgentBase(v)
  4811. return nil
  4812. case apikey.FieldCustomAgentKey:
  4813. v, ok := value.(string)
  4814. if !ok {
  4815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4816. }
  4817. m.SetCustomAgentKey(v)
  4818. return nil
  4819. case apikey.FieldOpenaiBase:
  4820. v, ok := value.(string)
  4821. if !ok {
  4822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4823. }
  4824. m.SetOpenaiBase(v)
  4825. return nil
  4826. case apikey.FieldOpenaiKey:
  4827. v, ok := value.(string)
  4828. if !ok {
  4829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4830. }
  4831. m.SetOpenaiKey(v)
  4832. return nil
  4833. }
  4834. return fmt.Errorf("unknown ApiKey field %s", name)
  4835. }
  4836. // AddedFields returns all numeric fields that were incremented/decremented during
  4837. // this mutation.
  4838. func (m *ApiKeyMutation) AddedFields() []string {
  4839. var fields []string
  4840. if m.addorganization_id != nil {
  4841. fields = append(fields, apikey.FieldOrganizationID)
  4842. }
  4843. return fields
  4844. }
  4845. // AddedField returns the numeric value that was incremented/decremented on a field
  4846. // with the given name. The second boolean return value indicates that this field
  4847. // was not set, or was not defined in the schema.
  4848. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4849. switch name {
  4850. case apikey.FieldOrganizationID:
  4851. return m.AddedOrganizationID()
  4852. }
  4853. return nil, false
  4854. }
  4855. // AddField adds the value to the field with the given name. It returns an error if
  4856. // the field is not defined in the schema, or if the type mismatched the field
  4857. // type.
  4858. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4859. switch name {
  4860. case apikey.FieldOrganizationID:
  4861. v, ok := value.(int64)
  4862. if !ok {
  4863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4864. }
  4865. m.AddOrganizationID(v)
  4866. return nil
  4867. }
  4868. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4869. }
  4870. // ClearedFields returns all nullable fields that were cleared during this
  4871. // mutation.
  4872. func (m *ApiKeyMutation) ClearedFields() []string {
  4873. var fields []string
  4874. if m.FieldCleared(apikey.FieldDeletedAt) {
  4875. fields = append(fields, apikey.FieldDeletedAt)
  4876. }
  4877. if m.FieldCleared(apikey.FieldTitle) {
  4878. fields = append(fields, apikey.FieldTitle)
  4879. }
  4880. if m.FieldCleared(apikey.FieldKey) {
  4881. fields = append(fields, apikey.FieldKey)
  4882. }
  4883. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4884. fields = append(fields, apikey.FieldCustomAgentBase)
  4885. }
  4886. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4887. fields = append(fields, apikey.FieldCustomAgentKey)
  4888. }
  4889. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4890. fields = append(fields, apikey.FieldOpenaiBase)
  4891. }
  4892. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4893. fields = append(fields, apikey.FieldOpenaiKey)
  4894. }
  4895. return fields
  4896. }
  4897. // FieldCleared returns a boolean indicating if a field with the given name was
  4898. // cleared in this mutation.
  4899. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4900. _, ok := m.clearedFields[name]
  4901. return ok
  4902. }
  4903. // ClearField clears the value of the field with the given name. It returns an
  4904. // error if the field is not defined in the schema.
  4905. func (m *ApiKeyMutation) ClearField(name string) error {
  4906. switch name {
  4907. case apikey.FieldDeletedAt:
  4908. m.ClearDeletedAt()
  4909. return nil
  4910. case apikey.FieldTitle:
  4911. m.ClearTitle()
  4912. return nil
  4913. case apikey.FieldKey:
  4914. m.ClearKey()
  4915. return nil
  4916. case apikey.FieldCustomAgentBase:
  4917. m.ClearCustomAgentBase()
  4918. return nil
  4919. case apikey.FieldCustomAgentKey:
  4920. m.ClearCustomAgentKey()
  4921. return nil
  4922. case apikey.FieldOpenaiBase:
  4923. m.ClearOpenaiBase()
  4924. return nil
  4925. case apikey.FieldOpenaiKey:
  4926. m.ClearOpenaiKey()
  4927. return nil
  4928. }
  4929. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  4930. }
  4931. // ResetField resets all changes in the mutation for the field with the given name.
  4932. // It returns an error if the field is not defined in the schema.
  4933. func (m *ApiKeyMutation) ResetField(name string) error {
  4934. switch name {
  4935. case apikey.FieldCreatedAt:
  4936. m.ResetCreatedAt()
  4937. return nil
  4938. case apikey.FieldUpdatedAt:
  4939. m.ResetUpdatedAt()
  4940. return nil
  4941. case apikey.FieldDeletedAt:
  4942. m.ResetDeletedAt()
  4943. return nil
  4944. case apikey.FieldTitle:
  4945. m.ResetTitle()
  4946. return nil
  4947. case apikey.FieldKey:
  4948. m.ResetKey()
  4949. return nil
  4950. case apikey.FieldOrganizationID:
  4951. m.ResetOrganizationID()
  4952. return nil
  4953. case apikey.FieldAgentID:
  4954. m.ResetAgentID()
  4955. return nil
  4956. case apikey.FieldCustomAgentBase:
  4957. m.ResetCustomAgentBase()
  4958. return nil
  4959. case apikey.FieldCustomAgentKey:
  4960. m.ResetCustomAgentKey()
  4961. return nil
  4962. case apikey.FieldOpenaiBase:
  4963. m.ResetOpenaiBase()
  4964. return nil
  4965. case apikey.FieldOpenaiKey:
  4966. m.ResetOpenaiKey()
  4967. return nil
  4968. }
  4969. return fmt.Errorf("unknown ApiKey field %s", name)
  4970. }
  4971. // AddedEdges returns all edge names that were set/added in this mutation.
  4972. func (m *ApiKeyMutation) AddedEdges() []string {
  4973. edges := make([]string, 0, 1)
  4974. if m.agent != nil {
  4975. edges = append(edges, apikey.EdgeAgent)
  4976. }
  4977. return edges
  4978. }
  4979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4980. // name in this mutation.
  4981. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  4982. switch name {
  4983. case apikey.EdgeAgent:
  4984. if id := m.agent; id != nil {
  4985. return []ent.Value{*id}
  4986. }
  4987. }
  4988. return nil
  4989. }
  4990. // RemovedEdges returns all edge names that were removed in this mutation.
  4991. func (m *ApiKeyMutation) RemovedEdges() []string {
  4992. edges := make([]string, 0, 1)
  4993. return edges
  4994. }
  4995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4996. // the given name in this mutation.
  4997. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  4998. return nil
  4999. }
  5000. // ClearedEdges returns all edge names that were cleared in this mutation.
  5001. func (m *ApiKeyMutation) ClearedEdges() []string {
  5002. edges := make([]string, 0, 1)
  5003. if m.clearedagent {
  5004. edges = append(edges, apikey.EdgeAgent)
  5005. }
  5006. return edges
  5007. }
  5008. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5009. // was cleared in this mutation.
  5010. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5011. switch name {
  5012. case apikey.EdgeAgent:
  5013. return m.clearedagent
  5014. }
  5015. return false
  5016. }
  5017. // ClearEdge clears the value of the edge with the given name. It returns an error
  5018. // if that edge is not defined in the schema.
  5019. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5020. switch name {
  5021. case apikey.EdgeAgent:
  5022. m.ClearAgent()
  5023. return nil
  5024. }
  5025. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5026. }
  5027. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5028. // It returns an error if the edge is not defined in the schema.
  5029. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5030. switch name {
  5031. case apikey.EdgeAgent:
  5032. m.ResetAgent()
  5033. return nil
  5034. }
  5035. return fmt.Errorf("unknown ApiKey edge %s", name)
  5036. }
  5037. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5038. type BatchMsgMutation struct {
  5039. config
  5040. op Op
  5041. typ string
  5042. id *uint64
  5043. created_at *time.Time
  5044. updated_at *time.Time
  5045. deleted_at *time.Time
  5046. status *uint8
  5047. addstatus *int8
  5048. batch_no *string
  5049. task_name *string
  5050. fromwxid *string
  5051. msg *string
  5052. tag *string
  5053. tagids *string
  5054. total *int32
  5055. addtotal *int32
  5056. success *int32
  5057. addsuccess *int32
  5058. fail *int32
  5059. addfail *int32
  5060. start_time *time.Time
  5061. stop_time *time.Time
  5062. send_time *time.Time
  5063. _type *int32
  5064. add_type *int32
  5065. organization_id *uint64
  5066. addorganization_id *int64
  5067. ctype *uint64
  5068. addctype *int64
  5069. cc *string
  5070. phone *string
  5071. template_name *string
  5072. template_code *string
  5073. lang *string
  5074. clearedFields map[string]struct{}
  5075. done bool
  5076. oldValue func(context.Context) (*BatchMsg, error)
  5077. predicates []predicate.BatchMsg
  5078. }
  5079. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5080. // batchmsgOption allows management of the mutation configuration using functional options.
  5081. type batchmsgOption func(*BatchMsgMutation)
  5082. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5083. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5084. m := &BatchMsgMutation{
  5085. config: c,
  5086. op: op,
  5087. typ: TypeBatchMsg,
  5088. clearedFields: make(map[string]struct{}),
  5089. }
  5090. for _, opt := range opts {
  5091. opt(m)
  5092. }
  5093. return m
  5094. }
  5095. // withBatchMsgID sets the ID field of the mutation.
  5096. func withBatchMsgID(id uint64) batchmsgOption {
  5097. return func(m *BatchMsgMutation) {
  5098. var (
  5099. err error
  5100. once sync.Once
  5101. value *BatchMsg
  5102. )
  5103. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5104. once.Do(func() {
  5105. if m.done {
  5106. err = errors.New("querying old values post mutation is not allowed")
  5107. } else {
  5108. value, err = m.Client().BatchMsg.Get(ctx, id)
  5109. }
  5110. })
  5111. return value, err
  5112. }
  5113. m.id = &id
  5114. }
  5115. }
  5116. // withBatchMsg sets the old BatchMsg of the mutation.
  5117. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5118. return func(m *BatchMsgMutation) {
  5119. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5120. return node, nil
  5121. }
  5122. m.id = &node.ID
  5123. }
  5124. }
  5125. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5126. // executed in a transaction (ent.Tx), a transactional client is returned.
  5127. func (m BatchMsgMutation) Client() *Client {
  5128. client := &Client{config: m.config}
  5129. client.init()
  5130. return client
  5131. }
  5132. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5133. // it returns an error otherwise.
  5134. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5135. if _, ok := m.driver.(*txDriver); !ok {
  5136. return nil, errors.New("ent: mutation is not running in a transaction")
  5137. }
  5138. tx := &Tx{config: m.config}
  5139. tx.init()
  5140. return tx, nil
  5141. }
  5142. // SetID sets the value of the id field. Note that this
  5143. // operation is only accepted on creation of BatchMsg entities.
  5144. func (m *BatchMsgMutation) SetID(id uint64) {
  5145. m.id = &id
  5146. }
  5147. // ID returns the ID value in the mutation. Note that the ID is only available
  5148. // if it was provided to the builder or after it was returned from the database.
  5149. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5150. if m.id == nil {
  5151. return
  5152. }
  5153. return *m.id, true
  5154. }
  5155. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5156. // That means, if the mutation is applied within a transaction with an isolation level such
  5157. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5158. // or updated by the mutation.
  5159. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5160. switch {
  5161. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5162. id, exists := m.ID()
  5163. if exists {
  5164. return []uint64{id}, nil
  5165. }
  5166. fallthrough
  5167. case m.op.Is(OpUpdate | OpDelete):
  5168. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5169. default:
  5170. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5171. }
  5172. }
  5173. // SetCreatedAt sets the "created_at" field.
  5174. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5175. m.created_at = &t
  5176. }
  5177. // CreatedAt returns the value of the "created_at" field in the mutation.
  5178. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5179. v := m.created_at
  5180. if v == nil {
  5181. return
  5182. }
  5183. return *v, true
  5184. }
  5185. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5186. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5188. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5189. if !m.op.Is(OpUpdateOne) {
  5190. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5191. }
  5192. if m.id == nil || m.oldValue == nil {
  5193. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5194. }
  5195. oldValue, err := m.oldValue(ctx)
  5196. if err != nil {
  5197. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5198. }
  5199. return oldValue.CreatedAt, nil
  5200. }
  5201. // ResetCreatedAt resets all changes to the "created_at" field.
  5202. func (m *BatchMsgMutation) ResetCreatedAt() {
  5203. m.created_at = nil
  5204. }
  5205. // SetUpdatedAt sets the "updated_at" field.
  5206. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5207. m.updated_at = &t
  5208. }
  5209. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5210. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5211. v := m.updated_at
  5212. if v == nil {
  5213. return
  5214. }
  5215. return *v, true
  5216. }
  5217. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5220. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5221. if !m.op.Is(OpUpdateOne) {
  5222. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5223. }
  5224. if m.id == nil || m.oldValue == nil {
  5225. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5226. }
  5227. oldValue, err := m.oldValue(ctx)
  5228. if err != nil {
  5229. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5230. }
  5231. return oldValue.UpdatedAt, nil
  5232. }
  5233. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5234. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5235. m.updated_at = nil
  5236. }
  5237. // SetDeletedAt sets the "deleted_at" field.
  5238. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5239. m.deleted_at = &t
  5240. }
  5241. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5242. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5243. v := m.deleted_at
  5244. if v == nil {
  5245. return
  5246. }
  5247. return *v, true
  5248. }
  5249. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5250. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5252. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5253. if !m.op.Is(OpUpdateOne) {
  5254. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5255. }
  5256. if m.id == nil || m.oldValue == nil {
  5257. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5258. }
  5259. oldValue, err := m.oldValue(ctx)
  5260. if err != nil {
  5261. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5262. }
  5263. return oldValue.DeletedAt, nil
  5264. }
  5265. // ClearDeletedAt clears the value of the "deleted_at" field.
  5266. func (m *BatchMsgMutation) ClearDeletedAt() {
  5267. m.deleted_at = nil
  5268. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5269. }
  5270. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5271. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5272. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5273. return ok
  5274. }
  5275. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5276. func (m *BatchMsgMutation) ResetDeletedAt() {
  5277. m.deleted_at = nil
  5278. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5279. }
  5280. // SetStatus sets the "status" field.
  5281. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5282. m.status = &u
  5283. m.addstatus = nil
  5284. }
  5285. // Status returns the value of the "status" field in the mutation.
  5286. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5287. v := m.status
  5288. if v == nil {
  5289. return
  5290. }
  5291. return *v, true
  5292. }
  5293. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5294. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5296. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5297. if !m.op.Is(OpUpdateOne) {
  5298. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5299. }
  5300. if m.id == nil || m.oldValue == nil {
  5301. return v, errors.New("OldStatus requires an ID field in the mutation")
  5302. }
  5303. oldValue, err := m.oldValue(ctx)
  5304. if err != nil {
  5305. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5306. }
  5307. return oldValue.Status, nil
  5308. }
  5309. // AddStatus adds u to the "status" field.
  5310. func (m *BatchMsgMutation) AddStatus(u int8) {
  5311. if m.addstatus != nil {
  5312. *m.addstatus += u
  5313. } else {
  5314. m.addstatus = &u
  5315. }
  5316. }
  5317. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5318. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5319. v := m.addstatus
  5320. if v == nil {
  5321. return
  5322. }
  5323. return *v, true
  5324. }
  5325. // ClearStatus clears the value of the "status" field.
  5326. func (m *BatchMsgMutation) ClearStatus() {
  5327. m.status = nil
  5328. m.addstatus = nil
  5329. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5330. }
  5331. // StatusCleared returns if the "status" field was cleared in this mutation.
  5332. func (m *BatchMsgMutation) StatusCleared() bool {
  5333. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5334. return ok
  5335. }
  5336. // ResetStatus resets all changes to the "status" field.
  5337. func (m *BatchMsgMutation) ResetStatus() {
  5338. m.status = nil
  5339. m.addstatus = nil
  5340. delete(m.clearedFields, batchmsg.FieldStatus)
  5341. }
  5342. // SetBatchNo sets the "batch_no" field.
  5343. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5344. m.batch_no = &s
  5345. }
  5346. // BatchNo returns the value of the "batch_no" field in the mutation.
  5347. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5348. v := m.batch_no
  5349. if v == nil {
  5350. return
  5351. }
  5352. return *v, true
  5353. }
  5354. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5357. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5358. if !m.op.Is(OpUpdateOne) {
  5359. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5360. }
  5361. if m.id == nil || m.oldValue == nil {
  5362. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5363. }
  5364. oldValue, err := m.oldValue(ctx)
  5365. if err != nil {
  5366. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5367. }
  5368. return oldValue.BatchNo, nil
  5369. }
  5370. // ClearBatchNo clears the value of the "batch_no" field.
  5371. func (m *BatchMsgMutation) ClearBatchNo() {
  5372. m.batch_no = nil
  5373. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5374. }
  5375. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5376. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5377. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5378. return ok
  5379. }
  5380. // ResetBatchNo resets all changes to the "batch_no" field.
  5381. func (m *BatchMsgMutation) ResetBatchNo() {
  5382. m.batch_no = nil
  5383. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5384. }
  5385. // SetTaskName sets the "task_name" field.
  5386. func (m *BatchMsgMutation) SetTaskName(s string) {
  5387. m.task_name = &s
  5388. }
  5389. // TaskName returns the value of the "task_name" field in the mutation.
  5390. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5391. v := m.task_name
  5392. if v == nil {
  5393. return
  5394. }
  5395. return *v, true
  5396. }
  5397. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5400. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5401. if !m.op.Is(OpUpdateOne) {
  5402. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5403. }
  5404. if m.id == nil || m.oldValue == nil {
  5405. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5406. }
  5407. oldValue, err := m.oldValue(ctx)
  5408. if err != nil {
  5409. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5410. }
  5411. return oldValue.TaskName, nil
  5412. }
  5413. // ClearTaskName clears the value of the "task_name" field.
  5414. func (m *BatchMsgMutation) ClearTaskName() {
  5415. m.task_name = nil
  5416. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5417. }
  5418. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5419. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5420. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5421. return ok
  5422. }
  5423. // ResetTaskName resets all changes to the "task_name" field.
  5424. func (m *BatchMsgMutation) ResetTaskName() {
  5425. m.task_name = nil
  5426. delete(m.clearedFields, batchmsg.FieldTaskName)
  5427. }
  5428. // SetFromwxid sets the "fromwxid" field.
  5429. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5430. m.fromwxid = &s
  5431. }
  5432. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5433. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5434. v := m.fromwxid
  5435. if v == nil {
  5436. return
  5437. }
  5438. return *v, true
  5439. }
  5440. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5443. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5444. if !m.op.Is(OpUpdateOne) {
  5445. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5446. }
  5447. if m.id == nil || m.oldValue == nil {
  5448. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5449. }
  5450. oldValue, err := m.oldValue(ctx)
  5451. if err != nil {
  5452. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5453. }
  5454. return oldValue.Fromwxid, nil
  5455. }
  5456. // ClearFromwxid clears the value of the "fromwxid" field.
  5457. func (m *BatchMsgMutation) ClearFromwxid() {
  5458. m.fromwxid = nil
  5459. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5460. }
  5461. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5462. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5463. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5464. return ok
  5465. }
  5466. // ResetFromwxid resets all changes to the "fromwxid" field.
  5467. func (m *BatchMsgMutation) ResetFromwxid() {
  5468. m.fromwxid = nil
  5469. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5470. }
  5471. // SetMsg sets the "msg" field.
  5472. func (m *BatchMsgMutation) SetMsg(s string) {
  5473. m.msg = &s
  5474. }
  5475. // Msg returns the value of the "msg" field in the mutation.
  5476. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5477. v := m.msg
  5478. if v == nil {
  5479. return
  5480. }
  5481. return *v, true
  5482. }
  5483. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5486. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5487. if !m.op.Is(OpUpdateOne) {
  5488. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5489. }
  5490. if m.id == nil || m.oldValue == nil {
  5491. return v, errors.New("OldMsg requires an ID field in the mutation")
  5492. }
  5493. oldValue, err := m.oldValue(ctx)
  5494. if err != nil {
  5495. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5496. }
  5497. return oldValue.Msg, nil
  5498. }
  5499. // ClearMsg clears the value of the "msg" field.
  5500. func (m *BatchMsgMutation) ClearMsg() {
  5501. m.msg = nil
  5502. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5503. }
  5504. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5505. func (m *BatchMsgMutation) MsgCleared() bool {
  5506. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5507. return ok
  5508. }
  5509. // ResetMsg resets all changes to the "msg" field.
  5510. func (m *BatchMsgMutation) ResetMsg() {
  5511. m.msg = nil
  5512. delete(m.clearedFields, batchmsg.FieldMsg)
  5513. }
  5514. // SetTag sets the "tag" field.
  5515. func (m *BatchMsgMutation) SetTag(s string) {
  5516. m.tag = &s
  5517. }
  5518. // Tag returns the value of the "tag" field in the mutation.
  5519. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5520. v := m.tag
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5527. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5529. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5530. if !m.op.Is(OpUpdateOne) {
  5531. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5532. }
  5533. if m.id == nil || m.oldValue == nil {
  5534. return v, errors.New("OldTag requires an ID field in the mutation")
  5535. }
  5536. oldValue, err := m.oldValue(ctx)
  5537. if err != nil {
  5538. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5539. }
  5540. return oldValue.Tag, nil
  5541. }
  5542. // ClearTag clears the value of the "tag" field.
  5543. func (m *BatchMsgMutation) ClearTag() {
  5544. m.tag = nil
  5545. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5546. }
  5547. // TagCleared returns if the "tag" field was cleared in this mutation.
  5548. func (m *BatchMsgMutation) TagCleared() bool {
  5549. _, ok := m.clearedFields[batchmsg.FieldTag]
  5550. return ok
  5551. }
  5552. // ResetTag resets all changes to the "tag" field.
  5553. func (m *BatchMsgMutation) ResetTag() {
  5554. m.tag = nil
  5555. delete(m.clearedFields, batchmsg.FieldTag)
  5556. }
  5557. // SetTagids sets the "tagids" field.
  5558. func (m *BatchMsgMutation) SetTagids(s string) {
  5559. m.tagids = &s
  5560. }
  5561. // Tagids returns the value of the "tagids" field in the mutation.
  5562. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5563. v := m.tagids
  5564. if v == nil {
  5565. return
  5566. }
  5567. return *v, true
  5568. }
  5569. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5570. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5572. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5573. if !m.op.Is(OpUpdateOne) {
  5574. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5575. }
  5576. if m.id == nil || m.oldValue == nil {
  5577. return v, errors.New("OldTagids requires an ID field in the mutation")
  5578. }
  5579. oldValue, err := m.oldValue(ctx)
  5580. if err != nil {
  5581. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5582. }
  5583. return oldValue.Tagids, nil
  5584. }
  5585. // ClearTagids clears the value of the "tagids" field.
  5586. func (m *BatchMsgMutation) ClearTagids() {
  5587. m.tagids = nil
  5588. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5589. }
  5590. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5591. func (m *BatchMsgMutation) TagidsCleared() bool {
  5592. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5593. return ok
  5594. }
  5595. // ResetTagids resets all changes to the "tagids" field.
  5596. func (m *BatchMsgMutation) ResetTagids() {
  5597. m.tagids = nil
  5598. delete(m.clearedFields, batchmsg.FieldTagids)
  5599. }
  5600. // SetTotal sets the "total" field.
  5601. func (m *BatchMsgMutation) SetTotal(i int32) {
  5602. m.total = &i
  5603. m.addtotal = nil
  5604. }
  5605. // Total returns the value of the "total" field in the mutation.
  5606. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5607. v := m.total
  5608. if v == nil {
  5609. return
  5610. }
  5611. return *v, true
  5612. }
  5613. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5614. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5616. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5617. if !m.op.Is(OpUpdateOne) {
  5618. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5619. }
  5620. if m.id == nil || m.oldValue == nil {
  5621. return v, errors.New("OldTotal requires an ID field in the mutation")
  5622. }
  5623. oldValue, err := m.oldValue(ctx)
  5624. if err != nil {
  5625. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5626. }
  5627. return oldValue.Total, nil
  5628. }
  5629. // AddTotal adds i to the "total" field.
  5630. func (m *BatchMsgMutation) AddTotal(i int32) {
  5631. if m.addtotal != nil {
  5632. *m.addtotal += i
  5633. } else {
  5634. m.addtotal = &i
  5635. }
  5636. }
  5637. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5638. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5639. v := m.addtotal
  5640. if v == nil {
  5641. return
  5642. }
  5643. return *v, true
  5644. }
  5645. // ClearTotal clears the value of the "total" field.
  5646. func (m *BatchMsgMutation) ClearTotal() {
  5647. m.total = nil
  5648. m.addtotal = nil
  5649. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5650. }
  5651. // TotalCleared returns if the "total" field was cleared in this mutation.
  5652. func (m *BatchMsgMutation) TotalCleared() bool {
  5653. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5654. return ok
  5655. }
  5656. // ResetTotal resets all changes to the "total" field.
  5657. func (m *BatchMsgMutation) ResetTotal() {
  5658. m.total = nil
  5659. m.addtotal = nil
  5660. delete(m.clearedFields, batchmsg.FieldTotal)
  5661. }
  5662. // SetSuccess sets the "success" field.
  5663. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5664. m.success = &i
  5665. m.addsuccess = nil
  5666. }
  5667. // Success returns the value of the "success" field in the mutation.
  5668. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5669. v := m.success
  5670. if v == nil {
  5671. return
  5672. }
  5673. return *v, true
  5674. }
  5675. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5678. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5679. if !m.op.Is(OpUpdateOne) {
  5680. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5681. }
  5682. if m.id == nil || m.oldValue == nil {
  5683. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5684. }
  5685. oldValue, err := m.oldValue(ctx)
  5686. if err != nil {
  5687. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5688. }
  5689. return oldValue.Success, nil
  5690. }
  5691. // AddSuccess adds i to the "success" field.
  5692. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5693. if m.addsuccess != nil {
  5694. *m.addsuccess += i
  5695. } else {
  5696. m.addsuccess = &i
  5697. }
  5698. }
  5699. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5700. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5701. v := m.addsuccess
  5702. if v == nil {
  5703. return
  5704. }
  5705. return *v, true
  5706. }
  5707. // ClearSuccess clears the value of the "success" field.
  5708. func (m *BatchMsgMutation) ClearSuccess() {
  5709. m.success = nil
  5710. m.addsuccess = nil
  5711. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5712. }
  5713. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5714. func (m *BatchMsgMutation) SuccessCleared() bool {
  5715. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5716. return ok
  5717. }
  5718. // ResetSuccess resets all changes to the "success" field.
  5719. func (m *BatchMsgMutation) ResetSuccess() {
  5720. m.success = nil
  5721. m.addsuccess = nil
  5722. delete(m.clearedFields, batchmsg.FieldSuccess)
  5723. }
  5724. // SetFail sets the "fail" field.
  5725. func (m *BatchMsgMutation) SetFail(i int32) {
  5726. m.fail = &i
  5727. m.addfail = nil
  5728. }
  5729. // Fail returns the value of the "fail" field in the mutation.
  5730. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5731. v := m.fail
  5732. if v == nil {
  5733. return
  5734. }
  5735. return *v, true
  5736. }
  5737. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5738. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5740. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5741. if !m.op.Is(OpUpdateOne) {
  5742. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5743. }
  5744. if m.id == nil || m.oldValue == nil {
  5745. return v, errors.New("OldFail requires an ID field in the mutation")
  5746. }
  5747. oldValue, err := m.oldValue(ctx)
  5748. if err != nil {
  5749. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5750. }
  5751. return oldValue.Fail, nil
  5752. }
  5753. // AddFail adds i to the "fail" field.
  5754. func (m *BatchMsgMutation) AddFail(i int32) {
  5755. if m.addfail != nil {
  5756. *m.addfail += i
  5757. } else {
  5758. m.addfail = &i
  5759. }
  5760. }
  5761. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5762. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5763. v := m.addfail
  5764. if v == nil {
  5765. return
  5766. }
  5767. return *v, true
  5768. }
  5769. // ClearFail clears the value of the "fail" field.
  5770. func (m *BatchMsgMutation) ClearFail() {
  5771. m.fail = nil
  5772. m.addfail = nil
  5773. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5774. }
  5775. // FailCleared returns if the "fail" field was cleared in this mutation.
  5776. func (m *BatchMsgMutation) FailCleared() bool {
  5777. _, ok := m.clearedFields[batchmsg.FieldFail]
  5778. return ok
  5779. }
  5780. // ResetFail resets all changes to the "fail" field.
  5781. func (m *BatchMsgMutation) ResetFail() {
  5782. m.fail = nil
  5783. m.addfail = nil
  5784. delete(m.clearedFields, batchmsg.FieldFail)
  5785. }
  5786. // SetStartTime sets the "start_time" field.
  5787. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5788. m.start_time = &t
  5789. }
  5790. // StartTime returns the value of the "start_time" field in the mutation.
  5791. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5792. v := m.start_time
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5801. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5807. }
  5808. oldValue, err := m.oldValue(ctx)
  5809. if err != nil {
  5810. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5811. }
  5812. return oldValue.StartTime, nil
  5813. }
  5814. // ClearStartTime clears the value of the "start_time" field.
  5815. func (m *BatchMsgMutation) ClearStartTime() {
  5816. m.start_time = nil
  5817. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5818. }
  5819. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5822. return ok
  5823. }
  5824. // ResetStartTime resets all changes to the "start_time" field.
  5825. func (m *BatchMsgMutation) ResetStartTime() {
  5826. m.start_time = nil
  5827. delete(m.clearedFields, batchmsg.FieldStartTime)
  5828. }
  5829. // SetStopTime sets the "stop_time" field.
  5830. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5831. m.stop_time = &t
  5832. }
  5833. // StopTime returns the value of the "stop_time" field in the mutation.
  5834. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5835. v := m.stop_time
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5842. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5854. }
  5855. return oldValue.StopTime, nil
  5856. }
  5857. // ClearStopTime clears the value of the "stop_time" field.
  5858. func (m *BatchMsgMutation) ClearStopTime() {
  5859. m.stop_time = nil
  5860. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5861. }
  5862. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5865. return ok
  5866. }
  5867. // ResetStopTime resets all changes to the "stop_time" field.
  5868. func (m *BatchMsgMutation) ResetStopTime() {
  5869. m.stop_time = nil
  5870. delete(m.clearedFields, batchmsg.FieldStopTime)
  5871. }
  5872. // SetSendTime sets the "send_time" field.
  5873. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5874. m.send_time = &t
  5875. }
  5876. // SendTime returns the value of the "send_time" field in the mutation.
  5877. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5878. v := m.send_time
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5885. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5887. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5893. }
  5894. oldValue, err := m.oldValue(ctx)
  5895. if err != nil {
  5896. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5897. }
  5898. return oldValue.SendTime, nil
  5899. }
  5900. // ClearSendTime clears the value of the "send_time" field.
  5901. func (m *BatchMsgMutation) ClearSendTime() {
  5902. m.send_time = nil
  5903. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5904. }
  5905. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5908. return ok
  5909. }
  5910. // ResetSendTime resets all changes to the "send_time" field.
  5911. func (m *BatchMsgMutation) ResetSendTime() {
  5912. m.send_time = nil
  5913. delete(m.clearedFields, batchmsg.FieldSendTime)
  5914. }
  5915. // SetType sets the "type" field.
  5916. func (m *BatchMsgMutation) SetType(i int32) {
  5917. m._type = &i
  5918. m.add_type = nil
  5919. }
  5920. // GetType returns the value of the "type" field in the mutation.
  5921. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5922. v := m._type
  5923. if v == nil {
  5924. return
  5925. }
  5926. return *v, true
  5927. }
  5928. // OldType returns the old "type" field's value of the BatchMsg entity.
  5929. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5931. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  5932. if !m.op.Is(OpUpdateOne) {
  5933. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5934. }
  5935. if m.id == nil || m.oldValue == nil {
  5936. return v, errors.New("OldType requires an ID field in the mutation")
  5937. }
  5938. oldValue, err := m.oldValue(ctx)
  5939. if err != nil {
  5940. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5941. }
  5942. return oldValue.Type, nil
  5943. }
  5944. // AddType adds i to the "type" field.
  5945. func (m *BatchMsgMutation) AddType(i int32) {
  5946. if m.add_type != nil {
  5947. *m.add_type += i
  5948. } else {
  5949. m.add_type = &i
  5950. }
  5951. }
  5952. // AddedType returns the value that was added to the "type" field in this mutation.
  5953. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  5954. v := m.add_type
  5955. if v == nil {
  5956. return
  5957. }
  5958. return *v, true
  5959. }
  5960. // ClearType clears the value of the "type" field.
  5961. func (m *BatchMsgMutation) ClearType() {
  5962. m._type = nil
  5963. m.add_type = nil
  5964. m.clearedFields[batchmsg.FieldType] = struct{}{}
  5965. }
  5966. // TypeCleared returns if the "type" field was cleared in this mutation.
  5967. func (m *BatchMsgMutation) TypeCleared() bool {
  5968. _, ok := m.clearedFields[batchmsg.FieldType]
  5969. return ok
  5970. }
  5971. // ResetType resets all changes to the "type" field.
  5972. func (m *BatchMsgMutation) ResetType() {
  5973. m._type = nil
  5974. m.add_type = nil
  5975. delete(m.clearedFields, batchmsg.FieldType)
  5976. }
  5977. // SetOrganizationID sets the "organization_id" field.
  5978. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  5979. m.organization_id = &u
  5980. m.addorganization_id = nil
  5981. }
  5982. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5983. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  5984. v := m.organization_id
  5985. if v == nil {
  5986. return
  5987. }
  5988. return *v, true
  5989. }
  5990. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  5991. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5993. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5994. if !m.op.Is(OpUpdateOne) {
  5995. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5996. }
  5997. if m.id == nil || m.oldValue == nil {
  5998. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5999. }
  6000. oldValue, err := m.oldValue(ctx)
  6001. if err != nil {
  6002. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6003. }
  6004. return oldValue.OrganizationID, nil
  6005. }
  6006. // AddOrganizationID adds u to the "organization_id" field.
  6007. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6008. if m.addorganization_id != nil {
  6009. *m.addorganization_id += u
  6010. } else {
  6011. m.addorganization_id = &u
  6012. }
  6013. }
  6014. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6015. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6016. v := m.addorganization_id
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // ResetOrganizationID resets all changes to the "organization_id" field.
  6023. func (m *BatchMsgMutation) ResetOrganizationID() {
  6024. m.organization_id = nil
  6025. m.addorganization_id = nil
  6026. }
  6027. // SetCtype sets the "ctype" field.
  6028. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6029. m.ctype = &u
  6030. m.addctype = nil
  6031. }
  6032. // Ctype returns the value of the "ctype" field in the mutation.
  6033. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6034. v := m.ctype
  6035. if v == nil {
  6036. return
  6037. }
  6038. return *v, true
  6039. }
  6040. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6041. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6043. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6044. if !m.op.Is(OpUpdateOne) {
  6045. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6046. }
  6047. if m.id == nil || m.oldValue == nil {
  6048. return v, errors.New("OldCtype requires an ID field in the mutation")
  6049. }
  6050. oldValue, err := m.oldValue(ctx)
  6051. if err != nil {
  6052. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6053. }
  6054. return oldValue.Ctype, nil
  6055. }
  6056. // AddCtype adds u to the "ctype" field.
  6057. func (m *BatchMsgMutation) AddCtype(u int64) {
  6058. if m.addctype != nil {
  6059. *m.addctype += u
  6060. } else {
  6061. m.addctype = &u
  6062. }
  6063. }
  6064. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6065. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6066. v := m.addctype
  6067. if v == nil {
  6068. return
  6069. }
  6070. return *v, true
  6071. }
  6072. // ResetCtype resets all changes to the "ctype" field.
  6073. func (m *BatchMsgMutation) ResetCtype() {
  6074. m.ctype = nil
  6075. m.addctype = nil
  6076. }
  6077. // SetCc sets the "cc" field.
  6078. func (m *BatchMsgMutation) SetCc(s string) {
  6079. m.cc = &s
  6080. }
  6081. // Cc returns the value of the "cc" field in the mutation.
  6082. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6083. v := m.cc
  6084. if v == nil {
  6085. return
  6086. }
  6087. return *v, true
  6088. }
  6089. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6090. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6092. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6093. if !m.op.Is(OpUpdateOne) {
  6094. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6095. }
  6096. if m.id == nil || m.oldValue == nil {
  6097. return v, errors.New("OldCc requires an ID field in the mutation")
  6098. }
  6099. oldValue, err := m.oldValue(ctx)
  6100. if err != nil {
  6101. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6102. }
  6103. return oldValue.Cc, nil
  6104. }
  6105. // ClearCc clears the value of the "cc" field.
  6106. func (m *BatchMsgMutation) ClearCc() {
  6107. m.cc = nil
  6108. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6109. }
  6110. // CcCleared returns if the "cc" field was cleared in this mutation.
  6111. func (m *BatchMsgMutation) CcCleared() bool {
  6112. _, ok := m.clearedFields[batchmsg.FieldCc]
  6113. return ok
  6114. }
  6115. // ResetCc resets all changes to the "cc" field.
  6116. func (m *BatchMsgMutation) ResetCc() {
  6117. m.cc = nil
  6118. delete(m.clearedFields, batchmsg.FieldCc)
  6119. }
  6120. // SetPhone sets the "phone" field.
  6121. func (m *BatchMsgMutation) SetPhone(s string) {
  6122. m.phone = &s
  6123. }
  6124. // Phone returns the value of the "phone" field in the mutation.
  6125. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6126. v := m.phone
  6127. if v == nil {
  6128. return
  6129. }
  6130. return *v, true
  6131. }
  6132. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6133. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6135. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6136. if !m.op.Is(OpUpdateOne) {
  6137. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6138. }
  6139. if m.id == nil || m.oldValue == nil {
  6140. return v, errors.New("OldPhone requires an ID field in the mutation")
  6141. }
  6142. oldValue, err := m.oldValue(ctx)
  6143. if err != nil {
  6144. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6145. }
  6146. return oldValue.Phone, nil
  6147. }
  6148. // ClearPhone clears the value of the "phone" field.
  6149. func (m *BatchMsgMutation) ClearPhone() {
  6150. m.phone = nil
  6151. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6152. }
  6153. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6154. func (m *BatchMsgMutation) PhoneCleared() bool {
  6155. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6156. return ok
  6157. }
  6158. // ResetPhone resets all changes to the "phone" field.
  6159. func (m *BatchMsgMutation) ResetPhone() {
  6160. m.phone = nil
  6161. delete(m.clearedFields, batchmsg.FieldPhone)
  6162. }
  6163. // SetTemplateName sets the "template_name" field.
  6164. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6165. m.template_name = &s
  6166. }
  6167. // TemplateName returns the value of the "template_name" field in the mutation.
  6168. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6169. v := m.template_name
  6170. if v == nil {
  6171. return
  6172. }
  6173. return *v, true
  6174. }
  6175. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6176. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6178. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6179. if !m.op.Is(OpUpdateOne) {
  6180. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6181. }
  6182. if m.id == nil || m.oldValue == nil {
  6183. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6184. }
  6185. oldValue, err := m.oldValue(ctx)
  6186. if err != nil {
  6187. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6188. }
  6189. return oldValue.TemplateName, nil
  6190. }
  6191. // ClearTemplateName clears the value of the "template_name" field.
  6192. func (m *BatchMsgMutation) ClearTemplateName() {
  6193. m.template_name = nil
  6194. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6195. }
  6196. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6197. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6198. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6199. return ok
  6200. }
  6201. // ResetTemplateName resets all changes to the "template_name" field.
  6202. func (m *BatchMsgMutation) ResetTemplateName() {
  6203. m.template_name = nil
  6204. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6205. }
  6206. // SetTemplateCode sets the "template_code" field.
  6207. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6208. m.template_code = &s
  6209. }
  6210. // TemplateCode returns the value of the "template_code" field in the mutation.
  6211. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6212. v := m.template_code
  6213. if v == nil {
  6214. return
  6215. }
  6216. return *v, true
  6217. }
  6218. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6221. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6222. if !m.op.Is(OpUpdateOne) {
  6223. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6224. }
  6225. if m.id == nil || m.oldValue == nil {
  6226. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6227. }
  6228. oldValue, err := m.oldValue(ctx)
  6229. if err != nil {
  6230. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6231. }
  6232. return oldValue.TemplateCode, nil
  6233. }
  6234. // ClearTemplateCode clears the value of the "template_code" field.
  6235. func (m *BatchMsgMutation) ClearTemplateCode() {
  6236. m.template_code = nil
  6237. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6238. }
  6239. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6240. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6241. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6242. return ok
  6243. }
  6244. // ResetTemplateCode resets all changes to the "template_code" field.
  6245. func (m *BatchMsgMutation) ResetTemplateCode() {
  6246. m.template_code = nil
  6247. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6248. }
  6249. // SetLang sets the "lang" field.
  6250. func (m *BatchMsgMutation) SetLang(s string) {
  6251. m.lang = &s
  6252. }
  6253. // Lang returns the value of the "lang" field in the mutation.
  6254. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6255. v := m.lang
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6262. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldLang requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6274. }
  6275. return oldValue.Lang, nil
  6276. }
  6277. // ClearLang clears the value of the "lang" field.
  6278. func (m *BatchMsgMutation) ClearLang() {
  6279. m.lang = nil
  6280. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6281. }
  6282. // LangCleared returns if the "lang" field was cleared in this mutation.
  6283. func (m *BatchMsgMutation) LangCleared() bool {
  6284. _, ok := m.clearedFields[batchmsg.FieldLang]
  6285. return ok
  6286. }
  6287. // ResetLang resets all changes to the "lang" field.
  6288. func (m *BatchMsgMutation) ResetLang() {
  6289. m.lang = nil
  6290. delete(m.clearedFields, batchmsg.FieldLang)
  6291. }
  6292. // Where appends a list predicates to the BatchMsgMutation builder.
  6293. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6294. m.predicates = append(m.predicates, ps...)
  6295. }
  6296. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6297. // users can use type-assertion to append predicates that do not depend on any generated package.
  6298. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6299. p := make([]predicate.BatchMsg, len(ps))
  6300. for i := range ps {
  6301. p[i] = ps[i]
  6302. }
  6303. m.Where(p...)
  6304. }
  6305. // Op returns the operation name.
  6306. func (m *BatchMsgMutation) Op() Op {
  6307. return m.op
  6308. }
  6309. // SetOp allows setting the mutation operation.
  6310. func (m *BatchMsgMutation) SetOp(op Op) {
  6311. m.op = op
  6312. }
  6313. // Type returns the node type of this mutation (BatchMsg).
  6314. func (m *BatchMsgMutation) Type() string {
  6315. return m.typ
  6316. }
  6317. // Fields returns all fields that were changed during this mutation. Note that in
  6318. // order to get all numeric fields that were incremented/decremented, call
  6319. // AddedFields().
  6320. func (m *BatchMsgMutation) Fields() []string {
  6321. fields := make([]string, 0, 24)
  6322. if m.created_at != nil {
  6323. fields = append(fields, batchmsg.FieldCreatedAt)
  6324. }
  6325. if m.updated_at != nil {
  6326. fields = append(fields, batchmsg.FieldUpdatedAt)
  6327. }
  6328. if m.deleted_at != nil {
  6329. fields = append(fields, batchmsg.FieldDeletedAt)
  6330. }
  6331. if m.status != nil {
  6332. fields = append(fields, batchmsg.FieldStatus)
  6333. }
  6334. if m.batch_no != nil {
  6335. fields = append(fields, batchmsg.FieldBatchNo)
  6336. }
  6337. if m.task_name != nil {
  6338. fields = append(fields, batchmsg.FieldTaskName)
  6339. }
  6340. if m.fromwxid != nil {
  6341. fields = append(fields, batchmsg.FieldFromwxid)
  6342. }
  6343. if m.msg != nil {
  6344. fields = append(fields, batchmsg.FieldMsg)
  6345. }
  6346. if m.tag != nil {
  6347. fields = append(fields, batchmsg.FieldTag)
  6348. }
  6349. if m.tagids != nil {
  6350. fields = append(fields, batchmsg.FieldTagids)
  6351. }
  6352. if m.total != nil {
  6353. fields = append(fields, batchmsg.FieldTotal)
  6354. }
  6355. if m.success != nil {
  6356. fields = append(fields, batchmsg.FieldSuccess)
  6357. }
  6358. if m.fail != nil {
  6359. fields = append(fields, batchmsg.FieldFail)
  6360. }
  6361. if m.start_time != nil {
  6362. fields = append(fields, batchmsg.FieldStartTime)
  6363. }
  6364. if m.stop_time != nil {
  6365. fields = append(fields, batchmsg.FieldStopTime)
  6366. }
  6367. if m.send_time != nil {
  6368. fields = append(fields, batchmsg.FieldSendTime)
  6369. }
  6370. if m._type != nil {
  6371. fields = append(fields, batchmsg.FieldType)
  6372. }
  6373. if m.organization_id != nil {
  6374. fields = append(fields, batchmsg.FieldOrganizationID)
  6375. }
  6376. if m.ctype != nil {
  6377. fields = append(fields, batchmsg.FieldCtype)
  6378. }
  6379. if m.cc != nil {
  6380. fields = append(fields, batchmsg.FieldCc)
  6381. }
  6382. if m.phone != nil {
  6383. fields = append(fields, batchmsg.FieldPhone)
  6384. }
  6385. if m.template_name != nil {
  6386. fields = append(fields, batchmsg.FieldTemplateName)
  6387. }
  6388. if m.template_code != nil {
  6389. fields = append(fields, batchmsg.FieldTemplateCode)
  6390. }
  6391. if m.lang != nil {
  6392. fields = append(fields, batchmsg.FieldLang)
  6393. }
  6394. return fields
  6395. }
  6396. // Field returns the value of a field with the given name. The second boolean
  6397. // return value indicates that this field was not set, or was not defined in the
  6398. // schema.
  6399. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6400. switch name {
  6401. case batchmsg.FieldCreatedAt:
  6402. return m.CreatedAt()
  6403. case batchmsg.FieldUpdatedAt:
  6404. return m.UpdatedAt()
  6405. case batchmsg.FieldDeletedAt:
  6406. return m.DeletedAt()
  6407. case batchmsg.FieldStatus:
  6408. return m.Status()
  6409. case batchmsg.FieldBatchNo:
  6410. return m.BatchNo()
  6411. case batchmsg.FieldTaskName:
  6412. return m.TaskName()
  6413. case batchmsg.FieldFromwxid:
  6414. return m.Fromwxid()
  6415. case batchmsg.FieldMsg:
  6416. return m.Msg()
  6417. case batchmsg.FieldTag:
  6418. return m.Tag()
  6419. case batchmsg.FieldTagids:
  6420. return m.Tagids()
  6421. case batchmsg.FieldTotal:
  6422. return m.Total()
  6423. case batchmsg.FieldSuccess:
  6424. return m.Success()
  6425. case batchmsg.FieldFail:
  6426. return m.Fail()
  6427. case batchmsg.FieldStartTime:
  6428. return m.StartTime()
  6429. case batchmsg.FieldStopTime:
  6430. return m.StopTime()
  6431. case batchmsg.FieldSendTime:
  6432. return m.SendTime()
  6433. case batchmsg.FieldType:
  6434. return m.GetType()
  6435. case batchmsg.FieldOrganizationID:
  6436. return m.OrganizationID()
  6437. case batchmsg.FieldCtype:
  6438. return m.Ctype()
  6439. case batchmsg.FieldCc:
  6440. return m.Cc()
  6441. case batchmsg.FieldPhone:
  6442. return m.Phone()
  6443. case batchmsg.FieldTemplateName:
  6444. return m.TemplateName()
  6445. case batchmsg.FieldTemplateCode:
  6446. return m.TemplateCode()
  6447. case batchmsg.FieldLang:
  6448. return m.Lang()
  6449. }
  6450. return nil, false
  6451. }
  6452. // OldField returns the old value of the field from the database. An error is
  6453. // returned if the mutation operation is not UpdateOne, or the query to the
  6454. // database failed.
  6455. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6456. switch name {
  6457. case batchmsg.FieldCreatedAt:
  6458. return m.OldCreatedAt(ctx)
  6459. case batchmsg.FieldUpdatedAt:
  6460. return m.OldUpdatedAt(ctx)
  6461. case batchmsg.FieldDeletedAt:
  6462. return m.OldDeletedAt(ctx)
  6463. case batchmsg.FieldStatus:
  6464. return m.OldStatus(ctx)
  6465. case batchmsg.FieldBatchNo:
  6466. return m.OldBatchNo(ctx)
  6467. case batchmsg.FieldTaskName:
  6468. return m.OldTaskName(ctx)
  6469. case batchmsg.FieldFromwxid:
  6470. return m.OldFromwxid(ctx)
  6471. case batchmsg.FieldMsg:
  6472. return m.OldMsg(ctx)
  6473. case batchmsg.FieldTag:
  6474. return m.OldTag(ctx)
  6475. case batchmsg.FieldTagids:
  6476. return m.OldTagids(ctx)
  6477. case batchmsg.FieldTotal:
  6478. return m.OldTotal(ctx)
  6479. case batchmsg.FieldSuccess:
  6480. return m.OldSuccess(ctx)
  6481. case batchmsg.FieldFail:
  6482. return m.OldFail(ctx)
  6483. case batchmsg.FieldStartTime:
  6484. return m.OldStartTime(ctx)
  6485. case batchmsg.FieldStopTime:
  6486. return m.OldStopTime(ctx)
  6487. case batchmsg.FieldSendTime:
  6488. return m.OldSendTime(ctx)
  6489. case batchmsg.FieldType:
  6490. return m.OldType(ctx)
  6491. case batchmsg.FieldOrganizationID:
  6492. return m.OldOrganizationID(ctx)
  6493. case batchmsg.FieldCtype:
  6494. return m.OldCtype(ctx)
  6495. case batchmsg.FieldCc:
  6496. return m.OldCc(ctx)
  6497. case batchmsg.FieldPhone:
  6498. return m.OldPhone(ctx)
  6499. case batchmsg.FieldTemplateName:
  6500. return m.OldTemplateName(ctx)
  6501. case batchmsg.FieldTemplateCode:
  6502. return m.OldTemplateCode(ctx)
  6503. case batchmsg.FieldLang:
  6504. return m.OldLang(ctx)
  6505. }
  6506. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6507. }
  6508. // SetField sets the value of a field with the given name. It returns an error if
  6509. // the field is not defined in the schema, or if the type mismatched the field
  6510. // type.
  6511. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6512. switch name {
  6513. case batchmsg.FieldCreatedAt:
  6514. v, ok := value.(time.Time)
  6515. if !ok {
  6516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6517. }
  6518. m.SetCreatedAt(v)
  6519. return nil
  6520. case batchmsg.FieldUpdatedAt:
  6521. v, ok := value.(time.Time)
  6522. if !ok {
  6523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6524. }
  6525. m.SetUpdatedAt(v)
  6526. return nil
  6527. case batchmsg.FieldDeletedAt:
  6528. v, ok := value.(time.Time)
  6529. if !ok {
  6530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6531. }
  6532. m.SetDeletedAt(v)
  6533. return nil
  6534. case batchmsg.FieldStatus:
  6535. v, ok := value.(uint8)
  6536. if !ok {
  6537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6538. }
  6539. m.SetStatus(v)
  6540. return nil
  6541. case batchmsg.FieldBatchNo:
  6542. v, ok := value.(string)
  6543. if !ok {
  6544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6545. }
  6546. m.SetBatchNo(v)
  6547. return nil
  6548. case batchmsg.FieldTaskName:
  6549. v, ok := value.(string)
  6550. if !ok {
  6551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6552. }
  6553. m.SetTaskName(v)
  6554. return nil
  6555. case batchmsg.FieldFromwxid:
  6556. v, ok := value.(string)
  6557. if !ok {
  6558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6559. }
  6560. m.SetFromwxid(v)
  6561. return nil
  6562. case batchmsg.FieldMsg:
  6563. v, ok := value.(string)
  6564. if !ok {
  6565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6566. }
  6567. m.SetMsg(v)
  6568. return nil
  6569. case batchmsg.FieldTag:
  6570. v, ok := value.(string)
  6571. if !ok {
  6572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6573. }
  6574. m.SetTag(v)
  6575. return nil
  6576. case batchmsg.FieldTagids:
  6577. v, ok := value.(string)
  6578. if !ok {
  6579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6580. }
  6581. m.SetTagids(v)
  6582. return nil
  6583. case batchmsg.FieldTotal:
  6584. v, ok := value.(int32)
  6585. if !ok {
  6586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6587. }
  6588. m.SetTotal(v)
  6589. return nil
  6590. case batchmsg.FieldSuccess:
  6591. v, ok := value.(int32)
  6592. if !ok {
  6593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6594. }
  6595. m.SetSuccess(v)
  6596. return nil
  6597. case batchmsg.FieldFail:
  6598. v, ok := value.(int32)
  6599. if !ok {
  6600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6601. }
  6602. m.SetFail(v)
  6603. return nil
  6604. case batchmsg.FieldStartTime:
  6605. v, ok := value.(time.Time)
  6606. if !ok {
  6607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6608. }
  6609. m.SetStartTime(v)
  6610. return nil
  6611. case batchmsg.FieldStopTime:
  6612. v, ok := value.(time.Time)
  6613. if !ok {
  6614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6615. }
  6616. m.SetStopTime(v)
  6617. return nil
  6618. case batchmsg.FieldSendTime:
  6619. v, ok := value.(time.Time)
  6620. if !ok {
  6621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6622. }
  6623. m.SetSendTime(v)
  6624. return nil
  6625. case batchmsg.FieldType:
  6626. v, ok := value.(int32)
  6627. if !ok {
  6628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6629. }
  6630. m.SetType(v)
  6631. return nil
  6632. case batchmsg.FieldOrganizationID:
  6633. v, ok := value.(uint64)
  6634. if !ok {
  6635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6636. }
  6637. m.SetOrganizationID(v)
  6638. return nil
  6639. case batchmsg.FieldCtype:
  6640. v, ok := value.(uint64)
  6641. if !ok {
  6642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6643. }
  6644. m.SetCtype(v)
  6645. return nil
  6646. case batchmsg.FieldCc:
  6647. v, ok := value.(string)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCc(v)
  6652. return nil
  6653. case batchmsg.FieldPhone:
  6654. v, ok := value.(string)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetPhone(v)
  6659. return nil
  6660. case batchmsg.FieldTemplateName:
  6661. v, ok := value.(string)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetTemplateName(v)
  6666. return nil
  6667. case batchmsg.FieldTemplateCode:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetTemplateCode(v)
  6673. return nil
  6674. case batchmsg.FieldLang:
  6675. v, ok := value.(string)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetLang(v)
  6680. return nil
  6681. }
  6682. return fmt.Errorf("unknown BatchMsg field %s", name)
  6683. }
  6684. // AddedFields returns all numeric fields that were incremented/decremented during
  6685. // this mutation.
  6686. func (m *BatchMsgMutation) AddedFields() []string {
  6687. var fields []string
  6688. if m.addstatus != nil {
  6689. fields = append(fields, batchmsg.FieldStatus)
  6690. }
  6691. if m.addtotal != nil {
  6692. fields = append(fields, batchmsg.FieldTotal)
  6693. }
  6694. if m.addsuccess != nil {
  6695. fields = append(fields, batchmsg.FieldSuccess)
  6696. }
  6697. if m.addfail != nil {
  6698. fields = append(fields, batchmsg.FieldFail)
  6699. }
  6700. if m.add_type != nil {
  6701. fields = append(fields, batchmsg.FieldType)
  6702. }
  6703. if m.addorganization_id != nil {
  6704. fields = append(fields, batchmsg.FieldOrganizationID)
  6705. }
  6706. if m.addctype != nil {
  6707. fields = append(fields, batchmsg.FieldCtype)
  6708. }
  6709. return fields
  6710. }
  6711. // AddedField returns the numeric value that was incremented/decremented on a field
  6712. // with the given name. The second boolean return value indicates that this field
  6713. // was not set, or was not defined in the schema.
  6714. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case batchmsg.FieldStatus:
  6717. return m.AddedStatus()
  6718. case batchmsg.FieldTotal:
  6719. return m.AddedTotal()
  6720. case batchmsg.FieldSuccess:
  6721. return m.AddedSuccess()
  6722. case batchmsg.FieldFail:
  6723. return m.AddedFail()
  6724. case batchmsg.FieldType:
  6725. return m.AddedType()
  6726. case batchmsg.FieldOrganizationID:
  6727. return m.AddedOrganizationID()
  6728. case batchmsg.FieldCtype:
  6729. return m.AddedCtype()
  6730. }
  6731. return nil, false
  6732. }
  6733. // AddField adds the value to the field with the given name. It returns an error if
  6734. // the field is not defined in the schema, or if the type mismatched the field
  6735. // type.
  6736. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6737. switch name {
  6738. case batchmsg.FieldStatus:
  6739. v, ok := value.(int8)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.AddStatus(v)
  6744. return nil
  6745. case batchmsg.FieldTotal:
  6746. v, ok := value.(int32)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.AddTotal(v)
  6751. return nil
  6752. case batchmsg.FieldSuccess:
  6753. v, ok := value.(int32)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.AddSuccess(v)
  6758. return nil
  6759. case batchmsg.FieldFail:
  6760. v, ok := value.(int32)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.AddFail(v)
  6765. return nil
  6766. case batchmsg.FieldType:
  6767. v, ok := value.(int32)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.AddType(v)
  6772. return nil
  6773. case batchmsg.FieldOrganizationID:
  6774. v, ok := value.(int64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.AddOrganizationID(v)
  6779. return nil
  6780. case batchmsg.FieldCtype:
  6781. v, ok := value.(int64)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.AddCtype(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6789. }
  6790. // ClearedFields returns all nullable fields that were cleared during this
  6791. // mutation.
  6792. func (m *BatchMsgMutation) ClearedFields() []string {
  6793. var fields []string
  6794. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6795. fields = append(fields, batchmsg.FieldDeletedAt)
  6796. }
  6797. if m.FieldCleared(batchmsg.FieldStatus) {
  6798. fields = append(fields, batchmsg.FieldStatus)
  6799. }
  6800. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6801. fields = append(fields, batchmsg.FieldBatchNo)
  6802. }
  6803. if m.FieldCleared(batchmsg.FieldTaskName) {
  6804. fields = append(fields, batchmsg.FieldTaskName)
  6805. }
  6806. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6807. fields = append(fields, batchmsg.FieldFromwxid)
  6808. }
  6809. if m.FieldCleared(batchmsg.FieldMsg) {
  6810. fields = append(fields, batchmsg.FieldMsg)
  6811. }
  6812. if m.FieldCleared(batchmsg.FieldTag) {
  6813. fields = append(fields, batchmsg.FieldTag)
  6814. }
  6815. if m.FieldCleared(batchmsg.FieldTagids) {
  6816. fields = append(fields, batchmsg.FieldTagids)
  6817. }
  6818. if m.FieldCleared(batchmsg.FieldTotal) {
  6819. fields = append(fields, batchmsg.FieldTotal)
  6820. }
  6821. if m.FieldCleared(batchmsg.FieldSuccess) {
  6822. fields = append(fields, batchmsg.FieldSuccess)
  6823. }
  6824. if m.FieldCleared(batchmsg.FieldFail) {
  6825. fields = append(fields, batchmsg.FieldFail)
  6826. }
  6827. if m.FieldCleared(batchmsg.FieldStartTime) {
  6828. fields = append(fields, batchmsg.FieldStartTime)
  6829. }
  6830. if m.FieldCleared(batchmsg.FieldStopTime) {
  6831. fields = append(fields, batchmsg.FieldStopTime)
  6832. }
  6833. if m.FieldCleared(batchmsg.FieldSendTime) {
  6834. fields = append(fields, batchmsg.FieldSendTime)
  6835. }
  6836. if m.FieldCleared(batchmsg.FieldType) {
  6837. fields = append(fields, batchmsg.FieldType)
  6838. }
  6839. if m.FieldCleared(batchmsg.FieldCc) {
  6840. fields = append(fields, batchmsg.FieldCc)
  6841. }
  6842. if m.FieldCleared(batchmsg.FieldPhone) {
  6843. fields = append(fields, batchmsg.FieldPhone)
  6844. }
  6845. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6846. fields = append(fields, batchmsg.FieldTemplateName)
  6847. }
  6848. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6849. fields = append(fields, batchmsg.FieldTemplateCode)
  6850. }
  6851. if m.FieldCleared(batchmsg.FieldLang) {
  6852. fields = append(fields, batchmsg.FieldLang)
  6853. }
  6854. return fields
  6855. }
  6856. // FieldCleared returns a boolean indicating if a field with the given name was
  6857. // cleared in this mutation.
  6858. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6859. _, ok := m.clearedFields[name]
  6860. return ok
  6861. }
  6862. // ClearField clears the value of the field with the given name. It returns an
  6863. // error if the field is not defined in the schema.
  6864. func (m *BatchMsgMutation) ClearField(name string) error {
  6865. switch name {
  6866. case batchmsg.FieldDeletedAt:
  6867. m.ClearDeletedAt()
  6868. return nil
  6869. case batchmsg.FieldStatus:
  6870. m.ClearStatus()
  6871. return nil
  6872. case batchmsg.FieldBatchNo:
  6873. m.ClearBatchNo()
  6874. return nil
  6875. case batchmsg.FieldTaskName:
  6876. m.ClearTaskName()
  6877. return nil
  6878. case batchmsg.FieldFromwxid:
  6879. m.ClearFromwxid()
  6880. return nil
  6881. case batchmsg.FieldMsg:
  6882. m.ClearMsg()
  6883. return nil
  6884. case batchmsg.FieldTag:
  6885. m.ClearTag()
  6886. return nil
  6887. case batchmsg.FieldTagids:
  6888. m.ClearTagids()
  6889. return nil
  6890. case batchmsg.FieldTotal:
  6891. m.ClearTotal()
  6892. return nil
  6893. case batchmsg.FieldSuccess:
  6894. m.ClearSuccess()
  6895. return nil
  6896. case batchmsg.FieldFail:
  6897. m.ClearFail()
  6898. return nil
  6899. case batchmsg.FieldStartTime:
  6900. m.ClearStartTime()
  6901. return nil
  6902. case batchmsg.FieldStopTime:
  6903. m.ClearStopTime()
  6904. return nil
  6905. case batchmsg.FieldSendTime:
  6906. m.ClearSendTime()
  6907. return nil
  6908. case batchmsg.FieldType:
  6909. m.ClearType()
  6910. return nil
  6911. case batchmsg.FieldCc:
  6912. m.ClearCc()
  6913. return nil
  6914. case batchmsg.FieldPhone:
  6915. m.ClearPhone()
  6916. return nil
  6917. case batchmsg.FieldTemplateName:
  6918. m.ClearTemplateName()
  6919. return nil
  6920. case batchmsg.FieldTemplateCode:
  6921. m.ClearTemplateCode()
  6922. return nil
  6923. case batchmsg.FieldLang:
  6924. m.ClearLang()
  6925. return nil
  6926. }
  6927. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  6928. }
  6929. // ResetField resets all changes in the mutation for the field with the given name.
  6930. // It returns an error if the field is not defined in the schema.
  6931. func (m *BatchMsgMutation) ResetField(name string) error {
  6932. switch name {
  6933. case batchmsg.FieldCreatedAt:
  6934. m.ResetCreatedAt()
  6935. return nil
  6936. case batchmsg.FieldUpdatedAt:
  6937. m.ResetUpdatedAt()
  6938. return nil
  6939. case batchmsg.FieldDeletedAt:
  6940. m.ResetDeletedAt()
  6941. return nil
  6942. case batchmsg.FieldStatus:
  6943. m.ResetStatus()
  6944. return nil
  6945. case batchmsg.FieldBatchNo:
  6946. m.ResetBatchNo()
  6947. return nil
  6948. case batchmsg.FieldTaskName:
  6949. m.ResetTaskName()
  6950. return nil
  6951. case batchmsg.FieldFromwxid:
  6952. m.ResetFromwxid()
  6953. return nil
  6954. case batchmsg.FieldMsg:
  6955. m.ResetMsg()
  6956. return nil
  6957. case batchmsg.FieldTag:
  6958. m.ResetTag()
  6959. return nil
  6960. case batchmsg.FieldTagids:
  6961. m.ResetTagids()
  6962. return nil
  6963. case batchmsg.FieldTotal:
  6964. m.ResetTotal()
  6965. return nil
  6966. case batchmsg.FieldSuccess:
  6967. m.ResetSuccess()
  6968. return nil
  6969. case batchmsg.FieldFail:
  6970. m.ResetFail()
  6971. return nil
  6972. case batchmsg.FieldStartTime:
  6973. m.ResetStartTime()
  6974. return nil
  6975. case batchmsg.FieldStopTime:
  6976. m.ResetStopTime()
  6977. return nil
  6978. case batchmsg.FieldSendTime:
  6979. m.ResetSendTime()
  6980. return nil
  6981. case batchmsg.FieldType:
  6982. m.ResetType()
  6983. return nil
  6984. case batchmsg.FieldOrganizationID:
  6985. m.ResetOrganizationID()
  6986. return nil
  6987. case batchmsg.FieldCtype:
  6988. m.ResetCtype()
  6989. return nil
  6990. case batchmsg.FieldCc:
  6991. m.ResetCc()
  6992. return nil
  6993. case batchmsg.FieldPhone:
  6994. m.ResetPhone()
  6995. return nil
  6996. case batchmsg.FieldTemplateName:
  6997. m.ResetTemplateName()
  6998. return nil
  6999. case batchmsg.FieldTemplateCode:
  7000. m.ResetTemplateCode()
  7001. return nil
  7002. case batchmsg.FieldLang:
  7003. m.ResetLang()
  7004. return nil
  7005. }
  7006. return fmt.Errorf("unknown BatchMsg field %s", name)
  7007. }
  7008. // AddedEdges returns all edge names that were set/added in this mutation.
  7009. func (m *BatchMsgMutation) AddedEdges() []string {
  7010. edges := make([]string, 0, 0)
  7011. return edges
  7012. }
  7013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7014. // name in this mutation.
  7015. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7016. return nil
  7017. }
  7018. // RemovedEdges returns all edge names that were removed in this mutation.
  7019. func (m *BatchMsgMutation) RemovedEdges() []string {
  7020. edges := make([]string, 0, 0)
  7021. return edges
  7022. }
  7023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7024. // the given name in this mutation.
  7025. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7026. return nil
  7027. }
  7028. // ClearedEdges returns all edge names that were cleared in this mutation.
  7029. func (m *BatchMsgMutation) ClearedEdges() []string {
  7030. edges := make([]string, 0, 0)
  7031. return edges
  7032. }
  7033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7034. // was cleared in this mutation.
  7035. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7036. return false
  7037. }
  7038. // ClearEdge clears the value of the edge with the given name. It returns an error
  7039. // if that edge is not defined in the schema.
  7040. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7041. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7042. }
  7043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7044. // It returns an error if the edge is not defined in the schema.
  7045. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7046. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7047. }
  7048. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7049. type CategoryMutation struct {
  7050. config
  7051. op Op
  7052. typ string
  7053. id *uint64
  7054. created_at *time.Time
  7055. updated_at *time.Time
  7056. deleted_at *time.Time
  7057. name *string
  7058. organization_id *uint64
  7059. addorganization_id *int64
  7060. clearedFields map[string]struct{}
  7061. done bool
  7062. oldValue func(context.Context) (*Category, error)
  7063. predicates []predicate.Category
  7064. }
  7065. var _ ent.Mutation = (*CategoryMutation)(nil)
  7066. // categoryOption allows management of the mutation configuration using functional options.
  7067. type categoryOption func(*CategoryMutation)
  7068. // newCategoryMutation creates new mutation for the Category entity.
  7069. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7070. m := &CategoryMutation{
  7071. config: c,
  7072. op: op,
  7073. typ: TypeCategory,
  7074. clearedFields: make(map[string]struct{}),
  7075. }
  7076. for _, opt := range opts {
  7077. opt(m)
  7078. }
  7079. return m
  7080. }
  7081. // withCategoryID sets the ID field of the mutation.
  7082. func withCategoryID(id uint64) categoryOption {
  7083. return func(m *CategoryMutation) {
  7084. var (
  7085. err error
  7086. once sync.Once
  7087. value *Category
  7088. )
  7089. m.oldValue = func(ctx context.Context) (*Category, error) {
  7090. once.Do(func() {
  7091. if m.done {
  7092. err = errors.New("querying old values post mutation is not allowed")
  7093. } else {
  7094. value, err = m.Client().Category.Get(ctx, id)
  7095. }
  7096. })
  7097. return value, err
  7098. }
  7099. m.id = &id
  7100. }
  7101. }
  7102. // withCategory sets the old Category of the mutation.
  7103. func withCategory(node *Category) categoryOption {
  7104. return func(m *CategoryMutation) {
  7105. m.oldValue = func(context.Context) (*Category, error) {
  7106. return node, nil
  7107. }
  7108. m.id = &node.ID
  7109. }
  7110. }
  7111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7112. // executed in a transaction (ent.Tx), a transactional client is returned.
  7113. func (m CategoryMutation) Client() *Client {
  7114. client := &Client{config: m.config}
  7115. client.init()
  7116. return client
  7117. }
  7118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7119. // it returns an error otherwise.
  7120. func (m CategoryMutation) Tx() (*Tx, error) {
  7121. if _, ok := m.driver.(*txDriver); !ok {
  7122. return nil, errors.New("ent: mutation is not running in a transaction")
  7123. }
  7124. tx := &Tx{config: m.config}
  7125. tx.init()
  7126. return tx, nil
  7127. }
  7128. // SetID sets the value of the id field. Note that this
  7129. // operation is only accepted on creation of Category entities.
  7130. func (m *CategoryMutation) SetID(id uint64) {
  7131. m.id = &id
  7132. }
  7133. // ID returns the ID value in the mutation. Note that the ID is only available
  7134. // if it was provided to the builder or after it was returned from the database.
  7135. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7136. if m.id == nil {
  7137. return
  7138. }
  7139. return *m.id, true
  7140. }
  7141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7142. // That means, if the mutation is applied within a transaction with an isolation level such
  7143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7144. // or updated by the mutation.
  7145. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7146. switch {
  7147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7148. id, exists := m.ID()
  7149. if exists {
  7150. return []uint64{id}, nil
  7151. }
  7152. fallthrough
  7153. case m.op.Is(OpUpdate | OpDelete):
  7154. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7155. default:
  7156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7157. }
  7158. }
  7159. // SetCreatedAt sets the "created_at" field.
  7160. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7161. m.created_at = &t
  7162. }
  7163. // CreatedAt returns the value of the "created_at" field in the mutation.
  7164. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7165. v := m.created_at
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7172. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7174. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7180. }
  7181. oldValue, err := m.oldValue(ctx)
  7182. if err != nil {
  7183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7184. }
  7185. return oldValue.CreatedAt, nil
  7186. }
  7187. // ResetCreatedAt resets all changes to the "created_at" field.
  7188. func (m *CategoryMutation) ResetCreatedAt() {
  7189. m.created_at = nil
  7190. }
  7191. // SetUpdatedAt sets the "updated_at" field.
  7192. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7193. m.updated_at = &t
  7194. }
  7195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7196. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7197. v := m.updated_at
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7204. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7206. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7207. if !m.op.Is(OpUpdateOne) {
  7208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7209. }
  7210. if m.id == nil || m.oldValue == nil {
  7211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7212. }
  7213. oldValue, err := m.oldValue(ctx)
  7214. if err != nil {
  7215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7216. }
  7217. return oldValue.UpdatedAt, nil
  7218. }
  7219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7220. func (m *CategoryMutation) ResetUpdatedAt() {
  7221. m.updated_at = nil
  7222. }
  7223. // SetDeletedAt sets the "deleted_at" field.
  7224. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7225. m.deleted_at = &t
  7226. }
  7227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7228. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7229. v := m.deleted_at
  7230. if v == nil {
  7231. return
  7232. }
  7233. return *v, true
  7234. }
  7235. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7236. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7238. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7239. if !m.op.Is(OpUpdateOne) {
  7240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7241. }
  7242. if m.id == nil || m.oldValue == nil {
  7243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7244. }
  7245. oldValue, err := m.oldValue(ctx)
  7246. if err != nil {
  7247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7248. }
  7249. return oldValue.DeletedAt, nil
  7250. }
  7251. // ClearDeletedAt clears the value of the "deleted_at" field.
  7252. func (m *CategoryMutation) ClearDeletedAt() {
  7253. m.deleted_at = nil
  7254. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7255. }
  7256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7257. func (m *CategoryMutation) DeletedAtCleared() bool {
  7258. _, ok := m.clearedFields[category.FieldDeletedAt]
  7259. return ok
  7260. }
  7261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7262. func (m *CategoryMutation) ResetDeletedAt() {
  7263. m.deleted_at = nil
  7264. delete(m.clearedFields, category.FieldDeletedAt)
  7265. }
  7266. // SetName sets the "name" field.
  7267. func (m *CategoryMutation) SetName(s string) {
  7268. m.name = &s
  7269. }
  7270. // Name returns the value of the "name" field in the mutation.
  7271. func (m *CategoryMutation) Name() (r string, exists bool) {
  7272. v := m.name
  7273. if v == nil {
  7274. return
  7275. }
  7276. return *v, true
  7277. }
  7278. // OldName returns the old "name" field's value of the Category entity.
  7279. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7281. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7282. if !m.op.Is(OpUpdateOne) {
  7283. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7284. }
  7285. if m.id == nil || m.oldValue == nil {
  7286. return v, errors.New("OldName requires an ID field in the mutation")
  7287. }
  7288. oldValue, err := m.oldValue(ctx)
  7289. if err != nil {
  7290. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7291. }
  7292. return oldValue.Name, nil
  7293. }
  7294. // ResetName resets all changes to the "name" field.
  7295. func (m *CategoryMutation) ResetName() {
  7296. m.name = nil
  7297. }
  7298. // SetOrganizationID sets the "organization_id" field.
  7299. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7300. m.organization_id = &u
  7301. m.addorganization_id = nil
  7302. }
  7303. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7304. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7305. v := m.organization_id
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7312. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7324. }
  7325. return oldValue.OrganizationID, nil
  7326. }
  7327. // AddOrganizationID adds u to the "organization_id" field.
  7328. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7329. if m.addorganization_id != nil {
  7330. *m.addorganization_id += u
  7331. } else {
  7332. m.addorganization_id = &u
  7333. }
  7334. }
  7335. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7336. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7337. v := m.addorganization_id
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // ResetOrganizationID resets all changes to the "organization_id" field.
  7344. func (m *CategoryMutation) ResetOrganizationID() {
  7345. m.organization_id = nil
  7346. m.addorganization_id = nil
  7347. }
  7348. // Where appends a list predicates to the CategoryMutation builder.
  7349. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7350. m.predicates = append(m.predicates, ps...)
  7351. }
  7352. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7353. // users can use type-assertion to append predicates that do not depend on any generated package.
  7354. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7355. p := make([]predicate.Category, len(ps))
  7356. for i := range ps {
  7357. p[i] = ps[i]
  7358. }
  7359. m.Where(p...)
  7360. }
  7361. // Op returns the operation name.
  7362. func (m *CategoryMutation) Op() Op {
  7363. return m.op
  7364. }
  7365. // SetOp allows setting the mutation operation.
  7366. func (m *CategoryMutation) SetOp(op Op) {
  7367. m.op = op
  7368. }
  7369. // Type returns the node type of this mutation (Category).
  7370. func (m *CategoryMutation) Type() string {
  7371. return m.typ
  7372. }
  7373. // Fields returns all fields that were changed during this mutation. Note that in
  7374. // order to get all numeric fields that were incremented/decremented, call
  7375. // AddedFields().
  7376. func (m *CategoryMutation) Fields() []string {
  7377. fields := make([]string, 0, 5)
  7378. if m.created_at != nil {
  7379. fields = append(fields, category.FieldCreatedAt)
  7380. }
  7381. if m.updated_at != nil {
  7382. fields = append(fields, category.FieldUpdatedAt)
  7383. }
  7384. if m.deleted_at != nil {
  7385. fields = append(fields, category.FieldDeletedAt)
  7386. }
  7387. if m.name != nil {
  7388. fields = append(fields, category.FieldName)
  7389. }
  7390. if m.organization_id != nil {
  7391. fields = append(fields, category.FieldOrganizationID)
  7392. }
  7393. return fields
  7394. }
  7395. // Field returns the value of a field with the given name. The second boolean
  7396. // return value indicates that this field was not set, or was not defined in the
  7397. // schema.
  7398. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7399. switch name {
  7400. case category.FieldCreatedAt:
  7401. return m.CreatedAt()
  7402. case category.FieldUpdatedAt:
  7403. return m.UpdatedAt()
  7404. case category.FieldDeletedAt:
  7405. return m.DeletedAt()
  7406. case category.FieldName:
  7407. return m.Name()
  7408. case category.FieldOrganizationID:
  7409. return m.OrganizationID()
  7410. }
  7411. return nil, false
  7412. }
  7413. // OldField returns the old value of the field from the database. An error is
  7414. // returned if the mutation operation is not UpdateOne, or the query to the
  7415. // database failed.
  7416. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7417. switch name {
  7418. case category.FieldCreatedAt:
  7419. return m.OldCreatedAt(ctx)
  7420. case category.FieldUpdatedAt:
  7421. return m.OldUpdatedAt(ctx)
  7422. case category.FieldDeletedAt:
  7423. return m.OldDeletedAt(ctx)
  7424. case category.FieldName:
  7425. return m.OldName(ctx)
  7426. case category.FieldOrganizationID:
  7427. return m.OldOrganizationID(ctx)
  7428. }
  7429. return nil, fmt.Errorf("unknown Category field %s", name)
  7430. }
  7431. // SetField sets the value of a field with the given name. It returns an error if
  7432. // the field is not defined in the schema, or if the type mismatched the field
  7433. // type.
  7434. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7435. switch name {
  7436. case category.FieldCreatedAt:
  7437. v, ok := value.(time.Time)
  7438. if !ok {
  7439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7440. }
  7441. m.SetCreatedAt(v)
  7442. return nil
  7443. case category.FieldUpdatedAt:
  7444. v, ok := value.(time.Time)
  7445. if !ok {
  7446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7447. }
  7448. m.SetUpdatedAt(v)
  7449. return nil
  7450. case category.FieldDeletedAt:
  7451. v, ok := value.(time.Time)
  7452. if !ok {
  7453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7454. }
  7455. m.SetDeletedAt(v)
  7456. return nil
  7457. case category.FieldName:
  7458. v, ok := value.(string)
  7459. if !ok {
  7460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7461. }
  7462. m.SetName(v)
  7463. return nil
  7464. case category.FieldOrganizationID:
  7465. v, ok := value.(uint64)
  7466. if !ok {
  7467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7468. }
  7469. m.SetOrganizationID(v)
  7470. return nil
  7471. }
  7472. return fmt.Errorf("unknown Category field %s", name)
  7473. }
  7474. // AddedFields returns all numeric fields that were incremented/decremented during
  7475. // this mutation.
  7476. func (m *CategoryMutation) AddedFields() []string {
  7477. var fields []string
  7478. if m.addorganization_id != nil {
  7479. fields = append(fields, category.FieldOrganizationID)
  7480. }
  7481. return fields
  7482. }
  7483. // AddedField returns the numeric value that was incremented/decremented on a field
  7484. // with the given name. The second boolean return value indicates that this field
  7485. // was not set, or was not defined in the schema.
  7486. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7487. switch name {
  7488. case category.FieldOrganizationID:
  7489. return m.AddedOrganizationID()
  7490. }
  7491. return nil, false
  7492. }
  7493. // AddField adds the value to the field with the given name. It returns an error if
  7494. // the field is not defined in the schema, or if the type mismatched the field
  7495. // type.
  7496. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7497. switch name {
  7498. case category.FieldOrganizationID:
  7499. v, ok := value.(int64)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.AddOrganizationID(v)
  7504. return nil
  7505. }
  7506. return fmt.Errorf("unknown Category numeric field %s", name)
  7507. }
  7508. // ClearedFields returns all nullable fields that were cleared during this
  7509. // mutation.
  7510. func (m *CategoryMutation) ClearedFields() []string {
  7511. var fields []string
  7512. if m.FieldCleared(category.FieldDeletedAt) {
  7513. fields = append(fields, category.FieldDeletedAt)
  7514. }
  7515. return fields
  7516. }
  7517. // FieldCleared returns a boolean indicating if a field with the given name was
  7518. // cleared in this mutation.
  7519. func (m *CategoryMutation) FieldCleared(name string) bool {
  7520. _, ok := m.clearedFields[name]
  7521. return ok
  7522. }
  7523. // ClearField clears the value of the field with the given name. It returns an
  7524. // error if the field is not defined in the schema.
  7525. func (m *CategoryMutation) ClearField(name string) error {
  7526. switch name {
  7527. case category.FieldDeletedAt:
  7528. m.ClearDeletedAt()
  7529. return nil
  7530. }
  7531. return fmt.Errorf("unknown Category nullable field %s", name)
  7532. }
  7533. // ResetField resets all changes in the mutation for the field with the given name.
  7534. // It returns an error if the field is not defined in the schema.
  7535. func (m *CategoryMutation) ResetField(name string) error {
  7536. switch name {
  7537. case category.FieldCreatedAt:
  7538. m.ResetCreatedAt()
  7539. return nil
  7540. case category.FieldUpdatedAt:
  7541. m.ResetUpdatedAt()
  7542. return nil
  7543. case category.FieldDeletedAt:
  7544. m.ResetDeletedAt()
  7545. return nil
  7546. case category.FieldName:
  7547. m.ResetName()
  7548. return nil
  7549. case category.FieldOrganizationID:
  7550. m.ResetOrganizationID()
  7551. return nil
  7552. }
  7553. return fmt.Errorf("unknown Category field %s", name)
  7554. }
  7555. // AddedEdges returns all edge names that were set/added in this mutation.
  7556. func (m *CategoryMutation) AddedEdges() []string {
  7557. edges := make([]string, 0, 0)
  7558. return edges
  7559. }
  7560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7561. // name in this mutation.
  7562. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7563. return nil
  7564. }
  7565. // RemovedEdges returns all edge names that were removed in this mutation.
  7566. func (m *CategoryMutation) RemovedEdges() []string {
  7567. edges := make([]string, 0, 0)
  7568. return edges
  7569. }
  7570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7571. // the given name in this mutation.
  7572. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7573. return nil
  7574. }
  7575. // ClearedEdges returns all edge names that were cleared in this mutation.
  7576. func (m *CategoryMutation) ClearedEdges() []string {
  7577. edges := make([]string, 0, 0)
  7578. return edges
  7579. }
  7580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7581. // was cleared in this mutation.
  7582. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7583. return false
  7584. }
  7585. // ClearEdge clears the value of the edge with the given name. It returns an error
  7586. // if that edge is not defined in the schema.
  7587. func (m *CategoryMutation) ClearEdge(name string) error {
  7588. return fmt.Errorf("unknown Category unique edge %s", name)
  7589. }
  7590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7591. // It returns an error if the edge is not defined in the schema.
  7592. func (m *CategoryMutation) ResetEdge(name string) error {
  7593. return fmt.Errorf("unknown Category edge %s", name)
  7594. }
  7595. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7596. type ChatRecordsMutation struct {
  7597. config
  7598. op Op
  7599. typ string
  7600. id *uint64
  7601. created_at *time.Time
  7602. updated_at *time.Time
  7603. deleted_at *time.Time
  7604. content *string
  7605. content_type *uint8
  7606. addcontent_type *int8
  7607. session_id *uint64
  7608. addsession_id *int64
  7609. user_id *uint64
  7610. adduser_id *int64
  7611. bot_id *uint64
  7612. addbot_id *int64
  7613. bot_type *uint8
  7614. addbot_type *int8
  7615. clearedFields map[string]struct{}
  7616. done bool
  7617. oldValue func(context.Context) (*ChatRecords, error)
  7618. predicates []predicate.ChatRecords
  7619. }
  7620. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7621. // chatrecordsOption allows management of the mutation configuration using functional options.
  7622. type chatrecordsOption func(*ChatRecordsMutation)
  7623. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7624. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7625. m := &ChatRecordsMutation{
  7626. config: c,
  7627. op: op,
  7628. typ: TypeChatRecords,
  7629. clearedFields: make(map[string]struct{}),
  7630. }
  7631. for _, opt := range opts {
  7632. opt(m)
  7633. }
  7634. return m
  7635. }
  7636. // withChatRecordsID sets the ID field of the mutation.
  7637. func withChatRecordsID(id uint64) chatrecordsOption {
  7638. return func(m *ChatRecordsMutation) {
  7639. var (
  7640. err error
  7641. once sync.Once
  7642. value *ChatRecords
  7643. )
  7644. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7645. once.Do(func() {
  7646. if m.done {
  7647. err = errors.New("querying old values post mutation is not allowed")
  7648. } else {
  7649. value, err = m.Client().ChatRecords.Get(ctx, id)
  7650. }
  7651. })
  7652. return value, err
  7653. }
  7654. m.id = &id
  7655. }
  7656. }
  7657. // withChatRecords sets the old ChatRecords of the mutation.
  7658. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7659. return func(m *ChatRecordsMutation) {
  7660. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7661. return node, nil
  7662. }
  7663. m.id = &node.ID
  7664. }
  7665. }
  7666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7667. // executed in a transaction (ent.Tx), a transactional client is returned.
  7668. func (m ChatRecordsMutation) Client() *Client {
  7669. client := &Client{config: m.config}
  7670. client.init()
  7671. return client
  7672. }
  7673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7674. // it returns an error otherwise.
  7675. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7676. if _, ok := m.driver.(*txDriver); !ok {
  7677. return nil, errors.New("ent: mutation is not running in a transaction")
  7678. }
  7679. tx := &Tx{config: m.config}
  7680. tx.init()
  7681. return tx, nil
  7682. }
  7683. // SetID sets the value of the id field. Note that this
  7684. // operation is only accepted on creation of ChatRecords entities.
  7685. func (m *ChatRecordsMutation) SetID(id uint64) {
  7686. m.id = &id
  7687. }
  7688. // ID returns the ID value in the mutation. Note that the ID is only available
  7689. // if it was provided to the builder or after it was returned from the database.
  7690. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7691. if m.id == nil {
  7692. return
  7693. }
  7694. return *m.id, true
  7695. }
  7696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7697. // That means, if the mutation is applied within a transaction with an isolation level such
  7698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7699. // or updated by the mutation.
  7700. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7701. switch {
  7702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7703. id, exists := m.ID()
  7704. if exists {
  7705. return []uint64{id}, nil
  7706. }
  7707. fallthrough
  7708. case m.op.Is(OpUpdate | OpDelete):
  7709. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7710. default:
  7711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7712. }
  7713. }
  7714. // SetCreatedAt sets the "created_at" field.
  7715. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7716. m.created_at = &t
  7717. }
  7718. // CreatedAt returns the value of the "created_at" field in the mutation.
  7719. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7720. v := m.created_at
  7721. if v == nil {
  7722. return
  7723. }
  7724. return *v, true
  7725. }
  7726. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7727. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7729. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7730. if !m.op.Is(OpUpdateOne) {
  7731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7732. }
  7733. if m.id == nil || m.oldValue == nil {
  7734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7735. }
  7736. oldValue, err := m.oldValue(ctx)
  7737. if err != nil {
  7738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7739. }
  7740. return oldValue.CreatedAt, nil
  7741. }
  7742. // ResetCreatedAt resets all changes to the "created_at" field.
  7743. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7744. m.created_at = nil
  7745. }
  7746. // SetUpdatedAt sets the "updated_at" field.
  7747. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7748. m.updated_at = &t
  7749. }
  7750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7751. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7752. v := m.updated_at
  7753. if v == nil {
  7754. return
  7755. }
  7756. return *v, true
  7757. }
  7758. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7759. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7761. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7762. if !m.op.Is(OpUpdateOne) {
  7763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7764. }
  7765. if m.id == nil || m.oldValue == nil {
  7766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7767. }
  7768. oldValue, err := m.oldValue(ctx)
  7769. if err != nil {
  7770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7771. }
  7772. return oldValue.UpdatedAt, nil
  7773. }
  7774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7775. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7776. m.updated_at = nil
  7777. }
  7778. // SetDeletedAt sets the "deleted_at" field.
  7779. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7780. m.deleted_at = &t
  7781. }
  7782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7783. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7784. v := m.deleted_at
  7785. if v == nil {
  7786. return
  7787. }
  7788. return *v, true
  7789. }
  7790. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7791. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7793. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7794. if !m.op.Is(OpUpdateOne) {
  7795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7796. }
  7797. if m.id == nil || m.oldValue == nil {
  7798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7799. }
  7800. oldValue, err := m.oldValue(ctx)
  7801. if err != nil {
  7802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7803. }
  7804. return oldValue.DeletedAt, nil
  7805. }
  7806. // ClearDeletedAt clears the value of the "deleted_at" field.
  7807. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7808. m.deleted_at = nil
  7809. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7810. }
  7811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7812. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7813. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7814. return ok
  7815. }
  7816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7817. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7818. m.deleted_at = nil
  7819. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7820. }
  7821. // SetContent sets the "content" field.
  7822. func (m *ChatRecordsMutation) SetContent(s string) {
  7823. m.content = &s
  7824. }
  7825. // Content returns the value of the "content" field in the mutation.
  7826. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7827. v := m.content
  7828. if v == nil {
  7829. return
  7830. }
  7831. return *v, true
  7832. }
  7833. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7834. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7836. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7837. if !m.op.Is(OpUpdateOne) {
  7838. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7839. }
  7840. if m.id == nil || m.oldValue == nil {
  7841. return v, errors.New("OldContent requires an ID field in the mutation")
  7842. }
  7843. oldValue, err := m.oldValue(ctx)
  7844. if err != nil {
  7845. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7846. }
  7847. return oldValue.Content, nil
  7848. }
  7849. // ResetContent resets all changes to the "content" field.
  7850. func (m *ChatRecordsMutation) ResetContent() {
  7851. m.content = nil
  7852. }
  7853. // SetContentType sets the "content_type" field.
  7854. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7855. m.content_type = &u
  7856. m.addcontent_type = nil
  7857. }
  7858. // ContentType returns the value of the "content_type" field in the mutation.
  7859. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7860. v := m.content_type
  7861. if v == nil {
  7862. return
  7863. }
  7864. return *v, true
  7865. }
  7866. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7867. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7869. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7870. if !m.op.Is(OpUpdateOne) {
  7871. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7872. }
  7873. if m.id == nil || m.oldValue == nil {
  7874. return v, errors.New("OldContentType requires an ID field in the mutation")
  7875. }
  7876. oldValue, err := m.oldValue(ctx)
  7877. if err != nil {
  7878. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7879. }
  7880. return oldValue.ContentType, nil
  7881. }
  7882. // AddContentType adds u to the "content_type" field.
  7883. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7884. if m.addcontent_type != nil {
  7885. *m.addcontent_type += u
  7886. } else {
  7887. m.addcontent_type = &u
  7888. }
  7889. }
  7890. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7891. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7892. v := m.addcontent_type
  7893. if v == nil {
  7894. return
  7895. }
  7896. return *v, true
  7897. }
  7898. // ResetContentType resets all changes to the "content_type" field.
  7899. func (m *ChatRecordsMutation) ResetContentType() {
  7900. m.content_type = nil
  7901. m.addcontent_type = nil
  7902. }
  7903. // SetSessionID sets the "session_id" field.
  7904. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7905. m.session_id = &u
  7906. m.addsession_id = nil
  7907. }
  7908. // SessionID returns the value of the "session_id" field in the mutation.
  7909. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7910. v := m.session_id
  7911. if v == nil {
  7912. return
  7913. }
  7914. return *v, true
  7915. }
  7916. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7917. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7919. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7920. if !m.op.Is(OpUpdateOne) {
  7921. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7922. }
  7923. if m.id == nil || m.oldValue == nil {
  7924. return v, errors.New("OldSessionID requires an ID field in the mutation")
  7925. }
  7926. oldValue, err := m.oldValue(ctx)
  7927. if err != nil {
  7928. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  7929. }
  7930. return oldValue.SessionID, nil
  7931. }
  7932. // AddSessionID adds u to the "session_id" field.
  7933. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  7934. if m.addsession_id != nil {
  7935. *m.addsession_id += u
  7936. } else {
  7937. m.addsession_id = &u
  7938. }
  7939. }
  7940. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  7941. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  7942. v := m.addsession_id
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // ResetSessionID resets all changes to the "session_id" field.
  7949. func (m *ChatRecordsMutation) ResetSessionID() {
  7950. m.session_id = nil
  7951. m.addsession_id = nil
  7952. }
  7953. // SetUserID sets the "user_id" field.
  7954. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  7955. m.user_id = &u
  7956. m.adduser_id = nil
  7957. }
  7958. // UserID returns the value of the "user_id" field in the mutation.
  7959. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  7960. v := m.user_id
  7961. if v == nil {
  7962. return
  7963. }
  7964. return *v, true
  7965. }
  7966. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  7967. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7969. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7970. if !m.op.Is(OpUpdateOne) {
  7971. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7972. }
  7973. if m.id == nil || m.oldValue == nil {
  7974. return v, errors.New("OldUserID requires an ID field in the mutation")
  7975. }
  7976. oldValue, err := m.oldValue(ctx)
  7977. if err != nil {
  7978. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7979. }
  7980. return oldValue.UserID, nil
  7981. }
  7982. // AddUserID adds u to the "user_id" field.
  7983. func (m *ChatRecordsMutation) AddUserID(u int64) {
  7984. if m.adduser_id != nil {
  7985. *m.adduser_id += u
  7986. } else {
  7987. m.adduser_id = &u
  7988. }
  7989. }
  7990. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7991. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  7992. v := m.adduser_id
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // ResetUserID resets all changes to the "user_id" field.
  7999. func (m *ChatRecordsMutation) ResetUserID() {
  8000. m.user_id = nil
  8001. m.adduser_id = nil
  8002. }
  8003. // SetBotID sets the "bot_id" field.
  8004. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8005. m.bot_id = &u
  8006. m.addbot_id = nil
  8007. }
  8008. // BotID returns the value of the "bot_id" field in the mutation.
  8009. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8010. v := m.bot_id
  8011. if v == nil {
  8012. return
  8013. }
  8014. return *v, true
  8015. }
  8016. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8017. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8019. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8020. if !m.op.Is(OpUpdateOne) {
  8021. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8022. }
  8023. if m.id == nil || m.oldValue == nil {
  8024. return v, errors.New("OldBotID requires an ID field in the mutation")
  8025. }
  8026. oldValue, err := m.oldValue(ctx)
  8027. if err != nil {
  8028. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8029. }
  8030. return oldValue.BotID, nil
  8031. }
  8032. // AddBotID adds u to the "bot_id" field.
  8033. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8034. if m.addbot_id != nil {
  8035. *m.addbot_id += u
  8036. } else {
  8037. m.addbot_id = &u
  8038. }
  8039. }
  8040. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8041. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8042. v := m.addbot_id
  8043. if v == nil {
  8044. return
  8045. }
  8046. return *v, true
  8047. }
  8048. // ResetBotID resets all changes to the "bot_id" field.
  8049. func (m *ChatRecordsMutation) ResetBotID() {
  8050. m.bot_id = nil
  8051. m.addbot_id = nil
  8052. }
  8053. // SetBotType sets the "bot_type" field.
  8054. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8055. m.bot_type = &u
  8056. m.addbot_type = nil
  8057. }
  8058. // BotType returns the value of the "bot_type" field in the mutation.
  8059. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8060. v := m.bot_type
  8061. if v == nil {
  8062. return
  8063. }
  8064. return *v, true
  8065. }
  8066. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8067. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8069. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8070. if !m.op.Is(OpUpdateOne) {
  8071. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8072. }
  8073. if m.id == nil || m.oldValue == nil {
  8074. return v, errors.New("OldBotType requires an ID field in the mutation")
  8075. }
  8076. oldValue, err := m.oldValue(ctx)
  8077. if err != nil {
  8078. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8079. }
  8080. return oldValue.BotType, nil
  8081. }
  8082. // AddBotType adds u to the "bot_type" field.
  8083. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8084. if m.addbot_type != nil {
  8085. *m.addbot_type += u
  8086. } else {
  8087. m.addbot_type = &u
  8088. }
  8089. }
  8090. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8091. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8092. v := m.addbot_type
  8093. if v == nil {
  8094. return
  8095. }
  8096. return *v, true
  8097. }
  8098. // ResetBotType resets all changes to the "bot_type" field.
  8099. func (m *ChatRecordsMutation) ResetBotType() {
  8100. m.bot_type = nil
  8101. m.addbot_type = nil
  8102. }
  8103. // Where appends a list predicates to the ChatRecordsMutation builder.
  8104. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8105. m.predicates = append(m.predicates, ps...)
  8106. }
  8107. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8108. // users can use type-assertion to append predicates that do not depend on any generated package.
  8109. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8110. p := make([]predicate.ChatRecords, len(ps))
  8111. for i := range ps {
  8112. p[i] = ps[i]
  8113. }
  8114. m.Where(p...)
  8115. }
  8116. // Op returns the operation name.
  8117. func (m *ChatRecordsMutation) Op() Op {
  8118. return m.op
  8119. }
  8120. // SetOp allows setting the mutation operation.
  8121. func (m *ChatRecordsMutation) SetOp(op Op) {
  8122. m.op = op
  8123. }
  8124. // Type returns the node type of this mutation (ChatRecords).
  8125. func (m *ChatRecordsMutation) Type() string {
  8126. return m.typ
  8127. }
  8128. // Fields returns all fields that were changed during this mutation. Note that in
  8129. // order to get all numeric fields that were incremented/decremented, call
  8130. // AddedFields().
  8131. func (m *ChatRecordsMutation) Fields() []string {
  8132. fields := make([]string, 0, 9)
  8133. if m.created_at != nil {
  8134. fields = append(fields, chatrecords.FieldCreatedAt)
  8135. }
  8136. if m.updated_at != nil {
  8137. fields = append(fields, chatrecords.FieldUpdatedAt)
  8138. }
  8139. if m.deleted_at != nil {
  8140. fields = append(fields, chatrecords.FieldDeletedAt)
  8141. }
  8142. if m.content != nil {
  8143. fields = append(fields, chatrecords.FieldContent)
  8144. }
  8145. if m.content_type != nil {
  8146. fields = append(fields, chatrecords.FieldContentType)
  8147. }
  8148. if m.session_id != nil {
  8149. fields = append(fields, chatrecords.FieldSessionID)
  8150. }
  8151. if m.user_id != nil {
  8152. fields = append(fields, chatrecords.FieldUserID)
  8153. }
  8154. if m.bot_id != nil {
  8155. fields = append(fields, chatrecords.FieldBotID)
  8156. }
  8157. if m.bot_type != nil {
  8158. fields = append(fields, chatrecords.FieldBotType)
  8159. }
  8160. return fields
  8161. }
  8162. // Field returns the value of a field with the given name. The second boolean
  8163. // return value indicates that this field was not set, or was not defined in the
  8164. // schema.
  8165. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8166. switch name {
  8167. case chatrecords.FieldCreatedAt:
  8168. return m.CreatedAt()
  8169. case chatrecords.FieldUpdatedAt:
  8170. return m.UpdatedAt()
  8171. case chatrecords.FieldDeletedAt:
  8172. return m.DeletedAt()
  8173. case chatrecords.FieldContent:
  8174. return m.Content()
  8175. case chatrecords.FieldContentType:
  8176. return m.ContentType()
  8177. case chatrecords.FieldSessionID:
  8178. return m.SessionID()
  8179. case chatrecords.FieldUserID:
  8180. return m.UserID()
  8181. case chatrecords.FieldBotID:
  8182. return m.BotID()
  8183. case chatrecords.FieldBotType:
  8184. return m.BotType()
  8185. }
  8186. return nil, false
  8187. }
  8188. // OldField returns the old value of the field from the database. An error is
  8189. // returned if the mutation operation is not UpdateOne, or the query to the
  8190. // database failed.
  8191. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8192. switch name {
  8193. case chatrecords.FieldCreatedAt:
  8194. return m.OldCreatedAt(ctx)
  8195. case chatrecords.FieldUpdatedAt:
  8196. return m.OldUpdatedAt(ctx)
  8197. case chatrecords.FieldDeletedAt:
  8198. return m.OldDeletedAt(ctx)
  8199. case chatrecords.FieldContent:
  8200. return m.OldContent(ctx)
  8201. case chatrecords.FieldContentType:
  8202. return m.OldContentType(ctx)
  8203. case chatrecords.FieldSessionID:
  8204. return m.OldSessionID(ctx)
  8205. case chatrecords.FieldUserID:
  8206. return m.OldUserID(ctx)
  8207. case chatrecords.FieldBotID:
  8208. return m.OldBotID(ctx)
  8209. case chatrecords.FieldBotType:
  8210. return m.OldBotType(ctx)
  8211. }
  8212. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8213. }
  8214. // SetField sets the value of a field with the given name. It returns an error if
  8215. // the field is not defined in the schema, or if the type mismatched the field
  8216. // type.
  8217. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8218. switch name {
  8219. case chatrecords.FieldCreatedAt:
  8220. v, ok := value.(time.Time)
  8221. if !ok {
  8222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8223. }
  8224. m.SetCreatedAt(v)
  8225. return nil
  8226. case chatrecords.FieldUpdatedAt:
  8227. v, ok := value.(time.Time)
  8228. if !ok {
  8229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8230. }
  8231. m.SetUpdatedAt(v)
  8232. return nil
  8233. case chatrecords.FieldDeletedAt:
  8234. v, ok := value.(time.Time)
  8235. if !ok {
  8236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8237. }
  8238. m.SetDeletedAt(v)
  8239. return nil
  8240. case chatrecords.FieldContent:
  8241. v, ok := value.(string)
  8242. if !ok {
  8243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8244. }
  8245. m.SetContent(v)
  8246. return nil
  8247. case chatrecords.FieldContentType:
  8248. v, ok := value.(uint8)
  8249. if !ok {
  8250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8251. }
  8252. m.SetContentType(v)
  8253. return nil
  8254. case chatrecords.FieldSessionID:
  8255. v, ok := value.(uint64)
  8256. if !ok {
  8257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8258. }
  8259. m.SetSessionID(v)
  8260. return nil
  8261. case chatrecords.FieldUserID:
  8262. v, ok := value.(uint64)
  8263. if !ok {
  8264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8265. }
  8266. m.SetUserID(v)
  8267. return nil
  8268. case chatrecords.FieldBotID:
  8269. v, ok := value.(uint64)
  8270. if !ok {
  8271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8272. }
  8273. m.SetBotID(v)
  8274. return nil
  8275. case chatrecords.FieldBotType:
  8276. v, ok := value.(uint8)
  8277. if !ok {
  8278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8279. }
  8280. m.SetBotType(v)
  8281. return nil
  8282. }
  8283. return fmt.Errorf("unknown ChatRecords field %s", name)
  8284. }
  8285. // AddedFields returns all numeric fields that were incremented/decremented during
  8286. // this mutation.
  8287. func (m *ChatRecordsMutation) AddedFields() []string {
  8288. var fields []string
  8289. if m.addcontent_type != nil {
  8290. fields = append(fields, chatrecords.FieldContentType)
  8291. }
  8292. if m.addsession_id != nil {
  8293. fields = append(fields, chatrecords.FieldSessionID)
  8294. }
  8295. if m.adduser_id != nil {
  8296. fields = append(fields, chatrecords.FieldUserID)
  8297. }
  8298. if m.addbot_id != nil {
  8299. fields = append(fields, chatrecords.FieldBotID)
  8300. }
  8301. if m.addbot_type != nil {
  8302. fields = append(fields, chatrecords.FieldBotType)
  8303. }
  8304. return fields
  8305. }
  8306. // AddedField returns the numeric value that was incremented/decremented on a field
  8307. // with the given name. The second boolean return value indicates that this field
  8308. // was not set, or was not defined in the schema.
  8309. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8310. switch name {
  8311. case chatrecords.FieldContentType:
  8312. return m.AddedContentType()
  8313. case chatrecords.FieldSessionID:
  8314. return m.AddedSessionID()
  8315. case chatrecords.FieldUserID:
  8316. return m.AddedUserID()
  8317. case chatrecords.FieldBotID:
  8318. return m.AddedBotID()
  8319. case chatrecords.FieldBotType:
  8320. return m.AddedBotType()
  8321. }
  8322. return nil, false
  8323. }
  8324. // AddField adds the value to the field with the given name. It returns an error if
  8325. // the field is not defined in the schema, or if the type mismatched the field
  8326. // type.
  8327. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8328. switch name {
  8329. case chatrecords.FieldContentType:
  8330. v, ok := value.(int8)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.AddContentType(v)
  8335. return nil
  8336. case chatrecords.FieldSessionID:
  8337. v, ok := value.(int64)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.AddSessionID(v)
  8342. return nil
  8343. case chatrecords.FieldUserID:
  8344. v, ok := value.(int64)
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.AddUserID(v)
  8349. return nil
  8350. case chatrecords.FieldBotID:
  8351. v, ok := value.(int64)
  8352. if !ok {
  8353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8354. }
  8355. m.AddBotID(v)
  8356. return nil
  8357. case chatrecords.FieldBotType:
  8358. v, ok := value.(int8)
  8359. if !ok {
  8360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8361. }
  8362. m.AddBotType(v)
  8363. return nil
  8364. }
  8365. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8366. }
  8367. // ClearedFields returns all nullable fields that were cleared during this
  8368. // mutation.
  8369. func (m *ChatRecordsMutation) ClearedFields() []string {
  8370. var fields []string
  8371. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8372. fields = append(fields, chatrecords.FieldDeletedAt)
  8373. }
  8374. return fields
  8375. }
  8376. // FieldCleared returns a boolean indicating if a field with the given name was
  8377. // cleared in this mutation.
  8378. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8379. _, ok := m.clearedFields[name]
  8380. return ok
  8381. }
  8382. // ClearField clears the value of the field with the given name. It returns an
  8383. // error if the field is not defined in the schema.
  8384. func (m *ChatRecordsMutation) ClearField(name string) error {
  8385. switch name {
  8386. case chatrecords.FieldDeletedAt:
  8387. m.ClearDeletedAt()
  8388. return nil
  8389. }
  8390. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8391. }
  8392. // ResetField resets all changes in the mutation for the field with the given name.
  8393. // It returns an error if the field is not defined in the schema.
  8394. func (m *ChatRecordsMutation) ResetField(name string) error {
  8395. switch name {
  8396. case chatrecords.FieldCreatedAt:
  8397. m.ResetCreatedAt()
  8398. return nil
  8399. case chatrecords.FieldUpdatedAt:
  8400. m.ResetUpdatedAt()
  8401. return nil
  8402. case chatrecords.FieldDeletedAt:
  8403. m.ResetDeletedAt()
  8404. return nil
  8405. case chatrecords.FieldContent:
  8406. m.ResetContent()
  8407. return nil
  8408. case chatrecords.FieldContentType:
  8409. m.ResetContentType()
  8410. return nil
  8411. case chatrecords.FieldSessionID:
  8412. m.ResetSessionID()
  8413. return nil
  8414. case chatrecords.FieldUserID:
  8415. m.ResetUserID()
  8416. return nil
  8417. case chatrecords.FieldBotID:
  8418. m.ResetBotID()
  8419. return nil
  8420. case chatrecords.FieldBotType:
  8421. m.ResetBotType()
  8422. return nil
  8423. }
  8424. return fmt.Errorf("unknown ChatRecords field %s", name)
  8425. }
  8426. // AddedEdges returns all edge names that were set/added in this mutation.
  8427. func (m *ChatRecordsMutation) AddedEdges() []string {
  8428. edges := make([]string, 0, 0)
  8429. return edges
  8430. }
  8431. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8432. // name in this mutation.
  8433. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8434. return nil
  8435. }
  8436. // RemovedEdges returns all edge names that were removed in this mutation.
  8437. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8438. edges := make([]string, 0, 0)
  8439. return edges
  8440. }
  8441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8442. // the given name in this mutation.
  8443. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8444. return nil
  8445. }
  8446. // ClearedEdges returns all edge names that were cleared in this mutation.
  8447. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8448. edges := make([]string, 0, 0)
  8449. return edges
  8450. }
  8451. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8452. // was cleared in this mutation.
  8453. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8454. return false
  8455. }
  8456. // ClearEdge clears the value of the edge with the given name. It returns an error
  8457. // if that edge is not defined in the schema.
  8458. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8459. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8460. }
  8461. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8462. // It returns an error if the edge is not defined in the schema.
  8463. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8464. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8465. }
  8466. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8467. type ChatSessionMutation struct {
  8468. config
  8469. op Op
  8470. typ string
  8471. id *uint64
  8472. created_at *time.Time
  8473. updated_at *time.Time
  8474. deleted_at *time.Time
  8475. name *string
  8476. user_id *uint64
  8477. adduser_id *int64
  8478. bot_id *uint64
  8479. addbot_id *int64
  8480. bot_type *uint8
  8481. addbot_type *int8
  8482. clearedFields map[string]struct{}
  8483. done bool
  8484. oldValue func(context.Context) (*ChatSession, error)
  8485. predicates []predicate.ChatSession
  8486. }
  8487. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8488. // chatsessionOption allows management of the mutation configuration using functional options.
  8489. type chatsessionOption func(*ChatSessionMutation)
  8490. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8491. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8492. m := &ChatSessionMutation{
  8493. config: c,
  8494. op: op,
  8495. typ: TypeChatSession,
  8496. clearedFields: make(map[string]struct{}),
  8497. }
  8498. for _, opt := range opts {
  8499. opt(m)
  8500. }
  8501. return m
  8502. }
  8503. // withChatSessionID sets the ID field of the mutation.
  8504. func withChatSessionID(id uint64) chatsessionOption {
  8505. return func(m *ChatSessionMutation) {
  8506. var (
  8507. err error
  8508. once sync.Once
  8509. value *ChatSession
  8510. )
  8511. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8512. once.Do(func() {
  8513. if m.done {
  8514. err = errors.New("querying old values post mutation is not allowed")
  8515. } else {
  8516. value, err = m.Client().ChatSession.Get(ctx, id)
  8517. }
  8518. })
  8519. return value, err
  8520. }
  8521. m.id = &id
  8522. }
  8523. }
  8524. // withChatSession sets the old ChatSession of the mutation.
  8525. func withChatSession(node *ChatSession) chatsessionOption {
  8526. return func(m *ChatSessionMutation) {
  8527. m.oldValue = func(context.Context) (*ChatSession, error) {
  8528. return node, nil
  8529. }
  8530. m.id = &node.ID
  8531. }
  8532. }
  8533. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8534. // executed in a transaction (ent.Tx), a transactional client is returned.
  8535. func (m ChatSessionMutation) Client() *Client {
  8536. client := &Client{config: m.config}
  8537. client.init()
  8538. return client
  8539. }
  8540. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8541. // it returns an error otherwise.
  8542. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8543. if _, ok := m.driver.(*txDriver); !ok {
  8544. return nil, errors.New("ent: mutation is not running in a transaction")
  8545. }
  8546. tx := &Tx{config: m.config}
  8547. tx.init()
  8548. return tx, nil
  8549. }
  8550. // SetID sets the value of the id field. Note that this
  8551. // operation is only accepted on creation of ChatSession entities.
  8552. func (m *ChatSessionMutation) SetID(id uint64) {
  8553. m.id = &id
  8554. }
  8555. // ID returns the ID value in the mutation. Note that the ID is only available
  8556. // if it was provided to the builder or after it was returned from the database.
  8557. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8558. if m.id == nil {
  8559. return
  8560. }
  8561. return *m.id, true
  8562. }
  8563. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8564. // That means, if the mutation is applied within a transaction with an isolation level such
  8565. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8566. // or updated by the mutation.
  8567. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8568. switch {
  8569. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8570. id, exists := m.ID()
  8571. if exists {
  8572. return []uint64{id}, nil
  8573. }
  8574. fallthrough
  8575. case m.op.Is(OpUpdate | OpDelete):
  8576. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8577. default:
  8578. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8579. }
  8580. }
  8581. // SetCreatedAt sets the "created_at" field.
  8582. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8583. m.created_at = &t
  8584. }
  8585. // CreatedAt returns the value of the "created_at" field in the mutation.
  8586. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8587. v := m.created_at
  8588. if v == nil {
  8589. return
  8590. }
  8591. return *v, true
  8592. }
  8593. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8594. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8596. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8597. if !m.op.Is(OpUpdateOne) {
  8598. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8599. }
  8600. if m.id == nil || m.oldValue == nil {
  8601. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8602. }
  8603. oldValue, err := m.oldValue(ctx)
  8604. if err != nil {
  8605. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8606. }
  8607. return oldValue.CreatedAt, nil
  8608. }
  8609. // ResetCreatedAt resets all changes to the "created_at" field.
  8610. func (m *ChatSessionMutation) ResetCreatedAt() {
  8611. m.created_at = nil
  8612. }
  8613. // SetUpdatedAt sets the "updated_at" field.
  8614. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8615. m.updated_at = &t
  8616. }
  8617. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8618. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8619. v := m.updated_at
  8620. if v == nil {
  8621. return
  8622. }
  8623. return *v, true
  8624. }
  8625. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8626. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8628. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8629. if !m.op.Is(OpUpdateOne) {
  8630. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8631. }
  8632. if m.id == nil || m.oldValue == nil {
  8633. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8634. }
  8635. oldValue, err := m.oldValue(ctx)
  8636. if err != nil {
  8637. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8638. }
  8639. return oldValue.UpdatedAt, nil
  8640. }
  8641. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8642. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8643. m.updated_at = nil
  8644. }
  8645. // SetDeletedAt sets the "deleted_at" field.
  8646. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8647. m.deleted_at = &t
  8648. }
  8649. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8650. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8651. v := m.deleted_at
  8652. if v == nil {
  8653. return
  8654. }
  8655. return *v, true
  8656. }
  8657. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8658. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8660. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8661. if !m.op.Is(OpUpdateOne) {
  8662. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8663. }
  8664. if m.id == nil || m.oldValue == nil {
  8665. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8666. }
  8667. oldValue, err := m.oldValue(ctx)
  8668. if err != nil {
  8669. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8670. }
  8671. return oldValue.DeletedAt, nil
  8672. }
  8673. // ClearDeletedAt clears the value of the "deleted_at" field.
  8674. func (m *ChatSessionMutation) ClearDeletedAt() {
  8675. m.deleted_at = nil
  8676. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8677. }
  8678. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8679. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8680. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8681. return ok
  8682. }
  8683. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8684. func (m *ChatSessionMutation) ResetDeletedAt() {
  8685. m.deleted_at = nil
  8686. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8687. }
  8688. // SetName sets the "name" field.
  8689. func (m *ChatSessionMutation) SetName(s string) {
  8690. m.name = &s
  8691. }
  8692. // Name returns the value of the "name" field in the mutation.
  8693. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8694. v := m.name
  8695. if v == nil {
  8696. return
  8697. }
  8698. return *v, true
  8699. }
  8700. // OldName returns the old "name" field's value of the ChatSession entity.
  8701. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8703. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8704. if !m.op.Is(OpUpdateOne) {
  8705. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8706. }
  8707. if m.id == nil || m.oldValue == nil {
  8708. return v, errors.New("OldName requires an ID field in the mutation")
  8709. }
  8710. oldValue, err := m.oldValue(ctx)
  8711. if err != nil {
  8712. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8713. }
  8714. return oldValue.Name, nil
  8715. }
  8716. // ResetName resets all changes to the "name" field.
  8717. func (m *ChatSessionMutation) ResetName() {
  8718. m.name = nil
  8719. }
  8720. // SetUserID sets the "user_id" field.
  8721. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8722. m.user_id = &u
  8723. m.adduser_id = nil
  8724. }
  8725. // UserID returns the value of the "user_id" field in the mutation.
  8726. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8727. v := m.user_id
  8728. if v == nil {
  8729. return
  8730. }
  8731. return *v, true
  8732. }
  8733. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8734. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8736. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8737. if !m.op.Is(OpUpdateOne) {
  8738. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8739. }
  8740. if m.id == nil || m.oldValue == nil {
  8741. return v, errors.New("OldUserID requires an ID field in the mutation")
  8742. }
  8743. oldValue, err := m.oldValue(ctx)
  8744. if err != nil {
  8745. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8746. }
  8747. return oldValue.UserID, nil
  8748. }
  8749. // AddUserID adds u to the "user_id" field.
  8750. func (m *ChatSessionMutation) AddUserID(u int64) {
  8751. if m.adduser_id != nil {
  8752. *m.adduser_id += u
  8753. } else {
  8754. m.adduser_id = &u
  8755. }
  8756. }
  8757. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8758. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8759. v := m.adduser_id
  8760. if v == nil {
  8761. return
  8762. }
  8763. return *v, true
  8764. }
  8765. // ResetUserID resets all changes to the "user_id" field.
  8766. func (m *ChatSessionMutation) ResetUserID() {
  8767. m.user_id = nil
  8768. m.adduser_id = nil
  8769. }
  8770. // SetBotID sets the "bot_id" field.
  8771. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8772. m.bot_id = &u
  8773. m.addbot_id = nil
  8774. }
  8775. // BotID returns the value of the "bot_id" field in the mutation.
  8776. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8777. v := m.bot_id
  8778. if v == nil {
  8779. return
  8780. }
  8781. return *v, true
  8782. }
  8783. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8784. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8786. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8787. if !m.op.Is(OpUpdateOne) {
  8788. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8789. }
  8790. if m.id == nil || m.oldValue == nil {
  8791. return v, errors.New("OldBotID requires an ID field in the mutation")
  8792. }
  8793. oldValue, err := m.oldValue(ctx)
  8794. if err != nil {
  8795. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8796. }
  8797. return oldValue.BotID, nil
  8798. }
  8799. // AddBotID adds u to the "bot_id" field.
  8800. func (m *ChatSessionMutation) AddBotID(u int64) {
  8801. if m.addbot_id != nil {
  8802. *m.addbot_id += u
  8803. } else {
  8804. m.addbot_id = &u
  8805. }
  8806. }
  8807. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8808. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8809. v := m.addbot_id
  8810. if v == nil {
  8811. return
  8812. }
  8813. return *v, true
  8814. }
  8815. // ResetBotID resets all changes to the "bot_id" field.
  8816. func (m *ChatSessionMutation) ResetBotID() {
  8817. m.bot_id = nil
  8818. m.addbot_id = nil
  8819. }
  8820. // SetBotType sets the "bot_type" field.
  8821. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8822. m.bot_type = &u
  8823. m.addbot_type = nil
  8824. }
  8825. // BotType returns the value of the "bot_type" field in the mutation.
  8826. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8827. v := m.bot_type
  8828. if v == nil {
  8829. return
  8830. }
  8831. return *v, true
  8832. }
  8833. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8834. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8836. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8837. if !m.op.Is(OpUpdateOne) {
  8838. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8839. }
  8840. if m.id == nil || m.oldValue == nil {
  8841. return v, errors.New("OldBotType requires an ID field in the mutation")
  8842. }
  8843. oldValue, err := m.oldValue(ctx)
  8844. if err != nil {
  8845. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8846. }
  8847. return oldValue.BotType, nil
  8848. }
  8849. // AddBotType adds u to the "bot_type" field.
  8850. func (m *ChatSessionMutation) AddBotType(u int8) {
  8851. if m.addbot_type != nil {
  8852. *m.addbot_type += u
  8853. } else {
  8854. m.addbot_type = &u
  8855. }
  8856. }
  8857. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8858. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8859. v := m.addbot_type
  8860. if v == nil {
  8861. return
  8862. }
  8863. return *v, true
  8864. }
  8865. // ResetBotType resets all changes to the "bot_type" field.
  8866. func (m *ChatSessionMutation) ResetBotType() {
  8867. m.bot_type = nil
  8868. m.addbot_type = nil
  8869. }
  8870. // Where appends a list predicates to the ChatSessionMutation builder.
  8871. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8872. m.predicates = append(m.predicates, ps...)
  8873. }
  8874. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8875. // users can use type-assertion to append predicates that do not depend on any generated package.
  8876. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8877. p := make([]predicate.ChatSession, len(ps))
  8878. for i := range ps {
  8879. p[i] = ps[i]
  8880. }
  8881. m.Where(p...)
  8882. }
  8883. // Op returns the operation name.
  8884. func (m *ChatSessionMutation) Op() Op {
  8885. return m.op
  8886. }
  8887. // SetOp allows setting the mutation operation.
  8888. func (m *ChatSessionMutation) SetOp(op Op) {
  8889. m.op = op
  8890. }
  8891. // Type returns the node type of this mutation (ChatSession).
  8892. func (m *ChatSessionMutation) Type() string {
  8893. return m.typ
  8894. }
  8895. // Fields returns all fields that were changed during this mutation. Note that in
  8896. // order to get all numeric fields that were incremented/decremented, call
  8897. // AddedFields().
  8898. func (m *ChatSessionMutation) Fields() []string {
  8899. fields := make([]string, 0, 7)
  8900. if m.created_at != nil {
  8901. fields = append(fields, chatsession.FieldCreatedAt)
  8902. }
  8903. if m.updated_at != nil {
  8904. fields = append(fields, chatsession.FieldUpdatedAt)
  8905. }
  8906. if m.deleted_at != nil {
  8907. fields = append(fields, chatsession.FieldDeletedAt)
  8908. }
  8909. if m.name != nil {
  8910. fields = append(fields, chatsession.FieldName)
  8911. }
  8912. if m.user_id != nil {
  8913. fields = append(fields, chatsession.FieldUserID)
  8914. }
  8915. if m.bot_id != nil {
  8916. fields = append(fields, chatsession.FieldBotID)
  8917. }
  8918. if m.bot_type != nil {
  8919. fields = append(fields, chatsession.FieldBotType)
  8920. }
  8921. return fields
  8922. }
  8923. // Field returns the value of a field with the given name. The second boolean
  8924. // return value indicates that this field was not set, or was not defined in the
  8925. // schema.
  8926. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  8927. switch name {
  8928. case chatsession.FieldCreatedAt:
  8929. return m.CreatedAt()
  8930. case chatsession.FieldUpdatedAt:
  8931. return m.UpdatedAt()
  8932. case chatsession.FieldDeletedAt:
  8933. return m.DeletedAt()
  8934. case chatsession.FieldName:
  8935. return m.Name()
  8936. case chatsession.FieldUserID:
  8937. return m.UserID()
  8938. case chatsession.FieldBotID:
  8939. return m.BotID()
  8940. case chatsession.FieldBotType:
  8941. return m.BotType()
  8942. }
  8943. return nil, false
  8944. }
  8945. // OldField returns the old value of the field from the database. An error is
  8946. // returned if the mutation operation is not UpdateOne, or the query to the
  8947. // database failed.
  8948. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8949. switch name {
  8950. case chatsession.FieldCreatedAt:
  8951. return m.OldCreatedAt(ctx)
  8952. case chatsession.FieldUpdatedAt:
  8953. return m.OldUpdatedAt(ctx)
  8954. case chatsession.FieldDeletedAt:
  8955. return m.OldDeletedAt(ctx)
  8956. case chatsession.FieldName:
  8957. return m.OldName(ctx)
  8958. case chatsession.FieldUserID:
  8959. return m.OldUserID(ctx)
  8960. case chatsession.FieldBotID:
  8961. return m.OldBotID(ctx)
  8962. case chatsession.FieldBotType:
  8963. return m.OldBotType(ctx)
  8964. }
  8965. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  8966. }
  8967. // SetField sets the value of a field with the given name. It returns an error if
  8968. // the field is not defined in the schema, or if the type mismatched the field
  8969. // type.
  8970. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  8971. switch name {
  8972. case chatsession.FieldCreatedAt:
  8973. v, ok := value.(time.Time)
  8974. if !ok {
  8975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8976. }
  8977. m.SetCreatedAt(v)
  8978. return nil
  8979. case chatsession.FieldUpdatedAt:
  8980. v, ok := value.(time.Time)
  8981. if !ok {
  8982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8983. }
  8984. m.SetUpdatedAt(v)
  8985. return nil
  8986. case chatsession.FieldDeletedAt:
  8987. v, ok := value.(time.Time)
  8988. if !ok {
  8989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8990. }
  8991. m.SetDeletedAt(v)
  8992. return nil
  8993. case chatsession.FieldName:
  8994. v, ok := value.(string)
  8995. if !ok {
  8996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8997. }
  8998. m.SetName(v)
  8999. return nil
  9000. case chatsession.FieldUserID:
  9001. v, ok := value.(uint64)
  9002. if !ok {
  9003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9004. }
  9005. m.SetUserID(v)
  9006. return nil
  9007. case chatsession.FieldBotID:
  9008. v, ok := value.(uint64)
  9009. if !ok {
  9010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9011. }
  9012. m.SetBotID(v)
  9013. return nil
  9014. case chatsession.FieldBotType:
  9015. v, ok := value.(uint8)
  9016. if !ok {
  9017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9018. }
  9019. m.SetBotType(v)
  9020. return nil
  9021. }
  9022. return fmt.Errorf("unknown ChatSession field %s", name)
  9023. }
  9024. // AddedFields returns all numeric fields that were incremented/decremented during
  9025. // this mutation.
  9026. func (m *ChatSessionMutation) AddedFields() []string {
  9027. var fields []string
  9028. if m.adduser_id != nil {
  9029. fields = append(fields, chatsession.FieldUserID)
  9030. }
  9031. if m.addbot_id != nil {
  9032. fields = append(fields, chatsession.FieldBotID)
  9033. }
  9034. if m.addbot_type != nil {
  9035. fields = append(fields, chatsession.FieldBotType)
  9036. }
  9037. return fields
  9038. }
  9039. // AddedField returns the numeric value that was incremented/decremented on a field
  9040. // with the given name. The second boolean return value indicates that this field
  9041. // was not set, or was not defined in the schema.
  9042. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9043. switch name {
  9044. case chatsession.FieldUserID:
  9045. return m.AddedUserID()
  9046. case chatsession.FieldBotID:
  9047. return m.AddedBotID()
  9048. case chatsession.FieldBotType:
  9049. return m.AddedBotType()
  9050. }
  9051. return nil, false
  9052. }
  9053. // AddField adds the value to the field with the given name. It returns an error if
  9054. // the field is not defined in the schema, or if the type mismatched the field
  9055. // type.
  9056. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9057. switch name {
  9058. case chatsession.FieldUserID:
  9059. v, ok := value.(int64)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.AddUserID(v)
  9064. return nil
  9065. case chatsession.FieldBotID:
  9066. v, ok := value.(int64)
  9067. if !ok {
  9068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9069. }
  9070. m.AddBotID(v)
  9071. return nil
  9072. case chatsession.FieldBotType:
  9073. v, ok := value.(int8)
  9074. if !ok {
  9075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9076. }
  9077. m.AddBotType(v)
  9078. return nil
  9079. }
  9080. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9081. }
  9082. // ClearedFields returns all nullable fields that were cleared during this
  9083. // mutation.
  9084. func (m *ChatSessionMutation) ClearedFields() []string {
  9085. var fields []string
  9086. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9087. fields = append(fields, chatsession.FieldDeletedAt)
  9088. }
  9089. return fields
  9090. }
  9091. // FieldCleared returns a boolean indicating if a field with the given name was
  9092. // cleared in this mutation.
  9093. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9094. _, ok := m.clearedFields[name]
  9095. return ok
  9096. }
  9097. // ClearField clears the value of the field with the given name. It returns an
  9098. // error if the field is not defined in the schema.
  9099. func (m *ChatSessionMutation) ClearField(name string) error {
  9100. switch name {
  9101. case chatsession.FieldDeletedAt:
  9102. m.ClearDeletedAt()
  9103. return nil
  9104. }
  9105. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9106. }
  9107. // ResetField resets all changes in the mutation for the field with the given name.
  9108. // It returns an error if the field is not defined in the schema.
  9109. func (m *ChatSessionMutation) ResetField(name string) error {
  9110. switch name {
  9111. case chatsession.FieldCreatedAt:
  9112. m.ResetCreatedAt()
  9113. return nil
  9114. case chatsession.FieldUpdatedAt:
  9115. m.ResetUpdatedAt()
  9116. return nil
  9117. case chatsession.FieldDeletedAt:
  9118. m.ResetDeletedAt()
  9119. return nil
  9120. case chatsession.FieldName:
  9121. m.ResetName()
  9122. return nil
  9123. case chatsession.FieldUserID:
  9124. m.ResetUserID()
  9125. return nil
  9126. case chatsession.FieldBotID:
  9127. m.ResetBotID()
  9128. return nil
  9129. case chatsession.FieldBotType:
  9130. m.ResetBotType()
  9131. return nil
  9132. }
  9133. return fmt.Errorf("unknown ChatSession field %s", name)
  9134. }
  9135. // AddedEdges returns all edge names that were set/added in this mutation.
  9136. func (m *ChatSessionMutation) AddedEdges() []string {
  9137. edges := make([]string, 0, 0)
  9138. return edges
  9139. }
  9140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9141. // name in this mutation.
  9142. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9143. return nil
  9144. }
  9145. // RemovedEdges returns all edge names that were removed in this mutation.
  9146. func (m *ChatSessionMutation) RemovedEdges() []string {
  9147. edges := make([]string, 0, 0)
  9148. return edges
  9149. }
  9150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9151. // the given name in this mutation.
  9152. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9153. return nil
  9154. }
  9155. // ClearedEdges returns all edge names that were cleared in this mutation.
  9156. func (m *ChatSessionMutation) ClearedEdges() []string {
  9157. edges := make([]string, 0, 0)
  9158. return edges
  9159. }
  9160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9161. // was cleared in this mutation.
  9162. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9163. return false
  9164. }
  9165. // ClearEdge clears the value of the edge with the given name. It returns an error
  9166. // if that edge is not defined in the schema.
  9167. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9168. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9169. }
  9170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9171. // It returns an error if the edge is not defined in the schema.
  9172. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9173. return fmt.Errorf("unknown ChatSession edge %s", name)
  9174. }
  9175. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9176. type ContactMutation struct {
  9177. config
  9178. op Op
  9179. typ string
  9180. id *uint64
  9181. created_at *time.Time
  9182. updated_at *time.Time
  9183. status *uint8
  9184. addstatus *int8
  9185. deleted_at *time.Time
  9186. wx_wxid *string
  9187. _type *int
  9188. add_type *int
  9189. wxid *string
  9190. account *string
  9191. nickname *string
  9192. markname *string
  9193. headimg *string
  9194. sex *int
  9195. addsex *int
  9196. starrole *string
  9197. dontseeit *int
  9198. adddontseeit *int
  9199. dontseeme *int
  9200. adddontseeme *int
  9201. lag *string
  9202. gid *string
  9203. gname *string
  9204. v3 *string
  9205. organization_id *uint64
  9206. addorganization_id *int64
  9207. ctype *uint64
  9208. addctype *int64
  9209. cage *int
  9210. addcage *int
  9211. cname *string
  9212. carea *string
  9213. cbirthday *string
  9214. cbirtharea *string
  9215. cidcard_no *string
  9216. ctitle *string
  9217. cc *string
  9218. phone *string
  9219. clearedFields map[string]struct{}
  9220. contact_relationships map[uint64]struct{}
  9221. removedcontact_relationships map[uint64]struct{}
  9222. clearedcontact_relationships bool
  9223. contact_messages map[uint64]struct{}
  9224. removedcontact_messages map[uint64]struct{}
  9225. clearedcontact_messages bool
  9226. done bool
  9227. oldValue func(context.Context) (*Contact, error)
  9228. predicates []predicate.Contact
  9229. }
  9230. var _ ent.Mutation = (*ContactMutation)(nil)
  9231. // contactOption allows management of the mutation configuration using functional options.
  9232. type contactOption func(*ContactMutation)
  9233. // newContactMutation creates new mutation for the Contact entity.
  9234. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9235. m := &ContactMutation{
  9236. config: c,
  9237. op: op,
  9238. typ: TypeContact,
  9239. clearedFields: make(map[string]struct{}),
  9240. }
  9241. for _, opt := range opts {
  9242. opt(m)
  9243. }
  9244. return m
  9245. }
  9246. // withContactID sets the ID field of the mutation.
  9247. func withContactID(id uint64) contactOption {
  9248. return func(m *ContactMutation) {
  9249. var (
  9250. err error
  9251. once sync.Once
  9252. value *Contact
  9253. )
  9254. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9255. once.Do(func() {
  9256. if m.done {
  9257. err = errors.New("querying old values post mutation is not allowed")
  9258. } else {
  9259. value, err = m.Client().Contact.Get(ctx, id)
  9260. }
  9261. })
  9262. return value, err
  9263. }
  9264. m.id = &id
  9265. }
  9266. }
  9267. // withContact sets the old Contact of the mutation.
  9268. func withContact(node *Contact) contactOption {
  9269. return func(m *ContactMutation) {
  9270. m.oldValue = func(context.Context) (*Contact, error) {
  9271. return node, nil
  9272. }
  9273. m.id = &node.ID
  9274. }
  9275. }
  9276. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9277. // executed in a transaction (ent.Tx), a transactional client is returned.
  9278. func (m ContactMutation) Client() *Client {
  9279. client := &Client{config: m.config}
  9280. client.init()
  9281. return client
  9282. }
  9283. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9284. // it returns an error otherwise.
  9285. func (m ContactMutation) Tx() (*Tx, error) {
  9286. if _, ok := m.driver.(*txDriver); !ok {
  9287. return nil, errors.New("ent: mutation is not running in a transaction")
  9288. }
  9289. tx := &Tx{config: m.config}
  9290. tx.init()
  9291. return tx, nil
  9292. }
  9293. // SetID sets the value of the id field. Note that this
  9294. // operation is only accepted on creation of Contact entities.
  9295. func (m *ContactMutation) SetID(id uint64) {
  9296. m.id = &id
  9297. }
  9298. // ID returns the ID value in the mutation. Note that the ID is only available
  9299. // if it was provided to the builder or after it was returned from the database.
  9300. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9301. if m.id == nil {
  9302. return
  9303. }
  9304. return *m.id, true
  9305. }
  9306. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9307. // That means, if the mutation is applied within a transaction with an isolation level such
  9308. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9309. // or updated by the mutation.
  9310. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9311. switch {
  9312. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9313. id, exists := m.ID()
  9314. if exists {
  9315. return []uint64{id}, nil
  9316. }
  9317. fallthrough
  9318. case m.op.Is(OpUpdate | OpDelete):
  9319. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9320. default:
  9321. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9322. }
  9323. }
  9324. // SetCreatedAt sets the "created_at" field.
  9325. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9326. m.created_at = &t
  9327. }
  9328. // CreatedAt returns the value of the "created_at" field in the mutation.
  9329. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9330. v := m.created_at
  9331. if v == nil {
  9332. return
  9333. }
  9334. return *v, true
  9335. }
  9336. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9337. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9339. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9340. if !m.op.Is(OpUpdateOne) {
  9341. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9342. }
  9343. if m.id == nil || m.oldValue == nil {
  9344. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9345. }
  9346. oldValue, err := m.oldValue(ctx)
  9347. if err != nil {
  9348. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9349. }
  9350. return oldValue.CreatedAt, nil
  9351. }
  9352. // ResetCreatedAt resets all changes to the "created_at" field.
  9353. func (m *ContactMutation) ResetCreatedAt() {
  9354. m.created_at = nil
  9355. }
  9356. // SetUpdatedAt sets the "updated_at" field.
  9357. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9358. m.updated_at = &t
  9359. }
  9360. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9361. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9362. v := m.updated_at
  9363. if v == nil {
  9364. return
  9365. }
  9366. return *v, true
  9367. }
  9368. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9369. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9371. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9372. if !m.op.Is(OpUpdateOne) {
  9373. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9374. }
  9375. if m.id == nil || m.oldValue == nil {
  9376. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9377. }
  9378. oldValue, err := m.oldValue(ctx)
  9379. if err != nil {
  9380. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9381. }
  9382. return oldValue.UpdatedAt, nil
  9383. }
  9384. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9385. func (m *ContactMutation) ResetUpdatedAt() {
  9386. m.updated_at = nil
  9387. }
  9388. // SetStatus sets the "status" field.
  9389. func (m *ContactMutation) SetStatus(u uint8) {
  9390. m.status = &u
  9391. m.addstatus = nil
  9392. }
  9393. // Status returns the value of the "status" field in the mutation.
  9394. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9395. v := m.status
  9396. if v == nil {
  9397. return
  9398. }
  9399. return *v, true
  9400. }
  9401. // OldStatus returns the old "status" field's value of the Contact entity.
  9402. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9404. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9405. if !m.op.Is(OpUpdateOne) {
  9406. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9407. }
  9408. if m.id == nil || m.oldValue == nil {
  9409. return v, errors.New("OldStatus requires an ID field in the mutation")
  9410. }
  9411. oldValue, err := m.oldValue(ctx)
  9412. if err != nil {
  9413. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9414. }
  9415. return oldValue.Status, nil
  9416. }
  9417. // AddStatus adds u to the "status" field.
  9418. func (m *ContactMutation) AddStatus(u int8) {
  9419. if m.addstatus != nil {
  9420. *m.addstatus += u
  9421. } else {
  9422. m.addstatus = &u
  9423. }
  9424. }
  9425. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9426. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9427. v := m.addstatus
  9428. if v == nil {
  9429. return
  9430. }
  9431. return *v, true
  9432. }
  9433. // ClearStatus clears the value of the "status" field.
  9434. func (m *ContactMutation) ClearStatus() {
  9435. m.status = nil
  9436. m.addstatus = nil
  9437. m.clearedFields[contact.FieldStatus] = struct{}{}
  9438. }
  9439. // StatusCleared returns if the "status" field was cleared in this mutation.
  9440. func (m *ContactMutation) StatusCleared() bool {
  9441. _, ok := m.clearedFields[contact.FieldStatus]
  9442. return ok
  9443. }
  9444. // ResetStatus resets all changes to the "status" field.
  9445. func (m *ContactMutation) ResetStatus() {
  9446. m.status = nil
  9447. m.addstatus = nil
  9448. delete(m.clearedFields, contact.FieldStatus)
  9449. }
  9450. // SetDeletedAt sets the "deleted_at" field.
  9451. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9452. m.deleted_at = &t
  9453. }
  9454. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9455. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9456. v := m.deleted_at
  9457. if v == nil {
  9458. return
  9459. }
  9460. return *v, true
  9461. }
  9462. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9463. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9465. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9466. if !m.op.Is(OpUpdateOne) {
  9467. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9468. }
  9469. if m.id == nil || m.oldValue == nil {
  9470. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9471. }
  9472. oldValue, err := m.oldValue(ctx)
  9473. if err != nil {
  9474. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9475. }
  9476. return oldValue.DeletedAt, nil
  9477. }
  9478. // ClearDeletedAt clears the value of the "deleted_at" field.
  9479. func (m *ContactMutation) ClearDeletedAt() {
  9480. m.deleted_at = nil
  9481. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9482. }
  9483. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9484. func (m *ContactMutation) DeletedAtCleared() bool {
  9485. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9486. return ok
  9487. }
  9488. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9489. func (m *ContactMutation) ResetDeletedAt() {
  9490. m.deleted_at = nil
  9491. delete(m.clearedFields, contact.FieldDeletedAt)
  9492. }
  9493. // SetWxWxid sets the "wx_wxid" field.
  9494. func (m *ContactMutation) SetWxWxid(s string) {
  9495. m.wx_wxid = &s
  9496. }
  9497. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9498. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9499. v := m.wx_wxid
  9500. if v == nil {
  9501. return
  9502. }
  9503. return *v, true
  9504. }
  9505. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9506. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9508. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9509. if !m.op.Is(OpUpdateOne) {
  9510. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9511. }
  9512. if m.id == nil || m.oldValue == nil {
  9513. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9514. }
  9515. oldValue, err := m.oldValue(ctx)
  9516. if err != nil {
  9517. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9518. }
  9519. return oldValue.WxWxid, nil
  9520. }
  9521. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9522. func (m *ContactMutation) ResetWxWxid() {
  9523. m.wx_wxid = nil
  9524. }
  9525. // SetType sets the "type" field.
  9526. func (m *ContactMutation) SetType(i int) {
  9527. m._type = &i
  9528. m.add_type = nil
  9529. }
  9530. // GetType returns the value of the "type" field in the mutation.
  9531. func (m *ContactMutation) GetType() (r int, exists bool) {
  9532. v := m._type
  9533. if v == nil {
  9534. return
  9535. }
  9536. return *v, true
  9537. }
  9538. // OldType returns the old "type" field's value of the Contact entity.
  9539. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9541. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9542. if !m.op.Is(OpUpdateOne) {
  9543. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9544. }
  9545. if m.id == nil || m.oldValue == nil {
  9546. return v, errors.New("OldType requires an ID field in the mutation")
  9547. }
  9548. oldValue, err := m.oldValue(ctx)
  9549. if err != nil {
  9550. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9551. }
  9552. return oldValue.Type, nil
  9553. }
  9554. // AddType adds i to the "type" field.
  9555. func (m *ContactMutation) AddType(i int) {
  9556. if m.add_type != nil {
  9557. *m.add_type += i
  9558. } else {
  9559. m.add_type = &i
  9560. }
  9561. }
  9562. // AddedType returns the value that was added to the "type" field in this mutation.
  9563. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9564. v := m.add_type
  9565. if v == nil {
  9566. return
  9567. }
  9568. return *v, true
  9569. }
  9570. // ClearType clears the value of the "type" field.
  9571. func (m *ContactMutation) ClearType() {
  9572. m._type = nil
  9573. m.add_type = nil
  9574. m.clearedFields[contact.FieldType] = struct{}{}
  9575. }
  9576. // TypeCleared returns if the "type" field was cleared in this mutation.
  9577. func (m *ContactMutation) TypeCleared() bool {
  9578. _, ok := m.clearedFields[contact.FieldType]
  9579. return ok
  9580. }
  9581. // ResetType resets all changes to the "type" field.
  9582. func (m *ContactMutation) ResetType() {
  9583. m._type = nil
  9584. m.add_type = nil
  9585. delete(m.clearedFields, contact.FieldType)
  9586. }
  9587. // SetWxid sets the "wxid" field.
  9588. func (m *ContactMutation) SetWxid(s string) {
  9589. m.wxid = &s
  9590. }
  9591. // Wxid returns the value of the "wxid" field in the mutation.
  9592. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9593. v := m.wxid
  9594. if v == nil {
  9595. return
  9596. }
  9597. return *v, true
  9598. }
  9599. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9600. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9602. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9603. if !m.op.Is(OpUpdateOne) {
  9604. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9605. }
  9606. if m.id == nil || m.oldValue == nil {
  9607. return v, errors.New("OldWxid requires an ID field in the mutation")
  9608. }
  9609. oldValue, err := m.oldValue(ctx)
  9610. if err != nil {
  9611. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9612. }
  9613. return oldValue.Wxid, nil
  9614. }
  9615. // ResetWxid resets all changes to the "wxid" field.
  9616. func (m *ContactMutation) ResetWxid() {
  9617. m.wxid = nil
  9618. }
  9619. // SetAccount sets the "account" field.
  9620. func (m *ContactMutation) SetAccount(s string) {
  9621. m.account = &s
  9622. }
  9623. // Account returns the value of the "account" field in the mutation.
  9624. func (m *ContactMutation) Account() (r string, exists bool) {
  9625. v := m.account
  9626. if v == nil {
  9627. return
  9628. }
  9629. return *v, true
  9630. }
  9631. // OldAccount returns the old "account" field's value of the Contact entity.
  9632. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9634. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9635. if !m.op.Is(OpUpdateOne) {
  9636. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9637. }
  9638. if m.id == nil || m.oldValue == nil {
  9639. return v, errors.New("OldAccount requires an ID field in the mutation")
  9640. }
  9641. oldValue, err := m.oldValue(ctx)
  9642. if err != nil {
  9643. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9644. }
  9645. return oldValue.Account, nil
  9646. }
  9647. // ResetAccount resets all changes to the "account" field.
  9648. func (m *ContactMutation) ResetAccount() {
  9649. m.account = nil
  9650. }
  9651. // SetNickname sets the "nickname" field.
  9652. func (m *ContactMutation) SetNickname(s string) {
  9653. m.nickname = &s
  9654. }
  9655. // Nickname returns the value of the "nickname" field in the mutation.
  9656. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9657. v := m.nickname
  9658. if v == nil {
  9659. return
  9660. }
  9661. return *v, true
  9662. }
  9663. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9664. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9666. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9667. if !m.op.Is(OpUpdateOne) {
  9668. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9669. }
  9670. if m.id == nil || m.oldValue == nil {
  9671. return v, errors.New("OldNickname requires an ID field in the mutation")
  9672. }
  9673. oldValue, err := m.oldValue(ctx)
  9674. if err != nil {
  9675. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9676. }
  9677. return oldValue.Nickname, nil
  9678. }
  9679. // ResetNickname resets all changes to the "nickname" field.
  9680. func (m *ContactMutation) ResetNickname() {
  9681. m.nickname = nil
  9682. }
  9683. // SetMarkname sets the "markname" field.
  9684. func (m *ContactMutation) SetMarkname(s string) {
  9685. m.markname = &s
  9686. }
  9687. // Markname returns the value of the "markname" field in the mutation.
  9688. func (m *ContactMutation) Markname() (r string, exists bool) {
  9689. v := m.markname
  9690. if v == nil {
  9691. return
  9692. }
  9693. return *v, true
  9694. }
  9695. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9696. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9698. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9699. if !m.op.Is(OpUpdateOne) {
  9700. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9701. }
  9702. if m.id == nil || m.oldValue == nil {
  9703. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9704. }
  9705. oldValue, err := m.oldValue(ctx)
  9706. if err != nil {
  9707. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9708. }
  9709. return oldValue.Markname, nil
  9710. }
  9711. // ResetMarkname resets all changes to the "markname" field.
  9712. func (m *ContactMutation) ResetMarkname() {
  9713. m.markname = nil
  9714. }
  9715. // SetHeadimg sets the "headimg" field.
  9716. func (m *ContactMutation) SetHeadimg(s string) {
  9717. m.headimg = &s
  9718. }
  9719. // Headimg returns the value of the "headimg" field in the mutation.
  9720. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9721. v := m.headimg
  9722. if v == nil {
  9723. return
  9724. }
  9725. return *v, true
  9726. }
  9727. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9728. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9730. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9731. if !m.op.Is(OpUpdateOne) {
  9732. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9733. }
  9734. if m.id == nil || m.oldValue == nil {
  9735. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9736. }
  9737. oldValue, err := m.oldValue(ctx)
  9738. if err != nil {
  9739. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9740. }
  9741. return oldValue.Headimg, nil
  9742. }
  9743. // ResetHeadimg resets all changes to the "headimg" field.
  9744. func (m *ContactMutation) ResetHeadimg() {
  9745. m.headimg = nil
  9746. }
  9747. // SetSex sets the "sex" field.
  9748. func (m *ContactMutation) SetSex(i int) {
  9749. m.sex = &i
  9750. m.addsex = nil
  9751. }
  9752. // Sex returns the value of the "sex" field in the mutation.
  9753. func (m *ContactMutation) Sex() (r int, exists bool) {
  9754. v := m.sex
  9755. if v == nil {
  9756. return
  9757. }
  9758. return *v, true
  9759. }
  9760. // OldSex returns the old "sex" field's value of the Contact entity.
  9761. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9763. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9764. if !m.op.Is(OpUpdateOne) {
  9765. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9766. }
  9767. if m.id == nil || m.oldValue == nil {
  9768. return v, errors.New("OldSex requires an ID field in the mutation")
  9769. }
  9770. oldValue, err := m.oldValue(ctx)
  9771. if err != nil {
  9772. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9773. }
  9774. return oldValue.Sex, nil
  9775. }
  9776. // AddSex adds i to the "sex" field.
  9777. func (m *ContactMutation) AddSex(i int) {
  9778. if m.addsex != nil {
  9779. *m.addsex += i
  9780. } else {
  9781. m.addsex = &i
  9782. }
  9783. }
  9784. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9785. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9786. v := m.addsex
  9787. if v == nil {
  9788. return
  9789. }
  9790. return *v, true
  9791. }
  9792. // ResetSex resets all changes to the "sex" field.
  9793. func (m *ContactMutation) ResetSex() {
  9794. m.sex = nil
  9795. m.addsex = nil
  9796. }
  9797. // SetStarrole sets the "starrole" field.
  9798. func (m *ContactMutation) SetStarrole(s string) {
  9799. m.starrole = &s
  9800. }
  9801. // Starrole returns the value of the "starrole" field in the mutation.
  9802. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9803. v := m.starrole
  9804. if v == nil {
  9805. return
  9806. }
  9807. return *v, true
  9808. }
  9809. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9810. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9812. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9813. if !m.op.Is(OpUpdateOne) {
  9814. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9815. }
  9816. if m.id == nil || m.oldValue == nil {
  9817. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9818. }
  9819. oldValue, err := m.oldValue(ctx)
  9820. if err != nil {
  9821. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9822. }
  9823. return oldValue.Starrole, nil
  9824. }
  9825. // ResetStarrole resets all changes to the "starrole" field.
  9826. func (m *ContactMutation) ResetStarrole() {
  9827. m.starrole = nil
  9828. }
  9829. // SetDontseeit sets the "dontseeit" field.
  9830. func (m *ContactMutation) SetDontseeit(i int) {
  9831. m.dontseeit = &i
  9832. m.adddontseeit = nil
  9833. }
  9834. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9835. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9836. v := m.dontseeit
  9837. if v == nil {
  9838. return
  9839. }
  9840. return *v, true
  9841. }
  9842. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9843. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9845. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9846. if !m.op.Is(OpUpdateOne) {
  9847. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9848. }
  9849. if m.id == nil || m.oldValue == nil {
  9850. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9851. }
  9852. oldValue, err := m.oldValue(ctx)
  9853. if err != nil {
  9854. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9855. }
  9856. return oldValue.Dontseeit, nil
  9857. }
  9858. // AddDontseeit adds i to the "dontseeit" field.
  9859. func (m *ContactMutation) AddDontseeit(i int) {
  9860. if m.adddontseeit != nil {
  9861. *m.adddontseeit += i
  9862. } else {
  9863. m.adddontseeit = &i
  9864. }
  9865. }
  9866. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9867. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9868. v := m.adddontseeit
  9869. if v == nil {
  9870. return
  9871. }
  9872. return *v, true
  9873. }
  9874. // ResetDontseeit resets all changes to the "dontseeit" field.
  9875. func (m *ContactMutation) ResetDontseeit() {
  9876. m.dontseeit = nil
  9877. m.adddontseeit = nil
  9878. }
  9879. // SetDontseeme sets the "dontseeme" field.
  9880. func (m *ContactMutation) SetDontseeme(i int) {
  9881. m.dontseeme = &i
  9882. m.adddontseeme = nil
  9883. }
  9884. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9885. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9886. v := m.dontseeme
  9887. if v == nil {
  9888. return
  9889. }
  9890. return *v, true
  9891. }
  9892. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9893. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9895. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9896. if !m.op.Is(OpUpdateOne) {
  9897. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9898. }
  9899. if m.id == nil || m.oldValue == nil {
  9900. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9901. }
  9902. oldValue, err := m.oldValue(ctx)
  9903. if err != nil {
  9904. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9905. }
  9906. return oldValue.Dontseeme, nil
  9907. }
  9908. // AddDontseeme adds i to the "dontseeme" field.
  9909. func (m *ContactMutation) AddDontseeme(i int) {
  9910. if m.adddontseeme != nil {
  9911. *m.adddontseeme += i
  9912. } else {
  9913. m.adddontseeme = &i
  9914. }
  9915. }
  9916. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9917. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9918. v := m.adddontseeme
  9919. if v == nil {
  9920. return
  9921. }
  9922. return *v, true
  9923. }
  9924. // ResetDontseeme resets all changes to the "dontseeme" field.
  9925. func (m *ContactMutation) ResetDontseeme() {
  9926. m.dontseeme = nil
  9927. m.adddontseeme = nil
  9928. }
  9929. // SetLag sets the "lag" field.
  9930. func (m *ContactMutation) SetLag(s string) {
  9931. m.lag = &s
  9932. }
  9933. // Lag returns the value of the "lag" field in the mutation.
  9934. func (m *ContactMutation) Lag() (r string, exists bool) {
  9935. v := m.lag
  9936. if v == nil {
  9937. return
  9938. }
  9939. return *v, true
  9940. }
  9941. // OldLag returns the old "lag" field's value of the Contact entity.
  9942. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9944. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  9945. if !m.op.Is(OpUpdateOne) {
  9946. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  9947. }
  9948. if m.id == nil || m.oldValue == nil {
  9949. return v, errors.New("OldLag requires an ID field in the mutation")
  9950. }
  9951. oldValue, err := m.oldValue(ctx)
  9952. if err != nil {
  9953. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  9954. }
  9955. return oldValue.Lag, nil
  9956. }
  9957. // ResetLag resets all changes to the "lag" field.
  9958. func (m *ContactMutation) ResetLag() {
  9959. m.lag = nil
  9960. }
  9961. // SetGid sets the "gid" field.
  9962. func (m *ContactMutation) SetGid(s string) {
  9963. m.gid = &s
  9964. }
  9965. // Gid returns the value of the "gid" field in the mutation.
  9966. func (m *ContactMutation) Gid() (r string, exists bool) {
  9967. v := m.gid
  9968. if v == nil {
  9969. return
  9970. }
  9971. return *v, true
  9972. }
  9973. // OldGid returns the old "gid" field's value of the Contact entity.
  9974. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9976. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  9977. if !m.op.Is(OpUpdateOne) {
  9978. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  9979. }
  9980. if m.id == nil || m.oldValue == nil {
  9981. return v, errors.New("OldGid requires an ID field in the mutation")
  9982. }
  9983. oldValue, err := m.oldValue(ctx)
  9984. if err != nil {
  9985. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  9986. }
  9987. return oldValue.Gid, nil
  9988. }
  9989. // ResetGid resets all changes to the "gid" field.
  9990. func (m *ContactMutation) ResetGid() {
  9991. m.gid = nil
  9992. }
  9993. // SetGname sets the "gname" field.
  9994. func (m *ContactMutation) SetGname(s string) {
  9995. m.gname = &s
  9996. }
  9997. // Gname returns the value of the "gname" field in the mutation.
  9998. func (m *ContactMutation) Gname() (r string, exists bool) {
  9999. v := m.gname
  10000. if v == nil {
  10001. return
  10002. }
  10003. return *v, true
  10004. }
  10005. // OldGname returns the old "gname" field's value of the Contact entity.
  10006. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10008. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10009. if !m.op.Is(OpUpdateOne) {
  10010. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10011. }
  10012. if m.id == nil || m.oldValue == nil {
  10013. return v, errors.New("OldGname requires an ID field in the mutation")
  10014. }
  10015. oldValue, err := m.oldValue(ctx)
  10016. if err != nil {
  10017. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10018. }
  10019. return oldValue.Gname, nil
  10020. }
  10021. // ResetGname resets all changes to the "gname" field.
  10022. func (m *ContactMutation) ResetGname() {
  10023. m.gname = nil
  10024. }
  10025. // SetV3 sets the "v3" field.
  10026. func (m *ContactMutation) SetV3(s string) {
  10027. m.v3 = &s
  10028. }
  10029. // V3 returns the value of the "v3" field in the mutation.
  10030. func (m *ContactMutation) V3() (r string, exists bool) {
  10031. v := m.v3
  10032. if v == nil {
  10033. return
  10034. }
  10035. return *v, true
  10036. }
  10037. // OldV3 returns the old "v3" field's value of the Contact entity.
  10038. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10040. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10041. if !m.op.Is(OpUpdateOne) {
  10042. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10043. }
  10044. if m.id == nil || m.oldValue == nil {
  10045. return v, errors.New("OldV3 requires an ID field in the mutation")
  10046. }
  10047. oldValue, err := m.oldValue(ctx)
  10048. if err != nil {
  10049. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10050. }
  10051. return oldValue.V3, nil
  10052. }
  10053. // ResetV3 resets all changes to the "v3" field.
  10054. func (m *ContactMutation) ResetV3() {
  10055. m.v3 = nil
  10056. }
  10057. // SetOrganizationID sets the "organization_id" field.
  10058. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10059. m.organization_id = &u
  10060. m.addorganization_id = nil
  10061. }
  10062. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10063. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10064. v := m.organization_id
  10065. if v == nil {
  10066. return
  10067. }
  10068. return *v, true
  10069. }
  10070. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10073. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10074. if !m.op.Is(OpUpdateOne) {
  10075. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10076. }
  10077. if m.id == nil || m.oldValue == nil {
  10078. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10079. }
  10080. oldValue, err := m.oldValue(ctx)
  10081. if err != nil {
  10082. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10083. }
  10084. return oldValue.OrganizationID, nil
  10085. }
  10086. // AddOrganizationID adds u to the "organization_id" field.
  10087. func (m *ContactMutation) AddOrganizationID(u int64) {
  10088. if m.addorganization_id != nil {
  10089. *m.addorganization_id += u
  10090. } else {
  10091. m.addorganization_id = &u
  10092. }
  10093. }
  10094. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10095. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10096. v := m.addorganization_id
  10097. if v == nil {
  10098. return
  10099. }
  10100. return *v, true
  10101. }
  10102. // ClearOrganizationID clears the value of the "organization_id" field.
  10103. func (m *ContactMutation) ClearOrganizationID() {
  10104. m.organization_id = nil
  10105. m.addorganization_id = nil
  10106. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10107. }
  10108. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10109. func (m *ContactMutation) OrganizationIDCleared() bool {
  10110. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10111. return ok
  10112. }
  10113. // ResetOrganizationID resets all changes to the "organization_id" field.
  10114. func (m *ContactMutation) ResetOrganizationID() {
  10115. m.organization_id = nil
  10116. m.addorganization_id = nil
  10117. delete(m.clearedFields, contact.FieldOrganizationID)
  10118. }
  10119. // SetCtype sets the "ctype" field.
  10120. func (m *ContactMutation) SetCtype(u uint64) {
  10121. m.ctype = &u
  10122. m.addctype = nil
  10123. }
  10124. // Ctype returns the value of the "ctype" field in the mutation.
  10125. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10126. v := m.ctype
  10127. if v == nil {
  10128. return
  10129. }
  10130. return *v, true
  10131. }
  10132. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10133. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10135. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10136. if !m.op.Is(OpUpdateOne) {
  10137. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10138. }
  10139. if m.id == nil || m.oldValue == nil {
  10140. return v, errors.New("OldCtype requires an ID field in the mutation")
  10141. }
  10142. oldValue, err := m.oldValue(ctx)
  10143. if err != nil {
  10144. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10145. }
  10146. return oldValue.Ctype, nil
  10147. }
  10148. // AddCtype adds u to the "ctype" field.
  10149. func (m *ContactMutation) AddCtype(u int64) {
  10150. if m.addctype != nil {
  10151. *m.addctype += u
  10152. } else {
  10153. m.addctype = &u
  10154. }
  10155. }
  10156. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10157. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10158. v := m.addctype
  10159. if v == nil {
  10160. return
  10161. }
  10162. return *v, true
  10163. }
  10164. // ResetCtype resets all changes to the "ctype" field.
  10165. func (m *ContactMutation) ResetCtype() {
  10166. m.ctype = nil
  10167. m.addctype = nil
  10168. }
  10169. // SetCage sets the "cage" field.
  10170. func (m *ContactMutation) SetCage(i int) {
  10171. m.cage = &i
  10172. m.addcage = nil
  10173. }
  10174. // Cage returns the value of the "cage" field in the mutation.
  10175. func (m *ContactMutation) Cage() (r int, exists bool) {
  10176. v := m.cage
  10177. if v == nil {
  10178. return
  10179. }
  10180. return *v, true
  10181. }
  10182. // OldCage returns the old "cage" field's value of the Contact entity.
  10183. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10185. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10186. if !m.op.Is(OpUpdateOne) {
  10187. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10188. }
  10189. if m.id == nil || m.oldValue == nil {
  10190. return v, errors.New("OldCage requires an ID field in the mutation")
  10191. }
  10192. oldValue, err := m.oldValue(ctx)
  10193. if err != nil {
  10194. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10195. }
  10196. return oldValue.Cage, nil
  10197. }
  10198. // AddCage adds i to the "cage" field.
  10199. func (m *ContactMutation) AddCage(i int) {
  10200. if m.addcage != nil {
  10201. *m.addcage += i
  10202. } else {
  10203. m.addcage = &i
  10204. }
  10205. }
  10206. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10207. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10208. v := m.addcage
  10209. if v == nil {
  10210. return
  10211. }
  10212. return *v, true
  10213. }
  10214. // ResetCage resets all changes to the "cage" field.
  10215. func (m *ContactMutation) ResetCage() {
  10216. m.cage = nil
  10217. m.addcage = nil
  10218. }
  10219. // SetCname sets the "cname" field.
  10220. func (m *ContactMutation) SetCname(s string) {
  10221. m.cname = &s
  10222. }
  10223. // Cname returns the value of the "cname" field in the mutation.
  10224. func (m *ContactMutation) Cname() (r string, exists bool) {
  10225. v := m.cname
  10226. if v == nil {
  10227. return
  10228. }
  10229. return *v, true
  10230. }
  10231. // OldCname returns the old "cname" field's value of the Contact entity.
  10232. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10234. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10235. if !m.op.Is(OpUpdateOne) {
  10236. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10237. }
  10238. if m.id == nil || m.oldValue == nil {
  10239. return v, errors.New("OldCname requires an ID field in the mutation")
  10240. }
  10241. oldValue, err := m.oldValue(ctx)
  10242. if err != nil {
  10243. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10244. }
  10245. return oldValue.Cname, nil
  10246. }
  10247. // ResetCname resets all changes to the "cname" field.
  10248. func (m *ContactMutation) ResetCname() {
  10249. m.cname = nil
  10250. }
  10251. // SetCarea sets the "carea" field.
  10252. func (m *ContactMutation) SetCarea(s string) {
  10253. m.carea = &s
  10254. }
  10255. // Carea returns the value of the "carea" field in the mutation.
  10256. func (m *ContactMutation) Carea() (r string, exists bool) {
  10257. v := m.carea
  10258. if v == nil {
  10259. return
  10260. }
  10261. return *v, true
  10262. }
  10263. // OldCarea returns the old "carea" field's value of the Contact entity.
  10264. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10266. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10267. if !m.op.Is(OpUpdateOne) {
  10268. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10269. }
  10270. if m.id == nil || m.oldValue == nil {
  10271. return v, errors.New("OldCarea requires an ID field in the mutation")
  10272. }
  10273. oldValue, err := m.oldValue(ctx)
  10274. if err != nil {
  10275. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10276. }
  10277. return oldValue.Carea, nil
  10278. }
  10279. // ResetCarea resets all changes to the "carea" field.
  10280. func (m *ContactMutation) ResetCarea() {
  10281. m.carea = nil
  10282. }
  10283. // SetCbirthday sets the "cbirthday" field.
  10284. func (m *ContactMutation) SetCbirthday(s string) {
  10285. m.cbirthday = &s
  10286. }
  10287. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10288. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10289. v := m.cbirthday
  10290. if v == nil {
  10291. return
  10292. }
  10293. return *v, true
  10294. }
  10295. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10296. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10298. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10299. if !m.op.Is(OpUpdateOne) {
  10300. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10301. }
  10302. if m.id == nil || m.oldValue == nil {
  10303. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10304. }
  10305. oldValue, err := m.oldValue(ctx)
  10306. if err != nil {
  10307. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10308. }
  10309. return oldValue.Cbirthday, nil
  10310. }
  10311. // ResetCbirthday resets all changes to the "cbirthday" field.
  10312. func (m *ContactMutation) ResetCbirthday() {
  10313. m.cbirthday = nil
  10314. }
  10315. // SetCbirtharea sets the "cbirtharea" field.
  10316. func (m *ContactMutation) SetCbirtharea(s string) {
  10317. m.cbirtharea = &s
  10318. }
  10319. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10320. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10321. v := m.cbirtharea
  10322. if v == nil {
  10323. return
  10324. }
  10325. return *v, true
  10326. }
  10327. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10328. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10330. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10331. if !m.op.Is(OpUpdateOne) {
  10332. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10333. }
  10334. if m.id == nil || m.oldValue == nil {
  10335. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10336. }
  10337. oldValue, err := m.oldValue(ctx)
  10338. if err != nil {
  10339. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10340. }
  10341. return oldValue.Cbirtharea, nil
  10342. }
  10343. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10344. func (m *ContactMutation) ResetCbirtharea() {
  10345. m.cbirtharea = nil
  10346. }
  10347. // SetCidcardNo sets the "cidcard_no" field.
  10348. func (m *ContactMutation) SetCidcardNo(s string) {
  10349. m.cidcard_no = &s
  10350. }
  10351. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10352. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10353. v := m.cidcard_no
  10354. if v == nil {
  10355. return
  10356. }
  10357. return *v, true
  10358. }
  10359. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10362. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10363. if !m.op.Is(OpUpdateOne) {
  10364. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10365. }
  10366. if m.id == nil || m.oldValue == nil {
  10367. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10368. }
  10369. oldValue, err := m.oldValue(ctx)
  10370. if err != nil {
  10371. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10372. }
  10373. return oldValue.CidcardNo, nil
  10374. }
  10375. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10376. func (m *ContactMutation) ResetCidcardNo() {
  10377. m.cidcard_no = nil
  10378. }
  10379. // SetCtitle sets the "ctitle" field.
  10380. func (m *ContactMutation) SetCtitle(s string) {
  10381. m.ctitle = &s
  10382. }
  10383. // Ctitle returns the value of the "ctitle" field in the mutation.
  10384. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10385. v := m.ctitle
  10386. if v == nil {
  10387. return
  10388. }
  10389. return *v, true
  10390. }
  10391. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10392. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10394. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10395. if !m.op.Is(OpUpdateOne) {
  10396. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10397. }
  10398. if m.id == nil || m.oldValue == nil {
  10399. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10400. }
  10401. oldValue, err := m.oldValue(ctx)
  10402. if err != nil {
  10403. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10404. }
  10405. return oldValue.Ctitle, nil
  10406. }
  10407. // ResetCtitle resets all changes to the "ctitle" field.
  10408. func (m *ContactMutation) ResetCtitle() {
  10409. m.ctitle = nil
  10410. }
  10411. // SetCc sets the "cc" field.
  10412. func (m *ContactMutation) SetCc(s string) {
  10413. m.cc = &s
  10414. }
  10415. // Cc returns the value of the "cc" field in the mutation.
  10416. func (m *ContactMutation) Cc() (r string, exists bool) {
  10417. v := m.cc
  10418. if v == nil {
  10419. return
  10420. }
  10421. return *v, true
  10422. }
  10423. // OldCc returns the old "cc" field's value of the Contact entity.
  10424. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10426. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10427. if !m.op.Is(OpUpdateOne) {
  10428. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10429. }
  10430. if m.id == nil || m.oldValue == nil {
  10431. return v, errors.New("OldCc requires an ID field in the mutation")
  10432. }
  10433. oldValue, err := m.oldValue(ctx)
  10434. if err != nil {
  10435. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10436. }
  10437. return oldValue.Cc, nil
  10438. }
  10439. // ResetCc resets all changes to the "cc" field.
  10440. func (m *ContactMutation) ResetCc() {
  10441. m.cc = nil
  10442. }
  10443. // SetPhone sets the "phone" field.
  10444. func (m *ContactMutation) SetPhone(s string) {
  10445. m.phone = &s
  10446. }
  10447. // Phone returns the value of the "phone" field in the mutation.
  10448. func (m *ContactMutation) Phone() (r string, exists bool) {
  10449. v := m.phone
  10450. if v == nil {
  10451. return
  10452. }
  10453. return *v, true
  10454. }
  10455. // OldPhone returns the old "phone" field's value of the Contact entity.
  10456. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10458. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10459. if !m.op.Is(OpUpdateOne) {
  10460. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10461. }
  10462. if m.id == nil || m.oldValue == nil {
  10463. return v, errors.New("OldPhone requires an ID field in the mutation")
  10464. }
  10465. oldValue, err := m.oldValue(ctx)
  10466. if err != nil {
  10467. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10468. }
  10469. return oldValue.Phone, nil
  10470. }
  10471. // ResetPhone resets all changes to the "phone" field.
  10472. func (m *ContactMutation) ResetPhone() {
  10473. m.phone = nil
  10474. }
  10475. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10476. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10477. if m.contact_relationships == nil {
  10478. m.contact_relationships = make(map[uint64]struct{})
  10479. }
  10480. for i := range ids {
  10481. m.contact_relationships[ids[i]] = struct{}{}
  10482. }
  10483. }
  10484. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10485. func (m *ContactMutation) ClearContactRelationships() {
  10486. m.clearedcontact_relationships = true
  10487. }
  10488. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10489. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10490. return m.clearedcontact_relationships
  10491. }
  10492. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10493. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10494. if m.removedcontact_relationships == nil {
  10495. m.removedcontact_relationships = make(map[uint64]struct{})
  10496. }
  10497. for i := range ids {
  10498. delete(m.contact_relationships, ids[i])
  10499. m.removedcontact_relationships[ids[i]] = struct{}{}
  10500. }
  10501. }
  10502. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10503. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10504. for id := range m.removedcontact_relationships {
  10505. ids = append(ids, id)
  10506. }
  10507. return
  10508. }
  10509. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10510. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10511. for id := range m.contact_relationships {
  10512. ids = append(ids, id)
  10513. }
  10514. return
  10515. }
  10516. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10517. func (m *ContactMutation) ResetContactRelationships() {
  10518. m.contact_relationships = nil
  10519. m.clearedcontact_relationships = false
  10520. m.removedcontact_relationships = nil
  10521. }
  10522. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10523. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10524. if m.contact_messages == nil {
  10525. m.contact_messages = make(map[uint64]struct{})
  10526. }
  10527. for i := range ids {
  10528. m.contact_messages[ids[i]] = struct{}{}
  10529. }
  10530. }
  10531. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10532. func (m *ContactMutation) ClearContactMessages() {
  10533. m.clearedcontact_messages = true
  10534. }
  10535. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10536. func (m *ContactMutation) ContactMessagesCleared() bool {
  10537. return m.clearedcontact_messages
  10538. }
  10539. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10540. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10541. if m.removedcontact_messages == nil {
  10542. m.removedcontact_messages = make(map[uint64]struct{})
  10543. }
  10544. for i := range ids {
  10545. delete(m.contact_messages, ids[i])
  10546. m.removedcontact_messages[ids[i]] = struct{}{}
  10547. }
  10548. }
  10549. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10550. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10551. for id := range m.removedcontact_messages {
  10552. ids = append(ids, id)
  10553. }
  10554. return
  10555. }
  10556. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10557. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10558. for id := range m.contact_messages {
  10559. ids = append(ids, id)
  10560. }
  10561. return
  10562. }
  10563. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10564. func (m *ContactMutation) ResetContactMessages() {
  10565. m.contact_messages = nil
  10566. m.clearedcontact_messages = false
  10567. m.removedcontact_messages = nil
  10568. }
  10569. // Where appends a list predicates to the ContactMutation builder.
  10570. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10571. m.predicates = append(m.predicates, ps...)
  10572. }
  10573. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10574. // users can use type-assertion to append predicates that do not depend on any generated package.
  10575. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10576. p := make([]predicate.Contact, len(ps))
  10577. for i := range ps {
  10578. p[i] = ps[i]
  10579. }
  10580. m.Where(p...)
  10581. }
  10582. // Op returns the operation name.
  10583. func (m *ContactMutation) Op() Op {
  10584. return m.op
  10585. }
  10586. // SetOp allows setting the mutation operation.
  10587. func (m *ContactMutation) SetOp(op Op) {
  10588. m.op = op
  10589. }
  10590. // Type returns the node type of this mutation (Contact).
  10591. func (m *ContactMutation) Type() string {
  10592. return m.typ
  10593. }
  10594. // Fields returns all fields that were changed during this mutation. Note that in
  10595. // order to get all numeric fields that were incremented/decremented, call
  10596. // AddedFields().
  10597. func (m *ContactMutation) Fields() []string {
  10598. fields := make([]string, 0, 30)
  10599. if m.created_at != nil {
  10600. fields = append(fields, contact.FieldCreatedAt)
  10601. }
  10602. if m.updated_at != nil {
  10603. fields = append(fields, contact.FieldUpdatedAt)
  10604. }
  10605. if m.status != nil {
  10606. fields = append(fields, contact.FieldStatus)
  10607. }
  10608. if m.deleted_at != nil {
  10609. fields = append(fields, contact.FieldDeletedAt)
  10610. }
  10611. if m.wx_wxid != nil {
  10612. fields = append(fields, contact.FieldWxWxid)
  10613. }
  10614. if m._type != nil {
  10615. fields = append(fields, contact.FieldType)
  10616. }
  10617. if m.wxid != nil {
  10618. fields = append(fields, contact.FieldWxid)
  10619. }
  10620. if m.account != nil {
  10621. fields = append(fields, contact.FieldAccount)
  10622. }
  10623. if m.nickname != nil {
  10624. fields = append(fields, contact.FieldNickname)
  10625. }
  10626. if m.markname != nil {
  10627. fields = append(fields, contact.FieldMarkname)
  10628. }
  10629. if m.headimg != nil {
  10630. fields = append(fields, contact.FieldHeadimg)
  10631. }
  10632. if m.sex != nil {
  10633. fields = append(fields, contact.FieldSex)
  10634. }
  10635. if m.starrole != nil {
  10636. fields = append(fields, contact.FieldStarrole)
  10637. }
  10638. if m.dontseeit != nil {
  10639. fields = append(fields, contact.FieldDontseeit)
  10640. }
  10641. if m.dontseeme != nil {
  10642. fields = append(fields, contact.FieldDontseeme)
  10643. }
  10644. if m.lag != nil {
  10645. fields = append(fields, contact.FieldLag)
  10646. }
  10647. if m.gid != nil {
  10648. fields = append(fields, contact.FieldGid)
  10649. }
  10650. if m.gname != nil {
  10651. fields = append(fields, contact.FieldGname)
  10652. }
  10653. if m.v3 != nil {
  10654. fields = append(fields, contact.FieldV3)
  10655. }
  10656. if m.organization_id != nil {
  10657. fields = append(fields, contact.FieldOrganizationID)
  10658. }
  10659. if m.ctype != nil {
  10660. fields = append(fields, contact.FieldCtype)
  10661. }
  10662. if m.cage != nil {
  10663. fields = append(fields, contact.FieldCage)
  10664. }
  10665. if m.cname != nil {
  10666. fields = append(fields, contact.FieldCname)
  10667. }
  10668. if m.carea != nil {
  10669. fields = append(fields, contact.FieldCarea)
  10670. }
  10671. if m.cbirthday != nil {
  10672. fields = append(fields, contact.FieldCbirthday)
  10673. }
  10674. if m.cbirtharea != nil {
  10675. fields = append(fields, contact.FieldCbirtharea)
  10676. }
  10677. if m.cidcard_no != nil {
  10678. fields = append(fields, contact.FieldCidcardNo)
  10679. }
  10680. if m.ctitle != nil {
  10681. fields = append(fields, contact.FieldCtitle)
  10682. }
  10683. if m.cc != nil {
  10684. fields = append(fields, contact.FieldCc)
  10685. }
  10686. if m.phone != nil {
  10687. fields = append(fields, contact.FieldPhone)
  10688. }
  10689. return fields
  10690. }
  10691. // Field returns the value of a field with the given name. The second boolean
  10692. // return value indicates that this field was not set, or was not defined in the
  10693. // schema.
  10694. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10695. switch name {
  10696. case contact.FieldCreatedAt:
  10697. return m.CreatedAt()
  10698. case contact.FieldUpdatedAt:
  10699. return m.UpdatedAt()
  10700. case contact.FieldStatus:
  10701. return m.Status()
  10702. case contact.FieldDeletedAt:
  10703. return m.DeletedAt()
  10704. case contact.FieldWxWxid:
  10705. return m.WxWxid()
  10706. case contact.FieldType:
  10707. return m.GetType()
  10708. case contact.FieldWxid:
  10709. return m.Wxid()
  10710. case contact.FieldAccount:
  10711. return m.Account()
  10712. case contact.FieldNickname:
  10713. return m.Nickname()
  10714. case contact.FieldMarkname:
  10715. return m.Markname()
  10716. case contact.FieldHeadimg:
  10717. return m.Headimg()
  10718. case contact.FieldSex:
  10719. return m.Sex()
  10720. case contact.FieldStarrole:
  10721. return m.Starrole()
  10722. case contact.FieldDontseeit:
  10723. return m.Dontseeit()
  10724. case contact.FieldDontseeme:
  10725. return m.Dontseeme()
  10726. case contact.FieldLag:
  10727. return m.Lag()
  10728. case contact.FieldGid:
  10729. return m.Gid()
  10730. case contact.FieldGname:
  10731. return m.Gname()
  10732. case contact.FieldV3:
  10733. return m.V3()
  10734. case contact.FieldOrganizationID:
  10735. return m.OrganizationID()
  10736. case contact.FieldCtype:
  10737. return m.Ctype()
  10738. case contact.FieldCage:
  10739. return m.Cage()
  10740. case contact.FieldCname:
  10741. return m.Cname()
  10742. case contact.FieldCarea:
  10743. return m.Carea()
  10744. case contact.FieldCbirthday:
  10745. return m.Cbirthday()
  10746. case contact.FieldCbirtharea:
  10747. return m.Cbirtharea()
  10748. case contact.FieldCidcardNo:
  10749. return m.CidcardNo()
  10750. case contact.FieldCtitle:
  10751. return m.Ctitle()
  10752. case contact.FieldCc:
  10753. return m.Cc()
  10754. case contact.FieldPhone:
  10755. return m.Phone()
  10756. }
  10757. return nil, false
  10758. }
  10759. // OldField returns the old value of the field from the database. An error is
  10760. // returned if the mutation operation is not UpdateOne, or the query to the
  10761. // database failed.
  10762. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10763. switch name {
  10764. case contact.FieldCreatedAt:
  10765. return m.OldCreatedAt(ctx)
  10766. case contact.FieldUpdatedAt:
  10767. return m.OldUpdatedAt(ctx)
  10768. case contact.FieldStatus:
  10769. return m.OldStatus(ctx)
  10770. case contact.FieldDeletedAt:
  10771. return m.OldDeletedAt(ctx)
  10772. case contact.FieldWxWxid:
  10773. return m.OldWxWxid(ctx)
  10774. case contact.FieldType:
  10775. return m.OldType(ctx)
  10776. case contact.FieldWxid:
  10777. return m.OldWxid(ctx)
  10778. case contact.FieldAccount:
  10779. return m.OldAccount(ctx)
  10780. case contact.FieldNickname:
  10781. return m.OldNickname(ctx)
  10782. case contact.FieldMarkname:
  10783. return m.OldMarkname(ctx)
  10784. case contact.FieldHeadimg:
  10785. return m.OldHeadimg(ctx)
  10786. case contact.FieldSex:
  10787. return m.OldSex(ctx)
  10788. case contact.FieldStarrole:
  10789. return m.OldStarrole(ctx)
  10790. case contact.FieldDontseeit:
  10791. return m.OldDontseeit(ctx)
  10792. case contact.FieldDontseeme:
  10793. return m.OldDontseeme(ctx)
  10794. case contact.FieldLag:
  10795. return m.OldLag(ctx)
  10796. case contact.FieldGid:
  10797. return m.OldGid(ctx)
  10798. case contact.FieldGname:
  10799. return m.OldGname(ctx)
  10800. case contact.FieldV3:
  10801. return m.OldV3(ctx)
  10802. case contact.FieldOrganizationID:
  10803. return m.OldOrganizationID(ctx)
  10804. case contact.FieldCtype:
  10805. return m.OldCtype(ctx)
  10806. case contact.FieldCage:
  10807. return m.OldCage(ctx)
  10808. case contact.FieldCname:
  10809. return m.OldCname(ctx)
  10810. case contact.FieldCarea:
  10811. return m.OldCarea(ctx)
  10812. case contact.FieldCbirthday:
  10813. return m.OldCbirthday(ctx)
  10814. case contact.FieldCbirtharea:
  10815. return m.OldCbirtharea(ctx)
  10816. case contact.FieldCidcardNo:
  10817. return m.OldCidcardNo(ctx)
  10818. case contact.FieldCtitle:
  10819. return m.OldCtitle(ctx)
  10820. case contact.FieldCc:
  10821. return m.OldCc(ctx)
  10822. case contact.FieldPhone:
  10823. return m.OldPhone(ctx)
  10824. }
  10825. return nil, fmt.Errorf("unknown Contact field %s", name)
  10826. }
  10827. // SetField sets the value of a field with the given name. It returns an error if
  10828. // the field is not defined in the schema, or if the type mismatched the field
  10829. // type.
  10830. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10831. switch name {
  10832. case contact.FieldCreatedAt:
  10833. v, ok := value.(time.Time)
  10834. if !ok {
  10835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10836. }
  10837. m.SetCreatedAt(v)
  10838. return nil
  10839. case contact.FieldUpdatedAt:
  10840. v, ok := value.(time.Time)
  10841. if !ok {
  10842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10843. }
  10844. m.SetUpdatedAt(v)
  10845. return nil
  10846. case contact.FieldStatus:
  10847. v, ok := value.(uint8)
  10848. if !ok {
  10849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10850. }
  10851. m.SetStatus(v)
  10852. return nil
  10853. case contact.FieldDeletedAt:
  10854. v, ok := value.(time.Time)
  10855. if !ok {
  10856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10857. }
  10858. m.SetDeletedAt(v)
  10859. return nil
  10860. case contact.FieldWxWxid:
  10861. v, ok := value.(string)
  10862. if !ok {
  10863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10864. }
  10865. m.SetWxWxid(v)
  10866. return nil
  10867. case contact.FieldType:
  10868. v, ok := value.(int)
  10869. if !ok {
  10870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10871. }
  10872. m.SetType(v)
  10873. return nil
  10874. case contact.FieldWxid:
  10875. v, ok := value.(string)
  10876. if !ok {
  10877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10878. }
  10879. m.SetWxid(v)
  10880. return nil
  10881. case contact.FieldAccount:
  10882. v, ok := value.(string)
  10883. if !ok {
  10884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10885. }
  10886. m.SetAccount(v)
  10887. return nil
  10888. case contact.FieldNickname:
  10889. v, ok := value.(string)
  10890. if !ok {
  10891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10892. }
  10893. m.SetNickname(v)
  10894. return nil
  10895. case contact.FieldMarkname:
  10896. v, ok := value.(string)
  10897. if !ok {
  10898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10899. }
  10900. m.SetMarkname(v)
  10901. return nil
  10902. case contact.FieldHeadimg:
  10903. v, ok := value.(string)
  10904. if !ok {
  10905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10906. }
  10907. m.SetHeadimg(v)
  10908. return nil
  10909. case contact.FieldSex:
  10910. v, ok := value.(int)
  10911. if !ok {
  10912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10913. }
  10914. m.SetSex(v)
  10915. return nil
  10916. case contact.FieldStarrole:
  10917. v, ok := value.(string)
  10918. if !ok {
  10919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10920. }
  10921. m.SetStarrole(v)
  10922. return nil
  10923. case contact.FieldDontseeit:
  10924. v, ok := value.(int)
  10925. if !ok {
  10926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10927. }
  10928. m.SetDontseeit(v)
  10929. return nil
  10930. case contact.FieldDontseeme:
  10931. v, ok := value.(int)
  10932. if !ok {
  10933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10934. }
  10935. m.SetDontseeme(v)
  10936. return nil
  10937. case contact.FieldLag:
  10938. v, ok := value.(string)
  10939. if !ok {
  10940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10941. }
  10942. m.SetLag(v)
  10943. return nil
  10944. case contact.FieldGid:
  10945. v, ok := value.(string)
  10946. if !ok {
  10947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10948. }
  10949. m.SetGid(v)
  10950. return nil
  10951. case contact.FieldGname:
  10952. v, ok := value.(string)
  10953. if !ok {
  10954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10955. }
  10956. m.SetGname(v)
  10957. return nil
  10958. case contact.FieldV3:
  10959. v, ok := value.(string)
  10960. if !ok {
  10961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10962. }
  10963. m.SetV3(v)
  10964. return nil
  10965. case contact.FieldOrganizationID:
  10966. v, ok := value.(uint64)
  10967. if !ok {
  10968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10969. }
  10970. m.SetOrganizationID(v)
  10971. return nil
  10972. case contact.FieldCtype:
  10973. v, ok := value.(uint64)
  10974. if !ok {
  10975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10976. }
  10977. m.SetCtype(v)
  10978. return nil
  10979. case contact.FieldCage:
  10980. v, ok := value.(int)
  10981. if !ok {
  10982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10983. }
  10984. m.SetCage(v)
  10985. return nil
  10986. case contact.FieldCname:
  10987. v, ok := value.(string)
  10988. if !ok {
  10989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10990. }
  10991. m.SetCname(v)
  10992. return nil
  10993. case contact.FieldCarea:
  10994. v, ok := value.(string)
  10995. if !ok {
  10996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10997. }
  10998. m.SetCarea(v)
  10999. return nil
  11000. case contact.FieldCbirthday:
  11001. v, ok := value.(string)
  11002. if !ok {
  11003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11004. }
  11005. m.SetCbirthday(v)
  11006. return nil
  11007. case contact.FieldCbirtharea:
  11008. v, ok := value.(string)
  11009. if !ok {
  11010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11011. }
  11012. m.SetCbirtharea(v)
  11013. return nil
  11014. case contact.FieldCidcardNo:
  11015. v, ok := value.(string)
  11016. if !ok {
  11017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11018. }
  11019. m.SetCidcardNo(v)
  11020. return nil
  11021. case contact.FieldCtitle:
  11022. v, ok := value.(string)
  11023. if !ok {
  11024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11025. }
  11026. m.SetCtitle(v)
  11027. return nil
  11028. case contact.FieldCc:
  11029. v, ok := value.(string)
  11030. if !ok {
  11031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11032. }
  11033. m.SetCc(v)
  11034. return nil
  11035. case contact.FieldPhone:
  11036. v, ok := value.(string)
  11037. if !ok {
  11038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11039. }
  11040. m.SetPhone(v)
  11041. return nil
  11042. }
  11043. return fmt.Errorf("unknown Contact field %s", name)
  11044. }
  11045. // AddedFields returns all numeric fields that were incremented/decremented during
  11046. // this mutation.
  11047. func (m *ContactMutation) AddedFields() []string {
  11048. var fields []string
  11049. if m.addstatus != nil {
  11050. fields = append(fields, contact.FieldStatus)
  11051. }
  11052. if m.add_type != nil {
  11053. fields = append(fields, contact.FieldType)
  11054. }
  11055. if m.addsex != nil {
  11056. fields = append(fields, contact.FieldSex)
  11057. }
  11058. if m.adddontseeit != nil {
  11059. fields = append(fields, contact.FieldDontseeit)
  11060. }
  11061. if m.adddontseeme != nil {
  11062. fields = append(fields, contact.FieldDontseeme)
  11063. }
  11064. if m.addorganization_id != nil {
  11065. fields = append(fields, contact.FieldOrganizationID)
  11066. }
  11067. if m.addctype != nil {
  11068. fields = append(fields, contact.FieldCtype)
  11069. }
  11070. if m.addcage != nil {
  11071. fields = append(fields, contact.FieldCage)
  11072. }
  11073. return fields
  11074. }
  11075. // AddedField returns the numeric value that was incremented/decremented on a field
  11076. // with the given name. The second boolean return value indicates that this field
  11077. // was not set, or was not defined in the schema.
  11078. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11079. switch name {
  11080. case contact.FieldStatus:
  11081. return m.AddedStatus()
  11082. case contact.FieldType:
  11083. return m.AddedType()
  11084. case contact.FieldSex:
  11085. return m.AddedSex()
  11086. case contact.FieldDontseeit:
  11087. return m.AddedDontseeit()
  11088. case contact.FieldDontseeme:
  11089. return m.AddedDontseeme()
  11090. case contact.FieldOrganizationID:
  11091. return m.AddedOrganizationID()
  11092. case contact.FieldCtype:
  11093. return m.AddedCtype()
  11094. case contact.FieldCage:
  11095. return m.AddedCage()
  11096. }
  11097. return nil, false
  11098. }
  11099. // AddField adds the value to the field with the given name. It returns an error if
  11100. // the field is not defined in the schema, or if the type mismatched the field
  11101. // type.
  11102. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11103. switch name {
  11104. case contact.FieldStatus:
  11105. v, ok := value.(int8)
  11106. if !ok {
  11107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11108. }
  11109. m.AddStatus(v)
  11110. return nil
  11111. case contact.FieldType:
  11112. v, ok := value.(int)
  11113. if !ok {
  11114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11115. }
  11116. m.AddType(v)
  11117. return nil
  11118. case contact.FieldSex:
  11119. v, ok := value.(int)
  11120. if !ok {
  11121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11122. }
  11123. m.AddSex(v)
  11124. return nil
  11125. case contact.FieldDontseeit:
  11126. v, ok := value.(int)
  11127. if !ok {
  11128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11129. }
  11130. m.AddDontseeit(v)
  11131. return nil
  11132. case contact.FieldDontseeme:
  11133. v, ok := value.(int)
  11134. if !ok {
  11135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11136. }
  11137. m.AddDontseeme(v)
  11138. return nil
  11139. case contact.FieldOrganizationID:
  11140. v, ok := value.(int64)
  11141. if !ok {
  11142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11143. }
  11144. m.AddOrganizationID(v)
  11145. return nil
  11146. case contact.FieldCtype:
  11147. v, ok := value.(int64)
  11148. if !ok {
  11149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11150. }
  11151. m.AddCtype(v)
  11152. return nil
  11153. case contact.FieldCage:
  11154. v, ok := value.(int)
  11155. if !ok {
  11156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11157. }
  11158. m.AddCage(v)
  11159. return nil
  11160. }
  11161. return fmt.Errorf("unknown Contact numeric field %s", name)
  11162. }
  11163. // ClearedFields returns all nullable fields that were cleared during this
  11164. // mutation.
  11165. func (m *ContactMutation) ClearedFields() []string {
  11166. var fields []string
  11167. if m.FieldCleared(contact.FieldStatus) {
  11168. fields = append(fields, contact.FieldStatus)
  11169. }
  11170. if m.FieldCleared(contact.FieldDeletedAt) {
  11171. fields = append(fields, contact.FieldDeletedAt)
  11172. }
  11173. if m.FieldCleared(contact.FieldType) {
  11174. fields = append(fields, contact.FieldType)
  11175. }
  11176. if m.FieldCleared(contact.FieldOrganizationID) {
  11177. fields = append(fields, contact.FieldOrganizationID)
  11178. }
  11179. return fields
  11180. }
  11181. // FieldCleared returns a boolean indicating if a field with the given name was
  11182. // cleared in this mutation.
  11183. func (m *ContactMutation) FieldCleared(name string) bool {
  11184. _, ok := m.clearedFields[name]
  11185. return ok
  11186. }
  11187. // ClearField clears the value of the field with the given name. It returns an
  11188. // error if the field is not defined in the schema.
  11189. func (m *ContactMutation) ClearField(name string) error {
  11190. switch name {
  11191. case contact.FieldStatus:
  11192. m.ClearStatus()
  11193. return nil
  11194. case contact.FieldDeletedAt:
  11195. m.ClearDeletedAt()
  11196. return nil
  11197. case contact.FieldType:
  11198. m.ClearType()
  11199. return nil
  11200. case contact.FieldOrganizationID:
  11201. m.ClearOrganizationID()
  11202. return nil
  11203. }
  11204. return fmt.Errorf("unknown Contact nullable field %s", name)
  11205. }
  11206. // ResetField resets all changes in the mutation for the field with the given name.
  11207. // It returns an error if the field is not defined in the schema.
  11208. func (m *ContactMutation) ResetField(name string) error {
  11209. switch name {
  11210. case contact.FieldCreatedAt:
  11211. m.ResetCreatedAt()
  11212. return nil
  11213. case contact.FieldUpdatedAt:
  11214. m.ResetUpdatedAt()
  11215. return nil
  11216. case contact.FieldStatus:
  11217. m.ResetStatus()
  11218. return nil
  11219. case contact.FieldDeletedAt:
  11220. m.ResetDeletedAt()
  11221. return nil
  11222. case contact.FieldWxWxid:
  11223. m.ResetWxWxid()
  11224. return nil
  11225. case contact.FieldType:
  11226. m.ResetType()
  11227. return nil
  11228. case contact.FieldWxid:
  11229. m.ResetWxid()
  11230. return nil
  11231. case contact.FieldAccount:
  11232. m.ResetAccount()
  11233. return nil
  11234. case contact.FieldNickname:
  11235. m.ResetNickname()
  11236. return nil
  11237. case contact.FieldMarkname:
  11238. m.ResetMarkname()
  11239. return nil
  11240. case contact.FieldHeadimg:
  11241. m.ResetHeadimg()
  11242. return nil
  11243. case contact.FieldSex:
  11244. m.ResetSex()
  11245. return nil
  11246. case contact.FieldStarrole:
  11247. m.ResetStarrole()
  11248. return nil
  11249. case contact.FieldDontseeit:
  11250. m.ResetDontseeit()
  11251. return nil
  11252. case contact.FieldDontseeme:
  11253. m.ResetDontseeme()
  11254. return nil
  11255. case contact.FieldLag:
  11256. m.ResetLag()
  11257. return nil
  11258. case contact.FieldGid:
  11259. m.ResetGid()
  11260. return nil
  11261. case contact.FieldGname:
  11262. m.ResetGname()
  11263. return nil
  11264. case contact.FieldV3:
  11265. m.ResetV3()
  11266. return nil
  11267. case contact.FieldOrganizationID:
  11268. m.ResetOrganizationID()
  11269. return nil
  11270. case contact.FieldCtype:
  11271. m.ResetCtype()
  11272. return nil
  11273. case contact.FieldCage:
  11274. m.ResetCage()
  11275. return nil
  11276. case contact.FieldCname:
  11277. m.ResetCname()
  11278. return nil
  11279. case contact.FieldCarea:
  11280. m.ResetCarea()
  11281. return nil
  11282. case contact.FieldCbirthday:
  11283. m.ResetCbirthday()
  11284. return nil
  11285. case contact.FieldCbirtharea:
  11286. m.ResetCbirtharea()
  11287. return nil
  11288. case contact.FieldCidcardNo:
  11289. m.ResetCidcardNo()
  11290. return nil
  11291. case contact.FieldCtitle:
  11292. m.ResetCtitle()
  11293. return nil
  11294. case contact.FieldCc:
  11295. m.ResetCc()
  11296. return nil
  11297. case contact.FieldPhone:
  11298. m.ResetPhone()
  11299. return nil
  11300. }
  11301. return fmt.Errorf("unknown Contact field %s", name)
  11302. }
  11303. // AddedEdges returns all edge names that were set/added in this mutation.
  11304. func (m *ContactMutation) AddedEdges() []string {
  11305. edges := make([]string, 0, 2)
  11306. if m.contact_relationships != nil {
  11307. edges = append(edges, contact.EdgeContactRelationships)
  11308. }
  11309. if m.contact_messages != nil {
  11310. edges = append(edges, contact.EdgeContactMessages)
  11311. }
  11312. return edges
  11313. }
  11314. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11315. // name in this mutation.
  11316. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11317. switch name {
  11318. case contact.EdgeContactRelationships:
  11319. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11320. for id := range m.contact_relationships {
  11321. ids = append(ids, id)
  11322. }
  11323. return ids
  11324. case contact.EdgeContactMessages:
  11325. ids := make([]ent.Value, 0, len(m.contact_messages))
  11326. for id := range m.contact_messages {
  11327. ids = append(ids, id)
  11328. }
  11329. return ids
  11330. }
  11331. return nil
  11332. }
  11333. // RemovedEdges returns all edge names that were removed in this mutation.
  11334. func (m *ContactMutation) RemovedEdges() []string {
  11335. edges := make([]string, 0, 2)
  11336. if m.removedcontact_relationships != nil {
  11337. edges = append(edges, contact.EdgeContactRelationships)
  11338. }
  11339. if m.removedcontact_messages != nil {
  11340. edges = append(edges, contact.EdgeContactMessages)
  11341. }
  11342. return edges
  11343. }
  11344. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11345. // the given name in this mutation.
  11346. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11347. switch name {
  11348. case contact.EdgeContactRelationships:
  11349. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11350. for id := range m.removedcontact_relationships {
  11351. ids = append(ids, id)
  11352. }
  11353. return ids
  11354. case contact.EdgeContactMessages:
  11355. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11356. for id := range m.removedcontact_messages {
  11357. ids = append(ids, id)
  11358. }
  11359. return ids
  11360. }
  11361. return nil
  11362. }
  11363. // ClearedEdges returns all edge names that were cleared in this mutation.
  11364. func (m *ContactMutation) ClearedEdges() []string {
  11365. edges := make([]string, 0, 2)
  11366. if m.clearedcontact_relationships {
  11367. edges = append(edges, contact.EdgeContactRelationships)
  11368. }
  11369. if m.clearedcontact_messages {
  11370. edges = append(edges, contact.EdgeContactMessages)
  11371. }
  11372. return edges
  11373. }
  11374. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11375. // was cleared in this mutation.
  11376. func (m *ContactMutation) EdgeCleared(name string) bool {
  11377. switch name {
  11378. case contact.EdgeContactRelationships:
  11379. return m.clearedcontact_relationships
  11380. case contact.EdgeContactMessages:
  11381. return m.clearedcontact_messages
  11382. }
  11383. return false
  11384. }
  11385. // ClearEdge clears the value of the edge with the given name. It returns an error
  11386. // if that edge is not defined in the schema.
  11387. func (m *ContactMutation) ClearEdge(name string) error {
  11388. switch name {
  11389. }
  11390. return fmt.Errorf("unknown Contact unique edge %s", name)
  11391. }
  11392. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11393. // It returns an error if the edge is not defined in the schema.
  11394. func (m *ContactMutation) ResetEdge(name string) error {
  11395. switch name {
  11396. case contact.EdgeContactRelationships:
  11397. m.ResetContactRelationships()
  11398. return nil
  11399. case contact.EdgeContactMessages:
  11400. m.ResetContactMessages()
  11401. return nil
  11402. }
  11403. return fmt.Errorf("unknown Contact edge %s", name)
  11404. }
  11405. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11406. type CreditBalanceMutation struct {
  11407. config
  11408. op Op
  11409. typ string
  11410. id *uint64
  11411. created_at *time.Time
  11412. updated_at *time.Time
  11413. deleted_at *time.Time
  11414. user_id *string
  11415. balance *float32
  11416. addbalance *float32
  11417. status *int
  11418. addstatus *int
  11419. organization_id *uint64
  11420. addorganization_id *int64
  11421. clearedFields map[string]struct{}
  11422. done bool
  11423. oldValue func(context.Context) (*CreditBalance, error)
  11424. predicates []predicate.CreditBalance
  11425. }
  11426. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11427. // creditbalanceOption allows management of the mutation configuration using functional options.
  11428. type creditbalanceOption func(*CreditBalanceMutation)
  11429. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11430. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11431. m := &CreditBalanceMutation{
  11432. config: c,
  11433. op: op,
  11434. typ: TypeCreditBalance,
  11435. clearedFields: make(map[string]struct{}),
  11436. }
  11437. for _, opt := range opts {
  11438. opt(m)
  11439. }
  11440. return m
  11441. }
  11442. // withCreditBalanceID sets the ID field of the mutation.
  11443. func withCreditBalanceID(id uint64) creditbalanceOption {
  11444. return func(m *CreditBalanceMutation) {
  11445. var (
  11446. err error
  11447. once sync.Once
  11448. value *CreditBalance
  11449. )
  11450. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11451. once.Do(func() {
  11452. if m.done {
  11453. err = errors.New("querying old values post mutation is not allowed")
  11454. } else {
  11455. value, err = m.Client().CreditBalance.Get(ctx, id)
  11456. }
  11457. })
  11458. return value, err
  11459. }
  11460. m.id = &id
  11461. }
  11462. }
  11463. // withCreditBalance sets the old CreditBalance of the mutation.
  11464. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11465. return func(m *CreditBalanceMutation) {
  11466. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11467. return node, nil
  11468. }
  11469. m.id = &node.ID
  11470. }
  11471. }
  11472. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11473. // executed in a transaction (ent.Tx), a transactional client is returned.
  11474. func (m CreditBalanceMutation) Client() *Client {
  11475. client := &Client{config: m.config}
  11476. client.init()
  11477. return client
  11478. }
  11479. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11480. // it returns an error otherwise.
  11481. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11482. if _, ok := m.driver.(*txDriver); !ok {
  11483. return nil, errors.New("ent: mutation is not running in a transaction")
  11484. }
  11485. tx := &Tx{config: m.config}
  11486. tx.init()
  11487. return tx, nil
  11488. }
  11489. // SetID sets the value of the id field. Note that this
  11490. // operation is only accepted on creation of CreditBalance entities.
  11491. func (m *CreditBalanceMutation) SetID(id uint64) {
  11492. m.id = &id
  11493. }
  11494. // ID returns the ID value in the mutation. Note that the ID is only available
  11495. // if it was provided to the builder or after it was returned from the database.
  11496. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11497. if m.id == nil {
  11498. return
  11499. }
  11500. return *m.id, true
  11501. }
  11502. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11503. // That means, if the mutation is applied within a transaction with an isolation level such
  11504. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11505. // or updated by the mutation.
  11506. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11507. switch {
  11508. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11509. id, exists := m.ID()
  11510. if exists {
  11511. return []uint64{id}, nil
  11512. }
  11513. fallthrough
  11514. case m.op.Is(OpUpdate | OpDelete):
  11515. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11516. default:
  11517. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11518. }
  11519. }
  11520. // SetCreatedAt sets the "created_at" field.
  11521. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11522. m.created_at = &t
  11523. }
  11524. // CreatedAt returns the value of the "created_at" field in the mutation.
  11525. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11526. v := m.created_at
  11527. if v == nil {
  11528. return
  11529. }
  11530. return *v, true
  11531. }
  11532. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11533. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11535. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11536. if !m.op.Is(OpUpdateOne) {
  11537. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11538. }
  11539. if m.id == nil || m.oldValue == nil {
  11540. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11541. }
  11542. oldValue, err := m.oldValue(ctx)
  11543. if err != nil {
  11544. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11545. }
  11546. return oldValue.CreatedAt, nil
  11547. }
  11548. // ResetCreatedAt resets all changes to the "created_at" field.
  11549. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11550. m.created_at = nil
  11551. }
  11552. // SetUpdatedAt sets the "updated_at" field.
  11553. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11554. m.updated_at = &t
  11555. }
  11556. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11557. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11558. v := m.updated_at
  11559. if v == nil {
  11560. return
  11561. }
  11562. return *v, true
  11563. }
  11564. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11565. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11567. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11568. if !m.op.Is(OpUpdateOne) {
  11569. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11570. }
  11571. if m.id == nil || m.oldValue == nil {
  11572. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11573. }
  11574. oldValue, err := m.oldValue(ctx)
  11575. if err != nil {
  11576. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11577. }
  11578. return oldValue.UpdatedAt, nil
  11579. }
  11580. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11581. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11582. m.updated_at = nil
  11583. }
  11584. // SetDeletedAt sets the "deleted_at" field.
  11585. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11586. m.deleted_at = &t
  11587. }
  11588. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11589. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11590. v := m.deleted_at
  11591. if v == nil {
  11592. return
  11593. }
  11594. return *v, true
  11595. }
  11596. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11597. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11599. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11600. if !m.op.Is(OpUpdateOne) {
  11601. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11602. }
  11603. if m.id == nil || m.oldValue == nil {
  11604. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11605. }
  11606. oldValue, err := m.oldValue(ctx)
  11607. if err != nil {
  11608. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11609. }
  11610. return oldValue.DeletedAt, nil
  11611. }
  11612. // ClearDeletedAt clears the value of the "deleted_at" field.
  11613. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11614. m.deleted_at = nil
  11615. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11616. }
  11617. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11618. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11619. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11620. return ok
  11621. }
  11622. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11623. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11624. m.deleted_at = nil
  11625. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11626. }
  11627. // SetUserID sets the "user_id" field.
  11628. func (m *CreditBalanceMutation) SetUserID(s string) {
  11629. m.user_id = &s
  11630. }
  11631. // UserID returns the value of the "user_id" field in the mutation.
  11632. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11633. v := m.user_id
  11634. if v == nil {
  11635. return
  11636. }
  11637. return *v, true
  11638. }
  11639. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11640. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11642. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11643. if !m.op.Is(OpUpdateOne) {
  11644. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11645. }
  11646. if m.id == nil || m.oldValue == nil {
  11647. return v, errors.New("OldUserID requires an ID field in the mutation")
  11648. }
  11649. oldValue, err := m.oldValue(ctx)
  11650. if err != nil {
  11651. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11652. }
  11653. return oldValue.UserID, nil
  11654. }
  11655. // ClearUserID clears the value of the "user_id" field.
  11656. func (m *CreditBalanceMutation) ClearUserID() {
  11657. m.user_id = nil
  11658. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11659. }
  11660. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11661. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11662. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11663. return ok
  11664. }
  11665. // ResetUserID resets all changes to the "user_id" field.
  11666. func (m *CreditBalanceMutation) ResetUserID() {
  11667. m.user_id = nil
  11668. delete(m.clearedFields, creditbalance.FieldUserID)
  11669. }
  11670. // SetBalance sets the "balance" field.
  11671. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11672. m.balance = &f
  11673. m.addbalance = nil
  11674. }
  11675. // Balance returns the value of the "balance" field in the mutation.
  11676. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11677. v := m.balance
  11678. if v == nil {
  11679. return
  11680. }
  11681. return *v, true
  11682. }
  11683. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11684. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11686. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11687. if !m.op.Is(OpUpdateOne) {
  11688. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11689. }
  11690. if m.id == nil || m.oldValue == nil {
  11691. return v, errors.New("OldBalance requires an ID field in the mutation")
  11692. }
  11693. oldValue, err := m.oldValue(ctx)
  11694. if err != nil {
  11695. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11696. }
  11697. return oldValue.Balance, nil
  11698. }
  11699. // AddBalance adds f to the "balance" field.
  11700. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11701. if m.addbalance != nil {
  11702. *m.addbalance += f
  11703. } else {
  11704. m.addbalance = &f
  11705. }
  11706. }
  11707. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11708. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11709. v := m.addbalance
  11710. if v == nil {
  11711. return
  11712. }
  11713. return *v, true
  11714. }
  11715. // ResetBalance resets all changes to the "balance" field.
  11716. func (m *CreditBalanceMutation) ResetBalance() {
  11717. m.balance = nil
  11718. m.addbalance = nil
  11719. }
  11720. // SetStatus sets the "status" field.
  11721. func (m *CreditBalanceMutation) SetStatus(i int) {
  11722. m.status = &i
  11723. m.addstatus = nil
  11724. }
  11725. // Status returns the value of the "status" field in the mutation.
  11726. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11727. v := m.status
  11728. if v == nil {
  11729. return
  11730. }
  11731. return *v, true
  11732. }
  11733. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11734. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11736. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11737. if !m.op.Is(OpUpdateOne) {
  11738. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11739. }
  11740. if m.id == nil || m.oldValue == nil {
  11741. return v, errors.New("OldStatus requires an ID field in the mutation")
  11742. }
  11743. oldValue, err := m.oldValue(ctx)
  11744. if err != nil {
  11745. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11746. }
  11747. return oldValue.Status, nil
  11748. }
  11749. // AddStatus adds i to the "status" field.
  11750. func (m *CreditBalanceMutation) AddStatus(i int) {
  11751. if m.addstatus != nil {
  11752. *m.addstatus += i
  11753. } else {
  11754. m.addstatus = &i
  11755. }
  11756. }
  11757. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11758. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11759. v := m.addstatus
  11760. if v == nil {
  11761. return
  11762. }
  11763. return *v, true
  11764. }
  11765. // ClearStatus clears the value of the "status" field.
  11766. func (m *CreditBalanceMutation) ClearStatus() {
  11767. m.status = nil
  11768. m.addstatus = nil
  11769. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11770. }
  11771. // StatusCleared returns if the "status" field was cleared in this mutation.
  11772. func (m *CreditBalanceMutation) StatusCleared() bool {
  11773. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11774. return ok
  11775. }
  11776. // ResetStatus resets all changes to the "status" field.
  11777. func (m *CreditBalanceMutation) ResetStatus() {
  11778. m.status = nil
  11779. m.addstatus = nil
  11780. delete(m.clearedFields, creditbalance.FieldStatus)
  11781. }
  11782. // SetOrganizationID sets the "organization_id" field.
  11783. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11784. m.organization_id = &u
  11785. m.addorganization_id = nil
  11786. }
  11787. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11788. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11789. v := m.organization_id
  11790. if v == nil {
  11791. return
  11792. }
  11793. return *v, true
  11794. }
  11795. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11796. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11798. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11799. if !m.op.Is(OpUpdateOne) {
  11800. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11801. }
  11802. if m.id == nil || m.oldValue == nil {
  11803. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11804. }
  11805. oldValue, err := m.oldValue(ctx)
  11806. if err != nil {
  11807. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11808. }
  11809. return oldValue.OrganizationID, nil
  11810. }
  11811. // AddOrganizationID adds u to the "organization_id" field.
  11812. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11813. if m.addorganization_id != nil {
  11814. *m.addorganization_id += u
  11815. } else {
  11816. m.addorganization_id = &u
  11817. }
  11818. }
  11819. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11820. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11821. v := m.addorganization_id
  11822. if v == nil {
  11823. return
  11824. }
  11825. return *v, true
  11826. }
  11827. // ClearOrganizationID clears the value of the "organization_id" field.
  11828. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11829. m.organization_id = nil
  11830. m.addorganization_id = nil
  11831. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11832. }
  11833. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11834. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11835. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11836. return ok
  11837. }
  11838. // ResetOrganizationID resets all changes to the "organization_id" field.
  11839. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11840. m.organization_id = nil
  11841. m.addorganization_id = nil
  11842. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11843. }
  11844. // Where appends a list predicates to the CreditBalanceMutation builder.
  11845. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11846. m.predicates = append(m.predicates, ps...)
  11847. }
  11848. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11849. // users can use type-assertion to append predicates that do not depend on any generated package.
  11850. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11851. p := make([]predicate.CreditBalance, len(ps))
  11852. for i := range ps {
  11853. p[i] = ps[i]
  11854. }
  11855. m.Where(p...)
  11856. }
  11857. // Op returns the operation name.
  11858. func (m *CreditBalanceMutation) Op() Op {
  11859. return m.op
  11860. }
  11861. // SetOp allows setting the mutation operation.
  11862. func (m *CreditBalanceMutation) SetOp(op Op) {
  11863. m.op = op
  11864. }
  11865. // Type returns the node type of this mutation (CreditBalance).
  11866. func (m *CreditBalanceMutation) Type() string {
  11867. return m.typ
  11868. }
  11869. // Fields returns all fields that were changed during this mutation. Note that in
  11870. // order to get all numeric fields that were incremented/decremented, call
  11871. // AddedFields().
  11872. func (m *CreditBalanceMutation) Fields() []string {
  11873. fields := make([]string, 0, 7)
  11874. if m.created_at != nil {
  11875. fields = append(fields, creditbalance.FieldCreatedAt)
  11876. }
  11877. if m.updated_at != nil {
  11878. fields = append(fields, creditbalance.FieldUpdatedAt)
  11879. }
  11880. if m.deleted_at != nil {
  11881. fields = append(fields, creditbalance.FieldDeletedAt)
  11882. }
  11883. if m.user_id != nil {
  11884. fields = append(fields, creditbalance.FieldUserID)
  11885. }
  11886. if m.balance != nil {
  11887. fields = append(fields, creditbalance.FieldBalance)
  11888. }
  11889. if m.status != nil {
  11890. fields = append(fields, creditbalance.FieldStatus)
  11891. }
  11892. if m.organization_id != nil {
  11893. fields = append(fields, creditbalance.FieldOrganizationID)
  11894. }
  11895. return fields
  11896. }
  11897. // Field returns the value of a field with the given name. The second boolean
  11898. // return value indicates that this field was not set, or was not defined in the
  11899. // schema.
  11900. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11901. switch name {
  11902. case creditbalance.FieldCreatedAt:
  11903. return m.CreatedAt()
  11904. case creditbalance.FieldUpdatedAt:
  11905. return m.UpdatedAt()
  11906. case creditbalance.FieldDeletedAt:
  11907. return m.DeletedAt()
  11908. case creditbalance.FieldUserID:
  11909. return m.UserID()
  11910. case creditbalance.FieldBalance:
  11911. return m.Balance()
  11912. case creditbalance.FieldStatus:
  11913. return m.Status()
  11914. case creditbalance.FieldOrganizationID:
  11915. return m.OrganizationID()
  11916. }
  11917. return nil, false
  11918. }
  11919. // OldField returns the old value of the field from the database. An error is
  11920. // returned if the mutation operation is not UpdateOne, or the query to the
  11921. // database failed.
  11922. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11923. switch name {
  11924. case creditbalance.FieldCreatedAt:
  11925. return m.OldCreatedAt(ctx)
  11926. case creditbalance.FieldUpdatedAt:
  11927. return m.OldUpdatedAt(ctx)
  11928. case creditbalance.FieldDeletedAt:
  11929. return m.OldDeletedAt(ctx)
  11930. case creditbalance.FieldUserID:
  11931. return m.OldUserID(ctx)
  11932. case creditbalance.FieldBalance:
  11933. return m.OldBalance(ctx)
  11934. case creditbalance.FieldStatus:
  11935. return m.OldStatus(ctx)
  11936. case creditbalance.FieldOrganizationID:
  11937. return m.OldOrganizationID(ctx)
  11938. }
  11939. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  11940. }
  11941. // SetField sets the value of a field with the given name. It returns an error if
  11942. // the field is not defined in the schema, or if the type mismatched the field
  11943. // type.
  11944. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  11945. switch name {
  11946. case creditbalance.FieldCreatedAt:
  11947. v, ok := value.(time.Time)
  11948. if !ok {
  11949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11950. }
  11951. m.SetCreatedAt(v)
  11952. return nil
  11953. case creditbalance.FieldUpdatedAt:
  11954. v, ok := value.(time.Time)
  11955. if !ok {
  11956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11957. }
  11958. m.SetUpdatedAt(v)
  11959. return nil
  11960. case creditbalance.FieldDeletedAt:
  11961. v, ok := value.(time.Time)
  11962. if !ok {
  11963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11964. }
  11965. m.SetDeletedAt(v)
  11966. return nil
  11967. case creditbalance.FieldUserID:
  11968. v, ok := value.(string)
  11969. if !ok {
  11970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11971. }
  11972. m.SetUserID(v)
  11973. return nil
  11974. case creditbalance.FieldBalance:
  11975. v, ok := value.(float32)
  11976. if !ok {
  11977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11978. }
  11979. m.SetBalance(v)
  11980. return nil
  11981. case creditbalance.FieldStatus:
  11982. v, ok := value.(int)
  11983. if !ok {
  11984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11985. }
  11986. m.SetStatus(v)
  11987. return nil
  11988. case creditbalance.FieldOrganizationID:
  11989. v, ok := value.(uint64)
  11990. if !ok {
  11991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11992. }
  11993. m.SetOrganizationID(v)
  11994. return nil
  11995. }
  11996. return fmt.Errorf("unknown CreditBalance field %s", name)
  11997. }
  11998. // AddedFields returns all numeric fields that were incremented/decremented during
  11999. // this mutation.
  12000. func (m *CreditBalanceMutation) AddedFields() []string {
  12001. var fields []string
  12002. if m.addbalance != nil {
  12003. fields = append(fields, creditbalance.FieldBalance)
  12004. }
  12005. if m.addstatus != nil {
  12006. fields = append(fields, creditbalance.FieldStatus)
  12007. }
  12008. if m.addorganization_id != nil {
  12009. fields = append(fields, creditbalance.FieldOrganizationID)
  12010. }
  12011. return fields
  12012. }
  12013. // AddedField returns the numeric value that was incremented/decremented on a field
  12014. // with the given name. The second boolean return value indicates that this field
  12015. // was not set, or was not defined in the schema.
  12016. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12017. switch name {
  12018. case creditbalance.FieldBalance:
  12019. return m.AddedBalance()
  12020. case creditbalance.FieldStatus:
  12021. return m.AddedStatus()
  12022. case creditbalance.FieldOrganizationID:
  12023. return m.AddedOrganizationID()
  12024. }
  12025. return nil, false
  12026. }
  12027. // AddField adds the value to the field with the given name. It returns an error if
  12028. // the field is not defined in the schema, or if the type mismatched the field
  12029. // type.
  12030. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12031. switch name {
  12032. case creditbalance.FieldBalance:
  12033. v, ok := value.(float32)
  12034. if !ok {
  12035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12036. }
  12037. m.AddBalance(v)
  12038. return nil
  12039. case creditbalance.FieldStatus:
  12040. v, ok := value.(int)
  12041. if !ok {
  12042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12043. }
  12044. m.AddStatus(v)
  12045. return nil
  12046. case creditbalance.FieldOrganizationID:
  12047. v, ok := value.(int64)
  12048. if !ok {
  12049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12050. }
  12051. m.AddOrganizationID(v)
  12052. return nil
  12053. }
  12054. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12055. }
  12056. // ClearedFields returns all nullable fields that were cleared during this
  12057. // mutation.
  12058. func (m *CreditBalanceMutation) ClearedFields() []string {
  12059. var fields []string
  12060. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12061. fields = append(fields, creditbalance.FieldDeletedAt)
  12062. }
  12063. if m.FieldCleared(creditbalance.FieldUserID) {
  12064. fields = append(fields, creditbalance.FieldUserID)
  12065. }
  12066. if m.FieldCleared(creditbalance.FieldStatus) {
  12067. fields = append(fields, creditbalance.FieldStatus)
  12068. }
  12069. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12070. fields = append(fields, creditbalance.FieldOrganizationID)
  12071. }
  12072. return fields
  12073. }
  12074. // FieldCleared returns a boolean indicating if a field with the given name was
  12075. // cleared in this mutation.
  12076. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12077. _, ok := m.clearedFields[name]
  12078. return ok
  12079. }
  12080. // ClearField clears the value of the field with the given name. It returns an
  12081. // error if the field is not defined in the schema.
  12082. func (m *CreditBalanceMutation) ClearField(name string) error {
  12083. switch name {
  12084. case creditbalance.FieldDeletedAt:
  12085. m.ClearDeletedAt()
  12086. return nil
  12087. case creditbalance.FieldUserID:
  12088. m.ClearUserID()
  12089. return nil
  12090. case creditbalance.FieldStatus:
  12091. m.ClearStatus()
  12092. return nil
  12093. case creditbalance.FieldOrganizationID:
  12094. m.ClearOrganizationID()
  12095. return nil
  12096. }
  12097. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12098. }
  12099. // ResetField resets all changes in the mutation for the field with the given name.
  12100. // It returns an error if the field is not defined in the schema.
  12101. func (m *CreditBalanceMutation) ResetField(name string) error {
  12102. switch name {
  12103. case creditbalance.FieldCreatedAt:
  12104. m.ResetCreatedAt()
  12105. return nil
  12106. case creditbalance.FieldUpdatedAt:
  12107. m.ResetUpdatedAt()
  12108. return nil
  12109. case creditbalance.FieldDeletedAt:
  12110. m.ResetDeletedAt()
  12111. return nil
  12112. case creditbalance.FieldUserID:
  12113. m.ResetUserID()
  12114. return nil
  12115. case creditbalance.FieldBalance:
  12116. m.ResetBalance()
  12117. return nil
  12118. case creditbalance.FieldStatus:
  12119. m.ResetStatus()
  12120. return nil
  12121. case creditbalance.FieldOrganizationID:
  12122. m.ResetOrganizationID()
  12123. return nil
  12124. }
  12125. return fmt.Errorf("unknown CreditBalance field %s", name)
  12126. }
  12127. // AddedEdges returns all edge names that were set/added in this mutation.
  12128. func (m *CreditBalanceMutation) AddedEdges() []string {
  12129. edges := make([]string, 0, 0)
  12130. return edges
  12131. }
  12132. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12133. // name in this mutation.
  12134. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12135. return nil
  12136. }
  12137. // RemovedEdges returns all edge names that were removed in this mutation.
  12138. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12139. edges := make([]string, 0, 0)
  12140. return edges
  12141. }
  12142. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12143. // the given name in this mutation.
  12144. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12145. return nil
  12146. }
  12147. // ClearedEdges returns all edge names that were cleared in this mutation.
  12148. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12149. edges := make([]string, 0, 0)
  12150. return edges
  12151. }
  12152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12153. // was cleared in this mutation.
  12154. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12155. return false
  12156. }
  12157. // ClearEdge clears the value of the edge with the given name. It returns an error
  12158. // if that edge is not defined in the schema.
  12159. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12160. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12161. }
  12162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12163. // It returns an error if the edge is not defined in the schema.
  12164. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12165. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12166. }
  12167. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12168. type CreditUsageMutation struct {
  12169. config
  12170. op Op
  12171. typ string
  12172. id *uint64
  12173. created_at *time.Time
  12174. updated_at *time.Time
  12175. deleted_at *time.Time
  12176. user_id *string
  12177. number *float32
  12178. addnumber *float32
  12179. status *int
  12180. addstatus *int
  12181. ntype *int
  12182. addntype *int
  12183. table *string
  12184. organization_id *uint64
  12185. addorganization_id *int64
  12186. nid *uint64
  12187. addnid *int64
  12188. reason *string
  12189. operator *string
  12190. clearedFields map[string]struct{}
  12191. done bool
  12192. oldValue func(context.Context) (*CreditUsage, error)
  12193. predicates []predicate.CreditUsage
  12194. }
  12195. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12196. // creditusageOption allows management of the mutation configuration using functional options.
  12197. type creditusageOption func(*CreditUsageMutation)
  12198. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12199. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12200. m := &CreditUsageMutation{
  12201. config: c,
  12202. op: op,
  12203. typ: TypeCreditUsage,
  12204. clearedFields: make(map[string]struct{}),
  12205. }
  12206. for _, opt := range opts {
  12207. opt(m)
  12208. }
  12209. return m
  12210. }
  12211. // withCreditUsageID sets the ID field of the mutation.
  12212. func withCreditUsageID(id uint64) creditusageOption {
  12213. return func(m *CreditUsageMutation) {
  12214. var (
  12215. err error
  12216. once sync.Once
  12217. value *CreditUsage
  12218. )
  12219. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12220. once.Do(func() {
  12221. if m.done {
  12222. err = errors.New("querying old values post mutation is not allowed")
  12223. } else {
  12224. value, err = m.Client().CreditUsage.Get(ctx, id)
  12225. }
  12226. })
  12227. return value, err
  12228. }
  12229. m.id = &id
  12230. }
  12231. }
  12232. // withCreditUsage sets the old CreditUsage of the mutation.
  12233. func withCreditUsage(node *CreditUsage) creditusageOption {
  12234. return func(m *CreditUsageMutation) {
  12235. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12236. return node, nil
  12237. }
  12238. m.id = &node.ID
  12239. }
  12240. }
  12241. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12242. // executed in a transaction (ent.Tx), a transactional client is returned.
  12243. func (m CreditUsageMutation) Client() *Client {
  12244. client := &Client{config: m.config}
  12245. client.init()
  12246. return client
  12247. }
  12248. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12249. // it returns an error otherwise.
  12250. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12251. if _, ok := m.driver.(*txDriver); !ok {
  12252. return nil, errors.New("ent: mutation is not running in a transaction")
  12253. }
  12254. tx := &Tx{config: m.config}
  12255. tx.init()
  12256. return tx, nil
  12257. }
  12258. // SetID sets the value of the id field. Note that this
  12259. // operation is only accepted on creation of CreditUsage entities.
  12260. func (m *CreditUsageMutation) SetID(id uint64) {
  12261. m.id = &id
  12262. }
  12263. // ID returns the ID value in the mutation. Note that the ID is only available
  12264. // if it was provided to the builder or after it was returned from the database.
  12265. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12266. if m.id == nil {
  12267. return
  12268. }
  12269. return *m.id, true
  12270. }
  12271. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12272. // That means, if the mutation is applied within a transaction with an isolation level such
  12273. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12274. // or updated by the mutation.
  12275. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12276. switch {
  12277. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12278. id, exists := m.ID()
  12279. if exists {
  12280. return []uint64{id}, nil
  12281. }
  12282. fallthrough
  12283. case m.op.Is(OpUpdate | OpDelete):
  12284. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12285. default:
  12286. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12287. }
  12288. }
  12289. // SetCreatedAt sets the "created_at" field.
  12290. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12291. m.created_at = &t
  12292. }
  12293. // CreatedAt returns the value of the "created_at" field in the mutation.
  12294. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12295. v := m.created_at
  12296. if v == nil {
  12297. return
  12298. }
  12299. return *v, true
  12300. }
  12301. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12302. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12304. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12305. if !m.op.Is(OpUpdateOne) {
  12306. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12307. }
  12308. if m.id == nil || m.oldValue == nil {
  12309. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12310. }
  12311. oldValue, err := m.oldValue(ctx)
  12312. if err != nil {
  12313. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12314. }
  12315. return oldValue.CreatedAt, nil
  12316. }
  12317. // ResetCreatedAt resets all changes to the "created_at" field.
  12318. func (m *CreditUsageMutation) ResetCreatedAt() {
  12319. m.created_at = nil
  12320. }
  12321. // SetUpdatedAt sets the "updated_at" field.
  12322. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12323. m.updated_at = &t
  12324. }
  12325. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12326. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12327. v := m.updated_at
  12328. if v == nil {
  12329. return
  12330. }
  12331. return *v, true
  12332. }
  12333. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12334. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12336. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12337. if !m.op.Is(OpUpdateOne) {
  12338. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12339. }
  12340. if m.id == nil || m.oldValue == nil {
  12341. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12342. }
  12343. oldValue, err := m.oldValue(ctx)
  12344. if err != nil {
  12345. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12346. }
  12347. return oldValue.UpdatedAt, nil
  12348. }
  12349. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12350. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12351. m.updated_at = nil
  12352. }
  12353. // SetDeletedAt sets the "deleted_at" field.
  12354. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12355. m.deleted_at = &t
  12356. }
  12357. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12358. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12359. v := m.deleted_at
  12360. if v == nil {
  12361. return
  12362. }
  12363. return *v, true
  12364. }
  12365. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12366. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12368. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12369. if !m.op.Is(OpUpdateOne) {
  12370. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12371. }
  12372. if m.id == nil || m.oldValue == nil {
  12373. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12374. }
  12375. oldValue, err := m.oldValue(ctx)
  12376. if err != nil {
  12377. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12378. }
  12379. return oldValue.DeletedAt, nil
  12380. }
  12381. // ClearDeletedAt clears the value of the "deleted_at" field.
  12382. func (m *CreditUsageMutation) ClearDeletedAt() {
  12383. m.deleted_at = nil
  12384. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12385. }
  12386. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12387. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12388. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12389. return ok
  12390. }
  12391. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12392. func (m *CreditUsageMutation) ResetDeletedAt() {
  12393. m.deleted_at = nil
  12394. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12395. }
  12396. // SetUserID sets the "user_id" field.
  12397. func (m *CreditUsageMutation) SetUserID(s string) {
  12398. m.user_id = &s
  12399. }
  12400. // UserID returns the value of the "user_id" field in the mutation.
  12401. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12402. v := m.user_id
  12403. if v == nil {
  12404. return
  12405. }
  12406. return *v, true
  12407. }
  12408. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12409. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12411. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12412. if !m.op.Is(OpUpdateOne) {
  12413. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12414. }
  12415. if m.id == nil || m.oldValue == nil {
  12416. return v, errors.New("OldUserID requires an ID field in the mutation")
  12417. }
  12418. oldValue, err := m.oldValue(ctx)
  12419. if err != nil {
  12420. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12421. }
  12422. return oldValue.UserID, nil
  12423. }
  12424. // ClearUserID clears the value of the "user_id" field.
  12425. func (m *CreditUsageMutation) ClearUserID() {
  12426. m.user_id = nil
  12427. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12428. }
  12429. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12430. func (m *CreditUsageMutation) UserIDCleared() bool {
  12431. _, ok := m.clearedFields[creditusage.FieldUserID]
  12432. return ok
  12433. }
  12434. // ResetUserID resets all changes to the "user_id" field.
  12435. func (m *CreditUsageMutation) ResetUserID() {
  12436. m.user_id = nil
  12437. delete(m.clearedFields, creditusage.FieldUserID)
  12438. }
  12439. // SetNumber sets the "number" field.
  12440. func (m *CreditUsageMutation) SetNumber(f float32) {
  12441. m.number = &f
  12442. m.addnumber = nil
  12443. }
  12444. // Number returns the value of the "number" field in the mutation.
  12445. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12446. v := m.number
  12447. if v == nil {
  12448. return
  12449. }
  12450. return *v, true
  12451. }
  12452. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12453. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12455. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12456. if !m.op.Is(OpUpdateOne) {
  12457. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12458. }
  12459. if m.id == nil || m.oldValue == nil {
  12460. return v, errors.New("OldNumber requires an ID field in the mutation")
  12461. }
  12462. oldValue, err := m.oldValue(ctx)
  12463. if err != nil {
  12464. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12465. }
  12466. return oldValue.Number, nil
  12467. }
  12468. // AddNumber adds f to the "number" field.
  12469. func (m *CreditUsageMutation) AddNumber(f float32) {
  12470. if m.addnumber != nil {
  12471. *m.addnumber += f
  12472. } else {
  12473. m.addnumber = &f
  12474. }
  12475. }
  12476. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12477. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12478. v := m.addnumber
  12479. if v == nil {
  12480. return
  12481. }
  12482. return *v, true
  12483. }
  12484. // ResetNumber resets all changes to the "number" field.
  12485. func (m *CreditUsageMutation) ResetNumber() {
  12486. m.number = nil
  12487. m.addnumber = nil
  12488. }
  12489. // SetStatus sets the "status" field.
  12490. func (m *CreditUsageMutation) SetStatus(i int) {
  12491. m.status = &i
  12492. m.addstatus = nil
  12493. }
  12494. // Status returns the value of the "status" field in the mutation.
  12495. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12496. v := m.status
  12497. if v == nil {
  12498. return
  12499. }
  12500. return *v, true
  12501. }
  12502. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12503. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12505. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12506. if !m.op.Is(OpUpdateOne) {
  12507. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12508. }
  12509. if m.id == nil || m.oldValue == nil {
  12510. return v, errors.New("OldStatus requires an ID field in the mutation")
  12511. }
  12512. oldValue, err := m.oldValue(ctx)
  12513. if err != nil {
  12514. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12515. }
  12516. return oldValue.Status, nil
  12517. }
  12518. // AddStatus adds i to the "status" field.
  12519. func (m *CreditUsageMutation) AddStatus(i int) {
  12520. if m.addstatus != nil {
  12521. *m.addstatus += i
  12522. } else {
  12523. m.addstatus = &i
  12524. }
  12525. }
  12526. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12527. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12528. v := m.addstatus
  12529. if v == nil {
  12530. return
  12531. }
  12532. return *v, true
  12533. }
  12534. // ClearStatus clears the value of the "status" field.
  12535. func (m *CreditUsageMutation) ClearStatus() {
  12536. m.status = nil
  12537. m.addstatus = nil
  12538. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12539. }
  12540. // StatusCleared returns if the "status" field was cleared in this mutation.
  12541. func (m *CreditUsageMutation) StatusCleared() bool {
  12542. _, ok := m.clearedFields[creditusage.FieldStatus]
  12543. return ok
  12544. }
  12545. // ResetStatus resets all changes to the "status" field.
  12546. func (m *CreditUsageMutation) ResetStatus() {
  12547. m.status = nil
  12548. m.addstatus = nil
  12549. delete(m.clearedFields, creditusage.FieldStatus)
  12550. }
  12551. // SetNtype sets the "ntype" field.
  12552. func (m *CreditUsageMutation) SetNtype(i int) {
  12553. m.ntype = &i
  12554. m.addntype = nil
  12555. }
  12556. // Ntype returns the value of the "ntype" field in the mutation.
  12557. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12558. v := m.ntype
  12559. if v == nil {
  12560. return
  12561. }
  12562. return *v, true
  12563. }
  12564. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12565. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12567. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12568. if !m.op.Is(OpUpdateOne) {
  12569. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12570. }
  12571. if m.id == nil || m.oldValue == nil {
  12572. return v, errors.New("OldNtype requires an ID field in the mutation")
  12573. }
  12574. oldValue, err := m.oldValue(ctx)
  12575. if err != nil {
  12576. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12577. }
  12578. return oldValue.Ntype, nil
  12579. }
  12580. // AddNtype adds i to the "ntype" field.
  12581. func (m *CreditUsageMutation) AddNtype(i int) {
  12582. if m.addntype != nil {
  12583. *m.addntype += i
  12584. } else {
  12585. m.addntype = &i
  12586. }
  12587. }
  12588. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12589. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12590. v := m.addntype
  12591. if v == nil {
  12592. return
  12593. }
  12594. return *v, true
  12595. }
  12596. // ResetNtype resets all changes to the "ntype" field.
  12597. func (m *CreditUsageMutation) ResetNtype() {
  12598. m.ntype = nil
  12599. m.addntype = nil
  12600. }
  12601. // SetTable sets the "table" field.
  12602. func (m *CreditUsageMutation) SetTable(s string) {
  12603. m.table = &s
  12604. }
  12605. // Table returns the value of the "table" field in the mutation.
  12606. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12607. v := m.table
  12608. if v == nil {
  12609. return
  12610. }
  12611. return *v, true
  12612. }
  12613. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12614. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12616. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12617. if !m.op.Is(OpUpdateOne) {
  12618. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12619. }
  12620. if m.id == nil || m.oldValue == nil {
  12621. return v, errors.New("OldTable requires an ID field in the mutation")
  12622. }
  12623. oldValue, err := m.oldValue(ctx)
  12624. if err != nil {
  12625. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12626. }
  12627. return oldValue.Table, nil
  12628. }
  12629. // ResetTable resets all changes to the "table" field.
  12630. func (m *CreditUsageMutation) ResetTable() {
  12631. m.table = nil
  12632. }
  12633. // SetOrganizationID sets the "organization_id" field.
  12634. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12635. m.organization_id = &u
  12636. m.addorganization_id = nil
  12637. }
  12638. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12639. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12640. v := m.organization_id
  12641. if v == nil {
  12642. return
  12643. }
  12644. return *v, true
  12645. }
  12646. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12647. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12649. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12650. if !m.op.Is(OpUpdateOne) {
  12651. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12652. }
  12653. if m.id == nil || m.oldValue == nil {
  12654. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12655. }
  12656. oldValue, err := m.oldValue(ctx)
  12657. if err != nil {
  12658. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12659. }
  12660. return oldValue.OrganizationID, nil
  12661. }
  12662. // AddOrganizationID adds u to the "organization_id" field.
  12663. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12664. if m.addorganization_id != nil {
  12665. *m.addorganization_id += u
  12666. } else {
  12667. m.addorganization_id = &u
  12668. }
  12669. }
  12670. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12671. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12672. v := m.addorganization_id
  12673. if v == nil {
  12674. return
  12675. }
  12676. return *v, true
  12677. }
  12678. // ClearOrganizationID clears the value of the "organization_id" field.
  12679. func (m *CreditUsageMutation) ClearOrganizationID() {
  12680. m.organization_id = nil
  12681. m.addorganization_id = nil
  12682. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12683. }
  12684. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12685. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12686. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12687. return ok
  12688. }
  12689. // ResetOrganizationID resets all changes to the "organization_id" field.
  12690. func (m *CreditUsageMutation) ResetOrganizationID() {
  12691. m.organization_id = nil
  12692. m.addorganization_id = nil
  12693. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12694. }
  12695. // SetNid sets the "nid" field.
  12696. func (m *CreditUsageMutation) SetNid(u uint64) {
  12697. m.nid = &u
  12698. m.addnid = nil
  12699. }
  12700. // Nid returns the value of the "nid" field in the mutation.
  12701. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12702. v := m.nid
  12703. if v == nil {
  12704. return
  12705. }
  12706. return *v, true
  12707. }
  12708. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12709. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12711. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12712. if !m.op.Is(OpUpdateOne) {
  12713. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12714. }
  12715. if m.id == nil || m.oldValue == nil {
  12716. return v, errors.New("OldNid requires an ID field in the mutation")
  12717. }
  12718. oldValue, err := m.oldValue(ctx)
  12719. if err != nil {
  12720. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12721. }
  12722. return oldValue.Nid, nil
  12723. }
  12724. // AddNid adds u to the "nid" field.
  12725. func (m *CreditUsageMutation) AddNid(u int64) {
  12726. if m.addnid != nil {
  12727. *m.addnid += u
  12728. } else {
  12729. m.addnid = &u
  12730. }
  12731. }
  12732. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12733. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12734. v := m.addnid
  12735. if v == nil {
  12736. return
  12737. }
  12738. return *v, true
  12739. }
  12740. // ResetNid resets all changes to the "nid" field.
  12741. func (m *CreditUsageMutation) ResetNid() {
  12742. m.nid = nil
  12743. m.addnid = nil
  12744. }
  12745. // SetReason sets the "reason" field.
  12746. func (m *CreditUsageMutation) SetReason(s string) {
  12747. m.reason = &s
  12748. }
  12749. // Reason returns the value of the "reason" field in the mutation.
  12750. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12751. v := m.reason
  12752. if v == nil {
  12753. return
  12754. }
  12755. return *v, true
  12756. }
  12757. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12758. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12760. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12761. if !m.op.Is(OpUpdateOne) {
  12762. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12763. }
  12764. if m.id == nil || m.oldValue == nil {
  12765. return v, errors.New("OldReason requires an ID field in the mutation")
  12766. }
  12767. oldValue, err := m.oldValue(ctx)
  12768. if err != nil {
  12769. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  12770. }
  12771. return oldValue.Reason, nil
  12772. }
  12773. // ResetReason resets all changes to the "reason" field.
  12774. func (m *CreditUsageMutation) ResetReason() {
  12775. m.reason = nil
  12776. }
  12777. // SetOperator sets the "operator" field.
  12778. func (m *CreditUsageMutation) SetOperator(s string) {
  12779. m.operator = &s
  12780. }
  12781. // Operator returns the value of the "operator" field in the mutation.
  12782. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12783. v := m.operator
  12784. if v == nil {
  12785. return
  12786. }
  12787. return *v, true
  12788. }
  12789. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12790. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12792. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12793. if !m.op.Is(OpUpdateOne) {
  12794. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12795. }
  12796. if m.id == nil || m.oldValue == nil {
  12797. return v, errors.New("OldOperator requires an ID field in the mutation")
  12798. }
  12799. oldValue, err := m.oldValue(ctx)
  12800. if err != nil {
  12801. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12802. }
  12803. return oldValue.Operator, nil
  12804. }
  12805. // ResetOperator resets all changes to the "operator" field.
  12806. func (m *CreditUsageMutation) ResetOperator() {
  12807. m.operator = nil
  12808. }
  12809. // Where appends a list predicates to the CreditUsageMutation builder.
  12810. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12811. m.predicates = append(m.predicates, ps...)
  12812. }
  12813. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12814. // users can use type-assertion to append predicates that do not depend on any generated package.
  12815. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12816. p := make([]predicate.CreditUsage, len(ps))
  12817. for i := range ps {
  12818. p[i] = ps[i]
  12819. }
  12820. m.Where(p...)
  12821. }
  12822. // Op returns the operation name.
  12823. func (m *CreditUsageMutation) Op() Op {
  12824. return m.op
  12825. }
  12826. // SetOp allows setting the mutation operation.
  12827. func (m *CreditUsageMutation) SetOp(op Op) {
  12828. m.op = op
  12829. }
  12830. // Type returns the node type of this mutation (CreditUsage).
  12831. func (m *CreditUsageMutation) Type() string {
  12832. return m.typ
  12833. }
  12834. // Fields returns all fields that were changed during this mutation. Note that in
  12835. // order to get all numeric fields that were incremented/decremented, call
  12836. // AddedFields().
  12837. func (m *CreditUsageMutation) Fields() []string {
  12838. fields := make([]string, 0, 12)
  12839. if m.created_at != nil {
  12840. fields = append(fields, creditusage.FieldCreatedAt)
  12841. }
  12842. if m.updated_at != nil {
  12843. fields = append(fields, creditusage.FieldUpdatedAt)
  12844. }
  12845. if m.deleted_at != nil {
  12846. fields = append(fields, creditusage.FieldDeletedAt)
  12847. }
  12848. if m.user_id != nil {
  12849. fields = append(fields, creditusage.FieldUserID)
  12850. }
  12851. if m.number != nil {
  12852. fields = append(fields, creditusage.FieldNumber)
  12853. }
  12854. if m.status != nil {
  12855. fields = append(fields, creditusage.FieldStatus)
  12856. }
  12857. if m.ntype != nil {
  12858. fields = append(fields, creditusage.FieldNtype)
  12859. }
  12860. if m.table != nil {
  12861. fields = append(fields, creditusage.FieldTable)
  12862. }
  12863. if m.organization_id != nil {
  12864. fields = append(fields, creditusage.FieldOrganizationID)
  12865. }
  12866. if m.nid != nil {
  12867. fields = append(fields, creditusage.FieldNid)
  12868. }
  12869. if m.reason != nil {
  12870. fields = append(fields, creditusage.FieldReason)
  12871. }
  12872. if m.operator != nil {
  12873. fields = append(fields, creditusage.FieldOperator)
  12874. }
  12875. return fields
  12876. }
  12877. // Field returns the value of a field with the given name. The second boolean
  12878. // return value indicates that this field was not set, or was not defined in the
  12879. // schema.
  12880. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  12881. switch name {
  12882. case creditusage.FieldCreatedAt:
  12883. return m.CreatedAt()
  12884. case creditusage.FieldUpdatedAt:
  12885. return m.UpdatedAt()
  12886. case creditusage.FieldDeletedAt:
  12887. return m.DeletedAt()
  12888. case creditusage.FieldUserID:
  12889. return m.UserID()
  12890. case creditusage.FieldNumber:
  12891. return m.Number()
  12892. case creditusage.FieldStatus:
  12893. return m.Status()
  12894. case creditusage.FieldNtype:
  12895. return m.Ntype()
  12896. case creditusage.FieldTable:
  12897. return m.Table()
  12898. case creditusage.FieldOrganizationID:
  12899. return m.OrganizationID()
  12900. case creditusage.FieldNid:
  12901. return m.Nid()
  12902. case creditusage.FieldReason:
  12903. return m.Reason()
  12904. case creditusage.FieldOperator:
  12905. return m.Operator()
  12906. }
  12907. return nil, false
  12908. }
  12909. // OldField returns the old value of the field from the database. An error is
  12910. // returned if the mutation operation is not UpdateOne, or the query to the
  12911. // database failed.
  12912. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12913. switch name {
  12914. case creditusage.FieldCreatedAt:
  12915. return m.OldCreatedAt(ctx)
  12916. case creditusage.FieldUpdatedAt:
  12917. return m.OldUpdatedAt(ctx)
  12918. case creditusage.FieldDeletedAt:
  12919. return m.OldDeletedAt(ctx)
  12920. case creditusage.FieldUserID:
  12921. return m.OldUserID(ctx)
  12922. case creditusage.FieldNumber:
  12923. return m.OldNumber(ctx)
  12924. case creditusage.FieldStatus:
  12925. return m.OldStatus(ctx)
  12926. case creditusage.FieldNtype:
  12927. return m.OldNtype(ctx)
  12928. case creditusage.FieldTable:
  12929. return m.OldTable(ctx)
  12930. case creditusage.FieldOrganizationID:
  12931. return m.OldOrganizationID(ctx)
  12932. case creditusage.FieldNid:
  12933. return m.OldNid(ctx)
  12934. case creditusage.FieldReason:
  12935. return m.OldReason(ctx)
  12936. case creditusage.FieldOperator:
  12937. return m.OldOperator(ctx)
  12938. }
  12939. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  12940. }
  12941. // SetField sets the value of a field with the given name. It returns an error if
  12942. // the field is not defined in the schema, or if the type mismatched the field
  12943. // type.
  12944. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  12945. switch name {
  12946. case creditusage.FieldCreatedAt:
  12947. v, ok := value.(time.Time)
  12948. if !ok {
  12949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12950. }
  12951. m.SetCreatedAt(v)
  12952. return nil
  12953. case creditusage.FieldUpdatedAt:
  12954. v, ok := value.(time.Time)
  12955. if !ok {
  12956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12957. }
  12958. m.SetUpdatedAt(v)
  12959. return nil
  12960. case creditusage.FieldDeletedAt:
  12961. v, ok := value.(time.Time)
  12962. if !ok {
  12963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12964. }
  12965. m.SetDeletedAt(v)
  12966. return nil
  12967. case creditusage.FieldUserID:
  12968. v, ok := value.(string)
  12969. if !ok {
  12970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12971. }
  12972. m.SetUserID(v)
  12973. return nil
  12974. case creditusage.FieldNumber:
  12975. v, ok := value.(float32)
  12976. if !ok {
  12977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12978. }
  12979. m.SetNumber(v)
  12980. return nil
  12981. case creditusage.FieldStatus:
  12982. v, ok := value.(int)
  12983. if !ok {
  12984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12985. }
  12986. m.SetStatus(v)
  12987. return nil
  12988. case creditusage.FieldNtype:
  12989. v, ok := value.(int)
  12990. if !ok {
  12991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12992. }
  12993. m.SetNtype(v)
  12994. return nil
  12995. case creditusage.FieldTable:
  12996. v, ok := value.(string)
  12997. if !ok {
  12998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12999. }
  13000. m.SetTable(v)
  13001. return nil
  13002. case creditusage.FieldOrganizationID:
  13003. v, ok := value.(uint64)
  13004. if !ok {
  13005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13006. }
  13007. m.SetOrganizationID(v)
  13008. return nil
  13009. case creditusage.FieldNid:
  13010. v, ok := value.(uint64)
  13011. if !ok {
  13012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13013. }
  13014. m.SetNid(v)
  13015. return nil
  13016. case creditusage.FieldReason:
  13017. v, ok := value.(string)
  13018. if !ok {
  13019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13020. }
  13021. m.SetReason(v)
  13022. return nil
  13023. case creditusage.FieldOperator:
  13024. v, ok := value.(string)
  13025. if !ok {
  13026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13027. }
  13028. m.SetOperator(v)
  13029. return nil
  13030. }
  13031. return fmt.Errorf("unknown CreditUsage field %s", name)
  13032. }
  13033. // AddedFields returns all numeric fields that were incremented/decremented during
  13034. // this mutation.
  13035. func (m *CreditUsageMutation) AddedFields() []string {
  13036. var fields []string
  13037. if m.addnumber != nil {
  13038. fields = append(fields, creditusage.FieldNumber)
  13039. }
  13040. if m.addstatus != nil {
  13041. fields = append(fields, creditusage.FieldStatus)
  13042. }
  13043. if m.addntype != nil {
  13044. fields = append(fields, creditusage.FieldNtype)
  13045. }
  13046. if m.addorganization_id != nil {
  13047. fields = append(fields, creditusage.FieldOrganizationID)
  13048. }
  13049. if m.addnid != nil {
  13050. fields = append(fields, creditusage.FieldNid)
  13051. }
  13052. return fields
  13053. }
  13054. // AddedField returns the numeric value that was incremented/decremented on a field
  13055. // with the given name. The second boolean return value indicates that this field
  13056. // was not set, or was not defined in the schema.
  13057. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13058. switch name {
  13059. case creditusage.FieldNumber:
  13060. return m.AddedNumber()
  13061. case creditusage.FieldStatus:
  13062. return m.AddedStatus()
  13063. case creditusage.FieldNtype:
  13064. return m.AddedNtype()
  13065. case creditusage.FieldOrganizationID:
  13066. return m.AddedOrganizationID()
  13067. case creditusage.FieldNid:
  13068. return m.AddedNid()
  13069. }
  13070. return nil, false
  13071. }
  13072. // AddField adds the value to the field with the given name. It returns an error if
  13073. // the field is not defined in the schema, or if the type mismatched the field
  13074. // type.
  13075. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13076. switch name {
  13077. case creditusage.FieldNumber:
  13078. v, ok := value.(float32)
  13079. if !ok {
  13080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13081. }
  13082. m.AddNumber(v)
  13083. return nil
  13084. case creditusage.FieldStatus:
  13085. v, ok := value.(int)
  13086. if !ok {
  13087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13088. }
  13089. m.AddStatus(v)
  13090. return nil
  13091. case creditusage.FieldNtype:
  13092. v, ok := value.(int)
  13093. if !ok {
  13094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13095. }
  13096. m.AddNtype(v)
  13097. return nil
  13098. case creditusage.FieldOrganizationID:
  13099. v, ok := value.(int64)
  13100. if !ok {
  13101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13102. }
  13103. m.AddOrganizationID(v)
  13104. return nil
  13105. case creditusage.FieldNid:
  13106. v, ok := value.(int64)
  13107. if !ok {
  13108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13109. }
  13110. m.AddNid(v)
  13111. return nil
  13112. }
  13113. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13114. }
  13115. // ClearedFields returns all nullable fields that were cleared during this
  13116. // mutation.
  13117. func (m *CreditUsageMutation) ClearedFields() []string {
  13118. var fields []string
  13119. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13120. fields = append(fields, creditusage.FieldDeletedAt)
  13121. }
  13122. if m.FieldCleared(creditusage.FieldUserID) {
  13123. fields = append(fields, creditusage.FieldUserID)
  13124. }
  13125. if m.FieldCleared(creditusage.FieldStatus) {
  13126. fields = append(fields, creditusage.FieldStatus)
  13127. }
  13128. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13129. fields = append(fields, creditusage.FieldOrganizationID)
  13130. }
  13131. return fields
  13132. }
  13133. // FieldCleared returns a boolean indicating if a field with the given name was
  13134. // cleared in this mutation.
  13135. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13136. _, ok := m.clearedFields[name]
  13137. return ok
  13138. }
  13139. // ClearField clears the value of the field with the given name. It returns an
  13140. // error if the field is not defined in the schema.
  13141. func (m *CreditUsageMutation) ClearField(name string) error {
  13142. switch name {
  13143. case creditusage.FieldDeletedAt:
  13144. m.ClearDeletedAt()
  13145. return nil
  13146. case creditusage.FieldUserID:
  13147. m.ClearUserID()
  13148. return nil
  13149. case creditusage.FieldStatus:
  13150. m.ClearStatus()
  13151. return nil
  13152. case creditusage.FieldOrganizationID:
  13153. m.ClearOrganizationID()
  13154. return nil
  13155. }
  13156. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13157. }
  13158. // ResetField resets all changes in the mutation for the field with the given name.
  13159. // It returns an error if the field is not defined in the schema.
  13160. func (m *CreditUsageMutation) ResetField(name string) error {
  13161. switch name {
  13162. case creditusage.FieldCreatedAt:
  13163. m.ResetCreatedAt()
  13164. return nil
  13165. case creditusage.FieldUpdatedAt:
  13166. m.ResetUpdatedAt()
  13167. return nil
  13168. case creditusage.FieldDeletedAt:
  13169. m.ResetDeletedAt()
  13170. return nil
  13171. case creditusage.FieldUserID:
  13172. m.ResetUserID()
  13173. return nil
  13174. case creditusage.FieldNumber:
  13175. m.ResetNumber()
  13176. return nil
  13177. case creditusage.FieldStatus:
  13178. m.ResetStatus()
  13179. return nil
  13180. case creditusage.FieldNtype:
  13181. m.ResetNtype()
  13182. return nil
  13183. case creditusage.FieldTable:
  13184. m.ResetTable()
  13185. return nil
  13186. case creditusage.FieldOrganizationID:
  13187. m.ResetOrganizationID()
  13188. return nil
  13189. case creditusage.FieldNid:
  13190. m.ResetNid()
  13191. return nil
  13192. case creditusage.FieldReason:
  13193. m.ResetReason()
  13194. return nil
  13195. case creditusage.FieldOperator:
  13196. m.ResetOperator()
  13197. return nil
  13198. }
  13199. return fmt.Errorf("unknown CreditUsage field %s", name)
  13200. }
  13201. // AddedEdges returns all edge names that were set/added in this mutation.
  13202. func (m *CreditUsageMutation) AddedEdges() []string {
  13203. edges := make([]string, 0, 0)
  13204. return edges
  13205. }
  13206. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13207. // name in this mutation.
  13208. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13209. return nil
  13210. }
  13211. // RemovedEdges returns all edge names that were removed in this mutation.
  13212. func (m *CreditUsageMutation) RemovedEdges() []string {
  13213. edges := make([]string, 0, 0)
  13214. return edges
  13215. }
  13216. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13217. // the given name in this mutation.
  13218. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13219. return nil
  13220. }
  13221. // ClearedEdges returns all edge names that were cleared in this mutation.
  13222. func (m *CreditUsageMutation) ClearedEdges() []string {
  13223. edges := make([]string, 0, 0)
  13224. return edges
  13225. }
  13226. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13227. // was cleared in this mutation.
  13228. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13229. return false
  13230. }
  13231. // ClearEdge clears the value of the edge with the given name. It returns an error
  13232. // if that edge is not defined in the schema.
  13233. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13234. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13235. }
  13236. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13237. // It returns an error if the edge is not defined in the schema.
  13238. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13239. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13240. }
  13241. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13242. type EmployeeMutation struct {
  13243. config
  13244. op Op
  13245. typ string
  13246. id *uint64
  13247. created_at *time.Time
  13248. updated_at *time.Time
  13249. deleted_at *time.Time
  13250. title *string
  13251. avatar *string
  13252. tags *string
  13253. hire_count *int
  13254. addhire_count *int
  13255. service_count *int
  13256. addservice_count *int
  13257. achievement_count *int
  13258. addachievement_count *int
  13259. intro *string
  13260. estimate *string
  13261. skill *string
  13262. ability_type *string
  13263. scene *string
  13264. switch_in *string
  13265. video_url *string
  13266. organization_id *uint64
  13267. addorganization_id *int64
  13268. category_id *uint64
  13269. addcategory_id *int64
  13270. api_base *string
  13271. api_key *string
  13272. ai_info *string
  13273. is_vip *int
  13274. addis_vip *int
  13275. chat_url *string
  13276. clearedFields map[string]struct{}
  13277. em_work_experiences map[uint64]struct{}
  13278. removedem_work_experiences map[uint64]struct{}
  13279. clearedem_work_experiences bool
  13280. em_tutorial map[uint64]struct{}
  13281. removedem_tutorial map[uint64]struct{}
  13282. clearedem_tutorial bool
  13283. done bool
  13284. oldValue func(context.Context) (*Employee, error)
  13285. predicates []predicate.Employee
  13286. }
  13287. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13288. // employeeOption allows management of the mutation configuration using functional options.
  13289. type employeeOption func(*EmployeeMutation)
  13290. // newEmployeeMutation creates new mutation for the Employee entity.
  13291. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13292. m := &EmployeeMutation{
  13293. config: c,
  13294. op: op,
  13295. typ: TypeEmployee,
  13296. clearedFields: make(map[string]struct{}),
  13297. }
  13298. for _, opt := range opts {
  13299. opt(m)
  13300. }
  13301. return m
  13302. }
  13303. // withEmployeeID sets the ID field of the mutation.
  13304. func withEmployeeID(id uint64) employeeOption {
  13305. return func(m *EmployeeMutation) {
  13306. var (
  13307. err error
  13308. once sync.Once
  13309. value *Employee
  13310. )
  13311. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13312. once.Do(func() {
  13313. if m.done {
  13314. err = errors.New("querying old values post mutation is not allowed")
  13315. } else {
  13316. value, err = m.Client().Employee.Get(ctx, id)
  13317. }
  13318. })
  13319. return value, err
  13320. }
  13321. m.id = &id
  13322. }
  13323. }
  13324. // withEmployee sets the old Employee of the mutation.
  13325. func withEmployee(node *Employee) employeeOption {
  13326. return func(m *EmployeeMutation) {
  13327. m.oldValue = func(context.Context) (*Employee, error) {
  13328. return node, nil
  13329. }
  13330. m.id = &node.ID
  13331. }
  13332. }
  13333. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13334. // executed in a transaction (ent.Tx), a transactional client is returned.
  13335. func (m EmployeeMutation) Client() *Client {
  13336. client := &Client{config: m.config}
  13337. client.init()
  13338. return client
  13339. }
  13340. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13341. // it returns an error otherwise.
  13342. func (m EmployeeMutation) Tx() (*Tx, error) {
  13343. if _, ok := m.driver.(*txDriver); !ok {
  13344. return nil, errors.New("ent: mutation is not running in a transaction")
  13345. }
  13346. tx := &Tx{config: m.config}
  13347. tx.init()
  13348. return tx, nil
  13349. }
  13350. // SetID sets the value of the id field. Note that this
  13351. // operation is only accepted on creation of Employee entities.
  13352. func (m *EmployeeMutation) SetID(id uint64) {
  13353. m.id = &id
  13354. }
  13355. // ID returns the ID value in the mutation. Note that the ID is only available
  13356. // if it was provided to the builder or after it was returned from the database.
  13357. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13358. if m.id == nil {
  13359. return
  13360. }
  13361. return *m.id, true
  13362. }
  13363. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13364. // That means, if the mutation is applied within a transaction with an isolation level such
  13365. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13366. // or updated by the mutation.
  13367. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13368. switch {
  13369. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13370. id, exists := m.ID()
  13371. if exists {
  13372. return []uint64{id}, nil
  13373. }
  13374. fallthrough
  13375. case m.op.Is(OpUpdate | OpDelete):
  13376. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13377. default:
  13378. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13379. }
  13380. }
  13381. // SetCreatedAt sets the "created_at" field.
  13382. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13383. m.created_at = &t
  13384. }
  13385. // CreatedAt returns the value of the "created_at" field in the mutation.
  13386. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13387. v := m.created_at
  13388. if v == nil {
  13389. return
  13390. }
  13391. return *v, true
  13392. }
  13393. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13394. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13396. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13397. if !m.op.Is(OpUpdateOne) {
  13398. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13399. }
  13400. if m.id == nil || m.oldValue == nil {
  13401. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13402. }
  13403. oldValue, err := m.oldValue(ctx)
  13404. if err != nil {
  13405. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13406. }
  13407. return oldValue.CreatedAt, nil
  13408. }
  13409. // ResetCreatedAt resets all changes to the "created_at" field.
  13410. func (m *EmployeeMutation) ResetCreatedAt() {
  13411. m.created_at = nil
  13412. }
  13413. // SetUpdatedAt sets the "updated_at" field.
  13414. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13415. m.updated_at = &t
  13416. }
  13417. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13418. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13419. v := m.updated_at
  13420. if v == nil {
  13421. return
  13422. }
  13423. return *v, true
  13424. }
  13425. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13426. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13428. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13429. if !m.op.Is(OpUpdateOne) {
  13430. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13431. }
  13432. if m.id == nil || m.oldValue == nil {
  13433. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13434. }
  13435. oldValue, err := m.oldValue(ctx)
  13436. if err != nil {
  13437. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13438. }
  13439. return oldValue.UpdatedAt, nil
  13440. }
  13441. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13442. func (m *EmployeeMutation) ResetUpdatedAt() {
  13443. m.updated_at = nil
  13444. }
  13445. // SetDeletedAt sets the "deleted_at" field.
  13446. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13447. m.deleted_at = &t
  13448. }
  13449. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13450. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13451. v := m.deleted_at
  13452. if v == nil {
  13453. return
  13454. }
  13455. return *v, true
  13456. }
  13457. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13460. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13461. if !m.op.Is(OpUpdateOne) {
  13462. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13463. }
  13464. if m.id == nil || m.oldValue == nil {
  13465. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13466. }
  13467. oldValue, err := m.oldValue(ctx)
  13468. if err != nil {
  13469. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13470. }
  13471. return oldValue.DeletedAt, nil
  13472. }
  13473. // ClearDeletedAt clears the value of the "deleted_at" field.
  13474. func (m *EmployeeMutation) ClearDeletedAt() {
  13475. m.deleted_at = nil
  13476. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13477. }
  13478. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13479. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13480. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13481. return ok
  13482. }
  13483. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13484. func (m *EmployeeMutation) ResetDeletedAt() {
  13485. m.deleted_at = nil
  13486. delete(m.clearedFields, employee.FieldDeletedAt)
  13487. }
  13488. // SetTitle sets the "title" field.
  13489. func (m *EmployeeMutation) SetTitle(s string) {
  13490. m.title = &s
  13491. }
  13492. // Title returns the value of the "title" field in the mutation.
  13493. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13494. v := m.title
  13495. if v == nil {
  13496. return
  13497. }
  13498. return *v, true
  13499. }
  13500. // OldTitle returns the old "title" field's value of the Employee entity.
  13501. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13503. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13504. if !m.op.Is(OpUpdateOne) {
  13505. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13506. }
  13507. if m.id == nil || m.oldValue == nil {
  13508. return v, errors.New("OldTitle requires an ID field in the mutation")
  13509. }
  13510. oldValue, err := m.oldValue(ctx)
  13511. if err != nil {
  13512. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13513. }
  13514. return oldValue.Title, nil
  13515. }
  13516. // ResetTitle resets all changes to the "title" field.
  13517. func (m *EmployeeMutation) ResetTitle() {
  13518. m.title = nil
  13519. }
  13520. // SetAvatar sets the "avatar" field.
  13521. func (m *EmployeeMutation) SetAvatar(s string) {
  13522. m.avatar = &s
  13523. }
  13524. // Avatar returns the value of the "avatar" field in the mutation.
  13525. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13526. v := m.avatar
  13527. if v == nil {
  13528. return
  13529. }
  13530. return *v, true
  13531. }
  13532. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13533. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13535. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13536. if !m.op.Is(OpUpdateOne) {
  13537. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13538. }
  13539. if m.id == nil || m.oldValue == nil {
  13540. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13541. }
  13542. oldValue, err := m.oldValue(ctx)
  13543. if err != nil {
  13544. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13545. }
  13546. return oldValue.Avatar, nil
  13547. }
  13548. // ResetAvatar resets all changes to the "avatar" field.
  13549. func (m *EmployeeMutation) ResetAvatar() {
  13550. m.avatar = nil
  13551. }
  13552. // SetTags sets the "tags" field.
  13553. func (m *EmployeeMutation) SetTags(s string) {
  13554. m.tags = &s
  13555. }
  13556. // Tags returns the value of the "tags" field in the mutation.
  13557. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13558. v := m.tags
  13559. if v == nil {
  13560. return
  13561. }
  13562. return *v, true
  13563. }
  13564. // OldTags returns the old "tags" field's value of the Employee entity.
  13565. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13567. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13568. if !m.op.Is(OpUpdateOne) {
  13569. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13570. }
  13571. if m.id == nil || m.oldValue == nil {
  13572. return v, errors.New("OldTags requires an ID field in the mutation")
  13573. }
  13574. oldValue, err := m.oldValue(ctx)
  13575. if err != nil {
  13576. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13577. }
  13578. return oldValue.Tags, nil
  13579. }
  13580. // ResetTags resets all changes to the "tags" field.
  13581. func (m *EmployeeMutation) ResetTags() {
  13582. m.tags = nil
  13583. }
  13584. // SetHireCount sets the "hire_count" field.
  13585. func (m *EmployeeMutation) SetHireCount(i int) {
  13586. m.hire_count = &i
  13587. m.addhire_count = nil
  13588. }
  13589. // HireCount returns the value of the "hire_count" field in the mutation.
  13590. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13591. v := m.hire_count
  13592. if v == nil {
  13593. return
  13594. }
  13595. return *v, true
  13596. }
  13597. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13598. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13600. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13601. if !m.op.Is(OpUpdateOne) {
  13602. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13603. }
  13604. if m.id == nil || m.oldValue == nil {
  13605. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13606. }
  13607. oldValue, err := m.oldValue(ctx)
  13608. if err != nil {
  13609. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13610. }
  13611. return oldValue.HireCount, nil
  13612. }
  13613. // AddHireCount adds i to the "hire_count" field.
  13614. func (m *EmployeeMutation) AddHireCount(i int) {
  13615. if m.addhire_count != nil {
  13616. *m.addhire_count += i
  13617. } else {
  13618. m.addhire_count = &i
  13619. }
  13620. }
  13621. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13622. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13623. v := m.addhire_count
  13624. if v == nil {
  13625. return
  13626. }
  13627. return *v, true
  13628. }
  13629. // ResetHireCount resets all changes to the "hire_count" field.
  13630. func (m *EmployeeMutation) ResetHireCount() {
  13631. m.hire_count = nil
  13632. m.addhire_count = nil
  13633. }
  13634. // SetServiceCount sets the "service_count" field.
  13635. func (m *EmployeeMutation) SetServiceCount(i int) {
  13636. m.service_count = &i
  13637. m.addservice_count = nil
  13638. }
  13639. // ServiceCount returns the value of the "service_count" field in the mutation.
  13640. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13641. v := m.service_count
  13642. if v == nil {
  13643. return
  13644. }
  13645. return *v, true
  13646. }
  13647. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13648. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13650. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13651. if !m.op.Is(OpUpdateOne) {
  13652. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13653. }
  13654. if m.id == nil || m.oldValue == nil {
  13655. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13656. }
  13657. oldValue, err := m.oldValue(ctx)
  13658. if err != nil {
  13659. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13660. }
  13661. return oldValue.ServiceCount, nil
  13662. }
  13663. // AddServiceCount adds i to the "service_count" field.
  13664. func (m *EmployeeMutation) AddServiceCount(i int) {
  13665. if m.addservice_count != nil {
  13666. *m.addservice_count += i
  13667. } else {
  13668. m.addservice_count = &i
  13669. }
  13670. }
  13671. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13672. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13673. v := m.addservice_count
  13674. if v == nil {
  13675. return
  13676. }
  13677. return *v, true
  13678. }
  13679. // ResetServiceCount resets all changes to the "service_count" field.
  13680. func (m *EmployeeMutation) ResetServiceCount() {
  13681. m.service_count = nil
  13682. m.addservice_count = nil
  13683. }
  13684. // SetAchievementCount sets the "achievement_count" field.
  13685. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13686. m.achievement_count = &i
  13687. m.addachievement_count = nil
  13688. }
  13689. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13690. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13691. v := m.achievement_count
  13692. if v == nil {
  13693. return
  13694. }
  13695. return *v, true
  13696. }
  13697. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13698. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13700. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13701. if !m.op.Is(OpUpdateOne) {
  13702. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13703. }
  13704. if m.id == nil || m.oldValue == nil {
  13705. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13706. }
  13707. oldValue, err := m.oldValue(ctx)
  13708. if err != nil {
  13709. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13710. }
  13711. return oldValue.AchievementCount, nil
  13712. }
  13713. // AddAchievementCount adds i to the "achievement_count" field.
  13714. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13715. if m.addachievement_count != nil {
  13716. *m.addachievement_count += i
  13717. } else {
  13718. m.addachievement_count = &i
  13719. }
  13720. }
  13721. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13722. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13723. v := m.addachievement_count
  13724. if v == nil {
  13725. return
  13726. }
  13727. return *v, true
  13728. }
  13729. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13730. func (m *EmployeeMutation) ResetAchievementCount() {
  13731. m.achievement_count = nil
  13732. m.addachievement_count = nil
  13733. }
  13734. // SetIntro sets the "intro" field.
  13735. func (m *EmployeeMutation) SetIntro(s string) {
  13736. m.intro = &s
  13737. }
  13738. // Intro returns the value of the "intro" field in the mutation.
  13739. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13740. v := m.intro
  13741. if v == nil {
  13742. return
  13743. }
  13744. return *v, true
  13745. }
  13746. // OldIntro returns the old "intro" field's value of the Employee entity.
  13747. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13749. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13750. if !m.op.Is(OpUpdateOne) {
  13751. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13752. }
  13753. if m.id == nil || m.oldValue == nil {
  13754. return v, errors.New("OldIntro requires an ID field in the mutation")
  13755. }
  13756. oldValue, err := m.oldValue(ctx)
  13757. if err != nil {
  13758. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13759. }
  13760. return oldValue.Intro, nil
  13761. }
  13762. // ResetIntro resets all changes to the "intro" field.
  13763. func (m *EmployeeMutation) ResetIntro() {
  13764. m.intro = nil
  13765. }
  13766. // SetEstimate sets the "estimate" field.
  13767. func (m *EmployeeMutation) SetEstimate(s string) {
  13768. m.estimate = &s
  13769. }
  13770. // Estimate returns the value of the "estimate" field in the mutation.
  13771. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13772. v := m.estimate
  13773. if v == nil {
  13774. return
  13775. }
  13776. return *v, true
  13777. }
  13778. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13779. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13781. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13782. if !m.op.Is(OpUpdateOne) {
  13783. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13784. }
  13785. if m.id == nil || m.oldValue == nil {
  13786. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13787. }
  13788. oldValue, err := m.oldValue(ctx)
  13789. if err != nil {
  13790. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13791. }
  13792. return oldValue.Estimate, nil
  13793. }
  13794. // ResetEstimate resets all changes to the "estimate" field.
  13795. func (m *EmployeeMutation) ResetEstimate() {
  13796. m.estimate = nil
  13797. }
  13798. // SetSkill sets the "skill" field.
  13799. func (m *EmployeeMutation) SetSkill(s string) {
  13800. m.skill = &s
  13801. }
  13802. // Skill returns the value of the "skill" field in the mutation.
  13803. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13804. v := m.skill
  13805. if v == nil {
  13806. return
  13807. }
  13808. return *v, true
  13809. }
  13810. // OldSkill returns the old "skill" field's value of the Employee entity.
  13811. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13813. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13814. if !m.op.Is(OpUpdateOne) {
  13815. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13816. }
  13817. if m.id == nil || m.oldValue == nil {
  13818. return v, errors.New("OldSkill requires an ID field in the mutation")
  13819. }
  13820. oldValue, err := m.oldValue(ctx)
  13821. if err != nil {
  13822. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13823. }
  13824. return oldValue.Skill, nil
  13825. }
  13826. // ResetSkill resets all changes to the "skill" field.
  13827. func (m *EmployeeMutation) ResetSkill() {
  13828. m.skill = nil
  13829. }
  13830. // SetAbilityType sets the "ability_type" field.
  13831. func (m *EmployeeMutation) SetAbilityType(s string) {
  13832. m.ability_type = &s
  13833. }
  13834. // AbilityType returns the value of the "ability_type" field in the mutation.
  13835. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13836. v := m.ability_type
  13837. if v == nil {
  13838. return
  13839. }
  13840. return *v, true
  13841. }
  13842. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13843. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13845. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  13846. if !m.op.Is(OpUpdateOne) {
  13847. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  13848. }
  13849. if m.id == nil || m.oldValue == nil {
  13850. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  13851. }
  13852. oldValue, err := m.oldValue(ctx)
  13853. if err != nil {
  13854. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  13855. }
  13856. return oldValue.AbilityType, nil
  13857. }
  13858. // ResetAbilityType resets all changes to the "ability_type" field.
  13859. func (m *EmployeeMutation) ResetAbilityType() {
  13860. m.ability_type = nil
  13861. }
  13862. // SetScene sets the "scene" field.
  13863. func (m *EmployeeMutation) SetScene(s string) {
  13864. m.scene = &s
  13865. }
  13866. // Scene returns the value of the "scene" field in the mutation.
  13867. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  13868. v := m.scene
  13869. if v == nil {
  13870. return
  13871. }
  13872. return *v, true
  13873. }
  13874. // OldScene returns the old "scene" field's value of the Employee entity.
  13875. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13877. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  13878. if !m.op.Is(OpUpdateOne) {
  13879. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  13880. }
  13881. if m.id == nil || m.oldValue == nil {
  13882. return v, errors.New("OldScene requires an ID field in the mutation")
  13883. }
  13884. oldValue, err := m.oldValue(ctx)
  13885. if err != nil {
  13886. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  13887. }
  13888. return oldValue.Scene, nil
  13889. }
  13890. // ResetScene resets all changes to the "scene" field.
  13891. func (m *EmployeeMutation) ResetScene() {
  13892. m.scene = nil
  13893. }
  13894. // SetSwitchIn sets the "switch_in" field.
  13895. func (m *EmployeeMutation) SetSwitchIn(s string) {
  13896. m.switch_in = &s
  13897. }
  13898. // SwitchIn returns the value of the "switch_in" field in the mutation.
  13899. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  13900. v := m.switch_in
  13901. if v == nil {
  13902. return
  13903. }
  13904. return *v, true
  13905. }
  13906. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  13907. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13909. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  13910. if !m.op.Is(OpUpdateOne) {
  13911. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  13912. }
  13913. if m.id == nil || m.oldValue == nil {
  13914. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  13915. }
  13916. oldValue, err := m.oldValue(ctx)
  13917. if err != nil {
  13918. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  13919. }
  13920. return oldValue.SwitchIn, nil
  13921. }
  13922. // ResetSwitchIn resets all changes to the "switch_in" field.
  13923. func (m *EmployeeMutation) ResetSwitchIn() {
  13924. m.switch_in = nil
  13925. }
  13926. // SetVideoURL sets the "video_url" field.
  13927. func (m *EmployeeMutation) SetVideoURL(s string) {
  13928. m.video_url = &s
  13929. }
  13930. // VideoURL returns the value of the "video_url" field in the mutation.
  13931. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  13932. v := m.video_url
  13933. if v == nil {
  13934. return
  13935. }
  13936. return *v, true
  13937. }
  13938. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  13939. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13941. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  13942. if !m.op.Is(OpUpdateOne) {
  13943. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  13944. }
  13945. if m.id == nil || m.oldValue == nil {
  13946. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  13947. }
  13948. oldValue, err := m.oldValue(ctx)
  13949. if err != nil {
  13950. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  13951. }
  13952. return oldValue.VideoURL, nil
  13953. }
  13954. // ResetVideoURL resets all changes to the "video_url" field.
  13955. func (m *EmployeeMutation) ResetVideoURL() {
  13956. m.video_url = nil
  13957. }
  13958. // SetOrganizationID sets the "organization_id" field.
  13959. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  13960. m.organization_id = &u
  13961. m.addorganization_id = nil
  13962. }
  13963. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13964. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  13965. v := m.organization_id
  13966. if v == nil {
  13967. return
  13968. }
  13969. return *v, true
  13970. }
  13971. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  13972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13974. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13975. if !m.op.Is(OpUpdateOne) {
  13976. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13977. }
  13978. if m.id == nil || m.oldValue == nil {
  13979. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13980. }
  13981. oldValue, err := m.oldValue(ctx)
  13982. if err != nil {
  13983. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13984. }
  13985. return oldValue.OrganizationID, nil
  13986. }
  13987. // AddOrganizationID adds u to the "organization_id" field.
  13988. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  13989. if m.addorganization_id != nil {
  13990. *m.addorganization_id += u
  13991. } else {
  13992. m.addorganization_id = &u
  13993. }
  13994. }
  13995. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13996. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  13997. v := m.addorganization_id
  13998. if v == nil {
  13999. return
  14000. }
  14001. return *v, true
  14002. }
  14003. // ResetOrganizationID resets all changes to the "organization_id" field.
  14004. func (m *EmployeeMutation) ResetOrganizationID() {
  14005. m.organization_id = nil
  14006. m.addorganization_id = nil
  14007. }
  14008. // SetCategoryID sets the "category_id" field.
  14009. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14010. m.category_id = &u
  14011. m.addcategory_id = nil
  14012. }
  14013. // CategoryID returns the value of the "category_id" field in the mutation.
  14014. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14015. v := m.category_id
  14016. if v == nil {
  14017. return
  14018. }
  14019. return *v, true
  14020. }
  14021. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14022. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14024. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14025. if !m.op.Is(OpUpdateOne) {
  14026. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14027. }
  14028. if m.id == nil || m.oldValue == nil {
  14029. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14030. }
  14031. oldValue, err := m.oldValue(ctx)
  14032. if err != nil {
  14033. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14034. }
  14035. return oldValue.CategoryID, nil
  14036. }
  14037. // AddCategoryID adds u to the "category_id" field.
  14038. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14039. if m.addcategory_id != nil {
  14040. *m.addcategory_id += u
  14041. } else {
  14042. m.addcategory_id = &u
  14043. }
  14044. }
  14045. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14046. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14047. v := m.addcategory_id
  14048. if v == nil {
  14049. return
  14050. }
  14051. return *v, true
  14052. }
  14053. // ResetCategoryID resets all changes to the "category_id" field.
  14054. func (m *EmployeeMutation) ResetCategoryID() {
  14055. m.category_id = nil
  14056. m.addcategory_id = nil
  14057. }
  14058. // SetAPIBase sets the "api_base" field.
  14059. func (m *EmployeeMutation) SetAPIBase(s string) {
  14060. m.api_base = &s
  14061. }
  14062. // APIBase returns the value of the "api_base" field in the mutation.
  14063. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14064. v := m.api_base
  14065. if v == nil {
  14066. return
  14067. }
  14068. return *v, true
  14069. }
  14070. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14071. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14073. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14074. if !m.op.Is(OpUpdateOne) {
  14075. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14076. }
  14077. if m.id == nil || m.oldValue == nil {
  14078. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14079. }
  14080. oldValue, err := m.oldValue(ctx)
  14081. if err != nil {
  14082. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14083. }
  14084. return oldValue.APIBase, nil
  14085. }
  14086. // ResetAPIBase resets all changes to the "api_base" field.
  14087. func (m *EmployeeMutation) ResetAPIBase() {
  14088. m.api_base = nil
  14089. }
  14090. // SetAPIKey sets the "api_key" field.
  14091. func (m *EmployeeMutation) SetAPIKey(s string) {
  14092. m.api_key = &s
  14093. }
  14094. // APIKey returns the value of the "api_key" field in the mutation.
  14095. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14096. v := m.api_key
  14097. if v == nil {
  14098. return
  14099. }
  14100. return *v, true
  14101. }
  14102. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14103. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14105. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14106. if !m.op.Is(OpUpdateOne) {
  14107. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14108. }
  14109. if m.id == nil || m.oldValue == nil {
  14110. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14111. }
  14112. oldValue, err := m.oldValue(ctx)
  14113. if err != nil {
  14114. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14115. }
  14116. return oldValue.APIKey, nil
  14117. }
  14118. // ResetAPIKey resets all changes to the "api_key" field.
  14119. func (m *EmployeeMutation) ResetAPIKey() {
  14120. m.api_key = nil
  14121. }
  14122. // SetAiInfo sets the "ai_info" field.
  14123. func (m *EmployeeMutation) SetAiInfo(s string) {
  14124. m.ai_info = &s
  14125. }
  14126. // AiInfo returns the value of the "ai_info" field in the mutation.
  14127. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14128. v := m.ai_info
  14129. if v == nil {
  14130. return
  14131. }
  14132. return *v, true
  14133. }
  14134. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14135. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14137. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14138. if !m.op.Is(OpUpdateOne) {
  14139. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14140. }
  14141. if m.id == nil || m.oldValue == nil {
  14142. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14143. }
  14144. oldValue, err := m.oldValue(ctx)
  14145. if err != nil {
  14146. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14147. }
  14148. return oldValue.AiInfo, nil
  14149. }
  14150. // ClearAiInfo clears the value of the "ai_info" field.
  14151. func (m *EmployeeMutation) ClearAiInfo() {
  14152. m.ai_info = nil
  14153. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14154. }
  14155. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14156. func (m *EmployeeMutation) AiInfoCleared() bool {
  14157. _, ok := m.clearedFields[employee.FieldAiInfo]
  14158. return ok
  14159. }
  14160. // ResetAiInfo resets all changes to the "ai_info" field.
  14161. func (m *EmployeeMutation) ResetAiInfo() {
  14162. m.ai_info = nil
  14163. delete(m.clearedFields, employee.FieldAiInfo)
  14164. }
  14165. // SetIsVip sets the "is_vip" field.
  14166. func (m *EmployeeMutation) SetIsVip(i int) {
  14167. m.is_vip = &i
  14168. m.addis_vip = nil
  14169. }
  14170. // IsVip returns the value of the "is_vip" field in the mutation.
  14171. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14172. v := m.is_vip
  14173. if v == nil {
  14174. return
  14175. }
  14176. return *v, true
  14177. }
  14178. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14179. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14181. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14182. if !m.op.Is(OpUpdateOne) {
  14183. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14184. }
  14185. if m.id == nil || m.oldValue == nil {
  14186. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14187. }
  14188. oldValue, err := m.oldValue(ctx)
  14189. if err != nil {
  14190. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14191. }
  14192. return oldValue.IsVip, nil
  14193. }
  14194. // AddIsVip adds i to the "is_vip" field.
  14195. func (m *EmployeeMutation) AddIsVip(i int) {
  14196. if m.addis_vip != nil {
  14197. *m.addis_vip += i
  14198. } else {
  14199. m.addis_vip = &i
  14200. }
  14201. }
  14202. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14203. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14204. v := m.addis_vip
  14205. if v == nil {
  14206. return
  14207. }
  14208. return *v, true
  14209. }
  14210. // ResetIsVip resets all changes to the "is_vip" field.
  14211. func (m *EmployeeMutation) ResetIsVip() {
  14212. m.is_vip = nil
  14213. m.addis_vip = nil
  14214. }
  14215. // SetChatURL sets the "chat_url" field.
  14216. func (m *EmployeeMutation) SetChatURL(s string) {
  14217. m.chat_url = &s
  14218. }
  14219. // ChatURL returns the value of the "chat_url" field in the mutation.
  14220. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14221. v := m.chat_url
  14222. if v == nil {
  14223. return
  14224. }
  14225. return *v, true
  14226. }
  14227. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14228. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14230. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14231. if !m.op.Is(OpUpdateOne) {
  14232. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14233. }
  14234. if m.id == nil || m.oldValue == nil {
  14235. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14236. }
  14237. oldValue, err := m.oldValue(ctx)
  14238. if err != nil {
  14239. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14240. }
  14241. return oldValue.ChatURL, nil
  14242. }
  14243. // ResetChatURL resets all changes to the "chat_url" field.
  14244. func (m *EmployeeMutation) ResetChatURL() {
  14245. m.chat_url = nil
  14246. }
  14247. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14248. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14249. if m.em_work_experiences == nil {
  14250. m.em_work_experiences = make(map[uint64]struct{})
  14251. }
  14252. for i := range ids {
  14253. m.em_work_experiences[ids[i]] = struct{}{}
  14254. }
  14255. }
  14256. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14257. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14258. m.clearedem_work_experiences = true
  14259. }
  14260. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14261. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14262. return m.clearedem_work_experiences
  14263. }
  14264. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14265. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14266. if m.removedem_work_experiences == nil {
  14267. m.removedem_work_experiences = make(map[uint64]struct{})
  14268. }
  14269. for i := range ids {
  14270. delete(m.em_work_experiences, ids[i])
  14271. m.removedem_work_experiences[ids[i]] = struct{}{}
  14272. }
  14273. }
  14274. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14275. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14276. for id := range m.removedem_work_experiences {
  14277. ids = append(ids, id)
  14278. }
  14279. return
  14280. }
  14281. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14282. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14283. for id := range m.em_work_experiences {
  14284. ids = append(ids, id)
  14285. }
  14286. return
  14287. }
  14288. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14289. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14290. m.em_work_experiences = nil
  14291. m.clearedem_work_experiences = false
  14292. m.removedem_work_experiences = nil
  14293. }
  14294. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14295. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14296. if m.em_tutorial == nil {
  14297. m.em_tutorial = make(map[uint64]struct{})
  14298. }
  14299. for i := range ids {
  14300. m.em_tutorial[ids[i]] = struct{}{}
  14301. }
  14302. }
  14303. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14304. func (m *EmployeeMutation) ClearEmTutorial() {
  14305. m.clearedem_tutorial = true
  14306. }
  14307. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14308. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14309. return m.clearedem_tutorial
  14310. }
  14311. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14312. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14313. if m.removedem_tutorial == nil {
  14314. m.removedem_tutorial = make(map[uint64]struct{})
  14315. }
  14316. for i := range ids {
  14317. delete(m.em_tutorial, ids[i])
  14318. m.removedem_tutorial[ids[i]] = struct{}{}
  14319. }
  14320. }
  14321. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14322. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14323. for id := range m.removedem_tutorial {
  14324. ids = append(ids, id)
  14325. }
  14326. return
  14327. }
  14328. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14329. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14330. for id := range m.em_tutorial {
  14331. ids = append(ids, id)
  14332. }
  14333. return
  14334. }
  14335. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14336. func (m *EmployeeMutation) ResetEmTutorial() {
  14337. m.em_tutorial = nil
  14338. m.clearedem_tutorial = false
  14339. m.removedem_tutorial = nil
  14340. }
  14341. // Where appends a list predicates to the EmployeeMutation builder.
  14342. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14343. m.predicates = append(m.predicates, ps...)
  14344. }
  14345. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14346. // users can use type-assertion to append predicates that do not depend on any generated package.
  14347. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14348. p := make([]predicate.Employee, len(ps))
  14349. for i := range ps {
  14350. p[i] = ps[i]
  14351. }
  14352. m.Where(p...)
  14353. }
  14354. // Op returns the operation name.
  14355. func (m *EmployeeMutation) Op() Op {
  14356. return m.op
  14357. }
  14358. // SetOp allows setting the mutation operation.
  14359. func (m *EmployeeMutation) SetOp(op Op) {
  14360. m.op = op
  14361. }
  14362. // Type returns the node type of this mutation (Employee).
  14363. func (m *EmployeeMutation) Type() string {
  14364. return m.typ
  14365. }
  14366. // Fields returns all fields that were changed during this mutation. Note that in
  14367. // order to get all numeric fields that were incremented/decremented, call
  14368. // AddedFields().
  14369. func (m *EmployeeMutation) Fields() []string {
  14370. fields := make([]string, 0, 23)
  14371. if m.created_at != nil {
  14372. fields = append(fields, employee.FieldCreatedAt)
  14373. }
  14374. if m.updated_at != nil {
  14375. fields = append(fields, employee.FieldUpdatedAt)
  14376. }
  14377. if m.deleted_at != nil {
  14378. fields = append(fields, employee.FieldDeletedAt)
  14379. }
  14380. if m.title != nil {
  14381. fields = append(fields, employee.FieldTitle)
  14382. }
  14383. if m.avatar != nil {
  14384. fields = append(fields, employee.FieldAvatar)
  14385. }
  14386. if m.tags != nil {
  14387. fields = append(fields, employee.FieldTags)
  14388. }
  14389. if m.hire_count != nil {
  14390. fields = append(fields, employee.FieldHireCount)
  14391. }
  14392. if m.service_count != nil {
  14393. fields = append(fields, employee.FieldServiceCount)
  14394. }
  14395. if m.achievement_count != nil {
  14396. fields = append(fields, employee.FieldAchievementCount)
  14397. }
  14398. if m.intro != nil {
  14399. fields = append(fields, employee.FieldIntro)
  14400. }
  14401. if m.estimate != nil {
  14402. fields = append(fields, employee.FieldEstimate)
  14403. }
  14404. if m.skill != nil {
  14405. fields = append(fields, employee.FieldSkill)
  14406. }
  14407. if m.ability_type != nil {
  14408. fields = append(fields, employee.FieldAbilityType)
  14409. }
  14410. if m.scene != nil {
  14411. fields = append(fields, employee.FieldScene)
  14412. }
  14413. if m.switch_in != nil {
  14414. fields = append(fields, employee.FieldSwitchIn)
  14415. }
  14416. if m.video_url != nil {
  14417. fields = append(fields, employee.FieldVideoURL)
  14418. }
  14419. if m.organization_id != nil {
  14420. fields = append(fields, employee.FieldOrganizationID)
  14421. }
  14422. if m.category_id != nil {
  14423. fields = append(fields, employee.FieldCategoryID)
  14424. }
  14425. if m.api_base != nil {
  14426. fields = append(fields, employee.FieldAPIBase)
  14427. }
  14428. if m.api_key != nil {
  14429. fields = append(fields, employee.FieldAPIKey)
  14430. }
  14431. if m.ai_info != nil {
  14432. fields = append(fields, employee.FieldAiInfo)
  14433. }
  14434. if m.is_vip != nil {
  14435. fields = append(fields, employee.FieldIsVip)
  14436. }
  14437. if m.chat_url != nil {
  14438. fields = append(fields, employee.FieldChatURL)
  14439. }
  14440. return fields
  14441. }
  14442. // Field returns the value of a field with the given name. The second boolean
  14443. // return value indicates that this field was not set, or was not defined in the
  14444. // schema.
  14445. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14446. switch name {
  14447. case employee.FieldCreatedAt:
  14448. return m.CreatedAt()
  14449. case employee.FieldUpdatedAt:
  14450. return m.UpdatedAt()
  14451. case employee.FieldDeletedAt:
  14452. return m.DeletedAt()
  14453. case employee.FieldTitle:
  14454. return m.Title()
  14455. case employee.FieldAvatar:
  14456. return m.Avatar()
  14457. case employee.FieldTags:
  14458. return m.Tags()
  14459. case employee.FieldHireCount:
  14460. return m.HireCount()
  14461. case employee.FieldServiceCount:
  14462. return m.ServiceCount()
  14463. case employee.FieldAchievementCount:
  14464. return m.AchievementCount()
  14465. case employee.FieldIntro:
  14466. return m.Intro()
  14467. case employee.FieldEstimate:
  14468. return m.Estimate()
  14469. case employee.FieldSkill:
  14470. return m.Skill()
  14471. case employee.FieldAbilityType:
  14472. return m.AbilityType()
  14473. case employee.FieldScene:
  14474. return m.Scene()
  14475. case employee.FieldSwitchIn:
  14476. return m.SwitchIn()
  14477. case employee.FieldVideoURL:
  14478. return m.VideoURL()
  14479. case employee.FieldOrganizationID:
  14480. return m.OrganizationID()
  14481. case employee.FieldCategoryID:
  14482. return m.CategoryID()
  14483. case employee.FieldAPIBase:
  14484. return m.APIBase()
  14485. case employee.FieldAPIKey:
  14486. return m.APIKey()
  14487. case employee.FieldAiInfo:
  14488. return m.AiInfo()
  14489. case employee.FieldIsVip:
  14490. return m.IsVip()
  14491. case employee.FieldChatURL:
  14492. return m.ChatURL()
  14493. }
  14494. return nil, false
  14495. }
  14496. // OldField returns the old value of the field from the database. An error is
  14497. // returned if the mutation operation is not UpdateOne, or the query to the
  14498. // database failed.
  14499. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14500. switch name {
  14501. case employee.FieldCreatedAt:
  14502. return m.OldCreatedAt(ctx)
  14503. case employee.FieldUpdatedAt:
  14504. return m.OldUpdatedAt(ctx)
  14505. case employee.FieldDeletedAt:
  14506. return m.OldDeletedAt(ctx)
  14507. case employee.FieldTitle:
  14508. return m.OldTitle(ctx)
  14509. case employee.FieldAvatar:
  14510. return m.OldAvatar(ctx)
  14511. case employee.FieldTags:
  14512. return m.OldTags(ctx)
  14513. case employee.FieldHireCount:
  14514. return m.OldHireCount(ctx)
  14515. case employee.FieldServiceCount:
  14516. return m.OldServiceCount(ctx)
  14517. case employee.FieldAchievementCount:
  14518. return m.OldAchievementCount(ctx)
  14519. case employee.FieldIntro:
  14520. return m.OldIntro(ctx)
  14521. case employee.FieldEstimate:
  14522. return m.OldEstimate(ctx)
  14523. case employee.FieldSkill:
  14524. return m.OldSkill(ctx)
  14525. case employee.FieldAbilityType:
  14526. return m.OldAbilityType(ctx)
  14527. case employee.FieldScene:
  14528. return m.OldScene(ctx)
  14529. case employee.FieldSwitchIn:
  14530. return m.OldSwitchIn(ctx)
  14531. case employee.FieldVideoURL:
  14532. return m.OldVideoURL(ctx)
  14533. case employee.FieldOrganizationID:
  14534. return m.OldOrganizationID(ctx)
  14535. case employee.FieldCategoryID:
  14536. return m.OldCategoryID(ctx)
  14537. case employee.FieldAPIBase:
  14538. return m.OldAPIBase(ctx)
  14539. case employee.FieldAPIKey:
  14540. return m.OldAPIKey(ctx)
  14541. case employee.FieldAiInfo:
  14542. return m.OldAiInfo(ctx)
  14543. case employee.FieldIsVip:
  14544. return m.OldIsVip(ctx)
  14545. case employee.FieldChatURL:
  14546. return m.OldChatURL(ctx)
  14547. }
  14548. return nil, fmt.Errorf("unknown Employee field %s", name)
  14549. }
  14550. // SetField sets the value of a field with the given name. It returns an error if
  14551. // the field is not defined in the schema, or if the type mismatched the field
  14552. // type.
  14553. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14554. switch name {
  14555. case employee.FieldCreatedAt:
  14556. v, ok := value.(time.Time)
  14557. if !ok {
  14558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14559. }
  14560. m.SetCreatedAt(v)
  14561. return nil
  14562. case employee.FieldUpdatedAt:
  14563. v, ok := value.(time.Time)
  14564. if !ok {
  14565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14566. }
  14567. m.SetUpdatedAt(v)
  14568. return nil
  14569. case employee.FieldDeletedAt:
  14570. v, ok := value.(time.Time)
  14571. if !ok {
  14572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14573. }
  14574. m.SetDeletedAt(v)
  14575. return nil
  14576. case employee.FieldTitle:
  14577. v, ok := value.(string)
  14578. if !ok {
  14579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14580. }
  14581. m.SetTitle(v)
  14582. return nil
  14583. case employee.FieldAvatar:
  14584. v, ok := value.(string)
  14585. if !ok {
  14586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14587. }
  14588. m.SetAvatar(v)
  14589. return nil
  14590. case employee.FieldTags:
  14591. v, ok := value.(string)
  14592. if !ok {
  14593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14594. }
  14595. m.SetTags(v)
  14596. return nil
  14597. case employee.FieldHireCount:
  14598. v, ok := value.(int)
  14599. if !ok {
  14600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14601. }
  14602. m.SetHireCount(v)
  14603. return nil
  14604. case employee.FieldServiceCount:
  14605. v, ok := value.(int)
  14606. if !ok {
  14607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14608. }
  14609. m.SetServiceCount(v)
  14610. return nil
  14611. case employee.FieldAchievementCount:
  14612. v, ok := value.(int)
  14613. if !ok {
  14614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14615. }
  14616. m.SetAchievementCount(v)
  14617. return nil
  14618. case employee.FieldIntro:
  14619. v, ok := value.(string)
  14620. if !ok {
  14621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14622. }
  14623. m.SetIntro(v)
  14624. return nil
  14625. case employee.FieldEstimate:
  14626. v, ok := value.(string)
  14627. if !ok {
  14628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14629. }
  14630. m.SetEstimate(v)
  14631. return nil
  14632. case employee.FieldSkill:
  14633. v, ok := value.(string)
  14634. if !ok {
  14635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14636. }
  14637. m.SetSkill(v)
  14638. return nil
  14639. case employee.FieldAbilityType:
  14640. v, ok := value.(string)
  14641. if !ok {
  14642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14643. }
  14644. m.SetAbilityType(v)
  14645. return nil
  14646. case employee.FieldScene:
  14647. v, ok := value.(string)
  14648. if !ok {
  14649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14650. }
  14651. m.SetScene(v)
  14652. return nil
  14653. case employee.FieldSwitchIn:
  14654. v, ok := value.(string)
  14655. if !ok {
  14656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14657. }
  14658. m.SetSwitchIn(v)
  14659. return nil
  14660. case employee.FieldVideoURL:
  14661. v, ok := value.(string)
  14662. if !ok {
  14663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14664. }
  14665. m.SetVideoURL(v)
  14666. return nil
  14667. case employee.FieldOrganizationID:
  14668. v, ok := value.(uint64)
  14669. if !ok {
  14670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14671. }
  14672. m.SetOrganizationID(v)
  14673. return nil
  14674. case employee.FieldCategoryID:
  14675. v, ok := value.(uint64)
  14676. if !ok {
  14677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14678. }
  14679. m.SetCategoryID(v)
  14680. return nil
  14681. case employee.FieldAPIBase:
  14682. v, ok := value.(string)
  14683. if !ok {
  14684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14685. }
  14686. m.SetAPIBase(v)
  14687. return nil
  14688. case employee.FieldAPIKey:
  14689. v, ok := value.(string)
  14690. if !ok {
  14691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14692. }
  14693. m.SetAPIKey(v)
  14694. return nil
  14695. case employee.FieldAiInfo:
  14696. v, ok := value.(string)
  14697. if !ok {
  14698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14699. }
  14700. m.SetAiInfo(v)
  14701. return nil
  14702. case employee.FieldIsVip:
  14703. v, ok := value.(int)
  14704. if !ok {
  14705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14706. }
  14707. m.SetIsVip(v)
  14708. return nil
  14709. case employee.FieldChatURL:
  14710. v, ok := value.(string)
  14711. if !ok {
  14712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14713. }
  14714. m.SetChatURL(v)
  14715. return nil
  14716. }
  14717. return fmt.Errorf("unknown Employee field %s", name)
  14718. }
  14719. // AddedFields returns all numeric fields that were incremented/decremented during
  14720. // this mutation.
  14721. func (m *EmployeeMutation) AddedFields() []string {
  14722. var fields []string
  14723. if m.addhire_count != nil {
  14724. fields = append(fields, employee.FieldHireCount)
  14725. }
  14726. if m.addservice_count != nil {
  14727. fields = append(fields, employee.FieldServiceCount)
  14728. }
  14729. if m.addachievement_count != nil {
  14730. fields = append(fields, employee.FieldAchievementCount)
  14731. }
  14732. if m.addorganization_id != nil {
  14733. fields = append(fields, employee.FieldOrganizationID)
  14734. }
  14735. if m.addcategory_id != nil {
  14736. fields = append(fields, employee.FieldCategoryID)
  14737. }
  14738. if m.addis_vip != nil {
  14739. fields = append(fields, employee.FieldIsVip)
  14740. }
  14741. return fields
  14742. }
  14743. // AddedField returns the numeric value that was incremented/decremented on a field
  14744. // with the given name. The second boolean return value indicates that this field
  14745. // was not set, or was not defined in the schema.
  14746. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14747. switch name {
  14748. case employee.FieldHireCount:
  14749. return m.AddedHireCount()
  14750. case employee.FieldServiceCount:
  14751. return m.AddedServiceCount()
  14752. case employee.FieldAchievementCount:
  14753. return m.AddedAchievementCount()
  14754. case employee.FieldOrganizationID:
  14755. return m.AddedOrganizationID()
  14756. case employee.FieldCategoryID:
  14757. return m.AddedCategoryID()
  14758. case employee.FieldIsVip:
  14759. return m.AddedIsVip()
  14760. }
  14761. return nil, false
  14762. }
  14763. // AddField adds the value to the field with the given name. It returns an error if
  14764. // the field is not defined in the schema, or if the type mismatched the field
  14765. // type.
  14766. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14767. switch name {
  14768. case employee.FieldHireCount:
  14769. v, ok := value.(int)
  14770. if !ok {
  14771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14772. }
  14773. m.AddHireCount(v)
  14774. return nil
  14775. case employee.FieldServiceCount:
  14776. v, ok := value.(int)
  14777. if !ok {
  14778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14779. }
  14780. m.AddServiceCount(v)
  14781. return nil
  14782. case employee.FieldAchievementCount:
  14783. v, ok := value.(int)
  14784. if !ok {
  14785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14786. }
  14787. m.AddAchievementCount(v)
  14788. return nil
  14789. case employee.FieldOrganizationID:
  14790. v, ok := value.(int64)
  14791. if !ok {
  14792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14793. }
  14794. m.AddOrganizationID(v)
  14795. return nil
  14796. case employee.FieldCategoryID:
  14797. v, ok := value.(int64)
  14798. if !ok {
  14799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14800. }
  14801. m.AddCategoryID(v)
  14802. return nil
  14803. case employee.FieldIsVip:
  14804. v, ok := value.(int)
  14805. if !ok {
  14806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14807. }
  14808. m.AddIsVip(v)
  14809. return nil
  14810. }
  14811. return fmt.Errorf("unknown Employee numeric field %s", name)
  14812. }
  14813. // ClearedFields returns all nullable fields that were cleared during this
  14814. // mutation.
  14815. func (m *EmployeeMutation) ClearedFields() []string {
  14816. var fields []string
  14817. if m.FieldCleared(employee.FieldDeletedAt) {
  14818. fields = append(fields, employee.FieldDeletedAt)
  14819. }
  14820. if m.FieldCleared(employee.FieldAiInfo) {
  14821. fields = append(fields, employee.FieldAiInfo)
  14822. }
  14823. return fields
  14824. }
  14825. // FieldCleared returns a boolean indicating if a field with the given name was
  14826. // cleared in this mutation.
  14827. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14828. _, ok := m.clearedFields[name]
  14829. return ok
  14830. }
  14831. // ClearField clears the value of the field with the given name. It returns an
  14832. // error if the field is not defined in the schema.
  14833. func (m *EmployeeMutation) ClearField(name string) error {
  14834. switch name {
  14835. case employee.FieldDeletedAt:
  14836. m.ClearDeletedAt()
  14837. return nil
  14838. case employee.FieldAiInfo:
  14839. m.ClearAiInfo()
  14840. return nil
  14841. }
  14842. return fmt.Errorf("unknown Employee nullable field %s", name)
  14843. }
  14844. // ResetField resets all changes in the mutation for the field with the given name.
  14845. // It returns an error if the field is not defined in the schema.
  14846. func (m *EmployeeMutation) ResetField(name string) error {
  14847. switch name {
  14848. case employee.FieldCreatedAt:
  14849. m.ResetCreatedAt()
  14850. return nil
  14851. case employee.FieldUpdatedAt:
  14852. m.ResetUpdatedAt()
  14853. return nil
  14854. case employee.FieldDeletedAt:
  14855. m.ResetDeletedAt()
  14856. return nil
  14857. case employee.FieldTitle:
  14858. m.ResetTitle()
  14859. return nil
  14860. case employee.FieldAvatar:
  14861. m.ResetAvatar()
  14862. return nil
  14863. case employee.FieldTags:
  14864. m.ResetTags()
  14865. return nil
  14866. case employee.FieldHireCount:
  14867. m.ResetHireCount()
  14868. return nil
  14869. case employee.FieldServiceCount:
  14870. m.ResetServiceCount()
  14871. return nil
  14872. case employee.FieldAchievementCount:
  14873. m.ResetAchievementCount()
  14874. return nil
  14875. case employee.FieldIntro:
  14876. m.ResetIntro()
  14877. return nil
  14878. case employee.FieldEstimate:
  14879. m.ResetEstimate()
  14880. return nil
  14881. case employee.FieldSkill:
  14882. m.ResetSkill()
  14883. return nil
  14884. case employee.FieldAbilityType:
  14885. m.ResetAbilityType()
  14886. return nil
  14887. case employee.FieldScene:
  14888. m.ResetScene()
  14889. return nil
  14890. case employee.FieldSwitchIn:
  14891. m.ResetSwitchIn()
  14892. return nil
  14893. case employee.FieldVideoURL:
  14894. m.ResetVideoURL()
  14895. return nil
  14896. case employee.FieldOrganizationID:
  14897. m.ResetOrganizationID()
  14898. return nil
  14899. case employee.FieldCategoryID:
  14900. m.ResetCategoryID()
  14901. return nil
  14902. case employee.FieldAPIBase:
  14903. m.ResetAPIBase()
  14904. return nil
  14905. case employee.FieldAPIKey:
  14906. m.ResetAPIKey()
  14907. return nil
  14908. case employee.FieldAiInfo:
  14909. m.ResetAiInfo()
  14910. return nil
  14911. case employee.FieldIsVip:
  14912. m.ResetIsVip()
  14913. return nil
  14914. case employee.FieldChatURL:
  14915. m.ResetChatURL()
  14916. return nil
  14917. }
  14918. return fmt.Errorf("unknown Employee field %s", name)
  14919. }
  14920. // AddedEdges returns all edge names that were set/added in this mutation.
  14921. func (m *EmployeeMutation) AddedEdges() []string {
  14922. edges := make([]string, 0, 2)
  14923. if m.em_work_experiences != nil {
  14924. edges = append(edges, employee.EdgeEmWorkExperiences)
  14925. }
  14926. if m.em_tutorial != nil {
  14927. edges = append(edges, employee.EdgeEmTutorial)
  14928. }
  14929. return edges
  14930. }
  14931. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14932. // name in this mutation.
  14933. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  14934. switch name {
  14935. case employee.EdgeEmWorkExperiences:
  14936. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  14937. for id := range m.em_work_experiences {
  14938. ids = append(ids, id)
  14939. }
  14940. return ids
  14941. case employee.EdgeEmTutorial:
  14942. ids := make([]ent.Value, 0, len(m.em_tutorial))
  14943. for id := range m.em_tutorial {
  14944. ids = append(ids, id)
  14945. }
  14946. return ids
  14947. }
  14948. return nil
  14949. }
  14950. // RemovedEdges returns all edge names that were removed in this mutation.
  14951. func (m *EmployeeMutation) RemovedEdges() []string {
  14952. edges := make([]string, 0, 2)
  14953. if m.removedem_work_experiences != nil {
  14954. edges = append(edges, employee.EdgeEmWorkExperiences)
  14955. }
  14956. if m.removedem_tutorial != nil {
  14957. edges = append(edges, employee.EdgeEmTutorial)
  14958. }
  14959. return edges
  14960. }
  14961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14962. // the given name in this mutation.
  14963. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  14964. switch name {
  14965. case employee.EdgeEmWorkExperiences:
  14966. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  14967. for id := range m.removedem_work_experiences {
  14968. ids = append(ids, id)
  14969. }
  14970. return ids
  14971. case employee.EdgeEmTutorial:
  14972. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  14973. for id := range m.removedem_tutorial {
  14974. ids = append(ids, id)
  14975. }
  14976. return ids
  14977. }
  14978. return nil
  14979. }
  14980. // ClearedEdges returns all edge names that were cleared in this mutation.
  14981. func (m *EmployeeMutation) ClearedEdges() []string {
  14982. edges := make([]string, 0, 2)
  14983. if m.clearedem_work_experiences {
  14984. edges = append(edges, employee.EdgeEmWorkExperiences)
  14985. }
  14986. if m.clearedem_tutorial {
  14987. edges = append(edges, employee.EdgeEmTutorial)
  14988. }
  14989. return edges
  14990. }
  14991. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14992. // was cleared in this mutation.
  14993. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  14994. switch name {
  14995. case employee.EdgeEmWorkExperiences:
  14996. return m.clearedem_work_experiences
  14997. case employee.EdgeEmTutorial:
  14998. return m.clearedem_tutorial
  14999. }
  15000. return false
  15001. }
  15002. // ClearEdge clears the value of the edge with the given name. It returns an error
  15003. // if that edge is not defined in the schema.
  15004. func (m *EmployeeMutation) ClearEdge(name string) error {
  15005. switch name {
  15006. }
  15007. return fmt.Errorf("unknown Employee unique edge %s", name)
  15008. }
  15009. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15010. // It returns an error if the edge is not defined in the schema.
  15011. func (m *EmployeeMutation) ResetEdge(name string) error {
  15012. switch name {
  15013. case employee.EdgeEmWorkExperiences:
  15014. m.ResetEmWorkExperiences()
  15015. return nil
  15016. case employee.EdgeEmTutorial:
  15017. m.ResetEmTutorial()
  15018. return nil
  15019. }
  15020. return fmt.Errorf("unknown Employee edge %s", name)
  15021. }
  15022. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15023. type EmployeeConfigMutation struct {
  15024. config
  15025. op Op
  15026. typ string
  15027. id *uint64
  15028. created_at *time.Time
  15029. updated_at *time.Time
  15030. deleted_at *time.Time
  15031. stype *string
  15032. title *string
  15033. photo *string
  15034. organization_id *uint64
  15035. addorganization_id *int64
  15036. clearedFields map[string]struct{}
  15037. done bool
  15038. oldValue func(context.Context) (*EmployeeConfig, error)
  15039. predicates []predicate.EmployeeConfig
  15040. }
  15041. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15042. // employeeconfigOption allows management of the mutation configuration using functional options.
  15043. type employeeconfigOption func(*EmployeeConfigMutation)
  15044. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15045. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15046. m := &EmployeeConfigMutation{
  15047. config: c,
  15048. op: op,
  15049. typ: TypeEmployeeConfig,
  15050. clearedFields: make(map[string]struct{}),
  15051. }
  15052. for _, opt := range opts {
  15053. opt(m)
  15054. }
  15055. return m
  15056. }
  15057. // withEmployeeConfigID sets the ID field of the mutation.
  15058. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15059. return func(m *EmployeeConfigMutation) {
  15060. var (
  15061. err error
  15062. once sync.Once
  15063. value *EmployeeConfig
  15064. )
  15065. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15066. once.Do(func() {
  15067. if m.done {
  15068. err = errors.New("querying old values post mutation is not allowed")
  15069. } else {
  15070. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15071. }
  15072. })
  15073. return value, err
  15074. }
  15075. m.id = &id
  15076. }
  15077. }
  15078. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15079. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15080. return func(m *EmployeeConfigMutation) {
  15081. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15082. return node, nil
  15083. }
  15084. m.id = &node.ID
  15085. }
  15086. }
  15087. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15088. // executed in a transaction (ent.Tx), a transactional client is returned.
  15089. func (m EmployeeConfigMutation) Client() *Client {
  15090. client := &Client{config: m.config}
  15091. client.init()
  15092. return client
  15093. }
  15094. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15095. // it returns an error otherwise.
  15096. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15097. if _, ok := m.driver.(*txDriver); !ok {
  15098. return nil, errors.New("ent: mutation is not running in a transaction")
  15099. }
  15100. tx := &Tx{config: m.config}
  15101. tx.init()
  15102. return tx, nil
  15103. }
  15104. // SetID sets the value of the id field. Note that this
  15105. // operation is only accepted on creation of EmployeeConfig entities.
  15106. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15107. m.id = &id
  15108. }
  15109. // ID returns the ID value in the mutation. Note that the ID is only available
  15110. // if it was provided to the builder or after it was returned from the database.
  15111. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15112. if m.id == nil {
  15113. return
  15114. }
  15115. return *m.id, true
  15116. }
  15117. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15118. // That means, if the mutation is applied within a transaction with an isolation level such
  15119. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15120. // or updated by the mutation.
  15121. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15122. switch {
  15123. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15124. id, exists := m.ID()
  15125. if exists {
  15126. return []uint64{id}, nil
  15127. }
  15128. fallthrough
  15129. case m.op.Is(OpUpdate | OpDelete):
  15130. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15131. default:
  15132. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15133. }
  15134. }
  15135. // SetCreatedAt sets the "created_at" field.
  15136. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15137. m.created_at = &t
  15138. }
  15139. // CreatedAt returns the value of the "created_at" field in the mutation.
  15140. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15141. v := m.created_at
  15142. if v == nil {
  15143. return
  15144. }
  15145. return *v, true
  15146. }
  15147. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15148. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15150. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15151. if !m.op.Is(OpUpdateOne) {
  15152. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15153. }
  15154. if m.id == nil || m.oldValue == nil {
  15155. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15156. }
  15157. oldValue, err := m.oldValue(ctx)
  15158. if err != nil {
  15159. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15160. }
  15161. return oldValue.CreatedAt, nil
  15162. }
  15163. // ResetCreatedAt resets all changes to the "created_at" field.
  15164. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15165. m.created_at = nil
  15166. }
  15167. // SetUpdatedAt sets the "updated_at" field.
  15168. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15169. m.updated_at = &t
  15170. }
  15171. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15172. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15173. v := m.updated_at
  15174. if v == nil {
  15175. return
  15176. }
  15177. return *v, true
  15178. }
  15179. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15180. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15182. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15183. if !m.op.Is(OpUpdateOne) {
  15184. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15185. }
  15186. if m.id == nil || m.oldValue == nil {
  15187. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15188. }
  15189. oldValue, err := m.oldValue(ctx)
  15190. if err != nil {
  15191. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15192. }
  15193. return oldValue.UpdatedAt, nil
  15194. }
  15195. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15196. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15197. m.updated_at = nil
  15198. }
  15199. // SetDeletedAt sets the "deleted_at" field.
  15200. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15201. m.deleted_at = &t
  15202. }
  15203. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15204. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15205. v := m.deleted_at
  15206. if v == nil {
  15207. return
  15208. }
  15209. return *v, true
  15210. }
  15211. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15212. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15214. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15215. if !m.op.Is(OpUpdateOne) {
  15216. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15217. }
  15218. if m.id == nil || m.oldValue == nil {
  15219. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15220. }
  15221. oldValue, err := m.oldValue(ctx)
  15222. if err != nil {
  15223. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15224. }
  15225. return oldValue.DeletedAt, nil
  15226. }
  15227. // ClearDeletedAt clears the value of the "deleted_at" field.
  15228. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15229. m.deleted_at = nil
  15230. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15231. }
  15232. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15233. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15234. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15235. return ok
  15236. }
  15237. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15238. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15239. m.deleted_at = nil
  15240. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15241. }
  15242. // SetStype sets the "stype" field.
  15243. func (m *EmployeeConfigMutation) SetStype(s string) {
  15244. m.stype = &s
  15245. }
  15246. // Stype returns the value of the "stype" field in the mutation.
  15247. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15248. v := m.stype
  15249. if v == nil {
  15250. return
  15251. }
  15252. return *v, true
  15253. }
  15254. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15255. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15257. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15258. if !m.op.Is(OpUpdateOne) {
  15259. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15260. }
  15261. if m.id == nil || m.oldValue == nil {
  15262. return v, errors.New("OldStype requires an ID field in the mutation")
  15263. }
  15264. oldValue, err := m.oldValue(ctx)
  15265. if err != nil {
  15266. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15267. }
  15268. return oldValue.Stype, nil
  15269. }
  15270. // ResetStype resets all changes to the "stype" field.
  15271. func (m *EmployeeConfigMutation) ResetStype() {
  15272. m.stype = nil
  15273. }
  15274. // SetTitle sets the "title" field.
  15275. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15276. m.title = &s
  15277. }
  15278. // Title returns the value of the "title" field in the mutation.
  15279. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15280. v := m.title
  15281. if v == nil {
  15282. return
  15283. }
  15284. return *v, true
  15285. }
  15286. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15287. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15289. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15290. if !m.op.Is(OpUpdateOne) {
  15291. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15292. }
  15293. if m.id == nil || m.oldValue == nil {
  15294. return v, errors.New("OldTitle requires an ID field in the mutation")
  15295. }
  15296. oldValue, err := m.oldValue(ctx)
  15297. if err != nil {
  15298. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15299. }
  15300. return oldValue.Title, nil
  15301. }
  15302. // ResetTitle resets all changes to the "title" field.
  15303. func (m *EmployeeConfigMutation) ResetTitle() {
  15304. m.title = nil
  15305. }
  15306. // SetPhoto sets the "photo" field.
  15307. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15308. m.photo = &s
  15309. }
  15310. // Photo returns the value of the "photo" field in the mutation.
  15311. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15312. v := m.photo
  15313. if v == nil {
  15314. return
  15315. }
  15316. return *v, true
  15317. }
  15318. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15319. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15321. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15322. if !m.op.Is(OpUpdateOne) {
  15323. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15324. }
  15325. if m.id == nil || m.oldValue == nil {
  15326. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15327. }
  15328. oldValue, err := m.oldValue(ctx)
  15329. if err != nil {
  15330. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15331. }
  15332. return oldValue.Photo, nil
  15333. }
  15334. // ResetPhoto resets all changes to the "photo" field.
  15335. func (m *EmployeeConfigMutation) ResetPhoto() {
  15336. m.photo = nil
  15337. }
  15338. // SetOrganizationID sets the "organization_id" field.
  15339. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15340. m.organization_id = &u
  15341. m.addorganization_id = nil
  15342. }
  15343. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15344. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15345. v := m.organization_id
  15346. if v == nil {
  15347. return
  15348. }
  15349. return *v, true
  15350. }
  15351. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15352. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15354. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15355. if !m.op.Is(OpUpdateOne) {
  15356. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15357. }
  15358. if m.id == nil || m.oldValue == nil {
  15359. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15360. }
  15361. oldValue, err := m.oldValue(ctx)
  15362. if err != nil {
  15363. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15364. }
  15365. return oldValue.OrganizationID, nil
  15366. }
  15367. // AddOrganizationID adds u to the "organization_id" field.
  15368. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15369. if m.addorganization_id != nil {
  15370. *m.addorganization_id += u
  15371. } else {
  15372. m.addorganization_id = &u
  15373. }
  15374. }
  15375. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15376. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15377. v := m.addorganization_id
  15378. if v == nil {
  15379. return
  15380. }
  15381. return *v, true
  15382. }
  15383. // ClearOrganizationID clears the value of the "organization_id" field.
  15384. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15385. m.organization_id = nil
  15386. m.addorganization_id = nil
  15387. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15388. }
  15389. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15390. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15391. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15392. return ok
  15393. }
  15394. // ResetOrganizationID resets all changes to the "organization_id" field.
  15395. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15396. m.organization_id = nil
  15397. m.addorganization_id = nil
  15398. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15399. }
  15400. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15401. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15402. m.predicates = append(m.predicates, ps...)
  15403. }
  15404. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15405. // users can use type-assertion to append predicates that do not depend on any generated package.
  15406. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15407. p := make([]predicate.EmployeeConfig, len(ps))
  15408. for i := range ps {
  15409. p[i] = ps[i]
  15410. }
  15411. m.Where(p...)
  15412. }
  15413. // Op returns the operation name.
  15414. func (m *EmployeeConfigMutation) Op() Op {
  15415. return m.op
  15416. }
  15417. // SetOp allows setting the mutation operation.
  15418. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15419. m.op = op
  15420. }
  15421. // Type returns the node type of this mutation (EmployeeConfig).
  15422. func (m *EmployeeConfigMutation) Type() string {
  15423. return m.typ
  15424. }
  15425. // Fields returns all fields that were changed during this mutation. Note that in
  15426. // order to get all numeric fields that were incremented/decremented, call
  15427. // AddedFields().
  15428. func (m *EmployeeConfigMutation) Fields() []string {
  15429. fields := make([]string, 0, 7)
  15430. if m.created_at != nil {
  15431. fields = append(fields, employeeconfig.FieldCreatedAt)
  15432. }
  15433. if m.updated_at != nil {
  15434. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15435. }
  15436. if m.deleted_at != nil {
  15437. fields = append(fields, employeeconfig.FieldDeletedAt)
  15438. }
  15439. if m.stype != nil {
  15440. fields = append(fields, employeeconfig.FieldStype)
  15441. }
  15442. if m.title != nil {
  15443. fields = append(fields, employeeconfig.FieldTitle)
  15444. }
  15445. if m.photo != nil {
  15446. fields = append(fields, employeeconfig.FieldPhoto)
  15447. }
  15448. if m.organization_id != nil {
  15449. fields = append(fields, employeeconfig.FieldOrganizationID)
  15450. }
  15451. return fields
  15452. }
  15453. // Field returns the value of a field with the given name. The second boolean
  15454. // return value indicates that this field was not set, or was not defined in the
  15455. // schema.
  15456. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15457. switch name {
  15458. case employeeconfig.FieldCreatedAt:
  15459. return m.CreatedAt()
  15460. case employeeconfig.FieldUpdatedAt:
  15461. return m.UpdatedAt()
  15462. case employeeconfig.FieldDeletedAt:
  15463. return m.DeletedAt()
  15464. case employeeconfig.FieldStype:
  15465. return m.Stype()
  15466. case employeeconfig.FieldTitle:
  15467. return m.Title()
  15468. case employeeconfig.FieldPhoto:
  15469. return m.Photo()
  15470. case employeeconfig.FieldOrganizationID:
  15471. return m.OrganizationID()
  15472. }
  15473. return nil, false
  15474. }
  15475. // OldField returns the old value of the field from the database. An error is
  15476. // returned if the mutation operation is not UpdateOne, or the query to the
  15477. // database failed.
  15478. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15479. switch name {
  15480. case employeeconfig.FieldCreatedAt:
  15481. return m.OldCreatedAt(ctx)
  15482. case employeeconfig.FieldUpdatedAt:
  15483. return m.OldUpdatedAt(ctx)
  15484. case employeeconfig.FieldDeletedAt:
  15485. return m.OldDeletedAt(ctx)
  15486. case employeeconfig.FieldStype:
  15487. return m.OldStype(ctx)
  15488. case employeeconfig.FieldTitle:
  15489. return m.OldTitle(ctx)
  15490. case employeeconfig.FieldPhoto:
  15491. return m.OldPhoto(ctx)
  15492. case employeeconfig.FieldOrganizationID:
  15493. return m.OldOrganizationID(ctx)
  15494. }
  15495. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15496. }
  15497. // SetField sets the value of a field with the given name. It returns an error if
  15498. // the field is not defined in the schema, or if the type mismatched the field
  15499. // type.
  15500. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15501. switch name {
  15502. case employeeconfig.FieldCreatedAt:
  15503. v, ok := value.(time.Time)
  15504. if !ok {
  15505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15506. }
  15507. m.SetCreatedAt(v)
  15508. return nil
  15509. case employeeconfig.FieldUpdatedAt:
  15510. v, ok := value.(time.Time)
  15511. if !ok {
  15512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15513. }
  15514. m.SetUpdatedAt(v)
  15515. return nil
  15516. case employeeconfig.FieldDeletedAt:
  15517. v, ok := value.(time.Time)
  15518. if !ok {
  15519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15520. }
  15521. m.SetDeletedAt(v)
  15522. return nil
  15523. case employeeconfig.FieldStype:
  15524. v, ok := value.(string)
  15525. if !ok {
  15526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15527. }
  15528. m.SetStype(v)
  15529. return nil
  15530. case employeeconfig.FieldTitle:
  15531. v, ok := value.(string)
  15532. if !ok {
  15533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15534. }
  15535. m.SetTitle(v)
  15536. return nil
  15537. case employeeconfig.FieldPhoto:
  15538. v, ok := value.(string)
  15539. if !ok {
  15540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15541. }
  15542. m.SetPhoto(v)
  15543. return nil
  15544. case employeeconfig.FieldOrganizationID:
  15545. v, ok := value.(uint64)
  15546. if !ok {
  15547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15548. }
  15549. m.SetOrganizationID(v)
  15550. return nil
  15551. }
  15552. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15553. }
  15554. // AddedFields returns all numeric fields that were incremented/decremented during
  15555. // this mutation.
  15556. func (m *EmployeeConfigMutation) AddedFields() []string {
  15557. var fields []string
  15558. if m.addorganization_id != nil {
  15559. fields = append(fields, employeeconfig.FieldOrganizationID)
  15560. }
  15561. return fields
  15562. }
  15563. // AddedField returns the numeric value that was incremented/decremented on a field
  15564. // with the given name. The second boolean return value indicates that this field
  15565. // was not set, or was not defined in the schema.
  15566. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15567. switch name {
  15568. case employeeconfig.FieldOrganizationID:
  15569. return m.AddedOrganizationID()
  15570. }
  15571. return nil, false
  15572. }
  15573. // AddField adds the value to the field with the given name. It returns an error if
  15574. // the field is not defined in the schema, or if the type mismatched the field
  15575. // type.
  15576. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15577. switch name {
  15578. case employeeconfig.FieldOrganizationID:
  15579. v, ok := value.(int64)
  15580. if !ok {
  15581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15582. }
  15583. m.AddOrganizationID(v)
  15584. return nil
  15585. }
  15586. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15587. }
  15588. // ClearedFields returns all nullable fields that were cleared during this
  15589. // mutation.
  15590. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15591. var fields []string
  15592. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15593. fields = append(fields, employeeconfig.FieldDeletedAt)
  15594. }
  15595. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15596. fields = append(fields, employeeconfig.FieldOrganizationID)
  15597. }
  15598. return fields
  15599. }
  15600. // FieldCleared returns a boolean indicating if a field with the given name was
  15601. // cleared in this mutation.
  15602. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15603. _, ok := m.clearedFields[name]
  15604. return ok
  15605. }
  15606. // ClearField clears the value of the field with the given name. It returns an
  15607. // error if the field is not defined in the schema.
  15608. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15609. switch name {
  15610. case employeeconfig.FieldDeletedAt:
  15611. m.ClearDeletedAt()
  15612. return nil
  15613. case employeeconfig.FieldOrganizationID:
  15614. m.ClearOrganizationID()
  15615. return nil
  15616. }
  15617. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15618. }
  15619. // ResetField resets all changes in the mutation for the field with the given name.
  15620. // It returns an error if the field is not defined in the schema.
  15621. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15622. switch name {
  15623. case employeeconfig.FieldCreatedAt:
  15624. m.ResetCreatedAt()
  15625. return nil
  15626. case employeeconfig.FieldUpdatedAt:
  15627. m.ResetUpdatedAt()
  15628. return nil
  15629. case employeeconfig.FieldDeletedAt:
  15630. m.ResetDeletedAt()
  15631. return nil
  15632. case employeeconfig.FieldStype:
  15633. m.ResetStype()
  15634. return nil
  15635. case employeeconfig.FieldTitle:
  15636. m.ResetTitle()
  15637. return nil
  15638. case employeeconfig.FieldPhoto:
  15639. m.ResetPhoto()
  15640. return nil
  15641. case employeeconfig.FieldOrganizationID:
  15642. m.ResetOrganizationID()
  15643. return nil
  15644. }
  15645. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15646. }
  15647. // AddedEdges returns all edge names that were set/added in this mutation.
  15648. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15649. edges := make([]string, 0, 0)
  15650. return edges
  15651. }
  15652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15653. // name in this mutation.
  15654. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15655. return nil
  15656. }
  15657. // RemovedEdges returns all edge names that were removed in this mutation.
  15658. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15659. edges := make([]string, 0, 0)
  15660. return edges
  15661. }
  15662. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15663. // the given name in this mutation.
  15664. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15665. return nil
  15666. }
  15667. // ClearedEdges returns all edge names that were cleared in this mutation.
  15668. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15669. edges := make([]string, 0, 0)
  15670. return edges
  15671. }
  15672. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15673. // was cleared in this mutation.
  15674. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15675. return false
  15676. }
  15677. // ClearEdge clears the value of the edge with the given name. It returns an error
  15678. // if that edge is not defined in the schema.
  15679. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15680. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15681. }
  15682. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15683. // It returns an error if the edge is not defined in the schema.
  15684. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15685. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15686. }
  15687. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15688. type LabelMutation struct {
  15689. config
  15690. op Op
  15691. typ string
  15692. id *uint64
  15693. created_at *time.Time
  15694. updated_at *time.Time
  15695. status *uint8
  15696. addstatus *int8
  15697. _type *int
  15698. add_type *int
  15699. name *string
  15700. from *int
  15701. addfrom *int
  15702. mode *int
  15703. addmode *int
  15704. conditions *string
  15705. organization_id *uint64
  15706. addorganization_id *int64
  15707. clearedFields map[string]struct{}
  15708. label_relationships map[uint64]struct{}
  15709. removedlabel_relationships map[uint64]struct{}
  15710. clearedlabel_relationships bool
  15711. done bool
  15712. oldValue func(context.Context) (*Label, error)
  15713. predicates []predicate.Label
  15714. }
  15715. var _ ent.Mutation = (*LabelMutation)(nil)
  15716. // labelOption allows management of the mutation configuration using functional options.
  15717. type labelOption func(*LabelMutation)
  15718. // newLabelMutation creates new mutation for the Label entity.
  15719. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15720. m := &LabelMutation{
  15721. config: c,
  15722. op: op,
  15723. typ: TypeLabel,
  15724. clearedFields: make(map[string]struct{}),
  15725. }
  15726. for _, opt := range opts {
  15727. opt(m)
  15728. }
  15729. return m
  15730. }
  15731. // withLabelID sets the ID field of the mutation.
  15732. func withLabelID(id uint64) labelOption {
  15733. return func(m *LabelMutation) {
  15734. var (
  15735. err error
  15736. once sync.Once
  15737. value *Label
  15738. )
  15739. m.oldValue = func(ctx context.Context) (*Label, error) {
  15740. once.Do(func() {
  15741. if m.done {
  15742. err = errors.New("querying old values post mutation is not allowed")
  15743. } else {
  15744. value, err = m.Client().Label.Get(ctx, id)
  15745. }
  15746. })
  15747. return value, err
  15748. }
  15749. m.id = &id
  15750. }
  15751. }
  15752. // withLabel sets the old Label of the mutation.
  15753. func withLabel(node *Label) labelOption {
  15754. return func(m *LabelMutation) {
  15755. m.oldValue = func(context.Context) (*Label, error) {
  15756. return node, nil
  15757. }
  15758. m.id = &node.ID
  15759. }
  15760. }
  15761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15762. // executed in a transaction (ent.Tx), a transactional client is returned.
  15763. func (m LabelMutation) Client() *Client {
  15764. client := &Client{config: m.config}
  15765. client.init()
  15766. return client
  15767. }
  15768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15769. // it returns an error otherwise.
  15770. func (m LabelMutation) Tx() (*Tx, error) {
  15771. if _, ok := m.driver.(*txDriver); !ok {
  15772. return nil, errors.New("ent: mutation is not running in a transaction")
  15773. }
  15774. tx := &Tx{config: m.config}
  15775. tx.init()
  15776. return tx, nil
  15777. }
  15778. // SetID sets the value of the id field. Note that this
  15779. // operation is only accepted on creation of Label entities.
  15780. func (m *LabelMutation) SetID(id uint64) {
  15781. m.id = &id
  15782. }
  15783. // ID returns the ID value in the mutation. Note that the ID is only available
  15784. // if it was provided to the builder or after it was returned from the database.
  15785. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15786. if m.id == nil {
  15787. return
  15788. }
  15789. return *m.id, true
  15790. }
  15791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15792. // That means, if the mutation is applied within a transaction with an isolation level such
  15793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15794. // or updated by the mutation.
  15795. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15796. switch {
  15797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15798. id, exists := m.ID()
  15799. if exists {
  15800. return []uint64{id}, nil
  15801. }
  15802. fallthrough
  15803. case m.op.Is(OpUpdate | OpDelete):
  15804. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15805. default:
  15806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15807. }
  15808. }
  15809. // SetCreatedAt sets the "created_at" field.
  15810. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15811. m.created_at = &t
  15812. }
  15813. // CreatedAt returns the value of the "created_at" field in the mutation.
  15814. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15815. v := m.created_at
  15816. if v == nil {
  15817. return
  15818. }
  15819. return *v, true
  15820. }
  15821. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15822. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15824. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15825. if !m.op.Is(OpUpdateOne) {
  15826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15827. }
  15828. if m.id == nil || m.oldValue == nil {
  15829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15830. }
  15831. oldValue, err := m.oldValue(ctx)
  15832. if err != nil {
  15833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15834. }
  15835. return oldValue.CreatedAt, nil
  15836. }
  15837. // ResetCreatedAt resets all changes to the "created_at" field.
  15838. func (m *LabelMutation) ResetCreatedAt() {
  15839. m.created_at = nil
  15840. }
  15841. // SetUpdatedAt sets the "updated_at" field.
  15842. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15843. m.updated_at = &t
  15844. }
  15845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15846. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  15847. v := m.updated_at
  15848. if v == nil {
  15849. return
  15850. }
  15851. return *v, true
  15852. }
  15853. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  15854. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15856. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15857. if !m.op.Is(OpUpdateOne) {
  15858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15859. }
  15860. if m.id == nil || m.oldValue == nil {
  15861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15862. }
  15863. oldValue, err := m.oldValue(ctx)
  15864. if err != nil {
  15865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15866. }
  15867. return oldValue.UpdatedAt, nil
  15868. }
  15869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15870. func (m *LabelMutation) ResetUpdatedAt() {
  15871. m.updated_at = nil
  15872. }
  15873. // SetStatus sets the "status" field.
  15874. func (m *LabelMutation) SetStatus(u uint8) {
  15875. m.status = &u
  15876. m.addstatus = nil
  15877. }
  15878. // Status returns the value of the "status" field in the mutation.
  15879. func (m *LabelMutation) Status() (r uint8, exists bool) {
  15880. v := m.status
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldStatus returns the old "status" field's value of the Label entity.
  15887. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldStatus requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15899. }
  15900. return oldValue.Status, nil
  15901. }
  15902. // AddStatus adds u to the "status" field.
  15903. func (m *LabelMutation) AddStatus(u int8) {
  15904. if m.addstatus != nil {
  15905. *m.addstatus += u
  15906. } else {
  15907. m.addstatus = &u
  15908. }
  15909. }
  15910. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15911. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  15912. v := m.addstatus
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // ClearStatus clears the value of the "status" field.
  15919. func (m *LabelMutation) ClearStatus() {
  15920. m.status = nil
  15921. m.addstatus = nil
  15922. m.clearedFields[label.FieldStatus] = struct{}{}
  15923. }
  15924. // StatusCleared returns if the "status" field was cleared in this mutation.
  15925. func (m *LabelMutation) StatusCleared() bool {
  15926. _, ok := m.clearedFields[label.FieldStatus]
  15927. return ok
  15928. }
  15929. // ResetStatus resets all changes to the "status" field.
  15930. func (m *LabelMutation) ResetStatus() {
  15931. m.status = nil
  15932. m.addstatus = nil
  15933. delete(m.clearedFields, label.FieldStatus)
  15934. }
  15935. // SetType sets the "type" field.
  15936. func (m *LabelMutation) SetType(i int) {
  15937. m._type = &i
  15938. m.add_type = nil
  15939. }
  15940. // GetType returns the value of the "type" field in the mutation.
  15941. func (m *LabelMutation) GetType() (r int, exists bool) {
  15942. v := m._type
  15943. if v == nil {
  15944. return
  15945. }
  15946. return *v, true
  15947. }
  15948. // OldType returns the old "type" field's value of the Label entity.
  15949. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15951. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  15952. if !m.op.Is(OpUpdateOne) {
  15953. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15954. }
  15955. if m.id == nil || m.oldValue == nil {
  15956. return v, errors.New("OldType requires an ID field in the mutation")
  15957. }
  15958. oldValue, err := m.oldValue(ctx)
  15959. if err != nil {
  15960. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15961. }
  15962. return oldValue.Type, nil
  15963. }
  15964. // AddType adds i to the "type" field.
  15965. func (m *LabelMutation) AddType(i int) {
  15966. if m.add_type != nil {
  15967. *m.add_type += i
  15968. } else {
  15969. m.add_type = &i
  15970. }
  15971. }
  15972. // AddedType returns the value that was added to the "type" field in this mutation.
  15973. func (m *LabelMutation) AddedType() (r int, exists bool) {
  15974. v := m.add_type
  15975. if v == nil {
  15976. return
  15977. }
  15978. return *v, true
  15979. }
  15980. // ResetType resets all changes to the "type" field.
  15981. func (m *LabelMutation) ResetType() {
  15982. m._type = nil
  15983. m.add_type = nil
  15984. }
  15985. // SetName sets the "name" field.
  15986. func (m *LabelMutation) SetName(s string) {
  15987. m.name = &s
  15988. }
  15989. // Name returns the value of the "name" field in the mutation.
  15990. func (m *LabelMutation) Name() (r string, exists bool) {
  15991. v := m.name
  15992. if v == nil {
  15993. return
  15994. }
  15995. return *v, true
  15996. }
  15997. // OldName returns the old "name" field's value of the Label entity.
  15998. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16000. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16001. if !m.op.Is(OpUpdateOne) {
  16002. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16003. }
  16004. if m.id == nil || m.oldValue == nil {
  16005. return v, errors.New("OldName requires an ID field in the mutation")
  16006. }
  16007. oldValue, err := m.oldValue(ctx)
  16008. if err != nil {
  16009. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16010. }
  16011. return oldValue.Name, nil
  16012. }
  16013. // ResetName resets all changes to the "name" field.
  16014. func (m *LabelMutation) ResetName() {
  16015. m.name = nil
  16016. }
  16017. // SetFrom sets the "from" field.
  16018. func (m *LabelMutation) SetFrom(i int) {
  16019. m.from = &i
  16020. m.addfrom = nil
  16021. }
  16022. // From returns the value of the "from" field in the mutation.
  16023. func (m *LabelMutation) From() (r int, exists bool) {
  16024. v := m.from
  16025. if v == nil {
  16026. return
  16027. }
  16028. return *v, true
  16029. }
  16030. // OldFrom returns the old "from" field's value of the Label entity.
  16031. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16033. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16034. if !m.op.Is(OpUpdateOne) {
  16035. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16036. }
  16037. if m.id == nil || m.oldValue == nil {
  16038. return v, errors.New("OldFrom requires an ID field in the mutation")
  16039. }
  16040. oldValue, err := m.oldValue(ctx)
  16041. if err != nil {
  16042. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16043. }
  16044. return oldValue.From, nil
  16045. }
  16046. // AddFrom adds i to the "from" field.
  16047. func (m *LabelMutation) AddFrom(i int) {
  16048. if m.addfrom != nil {
  16049. *m.addfrom += i
  16050. } else {
  16051. m.addfrom = &i
  16052. }
  16053. }
  16054. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16055. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16056. v := m.addfrom
  16057. if v == nil {
  16058. return
  16059. }
  16060. return *v, true
  16061. }
  16062. // ResetFrom resets all changes to the "from" field.
  16063. func (m *LabelMutation) ResetFrom() {
  16064. m.from = nil
  16065. m.addfrom = nil
  16066. }
  16067. // SetMode sets the "mode" field.
  16068. func (m *LabelMutation) SetMode(i int) {
  16069. m.mode = &i
  16070. m.addmode = nil
  16071. }
  16072. // Mode returns the value of the "mode" field in the mutation.
  16073. func (m *LabelMutation) Mode() (r int, exists bool) {
  16074. v := m.mode
  16075. if v == nil {
  16076. return
  16077. }
  16078. return *v, true
  16079. }
  16080. // OldMode returns the old "mode" field's value of the Label entity.
  16081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16083. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16084. if !m.op.Is(OpUpdateOne) {
  16085. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16086. }
  16087. if m.id == nil || m.oldValue == nil {
  16088. return v, errors.New("OldMode requires an ID field in the mutation")
  16089. }
  16090. oldValue, err := m.oldValue(ctx)
  16091. if err != nil {
  16092. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16093. }
  16094. return oldValue.Mode, nil
  16095. }
  16096. // AddMode adds i to the "mode" field.
  16097. func (m *LabelMutation) AddMode(i int) {
  16098. if m.addmode != nil {
  16099. *m.addmode += i
  16100. } else {
  16101. m.addmode = &i
  16102. }
  16103. }
  16104. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16105. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16106. v := m.addmode
  16107. if v == nil {
  16108. return
  16109. }
  16110. return *v, true
  16111. }
  16112. // ResetMode resets all changes to the "mode" field.
  16113. func (m *LabelMutation) ResetMode() {
  16114. m.mode = nil
  16115. m.addmode = nil
  16116. }
  16117. // SetConditions sets the "conditions" field.
  16118. func (m *LabelMutation) SetConditions(s string) {
  16119. m.conditions = &s
  16120. }
  16121. // Conditions returns the value of the "conditions" field in the mutation.
  16122. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16123. v := m.conditions
  16124. if v == nil {
  16125. return
  16126. }
  16127. return *v, true
  16128. }
  16129. // OldConditions returns the old "conditions" field's value of the Label entity.
  16130. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16132. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16133. if !m.op.Is(OpUpdateOne) {
  16134. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16135. }
  16136. if m.id == nil || m.oldValue == nil {
  16137. return v, errors.New("OldConditions requires an ID field in the mutation")
  16138. }
  16139. oldValue, err := m.oldValue(ctx)
  16140. if err != nil {
  16141. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16142. }
  16143. return oldValue.Conditions, nil
  16144. }
  16145. // ClearConditions clears the value of the "conditions" field.
  16146. func (m *LabelMutation) ClearConditions() {
  16147. m.conditions = nil
  16148. m.clearedFields[label.FieldConditions] = struct{}{}
  16149. }
  16150. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16151. func (m *LabelMutation) ConditionsCleared() bool {
  16152. _, ok := m.clearedFields[label.FieldConditions]
  16153. return ok
  16154. }
  16155. // ResetConditions resets all changes to the "conditions" field.
  16156. func (m *LabelMutation) ResetConditions() {
  16157. m.conditions = nil
  16158. delete(m.clearedFields, label.FieldConditions)
  16159. }
  16160. // SetOrganizationID sets the "organization_id" field.
  16161. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16162. m.organization_id = &u
  16163. m.addorganization_id = nil
  16164. }
  16165. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16166. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16167. v := m.organization_id
  16168. if v == nil {
  16169. return
  16170. }
  16171. return *v, true
  16172. }
  16173. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16174. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16176. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16177. if !m.op.Is(OpUpdateOne) {
  16178. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16179. }
  16180. if m.id == nil || m.oldValue == nil {
  16181. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16182. }
  16183. oldValue, err := m.oldValue(ctx)
  16184. if err != nil {
  16185. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16186. }
  16187. return oldValue.OrganizationID, nil
  16188. }
  16189. // AddOrganizationID adds u to the "organization_id" field.
  16190. func (m *LabelMutation) AddOrganizationID(u int64) {
  16191. if m.addorganization_id != nil {
  16192. *m.addorganization_id += u
  16193. } else {
  16194. m.addorganization_id = &u
  16195. }
  16196. }
  16197. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16198. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16199. v := m.addorganization_id
  16200. if v == nil {
  16201. return
  16202. }
  16203. return *v, true
  16204. }
  16205. // ClearOrganizationID clears the value of the "organization_id" field.
  16206. func (m *LabelMutation) ClearOrganizationID() {
  16207. m.organization_id = nil
  16208. m.addorganization_id = nil
  16209. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16210. }
  16211. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16212. func (m *LabelMutation) OrganizationIDCleared() bool {
  16213. _, ok := m.clearedFields[label.FieldOrganizationID]
  16214. return ok
  16215. }
  16216. // ResetOrganizationID resets all changes to the "organization_id" field.
  16217. func (m *LabelMutation) ResetOrganizationID() {
  16218. m.organization_id = nil
  16219. m.addorganization_id = nil
  16220. delete(m.clearedFields, label.FieldOrganizationID)
  16221. }
  16222. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16223. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16224. if m.label_relationships == nil {
  16225. m.label_relationships = make(map[uint64]struct{})
  16226. }
  16227. for i := range ids {
  16228. m.label_relationships[ids[i]] = struct{}{}
  16229. }
  16230. }
  16231. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16232. func (m *LabelMutation) ClearLabelRelationships() {
  16233. m.clearedlabel_relationships = true
  16234. }
  16235. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16236. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16237. return m.clearedlabel_relationships
  16238. }
  16239. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16240. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16241. if m.removedlabel_relationships == nil {
  16242. m.removedlabel_relationships = make(map[uint64]struct{})
  16243. }
  16244. for i := range ids {
  16245. delete(m.label_relationships, ids[i])
  16246. m.removedlabel_relationships[ids[i]] = struct{}{}
  16247. }
  16248. }
  16249. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16250. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16251. for id := range m.removedlabel_relationships {
  16252. ids = append(ids, id)
  16253. }
  16254. return
  16255. }
  16256. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16257. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16258. for id := range m.label_relationships {
  16259. ids = append(ids, id)
  16260. }
  16261. return
  16262. }
  16263. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16264. func (m *LabelMutation) ResetLabelRelationships() {
  16265. m.label_relationships = nil
  16266. m.clearedlabel_relationships = false
  16267. m.removedlabel_relationships = nil
  16268. }
  16269. // Where appends a list predicates to the LabelMutation builder.
  16270. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16271. m.predicates = append(m.predicates, ps...)
  16272. }
  16273. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16274. // users can use type-assertion to append predicates that do not depend on any generated package.
  16275. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16276. p := make([]predicate.Label, len(ps))
  16277. for i := range ps {
  16278. p[i] = ps[i]
  16279. }
  16280. m.Where(p...)
  16281. }
  16282. // Op returns the operation name.
  16283. func (m *LabelMutation) Op() Op {
  16284. return m.op
  16285. }
  16286. // SetOp allows setting the mutation operation.
  16287. func (m *LabelMutation) SetOp(op Op) {
  16288. m.op = op
  16289. }
  16290. // Type returns the node type of this mutation (Label).
  16291. func (m *LabelMutation) Type() string {
  16292. return m.typ
  16293. }
  16294. // Fields returns all fields that were changed during this mutation. Note that in
  16295. // order to get all numeric fields that were incremented/decremented, call
  16296. // AddedFields().
  16297. func (m *LabelMutation) Fields() []string {
  16298. fields := make([]string, 0, 9)
  16299. if m.created_at != nil {
  16300. fields = append(fields, label.FieldCreatedAt)
  16301. }
  16302. if m.updated_at != nil {
  16303. fields = append(fields, label.FieldUpdatedAt)
  16304. }
  16305. if m.status != nil {
  16306. fields = append(fields, label.FieldStatus)
  16307. }
  16308. if m._type != nil {
  16309. fields = append(fields, label.FieldType)
  16310. }
  16311. if m.name != nil {
  16312. fields = append(fields, label.FieldName)
  16313. }
  16314. if m.from != nil {
  16315. fields = append(fields, label.FieldFrom)
  16316. }
  16317. if m.mode != nil {
  16318. fields = append(fields, label.FieldMode)
  16319. }
  16320. if m.conditions != nil {
  16321. fields = append(fields, label.FieldConditions)
  16322. }
  16323. if m.organization_id != nil {
  16324. fields = append(fields, label.FieldOrganizationID)
  16325. }
  16326. return fields
  16327. }
  16328. // Field returns the value of a field with the given name. The second boolean
  16329. // return value indicates that this field was not set, or was not defined in the
  16330. // schema.
  16331. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16332. switch name {
  16333. case label.FieldCreatedAt:
  16334. return m.CreatedAt()
  16335. case label.FieldUpdatedAt:
  16336. return m.UpdatedAt()
  16337. case label.FieldStatus:
  16338. return m.Status()
  16339. case label.FieldType:
  16340. return m.GetType()
  16341. case label.FieldName:
  16342. return m.Name()
  16343. case label.FieldFrom:
  16344. return m.From()
  16345. case label.FieldMode:
  16346. return m.Mode()
  16347. case label.FieldConditions:
  16348. return m.Conditions()
  16349. case label.FieldOrganizationID:
  16350. return m.OrganizationID()
  16351. }
  16352. return nil, false
  16353. }
  16354. // OldField returns the old value of the field from the database. An error is
  16355. // returned if the mutation operation is not UpdateOne, or the query to the
  16356. // database failed.
  16357. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16358. switch name {
  16359. case label.FieldCreatedAt:
  16360. return m.OldCreatedAt(ctx)
  16361. case label.FieldUpdatedAt:
  16362. return m.OldUpdatedAt(ctx)
  16363. case label.FieldStatus:
  16364. return m.OldStatus(ctx)
  16365. case label.FieldType:
  16366. return m.OldType(ctx)
  16367. case label.FieldName:
  16368. return m.OldName(ctx)
  16369. case label.FieldFrom:
  16370. return m.OldFrom(ctx)
  16371. case label.FieldMode:
  16372. return m.OldMode(ctx)
  16373. case label.FieldConditions:
  16374. return m.OldConditions(ctx)
  16375. case label.FieldOrganizationID:
  16376. return m.OldOrganizationID(ctx)
  16377. }
  16378. return nil, fmt.Errorf("unknown Label field %s", name)
  16379. }
  16380. // SetField sets the value of a field with the given name. It returns an error if
  16381. // the field is not defined in the schema, or if the type mismatched the field
  16382. // type.
  16383. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16384. switch name {
  16385. case label.FieldCreatedAt:
  16386. v, ok := value.(time.Time)
  16387. if !ok {
  16388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16389. }
  16390. m.SetCreatedAt(v)
  16391. return nil
  16392. case label.FieldUpdatedAt:
  16393. v, ok := value.(time.Time)
  16394. if !ok {
  16395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16396. }
  16397. m.SetUpdatedAt(v)
  16398. return nil
  16399. case label.FieldStatus:
  16400. v, ok := value.(uint8)
  16401. if !ok {
  16402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16403. }
  16404. m.SetStatus(v)
  16405. return nil
  16406. case label.FieldType:
  16407. v, ok := value.(int)
  16408. if !ok {
  16409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16410. }
  16411. m.SetType(v)
  16412. return nil
  16413. case label.FieldName:
  16414. v, ok := value.(string)
  16415. if !ok {
  16416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16417. }
  16418. m.SetName(v)
  16419. return nil
  16420. case label.FieldFrom:
  16421. v, ok := value.(int)
  16422. if !ok {
  16423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16424. }
  16425. m.SetFrom(v)
  16426. return nil
  16427. case label.FieldMode:
  16428. v, ok := value.(int)
  16429. if !ok {
  16430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16431. }
  16432. m.SetMode(v)
  16433. return nil
  16434. case label.FieldConditions:
  16435. v, ok := value.(string)
  16436. if !ok {
  16437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16438. }
  16439. m.SetConditions(v)
  16440. return nil
  16441. case label.FieldOrganizationID:
  16442. v, ok := value.(uint64)
  16443. if !ok {
  16444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16445. }
  16446. m.SetOrganizationID(v)
  16447. return nil
  16448. }
  16449. return fmt.Errorf("unknown Label field %s", name)
  16450. }
  16451. // AddedFields returns all numeric fields that were incremented/decremented during
  16452. // this mutation.
  16453. func (m *LabelMutation) AddedFields() []string {
  16454. var fields []string
  16455. if m.addstatus != nil {
  16456. fields = append(fields, label.FieldStatus)
  16457. }
  16458. if m.add_type != nil {
  16459. fields = append(fields, label.FieldType)
  16460. }
  16461. if m.addfrom != nil {
  16462. fields = append(fields, label.FieldFrom)
  16463. }
  16464. if m.addmode != nil {
  16465. fields = append(fields, label.FieldMode)
  16466. }
  16467. if m.addorganization_id != nil {
  16468. fields = append(fields, label.FieldOrganizationID)
  16469. }
  16470. return fields
  16471. }
  16472. // AddedField returns the numeric value that was incremented/decremented on a field
  16473. // with the given name. The second boolean return value indicates that this field
  16474. // was not set, or was not defined in the schema.
  16475. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16476. switch name {
  16477. case label.FieldStatus:
  16478. return m.AddedStatus()
  16479. case label.FieldType:
  16480. return m.AddedType()
  16481. case label.FieldFrom:
  16482. return m.AddedFrom()
  16483. case label.FieldMode:
  16484. return m.AddedMode()
  16485. case label.FieldOrganizationID:
  16486. return m.AddedOrganizationID()
  16487. }
  16488. return nil, false
  16489. }
  16490. // AddField adds the value to the field with the given name. It returns an error if
  16491. // the field is not defined in the schema, or if the type mismatched the field
  16492. // type.
  16493. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16494. switch name {
  16495. case label.FieldStatus:
  16496. v, ok := value.(int8)
  16497. if !ok {
  16498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16499. }
  16500. m.AddStatus(v)
  16501. return nil
  16502. case label.FieldType:
  16503. v, ok := value.(int)
  16504. if !ok {
  16505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16506. }
  16507. m.AddType(v)
  16508. return nil
  16509. case label.FieldFrom:
  16510. v, ok := value.(int)
  16511. if !ok {
  16512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16513. }
  16514. m.AddFrom(v)
  16515. return nil
  16516. case label.FieldMode:
  16517. v, ok := value.(int)
  16518. if !ok {
  16519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16520. }
  16521. m.AddMode(v)
  16522. return nil
  16523. case label.FieldOrganizationID:
  16524. v, ok := value.(int64)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.AddOrganizationID(v)
  16529. return nil
  16530. }
  16531. return fmt.Errorf("unknown Label numeric field %s", name)
  16532. }
  16533. // ClearedFields returns all nullable fields that were cleared during this
  16534. // mutation.
  16535. func (m *LabelMutation) ClearedFields() []string {
  16536. var fields []string
  16537. if m.FieldCleared(label.FieldStatus) {
  16538. fields = append(fields, label.FieldStatus)
  16539. }
  16540. if m.FieldCleared(label.FieldConditions) {
  16541. fields = append(fields, label.FieldConditions)
  16542. }
  16543. if m.FieldCleared(label.FieldOrganizationID) {
  16544. fields = append(fields, label.FieldOrganizationID)
  16545. }
  16546. return fields
  16547. }
  16548. // FieldCleared returns a boolean indicating if a field with the given name was
  16549. // cleared in this mutation.
  16550. func (m *LabelMutation) FieldCleared(name string) bool {
  16551. _, ok := m.clearedFields[name]
  16552. return ok
  16553. }
  16554. // ClearField clears the value of the field with the given name. It returns an
  16555. // error if the field is not defined in the schema.
  16556. func (m *LabelMutation) ClearField(name string) error {
  16557. switch name {
  16558. case label.FieldStatus:
  16559. m.ClearStatus()
  16560. return nil
  16561. case label.FieldConditions:
  16562. m.ClearConditions()
  16563. return nil
  16564. case label.FieldOrganizationID:
  16565. m.ClearOrganizationID()
  16566. return nil
  16567. }
  16568. return fmt.Errorf("unknown Label nullable field %s", name)
  16569. }
  16570. // ResetField resets all changes in the mutation for the field with the given name.
  16571. // It returns an error if the field is not defined in the schema.
  16572. func (m *LabelMutation) ResetField(name string) error {
  16573. switch name {
  16574. case label.FieldCreatedAt:
  16575. m.ResetCreatedAt()
  16576. return nil
  16577. case label.FieldUpdatedAt:
  16578. m.ResetUpdatedAt()
  16579. return nil
  16580. case label.FieldStatus:
  16581. m.ResetStatus()
  16582. return nil
  16583. case label.FieldType:
  16584. m.ResetType()
  16585. return nil
  16586. case label.FieldName:
  16587. m.ResetName()
  16588. return nil
  16589. case label.FieldFrom:
  16590. m.ResetFrom()
  16591. return nil
  16592. case label.FieldMode:
  16593. m.ResetMode()
  16594. return nil
  16595. case label.FieldConditions:
  16596. m.ResetConditions()
  16597. return nil
  16598. case label.FieldOrganizationID:
  16599. m.ResetOrganizationID()
  16600. return nil
  16601. }
  16602. return fmt.Errorf("unknown Label field %s", name)
  16603. }
  16604. // AddedEdges returns all edge names that were set/added in this mutation.
  16605. func (m *LabelMutation) AddedEdges() []string {
  16606. edges := make([]string, 0, 1)
  16607. if m.label_relationships != nil {
  16608. edges = append(edges, label.EdgeLabelRelationships)
  16609. }
  16610. return edges
  16611. }
  16612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16613. // name in this mutation.
  16614. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16615. switch name {
  16616. case label.EdgeLabelRelationships:
  16617. ids := make([]ent.Value, 0, len(m.label_relationships))
  16618. for id := range m.label_relationships {
  16619. ids = append(ids, id)
  16620. }
  16621. return ids
  16622. }
  16623. return nil
  16624. }
  16625. // RemovedEdges returns all edge names that were removed in this mutation.
  16626. func (m *LabelMutation) RemovedEdges() []string {
  16627. edges := make([]string, 0, 1)
  16628. if m.removedlabel_relationships != nil {
  16629. edges = append(edges, label.EdgeLabelRelationships)
  16630. }
  16631. return edges
  16632. }
  16633. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16634. // the given name in this mutation.
  16635. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16636. switch name {
  16637. case label.EdgeLabelRelationships:
  16638. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16639. for id := range m.removedlabel_relationships {
  16640. ids = append(ids, id)
  16641. }
  16642. return ids
  16643. }
  16644. return nil
  16645. }
  16646. // ClearedEdges returns all edge names that were cleared in this mutation.
  16647. func (m *LabelMutation) ClearedEdges() []string {
  16648. edges := make([]string, 0, 1)
  16649. if m.clearedlabel_relationships {
  16650. edges = append(edges, label.EdgeLabelRelationships)
  16651. }
  16652. return edges
  16653. }
  16654. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16655. // was cleared in this mutation.
  16656. func (m *LabelMutation) EdgeCleared(name string) bool {
  16657. switch name {
  16658. case label.EdgeLabelRelationships:
  16659. return m.clearedlabel_relationships
  16660. }
  16661. return false
  16662. }
  16663. // ClearEdge clears the value of the edge with the given name. It returns an error
  16664. // if that edge is not defined in the schema.
  16665. func (m *LabelMutation) ClearEdge(name string) error {
  16666. switch name {
  16667. }
  16668. return fmt.Errorf("unknown Label unique edge %s", name)
  16669. }
  16670. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16671. // It returns an error if the edge is not defined in the schema.
  16672. func (m *LabelMutation) ResetEdge(name string) error {
  16673. switch name {
  16674. case label.EdgeLabelRelationships:
  16675. m.ResetLabelRelationships()
  16676. return nil
  16677. }
  16678. return fmt.Errorf("unknown Label edge %s", name)
  16679. }
  16680. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16681. type LabelRelationshipMutation struct {
  16682. config
  16683. op Op
  16684. typ string
  16685. id *uint64
  16686. created_at *time.Time
  16687. updated_at *time.Time
  16688. status *uint8
  16689. addstatus *int8
  16690. organization_id *uint64
  16691. addorganization_id *int64
  16692. clearedFields map[string]struct{}
  16693. contacts *uint64
  16694. clearedcontacts bool
  16695. labels *uint64
  16696. clearedlabels bool
  16697. done bool
  16698. oldValue func(context.Context) (*LabelRelationship, error)
  16699. predicates []predicate.LabelRelationship
  16700. }
  16701. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16702. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16703. type labelrelationshipOption func(*LabelRelationshipMutation)
  16704. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16705. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16706. m := &LabelRelationshipMutation{
  16707. config: c,
  16708. op: op,
  16709. typ: TypeLabelRelationship,
  16710. clearedFields: make(map[string]struct{}),
  16711. }
  16712. for _, opt := range opts {
  16713. opt(m)
  16714. }
  16715. return m
  16716. }
  16717. // withLabelRelationshipID sets the ID field of the mutation.
  16718. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16719. return func(m *LabelRelationshipMutation) {
  16720. var (
  16721. err error
  16722. once sync.Once
  16723. value *LabelRelationship
  16724. )
  16725. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16726. once.Do(func() {
  16727. if m.done {
  16728. err = errors.New("querying old values post mutation is not allowed")
  16729. } else {
  16730. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16731. }
  16732. })
  16733. return value, err
  16734. }
  16735. m.id = &id
  16736. }
  16737. }
  16738. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16739. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16740. return func(m *LabelRelationshipMutation) {
  16741. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16742. return node, nil
  16743. }
  16744. m.id = &node.ID
  16745. }
  16746. }
  16747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16748. // executed in a transaction (ent.Tx), a transactional client is returned.
  16749. func (m LabelRelationshipMutation) Client() *Client {
  16750. client := &Client{config: m.config}
  16751. client.init()
  16752. return client
  16753. }
  16754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16755. // it returns an error otherwise.
  16756. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16757. if _, ok := m.driver.(*txDriver); !ok {
  16758. return nil, errors.New("ent: mutation is not running in a transaction")
  16759. }
  16760. tx := &Tx{config: m.config}
  16761. tx.init()
  16762. return tx, nil
  16763. }
  16764. // SetID sets the value of the id field. Note that this
  16765. // operation is only accepted on creation of LabelRelationship entities.
  16766. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16767. m.id = &id
  16768. }
  16769. // ID returns the ID value in the mutation. Note that the ID is only available
  16770. // if it was provided to the builder or after it was returned from the database.
  16771. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16772. if m.id == nil {
  16773. return
  16774. }
  16775. return *m.id, true
  16776. }
  16777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16778. // That means, if the mutation is applied within a transaction with an isolation level such
  16779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16780. // or updated by the mutation.
  16781. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16782. switch {
  16783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16784. id, exists := m.ID()
  16785. if exists {
  16786. return []uint64{id}, nil
  16787. }
  16788. fallthrough
  16789. case m.op.Is(OpUpdate | OpDelete):
  16790. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16791. default:
  16792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16793. }
  16794. }
  16795. // SetCreatedAt sets the "created_at" field.
  16796. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16797. m.created_at = &t
  16798. }
  16799. // CreatedAt returns the value of the "created_at" field in the mutation.
  16800. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16801. v := m.created_at
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16808. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16820. }
  16821. return oldValue.CreatedAt, nil
  16822. }
  16823. // ResetCreatedAt resets all changes to the "created_at" field.
  16824. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16825. m.created_at = nil
  16826. }
  16827. // SetUpdatedAt sets the "updated_at" field.
  16828. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16829. m.updated_at = &t
  16830. }
  16831. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16832. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16833. v := m.updated_at
  16834. if v == nil {
  16835. return
  16836. }
  16837. return *v, true
  16838. }
  16839. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16840. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16842. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16843. if !m.op.Is(OpUpdateOne) {
  16844. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16845. }
  16846. if m.id == nil || m.oldValue == nil {
  16847. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16848. }
  16849. oldValue, err := m.oldValue(ctx)
  16850. if err != nil {
  16851. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16852. }
  16853. return oldValue.UpdatedAt, nil
  16854. }
  16855. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16856. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  16857. m.updated_at = nil
  16858. }
  16859. // SetStatus sets the "status" field.
  16860. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  16861. m.status = &u
  16862. m.addstatus = nil
  16863. }
  16864. // Status returns the value of the "status" field in the mutation.
  16865. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  16866. v := m.status
  16867. if v == nil {
  16868. return
  16869. }
  16870. return *v, true
  16871. }
  16872. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  16873. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16875. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16876. if !m.op.Is(OpUpdateOne) {
  16877. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16878. }
  16879. if m.id == nil || m.oldValue == nil {
  16880. return v, errors.New("OldStatus requires an ID field in the mutation")
  16881. }
  16882. oldValue, err := m.oldValue(ctx)
  16883. if err != nil {
  16884. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16885. }
  16886. return oldValue.Status, nil
  16887. }
  16888. // AddStatus adds u to the "status" field.
  16889. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  16890. if m.addstatus != nil {
  16891. *m.addstatus += u
  16892. } else {
  16893. m.addstatus = &u
  16894. }
  16895. }
  16896. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16897. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  16898. v := m.addstatus
  16899. if v == nil {
  16900. return
  16901. }
  16902. return *v, true
  16903. }
  16904. // ClearStatus clears the value of the "status" field.
  16905. func (m *LabelRelationshipMutation) ClearStatus() {
  16906. m.status = nil
  16907. m.addstatus = nil
  16908. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  16909. }
  16910. // StatusCleared returns if the "status" field was cleared in this mutation.
  16911. func (m *LabelRelationshipMutation) StatusCleared() bool {
  16912. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  16913. return ok
  16914. }
  16915. // ResetStatus resets all changes to the "status" field.
  16916. func (m *LabelRelationshipMutation) ResetStatus() {
  16917. m.status = nil
  16918. m.addstatus = nil
  16919. delete(m.clearedFields, labelrelationship.FieldStatus)
  16920. }
  16921. // SetLabelID sets the "label_id" field.
  16922. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  16923. m.labels = &u
  16924. }
  16925. // LabelID returns the value of the "label_id" field in the mutation.
  16926. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  16927. v := m.labels
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  16934. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldLabelID requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  16946. }
  16947. return oldValue.LabelID, nil
  16948. }
  16949. // ResetLabelID resets all changes to the "label_id" field.
  16950. func (m *LabelRelationshipMutation) ResetLabelID() {
  16951. m.labels = nil
  16952. }
  16953. // SetContactID sets the "contact_id" field.
  16954. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  16955. m.contacts = &u
  16956. }
  16957. // ContactID returns the value of the "contact_id" field in the mutation.
  16958. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  16959. v := m.contacts
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  16966. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldContactID requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16978. }
  16979. return oldValue.ContactID, nil
  16980. }
  16981. // ResetContactID resets all changes to the "contact_id" field.
  16982. func (m *LabelRelationshipMutation) ResetContactID() {
  16983. m.contacts = nil
  16984. }
  16985. // SetOrganizationID sets the "organization_id" field.
  16986. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  16987. m.organization_id = &u
  16988. m.addorganization_id = nil
  16989. }
  16990. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16991. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  16992. v := m.organization_id
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  16999. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17011. }
  17012. return oldValue.OrganizationID, nil
  17013. }
  17014. // AddOrganizationID adds u to the "organization_id" field.
  17015. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17016. if m.addorganization_id != nil {
  17017. *m.addorganization_id += u
  17018. } else {
  17019. m.addorganization_id = &u
  17020. }
  17021. }
  17022. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17023. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17024. v := m.addorganization_id
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // ClearOrganizationID clears the value of the "organization_id" field.
  17031. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17032. m.organization_id = nil
  17033. m.addorganization_id = nil
  17034. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17035. }
  17036. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17037. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17038. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17039. return ok
  17040. }
  17041. // ResetOrganizationID resets all changes to the "organization_id" field.
  17042. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17043. m.organization_id = nil
  17044. m.addorganization_id = nil
  17045. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17046. }
  17047. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17048. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17049. m.contacts = &id
  17050. }
  17051. // ClearContacts clears the "contacts" edge to the Contact entity.
  17052. func (m *LabelRelationshipMutation) ClearContacts() {
  17053. m.clearedcontacts = true
  17054. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17055. }
  17056. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17057. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17058. return m.clearedcontacts
  17059. }
  17060. // ContactsID returns the "contacts" edge ID in the mutation.
  17061. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17062. if m.contacts != nil {
  17063. return *m.contacts, true
  17064. }
  17065. return
  17066. }
  17067. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17068. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17069. // ContactsID instead. It exists only for internal usage by the builders.
  17070. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17071. if id := m.contacts; id != nil {
  17072. ids = append(ids, *id)
  17073. }
  17074. return
  17075. }
  17076. // ResetContacts resets all changes to the "contacts" edge.
  17077. func (m *LabelRelationshipMutation) ResetContacts() {
  17078. m.contacts = nil
  17079. m.clearedcontacts = false
  17080. }
  17081. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17082. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17083. m.labels = &id
  17084. }
  17085. // ClearLabels clears the "labels" edge to the Label entity.
  17086. func (m *LabelRelationshipMutation) ClearLabels() {
  17087. m.clearedlabels = true
  17088. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17089. }
  17090. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17091. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17092. return m.clearedlabels
  17093. }
  17094. // LabelsID returns the "labels" edge ID in the mutation.
  17095. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17096. if m.labels != nil {
  17097. return *m.labels, true
  17098. }
  17099. return
  17100. }
  17101. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17102. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17103. // LabelsID instead. It exists only for internal usage by the builders.
  17104. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17105. if id := m.labels; id != nil {
  17106. ids = append(ids, *id)
  17107. }
  17108. return
  17109. }
  17110. // ResetLabels resets all changes to the "labels" edge.
  17111. func (m *LabelRelationshipMutation) ResetLabels() {
  17112. m.labels = nil
  17113. m.clearedlabels = false
  17114. }
  17115. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17116. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17117. m.predicates = append(m.predicates, ps...)
  17118. }
  17119. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17120. // users can use type-assertion to append predicates that do not depend on any generated package.
  17121. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17122. p := make([]predicate.LabelRelationship, len(ps))
  17123. for i := range ps {
  17124. p[i] = ps[i]
  17125. }
  17126. m.Where(p...)
  17127. }
  17128. // Op returns the operation name.
  17129. func (m *LabelRelationshipMutation) Op() Op {
  17130. return m.op
  17131. }
  17132. // SetOp allows setting the mutation operation.
  17133. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17134. m.op = op
  17135. }
  17136. // Type returns the node type of this mutation (LabelRelationship).
  17137. func (m *LabelRelationshipMutation) Type() string {
  17138. return m.typ
  17139. }
  17140. // Fields returns all fields that were changed during this mutation. Note that in
  17141. // order to get all numeric fields that were incremented/decremented, call
  17142. // AddedFields().
  17143. func (m *LabelRelationshipMutation) Fields() []string {
  17144. fields := make([]string, 0, 6)
  17145. if m.created_at != nil {
  17146. fields = append(fields, labelrelationship.FieldCreatedAt)
  17147. }
  17148. if m.updated_at != nil {
  17149. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17150. }
  17151. if m.status != nil {
  17152. fields = append(fields, labelrelationship.FieldStatus)
  17153. }
  17154. if m.labels != nil {
  17155. fields = append(fields, labelrelationship.FieldLabelID)
  17156. }
  17157. if m.contacts != nil {
  17158. fields = append(fields, labelrelationship.FieldContactID)
  17159. }
  17160. if m.organization_id != nil {
  17161. fields = append(fields, labelrelationship.FieldOrganizationID)
  17162. }
  17163. return fields
  17164. }
  17165. // Field returns the value of a field with the given name. The second boolean
  17166. // return value indicates that this field was not set, or was not defined in the
  17167. // schema.
  17168. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17169. switch name {
  17170. case labelrelationship.FieldCreatedAt:
  17171. return m.CreatedAt()
  17172. case labelrelationship.FieldUpdatedAt:
  17173. return m.UpdatedAt()
  17174. case labelrelationship.FieldStatus:
  17175. return m.Status()
  17176. case labelrelationship.FieldLabelID:
  17177. return m.LabelID()
  17178. case labelrelationship.FieldContactID:
  17179. return m.ContactID()
  17180. case labelrelationship.FieldOrganizationID:
  17181. return m.OrganizationID()
  17182. }
  17183. return nil, false
  17184. }
  17185. // OldField returns the old value of the field from the database. An error is
  17186. // returned if the mutation operation is not UpdateOne, or the query to the
  17187. // database failed.
  17188. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17189. switch name {
  17190. case labelrelationship.FieldCreatedAt:
  17191. return m.OldCreatedAt(ctx)
  17192. case labelrelationship.FieldUpdatedAt:
  17193. return m.OldUpdatedAt(ctx)
  17194. case labelrelationship.FieldStatus:
  17195. return m.OldStatus(ctx)
  17196. case labelrelationship.FieldLabelID:
  17197. return m.OldLabelID(ctx)
  17198. case labelrelationship.FieldContactID:
  17199. return m.OldContactID(ctx)
  17200. case labelrelationship.FieldOrganizationID:
  17201. return m.OldOrganizationID(ctx)
  17202. }
  17203. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17204. }
  17205. // SetField sets the value of a field with the given name. It returns an error if
  17206. // the field is not defined in the schema, or if the type mismatched the field
  17207. // type.
  17208. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17209. switch name {
  17210. case labelrelationship.FieldCreatedAt:
  17211. v, ok := value.(time.Time)
  17212. if !ok {
  17213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17214. }
  17215. m.SetCreatedAt(v)
  17216. return nil
  17217. case labelrelationship.FieldUpdatedAt:
  17218. v, ok := value.(time.Time)
  17219. if !ok {
  17220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17221. }
  17222. m.SetUpdatedAt(v)
  17223. return nil
  17224. case labelrelationship.FieldStatus:
  17225. v, ok := value.(uint8)
  17226. if !ok {
  17227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17228. }
  17229. m.SetStatus(v)
  17230. return nil
  17231. case labelrelationship.FieldLabelID:
  17232. v, ok := value.(uint64)
  17233. if !ok {
  17234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17235. }
  17236. m.SetLabelID(v)
  17237. return nil
  17238. case labelrelationship.FieldContactID:
  17239. v, ok := value.(uint64)
  17240. if !ok {
  17241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17242. }
  17243. m.SetContactID(v)
  17244. return nil
  17245. case labelrelationship.FieldOrganizationID:
  17246. v, ok := value.(uint64)
  17247. if !ok {
  17248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17249. }
  17250. m.SetOrganizationID(v)
  17251. return nil
  17252. }
  17253. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17254. }
  17255. // AddedFields returns all numeric fields that were incremented/decremented during
  17256. // this mutation.
  17257. func (m *LabelRelationshipMutation) AddedFields() []string {
  17258. var fields []string
  17259. if m.addstatus != nil {
  17260. fields = append(fields, labelrelationship.FieldStatus)
  17261. }
  17262. if m.addorganization_id != nil {
  17263. fields = append(fields, labelrelationship.FieldOrganizationID)
  17264. }
  17265. return fields
  17266. }
  17267. // AddedField returns the numeric value that was incremented/decremented on a field
  17268. // with the given name. The second boolean return value indicates that this field
  17269. // was not set, or was not defined in the schema.
  17270. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17271. switch name {
  17272. case labelrelationship.FieldStatus:
  17273. return m.AddedStatus()
  17274. case labelrelationship.FieldOrganizationID:
  17275. return m.AddedOrganizationID()
  17276. }
  17277. return nil, false
  17278. }
  17279. // AddField adds the value to the field with the given name. It returns an error if
  17280. // the field is not defined in the schema, or if the type mismatched the field
  17281. // type.
  17282. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17283. switch name {
  17284. case labelrelationship.FieldStatus:
  17285. v, ok := value.(int8)
  17286. if !ok {
  17287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17288. }
  17289. m.AddStatus(v)
  17290. return nil
  17291. case labelrelationship.FieldOrganizationID:
  17292. v, ok := value.(int64)
  17293. if !ok {
  17294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17295. }
  17296. m.AddOrganizationID(v)
  17297. return nil
  17298. }
  17299. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17300. }
  17301. // ClearedFields returns all nullable fields that were cleared during this
  17302. // mutation.
  17303. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17304. var fields []string
  17305. if m.FieldCleared(labelrelationship.FieldStatus) {
  17306. fields = append(fields, labelrelationship.FieldStatus)
  17307. }
  17308. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17309. fields = append(fields, labelrelationship.FieldOrganizationID)
  17310. }
  17311. return fields
  17312. }
  17313. // FieldCleared returns a boolean indicating if a field with the given name was
  17314. // cleared in this mutation.
  17315. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17316. _, ok := m.clearedFields[name]
  17317. return ok
  17318. }
  17319. // ClearField clears the value of the field with the given name. It returns an
  17320. // error if the field is not defined in the schema.
  17321. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17322. switch name {
  17323. case labelrelationship.FieldStatus:
  17324. m.ClearStatus()
  17325. return nil
  17326. case labelrelationship.FieldOrganizationID:
  17327. m.ClearOrganizationID()
  17328. return nil
  17329. }
  17330. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17331. }
  17332. // ResetField resets all changes in the mutation for the field with the given name.
  17333. // It returns an error if the field is not defined in the schema.
  17334. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17335. switch name {
  17336. case labelrelationship.FieldCreatedAt:
  17337. m.ResetCreatedAt()
  17338. return nil
  17339. case labelrelationship.FieldUpdatedAt:
  17340. m.ResetUpdatedAt()
  17341. return nil
  17342. case labelrelationship.FieldStatus:
  17343. m.ResetStatus()
  17344. return nil
  17345. case labelrelationship.FieldLabelID:
  17346. m.ResetLabelID()
  17347. return nil
  17348. case labelrelationship.FieldContactID:
  17349. m.ResetContactID()
  17350. return nil
  17351. case labelrelationship.FieldOrganizationID:
  17352. m.ResetOrganizationID()
  17353. return nil
  17354. }
  17355. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17356. }
  17357. // AddedEdges returns all edge names that were set/added in this mutation.
  17358. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17359. edges := make([]string, 0, 2)
  17360. if m.contacts != nil {
  17361. edges = append(edges, labelrelationship.EdgeContacts)
  17362. }
  17363. if m.labels != nil {
  17364. edges = append(edges, labelrelationship.EdgeLabels)
  17365. }
  17366. return edges
  17367. }
  17368. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17369. // name in this mutation.
  17370. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17371. switch name {
  17372. case labelrelationship.EdgeContacts:
  17373. if id := m.contacts; id != nil {
  17374. return []ent.Value{*id}
  17375. }
  17376. case labelrelationship.EdgeLabels:
  17377. if id := m.labels; id != nil {
  17378. return []ent.Value{*id}
  17379. }
  17380. }
  17381. return nil
  17382. }
  17383. // RemovedEdges returns all edge names that were removed in this mutation.
  17384. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17385. edges := make([]string, 0, 2)
  17386. return edges
  17387. }
  17388. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17389. // the given name in this mutation.
  17390. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17391. return nil
  17392. }
  17393. // ClearedEdges returns all edge names that were cleared in this mutation.
  17394. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17395. edges := make([]string, 0, 2)
  17396. if m.clearedcontacts {
  17397. edges = append(edges, labelrelationship.EdgeContacts)
  17398. }
  17399. if m.clearedlabels {
  17400. edges = append(edges, labelrelationship.EdgeLabels)
  17401. }
  17402. return edges
  17403. }
  17404. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17405. // was cleared in this mutation.
  17406. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17407. switch name {
  17408. case labelrelationship.EdgeContacts:
  17409. return m.clearedcontacts
  17410. case labelrelationship.EdgeLabels:
  17411. return m.clearedlabels
  17412. }
  17413. return false
  17414. }
  17415. // ClearEdge clears the value of the edge with the given name. It returns an error
  17416. // if that edge is not defined in the schema.
  17417. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17418. switch name {
  17419. case labelrelationship.EdgeContacts:
  17420. m.ClearContacts()
  17421. return nil
  17422. case labelrelationship.EdgeLabels:
  17423. m.ClearLabels()
  17424. return nil
  17425. }
  17426. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17427. }
  17428. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17429. // It returns an error if the edge is not defined in the schema.
  17430. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17431. switch name {
  17432. case labelrelationship.EdgeContacts:
  17433. m.ResetContacts()
  17434. return nil
  17435. case labelrelationship.EdgeLabels:
  17436. m.ResetLabels()
  17437. return nil
  17438. }
  17439. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17440. }
  17441. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17442. type LabelTaggingMutation struct {
  17443. config
  17444. op Op
  17445. typ string
  17446. id *uint64
  17447. created_at *time.Time
  17448. updated_at *time.Time
  17449. status *uint8
  17450. addstatus *int8
  17451. deleted_at *time.Time
  17452. organization_id *uint64
  17453. addorganization_id *int64
  17454. _type *int
  17455. add_type *int
  17456. conditions *string
  17457. action_label_add *[]uint64
  17458. appendaction_label_add []uint64
  17459. action_label_del *[]uint64
  17460. appendaction_label_del []uint64
  17461. clearedFields map[string]struct{}
  17462. done bool
  17463. oldValue func(context.Context) (*LabelTagging, error)
  17464. predicates []predicate.LabelTagging
  17465. }
  17466. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17467. // labeltaggingOption allows management of the mutation configuration using functional options.
  17468. type labeltaggingOption func(*LabelTaggingMutation)
  17469. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17470. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17471. m := &LabelTaggingMutation{
  17472. config: c,
  17473. op: op,
  17474. typ: TypeLabelTagging,
  17475. clearedFields: make(map[string]struct{}),
  17476. }
  17477. for _, opt := range opts {
  17478. opt(m)
  17479. }
  17480. return m
  17481. }
  17482. // withLabelTaggingID sets the ID field of the mutation.
  17483. func withLabelTaggingID(id uint64) labeltaggingOption {
  17484. return func(m *LabelTaggingMutation) {
  17485. var (
  17486. err error
  17487. once sync.Once
  17488. value *LabelTagging
  17489. )
  17490. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17491. once.Do(func() {
  17492. if m.done {
  17493. err = errors.New("querying old values post mutation is not allowed")
  17494. } else {
  17495. value, err = m.Client().LabelTagging.Get(ctx, id)
  17496. }
  17497. })
  17498. return value, err
  17499. }
  17500. m.id = &id
  17501. }
  17502. }
  17503. // withLabelTagging sets the old LabelTagging of the mutation.
  17504. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17505. return func(m *LabelTaggingMutation) {
  17506. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17507. return node, nil
  17508. }
  17509. m.id = &node.ID
  17510. }
  17511. }
  17512. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17513. // executed in a transaction (ent.Tx), a transactional client is returned.
  17514. func (m LabelTaggingMutation) Client() *Client {
  17515. client := &Client{config: m.config}
  17516. client.init()
  17517. return client
  17518. }
  17519. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17520. // it returns an error otherwise.
  17521. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17522. if _, ok := m.driver.(*txDriver); !ok {
  17523. return nil, errors.New("ent: mutation is not running in a transaction")
  17524. }
  17525. tx := &Tx{config: m.config}
  17526. tx.init()
  17527. return tx, nil
  17528. }
  17529. // SetID sets the value of the id field. Note that this
  17530. // operation is only accepted on creation of LabelTagging entities.
  17531. func (m *LabelTaggingMutation) SetID(id uint64) {
  17532. m.id = &id
  17533. }
  17534. // ID returns the ID value in the mutation. Note that the ID is only available
  17535. // if it was provided to the builder or after it was returned from the database.
  17536. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17537. if m.id == nil {
  17538. return
  17539. }
  17540. return *m.id, true
  17541. }
  17542. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17543. // That means, if the mutation is applied within a transaction with an isolation level such
  17544. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17545. // or updated by the mutation.
  17546. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17547. switch {
  17548. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17549. id, exists := m.ID()
  17550. if exists {
  17551. return []uint64{id}, nil
  17552. }
  17553. fallthrough
  17554. case m.op.Is(OpUpdate | OpDelete):
  17555. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17556. default:
  17557. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17558. }
  17559. }
  17560. // SetCreatedAt sets the "created_at" field.
  17561. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17562. m.created_at = &t
  17563. }
  17564. // CreatedAt returns the value of the "created_at" field in the mutation.
  17565. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17566. v := m.created_at
  17567. if v == nil {
  17568. return
  17569. }
  17570. return *v, true
  17571. }
  17572. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17573. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17575. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17576. if !m.op.Is(OpUpdateOne) {
  17577. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17578. }
  17579. if m.id == nil || m.oldValue == nil {
  17580. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17581. }
  17582. oldValue, err := m.oldValue(ctx)
  17583. if err != nil {
  17584. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17585. }
  17586. return oldValue.CreatedAt, nil
  17587. }
  17588. // ResetCreatedAt resets all changes to the "created_at" field.
  17589. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17590. m.created_at = nil
  17591. }
  17592. // SetUpdatedAt sets the "updated_at" field.
  17593. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17594. m.updated_at = &t
  17595. }
  17596. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17597. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17598. v := m.updated_at
  17599. if v == nil {
  17600. return
  17601. }
  17602. return *v, true
  17603. }
  17604. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17605. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17607. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17608. if !m.op.Is(OpUpdateOne) {
  17609. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17610. }
  17611. if m.id == nil || m.oldValue == nil {
  17612. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17613. }
  17614. oldValue, err := m.oldValue(ctx)
  17615. if err != nil {
  17616. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17617. }
  17618. return oldValue.UpdatedAt, nil
  17619. }
  17620. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17621. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17622. m.updated_at = nil
  17623. }
  17624. // SetStatus sets the "status" field.
  17625. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17626. m.status = &u
  17627. m.addstatus = nil
  17628. }
  17629. // Status returns the value of the "status" field in the mutation.
  17630. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17631. v := m.status
  17632. if v == nil {
  17633. return
  17634. }
  17635. return *v, true
  17636. }
  17637. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17638. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17640. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17641. if !m.op.Is(OpUpdateOne) {
  17642. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17643. }
  17644. if m.id == nil || m.oldValue == nil {
  17645. return v, errors.New("OldStatus requires an ID field in the mutation")
  17646. }
  17647. oldValue, err := m.oldValue(ctx)
  17648. if err != nil {
  17649. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17650. }
  17651. return oldValue.Status, nil
  17652. }
  17653. // AddStatus adds u to the "status" field.
  17654. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17655. if m.addstatus != nil {
  17656. *m.addstatus += u
  17657. } else {
  17658. m.addstatus = &u
  17659. }
  17660. }
  17661. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17662. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17663. v := m.addstatus
  17664. if v == nil {
  17665. return
  17666. }
  17667. return *v, true
  17668. }
  17669. // ClearStatus clears the value of the "status" field.
  17670. func (m *LabelTaggingMutation) ClearStatus() {
  17671. m.status = nil
  17672. m.addstatus = nil
  17673. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17674. }
  17675. // StatusCleared returns if the "status" field was cleared in this mutation.
  17676. func (m *LabelTaggingMutation) StatusCleared() bool {
  17677. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17678. return ok
  17679. }
  17680. // ResetStatus resets all changes to the "status" field.
  17681. func (m *LabelTaggingMutation) ResetStatus() {
  17682. m.status = nil
  17683. m.addstatus = nil
  17684. delete(m.clearedFields, labeltagging.FieldStatus)
  17685. }
  17686. // SetDeletedAt sets the "deleted_at" field.
  17687. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17688. m.deleted_at = &t
  17689. }
  17690. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17691. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17692. v := m.deleted_at
  17693. if v == nil {
  17694. return
  17695. }
  17696. return *v, true
  17697. }
  17698. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17699. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17701. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17702. if !m.op.Is(OpUpdateOne) {
  17703. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17704. }
  17705. if m.id == nil || m.oldValue == nil {
  17706. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17707. }
  17708. oldValue, err := m.oldValue(ctx)
  17709. if err != nil {
  17710. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17711. }
  17712. return oldValue.DeletedAt, nil
  17713. }
  17714. // ClearDeletedAt clears the value of the "deleted_at" field.
  17715. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17716. m.deleted_at = nil
  17717. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17718. }
  17719. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17720. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17721. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17722. return ok
  17723. }
  17724. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17725. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17726. m.deleted_at = nil
  17727. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17728. }
  17729. // SetOrganizationID sets the "organization_id" field.
  17730. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17731. m.organization_id = &u
  17732. m.addorganization_id = nil
  17733. }
  17734. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17735. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17736. v := m.organization_id
  17737. if v == nil {
  17738. return
  17739. }
  17740. return *v, true
  17741. }
  17742. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17743. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17745. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17746. if !m.op.Is(OpUpdateOne) {
  17747. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17748. }
  17749. if m.id == nil || m.oldValue == nil {
  17750. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17751. }
  17752. oldValue, err := m.oldValue(ctx)
  17753. if err != nil {
  17754. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17755. }
  17756. return oldValue.OrganizationID, nil
  17757. }
  17758. // AddOrganizationID adds u to the "organization_id" field.
  17759. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17760. if m.addorganization_id != nil {
  17761. *m.addorganization_id += u
  17762. } else {
  17763. m.addorganization_id = &u
  17764. }
  17765. }
  17766. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17767. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17768. v := m.addorganization_id
  17769. if v == nil {
  17770. return
  17771. }
  17772. return *v, true
  17773. }
  17774. // ResetOrganizationID resets all changes to the "organization_id" field.
  17775. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17776. m.organization_id = nil
  17777. m.addorganization_id = nil
  17778. }
  17779. // SetType sets the "type" field.
  17780. func (m *LabelTaggingMutation) SetType(i int) {
  17781. m._type = &i
  17782. m.add_type = nil
  17783. }
  17784. // GetType returns the value of the "type" field in the mutation.
  17785. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17786. v := m._type
  17787. if v == nil {
  17788. return
  17789. }
  17790. return *v, true
  17791. }
  17792. // OldType returns the old "type" field's value of the LabelTagging entity.
  17793. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17795. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17796. if !m.op.Is(OpUpdateOne) {
  17797. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17798. }
  17799. if m.id == nil || m.oldValue == nil {
  17800. return v, errors.New("OldType requires an ID field in the mutation")
  17801. }
  17802. oldValue, err := m.oldValue(ctx)
  17803. if err != nil {
  17804. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17805. }
  17806. return oldValue.Type, nil
  17807. }
  17808. // AddType adds i to the "type" field.
  17809. func (m *LabelTaggingMutation) AddType(i int) {
  17810. if m.add_type != nil {
  17811. *m.add_type += i
  17812. } else {
  17813. m.add_type = &i
  17814. }
  17815. }
  17816. // AddedType returns the value that was added to the "type" field in this mutation.
  17817. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17818. v := m.add_type
  17819. if v == nil {
  17820. return
  17821. }
  17822. return *v, true
  17823. }
  17824. // ResetType resets all changes to the "type" field.
  17825. func (m *LabelTaggingMutation) ResetType() {
  17826. m._type = nil
  17827. m.add_type = nil
  17828. }
  17829. // SetConditions sets the "conditions" field.
  17830. func (m *LabelTaggingMutation) SetConditions(s string) {
  17831. m.conditions = &s
  17832. }
  17833. // Conditions returns the value of the "conditions" field in the mutation.
  17834. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17835. v := m.conditions
  17836. if v == nil {
  17837. return
  17838. }
  17839. return *v, true
  17840. }
  17841. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17842. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17844. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17845. if !m.op.Is(OpUpdateOne) {
  17846. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17847. }
  17848. if m.id == nil || m.oldValue == nil {
  17849. return v, errors.New("OldConditions requires an ID field in the mutation")
  17850. }
  17851. oldValue, err := m.oldValue(ctx)
  17852. if err != nil {
  17853. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17854. }
  17855. return oldValue.Conditions, nil
  17856. }
  17857. // ResetConditions resets all changes to the "conditions" field.
  17858. func (m *LabelTaggingMutation) ResetConditions() {
  17859. m.conditions = nil
  17860. }
  17861. // SetActionLabelAdd sets the "action_label_add" field.
  17862. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  17863. m.action_label_add = &u
  17864. m.appendaction_label_add = nil
  17865. }
  17866. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17867. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17868. v := m.action_label_add
  17869. if v == nil {
  17870. return
  17871. }
  17872. return *v, true
  17873. }
  17874. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  17875. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17877. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17878. if !m.op.Is(OpUpdateOne) {
  17879. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17880. }
  17881. if m.id == nil || m.oldValue == nil {
  17882. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17883. }
  17884. oldValue, err := m.oldValue(ctx)
  17885. if err != nil {
  17886. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17887. }
  17888. return oldValue.ActionLabelAdd, nil
  17889. }
  17890. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17891. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  17892. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17893. }
  17894. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17895. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17896. if len(m.appendaction_label_add) == 0 {
  17897. return nil, false
  17898. }
  17899. return m.appendaction_label_add, true
  17900. }
  17901. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17902. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  17903. m.action_label_add = nil
  17904. m.appendaction_label_add = nil
  17905. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  17906. }
  17907. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17908. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  17909. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  17910. return ok
  17911. }
  17912. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17913. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  17914. m.action_label_add = nil
  17915. m.appendaction_label_add = nil
  17916. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  17917. }
  17918. // SetActionLabelDel sets the "action_label_del" field.
  17919. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  17920. m.action_label_del = &u
  17921. m.appendaction_label_del = nil
  17922. }
  17923. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17924. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  17925. v := m.action_label_del
  17926. if v == nil {
  17927. return
  17928. }
  17929. return *v, true
  17930. }
  17931. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  17932. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17934. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17935. if !m.op.Is(OpUpdateOne) {
  17936. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17937. }
  17938. if m.id == nil || m.oldValue == nil {
  17939. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17940. }
  17941. oldValue, err := m.oldValue(ctx)
  17942. if err != nil {
  17943. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17944. }
  17945. return oldValue.ActionLabelDel, nil
  17946. }
  17947. // AppendActionLabelDel adds u to the "action_label_del" field.
  17948. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  17949. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17950. }
  17951. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17952. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17953. if len(m.appendaction_label_del) == 0 {
  17954. return nil, false
  17955. }
  17956. return m.appendaction_label_del, true
  17957. }
  17958. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17959. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  17960. m.action_label_del = nil
  17961. m.appendaction_label_del = nil
  17962. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  17963. }
  17964. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17965. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  17966. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  17967. return ok
  17968. }
  17969. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17970. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  17971. m.action_label_del = nil
  17972. m.appendaction_label_del = nil
  17973. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  17974. }
  17975. // Where appends a list predicates to the LabelTaggingMutation builder.
  17976. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  17977. m.predicates = append(m.predicates, ps...)
  17978. }
  17979. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  17980. // users can use type-assertion to append predicates that do not depend on any generated package.
  17981. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  17982. p := make([]predicate.LabelTagging, len(ps))
  17983. for i := range ps {
  17984. p[i] = ps[i]
  17985. }
  17986. m.Where(p...)
  17987. }
  17988. // Op returns the operation name.
  17989. func (m *LabelTaggingMutation) Op() Op {
  17990. return m.op
  17991. }
  17992. // SetOp allows setting the mutation operation.
  17993. func (m *LabelTaggingMutation) SetOp(op Op) {
  17994. m.op = op
  17995. }
  17996. // Type returns the node type of this mutation (LabelTagging).
  17997. func (m *LabelTaggingMutation) Type() string {
  17998. return m.typ
  17999. }
  18000. // Fields returns all fields that were changed during this mutation. Note that in
  18001. // order to get all numeric fields that were incremented/decremented, call
  18002. // AddedFields().
  18003. func (m *LabelTaggingMutation) Fields() []string {
  18004. fields := make([]string, 0, 9)
  18005. if m.created_at != nil {
  18006. fields = append(fields, labeltagging.FieldCreatedAt)
  18007. }
  18008. if m.updated_at != nil {
  18009. fields = append(fields, labeltagging.FieldUpdatedAt)
  18010. }
  18011. if m.status != nil {
  18012. fields = append(fields, labeltagging.FieldStatus)
  18013. }
  18014. if m.deleted_at != nil {
  18015. fields = append(fields, labeltagging.FieldDeletedAt)
  18016. }
  18017. if m.organization_id != nil {
  18018. fields = append(fields, labeltagging.FieldOrganizationID)
  18019. }
  18020. if m._type != nil {
  18021. fields = append(fields, labeltagging.FieldType)
  18022. }
  18023. if m.conditions != nil {
  18024. fields = append(fields, labeltagging.FieldConditions)
  18025. }
  18026. if m.action_label_add != nil {
  18027. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18028. }
  18029. if m.action_label_del != nil {
  18030. fields = append(fields, labeltagging.FieldActionLabelDel)
  18031. }
  18032. return fields
  18033. }
  18034. // Field returns the value of a field with the given name. The second boolean
  18035. // return value indicates that this field was not set, or was not defined in the
  18036. // schema.
  18037. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18038. switch name {
  18039. case labeltagging.FieldCreatedAt:
  18040. return m.CreatedAt()
  18041. case labeltagging.FieldUpdatedAt:
  18042. return m.UpdatedAt()
  18043. case labeltagging.FieldStatus:
  18044. return m.Status()
  18045. case labeltagging.FieldDeletedAt:
  18046. return m.DeletedAt()
  18047. case labeltagging.FieldOrganizationID:
  18048. return m.OrganizationID()
  18049. case labeltagging.FieldType:
  18050. return m.GetType()
  18051. case labeltagging.FieldConditions:
  18052. return m.Conditions()
  18053. case labeltagging.FieldActionLabelAdd:
  18054. return m.ActionLabelAdd()
  18055. case labeltagging.FieldActionLabelDel:
  18056. return m.ActionLabelDel()
  18057. }
  18058. return nil, false
  18059. }
  18060. // OldField returns the old value of the field from the database. An error is
  18061. // returned if the mutation operation is not UpdateOne, or the query to the
  18062. // database failed.
  18063. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18064. switch name {
  18065. case labeltagging.FieldCreatedAt:
  18066. return m.OldCreatedAt(ctx)
  18067. case labeltagging.FieldUpdatedAt:
  18068. return m.OldUpdatedAt(ctx)
  18069. case labeltagging.FieldStatus:
  18070. return m.OldStatus(ctx)
  18071. case labeltagging.FieldDeletedAt:
  18072. return m.OldDeletedAt(ctx)
  18073. case labeltagging.FieldOrganizationID:
  18074. return m.OldOrganizationID(ctx)
  18075. case labeltagging.FieldType:
  18076. return m.OldType(ctx)
  18077. case labeltagging.FieldConditions:
  18078. return m.OldConditions(ctx)
  18079. case labeltagging.FieldActionLabelAdd:
  18080. return m.OldActionLabelAdd(ctx)
  18081. case labeltagging.FieldActionLabelDel:
  18082. return m.OldActionLabelDel(ctx)
  18083. }
  18084. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18085. }
  18086. // SetField sets the value of a field with the given name. It returns an error if
  18087. // the field is not defined in the schema, or if the type mismatched the field
  18088. // type.
  18089. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18090. switch name {
  18091. case labeltagging.FieldCreatedAt:
  18092. v, ok := value.(time.Time)
  18093. if !ok {
  18094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18095. }
  18096. m.SetCreatedAt(v)
  18097. return nil
  18098. case labeltagging.FieldUpdatedAt:
  18099. v, ok := value.(time.Time)
  18100. if !ok {
  18101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18102. }
  18103. m.SetUpdatedAt(v)
  18104. return nil
  18105. case labeltagging.FieldStatus:
  18106. v, ok := value.(uint8)
  18107. if !ok {
  18108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18109. }
  18110. m.SetStatus(v)
  18111. return nil
  18112. case labeltagging.FieldDeletedAt:
  18113. v, ok := value.(time.Time)
  18114. if !ok {
  18115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18116. }
  18117. m.SetDeletedAt(v)
  18118. return nil
  18119. case labeltagging.FieldOrganizationID:
  18120. v, ok := value.(uint64)
  18121. if !ok {
  18122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18123. }
  18124. m.SetOrganizationID(v)
  18125. return nil
  18126. case labeltagging.FieldType:
  18127. v, ok := value.(int)
  18128. if !ok {
  18129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18130. }
  18131. m.SetType(v)
  18132. return nil
  18133. case labeltagging.FieldConditions:
  18134. v, ok := value.(string)
  18135. if !ok {
  18136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18137. }
  18138. m.SetConditions(v)
  18139. return nil
  18140. case labeltagging.FieldActionLabelAdd:
  18141. v, ok := value.([]uint64)
  18142. if !ok {
  18143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18144. }
  18145. m.SetActionLabelAdd(v)
  18146. return nil
  18147. case labeltagging.FieldActionLabelDel:
  18148. v, ok := value.([]uint64)
  18149. if !ok {
  18150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18151. }
  18152. m.SetActionLabelDel(v)
  18153. return nil
  18154. }
  18155. return fmt.Errorf("unknown LabelTagging field %s", name)
  18156. }
  18157. // AddedFields returns all numeric fields that were incremented/decremented during
  18158. // this mutation.
  18159. func (m *LabelTaggingMutation) AddedFields() []string {
  18160. var fields []string
  18161. if m.addstatus != nil {
  18162. fields = append(fields, labeltagging.FieldStatus)
  18163. }
  18164. if m.addorganization_id != nil {
  18165. fields = append(fields, labeltagging.FieldOrganizationID)
  18166. }
  18167. if m.add_type != nil {
  18168. fields = append(fields, labeltagging.FieldType)
  18169. }
  18170. return fields
  18171. }
  18172. // AddedField returns the numeric value that was incremented/decremented on a field
  18173. // with the given name. The second boolean return value indicates that this field
  18174. // was not set, or was not defined in the schema.
  18175. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18176. switch name {
  18177. case labeltagging.FieldStatus:
  18178. return m.AddedStatus()
  18179. case labeltagging.FieldOrganizationID:
  18180. return m.AddedOrganizationID()
  18181. case labeltagging.FieldType:
  18182. return m.AddedType()
  18183. }
  18184. return nil, false
  18185. }
  18186. // AddField adds the value to the field with the given name. It returns an error if
  18187. // the field is not defined in the schema, or if the type mismatched the field
  18188. // type.
  18189. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18190. switch name {
  18191. case labeltagging.FieldStatus:
  18192. v, ok := value.(int8)
  18193. if !ok {
  18194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18195. }
  18196. m.AddStatus(v)
  18197. return nil
  18198. case labeltagging.FieldOrganizationID:
  18199. v, ok := value.(int64)
  18200. if !ok {
  18201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18202. }
  18203. m.AddOrganizationID(v)
  18204. return nil
  18205. case labeltagging.FieldType:
  18206. v, ok := value.(int)
  18207. if !ok {
  18208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18209. }
  18210. m.AddType(v)
  18211. return nil
  18212. }
  18213. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18214. }
  18215. // ClearedFields returns all nullable fields that were cleared during this
  18216. // mutation.
  18217. func (m *LabelTaggingMutation) ClearedFields() []string {
  18218. var fields []string
  18219. if m.FieldCleared(labeltagging.FieldStatus) {
  18220. fields = append(fields, labeltagging.FieldStatus)
  18221. }
  18222. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18223. fields = append(fields, labeltagging.FieldDeletedAt)
  18224. }
  18225. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18226. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18227. }
  18228. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18229. fields = append(fields, labeltagging.FieldActionLabelDel)
  18230. }
  18231. return fields
  18232. }
  18233. // FieldCleared returns a boolean indicating if a field with the given name was
  18234. // cleared in this mutation.
  18235. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18236. _, ok := m.clearedFields[name]
  18237. return ok
  18238. }
  18239. // ClearField clears the value of the field with the given name. It returns an
  18240. // error if the field is not defined in the schema.
  18241. func (m *LabelTaggingMutation) ClearField(name string) error {
  18242. switch name {
  18243. case labeltagging.FieldStatus:
  18244. m.ClearStatus()
  18245. return nil
  18246. case labeltagging.FieldDeletedAt:
  18247. m.ClearDeletedAt()
  18248. return nil
  18249. case labeltagging.FieldActionLabelAdd:
  18250. m.ClearActionLabelAdd()
  18251. return nil
  18252. case labeltagging.FieldActionLabelDel:
  18253. m.ClearActionLabelDel()
  18254. return nil
  18255. }
  18256. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18257. }
  18258. // ResetField resets all changes in the mutation for the field with the given name.
  18259. // It returns an error if the field is not defined in the schema.
  18260. func (m *LabelTaggingMutation) ResetField(name string) error {
  18261. switch name {
  18262. case labeltagging.FieldCreatedAt:
  18263. m.ResetCreatedAt()
  18264. return nil
  18265. case labeltagging.FieldUpdatedAt:
  18266. m.ResetUpdatedAt()
  18267. return nil
  18268. case labeltagging.FieldStatus:
  18269. m.ResetStatus()
  18270. return nil
  18271. case labeltagging.FieldDeletedAt:
  18272. m.ResetDeletedAt()
  18273. return nil
  18274. case labeltagging.FieldOrganizationID:
  18275. m.ResetOrganizationID()
  18276. return nil
  18277. case labeltagging.FieldType:
  18278. m.ResetType()
  18279. return nil
  18280. case labeltagging.FieldConditions:
  18281. m.ResetConditions()
  18282. return nil
  18283. case labeltagging.FieldActionLabelAdd:
  18284. m.ResetActionLabelAdd()
  18285. return nil
  18286. case labeltagging.FieldActionLabelDel:
  18287. m.ResetActionLabelDel()
  18288. return nil
  18289. }
  18290. return fmt.Errorf("unknown LabelTagging field %s", name)
  18291. }
  18292. // AddedEdges returns all edge names that were set/added in this mutation.
  18293. func (m *LabelTaggingMutation) AddedEdges() []string {
  18294. edges := make([]string, 0, 0)
  18295. return edges
  18296. }
  18297. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18298. // name in this mutation.
  18299. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18300. return nil
  18301. }
  18302. // RemovedEdges returns all edge names that were removed in this mutation.
  18303. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18304. edges := make([]string, 0, 0)
  18305. return edges
  18306. }
  18307. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18308. // the given name in this mutation.
  18309. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18310. return nil
  18311. }
  18312. // ClearedEdges returns all edge names that were cleared in this mutation.
  18313. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18314. edges := make([]string, 0, 0)
  18315. return edges
  18316. }
  18317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18318. // was cleared in this mutation.
  18319. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18320. return false
  18321. }
  18322. // ClearEdge clears the value of the edge with the given name. It returns an error
  18323. // if that edge is not defined in the schema.
  18324. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18325. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18326. }
  18327. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18328. // It returns an error if the edge is not defined in the schema.
  18329. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18330. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18331. }
  18332. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18333. type MessageMutation struct {
  18334. config
  18335. op Op
  18336. typ string
  18337. id *int
  18338. wx_wxid *string
  18339. wxid *string
  18340. content *string
  18341. clearedFields map[string]struct{}
  18342. done bool
  18343. oldValue func(context.Context) (*Message, error)
  18344. predicates []predicate.Message
  18345. }
  18346. var _ ent.Mutation = (*MessageMutation)(nil)
  18347. // messageOption allows management of the mutation configuration using functional options.
  18348. type messageOption func(*MessageMutation)
  18349. // newMessageMutation creates new mutation for the Message entity.
  18350. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18351. m := &MessageMutation{
  18352. config: c,
  18353. op: op,
  18354. typ: TypeMessage,
  18355. clearedFields: make(map[string]struct{}),
  18356. }
  18357. for _, opt := range opts {
  18358. opt(m)
  18359. }
  18360. return m
  18361. }
  18362. // withMessageID sets the ID field of the mutation.
  18363. func withMessageID(id int) messageOption {
  18364. return func(m *MessageMutation) {
  18365. var (
  18366. err error
  18367. once sync.Once
  18368. value *Message
  18369. )
  18370. m.oldValue = func(ctx context.Context) (*Message, error) {
  18371. once.Do(func() {
  18372. if m.done {
  18373. err = errors.New("querying old values post mutation is not allowed")
  18374. } else {
  18375. value, err = m.Client().Message.Get(ctx, id)
  18376. }
  18377. })
  18378. return value, err
  18379. }
  18380. m.id = &id
  18381. }
  18382. }
  18383. // withMessage sets the old Message of the mutation.
  18384. func withMessage(node *Message) messageOption {
  18385. return func(m *MessageMutation) {
  18386. m.oldValue = func(context.Context) (*Message, error) {
  18387. return node, nil
  18388. }
  18389. m.id = &node.ID
  18390. }
  18391. }
  18392. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18393. // executed in a transaction (ent.Tx), a transactional client is returned.
  18394. func (m MessageMutation) Client() *Client {
  18395. client := &Client{config: m.config}
  18396. client.init()
  18397. return client
  18398. }
  18399. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18400. // it returns an error otherwise.
  18401. func (m MessageMutation) Tx() (*Tx, error) {
  18402. if _, ok := m.driver.(*txDriver); !ok {
  18403. return nil, errors.New("ent: mutation is not running in a transaction")
  18404. }
  18405. tx := &Tx{config: m.config}
  18406. tx.init()
  18407. return tx, nil
  18408. }
  18409. // ID returns the ID value in the mutation. Note that the ID is only available
  18410. // if it was provided to the builder or after it was returned from the database.
  18411. func (m *MessageMutation) ID() (id int, exists bool) {
  18412. if m.id == nil {
  18413. return
  18414. }
  18415. return *m.id, true
  18416. }
  18417. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18418. // That means, if the mutation is applied within a transaction with an isolation level such
  18419. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18420. // or updated by the mutation.
  18421. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18422. switch {
  18423. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18424. id, exists := m.ID()
  18425. if exists {
  18426. return []int{id}, nil
  18427. }
  18428. fallthrough
  18429. case m.op.Is(OpUpdate | OpDelete):
  18430. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18431. default:
  18432. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18433. }
  18434. }
  18435. // SetWxWxid sets the "wx_wxid" field.
  18436. func (m *MessageMutation) SetWxWxid(s string) {
  18437. m.wx_wxid = &s
  18438. }
  18439. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18440. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18441. v := m.wx_wxid
  18442. if v == nil {
  18443. return
  18444. }
  18445. return *v, true
  18446. }
  18447. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18448. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18450. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18451. if !m.op.Is(OpUpdateOne) {
  18452. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18453. }
  18454. if m.id == nil || m.oldValue == nil {
  18455. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18456. }
  18457. oldValue, err := m.oldValue(ctx)
  18458. if err != nil {
  18459. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18460. }
  18461. return oldValue.WxWxid, nil
  18462. }
  18463. // ClearWxWxid clears the value of the "wx_wxid" field.
  18464. func (m *MessageMutation) ClearWxWxid() {
  18465. m.wx_wxid = nil
  18466. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18467. }
  18468. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18469. func (m *MessageMutation) WxWxidCleared() bool {
  18470. _, ok := m.clearedFields[message.FieldWxWxid]
  18471. return ok
  18472. }
  18473. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18474. func (m *MessageMutation) ResetWxWxid() {
  18475. m.wx_wxid = nil
  18476. delete(m.clearedFields, message.FieldWxWxid)
  18477. }
  18478. // SetWxid sets the "wxid" field.
  18479. func (m *MessageMutation) SetWxid(s string) {
  18480. m.wxid = &s
  18481. }
  18482. // Wxid returns the value of the "wxid" field in the mutation.
  18483. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18484. v := m.wxid
  18485. if v == nil {
  18486. return
  18487. }
  18488. return *v, true
  18489. }
  18490. // OldWxid returns the old "wxid" field's value of the Message entity.
  18491. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18493. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18494. if !m.op.Is(OpUpdateOne) {
  18495. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18496. }
  18497. if m.id == nil || m.oldValue == nil {
  18498. return v, errors.New("OldWxid requires an ID field in the mutation")
  18499. }
  18500. oldValue, err := m.oldValue(ctx)
  18501. if err != nil {
  18502. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18503. }
  18504. return oldValue.Wxid, nil
  18505. }
  18506. // ResetWxid resets all changes to the "wxid" field.
  18507. func (m *MessageMutation) ResetWxid() {
  18508. m.wxid = nil
  18509. }
  18510. // SetContent sets the "content" field.
  18511. func (m *MessageMutation) SetContent(s string) {
  18512. m.content = &s
  18513. }
  18514. // Content returns the value of the "content" field in the mutation.
  18515. func (m *MessageMutation) Content() (r string, exists bool) {
  18516. v := m.content
  18517. if v == nil {
  18518. return
  18519. }
  18520. return *v, true
  18521. }
  18522. // OldContent returns the old "content" field's value of the Message entity.
  18523. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18525. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18526. if !m.op.Is(OpUpdateOne) {
  18527. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18528. }
  18529. if m.id == nil || m.oldValue == nil {
  18530. return v, errors.New("OldContent requires an ID field in the mutation")
  18531. }
  18532. oldValue, err := m.oldValue(ctx)
  18533. if err != nil {
  18534. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18535. }
  18536. return oldValue.Content, nil
  18537. }
  18538. // ResetContent resets all changes to the "content" field.
  18539. func (m *MessageMutation) ResetContent() {
  18540. m.content = nil
  18541. }
  18542. // Where appends a list predicates to the MessageMutation builder.
  18543. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18544. m.predicates = append(m.predicates, ps...)
  18545. }
  18546. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18547. // users can use type-assertion to append predicates that do not depend on any generated package.
  18548. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18549. p := make([]predicate.Message, len(ps))
  18550. for i := range ps {
  18551. p[i] = ps[i]
  18552. }
  18553. m.Where(p...)
  18554. }
  18555. // Op returns the operation name.
  18556. func (m *MessageMutation) Op() Op {
  18557. return m.op
  18558. }
  18559. // SetOp allows setting the mutation operation.
  18560. func (m *MessageMutation) SetOp(op Op) {
  18561. m.op = op
  18562. }
  18563. // Type returns the node type of this mutation (Message).
  18564. func (m *MessageMutation) Type() string {
  18565. return m.typ
  18566. }
  18567. // Fields returns all fields that were changed during this mutation. Note that in
  18568. // order to get all numeric fields that were incremented/decremented, call
  18569. // AddedFields().
  18570. func (m *MessageMutation) Fields() []string {
  18571. fields := make([]string, 0, 3)
  18572. if m.wx_wxid != nil {
  18573. fields = append(fields, message.FieldWxWxid)
  18574. }
  18575. if m.wxid != nil {
  18576. fields = append(fields, message.FieldWxid)
  18577. }
  18578. if m.content != nil {
  18579. fields = append(fields, message.FieldContent)
  18580. }
  18581. return fields
  18582. }
  18583. // Field returns the value of a field with the given name. The second boolean
  18584. // return value indicates that this field was not set, or was not defined in the
  18585. // schema.
  18586. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18587. switch name {
  18588. case message.FieldWxWxid:
  18589. return m.WxWxid()
  18590. case message.FieldWxid:
  18591. return m.Wxid()
  18592. case message.FieldContent:
  18593. return m.Content()
  18594. }
  18595. return nil, false
  18596. }
  18597. // OldField returns the old value of the field from the database. An error is
  18598. // returned if the mutation operation is not UpdateOne, or the query to the
  18599. // database failed.
  18600. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18601. switch name {
  18602. case message.FieldWxWxid:
  18603. return m.OldWxWxid(ctx)
  18604. case message.FieldWxid:
  18605. return m.OldWxid(ctx)
  18606. case message.FieldContent:
  18607. return m.OldContent(ctx)
  18608. }
  18609. return nil, fmt.Errorf("unknown Message field %s", name)
  18610. }
  18611. // SetField sets the value of a field with the given name. It returns an error if
  18612. // the field is not defined in the schema, or if the type mismatched the field
  18613. // type.
  18614. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18615. switch name {
  18616. case message.FieldWxWxid:
  18617. v, ok := value.(string)
  18618. if !ok {
  18619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18620. }
  18621. m.SetWxWxid(v)
  18622. return nil
  18623. case message.FieldWxid:
  18624. v, ok := value.(string)
  18625. if !ok {
  18626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18627. }
  18628. m.SetWxid(v)
  18629. return nil
  18630. case message.FieldContent:
  18631. v, ok := value.(string)
  18632. if !ok {
  18633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18634. }
  18635. m.SetContent(v)
  18636. return nil
  18637. }
  18638. return fmt.Errorf("unknown Message field %s", name)
  18639. }
  18640. // AddedFields returns all numeric fields that were incremented/decremented during
  18641. // this mutation.
  18642. func (m *MessageMutation) AddedFields() []string {
  18643. return nil
  18644. }
  18645. // AddedField returns the numeric value that was incremented/decremented on a field
  18646. // with the given name. The second boolean return value indicates that this field
  18647. // was not set, or was not defined in the schema.
  18648. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18649. return nil, false
  18650. }
  18651. // AddField adds the value to the field with the given name. It returns an error if
  18652. // the field is not defined in the schema, or if the type mismatched the field
  18653. // type.
  18654. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18655. switch name {
  18656. }
  18657. return fmt.Errorf("unknown Message numeric field %s", name)
  18658. }
  18659. // ClearedFields returns all nullable fields that were cleared during this
  18660. // mutation.
  18661. func (m *MessageMutation) ClearedFields() []string {
  18662. var fields []string
  18663. if m.FieldCleared(message.FieldWxWxid) {
  18664. fields = append(fields, message.FieldWxWxid)
  18665. }
  18666. return fields
  18667. }
  18668. // FieldCleared returns a boolean indicating if a field with the given name was
  18669. // cleared in this mutation.
  18670. func (m *MessageMutation) FieldCleared(name string) bool {
  18671. _, ok := m.clearedFields[name]
  18672. return ok
  18673. }
  18674. // ClearField clears the value of the field with the given name. It returns an
  18675. // error if the field is not defined in the schema.
  18676. func (m *MessageMutation) ClearField(name string) error {
  18677. switch name {
  18678. case message.FieldWxWxid:
  18679. m.ClearWxWxid()
  18680. return nil
  18681. }
  18682. return fmt.Errorf("unknown Message nullable field %s", name)
  18683. }
  18684. // ResetField resets all changes in the mutation for the field with the given name.
  18685. // It returns an error if the field is not defined in the schema.
  18686. func (m *MessageMutation) ResetField(name string) error {
  18687. switch name {
  18688. case message.FieldWxWxid:
  18689. m.ResetWxWxid()
  18690. return nil
  18691. case message.FieldWxid:
  18692. m.ResetWxid()
  18693. return nil
  18694. case message.FieldContent:
  18695. m.ResetContent()
  18696. return nil
  18697. }
  18698. return fmt.Errorf("unknown Message field %s", name)
  18699. }
  18700. // AddedEdges returns all edge names that were set/added in this mutation.
  18701. func (m *MessageMutation) AddedEdges() []string {
  18702. edges := make([]string, 0, 0)
  18703. return edges
  18704. }
  18705. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18706. // name in this mutation.
  18707. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18708. return nil
  18709. }
  18710. // RemovedEdges returns all edge names that were removed in this mutation.
  18711. func (m *MessageMutation) RemovedEdges() []string {
  18712. edges := make([]string, 0, 0)
  18713. return edges
  18714. }
  18715. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18716. // the given name in this mutation.
  18717. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18718. return nil
  18719. }
  18720. // ClearedEdges returns all edge names that were cleared in this mutation.
  18721. func (m *MessageMutation) ClearedEdges() []string {
  18722. edges := make([]string, 0, 0)
  18723. return edges
  18724. }
  18725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18726. // was cleared in this mutation.
  18727. func (m *MessageMutation) EdgeCleared(name string) bool {
  18728. return false
  18729. }
  18730. // ClearEdge clears the value of the edge with the given name. It returns an error
  18731. // if that edge is not defined in the schema.
  18732. func (m *MessageMutation) ClearEdge(name string) error {
  18733. return fmt.Errorf("unknown Message unique edge %s", name)
  18734. }
  18735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18736. // It returns an error if the edge is not defined in the schema.
  18737. func (m *MessageMutation) ResetEdge(name string) error {
  18738. return fmt.Errorf("unknown Message edge %s", name)
  18739. }
  18740. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18741. type MessageRecordsMutation struct {
  18742. config
  18743. op Op
  18744. typ string
  18745. id *uint64
  18746. created_at *time.Time
  18747. updated_at *time.Time
  18748. status *uint8
  18749. addstatus *int8
  18750. bot_wxid *string
  18751. contact_type *int
  18752. addcontact_type *int
  18753. contact_wxid *string
  18754. content_type *int
  18755. addcontent_type *int
  18756. content *string
  18757. meta *custom_types.Meta
  18758. error_detail *string
  18759. send_time *time.Time
  18760. source_type *int
  18761. addsource_type *int
  18762. organization_id *uint64
  18763. addorganization_id *int64
  18764. clearedFields map[string]struct{}
  18765. sop_stage *uint64
  18766. clearedsop_stage bool
  18767. sop_node *uint64
  18768. clearedsop_node bool
  18769. message_contact *uint64
  18770. clearedmessage_contact bool
  18771. done bool
  18772. oldValue func(context.Context) (*MessageRecords, error)
  18773. predicates []predicate.MessageRecords
  18774. }
  18775. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18776. // messagerecordsOption allows management of the mutation configuration using functional options.
  18777. type messagerecordsOption func(*MessageRecordsMutation)
  18778. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18779. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18780. m := &MessageRecordsMutation{
  18781. config: c,
  18782. op: op,
  18783. typ: TypeMessageRecords,
  18784. clearedFields: make(map[string]struct{}),
  18785. }
  18786. for _, opt := range opts {
  18787. opt(m)
  18788. }
  18789. return m
  18790. }
  18791. // withMessageRecordsID sets the ID field of the mutation.
  18792. func withMessageRecordsID(id uint64) messagerecordsOption {
  18793. return func(m *MessageRecordsMutation) {
  18794. var (
  18795. err error
  18796. once sync.Once
  18797. value *MessageRecords
  18798. )
  18799. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18800. once.Do(func() {
  18801. if m.done {
  18802. err = errors.New("querying old values post mutation is not allowed")
  18803. } else {
  18804. value, err = m.Client().MessageRecords.Get(ctx, id)
  18805. }
  18806. })
  18807. return value, err
  18808. }
  18809. m.id = &id
  18810. }
  18811. }
  18812. // withMessageRecords sets the old MessageRecords of the mutation.
  18813. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18814. return func(m *MessageRecordsMutation) {
  18815. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18816. return node, nil
  18817. }
  18818. m.id = &node.ID
  18819. }
  18820. }
  18821. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18822. // executed in a transaction (ent.Tx), a transactional client is returned.
  18823. func (m MessageRecordsMutation) Client() *Client {
  18824. client := &Client{config: m.config}
  18825. client.init()
  18826. return client
  18827. }
  18828. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18829. // it returns an error otherwise.
  18830. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18831. if _, ok := m.driver.(*txDriver); !ok {
  18832. return nil, errors.New("ent: mutation is not running in a transaction")
  18833. }
  18834. tx := &Tx{config: m.config}
  18835. tx.init()
  18836. return tx, nil
  18837. }
  18838. // SetID sets the value of the id field. Note that this
  18839. // operation is only accepted on creation of MessageRecords entities.
  18840. func (m *MessageRecordsMutation) SetID(id uint64) {
  18841. m.id = &id
  18842. }
  18843. // ID returns the ID value in the mutation. Note that the ID is only available
  18844. // if it was provided to the builder or after it was returned from the database.
  18845. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  18846. if m.id == nil {
  18847. return
  18848. }
  18849. return *m.id, true
  18850. }
  18851. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18852. // That means, if the mutation is applied within a transaction with an isolation level such
  18853. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18854. // or updated by the mutation.
  18855. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  18856. switch {
  18857. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18858. id, exists := m.ID()
  18859. if exists {
  18860. return []uint64{id}, nil
  18861. }
  18862. fallthrough
  18863. case m.op.Is(OpUpdate | OpDelete):
  18864. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  18865. default:
  18866. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18867. }
  18868. }
  18869. // SetCreatedAt sets the "created_at" field.
  18870. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  18871. m.created_at = &t
  18872. }
  18873. // CreatedAt returns the value of the "created_at" field in the mutation.
  18874. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  18875. v := m.created_at
  18876. if v == nil {
  18877. return
  18878. }
  18879. return *v, true
  18880. }
  18881. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  18882. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18884. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18885. if !m.op.Is(OpUpdateOne) {
  18886. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18887. }
  18888. if m.id == nil || m.oldValue == nil {
  18889. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18890. }
  18891. oldValue, err := m.oldValue(ctx)
  18892. if err != nil {
  18893. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18894. }
  18895. return oldValue.CreatedAt, nil
  18896. }
  18897. // ResetCreatedAt resets all changes to the "created_at" field.
  18898. func (m *MessageRecordsMutation) ResetCreatedAt() {
  18899. m.created_at = nil
  18900. }
  18901. // SetUpdatedAt sets the "updated_at" field.
  18902. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  18903. m.updated_at = &t
  18904. }
  18905. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18906. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  18907. v := m.updated_at
  18908. if v == nil {
  18909. return
  18910. }
  18911. return *v, true
  18912. }
  18913. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  18914. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18916. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18917. if !m.op.Is(OpUpdateOne) {
  18918. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18919. }
  18920. if m.id == nil || m.oldValue == nil {
  18921. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18922. }
  18923. oldValue, err := m.oldValue(ctx)
  18924. if err != nil {
  18925. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18926. }
  18927. return oldValue.UpdatedAt, nil
  18928. }
  18929. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18930. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  18931. m.updated_at = nil
  18932. }
  18933. // SetStatus sets the "status" field.
  18934. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  18935. m.status = &u
  18936. m.addstatus = nil
  18937. }
  18938. // Status returns the value of the "status" field in the mutation.
  18939. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  18940. v := m.status
  18941. if v == nil {
  18942. return
  18943. }
  18944. return *v, true
  18945. }
  18946. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  18947. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18949. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18950. if !m.op.Is(OpUpdateOne) {
  18951. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18952. }
  18953. if m.id == nil || m.oldValue == nil {
  18954. return v, errors.New("OldStatus requires an ID field in the mutation")
  18955. }
  18956. oldValue, err := m.oldValue(ctx)
  18957. if err != nil {
  18958. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18959. }
  18960. return oldValue.Status, nil
  18961. }
  18962. // AddStatus adds u to the "status" field.
  18963. func (m *MessageRecordsMutation) AddStatus(u int8) {
  18964. if m.addstatus != nil {
  18965. *m.addstatus += u
  18966. } else {
  18967. m.addstatus = &u
  18968. }
  18969. }
  18970. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18971. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  18972. v := m.addstatus
  18973. if v == nil {
  18974. return
  18975. }
  18976. return *v, true
  18977. }
  18978. // ClearStatus clears the value of the "status" field.
  18979. func (m *MessageRecordsMutation) ClearStatus() {
  18980. m.status = nil
  18981. m.addstatus = nil
  18982. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  18983. }
  18984. // StatusCleared returns if the "status" field was cleared in this mutation.
  18985. func (m *MessageRecordsMutation) StatusCleared() bool {
  18986. _, ok := m.clearedFields[messagerecords.FieldStatus]
  18987. return ok
  18988. }
  18989. // ResetStatus resets all changes to the "status" field.
  18990. func (m *MessageRecordsMutation) ResetStatus() {
  18991. m.status = nil
  18992. m.addstatus = nil
  18993. delete(m.clearedFields, messagerecords.FieldStatus)
  18994. }
  18995. // SetBotWxid sets the "bot_wxid" field.
  18996. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  18997. m.bot_wxid = &s
  18998. }
  18999. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19000. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19001. v := m.bot_wxid
  19002. if v == nil {
  19003. return
  19004. }
  19005. return *v, true
  19006. }
  19007. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19008. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19010. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19011. if !m.op.Is(OpUpdateOne) {
  19012. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19013. }
  19014. if m.id == nil || m.oldValue == nil {
  19015. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19016. }
  19017. oldValue, err := m.oldValue(ctx)
  19018. if err != nil {
  19019. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19020. }
  19021. return oldValue.BotWxid, nil
  19022. }
  19023. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19024. func (m *MessageRecordsMutation) ResetBotWxid() {
  19025. m.bot_wxid = nil
  19026. }
  19027. // SetContactID sets the "contact_id" field.
  19028. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19029. m.message_contact = &u
  19030. }
  19031. // ContactID returns the value of the "contact_id" field in the mutation.
  19032. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19033. v := m.message_contact
  19034. if v == nil {
  19035. return
  19036. }
  19037. return *v, true
  19038. }
  19039. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19040. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19042. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19043. if !m.op.Is(OpUpdateOne) {
  19044. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19045. }
  19046. if m.id == nil || m.oldValue == nil {
  19047. return v, errors.New("OldContactID requires an ID field in the mutation")
  19048. }
  19049. oldValue, err := m.oldValue(ctx)
  19050. if err != nil {
  19051. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19052. }
  19053. return oldValue.ContactID, nil
  19054. }
  19055. // ClearContactID clears the value of the "contact_id" field.
  19056. func (m *MessageRecordsMutation) ClearContactID() {
  19057. m.message_contact = nil
  19058. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19059. }
  19060. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19061. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19062. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19063. return ok
  19064. }
  19065. // ResetContactID resets all changes to the "contact_id" field.
  19066. func (m *MessageRecordsMutation) ResetContactID() {
  19067. m.message_contact = nil
  19068. delete(m.clearedFields, messagerecords.FieldContactID)
  19069. }
  19070. // SetContactType sets the "contact_type" field.
  19071. func (m *MessageRecordsMutation) SetContactType(i int) {
  19072. m.contact_type = &i
  19073. m.addcontact_type = nil
  19074. }
  19075. // ContactType returns the value of the "contact_type" field in the mutation.
  19076. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19077. v := m.contact_type
  19078. if v == nil {
  19079. return
  19080. }
  19081. return *v, true
  19082. }
  19083. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19084. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19086. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19087. if !m.op.Is(OpUpdateOne) {
  19088. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19089. }
  19090. if m.id == nil || m.oldValue == nil {
  19091. return v, errors.New("OldContactType requires an ID field in the mutation")
  19092. }
  19093. oldValue, err := m.oldValue(ctx)
  19094. if err != nil {
  19095. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19096. }
  19097. return oldValue.ContactType, nil
  19098. }
  19099. // AddContactType adds i to the "contact_type" field.
  19100. func (m *MessageRecordsMutation) AddContactType(i int) {
  19101. if m.addcontact_type != nil {
  19102. *m.addcontact_type += i
  19103. } else {
  19104. m.addcontact_type = &i
  19105. }
  19106. }
  19107. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19108. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19109. v := m.addcontact_type
  19110. if v == nil {
  19111. return
  19112. }
  19113. return *v, true
  19114. }
  19115. // ResetContactType resets all changes to the "contact_type" field.
  19116. func (m *MessageRecordsMutation) ResetContactType() {
  19117. m.contact_type = nil
  19118. m.addcontact_type = nil
  19119. }
  19120. // SetContactWxid sets the "contact_wxid" field.
  19121. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19122. m.contact_wxid = &s
  19123. }
  19124. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19125. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19126. v := m.contact_wxid
  19127. if v == nil {
  19128. return
  19129. }
  19130. return *v, true
  19131. }
  19132. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19133. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19135. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19136. if !m.op.Is(OpUpdateOne) {
  19137. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19138. }
  19139. if m.id == nil || m.oldValue == nil {
  19140. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19141. }
  19142. oldValue, err := m.oldValue(ctx)
  19143. if err != nil {
  19144. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19145. }
  19146. return oldValue.ContactWxid, nil
  19147. }
  19148. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19149. func (m *MessageRecordsMutation) ResetContactWxid() {
  19150. m.contact_wxid = nil
  19151. }
  19152. // SetContentType sets the "content_type" field.
  19153. func (m *MessageRecordsMutation) SetContentType(i int) {
  19154. m.content_type = &i
  19155. m.addcontent_type = nil
  19156. }
  19157. // ContentType returns the value of the "content_type" field in the mutation.
  19158. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19159. v := m.content_type
  19160. if v == nil {
  19161. return
  19162. }
  19163. return *v, true
  19164. }
  19165. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19166. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19168. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19169. if !m.op.Is(OpUpdateOne) {
  19170. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19171. }
  19172. if m.id == nil || m.oldValue == nil {
  19173. return v, errors.New("OldContentType requires an ID field in the mutation")
  19174. }
  19175. oldValue, err := m.oldValue(ctx)
  19176. if err != nil {
  19177. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19178. }
  19179. return oldValue.ContentType, nil
  19180. }
  19181. // AddContentType adds i to the "content_type" field.
  19182. func (m *MessageRecordsMutation) AddContentType(i int) {
  19183. if m.addcontent_type != nil {
  19184. *m.addcontent_type += i
  19185. } else {
  19186. m.addcontent_type = &i
  19187. }
  19188. }
  19189. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19190. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19191. v := m.addcontent_type
  19192. if v == nil {
  19193. return
  19194. }
  19195. return *v, true
  19196. }
  19197. // ResetContentType resets all changes to the "content_type" field.
  19198. func (m *MessageRecordsMutation) ResetContentType() {
  19199. m.content_type = nil
  19200. m.addcontent_type = nil
  19201. }
  19202. // SetContent sets the "content" field.
  19203. func (m *MessageRecordsMutation) SetContent(s string) {
  19204. m.content = &s
  19205. }
  19206. // Content returns the value of the "content" field in the mutation.
  19207. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19208. v := m.content
  19209. if v == nil {
  19210. return
  19211. }
  19212. return *v, true
  19213. }
  19214. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19215. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19217. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19218. if !m.op.Is(OpUpdateOne) {
  19219. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19220. }
  19221. if m.id == nil || m.oldValue == nil {
  19222. return v, errors.New("OldContent requires an ID field in the mutation")
  19223. }
  19224. oldValue, err := m.oldValue(ctx)
  19225. if err != nil {
  19226. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19227. }
  19228. return oldValue.Content, nil
  19229. }
  19230. // ResetContent resets all changes to the "content" field.
  19231. func (m *MessageRecordsMutation) ResetContent() {
  19232. m.content = nil
  19233. }
  19234. // SetMeta sets the "meta" field.
  19235. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19236. m.meta = &ct
  19237. }
  19238. // Meta returns the value of the "meta" field in the mutation.
  19239. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19240. v := m.meta
  19241. if v == nil {
  19242. return
  19243. }
  19244. return *v, true
  19245. }
  19246. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19247. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19249. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19250. if !m.op.Is(OpUpdateOne) {
  19251. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19252. }
  19253. if m.id == nil || m.oldValue == nil {
  19254. return v, errors.New("OldMeta requires an ID field in the mutation")
  19255. }
  19256. oldValue, err := m.oldValue(ctx)
  19257. if err != nil {
  19258. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19259. }
  19260. return oldValue.Meta, nil
  19261. }
  19262. // ClearMeta clears the value of the "meta" field.
  19263. func (m *MessageRecordsMutation) ClearMeta() {
  19264. m.meta = nil
  19265. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19266. }
  19267. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19268. func (m *MessageRecordsMutation) MetaCleared() bool {
  19269. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19270. return ok
  19271. }
  19272. // ResetMeta resets all changes to the "meta" field.
  19273. func (m *MessageRecordsMutation) ResetMeta() {
  19274. m.meta = nil
  19275. delete(m.clearedFields, messagerecords.FieldMeta)
  19276. }
  19277. // SetErrorDetail sets the "error_detail" field.
  19278. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19279. m.error_detail = &s
  19280. }
  19281. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19282. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19283. v := m.error_detail
  19284. if v == nil {
  19285. return
  19286. }
  19287. return *v, true
  19288. }
  19289. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19290. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19292. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19293. if !m.op.Is(OpUpdateOne) {
  19294. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19295. }
  19296. if m.id == nil || m.oldValue == nil {
  19297. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19298. }
  19299. oldValue, err := m.oldValue(ctx)
  19300. if err != nil {
  19301. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19302. }
  19303. return oldValue.ErrorDetail, nil
  19304. }
  19305. // ResetErrorDetail resets all changes to the "error_detail" field.
  19306. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19307. m.error_detail = nil
  19308. }
  19309. // SetSendTime sets the "send_time" field.
  19310. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19311. m.send_time = &t
  19312. }
  19313. // SendTime returns the value of the "send_time" field in the mutation.
  19314. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19315. v := m.send_time
  19316. if v == nil {
  19317. return
  19318. }
  19319. return *v, true
  19320. }
  19321. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19324. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19325. if !m.op.Is(OpUpdateOne) {
  19326. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19327. }
  19328. if m.id == nil || m.oldValue == nil {
  19329. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19330. }
  19331. oldValue, err := m.oldValue(ctx)
  19332. if err != nil {
  19333. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19334. }
  19335. return oldValue.SendTime, nil
  19336. }
  19337. // ClearSendTime clears the value of the "send_time" field.
  19338. func (m *MessageRecordsMutation) ClearSendTime() {
  19339. m.send_time = nil
  19340. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19341. }
  19342. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19343. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19344. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19345. return ok
  19346. }
  19347. // ResetSendTime resets all changes to the "send_time" field.
  19348. func (m *MessageRecordsMutation) ResetSendTime() {
  19349. m.send_time = nil
  19350. delete(m.clearedFields, messagerecords.FieldSendTime)
  19351. }
  19352. // SetSourceType sets the "source_type" field.
  19353. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19354. m.source_type = &i
  19355. m.addsource_type = nil
  19356. }
  19357. // SourceType returns the value of the "source_type" field in the mutation.
  19358. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19359. v := m.source_type
  19360. if v == nil {
  19361. return
  19362. }
  19363. return *v, true
  19364. }
  19365. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19366. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19368. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19369. if !m.op.Is(OpUpdateOne) {
  19370. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19371. }
  19372. if m.id == nil || m.oldValue == nil {
  19373. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19374. }
  19375. oldValue, err := m.oldValue(ctx)
  19376. if err != nil {
  19377. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19378. }
  19379. return oldValue.SourceType, nil
  19380. }
  19381. // AddSourceType adds i to the "source_type" field.
  19382. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19383. if m.addsource_type != nil {
  19384. *m.addsource_type += i
  19385. } else {
  19386. m.addsource_type = &i
  19387. }
  19388. }
  19389. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19390. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19391. v := m.addsource_type
  19392. if v == nil {
  19393. return
  19394. }
  19395. return *v, true
  19396. }
  19397. // ResetSourceType resets all changes to the "source_type" field.
  19398. func (m *MessageRecordsMutation) ResetSourceType() {
  19399. m.source_type = nil
  19400. m.addsource_type = nil
  19401. }
  19402. // SetSourceID sets the "source_id" field.
  19403. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19404. m.sop_stage = &u
  19405. }
  19406. // SourceID returns the value of the "source_id" field in the mutation.
  19407. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19408. v := m.sop_stage
  19409. if v == nil {
  19410. return
  19411. }
  19412. return *v, true
  19413. }
  19414. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19415. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19417. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19418. if !m.op.Is(OpUpdateOne) {
  19419. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19420. }
  19421. if m.id == nil || m.oldValue == nil {
  19422. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19423. }
  19424. oldValue, err := m.oldValue(ctx)
  19425. if err != nil {
  19426. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19427. }
  19428. return oldValue.SourceID, nil
  19429. }
  19430. // ClearSourceID clears the value of the "source_id" field.
  19431. func (m *MessageRecordsMutation) ClearSourceID() {
  19432. m.sop_stage = nil
  19433. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19434. }
  19435. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19436. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19437. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19438. return ok
  19439. }
  19440. // ResetSourceID resets all changes to the "source_id" field.
  19441. func (m *MessageRecordsMutation) ResetSourceID() {
  19442. m.sop_stage = nil
  19443. delete(m.clearedFields, messagerecords.FieldSourceID)
  19444. }
  19445. // SetSubSourceID sets the "sub_source_id" field.
  19446. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19447. m.sop_node = &u
  19448. }
  19449. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19450. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19451. v := m.sop_node
  19452. if v == nil {
  19453. return
  19454. }
  19455. return *v, true
  19456. }
  19457. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19458. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19460. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19461. if !m.op.Is(OpUpdateOne) {
  19462. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19463. }
  19464. if m.id == nil || m.oldValue == nil {
  19465. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19466. }
  19467. oldValue, err := m.oldValue(ctx)
  19468. if err != nil {
  19469. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19470. }
  19471. return oldValue.SubSourceID, nil
  19472. }
  19473. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19474. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19475. m.sop_node = nil
  19476. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19477. }
  19478. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19479. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19480. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19481. return ok
  19482. }
  19483. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19484. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19485. m.sop_node = nil
  19486. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19487. }
  19488. // SetOrganizationID sets the "organization_id" field.
  19489. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19490. m.organization_id = &u
  19491. m.addorganization_id = nil
  19492. }
  19493. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19494. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19495. v := m.organization_id
  19496. if v == nil {
  19497. return
  19498. }
  19499. return *v, true
  19500. }
  19501. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19502. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19504. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19505. if !m.op.Is(OpUpdateOne) {
  19506. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19507. }
  19508. if m.id == nil || m.oldValue == nil {
  19509. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19510. }
  19511. oldValue, err := m.oldValue(ctx)
  19512. if err != nil {
  19513. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19514. }
  19515. return oldValue.OrganizationID, nil
  19516. }
  19517. // AddOrganizationID adds u to the "organization_id" field.
  19518. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19519. if m.addorganization_id != nil {
  19520. *m.addorganization_id += u
  19521. } else {
  19522. m.addorganization_id = &u
  19523. }
  19524. }
  19525. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19526. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19527. v := m.addorganization_id
  19528. if v == nil {
  19529. return
  19530. }
  19531. return *v, true
  19532. }
  19533. // ClearOrganizationID clears the value of the "organization_id" field.
  19534. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19535. m.organization_id = nil
  19536. m.addorganization_id = nil
  19537. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19538. }
  19539. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19540. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19541. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19542. return ok
  19543. }
  19544. // ResetOrganizationID resets all changes to the "organization_id" field.
  19545. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19546. m.organization_id = nil
  19547. m.addorganization_id = nil
  19548. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19549. }
  19550. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19551. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19552. m.sop_stage = &id
  19553. }
  19554. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19555. func (m *MessageRecordsMutation) ClearSopStage() {
  19556. m.clearedsop_stage = true
  19557. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19558. }
  19559. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19560. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19561. return m.SourceIDCleared() || m.clearedsop_stage
  19562. }
  19563. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19564. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19565. if m.sop_stage != nil {
  19566. return *m.sop_stage, true
  19567. }
  19568. return
  19569. }
  19570. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19571. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19572. // SopStageID instead. It exists only for internal usage by the builders.
  19573. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19574. if id := m.sop_stage; id != nil {
  19575. ids = append(ids, *id)
  19576. }
  19577. return
  19578. }
  19579. // ResetSopStage resets all changes to the "sop_stage" edge.
  19580. func (m *MessageRecordsMutation) ResetSopStage() {
  19581. m.sop_stage = nil
  19582. m.clearedsop_stage = false
  19583. }
  19584. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19585. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19586. m.sop_node = &id
  19587. }
  19588. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19589. func (m *MessageRecordsMutation) ClearSopNode() {
  19590. m.clearedsop_node = true
  19591. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19592. }
  19593. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19594. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19595. return m.SubSourceIDCleared() || m.clearedsop_node
  19596. }
  19597. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19598. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19599. if m.sop_node != nil {
  19600. return *m.sop_node, true
  19601. }
  19602. return
  19603. }
  19604. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19605. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19606. // SopNodeID instead. It exists only for internal usage by the builders.
  19607. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19608. if id := m.sop_node; id != nil {
  19609. ids = append(ids, *id)
  19610. }
  19611. return
  19612. }
  19613. // ResetSopNode resets all changes to the "sop_node" edge.
  19614. func (m *MessageRecordsMutation) ResetSopNode() {
  19615. m.sop_node = nil
  19616. m.clearedsop_node = false
  19617. }
  19618. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19619. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19620. m.message_contact = &id
  19621. }
  19622. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19623. func (m *MessageRecordsMutation) ClearMessageContact() {
  19624. m.clearedmessage_contact = true
  19625. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19626. }
  19627. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19628. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19629. return m.ContactIDCleared() || m.clearedmessage_contact
  19630. }
  19631. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19632. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19633. if m.message_contact != nil {
  19634. return *m.message_contact, true
  19635. }
  19636. return
  19637. }
  19638. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19639. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19640. // MessageContactID instead. It exists only for internal usage by the builders.
  19641. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19642. if id := m.message_contact; id != nil {
  19643. ids = append(ids, *id)
  19644. }
  19645. return
  19646. }
  19647. // ResetMessageContact resets all changes to the "message_contact" edge.
  19648. func (m *MessageRecordsMutation) ResetMessageContact() {
  19649. m.message_contact = nil
  19650. m.clearedmessage_contact = false
  19651. }
  19652. // Where appends a list predicates to the MessageRecordsMutation builder.
  19653. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19654. m.predicates = append(m.predicates, ps...)
  19655. }
  19656. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19657. // users can use type-assertion to append predicates that do not depend on any generated package.
  19658. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19659. p := make([]predicate.MessageRecords, len(ps))
  19660. for i := range ps {
  19661. p[i] = ps[i]
  19662. }
  19663. m.Where(p...)
  19664. }
  19665. // Op returns the operation name.
  19666. func (m *MessageRecordsMutation) Op() Op {
  19667. return m.op
  19668. }
  19669. // SetOp allows setting the mutation operation.
  19670. func (m *MessageRecordsMutation) SetOp(op Op) {
  19671. m.op = op
  19672. }
  19673. // Type returns the node type of this mutation (MessageRecords).
  19674. func (m *MessageRecordsMutation) Type() string {
  19675. return m.typ
  19676. }
  19677. // Fields returns all fields that were changed during this mutation. Note that in
  19678. // order to get all numeric fields that were incremented/decremented, call
  19679. // AddedFields().
  19680. func (m *MessageRecordsMutation) Fields() []string {
  19681. fields := make([]string, 0, 16)
  19682. if m.created_at != nil {
  19683. fields = append(fields, messagerecords.FieldCreatedAt)
  19684. }
  19685. if m.updated_at != nil {
  19686. fields = append(fields, messagerecords.FieldUpdatedAt)
  19687. }
  19688. if m.status != nil {
  19689. fields = append(fields, messagerecords.FieldStatus)
  19690. }
  19691. if m.bot_wxid != nil {
  19692. fields = append(fields, messagerecords.FieldBotWxid)
  19693. }
  19694. if m.message_contact != nil {
  19695. fields = append(fields, messagerecords.FieldContactID)
  19696. }
  19697. if m.contact_type != nil {
  19698. fields = append(fields, messagerecords.FieldContactType)
  19699. }
  19700. if m.contact_wxid != nil {
  19701. fields = append(fields, messagerecords.FieldContactWxid)
  19702. }
  19703. if m.content_type != nil {
  19704. fields = append(fields, messagerecords.FieldContentType)
  19705. }
  19706. if m.content != nil {
  19707. fields = append(fields, messagerecords.FieldContent)
  19708. }
  19709. if m.meta != nil {
  19710. fields = append(fields, messagerecords.FieldMeta)
  19711. }
  19712. if m.error_detail != nil {
  19713. fields = append(fields, messagerecords.FieldErrorDetail)
  19714. }
  19715. if m.send_time != nil {
  19716. fields = append(fields, messagerecords.FieldSendTime)
  19717. }
  19718. if m.source_type != nil {
  19719. fields = append(fields, messagerecords.FieldSourceType)
  19720. }
  19721. if m.sop_stage != nil {
  19722. fields = append(fields, messagerecords.FieldSourceID)
  19723. }
  19724. if m.sop_node != nil {
  19725. fields = append(fields, messagerecords.FieldSubSourceID)
  19726. }
  19727. if m.organization_id != nil {
  19728. fields = append(fields, messagerecords.FieldOrganizationID)
  19729. }
  19730. return fields
  19731. }
  19732. // Field returns the value of a field with the given name. The second boolean
  19733. // return value indicates that this field was not set, or was not defined in the
  19734. // schema.
  19735. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19736. switch name {
  19737. case messagerecords.FieldCreatedAt:
  19738. return m.CreatedAt()
  19739. case messagerecords.FieldUpdatedAt:
  19740. return m.UpdatedAt()
  19741. case messagerecords.FieldStatus:
  19742. return m.Status()
  19743. case messagerecords.FieldBotWxid:
  19744. return m.BotWxid()
  19745. case messagerecords.FieldContactID:
  19746. return m.ContactID()
  19747. case messagerecords.FieldContactType:
  19748. return m.ContactType()
  19749. case messagerecords.FieldContactWxid:
  19750. return m.ContactWxid()
  19751. case messagerecords.FieldContentType:
  19752. return m.ContentType()
  19753. case messagerecords.FieldContent:
  19754. return m.Content()
  19755. case messagerecords.FieldMeta:
  19756. return m.Meta()
  19757. case messagerecords.FieldErrorDetail:
  19758. return m.ErrorDetail()
  19759. case messagerecords.FieldSendTime:
  19760. return m.SendTime()
  19761. case messagerecords.FieldSourceType:
  19762. return m.SourceType()
  19763. case messagerecords.FieldSourceID:
  19764. return m.SourceID()
  19765. case messagerecords.FieldSubSourceID:
  19766. return m.SubSourceID()
  19767. case messagerecords.FieldOrganizationID:
  19768. return m.OrganizationID()
  19769. }
  19770. return nil, false
  19771. }
  19772. // OldField returns the old value of the field from the database. An error is
  19773. // returned if the mutation operation is not UpdateOne, or the query to the
  19774. // database failed.
  19775. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19776. switch name {
  19777. case messagerecords.FieldCreatedAt:
  19778. return m.OldCreatedAt(ctx)
  19779. case messagerecords.FieldUpdatedAt:
  19780. return m.OldUpdatedAt(ctx)
  19781. case messagerecords.FieldStatus:
  19782. return m.OldStatus(ctx)
  19783. case messagerecords.FieldBotWxid:
  19784. return m.OldBotWxid(ctx)
  19785. case messagerecords.FieldContactID:
  19786. return m.OldContactID(ctx)
  19787. case messagerecords.FieldContactType:
  19788. return m.OldContactType(ctx)
  19789. case messagerecords.FieldContactWxid:
  19790. return m.OldContactWxid(ctx)
  19791. case messagerecords.FieldContentType:
  19792. return m.OldContentType(ctx)
  19793. case messagerecords.FieldContent:
  19794. return m.OldContent(ctx)
  19795. case messagerecords.FieldMeta:
  19796. return m.OldMeta(ctx)
  19797. case messagerecords.FieldErrorDetail:
  19798. return m.OldErrorDetail(ctx)
  19799. case messagerecords.FieldSendTime:
  19800. return m.OldSendTime(ctx)
  19801. case messagerecords.FieldSourceType:
  19802. return m.OldSourceType(ctx)
  19803. case messagerecords.FieldSourceID:
  19804. return m.OldSourceID(ctx)
  19805. case messagerecords.FieldSubSourceID:
  19806. return m.OldSubSourceID(ctx)
  19807. case messagerecords.FieldOrganizationID:
  19808. return m.OldOrganizationID(ctx)
  19809. }
  19810. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19811. }
  19812. // SetField sets the value of a field with the given name. It returns an error if
  19813. // the field is not defined in the schema, or if the type mismatched the field
  19814. // type.
  19815. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19816. switch name {
  19817. case messagerecords.FieldCreatedAt:
  19818. v, ok := value.(time.Time)
  19819. if !ok {
  19820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19821. }
  19822. m.SetCreatedAt(v)
  19823. return nil
  19824. case messagerecords.FieldUpdatedAt:
  19825. v, ok := value.(time.Time)
  19826. if !ok {
  19827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19828. }
  19829. m.SetUpdatedAt(v)
  19830. return nil
  19831. case messagerecords.FieldStatus:
  19832. v, ok := value.(uint8)
  19833. if !ok {
  19834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19835. }
  19836. m.SetStatus(v)
  19837. return nil
  19838. case messagerecords.FieldBotWxid:
  19839. v, ok := value.(string)
  19840. if !ok {
  19841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19842. }
  19843. m.SetBotWxid(v)
  19844. return nil
  19845. case messagerecords.FieldContactID:
  19846. v, ok := value.(uint64)
  19847. if !ok {
  19848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19849. }
  19850. m.SetContactID(v)
  19851. return nil
  19852. case messagerecords.FieldContactType:
  19853. v, ok := value.(int)
  19854. if !ok {
  19855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19856. }
  19857. m.SetContactType(v)
  19858. return nil
  19859. case messagerecords.FieldContactWxid:
  19860. v, ok := value.(string)
  19861. if !ok {
  19862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19863. }
  19864. m.SetContactWxid(v)
  19865. return nil
  19866. case messagerecords.FieldContentType:
  19867. v, ok := value.(int)
  19868. if !ok {
  19869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19870. }
  19871. m.SetContentType(v)
  19872. return nil
  19873. case messagerecords.FieldContent:
  19874. v, ok := value.(string)
  19875. if !ok {
  19876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19877. }
  19878. m.SetContent(v)
  19879. return nil
  19880. case messagerecords.FieldMeta:
  19881. v, ok := value.(custom_types.Meta)
  19882. if !ok {
  19883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19884. }
  19885. m.SetMeta(v)
  19886. return nil
  19887. case messagerecords.FieldErrorDetail:
  19888. v, ok := value.(string)
  19889. if !ok {
  19890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19891. }
  19892. m.SetErrorDetail(v)
  19893. return nil
  19894. case messagerecords.FieldSendTime:
  19895. v, ok := value.(time.Time)
  19896. if !ok {
  19897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19898. }
  19899. m.SetSendTime(v)
  19900. return nil
  19901. case messagerecords.FieldSourceType:
  19902. v, ok := value.(int)
  19903. if !ok {
  19904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19905. }
  19906. m.SetSourceType(v)
  19907. return nil
  19908. case messagerecords.FieldSourceID:
  19909. v, ok := value.(uint64)
  19910. if !ok {
  19911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19912. }
  19913. m.SetSourceID(v)
  19914. return nil
  19915. case messagerecords.FieldSubSourceID:
  19916. v, ok := value.(uint64)
  19917. if !ok {
  19918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19919. }
  19920. m.SetSubSourceID(v)
  19921. return nil
  19922. case messagerecords.FieldOrganizationID:
  19923. v, ok := value.(uint64)
  19924. if !ok {
  19925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19926. }
  19927. m.SetOrganizationID(v)
  19928. return nil
  19929. }
  19930. return fmt.Errorf("unknown MessageRecords field %s", name)
  19931. }
  19932. // AddedFields returns all numeric fields that were incremented/decremented during
  19933. // this mutation.
  19934. func (m *MessageRecordsMutation) AddedFields() []string {
  19935. var fields []string
  19936. if m.addstatus != nil {
  19937. fields = append(fields, messagerecords.FieldStatus)
  19938. }
  19939. if m.addcontact_type != nil {
  19940. fields = append(fields, messagerecords.FieldContactType)
  19941. }
  19942. if m.addcontent_type != nil {
  19943. fields = append(fields, messagerecords.FieldContentType)
  19944. }
  19945. if m.addsource_type != nil {
  19946. fields = append(fields, messagerecords.FieldSourceType)
  19947. }
  19948. if m.addorganization_id != nil {
  19949. fields = append(fields, messagerecords.FieldOrganizationID)
  19950. }
  19951. return fields
  19952. }
  19953. // AddedField returns the numeric value that was incremented/decremented on a field
  19954. // with the given name. The second boolean return value indicates that this field
  19955. // was not set, or was not defined in the schema.
  19956. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  19957. switch name {
  19958. case messagerecords.FieldStatus:
  19959. return m.AddedStatus()
  19960. case messagerecords.FieldContactType:
  19961. return m.AddedContactType()
  19962. case messagerecords.FieldContentType:
  19963. return m.AddedContentType()
  19964. case messagerecords.FieldSourceType:
  19965. return m.AddedSourceType()
  19966. case messagerecords.FieldOrganizationID:
  19967. return m.AddedOrganizationID()
  19968. }
  19969. return nil, false
  19970. }
  19971. // AddField adds the value to the field with the given name. It returns an error if
  19972. // the field is not defined in the schema, or if the type mismatched the field
  19973. // type.
  19974. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  19975. switch name {
  19976. case messagerecords.FieldStatus:
  19977. v, ok := value.(int8)
  19978. if !ok {
  19979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19980. }
  19981. m.AddStatus(v)
  19982. return nil
  19983. case messagerecords.FieldContactType:
  19984. v, ok := value.(int)
  19985. if !ok {
  19986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19987. }
  19988. m.AddContactType(v)
  19989. return nil
  19990. case messagerecords.FieldContentType:
  19991. v, ok := value.(int)
  19992. if !ok {
  19993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19994. }
  19995. m.AddContentType(v)
  19996. return nil
  19997. case messagerecords.FieldSourceType:
  19998. v, ok := value.(int)
  19999. if !ok {
  20000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20001. }
  20002. m.AddSourceType(v)
  20003. return nil
  20004. case messagerecords.FieldOrganizationID:
  20005. v, ok := value.(int64)
  20006. if !ok {
  20007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20008. }
  20009. m.AddOrganizationID(v)
  20010. return nil
  20011. }
  20012. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20013. }
  20014. // ClearedFields returns all nullable fields that were cleared during this
  20015. // mutation.
  20016. func (m *MessageRecordsMutation) ClearedFields() []string {
  20017. var fields []string
  20018. if m.FieldCleared(messagerecords.FieldStatus) {
  20019. fields = append(fields, messagerecords.FieldStatus)
  20020. }
  20021. if m.FieldCleared(messagerecords.FieldContactID) {
  20022. fields = append(fields, messagerecords.FieldContactID)
  20023. }
  20024. if m.FieldCleared(messagerecords.FieldMeta) {
  20025. fields = append(fields, messagerecords.FieldMeta)
  20026. }
  20027. if m.FieldCleared(messagerecords.FieldSendTime) {
  20028. fields = append(fields, messagerecords.FieldSendTime)
  20029. }
  20030. if m.FieldCleared(messagerecords.FieldSourceID) {
  20031. fields = append(fields, messagerecords.FieldSourceID)
  20032. }
  20033. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20034. fields = append(fields, messagerecords.FieldSubSourceID)
  20035. }
  20036. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20037. fields = append(fields, messagerecords.FieldOrganizationID)
  20038. }
  20039. return fields
  20040. }
  20041. // FieldCleared returns a boolean indicating if a field with the given name was
  20042. // cleared in this mutation.
  20043. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20044. _, ok := m.clearedFields[name]
  20045. return ok
  20046. }
  20047. // ClearField clears the value of the field with the given name. It returns an
  20048. // error if the field is not defined in the schema.
  20049. func (m *MessageRecordsMutation) ClearField(name string) error {
  20050. switch name {
  20051. case messagerecords.FieldStatus:
  20052. m.ClearStatus()
  20053. return nil
  20054. case messagerecords.FieldContactID:
  20055. m.ClearContactID()
  20056. return nil
  20057. case messagerecords.FieldMeta:
  20058. m.ClearMeta()
  20059. return nil
  20060. case messagerecords.FieldSendTime:
  20061. m.ClearSendTime()
  20062. return nil
  20063. case messagerecords.FieldSourceID:
  20064. m.ClearSourceID()
  20065. return nil
  20066. case messagerecords.FieldSubSourceID:
  20067. m.ClearSubSourceID()
  20068. return nil
  20069. case messagerecords.FieldOrganizationID:
  20070. m.ClearOrganizationID()
  20071. return nil
  20072. }
  20073. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20074. }
  20075. // ResetField resets all changes in the mutation for the field with the given name.
  20076. // It returns an error if the field is not defined in the schema.
  20077. func (m *MessageRecordsMutation) ResetField(name string) error {
  20078. switch name {
  20079. case messagerecords.FieldCreatedAt:
  20080. m.ResetCreatedAt()
  20081. return nil
  20082. case messagerecords.FieldUpdatedAt:
  20083. m.ResetUpdatedAt()
  20084. return nil
  20085. case messagerecords.FieldStatus:
  20086. m.ResetStatus()
  20087. return nil
  20088. case messagerecords.FieldBotWxid:
  20089. m.ResetBotWxid()
  20090. return nil
  20091. case messagerecords.FieldContactID:
  20092. m.ResetContactID()
  20093. return nil
  20094. case messagerecords.FieldContactType:
  20095. m.ResetContactType()
  20096. return nil
  20097. case messagerecords.FieldContactWxid:
  20098. m.ResetContactWxid()
  20099. return nil
  20100. case messagerecords.FieldContentType:
  20101. m.ResetContentType()
  20102. return nil
  20103. case messagerecords.FieldContent:
  20104. m.ResetContent()
  20105. return nil
  20106. case messagerecords.FieldMeta:
  20107. m.ResetMeta()
  20108. return nil
  20109. case messagerecords.FieldErrorDetail:
  20110. m.ResetErrorDetail()
  20111. return nil
  20112. case messagerecords.FieldSendTime:
  20113. m.ResetSendTime()
  20114. return nil
  20115. case messagerecords.FieldSourceType:
  20116. m.ResetSourceType()
  20117. return nil
  20118. case messagerecords.FieldSourceID:
  20119. m.ResetSourceID()
  20120. return nil
  20121. case messagerecords.FieldSubSourceID:
  20122. m.ResetSubSourceID()
  20123. return nil
  20124. case messagerecords.FieldOrganizationID:
  20125. m.ResetOrganizationID()
  20126. return nil
  20127. }
  20128. return fmt.Errorf("unknown MessageRecords field %s", name)
  20129. }
  20130. // AddedEdges returns all edge names that were set/added in this mutation.
  20131. func (m *MessageRecordsMutation) AddedEdges() []string {
  20132. edges := make([]string, 0, 3)
  20133. if m.sop_stage != nil {
  20134. edges = append(edges, messagerecords.EdgeSopStage)
  20135. }
  20136. if m.sop_node != nil {
  20137. edges = append(edges, messagerecords.EdgeSopNode)
  20138. }
  20139. if m.message_contact != nil {
  20140. edges = append(edges, messagerecords.EdgeMessageContact)
  20141. }
  20142. return edges
  20143. }
  20144. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20145. // name in this mutation.
  20146. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20147. switch name {
  20148. case messagerecords.EdgeSopStage:
  20149. if id := m.sop_stage; id != nil {
  20150. return []ent.Value{*id}
  20151. }
  20152. case messagerecords.EdgeSopNode:
  20153. if id := m.sop_node; id != nil {
  20154. return []ent.Value{*id}
  20155. }
  20156. case messagerecords.EdgeMessageContact:
  20157. if id := m.message_contact; id != nil {
  20158. return []ent.Value{*id}
  20159. }
  20160. }
  20161. return nil
  20162. }
  20163. // RemovedEdges returns all edge names that were removed in this mutation.
  20164. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20165. edges := make([]string, 0, 3)
  20166. return edges
  20167. }
  20168. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20169. // the given name in this mutation.
  20170. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20171. return nil
  20172. }
  20173. // ClearedEdges returns all edge names that were cleared in this mutation.
  20174. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20175. edges := make([]string, 0, 3)
  20176. if m.clearedsop_stage {
  20177. edges = append(edges, messagerecords.EdgeSopStage)
  20178. }
  20179. if m.clearedsop_node {
  20180. edges = append(edges, messagerecords.EdgeSopNode)
  20181. }
  20182. if m.clearedmessage_contact {
  20183. edges = append(edges, messagerecords.EdgeMessageContact)
  20184. }
  20185. return edges
  20186. }
  20187. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20188. // was cleared in this mutation.
  20189. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20190. switch name {
  20191. case messagerecords.EdgeSopStage:
  20192. return m.clearedsop_stage
  20193. case messagerecords.EdgeSopNode:
  20194. return m.clearedsop_node
  20195. case messagerecords.EdgeMessageContact:
  20196. return m.clearedmessage_contact
  20197. }
  20198. return false
  20199. }
  20200. // ClearEdge clears the value of the edge with the given name. It returns an error
  20201. // if that edge is not defined in the schema.
  20202. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20203. switch name {
  20204. case messagerecords.EdgeSopStage:
  20205. m.ClearSopStage()
  20206. return nil
  20207. case messagerecords.EdgeSopNode:
  20208. m.ClearSopNode()
  20209. return nil
  20210. case messagerecords.EdgeMessageContact:
  20211. m.ClearMessageContact()
  20212. return nil
  20213. }
  20214. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20215. }
  20216. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20217. // It returns an error if the edge is not defined in the schema.
  20218. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20219. switch name {
  20220. case messagerecords.EdgeSopStage:
  20221. m.ResetSopStage()
  20222. return nil
  20223. case messagerecords.EdgeSopNode:
  20224. m.ResetSopNode()
  20225. return nil
  20226. case messagerecords.EdgeMessageContact:
  20227. m.ResetMessageContact()
  20228. return nil
  20229. }
  20230. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20231. }
  20232. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20233. type MsgMutation struct {
  20234. config
  20235. op Op
  20236. typ string
  20237. id *uint64
  20238. created_at *time.Time
  20239. updated_at *time.Time
  20240. deleted_at *time.Time
  20241. status *uint8
  20242. addstatus *int8
  20243. fromwxid *string
  20244. toid *string
  20245. msgtype *int32
  20246. addmsgtype *int32
  20247. msg *string
  20248. batch_no *string
  20249. cc *string
  20250. phone *string
  20251. clearedFields map[string]struct{}
  20252. done bool
  20253. oldValue func(context.Context) (*Msg, error)
  20254. predicates []predicate.Msg
  20255. }
  20256. var _ ent.Mutation = (*MsgMutation)(nil)
  20257. // msgOption allows management of the mutation configuration using functional options.
  20258. type msgOption func(*MsgMutation)
  20259. // newMsgMutation creates new mutation for the Msg entity.
  20260. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20261. m := &MsgMutation{
  20262. config: c,
  20263. op: op,
  20264. typ: TypeMsg,
  20265. clearedFields: make(map[string]struct{}),
  20266. }
  20267. for _, opt := range opts {
  20268. opt(m)
  20269. }
  20270. return m
  20271. }
  20272. // withMsgID sets the ID field of the mutation.
  20273. func withMsgID(id uint64) msgOption {
  20274. return func(m *MsgMutation) {
  20275. var (
  20276. err error
  20277. once sync.Once
  20278. value *Msg
  20279. )
  20280. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20281. once.Do(func() {
  20282. if m.done {
  20283. err = errors.New("querying old values post mutation is not allowed")
  20284. } else {
  20285. value, err = m.Client().Msg.Get(ctx, id)
  20286. }
  20287. })
  20288. return value, err
  20289. }
  20290. m.id = &id
  20291. }
  20292. }
  20293. // withMsg sets the old Msg of the mutation.
  20294. func withMsg(node *Msg) msgOption {
  20295. return func(m *MsgMutation) {
  20296. m.oldValue = func(context.Context) (*Msg, error) {
  20297. return node, nil
  20298. }
  20299. m.id = &node.ID
  20300. }
  20301. }
  20302. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20303. // executed in a transaction (ent.Tx), a transactional client is returned.
  20304. func (m MsgMutation) Client() *Client {
  20305. client := &Client{config: m.config}
  20306. client.init()
  20307. return client
  20308. }
  20309. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20310. // it returns an error otherwise.
  20311. func (m MsgMutation) Tx() (*Tx, error) {
  20312. if _, ok := m.driver.(*txDriver); !ok {
  20313. return nil, errors.New("ent: mutation is not running in a transaction")
  20314. }
  20315. tx := &Tx{config: m.config}
  20316. tx.init()
  20317. return tx, nil
  20318. }
  20319. // SetID sets the value of the id field. Note that this
  20320. // operation is only accepted on creation of Msg entities.
  20321. func (m *MsgMutation) SetID(id uint64) {
  20322. m.id = &id
  20323. }
  20324. // ID returns the ID value in the mutation. Note that the ID is only available
  20325. // if it was provided to the builder or after it was returned from the database.
  20326. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20327. if m.id == nil {
  20328. return
  20329. }
  20330. return *m.id, true
  20331. }
  20332. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20333. // That means, if the mutation is applied within a transaction with an isolation level such
  20334. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20335. // or updated by the mutation.
  20336. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20337. switch {
  20338. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20339. id, exists := m.ID()
  20340. if exists {
  20341. return []uint64{id}, nil
  20342. }
  20343. fallthrough
  20344. case m.op.Is(OpUpdate | OpDelete):
  20345. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20346. default:
  20347. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20348. }
  20349. }
  20350. // SetCreatedAt sets the "created_at" field.
  20351. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20352. m.created_at = &t
  20353. }
  20354. // CreatedAt returns the value of the "created_at" field in the mutation.
  20355. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20356. v := m.created_at
  20357. if v == nil {
  20358. return
  20359. }
  20360. return *v, true
  20361. }
  20362. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20363. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20365. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20366. if !m.op.Is(OpUpdateOne) {
  20367. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20368. }
  20369. if m.id == nil || m.oldValue == nil {
  20370. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20371. }
  20372. oldValue, err := m.oldValue(ctx)
  20373. if err != nil {
  20374. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20375. }
  20376. return oldValue.CreatedAt, nil
  20377. }
  20378. // ResetCreatedAt resets all changes to the "created_at" field.
  20379. func (m *MsgMutation) ResetCreatedAt() {
  20380. m.created_at = nil
  20381. }
  20382. // SetUpdatedAt sets the "updated_at" field.
  20383. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20384. m.updated_at = &t
  20385. }
  20386. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20387. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20388. v := m.updated_at
  20389. if v == nil {
  20390. return
  20391. }
  20392. return *v, true
  20393. }
  20394. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20395. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20397. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20398. if !m.op.Is(OpUpdateOne) {
  20399. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20400. }
  20401. if m.id == nil || m.oldValue == nil {
  20402. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20403. }
  20404. oldValue, err := m.oldValue(ctx)
  20405. if err != nil {
  20406. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20407. }
  20408. return oldValue.UpdatedAt, nil
  20409. }
  20410. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20411. func (m *MsgMutation) ResetUpdatedAt() {
  20412. m.updated_at = nil
  20413. }
  20414. // SetDeletedAt sets the "deleted_at" field.
  20415. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20416. m.deleted_at = &t
  20417. }
  20418. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20419. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20420. v := m.deleted_at
  20421. if v == nil {
  20422. return
  20423. }
  20424. return *v, true
  20425. }
  20426. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20427. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20429. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20430. if !m.op.Is(OpUpdateOne) {
  20431. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20432. }
  20433. if m.id == nil || m.oldValue == nil {
  20434. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20435. }
  20436. oldValue, err := m.oldValue(ctx)
  20437. if err != nil {
  20438. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20439. }
  20440. return oldValue.DeletedAt, nil
  20441. }
  20442. // ClearDeletedAt clears the value of the "deleted_at" field.
  20443. func (m *MsgMutation) ClearDeletedAt() {
  20444. m.deleted_at = nil
  20445. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20446. }
  20447. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20448. func (m *MsgMutation) DeletedAtCleared() bool {
  20449. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20450. return ok
  20451. }
  20452. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20453. func (m *MsgMutation) ResetDeletedAt() {
  20454. m.deleted_at = nil
  20455. delete(m.clearedFields, msg.FieldDeletedAt)
  20456. }
  20457. // SetStatus sets the "status" field.
  20458. func (m *MsgMutation) SetStatus(u uint8) {
  20459. m.status = &u
  20460. m.addstatus = nil
  20461. }
  20462. // Status returns the value of the "status" field in the mutation.
  20463. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20464. v := m.status
  20465. if v == nil {
  20466. return
  20467. }
  20468. return *v, true
  20469. }
  20470. // OldStatus returns the old "status" field's value of the Msg entity.
  20471. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20473. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20474. if !m.op.Is(OpUpdateOne) {
  20475. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20476. }
  20477. if m.id == nil || m.oldValue == nil {
  20478. return v, errors.New("OldStatus requires an ID field in the mutation")
  20479. }
  20480. oldValue, err := m.oldValue(ctx)
  20481. if err != nil {
  20482. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20483. }
  20484. return oldValue.Status, nil
  20485. }
  20486. // AddStatus adds u to the "status" field.
  20487. func (m *MsgMutation) AddStatus(u int8) {
  20488. if m.addstatus != nil {
  20489. *m.addstatus += u
  20490. } else {
  20491. m.addstatus = &u
  20492. }
  20493. }
  20494. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20495. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20496. v := m.addstatus
  20497. if v == nil {
  20498. return
  20499. }
  20500. return *v, true
  20501. }
  20502. // ClearStatus clears the value of the "status" field.
  20503. func (m *MsgMutation) ClearStatus() {
  20504. m.status = nil
  20505. m.addstatus = nil
  20506. m.clearedFields[msg.FieldStatus] = struct{}{}
  20507. }
  20508. // StatusCleared returns if the "status" field was cleared in this mutation.
  20509. func (m *MsgMutation) StatusCleared() bool {
  20510. _, ok := m.clearedFields[msg.FieldStatus]
  20511. return ok
  20512. }
  20513. // ResetStatus resets all changes to the "status" field.
  20514. func (m *MsgMutation) ResetStatus() {
  20515. m.status = nil
  20516. m.addstatus = nil
  20517. delete(m.clearedFields, msg.FieldStatus)
  20518. }
  20519. // SetFromwxid sets the "fromwxid" field.
  20520. func (m *MsgMutation) SetFromwxid(s string) {
  20521. m.fromwxid = &s
  20522. }
  20523. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20524. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20525. v := m.fromwxid
  20526. if v == nil {
  20527. return
  20528. }
  20529. return *v, true
  20530. }
  20531. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20532. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20534. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20535. if !m.op.Is(OpUpdateOne) {
  20536. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20537. }
  20538. if m.id == nil || m.oldValue == nil {
  20539. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20540. }
  20541. oldValue, err := m.oldValue(ctx)
  20542. if err != nil {
  20543. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20544. }
  20545. return oldValue.Fromwxid, nil
  20546. }
  20547. // ClearFromwxid clears the value of the "fromwxid" field.
  20548. func (m *MsgMutation) ClearFromwxid() {
  20549. m.fromwxid = nil
  20550. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20551. }
  20552. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20553. func (m *MsgMutation) FromwxidCleared() bool {
  20554. _, ok := m.clearedFields[msg.FieldFromwxid]
  20555. return ok
  20556. }
  20557. // ResetFromwxid resets all changes to the "fromwxid" field.
  20558. func (m *MsgMutation) ResetFromwxid() {
  20559. m.fromwxid = nil
  20560. delete(m.clearedFields, msg.FieldFromwxid)
  20561. }
  20562. // SetToid sets the "toid" field.
  20563. func (m *MsgMutation) SetToid(s string) {
  20564. m.toid = &s
  20565. }
  20566. // Toid returns the value of the "toid" field in the mutation.
  20567. func (m *MsgMutation) Toid() (r string, exists bool) {
  20568. v := m.toid
  20569. if v == nil {
  20570. return
  20571. }
  20572. return *v, true
  20573. }
  20574. // OldToid returns the old "toid" field's value of the Msg entity.
  20575. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20577. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20578. if !m.op.Is(OpUpdateOne) {
  20579. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20580. }
  20581. if m.id == nil || m.oldValue == nil {
  20582. return v, errors.New("OldToid requires an ID field in the mutation")
  20583. }
  20584. oldValue, err := m.oldValue(ctx)
  20585. if err != nil {
  20586. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20587. }
  20588. return oldValue.Toid, nil
  20589. }
  20590. // ClearToid clears the value of the "toid" field.
  20591. func (m *MsgMutation) ClearToid() {
  20592. m.toid = nil
  20593. m.clearedFields[msg.FieldToid] = struct{}{}
  20594. }
  20595. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20596. func (m *MsgMutation) ToidCleared() bool {
  20597. _, ok := m.clearedFields[msg.FieldToid]
  20598. return ok
  20599. }
  20600. // ResetToid resets all changes to the "toid" field.
  20601. func (m *MsgMutation) ResetToid() {
  20602. m.toid = nil
  20603. delete(m.clearedFields, msg.FieldToid)
  20604. }
  20605. // SetMsgtype sets the "msgtype" field.
  20606. func (m *MsgMutation) SetMsgtype(i int32) {
  20607. m.msgtype = &i
  20608. m.addmsgtype = nil
  20609. }
  20610. // Msgtype returns the value of the "msgtype" field in the mutation.
  20611. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20612. v := m.msgtype
  20613. if v == nil {
  20614. return
  20615. }
  20616. return *v, true
  20617. }
  20618. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20619. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20621. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20622. if !m.op.Is(OpUpdateOne) {
  20623. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20624. }
  20625. if m.id == nil || m.oldValue == nil {
  20626. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20627. }
  20628. oldValue, err := m.oldValue(ctx)
  20629. if err != nil {
  20630. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20631. }
  20632. return oldValue.Msgtype, nil
  20633. }
  20634. // AddMsgtype adds i to the "msgtype" field.
  20635. func (m *MsgMutation) AddMsgtype(i int32) {
  20636. if m.addmsgtype != nil {
  20637. *m.addmsgtype += i
  20638. } else {
  20639. m.addmsgtype = &i
  20640. }
  20641. }
  20642. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20643. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20644. v := m.addmsgtype
  20645. if v == nil {
  20646. return
  20647. }
  20648. return *v, true
  20649. }
  20650. // ClearMsgtype clears the value of the "msgtype" field.
  20651. func (m *MsgMutation) ClearMsgtype() {
  20652. m.msgtype = nil
  20653. m.addmsgtype = nil
  20654. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20655. }
  20656. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20657. func (m *MsgMutation) MsgtypeCleared() bool {
  20658. _, ok := m.clearedFields[msg.FieldMsgtype]
  20659. return ok
  20660. }
  20661. // ResetMsgtype resets all changes to the "msgtype" field.
  20662. func (m *MsgMutation) ResetMsgtype() {
  20663. m.msgtype = nil
  20664. m.addmsgtype = nil
  20665. delete(m.clearedFields, msg.FieldMsgtype)
  20666. }
  20667. // SetMsg sets the "msg" field.
  20668. func (m *MsgMutation) SetMsg(s string) {
  20669. m.msg = &s
  20670. }
  20671. // Msg returns the value of the "msg" field in the mutation.
  20672. func (m *MsgMutation) Msg() (r string, exists bool) {
  20673. v := m.msg
  20674. if v == nil {
  20675. return
  20676. }
  20677. return *v, true
  20678. }
  20679. // OldMsg returns the old "msg" field's value of the Msg entity.
  20680. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20682. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20683. if !m.op.Is(OpUpdateOne) {
  20684. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20685. }
  20686. if m.id == nil || m.oldValue == nil {
  20687. return v, errors.New("OldMsg requires an ID field in the mutation")
  20688. }
  20689. oldValue, err := m.oldValue(ctx)
  20690. if err != nil {
  20691. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20692. }
  20693. return oldValue.Msg, nil
  20694. }
  20695. // ClearMsg clears the value of the "msg" field.
  20696. func (m *MsgMutation) ClearMsg() {
  20697. m.msg = nil
  20698. m.clearedFields[msg.FieldMsg] = struct{}{}
  20699. }
  20700. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20701. func (m *MsgMutation) MsgCleared() bool {
  20702. _, ok := m.clearedFields[msg.FieldMsg]
  20703. return ok
  20704. }
  20705. // ResetMsg resets all changes to the "msg" field.
  20706. func (m *MsgMutation) ResetMsg() {
  20707. m.msg = nil
  20708. delete(m.clearedFields, msg.FieldMsg)
  20709. }
  20710. // SetBatchNo sets the "batch_no" field.
  20711. func (m *MsgMutation) SetBatchNo(s string) {
  20712. m.batch_no = &s
  20713. }
  20714. // BatchNo returns the value of the "batch_no" field in the mutation.
  20715. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20716. v := m.batch_no
  20717. if v == nil {
  20718. return
  20719. }
  20720. return *v, true
  20721. }
  20722. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20723. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20725. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20726. if !m.op.Is(OpUpdateOne) {
  20727. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20728. }
  20729. if m.id == nil || m.oldValue == nil {
  20730. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20731. }
  20732. oldValue, err := m.oldValue(ctx)
  20733. if err != nil {
  20734. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20735. }
  20736. return oldValue.BatchNo, nil
  20737. }
  20738. // ClearBatchNo clears the value of the "batch_no" field.
  20739. func (m *MsgMutation) ClearBatchNo() {
  20740. m.batch_no = nil
  20741. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20742. }
  20743. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20744. func (m *MsgMutation) BatchNoCleared() bool {
  20745. _, ok := m.clearedFields[msg.FieldBatchNo]
  20746. return ok
  20747. }
  20748. // ResetBatchNo resets all changes to the "batch_no" field.
  20749. func (m *MsgMutation) ResetBatchNo() {
  20750. m.batch_no = nil
  20751. delete(m.clearedFields, msg.FieldBatchNo)
  20752. }
  20753. // SetCc sets the "cc" field.
  20754. func (m *MsgMutation) SetCc(s string) {
  20755. m.cc = &s
  20756. }
  20757. // Cc returns the value of the "cc" field in the mutation.
  20758. func (m *MsgMutation) Cc() (r string, exists bool) {
  20759. v := m.cc
  20760. if v == nil {
  20761. return
  20762. }
  20763. return *v, true
  20764. }
  20765. // OldCc returns the old "cc" field's value of the Msg entity.
  20766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20768. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20769. if !m.op.Is(OpUpdateOne) {
  20770. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20771. }
  20772. if m.id == nil || m.oldValue == nil {
  20773. return v, errors.New("OldCc requires an ID field in the mutation")
  20774. }
  20775. oldValue, err := m.oldValue(ctx)
  20776. if err != nil {
  20777. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20778. }
  20779. return oldValue.Cc, nil
  20780. }
  20781. // ResetCc resets all changes to the "cc" field.
  20782. func (m *MsgMutation) ResetCc() {
  20783. m.cc = nil
  20784. }
  20785. // SetPhone sets the "phone" field.
  20786. func (m *MsgMutation) SetPhone(s string) {
  20787. m.phone = &s
  20788. }
  20789. // Phone returns the value of the "phone" field in the mutation.
  20790. func (m *MsgMutation) Phone() (r string, exists bool) {
  20791. v := m.phone
  20792. if v == nil {
  20793. return
  20794. }
  20795. return *v, true
  20796. }
  20797. // OldPhone returns the old "phone" field's value of the Msg entity.
  20798. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20800. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20801. if !m.op.Is(OpUpdateOne) {
  20802. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20803. }
  20804. if m.id == nil || m.oldValue == nil {
  20805. return v, errors.New("OldPhone requires an ID field in the mutation")
  20806. }
  20807. oldValue, err := m.oldValue(ctx)
  20808. if err != nil {
  20809. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20810. }
  20811. return oldValue.Phone, nil
  20812. }
  20813. // ResetPhone resets all changes to the "phone" field.
  20814. func (m *MsgMutation) ResetPhone() {
  20815. m.phone = nil
  20816. }
  20817. // Where appends a list predicates to the MsgMutation builder.
  20818. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20819. m.predicates = append(m.predicates, ps...)
  20820. }
  20821. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20822. // users can use type-assertion to append predicates that do not depend on any generated package.
  20823. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20824. p := make([]predicate.Msg, len(ps))
  20825. for i := range ps {
  20826. p[i] = ps[i]
  20827. }
  20828. m.Where(p...)
  20829. }
  20830. // Op returns the operation name.
  20831. func (m *MsgMutation) Op() Op {
  20832. return m.op
  20833. }
  20834. // SetOp allows setting the mutation operation.
  20835. func (m *MsgMutation) SetOp(op Op) {
  20836. m.op = op
  20837. }
  20838. // Type returns the node type of this mutation (Msg).
  20839. func (m *MsgMutation) Type() string {
  20840. return m.typ
  20841. }
  20842. // Fields returns all fields that were changed during this mutation. Note that in
  20843. // order to get all numeric fields that were incremented/decremented, call
  20844. // AddedFields().
  20845. func (m *MsgMutation) Fields() []string {
  20846. fields := make([]string, 0, 11)
  20847. if m.created_at != nil {
  20848. fields = append(fields, msg.FieldCreatedAt)
  20849. }
  20850. if m.updated_at != nil {
  20851. fields = append(fields, msg.FieldUpdatedAt)
  20852. }
  20853. if m.deleted_at != nil {
  20854. fields = append(fields, msg.FieldDeletedAt)
  20855. }
  20856. if m.status != nil {
  20857. fields = append(fields, msg.FieldStatus)
  20858. }
  20859. if m.fromwxid != nil {
  20860. fields = append(fields, msg.FieldFromwxid)
  20861. }
  20862. if m.toid != nil {
  20863. fields = append(fields, msg.FieldToid)
  20864. }
  20865. if m.msgtype != nil {
  20866. fields = append(fields, msg.FieldMsgtype)
  20867. }
  20868. if m.msg != nil {
  20869. fields = append(fields, msg.FieldMsg)
  20870. }
  20871. if m.batch_no != nil {
  20872. fields = append(fields, msg.FieldBatchNo)
  20873. }
  20874. if m.cc != nil {
  20875. fields = append(fields, msg.FieldCc)
  20876. }
  20877. if m.phone != nil {
  20878. fields = append(fields, msg.FieldPhone)
  20879. }
  20880. return fields
  20881. }
  20882. // Field returns the value of a field with the given name. The second boolean
  20883. // return value indicates that this field was not set, or was not defined in the
  20884. // schema.
  20885. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  20886. switch name {
  20887. case msg.FieldCreatedAt:
  20888. return m.CreatedAt()
  20889. case msg.FieldUpdatedAt:
  20890. return m.UpdatedAt()
  20891. case msg.FieldDeletedAt:
  20892. return m.DeletedAt()
  20893. case msg.FieldStatus:
  20894. return m.Status()
  20895. case msg.FieldFromwxid:
  20896. return m.Fromwxid()
  20897. case msg.FieldToid:
  20898. return m.Toid()
  20899. case msg.FieldMsgtype:
  20900. return m.Msgtype()
  20901. case msg.FieldMsg:
  20902. return m.Msg()
  20903. case msg.FieldBatchNo:
  20904. return m.BatchNo()
  20905. case msg.FieldCc:
  20906. return m.Cc()
  20907. case msg.FieldPhone:
  20908. return m.Phone()
  20909. }
  20910. return nil, false
  20911. }
  20912. // OldField returns the old value of the field from the database. An error is
  20913. // returned if the mutation operation is not UpdateOne, or the query to the
  20914. // database failed.
  20915. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20916. switch name {
  20917. case msg.FieldCreatedAt:
  20918. return m.OldCreatedAt(ctx)
  20919. case msg.FieldUpdatedAt:
  20920. return m.OldUpdatedAt(ctx)
  20921. case msg.FieldDeletedAt:
  20922. return m.OldDeletedAt(ctx)
  20923. case msg.FieldStatus:
  20924. return m.OldStatus(ctx)
  20925. case msg.FieldFromwxid:
  20926. return m.OldFromwxid(ctx)
  20927. case msg.FieldToid:
  20928. return m.OldToid(ctx)
  20929. case msg.FieldMsgtype:
  20930. return m.OldMsgtype(ctx)
  20931. case msg.FieldMsg:
  20932. return m.OldMsg(ctx)
  20933. case msg.FieldBatchNo:
  20934. return m.OldBatchNo(ctx)
  20935. case msg.FieldCc:
  20936. return m.OldCc(ctx)
  20937. case msg.FieldPhone:
  20938. return m.OldPhone(ctx)
  20939. }
  20940. return nil, fmt.Errorf("unknown Msg field %s", name)
  20941. }
  20942. // SetField sets the value of a field with the given name. It returns an error if
  20943. // the field is not defined in the schema, or if the type mismatched the field
  20944. // type.
  20945. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  20946. switch name {
  20947. case msg.FieldCreatedAt:
  20948. v, ok := value.(time.Time)
  20949. if !ok {
  20950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20951. }
  20952. m.SetCreatedAt(v)
  20953. return nil
  20954. case msg.FieldUpdatedAt:
  20955. v, ok := value.(time.Time)
  20956. if !ok {
  20957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20958. }
  20959. m.SetUpdatedAt(v)
  20960. return nil
  20961. case msg.FieldDeletedAt:
  20962. v, ok := value.(time.Time)
  20963. if !ok {
  20964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20965. }
  20966. m.SetDeletedAt(v)
  20967. return nil
  20968. case msg.FieldStatus:
  20969. v, ok := value.(uint8)
  20970. if !ok {
  20971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20972. }
  20973. m.SetStatus(v)
  20974. return nil
  20975. case msg.FieldFromwxid:
  20976. v, ok := value.(string)
  20977. if !ok {
  20978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20979. }
  20980. m.SetFromwxid(v)
  20981. return nil
  20982. case msg.FieldToid:
  20983. v, ok := value.(string)
  20984. if !ok {
  20985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20986. }
  20987. m.SetToid(v)
  20988. return nil
  20989. case msg.FieldMsgtype:
  20990. v, ok := value.(int32)
  20991. if !ok {
  20992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20993. }
  20994. m.SetMsgtype(v)
  20995. return nil
  20996. case msg.FieldMsg:
  20997. v, ok := value.(string)
  20998. if !ok {
  20999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21000. }
  21001. m.SetMsg(v)
  21002. return nil
  21003. case msg.FieldBatchNo:
  21004. v, ok := value.(string)
  21005. if !ok {
  21006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21007. }
  21008. m.SetBatchNo(v)
  21009. return nil
  21010. case msg.FieldCc:
  21011. v, ok := value.(string)
  21012. if !ok {
  21013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21014. }
  21015. m.SetCc(v)
  21016. return nil
  21017. case msg.FieldPhone:
  21018. v, ok := value.(string)
  21019. if !ok {
  21020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21021. }
  21022. m.SetPhone(v)
  21023. return nil
  21024. }
  21025. return fmt.Errorf("unknown Msg field %s", name)
  21026. }
  21027. // AddedFields returns all numeric fields that were incremented/decremented during
  21028. // this mutation.
  21029. func (m *MsgMutation) AddedFields() []string {
  21030. var fields []string
  21031. if m.addstatus != nil {
  21032. fields = append(fields, msg.FieldStatus)
  21033. }
  21034. if m.addmsgtype != nil {
  21035. fields = append(fields, msg.FieldMsgtype)
  21036. }
  21037. return fields
  21038. }
  21039. // AddedField returns the numeric value that was incremented/decremented on a field
  21040. // with the given name. The second boolean return value indicates that this field
  21041. // was not set, or was not defined in the schema.
  21042. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21043. switch name {
  21044. case msg.FieldStatus:
  21045. return m.AddedStatus()
  21046. case msg.FieldMsgtype:
  21047. return m.AddedMsgtype()
  21048. }
  21049. return nil, false
  21050. }
  21051. // AddField adds the value to the field with the given name. It returns an error if
  21052. // the field is not defined in the schema, or if the type mismatched the field
  21053. // type.
  21054. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21055. switch name {
  21056. case msg.FieldStatus:
  21057. v, ok := value.(int8)
  21058. if !ok {
  21059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21060. }
  21061. m.AddStatus(v)
  21062. return nil
  21063. case msg.FieldMsgtype:
  21064. v, ok := value.(int32)
  21065. if !ok {
  21066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21067. }
  21068. m.AddMsgtype(v)
  21069. return nil
  21070. }
  21071. return fmt.Errorf("unknown Msg numeric field %s", name)
  21072. }
  21073. // ClearedFields returns all nullable fields that were cleared during this
  21074. // mutation.
  21075. func (m *MsgMutation) ClearedFields() []string {
  21076. var fields []string
  21077. if m.FieldCleared(msg.FieldDeletedAt) {
  21078. fields = append(fields, msg.FieldDeletedAt)
  21079. }
  21080. if m.FieldCleared(msg.FieldStatus) {
  21081. fields = append(fields, msg.FieldStatus)
  21082. }
  21083. if m.FieldCleared(msg.FieldFromwxid) {
  21084. fields = append(fields, msg.FieldFromwxid)
  21085. }
  21086. if m.FieldCleared(msg.FieldToid) {
  21087. fields = append(fields, msg.FieldToid)
  21088. }
  21089. if m.FieldCleared(msg.FieldMsgtype) {
  21090. fields = append(fields, msg.FieldMsgtype)
  21091. }
  21092. if m.FieldCleared(msg.FieldMsg) {
  21093. fields = append(fields, msg.FieldMsg)
  21094. }
  21095. if m.FieldCleared(msg.FieldBatchNo) {
  21096. fields = append(fields, msg.FieldBatchNo)
  21097. }
  21098. return fields
  21099. }
  21100. // FieldCleared returns a boolean indicating if a field with the given name was
  21101. // cleared in this mutation.
  21102. func (m *MsgMutation) FieldCleared(name string) bool {
  21103. _, ok := m.clearedFields[name]
  21104. return ok
  21105. }
  21106. // ClearField clears the value of the field with the given name. It returns an
  21107. // error if the field is not defined in the schema.
  21108. func (m *MsgMutation) ClearField(name string) error {
  21109. switch name {
  21110. case msg.FieldDeletedAt:
  21111. m.ClearDeletedAt()
  21112. return nil
  21113. case msg.FieldStatus:
  21114. m.ClearStatus()
  21115. return nil
  21116. case msg.FieldFromwxid:
  21117. m.ClearFromwxid()
  21118. return nil
  21119. case msg.FieldToid:
  21120. m.ClearToid()
  21121. return nil
  21122. case msg.FieldMsgtype:
  21123. m.ClearMsgtype()
  21124. return nil
  21125. case msg.FieldMsg:
  21126. m.ClearMsg()
  21127. return nil
  21128. case msg.FieldBatchNo:
  21129. m.ClearBatchNo()
  21130. return nil
  21131. }
  21132. return fmt.Errorf("unknown Msg nullable field %s", name)
  21133. }
  21134. // ResetField resets all changes in the mutation for the field with the given name.
  21135. // It returns an error if the field is not defined in the schema.
  21136. func (m *MsgMutation) ResetField(name string) error {
  21137. switch name {
  21138. case msg.FieldCreatedAt:
  21139. m.ResetCreatedAt()
  21140. return nil
  21141. case msg.FieldUpdatedAt:
  21142. m.ResetUpdatedAt()
  21143. return nil
  21144. case msg.FieldDeletedAt:
  21145. m.ResetDeletedAt()
  21146. return nil
  21147. case msg.FieldStatus:
  21148. m.ResetStatus()
  21149. return nil
  21150. case msg.FieldFromwxid:
  21151. m.ResetFromwxid()
  21152. return nil
  21153. case msg.FieldToid:
  21154. m.ResetToid()
  21155. return nil
  21156. case msg.FieldMsgtype:
  21157. m.ResetMsgtype()
  21158. return nil
  21159. case msg.FieldMsg:
  21160. m.ResetMsg()
  21161. return nil
  21162. case msg.FieldBatchNo:
  21163. m.ResetBatchNo()
  21164. return nil
  21165. case msg.FieldCc:
  21166. m.ResetCc()
  21167. return nil
  21168. case msg.FieldPhone:
  21169. m.ResetPhone()
  21170. return nil
  21171. }
  21172. return fmt.Errorf("unknown Msg field %s", name)
  21173. }
  21174. // AddedEdges returns all edge names that were set/added in this mutation.
  21175. func (m *MsgMutation) AddedEdges() []string {
  21176. edges := make([]string, 0, 0)
  21177. return edges
  21178. }
  21179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21180. // name in this mutation.
  21181. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21182. return nil
  21183. }
  21184. // RemovedEdges returns all edge names that were removed in this mutation.
  21185. func (m *MsgMutation) RemovedEdges() []string {
  21186. edges := make([]string, 0, 0)
  21187. return edges
  21188. }
  21189. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21190. // the given name in this mutation.
  21191. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21192. return nil
  21193. }
  21194. // ClearedEdges returns all edge names that were cleared in this mutation.
  21195. func (m *MsgMutation) ClearedEdges() []string {
  21196. edges := make([]string, 0, 0)
  21197. return edges
  21198. }
  21199. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21200. // was cleared in this mutation.
  21201. func (m *MsgMutation) EdgeCleared(name string) bool {
  21202. return false
  21203. }
  21204. // ClearEdge clears the value of the edge with the given name. It returns an error
  21205. // if that edge is not defined in the schema.
  21206. func (m *MsgMutation) ClearEdge(name string) error {
  21207. return fmt.Errorf("unknown Msg unique edge %s", name)
  21208. }
  21209. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21210. // It returns an error if the edge is not defined in the schema.
  21211. func (m *MsgMutation) ResetEdge(name string) error {
  21212. return fmt.Errorf("unknown Msg edge %s", name)
  21213. }
  21214. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21215. type PayRechargeMutation struct {
  21216. config
  21217. op Op
  21218. typ string
  21219. id *uint64
  21220. created_at *time.Time
  21221. updated_at *time.Time
  21222. deleted_at *time.Time
  21223. user_id *string
  21224. number *float32
  21225. addnumber *float32
  21226. status *int
  21227. addstatus *int
  21228. money *float32
  21229. addmoney *float32
  21230. out_trade_no *string
  21231. organization_id *uint64
  21232. addorganization_id *int64
  21233. clearedFields map[string]struct{}
  21234. done bool
  21235. oldValue func(context.Context) (*PayRecharge, error)
  21236. predicates []predicate.PayRecharge
  21237. }
  21238. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21239. // payrechargeOption allows management of the mutation configuration using functional options.
  21240. type payrechargeOption func(*PayRechargeMutation)
  21241. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21242. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21243. m := &PayRechargeMutation{
  21244. config: c,
  21245. op: op,
  21246. typ: TypePayRecharge,
  21247. clearedFields: make(map[string]struct{}),
  21248. }
  21249. for _, opt := range opts {
  21250. opt(m)
  21251. }
  21252. return m
  21253. }
  21254. // withPayRechargeID sets the ID field of the mutation.
  21255. func withPayRechargeID(id uint64) payrechargeOption {
  21256. return func(m *PayRechargeMutation) {
  21257. var (
  21258. err error
  21259. once sync.Once
  21260. value *PayRecharge
  21261. )
  21262. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21263. once.Do(func() {
  21264. if m.done {
  21265. err = errors.New("querying old values post mutation is not allowed")
  21266. } else {
  21267. value, err = m.Client().PayRecharge.Get(ctx, id)
  21268. }
  21269. })
  21270. return value, err
  21271. }
  21272. m.id = &id
  21273. }
  21274. }
  21275. // withPayRecharge sets the old PayRecharge of the mutation.
  21276. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21277. return func(m *PayRechargeMutation) {
  21278. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21279. return node, nil
  21280. }
  21281. m.id = &node.ID
  21282. }
  21283. }
  21284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21285. // executed in a transaction (ent.Tx), a transactional client is returned.
  21286. func (m PayRechargeMutation) Client() *Client {
  21287. client := &Client{config: m.config}
  21288. client.init()
  21289. return client
  21290. }
  21291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21292. // it returns an error otherwise.
  21293. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21294. if _, ok := m.driver.(*txDriver); !ok {
  21295. return nil, errors.New("ent: mutation is not running in a transaction")
  21296. }
  21297. tx := &Tx{config: m.config}
  21298. tx.init()
  21299. return tx, nil
  21300. }
  21301. // SetID sets the value of the id field. Note that this
  21302. // operation is only accepted on creation of PayRecharge entities.
  21303. func (m *PayRechargeMutation) SetID(id uint64) {
  21304. m.id = &id
  21305. }
  21306. // ID returns the ID value in the mutation. Note that the ID is only available
  21307. // if it was provided to the builder or after it was returned from the database.
  21308. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21309. if m.id == nil {
  21310. return
  21311. }
  21312. return *m.id, true
  21313. }
  21314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21315. // That means, if the mutation is applied within a transaction with an isolation level such
  21316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21317. // or updated by the mutation.
  21318. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21319. switch {
  21320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21321. id, exists := m.ID()
  21322. if exists {
  21323. return []uint64{id}, nil
  21324. }
  21325. fallthrough
  21326. case m.op.Is(OpUpdate | OpDelete):
  21327. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21328. default:
  21329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21330. }
  21331. }
  21332. // SetCreatedAt sets the "created_at" field.
  21333. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21334. m.created_at = &t
  21335. }
  21336. // CreatedAt returns the value of the "created_at" field in the mutation.
  21337. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21338. v := m.created_at
  21339. if v == nil {
  21340. return
  21341. }
  21342. return *v, true
  21343. }
  21344. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21345. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21347. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21348. if !m.op.Is(OpUpdateOne) {
  21349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21350. }
  21351. if m.id == nil || m.oldValue == nil {
  21352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21353. }
  21354. oldValue, err := m.oldValue(ctx)
  21355. if err != nil {
  21356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21357. }
  21358. return oldValue.CreatedAt, nil
  21359. }
  21360. // ResetCreatedAt resets all changes to the "created_at" field.
  21361. func (m *PayRechargeMutation) ResetCreatedAt() {
  21362. m.created_at = nil
  21363. }
  21364. // SetUpdatedAt sets the "updated_at" field.
  21365. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21366. m.updated_at = &t
  21367. }
  21368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21369. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21370. v := m.updated_at
  21371. if v == nil {
  21372. return
  21373. }
  21374. return *v, true
  21375. }
  21376. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21377. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21379. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21380. if !m.op.Is(OpUpdateOne) {
  21381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21382. }
  21383. if m.id == nil || m.oldValue == nil {
  21384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21385. }
  21386. oldValue, err := m.oldValue(ctx)
  21387. if err != nil {
  21388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21389. }
  21390. return oldValue.UpdatedAt, nil
  21391. }
  21392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21393. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21394. m.updated_at = nil
  21395. }
  21396. // SetDeletedAt sets the "deleted_at" field.
  21397. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21398. m.deleted_at = &t
  21399. }
  21400. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21401. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21402. v := m.deleted_at
  21403. if v == nil {
  21404. return
  21405. }
  21406. return *v, true
  21407. }
  21408. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21409. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21411. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21412. if !m.op.Is(OpUpdateOne) {
  21413. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21414. }
  21415. if m.id == nil || m.oldValue == nil {
  21416. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21417. }
  21418. oldValue, err := m.oldValue(ctx)
  21419. if err != nil {
  21420. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21421. }
  21422. return oldValue.DeletedAt, nil
  21423. }
  21424. // ClearDeletedAt clears the value of the "deleted_at" field.
  21425. func (m *PayRechargeMutation) ClearDeletedAt() {
  21426. m.deleted_at = nil
  21427. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21428. }
  21429. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21430. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21431. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21432. return ok
  21433. }
  21434. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21435. func (m *PayRechargeMutation) ResetDeletedAt() {
  21436. m.deleted_at = nil
  21437. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21438. }
  21439. // SetUserID sets the "user_id" field.
  21440. func (m *PayRechargeMutation) SetUserID(s string) {
  21441. m.user_id = &s
  21442. }
  21443. // UserID returns the value of the "user_id" field in the mutation.
  21444. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21445. v := m.user_id
  21446. if v == nil {
  21447. return
  21448. }
  21449. return *v, true
  21450. }
  21451. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21452. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21454. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21455. if !m.op.Is(OpUpdateOne) {
  21456. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21457. }
  21458. if m.id == nil || m.oldValue == nil {
  21459. return v, errors.New("OldUserID requires an ID field in the mutation")
  21460. }
  21461. oldValue, err := m.oldValue(ctx)
  21462. if err != nil {
  21463. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21464. }
  21465. return oldValue.UserID, nil
  21466. }
  21467. // ResetUserID resets all changes to the "user_id" field.
  21468. func (m *PayRechargeMutation) ResetUserID() {
  21469. m.user_id = nil
  21470. }
  21471. // SetNumber sets the "number" field.
  21472. func (m *PayRechargeMutation) SetNumber(f float32) {
  21473. m.number = &f
  21474. m.addnumber = nil
  21475. }
  21476. // Number returns the value of the "number" field in the mutation.
  21477. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21478. v := m.number
  21479. if v == nil {
  21480. return
  21481. }
  21482. return *v, true
  21483. }
  21484. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21485. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21487. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21488. if !m.op.Is(OpUpdateOne) {
  21489. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21490. }
  21491. if m.id == nil || m.oldValue == nil {
  21492. return v, errors.New("OldNumber requires an ID field in the mutation")
  21493. }
  21494. oldValue, err := m.oldValue(ctx)
  21495. if err != nil {
  21496. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21497. }
  21498. return oldValue.Number, nil
  21499. }
  21500. // AddNumber adds f to the "number" field.
  21501. func (m *PayRechargeMutation) AddNumber(f float32) {
  21502. if m.addnumber != nil {
  21503. *m.addnumber += f
  21504. } else {
  21505. m.addnumber = &f
  21506. }
  21507. }
  21508. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21509. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21510. v := m.addnumber
  21511. if v == nil {
  21512. return
  21513. }
  21514. return *v, true
  21515. }
  21516. // ResetNumber resets all changes to the "number" field.
  21517. func (m *PayRechargeMutation) ResetNumber() {
  21518. m.number = nil
  21519. m.addnumber = nil
  21520. }
  21521. // SetStatus sets the "status" field.
  21522. func (m *PayRechargeMutation) SetStatus(i int) {
  21523. m.status = &i
  21524. m.addstatus = nil
  21525. }
  21526. // Status returns the value of the "status" field in the mutation.
  21527. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21528. v := m.status
  21529. if v == nil {
  21530. return
  21531. }
  21532. return *v, true
  21533. }
  21534. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21535. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21537. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21538. if !m.op.Is(OpUpdateOne) {
  21539. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21540. }
  21541. if m.id == nil || m.oldValue == nil {
  21542. return v, errors.New("OldStatus requires an ID field in the mutation")
  21543. }
  21544. oldValue, err := m.oldValue(ctx)
  21545. if err != nil {
  21546. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21547. }
  21548. return oldValue.Status, nil
  21549. }
  21550. // AddStatus adds i to the "status" field.
  21551. func (m *PayRechargeMutation) AddStatus(i int) {
  21552. if m.addstatus != nil {
  21553. *m.addstatus += i
  21554. } else {
  21555. m.addstatus = &i
  21556. }
  21557. }
  21558. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21559. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21560. v := m.addstatus
  21561. if v == nil {
  21562. return
  21563. }
  21564. return *v, true
  21565. }
  21566. // ClearStatus clears the value of the "status" field.
  21567. func (m *PayRechargeMutation) ClearStatus() {
  21568. m.status = nil
  21569. m.addstatus = nil
  21570. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21571. }
  21572. // StatusCleared returns if the "status" field was cleared in this mutation.
  21573. func (m *PayRechargeMutation) StatusCleared() bool {
  21574. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21575. return ok
  21576. }
  21577. // ResetStatus resets all changes to the "status" field.
  21578. func (m *PayRechargeMutation) ResetStatus() {
  21579. m.status = nil
  21580. m.addstatus = nil
  21581. delete(m.clearedFields, payrecharge.FieldStatus)
  21582. }
  21583. // SetMoney sets the "money" field.
  21584. func (m *PayRechargeMutation) SetMoney(f float32) {
  21585. m.money = &f
  21586. m.addmoney = nil
  21587. }
  21588. // Money returns the value of the "money" field in the mutation.
  21589. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21590. v := m.money
  21591. if v == nil {
  21592. return
  21593. }
  21594. return *v, true
  21595. }
  21596. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21597. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21599. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21600. if !m.op.Is(OpUpdateOne) {
  21601. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21602. }
  21603. if m.id == nil || m.oldValue == nil {
  21604. return v, errors.New("OldMoney requires an ID field in the mutation")
  21605. }
  21606. oldValue, err := m.oldValue(ctx)
  21607. if err != nil {
  21608. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21609. }
  21610. return oldValue.Money, nil
  21611. }
  21612. // AddMoney adds f to the "money" field.
  21613. func (m *PayRechargeMutation) AddMoney(f float32) {
  21614. if m.addmoney != nil {
  21615. *m.addmoney += f
  21616. } else {
  21617. m.addmoney = &f
  21618. }
  21619. }
  21620. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21621. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21622. v := m.addmoney
  21623. if v == nil {
  21624. return
  21625. }
  21626. return *v, true
  21627. }
  21628. // ClearMoney clears the value of the "money" field.
  21629. func (m *PayRechargeMutation) ClearMoney() {
  21630. m.money = nil
  21631. m.addmoney = nil
  21632. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21633. }
  21634. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21635. func (m *PayRechargeMutation) MoneyCleared() bool {
  21636. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21637. return ok
  21638. }
  21639. // ResetMoney resets all changes to the "money" field.
  21640. func (m *PayRechargeMutation) ResetMoney() {
  21641. m.money = nil
  21642. m.addmoney = nil
  21643. delete(m.clearedFields, payrecharge.FieldMoney)
  21644. }
  21645. // SetOutTradeNo sets the "out_trade_no" field.
  21646. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21647. m.out_trade_no = &s
  21648. }
  21649. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21650. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21651. v := m.out_trade_no
  21652. if v == nil {
  21653. return
  21654. }
  21655. return *v, true
  21656. }
  21657. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21658. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21660. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21661. if !m.op.Is(OpUpdateOne) {
  21662. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21663. }
  21664. if m.id == nil || m.oldValue == nil {
  21665. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21666. }
  21667. oldValue, err := m.oldValue(ctx)
  21668. if err != nil {
  21669. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21670. }
  21671. return oldValue.OutTradeNo, nil
  21672. }
  21673. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21674. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21675. m.out_trade_no = nil
  21676. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21677. }
  21678. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21679. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21680. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21681. return ok
  21682. }
  21683. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21684. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21685. m.out_trade_no = nil
  21686. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21687. }
  21688. // SetOrganizationID sets the "organization_id" field.
  21689. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21690. m.organization_id = &u
  21691. m.addorganization_id = nil
  21692. }
  21693. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21694. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21695. v := m.organization_id
  21696. if v == nil {
  21697. return
  21698. }
  21699. return *v, true
  21700. }
  21701. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21702. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21704. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21705. if !m.op.Is(OpUpdateOne) {
  21706. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21707. }
  21708. if m.id == nil || m.oldValue == nil {
  21709. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21710. }
  21711. oldValue, err := m.oldValue(ctx)
  21712. if err != nil {
  21713. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21714. }
  21715. return oldValue.OrganizationID, nil
  21716. }
  21717. // AddOrganizationID adds u to the "organization_id" field.
  21718. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21719. if m.addorganization_id != nil {
  21720. *m.addorganization_id += u
  21721. } else {
  21722. m.addorganization_id = &u
  21723. }
  21724. }
  21725. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21726. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21727. v := m.addorganization_id
  21728. if v == nil {
  21729. return
  21730. }
  21731. return *v, true
  21732. }
  21733. // ResetOrganizationID resets all changes to the "organization_id" field.
  21734. func (m *PayRechargeMutation) ResetOrganizationID() {
  21735. m.organization_id = nil
  21736. m.addorganization_id = nil
  21737. }
  21738. // Where appends a list predicates to the PayRechargeMutation builder.
  21739. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21740. m.predicates = append(m.predicates, ps...)
  21741. }
  21742. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21743. // users can use type-assertion to append predicates that do not depend on any generated package.
  21744. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21745. p := make([]predicate.PayRecharge, len(ps))
  21746. for i := range ps {
  21747. p[i] = ps[i]
  21748. }
  21749. m.Where(p...)
  21750. }
  21751. // Op returns the operation name.
  21752. func (m *PayRechargeMutation) Op() Op {
  21753. return m.op
  21754. }
  21755. // SetOp allows setting the mutation operation.
  21756. func (m *PayRechargeMutation) SetOp(op Op) {
  21757. m.op = op
  21758. }
  21759. // Type returns the node type of this mutation (PayRecharge).
  21760. func (m *PayRechargeMutation) Type() string {
  21761. return m.typ
  21762. }
  21763. // Fields returns all fields that were changed during this mutation. Note that in
  21764. // order to get all numeric fields that were incremented/decremented, call
  21765. // AddedFields().
  21766. func (m *PayRechargeMutation) Fields() []string {
  21767. fields := make([]string, 0, 9)
  21768. if m.created_at != nil {
  21769. fields = append(fields, payrecharge.FieldCreatedAt)
  21770. }
  21771. if m.updated_at != nil {
  21772. fields = append(fields, payrecharge.FieldUpdatedAt)
  21773. }
  21774. if m.deleted_at != nil {
  21775. fields = append(fields, payrecharge.FieldDeletedAt)
  21776. }
  21777. if m.user_id != nil {
  21778. fields = append(fields, payrecharge.FieldUserID)
  21779. }
  21780. if m.number != nil {
  21781. fields = append(fields, payrecharge.FieldNumber)
  21782. }
  21783. if m.status != nil {
  21784. fields = append(fields, payrecharge.FieldStatus)
  21785. }
  21786. if m.money != nil {
  21787. fields = append(fields, payrecharge.FieldMoney)
  21788. }
  21789. if m.out_trade_no != nil {
  21790. fields = append(fields, payrecharge.FieldOutTradeNo)
  21791. }
  21792. if m.organization_id != nil {
  21793. fields = append(fields, payrecharge.FieldOrganizationID)
  21794. }
  21795. return fields
  21796. }
  21797. // Field returns the value of a field with the given name. The second boolean
  21798. // return value indicates that this field was not set, or was not defined in the
  21799. // schema.
  21800. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21801. switch name {
  21802. case payrecharge.FieldCreatedAt:
  21803. return m.CreatedAt()
  21804. case payrecharge.FieldUpdatedAt:
  21805. return m.UpdatedAt()
  21806. case payrecharge.FieldDeletedAt:
  21807. return m.DeletedAt()
  21808. case payrecharge.FieldUserID:
  21809. return m.UserID()
  21810. case payrecharge.FieldNumber:
  21811. return m.Number()
  21812. case payrecharge.FieldStatus:
  21813. return m.Status()
  21814. case payrecharge.FieldMoney:
  21815. return m.Money()
  21816. case payrecharge.FieldOutTradeNo:
  21817. return m.OutTradeNo()
  21818. case payrecharge.FieldOrganizationID:
  21819. return m.OrganizationID()
  21820. }
  21821. return nil, false
  21822. }
  21823. // OldField returns the old value of the field from the database. An error is
  21824. // returned if the mutation operation is not UpdateOne, or the query to the
  21825. // database failed.
  21826. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21827. switch name {
  21828. case payrecharge.FieldCreatedAt:
  21829. return m.OldCreatedAt(ctx)
  21830. case payrecharge.FieldUpdatedAt:
  21831. return m.OldUpdatedAt(ctx)
  21832. case payrecharge.FieldDeletedAt:
  21833. return m.OldDeletedAt(ctx)
  21834. case payrecharge.FieldUserID:
  21835. return m.OldUserID(ctx)
  21836. case payrecharge.FieldNumber:
  21837. return m.OldNumber(ctx)
  21838. case payrecharge.FieldStatus:
  21839. return m.OldStatus(ctx)
  21840. case payrecharge.FieldMoney:
  21841. return m.OldMoney(ctx)
  21842. case payrecharge.FieldOutTradeNo:
  21843. return m.OldOutTradeNo(ctx)
  21844. case payrecharge.FieldOrganizationID:
  21845. return m.OldOrganizationID(ctx)
  21846. }
  21847. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  21848. }
  21849. // SetField sets the value of a field with the given name. It returns an error if
  21850. // the field is not defined in the schema, or if the type mismatched the field
  21851. // type.
  21852. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  21853. switch name {
  21854. case payrecharge.FieldCreatedAt:
  21855. v, ok := value.(time.Time)
  21856. if !ok {
  21857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21858. }
  21859. m.SetCreatedAt(v)
  21860. return nil
  21861. case payrecharge.FieldUpdatedAt:
  21862. v, ok := value.(time.Time)
  21863. if !ok {
  21864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21865. }
  21866. m.SetUpdatedAt(v)
  21867. return nil
  21868. case payrecharge.FieldDeletedAt:
  21869. v, ok := value.(time.Time)
  21870. if !ok {
  21871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21872. }
  21873. m.SetDeletedAt(v)
  21874. return nil
  21875. case payrecharge.FieldUserID:
  21876. v, ok := value.(string)
  21877. if !ok {
  21878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21879. }
  21880. m.SetUserID(v)
  21881. return nil
  21882. case payrecharge.FieldNumber:
  21883. v, ok := value.(float32)
  21884. if !ok {
  21885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21886. }
  21887. m.SetNumber(v)
  21888. return nil
  21889. case payrecharge.FieldStatus:
  21890. v, ok := value.(int)
  21891. if !ok {
  21892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21893. }
  21894. m.SetStatus(v)
  21895. return nil
  21896. case payrecharge.FieldMoney:
  21897. v, ok := value.(float32)
  21898. if !ok {
  21899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21900. }
  21901. m.SetMoney(v)
  21902. return nil
  21903. case payrecharge.FieldOutTradeNo:
  21904. v, ok := value.(string)
  21905. if !ok {
  21906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21907. }
  21908. m.SetOutTradeNo(v)
  21909. return nil
  21910. case payrecharge.FieldOrganizationID:
  21911. v, ok := value.(uint64)
  21912. if !ok {
  21913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21914. }
  21915. m.SetOrganizationID(v)
  21916. return nil
  21917. }
  21918. return fmt.Errorf("unknown PayRecharge field %s", name)
  21919. }
  21920. // AddedFields returns all numeric fields that were incremented/decremented during
  21921. // this mutation.
  21922. func (m *PayRechargeMutation) AddedFields() []string {
  21923. var fields []string
  21924. if m.addnumber != nil {
  21925. fields = append(fields, payrecharge.FieldNumber)
  21926. }
  21927. if m.addstatus != nil {
  21928. fields = append(fields, payrecharge.FieldStatus)
  21929. }
  21930. if m.addmoney != nil {
  21931. fields = append(fields, payrecharge.FieldMoney)
  21932. }
  21933. if m.addorganization_id != nil {
  21934. fields = append(fields, payrecharge.FieldOrganizationID)
  21935. }
  21936. return fields
  21937. }
  21938. // AddedField returns the numeric value that was incremented/decremented on a field
  21939. // with the given name. The second boolean return value indicates that this field
  21940. // was not set, or was not defined in the schema.
  21941. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  21942. switch name {
  21943. case payrecharge.FieldNumber:
  21944. return m.AddedNumber()
  21945. case payrecharge.FieldStatus:
  21946. return m.AddedStatus()
  21947. case payrecharge.FieldMoney:
  21948. return m.AddedMoney()
  21949. case payrecharge.FieldOrganizationID:
  21950. return m.AddedOrganizationID()
  21951. }
  21952. return nil, false
  21953. }
  21954. // AddField adds the value to the field with the given name. It returns an error if
  21955. // the field is not defined in the schema, or if the type mismatched the field
  21956. // type.
  21957. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  21958. switch name {
  21959. case payrecharge.FieldNumber:
  21960. v, ok := value.(float32)
  21961. if !ok {
  21962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21963. }
  21964. m.AddNumber(v)
  21965. return nil
  21966. case payrecharge.FieldStatus:
  21967. v, ok := value.(int)
  21968. if !ok {
  21969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21970. }
  21971. m.AddStatus(v)
  21972. return nil
  21973. case payrecharge.FieldMoney:
  21974. v, ok := value.(float32)
  21975. if !ok {
  21976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21977. }
  21978. m.AddMoney(v)
  21979. return nil
  21980. case payrecharge.FieldOrganizationID:
  21981. v, ok := value.(int64)
  21982. if !ok {
  21983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21984. }
  21985. m.AddOrganizationID(v)
  21986. return nil
  21987. }
  21988. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  21989. }
  21990. // ClearedFields returns all nullable fields that were cleared during this
  21991. // mutation.
  21992. func (m *PayRechargeMutation) ClearedFields() []string {
  21993. var fields []string
  21994. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  21995. fields = append(fields, payrecharge.FieldDeletedAt)
  21996. }
  21997. if m.FieldCleared(payrecharge.FieldStatus) {
  21998. fields = append(fields, payrecharge.FieldStatus)
  21999. }
  22000. if m.FieldCleared(payrecharge.FieldMoney) {
  22001. fields = append(fields, payrecharge.FieldMoney)
  22002. }
  22003. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22004. fields = append(fields, payrecharge.FieldOutTradeNo)
  22005. }
  22006. return fields
  22007. }
  22008. // FieldCleared returns a boolean indicating if a field with the given name was
  22009. // cleared in this mutation.
  22010. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22011. _, ok := m.clearedFields[name]
  22012. return ok
  22013. }
  22014. // ClearField clears the value of the field with the given name. It returns an
  22015. // error if the field is not defined in the schema.
  22016. func (m *PayRechargeMutation) ClearField(name string) error {
  22017. switch name {
  22018. case payrecharge.FieldDeletedAt:
  22019. m.ClearDeletedAt()
  22020. return nil
  22021. case payrecharge.FieldStatus:
  22022. m.ClearStatus()
  22023. return nil
  22024. case payrecharge.FieldMoney:
  22025. m.ClearMoney()
  22026. return nil
  22027. case payrecharge.FieldOutTradeNo:
  22028. m.ClearOutTradeNo()
  22029. return nil
  22030. }
  22031. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22032. }
  22033. // ResetField resets all changes in the mutation for the field with the given name.
  22034. // It returns an error if the field is not defined in the schema.
  22035. func (m *PayRechargeMutation) ResetField(name string) error {
  22036. switch name {
  22037. case payrecharge.FieldCreatedAt:
  22038. m.ResetCreatedAt()
  22039. return nil
  22040. case payrecharge.FieldUpdatedAt:
  22041. m.ResetUpdatedAt()
  22042. return nil
  22043. case payrecharge.FieldDeletedAt:
  22044. m.ResetDeletedAt()
  22045. return nil
  22046. case payrecharge.FieldUserID:
  22047. m.ResetUserID()
  22048. return nil
  22049. case payrecharge.FieldNumber:
  22050. m.ResetNumber()
  22051. return nil
  22052. case payrecharge.FieldStatus:
  22053. m.ResetStatus()
  22054. return nil
  22055. case payrecharge.FieldMoney:
  22056. m.ResetMoney()
  22057. return nil
  22058. case payrecharge.FieldOutTradeNo:
  22059. m.ResetOutTradeNo()
  22060. return nil
  22061. case payrecharge.FieldOrganizationID:
  22062. m.ResetOrganizationID()
  22063. return nil
  22064. }
  22065. return fmt.Errorf("unknown PayRecharge field %s", name)
  22066. }
  22067. // AddedEdges returns all edge names that were set/added in this mutation.
  22068. func (m *PayRechargeMutation) AddedEdges() []string {
  22069. edges := make([]string, 0, 0)
  22070. return edges
  22071. }
  22072. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22073. // name in this mutation.
  22074. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22075. return nil
  22076. }
  22077. // RemovedEdges returns all edge names that were removed in this mutation.
  22078. func (m *PayRechargeMutation) RemovedEdges() []string {
  22079. edges := make([]string, 0, 0)
  22080. return edges
  22081. }
  22082. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22083. // the given name in this mutation.
  22084. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22085. return nil
  22086. }
  22087. // ClearedEdges returns all edge names that were cleared in this mutation.
  22088. func (m *PayRechargeMutation) ClearedEdges() []string {
  22089. edges := make([]string, 0, 0)
  22090. return edges
  22091. }
  22092. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22093. // was cleared in this mutation.
  22094. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22095. return false
  22096. }
  22097. // ClearEdge clears the value of the edge with the given name. It returns an error
  22098. // if that edge is not defined in the schema.
  22099. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22100. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22101. }
  22102. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22103. // It returns an error if the edge is not defined in the schema.
  22104. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22105. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22106. }
  22107. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22108. type ServerMutation struct {
  22109. config
  22110. op Op
  22111. typ string
  22112. id *uint64
  22113. created_at *time.Time
  22114. updated_at *time.Time
  22115. status *uint8
  22116. addstatus *int8
  22117. deleted_at *time.Time
  22118. name *string
  22119. public_ip *string
  22120. private_ip *string
  22121. admin_port *string
  22122. clearedFields map[string]struct{}
  22123. wxs map[uint64]struct{}
  22124. removedwxs map[uint64]struct{}
  22125. clearedwxs bool
  22126. done bool
  22127. oldValue func(context.Context) (*Server, error)
  22128. predicates []predicate.Server
  22129. }
  22130. var _ ent.Mutation = (*ServerMutation)(nil)
  22131. // serverOption allows management of the mutation configuration using functional options.
  22132. type serverOption func(*ServerMutation)
  22133. // newServerMutation creates new mutation for the Server entity.
  22134. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22135. m := &ServerMutation{
  22136. config: c,
  22137. op: op,
  22138. typ: TypeServer,
  22139. clearedFields: make(map[string]struct{}),
  22140. }
  22141. for _, opt := range opts {
  22142. opt(m)
  22143. }
  22144. return m
  22145. }
  22146. // withServerID sets the ID field of the mutation.
  22147. func withServerID(id uint64) serverOption {
  22148. return func(m *ServerMutation) {
  22149. var (
  22150. err error
  22151. once sync.Once
  22152. value *Server
  22153. )
  22154. m.oldValue = func(ctx context.Context) (*Server, error) {
  22155. once.Do(func() {
  22156. if m.done {
  22157. err = errors.New("querying old values post mutation is not allowed")
  22158. } else {
  22159. value, err = m.Client().Server.Get(ctx, id)
  22160. }
  22161. })
  22162. return value, err
  22163. }
  22164. m.id = &id
  22165. }
  22166. }
  22167. // withServer sets the old Server of the mutation.
  22168. func withServer(node *Server) serverOption {
  22169. return func(m *ServerMutation) {
  22170. m.oldValue = func(context.Context) (*Server, error) {
  22171. return node, nil
  22172. }
  22173. m.id = &node.ID
  22174. }
  22175. }
  22176. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22177. // executed in a transaction (ent.Tx), a transactional client is returned.
  22178. func (m ServerMutation) Client() *Client {
  22179. client := &Client{config: m.config}
  22180. client.init()
  22181. return client
  22182. }
  22183. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22184. // it returns an error otherwise.
  22185. func (m ServerMutation) Tx() (*Tx, error) {
  22186. if _, ok := m.driver.(*txDriver); !ok {
  22187. return nil, errors.New("ent: mutation is not running in a transaction")
  22188. }
  22189. tx := &Tx{config: m.config}
  22190. tx.init()
  22191. return tx, nil
  22192. }
  22193. // SetID sets the value of the id field. Note that this
  22194. // operation is only accepted on creation of Server entities.
  22195. func (m *ServerMutation) SetID(id uint64) {
  22196. m.id = &id
  22197. }
  22198. // ID returns the ID value in the mutation. Note that the ID is only available
  22199. // if it was provided to the builder or after it was returned from the database.
  22200. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22201. if m.id == nil {
  22202. return
  22203. }
  22204. return *m.id, true
  22205. }
  22206. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22207. // That means, if the mutation is applied within a transaction with an isolation level such
  22208. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22209. // or updated by the mutation.
  22210. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22211. switch {
  22212. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22213. id, exists := m.ID()
  22214. if exists {
  22215. return []uint64{id}, nil
  22216. }
  22217. fallthrough
  22218. case m.op.Is(OpUpdate | OpDelete):
  22219. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22220. default:
  22221. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22222. }
  22223. }
  22224. // SetCreatedAt sets the "created_at" field.
  22225. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22226. m.created_at = &t
  22227. }
  22228. // CreatedAt returns the value of the "created_at" field in the mutation.
  22229. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22230. v := m.created_at
  22231. if v == nil {
  22232. return
  22233. }
  22234. return *v, true
  22235. }
  22236. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22237. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22239. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22240. if !m.op.Is(OpUpdateOne) {
  22241. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22242. }
  22243. if m.id == nil || m.oldValue == nil {
  22244. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22245. }
  22246. oldValue, err := m.oldValue(ctx)
  22247. if err != nil {
  22248. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22249. }
  22250. return oldValue.CreatedAt, nil
  22251. }
  22252. // ResetCreatedAt resets all changes to the "created_at" field.
  22253. func (m *ServerMutation) ResetCreatedAt() {
  22254. m.created_at = nil
  22255. }
  22256. // SetUpdatedAt sets the "updated_at" field.
  22257. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22258. m.updated_at = &t
  22259. }
  22260. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22261. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22262. v := m.updated_at
  22263. if v == nil {
  22264. return
  22265. }
  22266. return *v, true
  22267. }
  22268. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22269. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22271. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22272. if !m.op.Is(OpUpdateOne) {
  22273. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22274. }
  22275. if m.id == nil || m.oldValue == nil {
  22276. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22277. }
  22278. oldValue, err := m.oldValue(ctx)
  22279. if err != nil {
  22280. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22281. }
  22282. return oldValue.UpdatedAt, nil
  22283. }
  22284. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22285. func (m *ServerMutation) ResetUpdatedAt() {
  22286. m.updated_at = nil
  22287. }
  22288. // SetStatus sets the "status" field.
  22289. func (m *ServerMutation) SetStatus(u uint8) {
  22290. m.status = &u
  22291. m.addstatus = nil
  22292. }
  22293. // Status returns the value of the "status" field in the mutation.
  22294. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22295. v := m.status
  22296. if v == nil {
  22297. return
  22298. }
  22299. return *v, true
  22300. }
  22301. // OldStatus returns the old "status" field's value of the Server entity.
  22302. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22304. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22305. if !m.op.Is(OpUpdateOne) {
  22306. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22307. }
  22308. if m.id == nil || m.oldValue == nil {
  22309. return v, errors.New("OldStatus requires an ID field in the mutation")
  22310. }
  22311. oldValue, err := m.oldValue(ctx)
  22312. if err != nil {
  22313. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22314. }
  22315. return oldValue.Status, nil
  22316. }
  22317. // AddStatus adds u to the "status" field.
  22318. func (m *ServerMutation) AddStatus(u int8) {
  22319. if m.addstatus != nil {
  22320. *m.addstatus += u
  22321. } else {
  22322. m.addstatus = &u
  22323. }
  22324. }
  22325. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22326. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22327. v := m.addstatus
  22328. if v == nil {
  22329. return
  22330. }
  22331. return *v, true
  22332. }
  22333. // ClearStatus clears the value of the "status" field.
  22334. func (m *ServerMutation) ClearStatus() {
  22335. m.status = nil
  22336. m.addstatus = nil
  22337. m.clearedFields[server.FieldStatus] = struct{}{}
  22338. }
  22339. // StatusCleared returns if the "status" field was cleared in this mutation.
  22340. func (m *ServerMutation) StatusCleared() bool {
  22341. _, ok := m.clearedFields[server.FieldStatus]
  22342. return ok
  22343. }
  22344. // ResetStatus resets all changes to the "status" field.
  22345. func (m *ServerMutation) ResetStatus() {
  22346. m.status = nil
  22347. m.addstatus = nil
  22348. delete(m.clearedFields, server.FieldStatus)
  22349. }
  22350. // SetDeletedAt sets the "deleted_at" field.
  22351. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22352. m.deleted_at = &t
  22353. }
  22354. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22355. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22356. v := m.deleted_at
  22357. if v == nil {
  22358. return
  22359. }
  22360. return *v, true
  22361. }
  22362. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22363. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22365. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22366. if !m.op.Is(OpUpdateOne) {
  22367. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22368. }
  22369. if m.id == nil || m.oldValue == nil {
  22370. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22371. }
  22372. oldValue, err := m.oldValue(ctx)
  22373. if err != nil {
  22374. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22375. }
  22376. return oldValue.DeletedAt, nil
  22377. }
  22378. // ClearDeletedAt clears the value of the "deleted_at" field.
  22379. func (m *ServerMutation) ClearDeletedAt() {
  22380. m.deleted_at = nil
  22381. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22382. }
  22383. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22384. func (m *ServerMutation) DeletedAtCleared() bool {
  22385. _, ok := m.clearedFields[server.FieldDeletedAt]
  22386. return ok
  22387. }
  22388. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22389. func (m *ServerMutation) ResetDeletedAt() {
  22390. m.deleted_at = nil
  22391. delete(m.clearedFields, server.FieldDeletedAt)
  22392. }
  22393. // SetName sets the "name" field.
  22394. func (m *ServerMutation) SetName(s string) {
  22395. m.name = &s
  22396. }
  22397. // Name returns the value of the "name" field in the mutation.
  22398. func (m *ServerMutation) Name() (r string, exists bool) {
  22399. v := m.name
  22400. if v == nil {
  22401. return
  22402. }
  22403. return *v, true
  22404. }
  22405. // OldName returns the old "name" field's value of the Server entity.
  22406. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22408. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22409. if !m.op.Is(OpUpdateOne) {
  22410. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22411. }
  22412. if m.id == nil || m.oldValue == nil {
  22413. return v, errors.New("OldName requires an ID field in the mutation")
  22414. }
  22415. oldValue, err := m.oldValue(ctx)
  22416. if err != nil {
  22417. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22418. }
  22419. return oldValue.Name, nil
  22420. }
  22421. // ResetName resets all changes to the "name" field.
  22422. func (m *ServerMutation) ResetName() {
  22423. m.name = nil
  22424. }
  22425. // SetPublicIP sets the "public_ip" field.
  22426. func (m *ServerMutation) SetPublicIP(s string) {
  22427. m.public_ip = &s
  22428. }
  22429. // PublicIP returns the value of the "public_ip" field in the mutation.
  22430. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22431. v := m.public_ip
  22432. if v == nil {
  22433. return
  22434. }
  22435. return *v, true
  22436. }
  22437. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22438. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22440. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22441. if !m.op.Is(OpUpdateOne) {
  22442. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22443. }
  22444. if m.id == nil || m.oldValue == nil {
  22445. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22446. }
  22447. oldValue, err := m.oldValue(ctx)
  22448. if err != nil {
  22449. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22450. }
  22451. return oldValue.PublicIP, nil
  22452. }
  22453. // ResetPublicIP resets all changes to the "public_ip" field.
  22454. func (m *ServerMutation) ResetPublicIP() {
  22455. m.public_ip = nil
  22456. }
  22457. // SetPrivateIP sets the "private_ip" field.
  22458. func (m *ServerMutation) SetPrivateIP(s string) {
  22459. m.private_ip = &s
  22460. }
  22461. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22462. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22463. v := m.private_ip
  22464. if v == nil {
  22465. return
  22466. }
  22467. return *v, true
  22468. }
  22469. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22470. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22472. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22473. if !m.op.Is(OpUpdateOne) {
  22474. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22475. }
  22476. if m.id == nil || m.oldValue == nil {
  22477. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22478. }
  22479. oldValue, err := m.oldValue(ctx)
  22480. if err != nil {
  22481. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22482. }
  22483. return oldValue.PrivateIP, nil
  22484. }
  22485. // ResetPrivateIP resets all changes to the "private_ip" field.
  22486. func (m *ServerMutation) ResetPrivateIP() {
  22487. m.private_ip = nil
  22488. }
  22489. // SetAdminPort sets the "admin_port" field.
  22490. func (m *ServerMutation) SetAdminPort(s string) {
  22491. m.admin_port = &s
  22492. }
  22493. // AdminPort returns the value of the "admin_port" field in the mutation.
  22494. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22495. v := m.admin_port
  22496. if v == nil {
  22497. return
  22498. }
  22499. return *v, true
  22500. }
  22501. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22502. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22504. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22505. if !m.op.Is(OpUpdateOne) {
  22506. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22507. }
  22508. if m.id == nil || m.oldValue == nil {
  22509. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22510. }
  22511. oldValue, err := m.oldValue(ctx)
  22512. if err != nil {
  22513. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22514. }
  22515. return oldValue.AdminPort, nil
  22516. }
  22517. // ResetAdminPort resets all changes to the "admin_port" field.
  22518. func (m *ServerMutation) ResetAdminPort() {
  22519. m.admin_port = nil
  22520. }
  22521. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22522. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22523. if m.wxs == nil {
  22524. m.wxs = make(map[uint64]struct{})
  22525. }
  22526. for i := range ids {
  22527. m.wxs[ids[i]] = struct{}{}
  22528. }
  22529. }
  22530. // ClearWxs clears the "wxs" edge to the Wx entity.
  22531. func (m *ServerMutation) ClearWxs() {
  22532. m.clearedwxs = true
  22533. }
  22534. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22535. func (m *ServerMutation) WxsCleared() bool {
  22536. return m.clearedwxs
  22537. }
  22538. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22539. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22540. if m.removedwxs == nil {
  22541. m.removedwxs = make(map[uint64]struct{})
  22542. }
  22543. for i := range ids {
  22544. delete(m.wxs, ids[i])
  22545. m.removedwxs[ids[i]] = struct{}{}
  22546. }
  22547. }
  22548. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22549. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22550. for id := range m.removedwxs {
  22551. ids = append(ids, id)
  22552. }
  22553. return
  22554. }
  22555. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22556. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22557. for id := range m.wxs {
  22558. ids = append(ids, id)
  22559. }
  22560. return
  22561. }
  22562. // ResetWxs resets all changes to the "wxs" edge.
  22563. func (m *ServerMutation) ResetWxs() {
  22564. m.wxs = nil
  22565. m.clearedwxs = false
  22566. m.removedwxs = nil
  22567. }
  22568. // Where appends a list predicates to the ServerMutation builder.
  22569. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22570. m.predicates = append(m.predicates, ps...)
  22571. }
  22572. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22573. // users can use type-assertion to append predicates that do not depend on any generated package.
  22574. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22575. p := make([]predicate.Server, len(ps))
  22576. for i := range ps {
  22577. p[i] = ps[i]
  22578. }
  22579. m.Where(p...)
  22580. }
  22581. // Op returns the operation name.
  22582. func (m *ServerMutation) Op() Op {
  22583. return m.op
  22584. }
  22585. // SetOp allows setting the mutation operation.
  22586. func (m *ServerMutation) SetOp(op Op) {
  22587. m.op = op
  22588. }
  22589. // Type returns the node type of this mutation (Server).
  22590. func (m *ServerMutation) Type() string {
  22591. return m.typ
  22592. }
  22593. // Fields returns all fields that were changed during this mutation. Note that in
  22594. // order to get all numeric fields that were incremented/decremented, call
  22595. // AddedFields().
  22596. func (m *ServerMutation) Fields() []string {
  22597. fields := make([]string, 0, 8)
  22598. if m.created_at != nil {
  22599. fields = append(fields, server.FieldCreatedAt)
  22600. }
  22601. if m.updated_at != nil {
  22602. fields = append(fields, server.FieldUpdatedAt)
  22603. }
  22604. if m.status != nil {
  22605. fields = append(fields, server.FieldStatus)
  22606. }
  22607. if m.deleted_at != nil {
  22608. fields = append(fields, server.FieldDeletedAt)
  22609. }
  22610. if m.name != nil {
  22611. fields = append(fields, server.FieldName)
  22612. }
  22613. if m.public_ip != nil {
  22614. fields = append(fields, server.FieldPublicIP)
  22615. }
  22616. if m.private_ip != nil {
  22617. fields = append(fields, server.FieldPrivateIP)
  22618. }
  22619. if m.admin_port != nil {
  22620. fields = append(fields, server.FieldAdminPort)
  22621. }
  22622. return fields
  22623. }
  22624. // Field returns the value of a field with the given name. The second boolean
  22625. // return value indicates that this field was not set, or was not defined in the
  22626. // schema.
  22627. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22628. switch name {
  22629. case server.FieldCreatedAt:
  22630. return m.CreatedAt()
  22631. case server.FieldUpdatedAt:
  22632. return m.UpdatedAt()
  22633. case server.FieldStatus:
  22634. return m.Status()
  22635. case server.FieldDeletedAt:
  22636. return m.DeletedAt()
  22637. case server.FieldName:
  22638. return m.Name()
  22639. case server.FieldPublicIP:
  22640. return m.PublicIP()
  22641. case server.FieldPrivateIP:
  22642. return m.PrivateIP()
  22643. case server.FieldAdminPort:
  22644. return m.AdminPort()
  22645. }
  22646. return nil, false
  22647. }
  22648. // OldField returns the old value of the field from the database. An error is
  22649. // returned if the mutation operation is not UpdateOne, or the query to the
  22650. // database failed.
  22651. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22652. switch name {
  22653. case server.FieldCreatedAt:
  22654. return m.OldCreatedAt(ctx)
  22655. case server.FieldUpdatedAt:
  22656. return m.OldUpdatedAt(ctx)
  22657. case server.FieldStatus:
  22658. return m.OldStatus(ctx)
  22659. case server.FieldDeletedAt:
  22660. return m.OldDeletedAt(ctx)
  22661. case server.FieldName:
  22662. return m.OldName(ctx)
  22663. case server.FieldPublicIP:
  22664. return m.OldPublicIP(ctx)
  22665. case server.FieldPrivateIP:
  22666. return m.OldPrivateIP(ctx)
  22667. case server.FieldAdminPort:
  22668. return m.OldAdminPort(ctx)
  22669. }
  22670. return nil, fmt.Errorf("unknown Server field %s", name)
  22671. }
  22672. // SetField sets the value of a field with the given name. It returns an error if
  22673. // the field is not defined in the schema, or if the type mismatched the field
  22674. // type.
  22675. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22676. switch name {
  22677. case server.FieldCreatedAt:
  22678. v, ok := value.(time.Time)
  22679. if !ok {
  22680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22681. }
  22682. m.SetCreatedAt(v)
  22683. return nil
  22684. case server.FieldUpdatedAt:
  22685. v, ok := value.(time.Time)
  22686. if !ok {
  22687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22688. }
  22689. m.SetUpdatedAt(v)
  22690. return nil
  22691. case server.FieldStatus:
  22692. v, ok := value.(uint8)
  22693. if !ok {
  22694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22695. }
  22696. m.SetStatus(v)
  22697. return nil
  22698. case server.FieldDeletedAt:
  22699. v, ok := value.(time.Time)
  22700. if !ok {
  22701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22702. }
  22703. m.SetDeletedAt(v)
  22704. return nil
  22705. case server.FieldName:
  22706. v, ok := value.(string)
  22707. if !ok {
  22708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22709. }
  22710. m.SetName(v)
  22711. return nil
  22712. case server.FieldPublicIP:
  22713. v, ok := value.(string)
  22714. if !ok {
  22715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22716. }
  22717. m.SetPublicIP(v)
  22718. return nil
  22719. case server.FieldPrivateIP:
  22720. v, ok := value.(string)
  22721. if !ok {
  22722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22723. }
  22724. m.SetPrivateIP(v)
  22725. return nil
  22726. case server.FieldAdminPort:
  22727. v, ok := value.(string)
  22728. if !ok {
  22729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22730. }
  22731. m.SetAdminPort(v)
  22732. return nil
  22733. }
  22734. return fmt.Errorf("unknown Server field %s", name)
  22735. }
  22736. // AddedFields returns all numeric fields that were incremented/decremented during
  22737. // this mutation.
  22738. func (m *ServerMutation) AddedFields() []string {
  22739. var fields []string
  22740. if m.addstatus != nil {
  22741. fields = append(fields, server.FieldStatus)
  22742. }
  22743. return fields
  22744. }
  22745. // AddedField returns the numeric value that was incremented/decremented on a field
  22746. // with the given name. The second boolean return value indicates that this field
  22747. // was not set, or was not defined in the schema.
  22748. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22749. switch name {
  22750. case server.FieldStatus:
  22751. return m.AddedStatus()
  22752. }
  22753. return nil, false
  22754. }
  22755. // AddField adds the value to the field with the given name. It returns an error if
  22756. // the field is not defined in the schema, or if the type mismatched the field
  22757. // type.
  22758. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22759. switch name {
  22760. case server.FieldStatus:
  22761. v, ok := value.(int8)
  22762. if !ok {
  22763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22764. }
  22765. m.AddStatus(v)
  22766. return nil
  22767. }
  22768. return fmt.Errorf("unknown Server numeric field %s", name)
  22769. }
  22770. // ClearedFields returns all nullable fields that were cleared during this
  22771. // mutation.
  22772. func (m *ServerMutation) ClearedFields() []string {
  22773. var fields []string
  22774. if m.FieldCleared(server.FieldStatus) {
  22775. fields = append(fields, server.FieldStatus)
  22776. }
  22777. if m.FieldCleared(server.FieldDeletedAt) {
  22778. fields = append(fields, server.FieldDeletedAt)
  22779. }
  22780. return fields
  22781. }
  22782. // FieldCleared returns a boolean indicating if a field with the given name was
  22783. // cleared in this mutation.
  22784. func (m *ServerMutation) FieldCleared(name string) bool {
  22785. _, ok := m.clearedFields[name]
  22786. return ok
  22787. }
  22788. // ClearField clears the value of the field with the given name. It returns an
  22789. // error if the field is not defined in the schema.
  22790. func (m *ServerMutation) ClearField(name string) error {
  22791. switch name {
  22792. case server.FieldStatus:
  22793. m.ClearStatus()
  22794. return nil
  22795. case server.FieldDeletedAt:
  22796. m.ClearDeletedAt()
  22797. return nil
  22798. }
  22799. return fmt.Errorf("unknown Server nullable field %s", name)
  22800. }
  22801. // ResetField resets all changes in the mutation for the field with the given name.
  22802. // It returns an error if the field is not defined in the schema.
  22803. func (m *ServerMutation) ResetField(name string) error {
  22804. switch name {
  22805. case server.FieldCreatedAt:
  22806. m.ResetCreatedAt()
  22807. return nil
  22808. case server.FieldUpdatedAt:
  22809. m.ResetUpdatedAt()
  22810. return nil
  22811. case server.FieldStatus:
  22812. m.ResetStatus()
  22813. return nil
  22814. case server.FieldDeletedAt:
  22815. m.ResetDeletedAt()
  22816. return nil
  22817. case server.FieldName:
  22818. m.ResetName()
  22819. return nil
  22820. case server.FieldPublicIP:
  22821. m.ResetPublicIP()
  22822. return nil
  22823. case server.FieldPrivateIP:
  22824. m.ResetPrivateIP()
  22825. return nil
  22826. case server.FieldAdminPort:
  22827. m.ResetAdminPort()
  22828. return nil
  22829. }
  22830. return fmt.Errorf("unknown Server field %s", name)
  22831. }
  22832. // AddedEdges returns all edge names that were set/added in this mutation.
  22833. func (m *ServerMutation) AddedEdges() []string {
  22834. edges := make([]string, 0, 1)
  22835. if m.wxs != nil {
  22836. edges = append(edges, server.EdgeWxs)
  22837. }
  22838. return edges
  22839. }
  22840. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22841. // name in this mutation.
  22842. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22843. switch name {
  22844. case server.EdgeWxs:
  22845. ids := make([]ent.Value, 0, len(m.wxs))
  22846. for id := range m.wxs {
  22847. ids = append(ids, id)
  22848. }
  22849. return ids
  22850. }
  22851. return nil
  22852. }
  22853. // RemovedEdges returns all edge names that were removed in this mutation.
  22854. func (m *ServerMutation) RemovedEdges() []string {
  22855. edges := make([]string, 0, 1)
  22856. if m.removedwxs != nil {
  22857. edges = append(edges, server.EdgeWxs)
  22858. }
  22859. return edges
  22860. }
  22861. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22862. // the given name in this mutation.
  22863. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  22864. switch name {
  22865. case server.EdgeWxs:
  22866. ids := make([]ent.Value, 0, len(m.removedwxs))
  22867. for id := range m.removedwxs {
  22868. ids = append(ids, id)
  22869. }
  22870. return ids
  22871. }
  22872. return nil
  22873. }
  22874. // ClearedEdges returns all edge names that were cleared in this mutation.
  22875. func (m *ServerMutation) ClearedEdges() []string {
  22876. edges := make([]string, 0, 1)
  22877. if m.clearedwxs {
  22878. edges = append(edges, server.EdgeWxs)
  22879. }
  22880. return edges
  22881. }
  22882. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22883. // was cleared in this mutation.
  22884. func (m *ServerMutation) EdgeCleared(name string) bool {
  22885. switch name {
  22886. case server.EdgeWxs:
  22887. return m.clearedwxs
  22888. }
  22889. return false
  22890. }
  22891. // ClearEdge clears the value of the edge with the given name. It returns an error
  22892. // if that edge is not defined in the schema.
  22893. func (m *ServerMutation) ClearEdge(name string) error {
  22894. switch name {
  22895. }
  22896. return fmt.Errorf("unknown Server unique edge %s", name)
  22897. }
  22898. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22899. // It returns an error if the edge is not defined in the schema.
  22900. func (m *ServerMutation) ResetEdge(name string) error {
  22901. switch name {
  22902. case server.EdgeWxs:
  22903. m.ResetWxs()
  22904. return nil
  22905. }
  22906. return fmt.Errorf("unknown Server edge %s", name)
  22907. }
  22908. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22909. type SopNodeMutation struct {
  22910. config
  22911. op Op
  22912. typ string
  22913. id *uint64
  22914. created_at *time.Time
  22915. updated_at *time.Time
  22916. status *uint8
  22917. addstatus *int8
  22918. deleted_at *time.Time
  22919. parent_id *uint64
  22920. addparent_id *int64
  22921. name *string
  22922. condition_type *int
  22923. addcondition_type *int
  22924. condition_list *[]string
  22925. appendcondition_list []string
  22926. no_reply_condition *uint64
  22927. addno_reply_condition *int64
  22928. no_reply_unit *string
  22929. action_message *[]custom_types.Action
  22930. appendaction_message []custom_types.Action
  22931. action_label_add *[]uint64
  22932. appendaction_label_add []uint64
  22933. action_label_del *[]uint64
  22934. appendaction_label_del []uint64
  22935. action_forward **custom_types.ActionForward
  22936. clearedFields map[string]struct{}
  22937. sop_stage *uint64
  22938. clearedsop_stage bool
  22939. node_messages map[uint64]struct{}
  22940. removednode_messages map[uint64]struct{}
  22941. clearednode_messages bool
  22942. done bool
  22943. oldValue func(context.Context) (*SopNode, error)
  22944. predicates []predicate.SopNode
  22945. }
  22946. var _ ent.Mutation = (*SopNodeMutation)(nil)
  22947. // sopnodeOption allows management of the mutation configuration using functional options.
  22948. type sopnodeOption func(*SopNodeMutation)
  22949. // newSopNodeMutation creates new mutation for the SopNode entity.
  22950. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  22951. m := &SopNodeMutation{
  22952. config: c,
  22953. op: op,
  22954. typ: TypeSopNode,
  22955. clearedFields: make(map[string]struct{}),
  22956. }
  22957. for _, opt := range opts {
  22958. opt(m)
  22959. }
  22960. return m
  22961. }
  22962. // withSopNodeID sets the ID field of the mutation.
  22963. func withSopNodeID(id uint64) sopnodeOption {
  22964. return func(m *SopNodeMutation) {
  22965. var (
  22966. err error
  22967. once sync.Once
  22968. value *SopNode
  22969. )
  22970. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  22971. once.Do(func() {
  22972. if m.done {
  22973. err = errors.New("querying old values post mutation is not allowed")
  22974. } else {
  22975. value, err = m.Client().SopNode.Get(ctx, id)
  22976. }
  22977. })
  22978. return value, err
  22979. }
  22980. m.id = &id
  22981. }
  22982. }
  22983. // withSopNode sets the old SopNode of the mutation.
  22984. func withSopNode(node *SopNode) sopnodeOption {
  22985. return func(m *SopNodeMutation) {
  22986. m.oldValue = func(context.Context) (*SopNode, error) {
  22987. return node, nil
  22988. }
  22989. m.id = &node.ID
  22990. }
  22991. }
  22992. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22993. // executed in a transaction (ent.Tx), a transactional client is returned.
  22994. func (m SopNodeMutation) Client() *Client {
  22995. client := &Client{config: m.config}
  22996. client.init()
  22997. return client
  22998. }
  22999. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23000. // it returns an error otherwise.
  23001. func (m SopNodeMutation) Tx() (*Tx, error) {
  23002. if _, ok := m.driver.(*txDriver); !ok {
  23003. return nil, errors.New("ent: mutation is not running in a transaction")
  23004. }
  23005. tx := &Tx{config: m.config}
  23006. tx.init()
  23007. return tx, nil
  23008. }
  23009. // SetID sets the value of the id field. Note that this
  23010. // operation is only accepted on creation of SopNode entities.
  23011. func (m *SopNodeMutation) SetID(id uint64) {
  23012. m.id = &id
  23013. }
  23014. // ID returns the ID value in the mutation. Note that the ID is only available
  23015. // if it was provided to the builder or after it was returned from the database.
  23016. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23017. if m.id == nil {
  23018. return
  23019. }
  23020. return *m.id, true
  23021. }
  23022. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23023. // That means, if the mutation is applied within a transaction with an isolation level such
  23024. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23025. // or updated by the mutation.
  23026. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23027. switch {
  23028. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23029. id, exists := m.ID()
  23030. if exists {
  23031. return []uint64{id}, nil
  23032. }
  23033. fallthrough
  23034. case m.op.Is(OpUpdate | OpDelete):
  23035. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23036. default:
  23037. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23038. }
  23039. }
  23040. // SetCreatedAt sets the "created_at" field.
  23041. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23042. m.created_at = &t
  23043. }
  23044. // CreatedAt returns the value of the "created_at" field in the mutation.
  23045. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23046. v := m.created_at
  23047. if v == nil {
  23048. return
  23049. }
  23050. return *v, true
  23051. }
  23052. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23053. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23055. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23056. if !m.op.Is(OpUpdateOne) {
  23057. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23058. }
  23059. if m.id == nil || m.oldValue == nil {
  23060. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23061. }
  23062. oldValue, err := m.oldValue(ctx)
  23063. if err != nil {
  23064. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23065. }
  23066. return oldValue.CreatedAt, nil
  23067. }
  23068. // ResetCreatedAt resets all changes to the "created_at" field.
  23069. func (m *SopNodeMutation) ResetCreatedAt() {
  23070. m.created_at = nil
  23071. }
  23072. // SetUpdatedAt sets the "updated_at" field.
  23073. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23074. m.updated_at = &t
  23075. }
  23076. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23077. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23078. v := m.updated_at
  23079. if v == nil {
  23080. return
  23081. }
  23082. return *v, true
  23083. }
  23084. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23085. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23087. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23088. if !m.op.Is(OpUpdateOne) {
  23089. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23090. }
  23091. if m.id == nil || m.oldValue == nil {
  23092. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23093. }
  23094. oldValue, err := m.oldValue(ctx)
  23095. if err != nil {
  23096. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23097. }
  23098. return oldValue.UpdatedAt, nil
  23099. }
  23100. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23101. func (m *SopNodeMutation) ResetUpdatedAt() {
  23102. m.updated_at = nil
  23103. }
  23104. // SetStatus sets the "status" field.
  23105. func (m *SopNodeMutation) SetStatus(u uint8) {
  23106. m.status = &u
  23107. m.addstatus = nil
  23108. }
  23109. // Status returns the value of the "status" field in the mutation.
  23110. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23111. v := m.status
  23112. if v == nil {
  23113. return
  23114. }
  23115. return *v, true
  23116. }
  23117. // OldStatus returns the old "status" field's value of the SopNode entity.
  23118. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23120. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23121. if !m.op.Is(OpUpdateOne) {
  23122. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23123. }
  23124. if m.id == nil || m.oldValue == nil {
  23125. return v, errors.New("OldStatus requires an ID field in the mutation")
  23126. }
  23127. oldValue, err := m.oldValue(ctx)
  23128. if err != nil {
  23129. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23130. }
  23131. return oldValue.Status, nil
  23132. }
  23133. // AddStatus adds u to the "status" field.
  23134. func (m *SopNodeMutation) AddStatus(u int8) {
  23135. if m.addstatus != nil {
  23136. *m.addstatus += u
  23137. } else {
  23138. m.addstatus = &u
  23139. }
  23140. }
  23141. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23142. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23143. v := m.addstatus
  23144. if v == nil {
  23145. return
  23146. }
  23147. return *v, true
  23148. }
  23149. // ClearStatus clears the value of the "status" field.
  23150. func (m *SopNodeMutation) ClearStatus() {
  23151. m.status = nil
  23152. m.addstatus = nil
  23153. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23154. }
  23155. // StatusCleared returns if the "status" field was cleared in this mutation.
  23156. func (m *SopNodeMutation) StatusCleared() bool {
  23157. _, ok := m.clearedFields[sopnode.FieldStatus]
  23158. return ok
  23159. }
  23160. // ResetStatus resets all changes to the "status" field.
  23161. func (m *SopNodeMutation) ResetStatus() {
  23162. m.status = nil
  23163. m.addstatus = nil
  23164. delete(m.clearedFields, sopnode.FieldStatus)
  23165. }
  23166. // SetDeletedAt sets the "deleted_at" field.
  23167. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23168. m.deleted_at = &t
  23169. }
  23170. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23171. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23172. v := m.deleted_at
  23173. if v == nil {
  23174. return
  23175. }
  23176. return *v, true
  23177. }
  23178. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23179. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23181. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23182. if !m.op.Is(OpUpdateOne) {
  23183. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23184. }
  23185. if m.id == nil || m.oldValue == nil {
  23186. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23187. }
  23188. oldValue, err := m.oldValue(ctx)
  23189. if err != nil {
  23190. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23191. }
  23192. return oldValue.DeletedAt, nil
  23193. }
  23194. // ClearDeletedAt clears the value of the "deleted_at" field.
  23195. func (m *SopNodeMutation) ClearDeletedAt() {
  23196. m.deleted_at = nil
  23197. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23198. }
  23199. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23200. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23201. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23202. return ok
  23203. }
  23204. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23205. func (m *SopNodeMutation) ResetDeletedAt() {
  23206. m.deleted_at = nil
  23207. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23208. }
  23209. // SetStageID sets the "stage_id" field.
  23210. func (m *SopNodeMutation) SetStageID(u uint64) {
  23211. m.sop_stage = &u
  23212. }
  23213. // StageID returns the value of the "stage_id" field in the mutation.
  23214. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23215. v := m.sop_stage
  23216. if v == nil {
  23217. return
  23218. }
  23219. return *v, true
  23220. }
  23221. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23222. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23224. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23225. if !m.op.Is(OpUpdateOne) {
  23226. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23227. }
  23228. if m.id == nil || m.oldValue == nil {
  23229. return v, errors.New("OldStageID requires an ID field in the mutation")
  23230. }
  23231. oldValue, err := m.oldValue(ctx)
  23232. if err != nil {
  23233. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23234. }
  23235. return oldValue.StageID, nil
  23236. }
  23237. // ResetStageID resets all changes to the "stage_id" field.
  23238. func (m *SopNodeMutation) ResetStageID() {
  23239. m.sop_stage = nil
  23240. }
  23241. // SetParentID sets the "parent_id" field.
  23242. func (m *SopNodeMutation) SetParentID(u uint64) {
  23243. m.parent_id = &u
  23244. m.addparent_id = nil
  23245. }
  23246. // ParentID returns the value of the "parent_id" field in the mutation.
  23247. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23248. v := m.parent_id
  23249. if v == nil {
  23250. return
  23251. }
  23252. return *v, true
  23253. }
  23254. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23255. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23257. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23258. if !m.op.Is(OpUpdateOne) {
  23259. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23260. }
  23261. if m.id == nil || m.oldValue == nil {
  23262. return v, errors.New("OldParentID requires an ID field in the mutation")
  23263. }
  23264. oldValue, err := m.oldValue(ctx)
  23265. if err != nil {
  23266. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23267. }
  23268. return oldValue.ParentID, nil
  23269. }
  23270. // AddParentID adds u to the "parent_id" field.
  23271. func (m *SopNodeMutation) AddParentID(u int64) {
  23272. if m.addparent_id != nil {
  23273. *m.addparent_id += u
  23274. } else {
  23275. m.addparent_id = &u
  23276. }
  23277. }
  23278. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23279. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23280. v := m.addparent_id
  23281. if v == nil {
  23282. return
  23283. }
  23284. return *v, true
  23285. }
  23286. // ResetParentID resets all changes to the "parent_id" field.
  23287. func (m *SopNodeMutation) ResetParentID() {
  23288. m.parent_id = nil
  23289. m.addparent_id = nil
  23290. }
  23291. // SetName sets the "name" field.
  23292. func (m *SopNodeMutation) SetName(s string) {
  23293. m.name = &s
  23294. }
  23295. // Name returns the value of the "name" field in the mutation.
  23296. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23297. v := m.name
  23298. if v == nil {
  23299. return
  23300. }
  23301. return *v, true
  23302. }
  23303. // OldName returns the old "name" field's value of the SopNode entity.
  23304. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23306. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23307. if !m.op.Is(OpUpdateOne) {
  23308. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23309. }
  23310. if m.id == nil || m.oldValue == nil {
  23311. return v, errors.New("OldName requires an ID field in the mutation")
  23312. }
  23313. oldValue, err := m.oldValue(ctx)
  23314. if err != nil {
  23315. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23316. }
  23317. return oldValue.Name, nil
  23318. }
  23319. // ResetName resets all changes to the "name" field.
  23320. func (m *SopNodeMutation) ResetName() {
  23321. m.name = nil
  23322. }
  23323. // SetConditionType sets the "condition_type" field.
  23324. func (m *SopNodeMutation) SetConditionType(i int) {
  23325. m.condition_type = &i
  23326. m.addcondition_type = nil
  23327. }
  23328. // ConditionType returns the value of the "condition_type" field in the mutation.
  23329. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23330. v := m.condition_type
  23331. if v == nil {
  23332. return
  23333. }
  23334. return *v, true
  23335. }
  23336. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23337. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23339. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23340. if !m.op.Is(OpUpdateOne) {
  23341. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23342. }
  23343. if m.id == nil || m.oldValue == nil {
  23344. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23345. }
  23346. oldValue, err := m.oldValue(ctx)
  23347. if err != nil {
  23348. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23349. }
  23350. return oldValue.ConditionType, nil
  23351. }
  23352. // AddConditionType adds i to the "condition_type" field.
  23353. func (m *SopNodeMutation) AddConditionType(i int) {
  23354. if m.addcondition_type != nil {
  23355. *m.addcondition_type += i
  23356. } else {
  23357. m.addcondition_type = &i
  23358. }
  23359. }
  23360. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23361. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23362. v := m.addcondition_type
  23363. if v == nil {
  23364. return
  23365. }
  23366. return *v, true
  23367. }
  23368. // ResetConditionType resets all changes to the "condition_type" field.
  23369. func (m *SopNodeMutation) ResetConditionType() {
  23370. m.condition_type = nil
  23371. m.addcondition_type = nil
  23372. }
  23373. // SetConditionList sets the "condition_list" field.
  23374. func (m *SopNodeMutation) SetConditionList(s []string) {
  23375. m.condition_list = &s
  23376. m.appendcondition_list = nil
  23377. }
  23378. // ConditionList returns the value of the "condition_list" field in the mutation.
  23379. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23380. v := m.condition_list
  23381. if v == nil {
  23382. return
  23383. }
  23384. return *v, true
  23385. }
  23386. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23387. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23389. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23390. if !m.op.Is(OpUpdateOne) {
  23391. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23392. }
  23393. if m.id == nil || m.oldValue == nil {
  23394. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23395. }
  23396. oldValue, err := m.oldValue(ctx)
  23397. if err != nil {
  23398. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23399. }
  23400. return oldValue.ConditionList, nil
  23401. }
  23402. // AppendConditionList adds s to the "condition_list" field.
  23403. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23404. m.appendcondition_list = append(m.appendcondition_list, s...)
  23405. }
  23406. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23407. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23408. if len(m.appendcondition_list) == 0 {
  23409. return nil, false
  23410. }
  23411. return m.appendcondition_list, true
  23412. }
  23413. // ClearConditionList clears the value of the "condition_list" field.
  23414. func (m *SopNodeMutation) ClearConditionList() {
  23415. m.condition_list = nil
  23416. m.appendcondition_list = nil
  23417. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23418. }
  23419. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23420. func (m *SopNodeMutation) ConditionListCleared() bool {
  23421. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23422. return ok
  23423. }
  23424. // ResetConditionList resets all changes to the "condition_list" field.
  23425. func (m *SopNodeMutation) ResetConditionList() {
  23426. m.condition_list = nil
  23427. m.appendcondition_list = nil
  23428. delete(m.clearedFields, sopnode.FieldConditionList)
  23429. }
  23430. // SetNoReplyCondition sets the "no_reply_condition" field.
  23431. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23432. m.no_reply_condition = &u
  23433. m.addno_reply_condition = nil
  23434. }
  23435. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23436. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23437. v := m.no_reply_condition
  23438. if v == nil {
  23439. return
  23440. }
  23441. return *v, true
  23442. }
  23443. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23444. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23446. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23447. if !m.op.Is(OpUpdateOne) {
  23448. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23449. }
  23450. if m.id == nil || m.oldValue == nil {
  23451. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23452. }
  23453. oldValue, err := m.oldValue(ctx)
  23454. if err != nil {
  23455. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23456. }
  23457. return oldValue.NoReplyCondition, nil
  23458. }
  23459. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23460. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23461. if m.addno_reply_condition != nil {
  23462. *m.addno_reply_condition += u
  23463. } else {
  23464. m.addno_reply_condition = &u
  23465. }
  23466. }
  23467. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23468. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23469. v := m.addno_reply_condition
  23470. if v == nil {
  23471. return
  23472. }
  23473. return *v, true
  23474. }
  23475. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23476. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23477. m.no_reply_condition = nil
  23478. m.addno_reply_condition = nil
  23479. }
  23480. // SetNoReplyUnit sets the "no_reply_unit" field.
  23481. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23482. m.no_reply_unit = &s
  23483. }
  23484. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23485. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23486. v := m.no_reply_unit
  23487. if v == nil {
  23488. return
  23489. }
  23490. return *v, true
  23491. }
  23492. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23493. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23495. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23496. if !m.op.Is(OpUpdateOne) {
  23497. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23498. }
  23499. if m.id == nil || m.oldValue == nil {
  23500. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23501. }
  23502. oldValue, err := m.oldValue(ctx)
  23503. if err != nil {
  23504. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23505. }
  23506. return oldValue.NoReplyUnit, nil
  23507. }
  23508. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23509. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23510. m.no_reply_unit = nil
  23511. }
  23512. // SetActionMessage sets the "action_message" field.
  23513. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23514. m.action_message = &ct
  23515. m.appendaction_message = nil
  23516. }
  23517. // ActionMessage returns the value of the "action_message" field in the mutation.
  23518. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23519. v := m.action_message
  23520. if v == nil {
  23521. return
  23522. }
  23523. return *v, true
  23524. }
  23525. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23526. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23528. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23529. if !m.op.Is(OpUpdateOne) {
  23530. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23531. }
  23532. if m.id == nil || m.oldValue == nil {
  23533. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23534. }
  23535. oldValue, err := m.oldValue(ctx)
  23536. if err != nil {
  23537. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23538. }
  23539. return oldValue.ActionMessage, nil
  23540. }
  23541. // AppendActionMessage adds ct to the "action_message" field.
  23542. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23543. m.appendaction_message = append(m.appendaction_message, ct...)
  23544. }
  23545. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23546. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23547. if len(m.appendaction_message) == 0 {
  23548. return nil, false
  23549. }
  23550. return m.appendaction_message, true
  23551. }
  23552. // ClearActionMessage clears the value of the "action_message" field.
  23553. func (m *SopNodeMutation) ClearActionMessage() {
  23554. m.action_message = nil
  23555. m.appendaction_message = nil
  23556. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23557. }
  23558. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23559. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23560. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23561. return ok
  23562. }
  23563. // ResetActionMessage resets all changes to the "action_message" field.
  23564. func (m *SopNodeMutation) ResetActionMessage() {
  23565. m.action_message = nil
  23566. m.appendaction_message = nil
  23567. delete(m.clearedFields, sopnode.FieldActionMessage)
  23568. }
  23569. // SetActionLabelAdd sets the "action_label_add" field.
  23570. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23571. m.action_label_add = &u
  23572. m.appendaction_label_add = nil
  23573. }
  23574. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23575. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23576. v := m.action_label_add
  23577. if v == nil {
  23578. return
  23579. }
  23580. return *v, true
  23581. }
  23582. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23583. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23585. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23586. if !m.op.Is(OpUpdateOne) {
  23587. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23588. }
  23589. if m.id == nil || m.oldValue == nil {
  23590. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23591. }
  23592. oldValue, err := m.oldValue(ctx)
  23593. if err != nil {
  23594. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23595. }
  23596. return oldValue.ActionLabelAdd, nil
  23597. }
  23598. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23599. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23600. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23601. }
  23602. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23603. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23604. if len(m.appendaction_label_add) == 0 {
  23605. return nil, false
  23606. }
  23607. return m.appendaction_label_add, true
  23608. }
  23609. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23610. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23611. m.action_label_add = nil
  23612. m.appendaction_label_add = nil
  23613. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23614. }
  23615. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23616. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23617. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23618. return ok
  23619. }
  23620. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23621. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23622. m.action_label_add = nil
  23623. m.appendaction_label_add = nil
  23624. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23625. }
  23626. // SetActionLabelDel sets the "action_label_del" field.
  23627. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23628. m.action_label_del = &u
  23629. m.appendaction_label_del = nil
  23630. }
  23631. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23632. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23633. v := m.action_label_del
  23634. if v == nil {
  23635. return
  23636. }
  23637. return *v, true
  23638. }
  23639. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23640. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23642. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23643. if !m.op.Is(OpUpdateOne) {
  23644. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23645. }
  23646. if m.id == nil || m.oldValue == nil {
  23647. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23648. }
  23649. oldValue, err := m.oldValue(ctx)
  23650. if err != nil {
  23651. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23652. }
  23653. return oldValue.ActionLabelDel, nil
  23654. }
  23655. // AppendActionLabelDel adds u to the "action_label_del" field.
  23656. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23657. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23658. }
  23659. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23660. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23661. if len(m.appendaction_label_del) == 0 {
  23662. return nil, false
  23663. }
  23664. return m.appendaction_label_del, true
  23665. }
  23666. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23667. func (m *SopNodeMutation) ClearActionLabelDel() {
  23668. m.action_label_del = nil
  23669. m.appendaction_label_del = nil
  23670. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23671. }
  23672. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23673. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23674. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23675. return ok
  23676. }
  23677. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23678. func (m *SopNodeMutation) ResetActionLabelDel() {
  23679. m.action_label_del = nil
  23680. m.appendaction_label_del = nil
  23681. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23682. }
  23683. // SetActionForward sets the "action_forward" field.
  23684. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23685. m.action_forward = &ctf
  23686. }
  23687. // ActionForward returns the value of the "action_forward" field in the mutation.
  23688. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23689. v := m.action_forward
  23690. if v == nil {
  23691. return
  23692. }
  23693. return *v, true
  23694. }
  23695. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23696. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23698. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23699. if !m.op.Is(OpUpdateOne) {
  23700. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23701. }
  23702. if m.id == nil || m.oldValue == nil {
  23703. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23704. }
  23705. oldValue, err := m.oldValue(ctx)
  23706. if err != nil {
  23707. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23708. }
  23709. return oldValue.ActionForward, nil
  23710. }
  23711. // ClearActionForward clears the value of the "action_forward" field.
  23712. func (m *SopNodeMutation) ClearActionForward() {
  23713. m.action_forward = nil
  23714. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23715. }
  23716. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23717. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23718. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23719. return ok
  23720. }
  23721. // ResetActionForward resets all changes to the "action_forward" field.
  23722. func (m *SopNodeMutation) ResetActionForward() {
  23723. m.action_forward = nil
  23724. delete(m.clearedFields, sopnode.FieldActionForward)
  23725. }
  23726. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23727. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23728. m.sop_stage = &id
  23729. }
  23730. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23731. func (m *SopNodeMutation) ClearSopStage() {
  23732. m.clearedsop_stage = true
  23733. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23734. }
  23735. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23736. func (m *SopNodeMutation) SopStageCleared() bool {
  23737. return m.clearedsop_stage
  23738. }
  23739. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23740. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23741. if m.sop_stage != nil {
  23742. return *m.sop_stage, true
  23743. }
  23744. return
  23745. }
  23746. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23747. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23748. // SopStageID instead. It exists only for internal usage by the builders.
  23749. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23750. if id := m.sop_stage; id != nil {
  23751. ids = append(ids, *id)
  23752. }
  23753. return
  23754. }
  23755. // ResetSopStage resets all changes to the "sop_stage" edge.
  23756. func (m *SopNodeMutation) ResetSopStage() {
  23757. m.sop_stage = nil
  23758. m.clearedsop_stage = false
  23759. }
  23760. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23761. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23762. if m.node_messages == nil {
  23763. m.node_messages = make(map[uint64]struct{})
  23764. }
  23765. for i := range ids {
  23766. m.node_messages[ids[i]] = struct{}{}
  23767. }
  23768. }
  23769. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23770. func (m *SopNodeMutation) ClearNodeMessages() {
  23771. m.clearednode_messages = true
  23772. }
  23773. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23774. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23775. return m.clearednode_messages
  23776. }
  23777. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23778. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23779. if m.removednode_messages == nil {
  23780. m.removednode_messages = make(map[uint64]struct{})
  23781. }
  23782. for i := range ids {
  23783. delete(m.node_messages, ids[i])
  23784. m.removednode_messages[ids[i]] = struct{}{}
  23785. }
  23786. }
  23787. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23788. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23789. for id := range m.removednode_messages {
  23790. ids = append(ids, id)
  23791. }
  23792. return
  23793. }
  23794. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23795. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23796. for id := range m.node_messages {
  23797. ids = append(ids, id)
  23798. }
  23799. return
  23800. }
  23801. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23802. func (m *SopNodeMutation) ResetNodeMessages() {
  23803. m.node_messages = nil
  23804. m.clearednode_messages = false
  23805. m.removednode_messages = nil
  23806. }
  23807. // Where appends a list predicates to the SopNodeMutation builder.
  23808. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23809. m.predicates = append(m.predicates, ps...)
  23810. }
  23811. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23812. // users can use type-assertion to append predicates that do not depend on any generated package.
  23813. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23814. p := make([]predicate.SopNode, len(ps))
  23815. for i := range ps {
  23816. p[i] = ps[i]
  23817. }
  23818. m.Where(p...)
  23819. }
  23820. // Op returns the operation name.
  23821. func (m *SopNodeMutation) Op() Op {
  23822. return m.op
  23823. }
  23824. // SetOp allows setting the mutation operation.
  23825. func (m *SopNodeMutation) SetOp(op Op) {
  23826. m.op = op
  23827. }
  23828. // Type returns the node type of this mutation (SopNode).
  23829. func (m *SopNodeMutation) Type() string {
  23830. return m.typ
  23831. }
  23832. // Fields returns all fields that were changed during this mutation. Note that in
  23833. // order to get all numeric fields that were incremented/decremented, call
  23834. // AddedFields().
  23835. func (m *SopNodeMutation) Fields() []string {
  23836. fields := make([]string, 0, 15)
  23837. if m.created_at != nil {
  23838. fields = append(fields, sopnode.FieldCreatedAt)
  23839. }
  23840. if m.updated_at != nil {
  23841. fields = append(fields, sopnode.FieldUpdatedAt)
  23842. }
  23843. if m.status != nil {
  23844. fields = append(fields, sopnode.FieldStatus)
  23845. }
  23846. if m.deleted_at != nil {
  23847. fields = append(fields, sopnode.FieldDeletedAt)
  23848. }
  23849. if m.sop_stage != nil {
  23850. fields = append(fields, sopnode.FieldStageID)
  23851. }
  23852. if m.parent_id != nil {
  23853. fields = append(fields, sopnode.FieldParentID)
  23854. }
  23855. if m.name != nil {
  23856. fields = append(fields, sopnode.FieldName)
  23857. }
  23858. if m.condition_type != nil {
  23859. fields = append(fields, sopnode.FieldConditionType)
  23860. }
  23861. if m.condition_list != nil {
  23862. fields = append(fields, sopnode.FieldConditionList)
  23863. }
  23864. if m.no_reply_condition != nil {
  23865. fields = append(fields, sopnode.FieldNoReplyCondition)
  23866. }
  23867. if m.no_reply_unit != nil {
  23868. fields = append(fields, sopnode.FieldNoReplyUnit)
  23869. }
  23870. if m.action_message != nil {
  23871. fields = append(fields, sopnode.FieldActionMessage)
  23872. }
  23873. if m.action_label_add != nil {
  23874. fields = append(fields, sopnode.FieldActionLabelAdd)
  23875. }
  23876. if m.action_label_del != nil {
  23877. fields = append(fields, sopnode.FieldActionLabelDel)
  23878. }
  23879. if m.action_forward != nil {
  23880. fields = append(fields, sopnode.FieldActionForward)
  23881. }
  23882. return fields
  23883. }
  23884. // Field returns the value of a field with the given name. The second boolean
  23885. // return value indicates that this field was not set, or was not defined in the
  23886. // schema.
  23887. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  23888. switch name {
  23889. case sopnode.FieldCreatedAt:
  23890. return m.CreatedAt()
  23891. case sopnode.FieldUpdatedAt:
  23892. return m.UpdatedAt()
  23893. case sopnode.FieldStatus:
  23894. return m.Status()
  23895. case sopnode.FieldDeletedAt:
  23896. return m.DeletedAt()
  23897. case sopnode.FieldStageID:
  23898. return m.StageID()
  23899. case sopnode.FieldParentID:
  23900. return m.ParentID()
  23901. case sopnode.FieldName:
  23902. return m.Name()
  23903. case sopnode.FieldConditionType:
  23904. return m.ConditionType()
  23905. case sopnode.FieldConditionList:
  23906. return m.ConditionList()
  23907. case sopnode.FieldNoReplyCondition:
  23908. return m.NoReplyCondition()
  23909. case sopnode.FieldNoReplyUnit:
  23910. return m.NoReplyUnit()
  23911. case sopnode.FieldActionMessage:
  23912. return m.ActionMessage()
  23913. case sopnode.FieldActionLabelAdd:
  23914. return m.ActionLabelAdd()
  23915. case sopnode.FieldActionLabelDel:
  23916. return m.ActionLabelDel()
  23917. case sopnode.FieldActionForward:
  23918. return m.ActionForward()
  23919. }
  23920. return nil, false
  23921. }
  23922. // OldField returns the old value of the field from the database. An error is
  23923. // returned if the mutation operation is not UpdateOne, or the query to the
  23924. // database failed.
  23925. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23926. switch name {
  23927. case sopnode.FieldCreatedAt:
  23928. return m.OldCreatedAt(ctx)
  23929. case sopnode.FieldUpdatedAt:
  23930. return m.OldUpdatedAt(ctx)
  23931. case sopnode.FieldStatus:
  23932. return m.OldStatus(ctx)
  23933. case sopnode.FieldDeletedAt:
  23934. return m.OldDeletedAt(ctx)
  23935. case sopnode.FieldStageID:
  23936. return m.OldStageID(ctx)
  23937. case sopnode.FieldParentID:
  23938. return m.OldParentID(ctx)
  23939. case sopnode.FieldName:
  23940. return m.OldName(ctx)
  23941. case sopnode.FieldConditionType:
  23942. return m.OldConditionType(ctx)
  23943. case sopnode.FieldConditionList:
  23944. return m.OldConditionList(ctx)
  23945. case sopnode.FieldNoReplyCondition:
  23946. return m.OldNoReplyCondition(ctx)
  23947. case sopnode.FieldNoReplyUnit:
  23948. return m.OldNoReplyUnit(ctx)
  23949. case sopnode.FieldActionMessage:
  23950. return m.OldActionMessage(ctx)
  23951. case sopnode.FieldActionLabelAdd:
  23952. return m.OldActionLabelAdd(ctx)
  23953. case sopnode.FieldActionLabelDel:
  23954. return m.OldActionLabelDel(ctx)
  23955. case sopnode.FieldActionForward:
  23956. return m.OldActionForward(ctx)
  23957. }
  23958. return nil, fmt.Errorf("unknown SopNode field %s", name)
  23959. }
  23960. // SetField sets the value of a field with the given name. It returns an error if
  23961. // the field is not defined in the schema, or if the type mismatched the field
  23962. // type.
  23963. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  23964. switch name {
  23965. case sopnode.FieldCreatedAt:
  23966. v, ok := value.(time.Time)
  23967. if !ok {
  23968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23969. }
  23970. m.SetCreatedAt(v)
  23971. return nil
  23972. case sopnode.FieldUpdatedAt:
  23973. v, ok := value.(time.Time)
  23974. if !ok {
  23975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23976. }
  23977. m.SetUpdatedAt(v)
  23978. return nil
  23979. case sopnode.FieldStatus:
  23980. v, ok := value.(uint8)
  23981. if !ok {
  23982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23983. }
  23984. m.SetStatus(v)
  23985. return nil
  23986. case sopnode.FieldDeletedAt:
  23987. v, ok := value.(time.Time)
  23988. if !ok {
  23989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23990. }
  23991. m.SetDeletedAt(v)
  23992. return nil
  23993. case sopnode.FieldStageID:
  23994. v, ok := value.(uint64)
  23995. if !ok {
  23996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23997. }
  23998. m.SetStageID(v)
  23999. return nil
  24000. case sopnode.FieldParentID:
  24001. v, ok := value.(uint64)
  24002. if !ok {
  24003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24004. }
  24005. m.SetParentID(v)
  24006. return nil
  24007. case sopnode.FieldName:
  24008. v, ok := value.(string)
  24009. if !ok {
  24010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24011. }
  24012. m.SetName(v)
  24013. return nil
  24014. case sopnode.FieldConditionType:
  24015. v, ok := value.(int)
  24016. if !ok {
  24017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24018. }
  24019. m.SetConditionType(v)
  24020. return nil
  24021. case sopnode.FieldConditionList:
  24022. v, ok := value.([]string)
  24023. if !ok {
  24024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24025. }
  24026. m.SetConditionList(v)
  24027. return nil
  24028. case sopnode.FieldNoReplyCondition:
  24029. v, ok := value.(uint64)
  24030. if !ok {
  24031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24032. }
  24033. m.SetNoReplyCondition(v)
  24034. return nil
  24035. case sopnode.FieldNoReplyUnit:
  24036. v, ok := value.(string)
  24037. if !ok {
  24038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24039. }
  24040. m.SetNoReplyUnit(v)
  24041. return nil
  24042. case sopnode.FieldActionMessage:
  24043. v, ok := value.([]custom_types.Action)
  24044. if !ok {
  24045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24046. }
  24047. m.SetActionMessage(v)
  24048. return nil
  24049. case sopnode.FieldActionLabelAdd:
  24050. v, ok := value.([]uint64)
  24051. if !ok {
  24052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24053. }
  24054. m.SetActionLabelAdd(v)
  24055. return nil
  24056. case sopnode.FieldActionLabelDel:
  24057. v, ok := value.([]uint64)
  24058. if !ok {
  24059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24060. }
  24061. m.SetActionLabelDel(v)
  24062. return nil
  24063. case sopnode.FieldActionForward:
  24064. v, ok := value.(*custom_types.ActionForward)
  24065. if !ok {
  24066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24067. }
  24068. m.SetActionForward(v)
  24069. return nil
  24070. }
  24071. return fmt.Errorf("unknown SopNode field %s", name)
  24072. }
  24073. // AddedFields returns all numeric fields that were incremented/decremented during
  24074. // this mutation.
  24075. func (m *SopNodeMutation) AddedFields() []string {
  24076. var fields []string
  24077. if m.addstatus != nil {
  24078. fields = append(fields, sopnode.FieldStatus)
  24079. }
  24080. if m.addparent_id != nil {
  24081. fields = append(fields, sopnode.FieldParentID)
  24082. }
  24083. if m.addcondition_type != nil {
  24084. fields = append(fields, sopnode.FieldConditionType)
  24085. }
  24086. if m.addno_reply_condition != nil {
  24087. fields = append(fields, sopnode.FieldNoReplyCondition)
  24088. }
  24089. return fields
  24090. }
  24091. // AddedField returns the numeric value that was incremented/decremented on a field
  24092. // with the given name. The second boolean return value indicates that this field
  24093. // was not set, or was not defined in the schema.
  24094. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24095. switch name {
  24096. case sopnode.FieldStatus:
  24097. return m.AddedStatus()
  24098. case sopnode.FieldParentID:
  24099. return m.AddedParentID()
  24100. case sopnode.FieldConditionType:
  24101. return m.AddedConditionType()
  24102. case sopnode.FieldNoReplyCondition:
  24103. return m.AddedNoReplyCondition()
  24104. }
  24105. return nil, false
  24106. }
  24107. // AddField adds the value to the field with the given name. It returns an error if
  24108. // the field is not defined in the schema, or if the type mismatched the field
  24109. // type.
  24110. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24111. switch name {
  24112. case sopnode.FieldStatus:
  24113. v, ok := value.(int8)
  24114. if !ok {
  24115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24116. }
  24117. m.AddStatus(v)
  24118. return nil
  24119. case sopnode.FieldParentID:
  24120. v, ok := value.(int64)
  24121. if !ok {
  24122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24123. }
  24124. m.AddParentID(v)
  24125. return nil
  24126. case sopnode.FieldConditionType:
  24127. v, ok := value.(int)
  24128. if !ok {
  24129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24130. }
  24131. m.AddConditionType(v)
  24132. return nil
  24133. case sopnode.FieldNoReplyCondition:
  24134. v, ok := value.(int64)
  24135. if !ok {
  24136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24137. }
  24138. m.AddNoReplyCondition(v)
  24139. return nil
  24140. }
  24141. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24142. }
  24143. // ClearedFields returns all nullable fields that were cleared during this
  24144. // mutation.
  24145. func (m *SopNodeMutation) ClearedFields() []string {
  24146. var fields []string
  24147. if m.FieldCleared(sopnode.FieldStatus) {
  24148. fields = append(fields, sopnode.FieldStatus)
  24149. }
  24150. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24151. fields = append(fields, sopnode.FieldDeletedAt)
  24152. }
  24153. if m.FieldCleared(sopnode.FieldConditionList) {
  24154. fields = append(fields, sopnode.FieldConditionList)
  24155. }
  24156. if m.FieldCleared(sopnode.FieldActionMessage) {
  24157. fields = append(fields, sopnode.FieldActionMessage)
  24158. }
  24159. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24160. fields = append(fields, sopnode.FieldActionLabelAdd)
  24161. }
  24162. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24163. fields = append(fields, sopnode.FieldActionLabelDel)
  24164. }
  24165. if m.FieldCleared(sopnode.FieldActionForward) {
  24166. fields = append(fields, sopnode.FieldActionForward)
  24167. }
  24168. return fields
  24169. }
  24170. // FieldCleared returns a boolean indicating if a field with the given name was
  24171. // cleared in this mutation.
  24172. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24173. _, ok := m.clearedFields[name]
  24174. return ok
  24175. }
  24176. // ClearField clears the value of the field with the given name. It returns an
  24177. // error if the field is not defined in the schema.
  24178. func (m *SopNodeMutation) ClearField(name string) error {
  24179. switch name {
  24180. case sopnode.FieldStatus:
  24181. m.ClearStatus()
  24182. return nil
  24183. case sopnode.FieldDeletedAt:
  24184. m.ClearDeletedAt()
  24185. return nil
  24186. case sopnode.FieldConditionList:
  24187. m.ClearConditionList()
  24188. return nil
  24189. case sopnode.FieldActionMessage:
  24190. m.ClearActionMessage()
  24191. return nil
  24192. case sopnode.FieldActionLabelAdd:
  24193. m.ClearActionLabelAdd()
  24194. return nil
  24195. case sopnode.FieldActionLabelDel:
  24196. m.ClearActionLabelDel()
  24197. return nil
  24198. case sopnode.FieldActionForward:
  24199. m.ClearActionForward()
  24200. return nil
  24201. }
  24202. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24203. }
  24204. // ResetField resets all changes in the mutation for the field with the given name.
  24205. // It returns an error if the field is not defined in the schema.
  24206. func (m *SopNodeMutation) ResetField(name string) error {
  24207. switch name {
  24208. case sopnode.FieldCreatedAt:
  24209. m.ResetCreatedAt()
  24210. return nil
  24211. case sopnode.FieldUpdatedAt:
  24212. m.ResetUpdatedAt()
  24213. return nil
  24214. case sopnode.FieldStatus:
  24215. m.ResetStatus()
  24216. return nil
  24217. case sopnode.FieldDeletedAt:
  24218. m.ResetDeletedAt()
  24219. return nil
  24220. case sopnode.FieldStageID:
  24221. m.ResetStageID()
  24222. return nil
  24223. case sopnode.FieldParentID:
  24224. m.ResetParentID()
  24225. return nil
  24226. case sopnode.FieldName:
  24227. m.ResetName()
  24228. return nil
  24229. case sopnode.FieldConditionType:
  24230. m.ResetConditionType()
  24231. return nil
  24232. case sopnode.FieldConditionList:
  24233. m.ResetConditionList()
  24234. return nil
  24235. case sopnode.FieldNoReplyCondition:
  24236. m.ResetNoReplyCondition()
  24237. return nil
  24238. case sopnode.FieldNoReplyUnit:
  24239. m.ResetNoReplyUnit()
  24240. return nil
  24241. case sopnode.FieldActionMessage:
  24242. m.ResetActionMessage()
  24243. return nil
  24244. case sopnode.FieldActionLabelAdd:
  24245. m.ResetActionLabelAdd()
  24246. return nil
  24247. case sopnode.FieldActionLabelDel:
  24248. m.ResetActionLabelDel()
  24249. return nil
  24250. case sopnode.FieldActionForward:
  24251. m.ResetActionForward()
  24252. return nil
  24253. }
  24254. return fmt.Errorf("unknown SopNode field %s", name)
  24255. }
  24256. // AddedEdges returns all edge names that were set/added in this mutation.
  24257. func (m *SopNodeMutation) AddedEdges() []string {
  24258. edges := make([]string, 0, 2)
  24259. if m.sop_stage != nil {
  24260. edges = append(edges, sopnode.EdgeSopStage)
  24261. }
  24262. if m.node_messages != nil {
  24263. edges = append(edges, sopnode.EdgeNodeMessages)
  24264. }
  24265. return edges
  24266. }
  24267. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24268. // name in this mutation.
  24269. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24270. switch name {
  24271. case sopnode.EdgeSopStage:
  24272. if id := m.sop_stage; id != nil {
  24273. return []ent.Value{*id}
  24274. }
  24275. case sopnode.EdgeNodeMessages:
  24276. ids := make([]ent.Value, 0, len(m.node_messages))
  24277. for id := range m.node_messages {
  24278. ids = append(ids, id)
  24279. }
  24280. return ids
  24281. }
  24282. return nil
  24283. }
  24284. // RemovedEdges returns all edge names that were removed in this mutation.
  24285. func (m *SopNodeMutation) RemovedEdges() []string {
  24286. edges := make([]string, 0, 2)
  24287. if m.removednode_messages != nil {
  24288. edges = append(edges, sopnode.EdgeNodeMessages)
  24289. }
  24290. return edges
  24291. }
  24292. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24293. // the given name in this mutation.
  24294. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24295. switch name {
  24296. case sopnode.EdgeNodeMessages:
  24297. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24298. for id := range m.removednode_messages {
  24299. ids = append(ids, id)
  24300. }
  24301. return ids
  24302. }
  24303. return nil
  24304. }
  24305. // ClearedEdges returns all edge names that were cleared in this mutation.
  24306. func (m *SopNodeMutation) ClearedEdges() []string {
  24307. edges := make([]string, 0, 2)
  24308. if m.clearedsop_stage {
  24309. edges = append(edges, sopnode.EdgeSopStage)
  24310. }
  24311. if m.clearednode_messages {
  24312. edges = append(edges, sopnode.EdgeNodeMessages)
  24313. }
  24314. return edges
  24315. }
  24316. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24317. // was cleared in this mutation.
  24318. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24319. switch name {
  24320. case sopnode.EdgeSopStage:
  24321. return m.clearedsop_stage
  24322. case sopnode.EdgeNodeMessages:
  24323. return m.clearednode_messages
  24324. }
  24325. return false
  24326. }
  24327. // ClearEdge clears the value of the edge with the given name. It returns an error
  24328. // if that edge is not defined in the schema.
  24329. func (m *SopNodeMutation) ClearEdge(name string) error {
  24330. switch name {
  24331. case sopnode.EdgeSopStage:
  24332. m.ClearSopStage()
  24333. return nil
  24334. }
  24335. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24336. }
  24337. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24338. // It returns an error if the edge is not defined in the schema.
  24339. func (m *SopNodeMutation) ResetEdge(name string) error {
  24340. switch name {
  24341. case sopnode.EdgeSopStage:
  24342. m.ResetSopStage()
  24343. return nil
  24344. case sopnode.EdgeNodeMessages:
  24345. m.ResetNodeMessages()
  24346. return nil
  24347. }
  24348. return fmt.Errorf("unknown SopNode edge %s", name)
  24349. }
  24350. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24351. type SopStageMutation struct {
  24352. config
  24353. op Op
  24354. typ string
  24355. id *uint64
  24356. created_at *time.Time
  24357. updated_at *time.Time
  24358. status *uint8
  24359. addstatus *int8
  24360. deleted_at *time.Time
  24361. name *string
  24362. condition_type *int
  24363. addcondition_type *int
  24364. condition_operator *int
  24365. addcondition_operator *int
  24366. condition_list *[]custom_types.Condition
  24367. appendcondition_list []custom_types.Condition
  24368. action_message *[]custom_types.Action
  24369. appendaction_message []custom_types.Action
  24370. action_label_add *[]uint64
  24371. appendaction_label_add []uint64
  24372. action_label_del *[]uint64
  24373. appendaction_label_del []uint64
  24374. action_forward **custom_types.ActionForward
  24375. index_sort *int
  24376. addindex_sort *int
  24377. clearedFields map[string]struct{}
  24378. sop_task *uint64
  24379. clearedsop_task bool
  24380. stage_nodes map[uint64]struct{}
  24381. removedstage_nodes map[uint64]struct{}
  24382. clearedstage_nodes bool
  24383. stage_messages map[uint64]struct{}
  24384. removedstage_messages map[uint64]struct{}
  24385. clearedstage_messages bool
  24386. done bool
  24387. oldValue func(context.Context) (*SopStage, error)
  24388. predicates []predicate.SopStage
  24389. }
  24390. var _ ent.Mutation = (*SopStageMutation)(nil)
  24391. // sopstageOption allows management of the mutation configuration using functional options.
  24392. type sopstageOption func(*SopStageMutation)
  24393. // newSopStageMutation creates new mutation for the SopStage entity.
  24394. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24395. m := &SopStageMutation{
  24396. config: c,
  24397. op: op,
  24398. typ: TypeSopStage,
  24399. clearedFields: make(map[string]struct{}),
  24400. }
  24401. for _, opt := range opts {
  24402. opt(m)
  24403. }
  24404. return m
  24405. }
  24406. // withSopStageID sets the ID field of the mutation.
  24407. func withSopStageID(id uint64) sopstageOption {
  24408. return func(m *SopStageMutation) {
  24409. var (
  24410. err error
  24411. once sync.Once
  24412. value *SopStage
  24413. )
  24414. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24415. once.Do(func() {
  24416. if m.done {
  24417. err = errors.New("querying old values post mutation is not allowed")
  24418. } else {
  24419. value, err = m.Client().SopStage.Get(ctx, id)
  24420. }
  24421. })
  24422. return value, err
  24423. }
  24424. m.id = &id
  24425. }
  24426. }
  24427. // withSopStage sets the old SopStage of the mutation.
  24428. func withSopStage(node *SopStage) sopstageOption {
  24429. return func(m *SopStageMutation) {
  24430. m.oldValue = func(context.Context) (*SopStage, error) {
  24431. return node, nil
  24432. }
  24433. m.id = &node.ID
  24434. }
  24435. }
  24436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24437. // executed in a transaction (ent.Tx), a transactional client is returned.
  24438. func (m SopStageMutation) Client() *Client {
  24439. client := &Client{config: m.config}
  24440. client.init()
  24441. return client
  24442. }
  24443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24444. // it returns an error otherwise.
  24445. func (m SopStageMutation) Tx() (*Tx, error) {
  24446. if _, ok := m.driver.(*txDriver); !ok {
  24447. return nil, errors.New("ent: mutation is not running in a transaction")
  24448. }
  24449. tx := &Tx{config: m.config}
  24450. tx.init()
  24451. return tx, nil
  24452. }
  24453. // SetID sets the value of the id field. Note that this
  24454. // operation is only accepted on creation of SopStage entities.
  24455. func (m *SopStageMutation) SetID(id uint64) {
  24456. m.id = &id
  24457. }
  24458. // ID returns the ID value in the mutation. Note that the ID is only available
  24459. // if it was provided to the builder or after it was returned from the database.
  24460. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24461. if m.id == nil {
  24462. return
  24463. }
  24464. return *m.id, true
  24465. }
  24466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24467. // That means, if the mutation is applied within a transaction with an isolation level such
  24468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24469. // or updated by the mutation.
  24470. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24471. switch {
  24472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24473. id, exists := m.ID()
  24474. if exists {
  24475. return []uint64{id}, nil
  24476. }
  24477. fallthrough
  24478. case m.op.Is(OpUpdate | OpDelete):
  24479. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24480. default:
  24481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24482. }
  24483. }
  24484. // SetCreatedAt sets the "created_at" field.
  24485. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24486. m.created_at = &t
  24487. }
  24488. // CreatedAt returns the value of the "created_at" field in the mutation.
  24489. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24490. v := m.created_at
  24491. if v == nil {
  24492. return
  24493. }
  24494. return *v, true
  24495. }
  24496. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24497. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24499. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24500. if !m.op.Is(OpUpdateOne) {
  24501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24502. }
  24503. if m.id == nil || m.oldValue == nil {
  24504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24505. }
  24506. oldValue, err := m.oldValue(ctx)
  24507. if err != nil {
  24508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24509. }
  24510. return oldValue.CreatedAt, nil
  24511. }
  24512. // ResetCreatedAt resets all changes to the "created_at" field.
  24513. func (m *SopStageMutation) ResetCreatedAt() {
  24514. m.created_at = nil
  24515. }
  24516. // SetUpdatedAt sets the "updated_at" field.
  24517. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24518. m.updated_at = &t
  24519. }
  24520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24521. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24522. v := m.updated_at
  24523. if v == nil {
  24524. return
  24525. }
  24526. return *v, true
  24527. }
  24528. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24529. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24531. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24532. if !m.op.Is(OpUpdateOne) {
  24533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24534. }
  24535. if m.id == nil || m.oldValue == nil {
  24536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24537. }
  24538. oldValue, err := m.oldValue(ctx)
  24539. if err != nil {
  24540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24541. }
  24542. return oldValue.UpdatedAt, nil
  24543. }
  24544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24545. func (m *SopStageMutation) ResetUpdatedAt() {
  24546. m.updated_at = nil
  24547. }
  24548. // SetStatus sets the "status" field.
  24549. func (m *SopStageMutation) SetStatus(u uint8) {
  24550. m.status = &u
  24551. m.addstatus = nil
  24552. }
  24553. // Status returns the value of the "status" field in the mutation.
  24554. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24555. v := m.status
  24556. if v == nil {
  24557. return
  24558. }
  24559. return *v, true
  24560. }
  24561. // OldStatus returns the old "status" field's value of the SopStage entity.
  24562. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24564. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24565. if !m.op.Is(OpUpdateOne) {
  24566. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24567. }
  24568. if m.id == nil || m.oldValue == nil {
  24569. return v, errors.New("OldStatus requires an ID field in the mutation")
  24570. }
  24571. oldValue, err := m.oldValue(ctx)
  24572. if err != nil {
  24573. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24574. }
  24575. return oldValue.Status, nil
  24576. }
  24577. // AddStatus adds u to the "status" field.
  24578. func (m *SopStageMutation) AddStatus(u int8) {
  24579. if m.addstatus != nil {
  24580. *m.addstatus += u
  24581. } else {
  24582. m.addstatus = &u
  24583. }
  24584. }
  24585. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24586. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24587. v := m.addstatus
  24588. if v == nil {
  24589. return
  24590. }
  24591. return *v, true
  24592. }
  24593. // ClearStatus clears the value of the "status" field.
  24594. func (m *SopStageMutation) ClearStatus() {
  24595. m.status = nil
  24596. m.addstatus = nil
  24597. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24598. }
  24599. // StatusCleared returns if the "status" field was cleared in this mutation.
  24600. func (m *SopStageMutation) StatusCleared() bool {
  24601. _, ok := m.clearedFields[sopstage.FieldStatus]
  24602. return ok
  24603. }
  24604. // ResetStatus resets all changes to the "status" field.
  24605. func (m *SopStageMutation) ResetStatus() {
  24606. m.status = nil
  24607. m.addstatus = nil
  24608. delete(m.clearedFields, sopstage.FieldStatus)
  24609. }
  24610. // SetDeletedAt sets the "deleted_at" field.
  24611. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24612. m.deleted_at = &t
  24613. }
  24614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24615. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24616. v := m.deleted_at
  24617. if v == nil {
  24618. return
  24619. }
  24620. return *v, true
  24621. }
  24622. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24623. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24625. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24626. if !m.op.Is(OpUpdateOne) {
  24627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24628. }
  24629. if m.id == nil || m.oldValue == nil {
  24630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24631. }
  24632. oldValue, err := m.oldValue(ctx)
  24633. if err != nil {
  24634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24635. }
  24636. return oldValue.DeletedAt, nil
  24637. }
  24638. // ClearDeletedAt clears the value of the "deleted_at" field.
  24639. func (m *SopStageMutation) ClearDeletedAt() {
  24640. m.deleted_at = nil
  24641. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24642. }
  24643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24644. func (m *SopStageMutation) DeletedAtCleared() bool {
  24645. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24646. return ok
  24647. }
  24648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24649. func (m *SopStageMutation) ResetDeletedAt() {
  24650. m.deleted_at = nil
  24651. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24652. }
  24653. // SetTaskID sets the "task_id" field.
  24654. func (m *SopStageMutation) SetTaskID(u uint64) {
  24655. m.sop_task = &u
  24656. }
  24657. // TaskID returns the value of the "task_id" field in the mutation.
  24658. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24659. v := m.sop_task
  24660. if v == nil {
  24661. return
  24662. }
  24663. return *v, true
  24664. }
  24665. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24666. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24668. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24669. if !m.op.Is(OpUpdateOne) {
  24670. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24671. }
  24672. if m.id == nil || m.oldValue == nil {
  24673. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24674. }
  24675. oldValue, err := m.oldValue(ctx)
  24676. if err != nil {
  24677. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24678. }
  24679. return oldValue.TaskID, nil
  24680. }
  24681. // ResetTaskID resets all changes to the "task_id" field.
  24682. func (m *SopStageMutation) ResetTaskID() {
  24683. m.sop_task = nil
  24684. }
  24685. // SetName sets the "name" field.
  24686. func (m *SopStageMutation) SetName(s string) {
  24687. m.name = &s
  24688. }
  24689. // Name returns the value of the "name" field in the mutation.
  24690. func (m *SopStageMutation) Name() (r string, exists bool) {
  24691. v := m.name
  24692. if v == nil {
  24693. return
  24694. }
  24695. return *v, true
  24696. }
  24697. // OldName returns the old "name" field's value of the SopStage entity.
  24698. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24700. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24701. if !m.op.Is(OpUpdateOne) {
  24702. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24703. }
  24704. if m.id == nil || m.oldValue == nil {
  24705. return v, errors.New("OldName requires an ID field in the mutation")
  24706. }
  24707. oldValue, err := m.oldValue(ctx)
  24708. if err != nil {
  24709. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24710. }
  24711. return oldValue.Name, nil
  24712. }
  24713. // ResetName resets all changes to the "name" field.
  24714. func (m *SopStageMutation) ResetName() {
  24715. m.name = nil
  24716. }
  24717. // SetConditionType sets the "condition_type" field.
  24718. func (m *SopStageMutation) SetConditionType(i int) {
  24719. m.condition_type = &i
  24720. m.addcondition_type = nil
  24721. }
  24722. // ConditionType returns the value of the "condition_type" field in the mutation.
  24723. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24724. v := m.condition_type
  24725. if v == nil {
  24726. return
  24727. }
  24728. return *v, true
  24729. }
  24730. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24731. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24733. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24734. if !m.op.Is(OpUpdateOne) {
  24735. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24736. }
  24737. if m.id == nil || m.oldValue == nil {
  24738. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24739. }
  24740. oldValue, err := m.oldValue(ctx)
  24741. if err != nil {
  24742. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24743. }
  24744. return oldValue.ConditionType, nil
  24745. }
  24746. // AddConditionType adds i to the "condition_type" field.
  24747. func (m *SopStageMutation) AddConditionType(i int) {
  24748. if m.addcondition_type != nil {
  24749. *m.addcondition_type += i
  24750. } else {
  24751. m.addcondition_type = &i
  24752. }
  24753. }
  24754. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24755. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24756. v := m.addcondition_type
  24757. if v == nil {
  24758. return
  24759. }
  24760. return *v, true
  24761. }
  24762. // ResetConditionType resets all changes to the "condition_type" field.
  24763. func (m *SopStageMutation) ResetConditionType() {
  24764. m.condition_type = nil
  24765. m.addcondition_type = nil
  24766. }
  24767. // SetConditionOperator sets the "condition_operator" field.
  24768. func (m *SopStageMutation) SetConditionOperator(i int) {
  24769. m.condition_operator = &i
  24770. m.addcondition_operator = nil
  24771. }
  24772. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24773. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24774. v := m.condition_operator
  24775. if v == nil {
  24776. return
  24777. }
  24778. return *v, true
  24779. }
  24780. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24781. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24783. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24784. if !m.op.Is(OpUpdateOne) {
  24785. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24786. }
  24787. if m.id == nil || m.oldValue == nil {
  24788. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24789. }
  24790. oldValue, err := m.oldValue(ctx)
  24791. if err != nil {
  24792. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24793. }
  24794. return oldValue.ConditionOperator, nil
  24795. }
  24796. // AddConditionOperator adds i to the "condition_operator" field.
  24797. func (m *SopStageMutation) AddConditionOperator(i int) {
  24798. if m.addcondition_operator != nil {
  24799. *m.addcondition_operator += i
  24800. } else {
  24801. m.addcondition_operator = &i
  24802. }
  24803. }
  24804. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24805. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24806. v := m.addcondition_operator
  24807. if v == nil {
  24808. return
  24809. }
  24810. return *v, true
  24811. }
  24812. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24813. func (m *SopStageMutation) ResetConditionOperator() {
  24814. m.condition_operator = nil
  24815. m.addcondition_operator = nil
  24816. }
  24817. // SetConditionList sets the "condition_list" field.
  24818. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24819. m.condition_list = &ct
  24820. m.appendcondition_list = nil
  24821. }
  24822. // ConditionList returns the value of the "condition_list" field in the mutation.
  24823. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24824. v := m.condition_list
  24825. if v == nil {
  24826. return
  24827. }
  24828. return *v, true
  24829. }
  24830. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24831. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24833. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24834. if !m.op.Is(OpUpdateOne) {
  24835. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24836. }
  24837. if m.id == nil || m.oldValue == nil {
  24838. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24839. }
  24840. oldValue, err := m.oldValue(ctx)
  24841. if err != nil {
  24842. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24843. }
  24844. return oldValue.ConditionList, nil
  24845. }
  24846. // AppendConditionList adds ct to the "condition_list" field.
  24847. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  24848. m.appendcondition_list = append(m.appendcondition_list, ct...)
  24849. }
  24850. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24851. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  24852. if len(m.appendcondition_list) == 0 {
  24853. return nil, false
  24854. }
  24855. return m.appendcondition_list, true
  24856. }
  24857. // ResetConditionList resets all changes to the "condition_list" field.
  24858. func (m *SopStageMutation) ResetConditionList() {
  24859. m.condition_list = nil
  24860. m.appendcondition_list = nil
  24861. }
  24862. // SetActionMessage sets the "action_message" field.
  24863. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  24864. m.action_message = &ct
  24865. m.appendaction_message = nil
  24866. }
  24867. // ActionMessage returns the value of the "action_message" field in the mutation.
  24868. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24869. v := m.action_message
  24870. if v == nil {
  24871. return
  24872. }
  24873. return *v, true
  24874. }
  24875. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  24876. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24878. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24879. if !m.op.Is(OpUpdateOne) {
  24880. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24881. }
  24882. if m.id == nil || m.oldValue == nil {
  24883. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24884. }
  24885. oldValue, err := m.oldValue(ctx)
  24886. if err != nil {
  24887. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24888. }
  24889. return oldValue.ActionMessage, nil
  24890. }
  24891. // AppendActionMessage adds ct to the "action_message" field.
  24892. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  24893. m.appendaction_message = append(m.appendaction_message, ct...)
  24894. }
  24895. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24896. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24897. if len(m.appendaction_message) == 0 {
  24898. return nil, false
  24899. }
  24900. return m.appendaction_message, true
  24901. }
  24902. // ClearActionMessage clears the value of the "action_message" field.
  24903. func (m *SopStageMutation) ClearActionMessage() {
  24904. m.action_message = nil
  24905. m.appendaction_message = nil
  24906. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24907. }
  24908. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24909. func (m *SopStageMutation) ActionMessageCleared() bool {
  24910. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24911. return ok
  24912. }
  24913. // ResetActionMessage resets all changes to the "action_message" field.
  24914. func (m *SopStageMutation) ResetActionMessage() {
  24915. m.action_message = nil
  24916. m.appendaction_message = nil
  24917. delete(m.clearedFields, sopstage.FieldActionMessage)
  24918. }
  24919. // SetActionLabelAdd sets the "action_label_add" field.
  24920. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24921. m.action_label_add = &u
  24922. m.appendaction_label_add = nil
  24923. }
  24924. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24925. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24926. v := m.action_label_add
  24927. if v == nil {
  24928. return
  24929. }
  24930. return *v, true
  24931. }
  24932. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  24933. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24935. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24936. if !m.op.Is(OpUpdateOne) {
  24937. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24938. }
  24939. if m.id == nil || m.oldValue == nil {
  24940. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24941. }
  24942. oldValue, err := m.oldValue(ctx)
  24943. if err != nil {
  24944. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24945. }
  24946. return oldValue.ActionLabelAdd, nil
  24947. }
  24948. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24949. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  24950. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24951. }
  24952. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24953. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24954. if len(m.appendaction_label_add) == 0 {
  24955. return nil, false
  24956. }
  24957. return m.appendaction_label_add, true
  24958. }
  24959. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24960. func (m *SopStageMutation) ClearActionLabelAdd() {
  24961. m.action_label_add = nil
  24962. m.appendaction_label_add = nil
  24963. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  24964. }
  24965. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24966. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  24967. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  24968. return ok
  24969. }
  24970. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24971. func (m *SopStageMutation) ResetActionLabelAdd() {
  24972. m.action_label_add = nil
  24973. m.appendaction_label_add = nil
  24974. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  24975. }
  24976. // SetActionLabelDel sets the "action_label_del" field.
  24977. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  24978. m.action_label_del = &u
  24979. m.appendaction_label_del = nil
  24980. }
  24981. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24982. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  24983. v := m.action_label_del
  24984. if v == nil {
  24985. return
  24986. }
  24987. return *v, true
  24988. }
  24989. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  24990. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24992. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24993. if !m.op.Is(OpUpdateOne) {
  24994. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24995. }
  24996. if m.id == nil || m.oldValue == nil {
  24997. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24998. }
  24999. oldValue, err := m.oldValue(ctx)
  25000. if err != nil {
  25001. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25002. }
  25003. return oldValue.ActionLabelDel, nil
  25004. }
  25005. // AppendActionLabelDel adds u to the "action_label_del" field.
  25006. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25007. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25008. }
  25009. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25010. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25011. if len(m.appendaction_label_del) == 0 {
  25012. return nil, false
  25013. }
  25014. return m.appendaction_label_del, true
  25015. }
  25016. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25017. func (m *SopStageMutation) ClearActionLabelDel() {
  25018. m.action_label_del = nil
  25019. m.appendaction_label_del = nil
  25020. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25021. }
  25022. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25023. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25024. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25025. return ok
  25026. }
  25027. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25028. func (m *SopStageMutation) ResetActionLabelDel() {
  25029. m.action_label_del = nil
  25030. m.appendaction_label_del = nil
  25031. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25032. }
  25033. // SetActionForward sets the "action_forward" field.
  25034. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25035. m.action_forward = &ctf
  25036. }
  25037. // ActionForward returns the value of the "action_forward" field in the mutation.
  25038. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25039. v := m.action_forward
  25040. if v == nil {
  25041. return
  25042. }
  25043. return *v, true
  25044. }
  25045. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25048. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25049. if !m.op.Is(OpUpdateOne) {
  25050. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25051. }
  25052. if m.id == nil || m.oldValue == nil {
  25053. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25054. }
  25055. oldValue, err := m.oldValue(ctx)
  25056. if err != nil {
  25057. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25058. }
  25059. return oldValue.ActionForward, nil
  25060. }
  25061. // ClearActionForward clears the value of the "action_forward" field.
  25062. func (m *SopStageMutation) ClearActionForward() {
  25063. m.action_forward = nil
  25064. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25065. }
  25066. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25067. func (m *SopStageMutation) ActionForwardCleared() bool {
  25068. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25069. return ok
  25070. }
  25071. // ResetActionForward resets all changes to the "action_forward" field.
  25072. func (m *SopStageMutation) ResetActionForward() {
  25073. m.action_forward = nil
  25074. delete(m.clearedFields, sopstage.FieldActionForward)
  25075. }
  25076. // SetIndexSort sets the "index_sort" field.
  25077. func (m *SopStageMutation) SetIndexSort(i int) {
  25078. m.index_sort = &i
  25079. m.addindex_sort = nil
  25080. }
  25081. // IndexSort returns the value of the "index_sort" field in the mutation.
  25082. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25083. v := m.index_sort
  25084. if v == nil {
  25085. return
  25086. }
  25087. return *v, true
  25088. }
  25089. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25090. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25092. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25093. if !m.op.Is(OpUpdateOne) {
  25094. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25095. }
  25096. if m.id == nil || m.oldValue == nil {
  25097. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25098. }
  25099. oldValue, err := m.oldValue(ctx)
  25100. if err != nil {
  25101. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25102. }
  25103. return oldValue.IndexSort, nil
  25104. }
  25105. // AddIndexSort adds i to the "index_sort" field.
  25106. func (m *SopStageMutation) AddIndexSort(i int) {
  25107. if m.addindex_sort != nil {
  25108. *m.addindex_sort += i
  25109. } else {
  25110. m.addindex_sort = &i
  25111. }
  25112. }
  25113. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25114. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25115. v := m.addindex_sort
  25116. if v == nil {
  25117. return
  25118. }
  25119. return *v, true
  25120. }
  25121. // ClearIndexSort clears the value of the "index_sort" field.
  25122. func (m *SopStageMutation) ClearIndexSort() {
  25123. m.index_sort = nil
  25124. m.addindex_sort = nil
  25125. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25126. }
  25127. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25128. func (m *SopStageMutation) IndexSortCleared() bool {
  25129. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25130. return ok
  25131. }
  25132. // ResetIndexSort resets all changes to the "index_sort" field.
  25133. func (m *SopStageMutation) ResetIndexSort() {
  25134. m.index_sort = nil
  25135. m.addindex_sort = nil
  25136. delete(m.clearedFields, sopstage.FieldIndexSort)
  25137. }
  25138. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25139. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25140. m.sop_task = &id
  25141. }
  25142. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25143. func (m *SopStageMutation) ClearSopTask() {
  25144. m.clearedsop_task = true
  25145. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25146. }
  25147. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25148. func (m *SopStageMutation) SopTaskCleared() bool {
  25149. return m.clearedsop_task
  25150. }
  25151. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25152. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25153. if m.sop_task != nil {
  25154. return *m.sop_task, true
  25155. }
  25156. return
  25157. }
  25158. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25159. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25160. // SopTaskID instead. It exists only for internal usage by the builders.
  25161. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25162. if id := m.sop_task; id != nil {
  25163. ids = append(ids, *id)
  25164. }
  25165. return
  25166. }
  25167. // ResetSopTask resets all changes to the "sop_task" edge.
  25168. func (m *SopStageMutation) ResetSopTask() {
  25169. m.sop_task = nil
  25170. m.clearedsop_task = false
  25171. }
  25172. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25173. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25174. if m.stage_nodes == nil {
  25175. m.stage_nodes = make(map[uint64]struct{})
  25176. }
  25177. for i := range ids {
  25178. m.stage_nodes[ids[i]] = struct{}{}
  25179. }
  25180. }
  25181. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25182. func (m *SopStageMutation) ClearStageNodes() {
  25183. m.clearedstage_nodes = true
  25184. }
  25185. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25186. func (m *SopStageMutation) StageNodesCleared() bool {
  25187. return m.clearedstage_nodes
  25188. }
  25189. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25190. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25191. if m.removedstage_nodes == nil {
  25192. m.removedstage_nodes = make(map[uint64]struct{})
  25193. }
  25194. for i := range ids {
  25195. delete(m.stage_nodes, ids[i])
  25196. m.removedstage_nodes[ids[i]] = struct{}{}
  25197. }
  25198. }
  25199. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25200. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25201. for id := range m.removedstage_nodes {
  25202. ids = append(ids, id)
  25203. }
  25204. return
  25205. }
  25206. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25207. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25208. for id := range m.stage_nodes {
  25209. ids = append(ids, id)
  25210. }
  25211. return
  25212. }
  25213. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25214. func (m *SopStageMutation) ResetStageNodes() {
  25215. m.stage_nodes = nil
  25216. m.clearedstage_nodes = false
  25217. m.removedstage_nodes = nil
  25218. }
  25219. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25220. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25221. if m.stage_messages == nil {
  25222. m.stage_messages = make(map[uint64]struct{})
  25223. }
  25224. for i := range ids {
  25225. m.stage_messages[ids[i]] = struct{}{}
  25226. }
  25227. }
  25228. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25229. func (m *SopStageMutation) ClearStageMessages() {
  25230. m.clearedstage_messages = true
  25231. }
  25232. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25233. func (m *SopStageMutation) StageMessagesCleared() bool {
  25234. return m.clearedstage_messages
  25235. }
  25236. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25237. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25238. if m.removedstage_messages == nil {
  25239. m.removedstage_messages = make(map[uint64]struct{})
  25240. }
  25241. for i := range ids {
  25242. delete(m.stage_messages, ids[i])
  25243. m.removedstage_messages[ids[i]] = struct{}{}
  25244. }
  25245. }
  25246. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25247. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25248. for id := range m.removedstage_messages {
  25249. ids = append(ids, id)
  25250. }
  25251. return
  25252. }
  25253. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25254. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25255. for id := range m.stage_messages {
  25256. ids = append(ids, id)
  25257. }
  25258. return
  25259. }
  25260. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25261. func (m *SopStageMutation) ResetStageMessages() {
  25262. m.stage_messages = nil
  25263. m.clearedstage_messages = false
  25264. m.removedstage_messages = nil
  25265. }
  25266. // Where appends a list predicates to the SopStageMutation builder.
  25267. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25268. m.predicates = append(m.predicates, ps...)
  25269. }
  25270. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25271. // users can use type-assertion to append predicates that do not depend on any generated package.
  25272. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25273. p := make([]predicate.SopStage, len(ps))
  25274. for i := range ps {
  25275. p[i] = ps[i]
  25276. }
  25277. m.Where(p...)
  25278. }
  25279. // Op returns the operation name.
  25280. func (m *SopStageMutation) Op() Op {
  25281. return m.op
  25282. }
  25283. // SetOp allows setting the mutation operation.
  25284. func (m *SopStageMutation) SetOp(op Op) {
  25285. m.op = op
  25286. }
  25287. // Type returns the node type of this mutation (SopStage).
  25288. func (m *SopStageMutation) Type() string {
  25289. return m.typ
  25290. }
  25291. // Fields returns all fields that were changed during this mutation. Note that in
  25292. // order to get all numeric fields that were incremented/decremented, call
  25293. // AddedFields().
  25294. func (m *SopStageMutation) Fields() []string {
  25295. fields := make([]string, 0, 14)
  25296. if m.created_at != nil {
  25297. fields = append(fields, sopstage.FieldCreatedAt)
  25298. }
  25299. if m.updated_at != nil {
  25300. fields = append(fields, sopstage.FieldUpdatedAt)
  25301. }
  25302. if m.status != nil {
  25303. fields = append(fields, sopstage.FieldStatus)
  25304. }
  25305. if m.deleted_at != nil {
  25306. fields = append(fields, sopstage.FieldDeletedAt)
  25307. }
  25308. if m.sop_task != nil {
  25309. fields = append(fields, sopstage.FieldTaskID)
  25310. }
  25311. if m.name != nil {
  25312. fields = append(fields, sopstage.FieldName)
  25313. }
  25314. if m.condition_type != nil {
  25315. fields = append(fields, sopstage.FieldConditionType)
  25316. }
  25317. if m.condition_operator != nil {
  25318. fields = append(fields, sopstage.FieldConditionOperator)
  25319. }
  25320. if m.condition_list != nil {
  25321. fields = append(fields, sopstage.FieldConditionList)
  25322. }
  25323. if m.action_message != nil {
  25324. fields = append(fields, sopstage.FieldActionMessage)
  25325. }
  25326. if m.action_label_add != nil {
  25327. fields = append(fields, sopstage.FieldActionLabelAdd)
  25328. }
  25329. if m.action_label_del != nil {
  25330. fields = append(fields, sopstage.FieldActionLabelDel)
  25331. }
  25332. if m.action_forward != nil {
  25333. fields = append(fields, sopstage.FieldActionForward)
  25334. }
  25335. if m.index_sort != nil {
  25336. fields = append(fields, sopstage.FieldIndexSort)
  25337. }
  25338. return fields
  25339. }
  25340. // Field returns the value of a field with the given name. The second boolean
  25341. // return value indicates that this field was not set, or was not defined in the
  25342. // schema.
  25343. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25344. switch name {
  25345. case sopstage.FieldCreatedAt:
  25346. return m.CreatedAt()
  25347. case sopstage.FieldUpdatedAt:
  25348. return m.UpdatedAt()
  25349. case sopstage.FieldStatus:
  25350. return m.Status()
  25351. case sopstage.FieldDeletedAt:
  25352. return m.DeletedAt()
  25353. case sopstage.FieldTaskID:
  25354. return m.TaskID()
  25355. case sopstage.FieldName:
  25356. return m.Name()
  25357. case sopstage.FieldConditionType:
  25358. return m.ConditionType()
  25359. case sopstage.FieldConditionOperator:
  25360. return m.ConditionOperator()
  25361. case sopstage.FieldConditionList:
  25362. return m.ConditionList()
  25363. case sopstage.FieldActionMessage:
  25364. return m.ActionMessage()
  25365. case sopstage.FieldActionLabelAdd:
  25366. return m.ActionLabelAdd()
  25367. case sopstage.FieldActionLabelDel:
  25368. return m.ActionLabelDel()
  25369. case sopstage.FieldActionForward:
  25370. return m.ActionForward()
  25371. case sopstage.FieldIndexSort:
  25372. return m.IndexSort()
  25373. }
  25374. return nil, false
  25375. }
  25376. // OldField returns the old value of the field from the database. An error is
  25377. // returned if the mutation operation is not UpdateOne, or the query to the
  25378. // database failed.
  25379. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25380. switch name {
  25381. case sopstage.FieldCreatedAt:
  25382. return m.OldCreatedAt(ctx)
  25383. case sopstage.FieldUpdatedAt:
  25384. return m.OldUpdatedAt(ctx)
  25385. case sopstage.FieldStatus:
  25386. return m.OldStatus(ctx)
  25387. case sopstage.FieldDeletedAt:
  25388. return m.OldDeletedAt(ctx)
  25389. case sopstage.FieldTaskID:
  25390. return m.OldTaskID(ctx)
  25391. case sopstage.FieldName:
  25392. return m.OldName(ctx)
  25393. case sopstage.FieldConditionType:
  25394. return m.OldConditionType(ctx)
  25395. case sopstage.FieldConditionOperator:
  25396. return m.OldConditionOperator(ctx)
  25397. case sopstage.FieldConditionList:
  25398. return m.OldConditionList(ctx)
  25399. case sopstage.FieldActionMessage:
  25400. return m.OldActionMessage(ctx)
  25401. case sopstage.FieldActionLabelAdd:
  25402. return m.OldActionLabelAdd(ctx)
  25403. case sopstage.FieldActionLabelDel:
  25404. return m.OldActionLabelDel(ctx)
  25405. case sopstage.FieldActionForward:
  25406. return m.OldActionForward(ctx)
  25407. case sopstage.FieldIndexSort:
  25408. return m.OldIndexSort(ctx)
  25409. }
  25410. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25411. }
  25412. // SetField sets the value of a field with the given name. It returns an error if
  25413. // the field is not defined in the schema, or if the type mismatched the field
  25414. // type.
  25415. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25416. switch name {
  25417. case sopstage.FieldCreatedAt:
  25418. v, ok := value.(time.Time)
  25419. if !ok {
  25420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25421. }
  25422. m.SetCreatedAt(v)
  25423. return nil
  25424. case sopstage.FieldUpdatedAt:
  25425. v, ok := value.(time.Time)
  25426. if !ok {
  25427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25428. }
  25429. m.SetUpdatedAt(v)
  25430. return nil
  25431. case sopstage.FieldStatus:
  25432. v, ok := value.(uint8)
  25433. if !ok {
  25434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25435. }
  25436. m.SetStatus(v)
  25437. return nil
  25438. case sopstage.FieldDeletedAt:
  25439. v, ok := value.(time.Time)
  25440. if !ok {
  25441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25442. }
  25443. m.SetDeletedAt(v)
  25444. return nil
  25445. case sopstage.FieldTaskID:
  25446. v, ok := value.(uint64)
  25447. if !ok {
  25448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25449. }
  25450. m.SetTaskID(v)
  25451. return nil
  25452. case sopstage.FieldName:
  25453. v, ok := value.(string)
  25454. if !ok {
  25455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25456. }
  25457. m.SetName(v)
  25458. return nil
  25459. case sopstage.FieldConditionType:
  25460. v, ok := value.(int)
  25461. if !ok {
  25462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25463. }
  25464. m.SetConditionType(v)
  25465. return nil
  25466. case sopstage.FieldConditionOperator:
  25467. v, ok := value.(int)
  25468. if !ok {
  25469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25470. }
  25471. m.SetConditionOperator(v)
  25472. return nil
  25473. case sopstage.FieldConditionList:
  25474. v, ok := value.([]custom_types.Condition)
  25475. if !ok {
  25476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25477. }
  25478. m.SetConditionList(v)
  25479. return nil
  25480. case sopstage.FieldActionMessage:
  25481. v, ok := value.([]custom_types.Action)
  25482. if !ok {
  25483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25484. }
  25485. m.SetActionMessage(v)
  25486. return nil
  25487. case sopstage.FieldActionLabelAdd:
  25488. v, ok := value.([]uint64)
  25489. if !ok {
  25490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25491. }
  25492. m.SetActionLabelAdd(v)
  25493. return nil
  25494. case sopstage.FieldActionLabelDel:
  25495. v, ok := value.([]uint64)
  25496. if !ok {
  25497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25498. }
  25499. m.SetActionLabelDel(v)
  25500. return nil
  25501. case sopstage.FieldActionForward:
  25502. v, ok := value.(*custom_types.ActionForward)
  25503. if !ok {
  25504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25505. }
  25506. m.SetActionForward(v)
  25507. return nil
  25508. case sopstage.FieldIndexSort:
  25509. v, ok := value.(int)
  25510. if !ok {
  25511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25512. }
  25513. m.SetIndexSort(v)
  25514. return nil
  25515. }
  25516. return fmt.Errorf("unknown SopStage field %s", name)
  25517. }
  25518. // AddedFields returns all numeric fields that were incremented/decremented during
  25519. // this mutation.
  25520. func (m *SopStageMutation) AddedFields() []string {
  25521. var fields []string
  25522. if m.addstatus != nil {
  25523. fields = append(fields, sopstage.FieldStatus)
  25524. }
  25525. if m.addcondition_type != nil {
  25526. fields = append(fields, sopstage.FieldConditionType)
  25527. }
  25528. if m.addcondition_operator != nil {
  25529. fields = append(fields, sopstage.FieldConditionOperator)
  25530. }
  25531. if m.addindex_sort != nil {
  25532. fields = append(fields, sopstage.FieldIndexSort)
  25533. }
  25534. return fields
  25535. }
  25536. // AddedField returns the numeric value that was incremented/decremented on a field
  25537. // with the given name. The second boolean return value indicates that this field
  25538. // was not set, or was not defined in the schema.
  25539. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25540. switch name {
  25541. case sopstage.FieldStatus:
  25542. return m.AddedStatus()
  25543. case sopstage.FieldConditionType:
  25544. return m.AddedConditionType()
  25545. case sopstage.FieldConditionOperator:
  25546. return m.AddedConditionOperator()
  25547. case sopstage.FieldIndexSort:
  25548. return m.AddedIndexSort()
  25549. }
  25550. return nil, false
  25551. }
  25552. // AddField adds the value to the field with the given name. It returns an error if
  25553. // the field is not defined in the schema, or if the type mismatched the field
  25554. // type.
  25555. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25556. switch name {
  25557. case sopstage.FieldStatus:
  25558. v, ok := value.(int8)
  25559. if !ok {
  25560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25561. }
  25562. m.AddStatus(v)
  25563. return nil
  25564. case sopstage.FieldConditionType:
  25565. v, ok := value.(int)
  25566. if !ok {
  25567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25568. }
  25569. m.AddConditionType(v)
  25570. return nil
  25571. case sopstage.FieldConditionOperator:
  25572. v, ok := value.(int)
  25573. if !ok {
  25574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25575. }
  25576. m.AddConditionOperator(v)
  25577. return nil
  25578. case sopstage.FieldIndexSort:
  25579. v, ok := value.(int)
  25580. if !ok {
  25581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25582. }
  25583. m.AddIndexSort(v)
  25584. return nil
  25585. }
  25586. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25587. }
  25588. // ClearedFields returns all nullable fields that were cleared during this
  25589. // mutation.
  25590. func (m *SopStageMutation) ClearedFields() []string {
  25591. var fields []string
  25592. if m.FieldCleared(sopstage.FieldStatus) {
  25593. fields = append(fields, sopstage.FieldStatus)
  25594. }
  25595. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25596. fields = append(fields, sopstage.FieldDeletedAt)
  25597. }
  25598. if m.FieldCleared(sopstage.FieldActionMessage) {
  25599. fields = append(fields, sopstage.FieldActionMessage)
  25600. }
  25601. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25602. fields = append(fields, sopstage.FieldActionLabelAdd)
  25603. }
  25604. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25605. fields = append(fields, sopstage.FieldActionLabelDel)
  25606. }
  25607. if m.FieldCleared(sopstage.FieldActionForward) {
  25608. fields = append(fields, sopstage.FieldActionForward)
  25609. }
  25610. if m.FieldCleared(sopstage.FieldIndexSort) {
  25611. fields = append(fields, sopstage.FieldIndexSort)
  25612. }
  25613. return fields
  25614. }
  25615. // FieldCleared returns a boolean indicating if a field with the given name was
  25616. // cleared in this mutation.
  25617. func (m *SopStageMutation) FieldCleared(name string) bool {
  25618. _, ok := m.clearedFields[name]
  25619. return ok
  25620. }
  25621. // ClearField clears the value of the field with the given name. It returns an
  25622. // error if the field is not defined in the schema.
  25623. func (m *SopStageMutation) ClearField(name string) error {
  25624. switch name {
  25625. case sopstage.FieldStatus:
  25626. m.ClearStatus()
  25627. return nil
  25628. case sopstage.FieldDeletedAt:
  25629. m.ClearDeletedAt()
  25630. return nil
  25631. case sopstage.FieldActionMessage:
  25632. m.ClearActionMessage()
  25633. return nil
  25634. case sopstage.FieldActionLabelAdd:
  25635. m.ClearActionLabelAdd()
  25636. return nil
  25637. case sopstage.FieldActionLabelDel:
  25638. m.ClearActionLabelDel()
  25639. return nil
  25640. case sopstage.FieldActionForward:
  25641. m.ClearActionForward()
  25642. return nil
  25643. case sopstage.FieldIndexSort:
  25644. m.ClearIndexSort()
  25645. return nil
  25646. }
  25647. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25648. }
  25649. // ResetField resets all changes in the mutation for the field with the given name.
  25650. // It returns an error if the field is not defined in the schema.
  25651. func (m *SopStageMutation) ResetField(name string) error {
  25652. switch name {
  25653. case sopstage.FieldCreatedAt:
  25654. m.ResetCreatedAt()
  25655. return nil
  25656. case sopstage.FieldUpdatedAt:
  25657. m.ResetUpdatedAt()
  25658. return nil
  25659. case sopstage.FieldStatus:
  25660. m.ResetStatus()
  25661. return nil
  25662. case sopstage.FieldDeletedAt:
  25663. m.ResetDeletedAt()
  25664. return nil
  25665. case sopstage.FieldTaskID:
  25666. m.ResetTaskID()
  25667. return nil
  25668. case sopstage.FieldName:
  25669. m.ResetName()
  25670. return nil
  25671. case sopstage.FieldConditionType:
  25672. m.ResetConditionType()
  25673. return nil
  25674. case sopstage.FieldConditionOperator:
  25675. m.ResetConditionOperator()
  25676. return nil
  25677. case sopstage.FieldConditionList:
  25678. m.ResetConditionList()
  25679. return nil
  25680. case sopstage.FieldActionMessage:
  25681. m.ResetActionMessage()
  25682. return nil
  25683. case sopstage.FieldActionLabelAdd:
  25684. m.ResetActionLabelAdd()
  25685. return nil
  25686. case sopstage.FieldActionLabelDel:
  25687. m.ResetActionLabelDel()
  25688. return nil
  25689. case sopstage.FieldActionForward:
  25690. m.ResetActionForward()
  25691. return nil
  25692. case sopstage.FieldIndexSort:
  25693. m.ResetIndexSort()
  25694. return nil
  25695. }
  25696. return fmt.Errorf("unknown SopStage field %s", name)
  25697. }
  25698. // AddedEdges returns all edge names that were set/added in this mutation.
  25699. func (m *SopStageMutation) AddedEdges() []string {
  25700. edges := make([]string, 0, 3)
  25701. if m.sop_task != nil {
  25702. edges = append(edges, sopstage.EdgeSopTask)
  25703. }
  25704. if m.stage_nodes != nil {
  25705. edges = append(edges, sopstage.EdgeStageNodes)
  25706. }
  25707. if m.stage_messages != nil {
  25708. edges = append(edges, sopstage.EdgeStageMessages)
  25709. }
  25710. return edges
  25711. }
  25712. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25713. // name in this mutation.
  25714. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25715. switch name {
  25716. case sopstage.EdgeSopTask:
  25717. if id := m.sop_task; id != nil {
  25718. return []ent.Value{*id}
  25719. }
  25720. case sopstage.EdgeStageNodes:
  25721. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25722. for id := range m.stage_nodes {
  25723. ids = append(ids, id)
  25724. }
  25725. return ids
  25726. case sopstage.EdgeStageMessages:
  25727. ids := make([]ent.Value, 0, len(m.stage_messages))
  25728. for id := range m.stage_messages {
  25729. ids = append(ids, id)
  25730. }
  25731. return ids
  25732. }
  25733. return nil
  25734. }
  25735. // RemovedEdges returns all edge names that were removed in this mutation.
  25736. func (m *SopStageMutation) RemovedEdges() []string {
  25737. edges := make([]string, 0, 3)
  25738. if m.removedstage_nodes != nil {
  25739. edges = append(edges, sopstage.EdgeStageNodes)
  25740. }
  25741. if m.removedstage_messages != nil {
  25742. edges = append(edges, sopstage.EdgeStageMessages)
  25743. }
  25744. return edges
  25745. }
  25746. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25747. // the given name in this mutation.
  25748. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25749. switch name {
  25750. case sopstage.EdgeStageNodes:
  25751. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25752. for id := range m.removedstage_nodes {
  25753. ids = append(ids, id)
  25754. }
  25755. return ids
  25756. case sopstage.EdgeStageMessages:
  25757. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25758. for id := range m.removedstage_messages {
  25759. ids = append(ids, id)
  25760. }
  25761. return ids
  25762. }
  25763. return nil
  25764. }
  25765. // ClearedEdges returns all edge names that were cleared in this mutation.
  25766. func (m *SopStageMutation) ClearedEdges() []string {
  25767. edges := make([]string, 0, 3)
  25768. if m.clearedsop_task {
  25769. edges = append(edges, sopstage.EdgeSopTask)
  25770. }
  25771. if m.clearedstage_nodes {
  25772. edges = append(edges, sopstage.EdgeStageNodes)
  25773. }
  25774. if m.clearedstage_messages {
  25775. edges = append(edges, sopstage.EdgeStageMessages)
  25776. }
  25777. return edges
  25778. }
  25779. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25780. // was cleared in this mutation.
  25781. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25782. switch name {
  25783. case sopstage.EdgeSopTask:
  25784. return m.clearedsop_task
  25785. case sopstage.EdgeStageNodes:
  25786. return m.clearedstage_nodes
  25787. case sopstage.EdgeStageMessages:
  25788. return m.clearedstage_messages
  25789. }
  25790. return false
  25791. }
  25792. // ClearEdge clears the value of the edge with the given name. It returns an error
  25793. // if that edge is not defined in the schema.
  25794. func (m *SopStageMutation) ClearEdge(name string) error {
  25795. switch name {
  25796. case sopstage.EdgeSopTask:
  25797. m.ClearSopTask()
  25798. return nil
  25799. }
  25800. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25801. }
  25802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25803. // It returns an error if the edge is not defined in the schema.
  25804. func (m *SopStageMutation) ResetEdge(name string) error {
  25805. switch name {
  25806. case sopstage.EdgeSopTask:
  25807. m.ResetSopTask()
  25808. return nil
  25809. case sopstage.EdgeStageNodes:
  25810. m.ResetStageNodes()
  25811. return nil
  25812. case sopstage.EdgeStageMessages:
  25813. m.ResetStageMessages()
  25814. return nil
  25815. }
  25816. return fmt.Errorf("unknown SopStage edge %s", name)
  25817. }
  25818. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25819. type SopTaskMutation struct {
  25820. config
  25821. op Op
  25822. typ string
  25823. id *uint64
  25824. created_at *time.Time
  25825. updated_at *time.Time
  25826. status *uint8
  25827. addstatus *int8
  25828. deleted_at *time.Time
  25829. name *string
  25830. bot_wxid_list *[]string
  25831. appendbot_wxid_list []string
  25832. _type *int
  25833. add_type *int
  25834. plan_start_time *time.Time
  25835. plan_end_time *time.Time
  25836. creator_id *string
  25837. organization_id *uint64
  25838. addorganization_id *int64
  25839. token *[]string
  25840. appendtoken []string
  25841. clearedFields map[string]struct{}
  25842. task_stages map[uint64]struct{}
  25843. removedtask_stages map[uint64]struct{}
  25844. clearedtask_stages bool
  25845. done bool
  25846. oldValue func(context.Context) (*SopTask, error)
  25847. predicates []predicate.SopTask
  25848. }
  25849. var _ ent.Mutation = (*SopTaskMutation)(nil)
  25850. // soptaskOption allows management of the mutation configuration using functional options.
  25851. type soptaskOption func(*SopTaskMutation)
  25852. // newSopTaskMutation creates new mutation for the SopTask entity.
  25853. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  25854. m := &SopTaskMutation{
  25855. config: c,
  25856. op: op,
  25857. typ: TypeSopTask,
  25858. clearedFields: make(map[string]struct{}),
  25859. }
  25860. for _, opt := range opts {
  25861. opt(m)
  25862. }
  25863. return m
  25864. }
  25865. // withSopTaskID sets the ID field of the mutation.
  25866. func withSopTaskID(id uint64) soptaskOption {
  25867. return func(m *SopTaskMutation) {
  25868. var (
  25869. err error
  25870. once sync.Once
  25871. value *SopTask
  25872. )
  25873. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  25874. once.Do(func() {
  25875. if m.done {
  25876. err = errors.New("querying old values post mutation is not allowed")
  25877. } else {
  25878. value, err = m.Client().SopTask.Get(ctx, id)
  25879. }
  25880. })
  25881. return value, err
  25882. }
  25883. m.id = &id
  25884. }
  25885. }
  25886. // withSopTask sets the old SopTask of the mutation.
  25887. func withSopTask(node *SopTask) soptaskOption {
  25888. return func(m *SopTaskMutation) {
  25889. m.oldValue = func(context.Context) (*SopTask, error) {
  25890. return node, nil
  25891. }
  25892. m.id = &node.ID
  25893. }
  25894. }
  25895. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25896. // executed in a transaction (ent.Tx), a transactional client is returned.
  25897. func (m SopTaskMutation) Client() *Client {
  25898. client := &Client{config: m.config}
  25899. client.init()
  25900. return client
  25901. }
  25902. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25903. // it returns an error otherwise.
  25904. func (m SopTaskMutation) Tx() (*Tx, error) {
  25905. if _, ok := m.driver.(*txDriver); !ok {
  25906. return nil, errors.New("ent: mutation is not running in a transaction")
  25907. }
  25908. tx := &Tx{config: m.config}
  25909. tx.init()
  25910. return tx, nil
  25911. }
  25912. // SetID sets the value of the id field. Note that this
  25913. // operation is only accepted on creation of SopTask entities.
  25914. func (m *SopTaskMutation) SetID(id uint64) {
  25915. m.id = &id
  25916. }
  25917. // ID returns the ID value in the mutation. Note that the ID is only available
  25918. // if it was provided to the builder or after it was returned from the database.
  25919. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25920. if m.id == nil {
  25921. return
  25922. }
  25923. return *m.id, true
  25924. }
  25925. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25926. // That means, if the mutation is applied within a transaction with an isolation level such
  25927. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25928. // or updated by the mutation.
  25929. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  25930. switch {
  25931. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25932. id, exists := m.ID()
  25933. if exists {
  25934. return []uint64{id}, nil
  25935. }
  25936. fallthrough
  25937. case m.op.Is(OpUpdate | OpDelete):
  25938. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  25939. default:
  25940. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25941. }
  25942. }
  25943. // SetCreatedAt sets the "created_at" field.
  25944. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  25945. m.created_at = &t
  25946. }
  25947. // CreatedAt returns the value of the "created_at" field in the mutation.
  25948. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  25949. v := m.created_at
  25950. if v == nil {
  25951. return
  25952. }
  25953. return *v, true
  25954. }
  25955. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  25956. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25958. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25959. if !m.op.Is(OpUpdateOne) {
  25960. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25961. }
  25962. if m.id == nil || m.oldValue == nil {
  25963. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25964. }
  25965. oldValue, err := m.oldValue(ctx)
  25966. if err != nil {
  25967. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25968. }
  25969. return oldValue.CreatedAt, nil
  25970. }
  25971. // ResetCreatedAt resets all changes to the "created_at" field.
  25972. func (m *SopTaskMutation) ResetCreatedAt() {
  25973. m.created_at = nil
  25974. }
  25975. // SetUpdatedAt sets the "updated_at" field.
  25976. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  25977. m.updated_at = &t
  25978. }
  25979. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25980. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  25981. v := m.updated_at
  25982. if v == nil {
  25983. return
  25984. }
  25985. return *v, true
  25986. }
  25987. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  25988. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25990. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25991. if !m.op.Is(OpUpdateOne) {
  25992. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25993. }
  25994. if m.id == nil || m.oldValue == nil {
  25995. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25996. }
  25997. oldValue, err := m.oldValue(ctx)
  25998. if err != nil {
  25999. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26000. }
  26001. return oldValue.UpdatedAt, nil
  26002. }
  26003. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26004. func (m *SopTaskMutation) ResetUpdatedAt() {
  26005. m.updated_at = nil
  26006. }
  26007. // SetStatus sets the "status" field.
  26008. func (m *SopTaskMutation) SetStatus(u uint8) {
  26009. m.status = &u
  26010. m.addstatus = nil
  26011. }
  26012. // Status returns the value of the "status" field in the mutation.
  26013. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26014. v := m.status
  26015. if v == nil {
  26016. return
  26017. }
  26018. return *v, true
  26019. }
  26020. // OldStatus returns the old "status" field's value of the SopTask entity.
  26021. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26023. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26024. if !m.op.Is(OpUpdateOne) {
  26025. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26026. }
  26027. if m.id == nil || m.oldValue == nil {
  26028. return v, errors.New("OldStatus requires an ID field in the mutation")
  26029. }
  26030. oldValue, err := m.oldValue(ctx)
  26031. if err != nil {
  26032. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26033. }
  26034. return oldValue.Status, nil
  26035. }
  26036. // AddStatus adds u to the "status" field.
  26037. func (m *SopTaskMutation) AddStatus(u int8) {
  26038. if m.addstatus != nil {
  26039. *m.addstatus += u
  26040. } else {
  26041. m.addstatus = &u
  26042. }
  26043. }
  26044. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26045. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26046. v := m.addstatus
  26047. if v == nil {
  26048. return
  26049. }
  26050. return *v, true
  26051. }
  26052. // ClearStatus clears the value of the "status" field.
  26053. func (m *SopTaskMutation) ClearStatus() {
  26054. m.status = nil
  26055. m.addstatus = nil
  26056. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26057. }
  26058. // StatusCleared returns if the "status" field was cleared in this mutation.
  26059. func (m *SopTaskMutation) StatusCleared() bool {
  26060. _, ok := m.clearedFields[soptask.FieldStatus]
  26061. return ok
  26062. }
  26063. // ResetStatus resets all changes to the "status" field.
  26064. func (m *SopTaskMutation) ResetStatus() {
  26065. m.status = nil
  26066. m.addstatus = nil
  26067. delete(m.clearedFields, soptask.FieldStatus)
  26068. }
  26069. // SetDeletedAt sets the "deleted_at" field.
  26070. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26071. m.deleted_at = &t
  26072. }
  26073. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26074. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26075. v := m.deleted_at
  26076. if v == nil {
  26077. return
  26078. }
  26079. return *v, true
  26080. }
  26081. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26082. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26084. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26085. if !m.op.Is(OpUpdateOne) {
  26086. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26087. }
  26088. if m.id == nil || m.oldValue == nil {
  26089. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26090. }
  26091. oldValue, err := m.oldValue(ctx)
  26092. if err != nil {
  26093. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26094. }
  26095. return oldValue.DeletedAt, nil
  26096. }
  26097. // ClearDeletedAt clears the value of the "deleted_at" field.
  26098. func (m *SopTaskMutation) ClearDeletedAt() {
  26099. m.deleted_at = nil
  26100. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26101. }
  26102. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26103. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26104. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26105. return ok
  26106. }
  26107. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26108. func (m *SopTaskMutation) ResetDeletedAt() {
  26109. m.deleted_at = nil
  26110. delete(m.clearedFields, soptask.FieldDeletedAt)
  26111. }
  26112. // SetName sets the "name" field.
  26113. func (m *SopTaskMutation) SetName(s string) {
  26114. m.name = &s
  26115. }
  26116. // Name returns the value of the "name" field in the mutation.
  26117. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26118. v := m.name
  26119. if v == nil {
  26120. return
  26121. }
  26122. return *v, true
  26123. }
  26124. // OldName returns the old "name" field's value of the SopTask entity.
  26125. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26127. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26128. if !m.op.Is(OpUpdateOne) {
  26129. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26130. }
  26131. if m.id == nil || m.oldValue == nil {
  26132. return v, errors.New("OldName requires an ID field in the mutation")
  26133. }
  26134. oldValue, err := m.oldValue(ctx)
  26135. if err != nil {
  26136. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26137. }
  26138. return oldValue.Name, nil
  26139. }
  26140. // ResetName resets all changes to the "name" field.
  26141. func (m *SopTaskMutation) ResetName() {
  26142. m.name = nil
  26143. }
  26144. // SetBotWxidList sets the "bot_wxid_list" field.
  26145. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26146. m.bot_wxid_list = &s
  26147. m.appendbot_wxid_list = nil
  26148. }
  26149. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26150. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26151. v := m.bot_wxid_list
  26152. if v == nil {
  26153. return
  26154. }
  26155. return *v, true
  26156. }
  26157. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26158. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26160. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26161. if !m.op.Is(OpUpdateOne) {
  26162. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26163. }
  26164. if m.id == nil || m.oldValue == nil {
  26165. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26166. }
  26167. oldValue, err := m.oldValue(ctx)
  26168. if err != nil {
  26169. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26170. }
  26171. return oldValue.BotWxidList, nil
  26172. }
  26173. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26174. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26175. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26176. }
  26177. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26178. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26179. if len(m.appendbot_wxid_list) == 0 {
  26180. return nil, false
  26181. }
  26182. return m.appendbot_wxid_list, true
  26183. }
  26184. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26185. func (m *SopTaskMutation) ClearBotWxidList() {
  26186. m.bot_wxid_list = nil
  26187. m.appendbot_wxid_list = nil
  26188. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26189. }
  26190. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26191. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26192. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26193. return ok
  26194. }
  26195. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26196. func (m *SopTaskMutation) ResetBotWxidList() {
  26197. m.bot_wxid_list = nil
  26198. m.appendbot_wxid_list = nil
  26199. delete(m.clearedFields, soptask.FieldBotWxidList)
  26200. }
  26201. // SetType sets the "type" field.
  26202. func (m *SopTaskMutation) SetType(i int) {
  26203. m._type = &i
  26204. m.add_type = nil
  26205. }
  26206. // GetType returns the value of the "type" field in the mutation.
  26207. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26208. v := m._type
  26209. if v == nil {
  26210. return
  26211. }
  26212. return *v, true
  26213. }
  26214. // OldType returns the old "type" field's value of the SopTask entity.
  26215. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26217. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26218. if !m.op.Is(OpUpdateOne) {
  26219. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26220. }
  26221. if m.id == nil || m.oldValue == nil {
  26222. return v, errors.New("OldType requires an ID field in the mutation")
  26223. }
  26224. oldValue, err := m.oldValue(ctx)
  26225. if err != nil {
  26226. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26227. }
  26228. return oldValue.Type, nil
  26229. }
  26230. // AddType adds i to the "type" field.
  26231. func (m *SopTaskMutation) AddType(i int) {
  26232. if m.add_type != nil {
  26233. *m.add_type += i
  26234. } else {
  26235. m.add_type = &i
  26236. }
  26237. }
  26238. // AddedType returns the value that was added to the "type" field in this mutation.
  26239. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26240. v := m.add_type
  26241. if v == nil {
  26242. return
  26243. }
  26244. return *v, true
  26245. }
  26246. // ResetType resets all changes to the "type" field.
  26247. func (m *SopTaskMutation) ResetType() {
  26248. m._type = nil
  26249. m.add_type = nil
  26250. }
  26251. // SetPlanStartTime sets the "plan_start_time" field.
  26252. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26253. m.plan_start_time = &t
  26254. }
  26255. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26256. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26257. v := m.plan_start_time
  26258. if v == nil {
  26259. return
  26260. }
  26261. return *v, true
  26262. }
  26263. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26264. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26266. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26267. if !m.op.Is(OpUpdateOne) {
  26268. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26269. }
  26270. if m.id == nil || m.oldValue == nil {
  26271. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26272. }
  26273. oldValue, err := m.oldValue(ctx)
  26274. if err != nil {
  26275. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26276. }
  26277. return oldValue.PlanStartTime, nil
  26278. }
  26279. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26280. func (m *SopTaskMutation) ClearPlanStartTime() {
  26281. m.plan_start_time = nil
  26282. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26283. }
  26284. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26285. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26286. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26287. return ok
  26288. }
  26289. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26290. func (m *SopTaskMutation) ResetPlanStartTime() {
  26291. m.plan_start_time = nil
  26292. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26293. }
  26294. // SetPlanEndTime sets the "plan_end_time" field.
  26295. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26296. m.plan_end_time = &t
  26297. }
  26298. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26299. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26300. v := m.plan_end_time
  26301. if v == nil {
  26302. return
  26303. }
  26304. return *v, true
  26305. }
  26306. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26307. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26309. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26310. if !m.op.Is(OpUpdateOne) {
  26311. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26312. }
  26313. if m.id == nil || m.oldValue == nil {
  26314. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26315. }
  26316. oldValue, err := m.oldValue(ctx)
  26317. if err != nil {
  26318. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26319. }
  26320. return oldValue.PlanEndTime, nil
  26321. }
  26322. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26323. func (m *SopTaskMutation) ClearPlanEndTime() {
  26324. m.plan_end_time = nil
  26325. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26326. }
  26327. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26328. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26329. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26330. return ok
  26331. }
  26332. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26333. func (m *SopTaskMutation) ResetPlanEndTime() {
  26334. m.plan_end_time = nil
  26335. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26336. }
  26337. // SetCreatorID sets the "creator_id" field.
  26338. func (m *SopTaskMutation) SetCreatorID(s string) {
  26339. m.creator_id = &s
  26340. }
  26341. // CreatorID returns the value of the "creator_id" field in the mutation.
  26342. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26343. v := m.creator_id
  26344. if v == nil {
  26345. return
  26346. }
  26347. return *v, true
  26348. }
  26349. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26350. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26352. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26353. if !m.op.Is(OpUpdateOne) {
  26354. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26355. }
  26356. if m.id == nil || m.oldValue == nil {
  26357. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26358. }
  26359. oldValue, err := m.oldValue(ctx)
  26360. if err != nil {
  26361. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26362. }
  26363. return oldValue.CreatorID, nil
  26364. }
  26365. // ClearCreatorID clears the value of the "creator_id" field.
  26366. func (m *SopTaskMutation) ClearCreatorID() {
  26367. m.creator_id = nil
  26368. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26369. }
  26370. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26371. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26372. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26373. return ok
  26374. }
  26375. // ResetCreatorID resets all changes to the "creator_id" field.
  26376. func (m *SopTaskMutation) ResetCreatorID() {
  26377. m.creator_id = nil
  26378. delete(m.clearedFields, soptask.FieldCreatorID)
  26379. }
  26380. // SetOrganizationID sets the "organization_id" field.
  26381. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26382. m.organization_id = &u
  26383. m.addorganization_id = nil
  26384. }
  26385. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26386. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26387. v := m.organization_id
  26388. if v == nil {
  26389. return
  26390. }
  26391. return *v, true
  26392. }
  26393. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26394. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26396. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26397. if !m.op.Is(OpUpdateOne) {
  26398. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26399. }
  26400. if m.id == nil || m.oldValue == nil {
  26401. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26402. }
  26403. oldValue, err := m.oldValue(ctx)
  26404. if err != nil {
  26405. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26406. }
  26407. return oldValue.OrganizationID, nil
  26408. }
  26409. // AddOrganizationID adds u to the "organization_id" field.
  26410. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26411. if m.addorganization_id != nil {
  26412. *m.addorganization_id += u
  26413. } else {
  26414. m.addorganization_id = &u
  26415. }
  26416. }
  26417. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26418. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26419. v := m.addorganization_id
  26420. if v == nil {
  26421. return
  26422. }
  26423. return *v, true
  26424. }
  26425. // ClearOrganizationID clears the value of the "organization_id" field.
  26426. func (m *SopTaskMutation) ClearOrganizationID() {
  26427. m.organization_id = nil
  26428. m.addorganization_id = nil
  26429. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26430. }
  26431. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26432. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26433. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26434. return ok
  26435. }
  26436. // ResetOrganizationID resets all changes to the "organization_id" field.
  26437. func (m *SopTaskMutation) ResetOrganizationID() {
  26438. m.organization_id = nil
  26439. m.addorganization_id = nil
  26440. delete(m.clearedFields, soptask.FieldOrganizationID)
  26441. }
  26442. // SetToken sets the "token" field.
  26443. func (m *SopTaskMutation) SetToken(s []string) {
  26444. m.token = &s
  26445. m.appendtoken = nil
  26446. }
  26447. // Token returns the value of the "token" field in the mutation.
  26448. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26449. v := m.token
  26450. if v == nil {
  26451. return
  26452. }
  26453. return *v, true
  26454. }
  26455. // OldToken returns the old "token" field's value of the SopTask entity.
  26456. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26458. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26459. if !m.op.Is(OpUpdateOne) {
  26460. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26461. }
  26462. if m.id == nil || m.oldValue == nil {
  26463. return v, errors.New("OldToken requires an ID field in the mutation")
  26464. }
  26465. oldValue, err := m.oldValue(ctx)
  26466. if err != nil {
  26467. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26468. }
  26469. return oldValue.Token, nil
  26470. }
  26471. // AppendToken adds s to the "token" field.
  26472. func (m *SopTaskMutation) AppendToken(s []string) {
  26473. m.appendtoken = append(m.appendtoken, s...)
  26474. }
  26475. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26476. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26477. if len(m.appendtoken) == 0 {
  26478. return nil, false
  26479. }
  26480. return m.appendtoken, true
  26481. }
  26482. // ClearToken clears the value of the "token" field.
  26483. func (m *SopTaskMutation) ClearToken() {
  26484. m.token = nil
  26485. m.appendtoken = nil
  26486. m.clearedFields[soptask.FieldToken] = struct{}{}
  26487. }
  26488. // TokenCleared returns if the "token" field was cleared in this mutation.
  26489. func (m *SopTaskMutation) TokenCleared() bool {
  26490. _, ok := m.clearedFields[soptask.FieldToken]
  26491. return ok
  26492. }
  26493. // ResetToken resets all changes to the "token" field.
  26494. func (m *SopTaskMutation) ResetToken() {
  26495. m.token = nil
  26496. m.appendtoken = nil
  26497. delete(m.clearedFields, soptask.FieldToken)
  26498. }
  26499. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26500. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26501. if m.task_stages == nil {
  26502. m.task_stages = make(map[uint64]struct{})
  26503. }
  26504. for i := range ids {
  26505. m.task_stages[ids[i]] = struct{}{}
  26506. }
  26507. }
  26508. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26509. func (m *SopTaskMutation) ClearTaskStages() {
  26510. m.clearedtask_stages = true
  26511. }
  26512. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26513. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26514. return m.clearedtask_stages
  26515. }
  26516. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26517. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26518. if m.removedtask_stages == nil {
  26519. m.removedtask_stages = make(map[uint64]struct{})
  26520. }
  26521. for i := range ids {
  26522. delete(m.task_stages, ids[i])
  26523. m.removedtask_stages[ids[i]] = struct{}{}
  26524. }
  26525. }
  26526. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26527. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26528. for id := range m.removedtask_stages {
  26529. ids = append(ids, id)
  26530. }
  26531. return
  26532. }
  26533. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26534. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26535. for id := range m.task_stages {
  26536. ids = append(ids, id)
  26537. }
  26538. return
  26539. }
  26540. // ResetTaskStages resets all changes to the "task_stages" edge.
  26541. func (m *SopTaskMutation) ResetTaskStages() {
  26542. m.task_stages = nil
  26543. m.clearedtask_stages = false
  26544. m.removedtask_stages = nil
  26545. }
  26546. // Where appends a list predicates to the SopTaskMutation builder.
  26547. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26548. m.predicates = append(m.predicates, ps...)
  26549. }
  26550. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26551. // users can use type-assertion to append predicates that do not depend on any generated package.
  26552. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26553. p := make([]predicate.SopTask, len(ps))
  26554. for i := range ps {
  26555. p[i] = ps[i]
  26556. }
  26557. m.Where(p...)
  26558. }
  26559. // Op returns the operation name.
  26560. func (m *SopTaskMutation) Op() Op {
  26561. return m.op
  26562. }
  26563. // SetOp allows setting the mutation operation.
  26564. func (m *SopTaskMutation) SetOp(op Op) {
  26565. m.op = op
  26566. }
  26567. // Type returns the node type of this mutation (SopTask).
  26568. func (m *SopTaskMutation) Type() string {
  26569. return m.typ
  26570. }
  26571. // Fields returns all fields that were changed during this mutation. Note that in
  26572. // order to get all numeric fields that were incremented/decremented, call
  26573. // AddedFields().
  26574. func (m *SopTaskMutation) Fields() []string {
  26575. fields := make([]string, 0, 12)
  26576. if m.created_at != nil {
  26577. fields = append(fields, soptask.FieldCreatedAt)
  26578. }
  26579. if m.updated_at != nil {
  26580. fields = append(fields, soptask.FieldUpdatedAt)
  26581. }
  26582. if m.status != nil {
  26583. fields = append(fields, soptask.FieldStatus)
  26584. }
  26585. if m.deleted_at != nil {
  26586. fields = append(fields, soptask.FieldDeletedAt)
  26587. }
  26588. if m.name != nil {
  26589. fields = append(fields, soptask.FieldName)
  26590. }
  26591. if m.bot_wxid_list != nil {
  26592. fields = append(fields, soptask.FieldBotWxidList)
  26593. }
  26594. if m._type != nil {
  26595. fields = append(fields, soptask.FieldType)
  26596. }
  26597. if m.plan_start_time != nil {
  26598. fields = append(fields, soptask.FieldPlanStartTime)
  26599. }
  26600. if m.plan_end_time != nil {
  26601. fields = append(fields, soptask.FieldPlanEndTime)
  26602. }
  26603. if m.creator_id != nil {
  26604. fields = append(fields, soptask.FieldCreatorID)
  26605. }
  26606. if m.organization_id != nil {
  26607. fields = append(fields, soptask.FieldOrganizationID)
  26608. }
  26609. if m.token != nil {
  26610. fields = append(fields, soptask.FieldToken)
  26611. }
  26612. return fields
  26613. }
  26614. // Field returns the value of a field with the given name. The second boolean
  26615. // return value indicates that this field was not set, or was not defined in the
  26616. // schema.
  26617. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26618. switch name {
  26619. case soptask.FieldCreatedAt:
  26620. return m.CreatedAt()
  26621. case soptask.FieldUpdatedAt:
  26622. return m.UpdatedAt()
  26623. case soptask.FieldStatus:
  26624. return m.Status()
  26625. case soptask.FieldDeletedAt:
  26626. return m.DeletedAt()
  26627. case soptask.FieldName:
  26628. return m.Name()
  26629. case soptask.FieldBotWxidList:
  26630. return m.BotWxidList()
  26631. case soptask.FieldType:
  26632. return m.GetType()
  26633. case soptask.FieldPlanStartTime:
  26634. return m.PlanStartTime()
  26635. case soptask.FieldPlanEndTime:
  26636. return m.PlanEndTime()
  26637. case soptask.FieldCreatorID:
  26638. return m.CreatorID()
  26639. case soptask.FieldOrganizationID:
  26640. return m.OrganizationID()
  26641. case soptask.FieldToken:
  26642. return m.Token()
  26643. }
  26644. return nil, false
  26645. }
  26646. // OldField returns the old value of the field from the database. An error is
  26647. // returned if the mutation operation is not UpdateOne, or the query to the
  26648. // database failed.
  26649. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26650. switch name {
  26651. case soptask.FieldCreatedAt:
  26652. return m.OldCreatedAt(ctx)
  26653. case soptask.FieldUpdatedAt:
  26654. return m.OldUpdatedAt(ctx)
  26655. case soptask.FieldStatus:
  26656. return m.OldStatus(ctx)
  26657. case soptask.FieldDeletedAt:
  26658. return m.OldDeletedAt(ctx)
  26659. case soptask.FieldName:
  26660. return m.OldName(ctx)
  26661. case soptask.FieldBotWxidList:
  26662. return m.OldBotWxidList(ctx)
  26663. case soptask.FieldType:
  26664. return m.OldType(ctx)
  26665. case soptask.FieldPlanStartTime:
  26666. return m.OldPlanStartTime(ctx)
  26667. case soptask.FieldPlanEndTime:
  26668. return m.OldPlanEndTime(ctx)
  26669. case soptask.FieldCreatorID:
  26670. return m.OldCreatorID(ctx)
  26671. case soptask.FieldOrganizationID:
  26672. return m.OldOrganizationID(ctx)
  26673. case soptask.FieldToken:
  26674. return m.OldToken(ctx)
  26675. }
  26676. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26677. }
  26678. // SetField sets the value of a field with the given name. It returns an error if
  26679. // the field is not defined in the schema, or if the type mismatched the field
  26680. // type.
  26681. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26682. switch name {
  26683. case soptask.FieldCreatedAt:
  26684. v, ok := value.(time.Time)
  26685. if !ok {
  26686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26687. }
  26688. m.SetCreatedAt(v)
  26689. return nil
  26690. case soptask.FieldUpdatedAt:
  26691. v, ok := value.(time.Time)
  26692. if !ok {
  26693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26694. }
  26695. m.SetUpdatedAt(v)
  26696. return nil
  26697. case soptask.FieldStatus:
  26698. v, ok := value.(uint8)
  26699. if !ok {
  26700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26701. }
  26702. m.SetStatus(v)
  26703. return nil
  26704. case soptask.FieldDeletedAt:
  26705. v, ok := value.(time.Time)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.SetDeletedAt(v)
  26710. return nil
  26711. case soptask.FieldName:
  26712. v, ok := value.(string)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.SetName(v)
  26717. return nil
  26718. case soptask.FieldBotWxidList:
  26719. v, ok := value.([]string)
  26720. if !ok {
  26721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26722. }
  26723. m.SetBotWxidList(v)
  26724. return nil
  26725. case soptask.FieldType:
  26726. v, ok := value.(int)
  26727. if !ok {
  26728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26729. }
  26730. m.SetType(v)
  26731. return nil
  26732. case soptask.FieldPlanStartTime:
  26733. v, ok := value.(time.Time)
  26734. if !ok {
  26735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26736. }
  26737. m.SetPlanStartTime(v)
  26738. return nil
  26739. case soptask.FieldPlanEndTime:
  26740. v, ok := value.(time.Time)
  26741. if !ok {
  26742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26743. }
  26744. m.SetPlanEndTime(v)
  26745. return nil
  26746. case soptask.FieldCreatorID:
  26747. v, ok := value.(string)
  26748. if !ok {
  26749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26750. }
  26751. m.SetCreatorID(v)
  26752. return nil
  26753. case soptask.FieldOrganizationID:
  26754. v, ok := value.(uint64)
  26755. if !ok {
  26756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26757. }
  26758. m.SetOrganizationID(v)
  26759. return nil
  26760. case soptask.FieldToken:
  26761. v, ok := value.([]string)
  26762. if !ok {
  26763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26764. }
  26765. m.SetToken(v)
  26766. return nil
  26767. }
  26768. return fmt.Errorf("unknown SopTask field %s", name)
  26769. }
  26770. // AddedFields returns all numeric fields that were incremented/decremented during
  26771. // this mutation.
  26772. func (m *SopTaskMutation) AddedFields() []string {
  26773. var fields []string
  26774. if m.addstatus != nil {
  26775. fields = append(fields, soptask.FieldStatus)
  26776. }
  26777. if m.add_type != nil {
  26778. fields = append(fields, soptask.FieldType)
  26779. }
  26780. if m.addorganization_id != nil {
  26781. fields = append(fields, soptask.FieldOrganizationID)
  26782. }
  26783. return fields
  26784. }
  26785. // AddedField returns the numeric value that was incremented/decremented on a field
  26786. // with the given name. The second boolean return value indicates that this field
  26787. // was not set, or was not defined in the schema.
  26788. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26789. switch name {
  26790. case soptask.FieldStatus:
  26791. return m.AddedStatus()
  26792. case soptask.FieldType:
  26793. return m.AddedType()
  26794. case soptask.FieldOrganizationID:
  26795. return m.AddedOrganizationID()
  26796. }
  26797. return nil, false
  26798. }
  26799. // AddField adds the value to the field with the given name. It returns an error if
  26800. // the field is not defined in the schema, or if the type mismatched the field
  26801. // type.
  26802. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26803. switch name {
  26804. case soptask.FieldStatus:
  26805. v, ok := value.(int8)
  26806. if !ok {
  26807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26808. }
  26809. m.AddStatus(v)
  26810. return nil
  26811. case soptask.FieldType:
  26812. v, ok := value.(int)
  26813. if !ok {
  26814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26815. }
  26816. m.AddType(v)
  26817. return nil
  26818. case soptask.FieldOrganizationID:
  26819. v, ok := value.(int64)
  26820. if !ok {
  26821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26822. }
  26823. m.AddOrganizationID(v)
  26824. return nil
  26825. }
  26826. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26827. }
  26828. // ClearedFields returns all nullable fields that were cleared during this
  26829. // mutation.
  26830. func (m *SopTaskMutation) ClearedFields() []string {
  26831. var fields []string
  26832. if m.FieldCleared(soptask.FieldStatus) {
  26833. fields = append(fields, soptask.FieldStatus)
  26834. }
  26835. if m.FieldCleared(soptask.FieldDeletedAt) {
  26836. fields = append(fields, soptask.FieldDeletedAt)
  26837. }
  26838. if m.FieldCleared(soptask.FieldBotWxidList) {
  26839. fields = append(fields, soptask.FieldBotWxidList)
  26840. }
  26841. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26842. fields = append(fields, soptask.FieldPlanStartTime)
  26843. }
  26844. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26845. fields = append(fields, soptask.FieldPlanEndTime)
  26846. }
  26847. if m.FieldCleared(soptask.FieldCreatorID) {
  26848. fields = append(fields, soptask.FieldCreatorID)
  26849. }
  26850. if m.FieldCleared(soptask.FieldOrganizationID) {
  26851. fields = append(fields, soptask.FieldOrganizationID)
  26852. }
  26853. if m.FieldCleared(soptask.FieldToken) {
  26854. fields = append(fields, soptask.FieldToken)
  26855. }
  26856. return fields
  26857. }
  26858. // FieldCleared returns a boolean indicating if a field with the given name was
  26859. // cleared in this mutation.
  26860. func (m *SopTaskMutation) FieldCleared(name string) bool {
  26861. _, ok := m.clearedFields[name]
  26862. return ok
  26863. }
  26864. // ClearField clears the value of the field with the given name. It returns an
  26865. // error if the field is not defined in the schema.
  26866. func (m *SopTaskMutation) ClearField(name string) error {
  26867. switch name {
  26868. case soptask.FieldStatus:
  26869. m.ClearStatus()
  26870. return nil
  26871. case soptask.FieldDeletedAt:
  26872. m.ClearDeletedAt()
  26873. return nil
  26874. case soptask.FieldBotWxidList:
  26875. m.ClearBotWxidList()
  26876. return nil
  26877. case soptask.FieldPlanStartTime:
  26878. m.ClearPlanStartTime()
  26879. return nil
  26880. case soptask.FieldPlanEndTime:
  26881. m.ClearPlanEndTime()
  26882. return nil
  26883. case soptask.FieldCreatorID:
  26884. m.ClearCreatorID()
  26885. return nil
  26886. case soptask.FieldOrganizationID:
  26887. m.ClearOrganizationID()
  26888. return nil
  26889. case soptask.FieldToken:
  26890. m.ClearToken()
  26891. return nil
  26892. }
  26893. return fmt.Errorf("unknown SopTask nullable field %s", name)
  26894. }
  26895. // ResetField resets all changes in the mutation for the field with the given name.
  26896. // It returns an error if the field is not defined in the schema.
  26897. func (m *SopTaskMutation) ResetField(name string) error {
  26898. switch name {
  26899. case soptask.FieldCreatedAt:
  26900. m.ResetCreatedAt()
  26901. return nil
  26902. case soptask.FieldUpdatedAt:
  26903. m.ResetUpdatedAt()
  26904. return nil
  26905. case soptask.FieldStatus:
  26906. m.ResetStatus()
  26907. return nil
  26908. case soptask.FieldDeletedAt:
  26909. m.ResetDeletedAt()
  26910. return nil
  26911. case soptask.FieldName:
  26912. m.ResetName()
  26913. return nil
  26914. case soptask.FieldBotWxidList:
  26915. m.ResetBotWxidList()
  26916. return nil
  26917. case soptask.FieldType:
  26918. m.ResetType()
  26919. return nil
  26920. case soptask.FieldPlanStartTime:
  26921. m.ResetPlanStartTime()
  26922. return nil
  26923. case soptask.FieldPlanEndTime:
  26924. m.ResetPlanEndTime()
  26925. return nil
  26926. case soptask.FieldCreatorID:
  26927. m.ResetCreatorID()
  26928. return nil
  26929. case soptask.FieldOrganizationID:
  26930. m.ResetOrganizationID()
  26931. return nil
  26932. case soptask.FieldToken:
  26933. m.ResetToken()
  26934. return nil
  26935. }
  26936. return fmt.Errorf("unknown SopTask field %s", name)
  26937. }
  26938. // AddedEdges returns all edge names that were set/added in this mutation.
  26939. func (m *SopTaskMutation) AddedEdges() []string {
  26940. edges := make([]string, 0, 1)
  26941. if m.task_stages != nil {
  26942. edges = append(edges, soptask.EdgeTaskStages)
  26943. }
  26944. return edges
  26945. }
  26946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26947. // name in this mutation.
  26948. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  26949. switch name {
  26950. case soptask.EdgeTaskStages:
  26951. ids := make([]ent.Value, 0, len(m.task_stages))
  26952. for id := range m.task_stages {
  26953. ids = append(ids, id)
  26954. }
  26955. return ids
  26956. }
  26957. return nil
  26958. }
  26959. // RemovedEdges returns all edge names that were removed in this mutation.
  26960. func (m *SopTaskMutation) RemovedEdges() []string {
  26961. edges := make([]string, 0, 1)
  26962. if m.removedtask_stages != nil {
  26963. edges = append(edges, soptask.EdgeTaskStages)
  26964. }
  26965. return edges
  26966. }
  26967. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26968. // the given name in this mutation.
  26969. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  26970. switch name {
  26971. case soptask.EdgeTaskStages:
  26972. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  26973. for id := range m.removedtask_stages {
  26974. ids = append(ids, id)
  26975. }
  26976. return ids
  26977. }
  26978. return nil
  26979. }
  26980. // ClearedEdges returns all edge names that were cleared in this mutation.
  26981. func (m *SopTaskMutation) ClearedEdges() []string {
  26982. edges := make([]string, 0, 1)
  26983. if m.clearedtask_stages {
  26984. edges = append(edges, soptask.EdgeTaskStages)
  26985. }
  26986. return edges
  26987. }
  26988. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26989. // was cleared in this mutation.
  26990. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  26991. switch name {
  26992. case soptask.EdgeTaskStages:
  26993. return m.clearedtask_stages
  26994. }
  26995. return false
  26996. }
  26997. // ClearEdge clears the value of the edge with the given name. It returns an error
  26998. // if that edge is not defined in the schema.
  26999. func (m *SopTaskMutation) ClearEdge(name string) error {
  27000. switch name {
  27001. }
  27002. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27003. }
  27004. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27005. // It returns an error if the edge is not defined in the schema.
  27006. func (m *SopTaskMutation) ResetEdge(name string) error {
  27007. switch name {
  27008. case soptask.EdgeTaskStages:
  27009. m.ResetTaskStages()
  27010. return nil
  27011. }
  27012. return fmt.Errorf("unknown SopTask edge %s", name)
  27013. }
  27014. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27015. type TokenMutation struct {
  27016. config
  27017. op Op
  27018. typ string
  27019. id *uint64
  27020. created_at *time.Time
  27021. updated_at *time.Time
  27022. deleted_at *time.Time
  27023. expire_at *time.Time
  27024. token *string
  27025. mac *string
  27026. organization_id *uint64
  27027. addorganization_id *int64
  27028. custom_agent_base *string
  27029. custom_agent_key *string
  27030. openai_base *string
  27031. openai_key *string
  27032. clearedFields map[string]struct{}
  27033. agent *uint64
  27034. clearedagent bool
  27035. done bool
  27036. oldValue func(context.Context) (*Token, error)
  27037. predicates []predicate.Token
  27038. }
  27039. var _ ent.Mutation = (*TokenMutation)(nil)
  27040. // tokenOption allows management of the mutation configuration using functional options.
  27041. type tokenOption func(*TokenMutation)
  27042. // newTokenMutation creates new mutation for the Token entity.
  27043. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27044. m := &TokenMutation{
  27045. config: c,
  27046. op: op,
  27047. typ: TypeToken,
  27048. clearedFields: make(map[string]struct{}),
  27049. }
  27050. for _, opt := range opts {
  27051. opt(m)
  27052. }
  27053. return m
  27054. }
  27055. // withTokenID sets the ID field of the mutation.
  27056. func withTokenID(id uint64) tokenOption {
  27057. return func(m *TokenMutation) {
  27058. var (
  27059. err error
  27060. once sync.Once
  27061. value *Token
  27062. )
  27063. m.oldValue = func(ctx context.Context) (*Token, error) {
  27064. once.Do(func() {
  27065. if m.done {
  27066. err = errors.New("querying old values post mutation is not allowed")
  27067. } else {
  27068. value, err = m.Client().Token.Get(ctx, id)
  27069. }
  27070. })
  27071. return value, err
  27072. }
  27073. m.id = &id
  27074. }
  27075. }
  27076. // withToken sets the old Token of the mutation.
  27077. func withToken(node *Token) tokenOption {
  27078. return func(m *TokenMutation) {
  27079. m.oldValue = func(context.Context) (*Token, error) {
  27080. return node, nil
  27081. }
  27082. m.id = &node.ID
  27083. }
  27084. }
  27085. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27086. // executed in a transaction (ent.Tx), a transactional client is returned.
  27087. func (m TokenMutation) Client() *Client {
  27088. client := &Client{config: m.config}
  27089. client.init()
  27090. return client
  27091. }
  27092. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27093. // it returns an error otherwise.
  27094. func (m TokenMutation) Tx() (*Tx, error) {
  27095. if _, ok := m.driver.(*txDriver); !ok {
  27096. return nil, errors.New("ent: mutation is not running in a transaction")
  27097. }
  27098. tx := &Tx{config: m.config}
  27099. tx.init()
  27100. return tx, nil
  27101. }
  27102. // SetID sets the value of the id field. Note that this
  27103. // operation is only accepted on creation of Token entities.
  27104. func (m *TokenMutation) SetID(id uint64) {
  27105. m.id = &id
  27106. }
  27107. // ID returns the ID value in the mutation. Note that the ID is only available
  27108. // if it was provided to the builder or after it was returned from the database.
  27109. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27110. if m.id == nil {
  27111. return
  27112. }
  27113. return *m.id, true
  27114. }
  27115. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27116. // That means, if the mutation is applied within a transaction with an isolation level such
  27117. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27118. // or updated by the mutation.
  27119. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27120. switch {
  27121. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27122. id, exists := m.ID()
  27123. if exists {
  27124. return []uint64{id}, nil
  27125. }
  27126. fallthrough
  27127. case m.op.Is(OpUpdate | OpDelete):
  27128. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27129. default:
  27130. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27131. }
  27132. }
  27133. // SetCreatedAt sets the "created_at" field.
  27134. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27135. m.created_at = &t
  27136. }
  27137. // CreatedAt returns the value of the "created_at" field in the mutation.
  27138. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27139. v := m.created_at
  27140. if v == nil {
  27141. return
  27142. }
  27143. return *v, true
  27144. }
  27145. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27146. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27148. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27149. if !m.op.Is(OpUpdateOne) {
  27150. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27151. }
  27152. if m.id == nil || m.oldValue == nil {
  27153. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27154. }
  27155. oldValue, err := m.oldValue(ctx)
  27156. if err != nil {
  27157. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27158. }
  27159. return oldValue.CreatedAt, nil
  27160. }
  27161. // ResetCreatedAt resets all changes to the "created_at" field.
  27162. func (m *TokenMutation) ResetCreatedAt() {
  27163. m.created_at = nil
  27164. }
  27165. // SetUpdatedAt sets the "updated_at" field.
  27166. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27167. m.updated_at = &t
  27168. }
  27169. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27170. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27171. v := m.updated_at
  27172. if v == nil {
  27173. return
  27174. }
  27175. return *v, true
  27176. }
  27177. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27178. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27180. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27181. if !m.op.Is(OpUpdateOne) {
  27182. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27183. }
  27184. if m.id == nil || m.oldValue == nil {
  27185. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27186. }
  27187. oldValue, err := m.oldValue(ctx)
  27188. if err != nil {
  27189. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27190. }
  27191. return oldValue.UpdatedAt, nil
  27192. }
  27193. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27194. func (m *TokenMutation) ResetUpdatedAt() {
  27195. m.updated_at = nil
  27196. }
  27197. // SetDeletedAt sets the "deleted_at" field.
  27198. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27199. m.deleted_at = &t
  27200. }
  27201. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27202. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27203. v := m.deleted_at
  27204. if v == nil {
  27205. return
  27206. }
  27207. return *v, true
  27208. }
  27209. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27210. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27212. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27213. if !m.op.Is(OpUpdateOne) {
  27214. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27215. }
  27216. if m.id == nil || m.oldValue == nil {
  27217. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27218. }
  27219. oldValue, err := m.oldValue(ctx)
  27220. if err != nil {
  27221. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27222. }
  27223. return oldValue.DeletedAt, nil
  27224. }
  27225. // ClearDeletedAt clears the value of the "deleted_at" field.
  27226. func (m *TokenMutation) ClearDeletedAt() {
  27227. m.deleted_at = nil
  27228. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27229. }
  27230. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27231. func (m *TokenMutation) DeletedAtCleared() bool {
  27232. _, ok := m.clearedFields[token.FieldDeletedAt]
  27233. return ok
  27234. }
  27235. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27236. func (m *TokenMutation) ResetDeletedAt() {
  27237. m.deleted_at = nil
  27238. delete(m.clearedFields, token.FieldDeletedAt)
  27239. }
  27240. // SetExpireAt sets the "expire_at" field.
  27241. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27242. m.expire_at = &t
  27243. }
  27244. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27245. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27246. v := m.expire_at
  27247. if v == nil {
  27248. return
  27249. }
  27250. return *v, true
  27251. }
  27252. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27253. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27255. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27256. if !m.op.Is(OpUpdateOne) {
  27257. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27258. }
  27259. if m.id == nil || m.oldValue == nil {
  27260. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27261. }
  27262. oldValue, err := m.oldValue(ctx)
  27263. if err != nil {
  27264. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27265. }
  27266. return oldValue.ExpireAt, nil
  27267. }
  27268. // ClearExpireAt clears the value of the "expire_at" field.
  27269. func (m *TokenMutation) ClearExpireAt() {
  27270. m.expire_at = nil
  27271. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27272. }
  27273. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27274. func (m *TokenMutation) ExpireAtCleared() bool {
  27275. _, ok := m.clearedFields[token.FieldExpireAt]
  27276. return ok
  27277. }
  27278. // ResetExpireAt resets all changes to the "expire_at" field.
  27279. func (m *TokenMutation) ResetExpireAt() {
  27280. m.expire_at = nil
  27281. delete(m.clearedFields, token.FieldExpireAt)
  27282. }
  27283. // SetToken sets the "token" field.
  27284. func (m *TokenMutation) SetToken(s string) {
  27285. m.token = &s
  27286. }
  27287. // Token returns the value of the "token" field in the mutation.
  27288. func (m *TokenMutation) Token() (r string, exists bool) {
  27289. v := m.token
  27290. if v == nil {
  27291. return
  27292. }
  27293. return *v, true
  27294. }
  27295. // OldToken returns the old "token" field's value of the Token entity.
  27296. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27298. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27299. if !m.op.Is(OpUpdateOne) {
  27300. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27301. }
  27302. if m.id == nil || m.oldValue == nil {
  27303. return v, errors.New("OldToken requires an ID field in the mutation")
  27304. }
  27305. oldValue, err := m.oldValue(ctx)
  27306. if err != nil {
  27307. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27308. }
  27309. return oldValue.Token, nil
  27310. }
  27311. // ClearToken clears the value of the "token" field.
  27312. func (m *TokenMutation) ClearToken() {
  27313. m.token = nil
  27314. m.clearedFields[token.FieldToken] = struct{}{}
  27315. }
  27316. // TokenCleared returns if the "token" field was cleared in this mutation.
  27317. func (m *TokenMutation) TokenCleared() bool {
  27318. _, ok := m.clearedFields[token.FieldToken]
  27319. return ok
  27320. }
  27321. // ResetToken resets all changes to the "token" field.
  27322. func (m *TokenMutation) ResetToken() {
  27323. m.token = nil
  27324. delete(m.clearedFields, token.FieldToken)
  27325. }
  27326. // SetMAC sets the "mac" field.
  27327. func (m *TokenMutation) SetMAC(s string) {
  27328. m.mac = &s
  27329. }
  27330. // MAC returns the value of the "mac" field in the mutation.
  27331. func (m *TokenMutation) MAC() (r string, exists bool) {
  27332. v := m.mac
  27333. if v == nil {
  27334. return
  27335. }
  27336. return *v, true
  27337. }
  27338. // OldMAC returns the old "mac" field's value of the Token entity.
  27339. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27341. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27342. if !m.op.Is(OpUpdateOne) {
  27343. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27344. }
  27345. if m.id == nil || m.oldValue == nil {
  27346. return v, errors.New("OldMAC requires an ID field in the mutation")
  27347. }
  27348. oldValue, err := m.oldValue(ctx)
  27349. if err != nil {
  27350. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27351. }
  27352. return oldValue.MAC, nil
  27353. }
  27354. // ClearMAC clears the value of the "mac" field.
  27355. func (m *TokenMutation) ClearMAC() {
  27356. m.mac = nil
  27357. m.clearedFields[token.FieldMAC] = struct{}{}
  27358. }
  27359. // MACCleared returns if the "mac" field was cleared in this mutation.
  27360. func (m *TokenMutation) MACCleared() bool {
  27361. _, ok := m.clearedFields[token.FieldMAC]
  27362. return ok
  27363. }
  27364. // ResetMAC resets all changes to the "mac" field.
  27365. func (m *TokenMutation) ResetMAC() {
  27366. m.mac = nil
  27367. delete(m.clearedFields, token.FieldMAC)
  27368. }
  27369. // SetOrganizationID sets the "organization_id" field.
  27370. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27371. m.organization_id = &u
  27372. m.addorganization_id = nil
  27373. }
  27374. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27375. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27376. v := m.organization_id
  27377. if v == nil {
  27378. return
  27379. }
  27380. return *v, true
  27381. }
  27382. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27383. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27385. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27386. if !m.op.Is(OpUpdateOne) {
  27387. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27388. }
  27389. if m.id == nil || m.oldValue == nil {
  27390. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27391. }
  27392. oldValue, err := m.oldValue(ctx)
  27393. if err != nil {
  27394. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27395. }
  27396. return oldValue.OrganizationID, nil
  27397. }
  27398. // AddOrganizationID adds u to the "organization_id" field.
  27399. func (m *TokenMutation) AddOrganizationID(u int64) {
  27400. if m.addorganization_id != nil {
  27401. *m.addorganization_id += u
  27402. } else {
  27403. m.addorganization_id = &u
  27404. }
  27405. }
  27406. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27407. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27408. v := m.addorganization_id
  27409. if v == nil {
  27410. return
  27411. }
  27412. return *v, true
  27413. }
  27414. // ResetOrganizationID resets all changes to the "organization_id" field.
  27415. func (m *TokenMutation) ResetOrganizationID() {
  27416. m.organization_id = nil
  27417. m.addorganization_id = nil
  27418. }
  27419. // SetAgentID sets the "agent_id" field.
  27420. func (m *TokenMutation) SetAgentID(u uint64) {
  27421. m.agent = &u
  27422. }
  27423. // AgentID returns the value of the "agent_id" field in the mutation.
  27424. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27425. v := m.agent
  27426. if v == nil {
  27427. return
  27428. }
  27429. return *v, true
  27430. }
  27431. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27432. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27434. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27435. if !m.op.Is(OpUpdateOne) {
  27436. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27437. }
  27438. if m.id == nil || m.oldValue == nil {
  27439. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27440. }
  27441. oldValue, err := m.oldValue(ctx)
  27442. if err != nil {
  27443. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27444. }
  27445. return oldValue.AgentID, nil
  27446. }
  27447. // ResetAgentID resets all changes to the "agent_id" field.
  27448. func (m *TokenMutation) ResetAgentID() {
  27449. m.agent = nil
  27450. }
  27451. // SetCustomAgentBase sets the "custom_agent_base" field.
  27452. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27453. m.custom_agent_base = &s
  27454. }
  27455. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27456. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27457. v := m.custom_agent_base
  27458. if v == nil {
  27459. return
  27460. }
  27461. return *v, true
  27462. }
  27463. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27464. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27466. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27467. if !m.op.Is(OpUpdateOne) {
  27468. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27469. }
  27470. if m.id == nil || m.oldValue == nil {
  27471. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27472. }
  27473. oldValue, err := m.oldValue(ctx)
  27474. if err != nil {
  27475. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27476. }
  27477. return oldValue.CustomAgentBase, nil
  27478. }
  27479. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27480. func (m *TokenMutation) ClearCustomAgentBase() {
  27481. m.custom_agent_base = nil
  27482. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27483. }
  27484. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27485. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27486. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27487. return ok
  27488. }
  27489. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27490. func (m *TokenMutation) ResetCustomAgentBase() {
  27491. m.custom_agent_base = nil
  27492. delete(m.clearedFields, token.FieldCustomAgentBase)
  27493. }
  27494. // SetCustomAgentKey sets the "custom_agent_key" field.
  27495. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27496. m.custom_agent_key = &s
  27497. }
  27498. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27499. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27500. v := m.custom_agent_key
  27501. if v == nil {
  27502. return
  27503. }
  27504. return *v, true
  27505. }
  27506. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27507. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27509. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27510. if !m.op.Is(OpUpdateOne) {
  27511. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27512. }
  27513. if m.id == nil || m.oldValue == nil {
  27514. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27515. }
  27516. oldValue, err := m.oldValue(ctx)
  27517. if err != nil {
  27518. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27519. }
  27520. return oldValue.CustomAgentKey, nil
  27521. }
  27522. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27523. func (m *TokenMutation) ClearCustomAgentKey() {
  27524. m.custom_agent_key = nil
  27525. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27526. }
  27527. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27528. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27529. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27530. return ok
  27531. }
  27532. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27533. func (m *TokenMutation) ResetCustomAgentKey() {
  27534. m.custom_agent_key = nil
  27535. delete(m.clearedFields, token.FieldCustomAgentKey)
  27536. }
  27537. // SetOpenaiBase sets the "openai_base" field.
  27538. func (m *TokenMutation) SetOpenaiBase(s string) {
  27539. m.openai_base = &s
  27540. }
  27541. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27542. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27543. v := m.openai_base
  27544. if v == nil {
  27545. return
  27546. }
  27547. return *v, true
  27548. }
  27549. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27550. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27552. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27553. if !m.op.Is(OpUpdateOne) {
  27554. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27555. }
  27556. if m.id == nil || m.oldValue == nil {
  27557. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27558. }
  27559. oldValue, err := m.oldValue(ctx)
  27560. if err != nil {
  27561. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27562. }
  27563. return oldValue.OpenaiBase, nil
  27564. }
  27565. // ClearOpenaiBase clears the value of the "openai_base" field.
  27566. func (m *TokenMutation) ClearOpenaiBase() {
  27567. m.openai_base = nil
  27568. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27569. }
  27570. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27571. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27572. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27573. return ok
  27574. }
  27575. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27576. func (m *TokenMutation) ResetOpenaiBase() {
  27577. m.openai_base = nil
  27578. delete(m.clearedFields, token.FieldOpenaiBase)
  27579. }
  27580. // SetOpenaiKey sets the "openai_key" field.
  27581. func (m *TokenMutation) SetOpenaiKey(s string) {
  27582. m.openai_key = &s
  27583. }
  27584. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27585. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27586. v := m.openai_key
  27587. if v == nil {
  27588. return
  27589. }
  27590. return *v, true
  27591. }
  27592. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27593. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27595. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27596. if !m.op.Is(OpUpdateOne) {
  27597. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27598. }
  27599. if m.id == nil || m.oldValue == nil {
  27600. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27601. }
  27602. oldValue, err := m.oldValue(ctx)
  27603. if err != nil {
  27604. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27605. }
  27606. return oldValue.OpenaiKey, nil
  27607. }
  27608. // ClearOpenaiKey clears the value of the "openai_key" field.
  27609. func (m *TokenMutation) ClearOpenaiKey() {
  27610. m.openai_key = nil
  27611. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27612. }
  27613. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27614. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27615. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27616. return ok
  27617. }
  27618. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27619. func (m *TokenMutation) ResetOpenaiKey() {
  27620. m.openai_key = nil
  27621. delete(m.clearedFields, token.FieldOpenaiKey)
  27622. }
  27623. // ClearAgent clears the "agent" edge to the Agent entity.
  27624. func (m *TokenMutation) ClearAgent() {
  27625. m.clearedagent = true
  27626. m.clearedFields[token.FieldAgentID] = struct{}{}
  27627. }
  27628. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27629. func (m *TokenMutation) AgentCleared() bool {
  27630. return m.clearedagent
  27631. }
  27632. // AgentIDs returns the "agent" edge IDs in the mutation.
  27633. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27634. // AgentID instead. It exists only for internal usage by the builders.
  27635. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27636. if id := m.agent; id != nil {
  27637. ids = append(ids, *id)
  27638. }
  27639. return
  27640. }
  27641. // ResetAgent resets all changes to the "agent" edge.
  27642. func (m *TokenMutation) ResetAgent() {
  27643. m.agent = nil
  27644. m.clearedagent = false
  27645. }
  27646. // Where appends a list predicates to the TokenMutation builder.
  27647. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27648. m.predicates = append(m.predicates, ps...)
  27649. }
  27650. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27651. // users can use type-assertion to append predicates that do not depend on any generated package.
  27652. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27653. p := make([]predicate.Token, len(ps))
  27654. for i := range ps {
  27655. p[i] = ps[i]
  27656. }
  27657. m.Where(p...)
  27658. }
  27659. // Op returns the operation name.
  27660. func (m *TokenMutation) Op() Op {
  27661. return m.op
  27662. }
  27663. // SetOp allows setting the mutation operation.
  27664. func (m *TokenMutation) SetOp(op Op) {
  27665. m.op = op
  27666. }
  27667. // Type returns the node type of this mutation (Token).
  27668. func (m *TokenMutation) Type() string {
  27669. return m.typ
  27670. }
  27671. // Fields returns all fields that were changed during this mutation. Note that in
  27672. // order to get all numeric fields that were incremented/decremented, call
  27673. // AddedFields().
  27674. func (m *TokenMutation) Fields() []string {
  27675. fields := make([]string, 0, 12)
  27676. if m.created_at != nil {
  27677. fields = append(fields, token.FieldCreatedAt)
  27678. }
  27679. if m.updated_at != nil {
  27680. fields = append(fields, token.FieldUpdatedAt)
  27681. }
  27682. if m.deleted_at != nil {
  27683. fields = append(fields, token.FieldDeletedAt)
  27684. }
  27685. if m.expire_at != nil {
  27686. fields = append(fields, token.FieldExpireAt)
  27687. }
  27688. if m.token != nil {
  27689. fields = append(fields, token.FieldToken)
  27690. }
  27691. if m.mac != nil {
  27692. fields = append(fields, token.FieldMAC)
  27693. }
  27694. if m.organization_id != nil {
  27695. fields = append(fields, token.FieldOrganizationID)
  27696. }
  27697. if m.agent != nil {
  27698. fields = append(fields, token.FieldAgentID)
  27699. }
  27700. if m.custom_agent_base != nil {
  27701. fields = append(fields, token.FieldCustomAgentBase)
  27702. }
  27703. if m.custom_agent_key != nil {
  27704. fields = append(fields, token.FieldCustomAgentKey)
  27705. }
  27706. if m.openai_base != nil {
  27707. fields = append(fields, token.FieldOpenaiBase)
  27708. }
  27709. if m.openai_key != nil {
  27710. fields = append(fields, token.FieldOpenaiKey)
  27711. }
  27712. return fields
  27713. }
  27714. // Field returns the value of a field with the given name. The second boolean
  27715. // return value indicates that this field was not set, or was not defined in the
  27716. // schema.
  27717. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27718. switch name {
  27719. case token.FieldCreatedAt:
  27720. return m.CreatedAt()
  27721. case token.FieldUpdatedAt:
  27722. return m.UpdatedAt()
  27723. case token.FieldDeletedAt:
  27724. return m.DeletedAt()
  27725. case token.FieldExpireAt:
  27726. return m.ExpireAt()
  27727. case token.FieldToken:
  27728. return m.Token()
  27729. case token.FieldMAC:
  27730. return m.MAC()
  27731. case token.FieldOrganizationID:
  27732. return m.OrganizationID()
  27733. case token.FieldAgentID:
  27734. return m.AgentID()
  27735. case token.FieldCustomAgentBase:
  27736. return m.CustomAgentBase()
  27737. case token.FieldCustomAgentKey:
  27738. return m.CustomAgentKey()
  27739. case token.FieldOpenaiBase:
  27740. return m.OpenaiBase()
  27741. case token.FieldOpenaiKey:
  27742. return m.OpenaiKey()
  27743. }
  27744. return nil, false
  27745. }
  27746. // OldField returns the old value of the field from the database. An error is
  27747. // returned if the mutation operation is not UpdateOne, or the query to the
  27748. // database failed.
  27749. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27750. switch name {
  27751. case token.FieldCreatedAt:
  27752. return m.OldCreatedAt(ctx)
  27753. case token.FieldUpdatedAt:
  27754. return m.OldUpdatedAt(ctx)
  27755. case token.FieldDeletedAt:
  27756. return m.OldDeletedAt(ctx)
  27757. case token.FieldExpireAt:
  27758. return m.OldExpireAt(ctx)
  27759. case token.FieldToken:
  27760. return m.OldToken(ctx)
  27761. case token.FieldMAC:
  27762. return m.OldMAC(ctx)
  27763. case token.FieldOrganizationID:
  27764. return m.OldOrganizationID(ctx)
  27765. case token.FieldAgentID:
  27766. return m.OldAgentID(ctx)
  27767. case token.FieldCustomAgentBase:
  27768. return m.OldCustomAgentBase(ctx)
  27769. case token.FieldCustomAgentKey:
  27770. return m.OldCustomAgentKey(ctx)
  27771. case token.FieldOpenaiBase:
  27772. return m.OldOpenaiBase(ctx)
  27773. case token.FieldOpenaiKey:
  27774. return m.OldOpenaiKey(ctx)
  27775. }
  27776. return nil, fmt.Errorf("unknown Token field %s", name)
  27777. }
  27778. // SetField sets the value of a field with the given name. It returns an error if
  27779. // the field is not defined in the schema, or if the type mismatched the field
  27780. // type.
  27781. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27782. switch name {
  27783. case token.FieldCreatedAt:
  27784. v, ok := value.(time.Time)
  27785. if !ok {
  27786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27787. }
  27788. m.SetCreatedAt(v)
  27789. return nil
  27790. case token.FieldUpdatedAt:
  27791. v, ok := value.(time.Time)
  27792. if !ok {
  27793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27794. }
  27795. m.SetUpdatedAt(v)
  27796. return nil
  27797. case token.FieldDeletedAt:
  27798. v, ok := value.(time.Time)
  27799. if !ok {
  27800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27801. }
  27802. m.SetDeletedAt(v)
  27803. return nil
  27804. case token.FieldExpireAt:
  27805. v, ok := value.(time.Time)
  27806. if !ok {
  27807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27808. }
  27809. m.SetExpireAt(v)
  27810. return nil
  27811. case token.FieldToken:
  27812. v, ok := value.(string)
  27813. if !ok {
  27814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27815. }
  27816. m.SetToken(v)
  27817. return nil
  27818. case token.FieldMAC:
  27819. v, ok := value.(string)
  27820. if !ok {
  27821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27822. }
  27823. m.SetMAC(v)
  27824. return nil
  27825. case token.FieldOrganizationID:
  27826. v, ok := value.(uint64)
  27827. if !ok {
  27828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27829. }
  27830. m.SetOrganizationID(v)
  27831. return nil
  27832. case token.FieldAgentID:
  27833. v, ok := value.(uint64)
  27834. if !ok {
  27835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27836. }
  27837. m.SetAgentID(v)
  27838. return nil
  27839. case token.FieldCustomAgentBase:
  27840. v, ok := value.(string)
  27841. if !ok {
  27842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27843. }
  27844. m.SetCustomAgentBase(v)
  27845. return nil
  27846. case token.FieldCustomAgentKey:
  27847. v, ok := value.(string)
  27848. if !ok {
  27849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27850. }
  27851. m.SetCustomAgentKey(v)
  27852. return nil
  27853. case token.FieldOpenaiBase:
  27854. v, ok := value.(string)
  27855. if !ok {
  27856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27857. }
  27858. m.SetOpenaiBase(v)
  27859. return nil
  27860. case token.FieldOpenaiKey:
  27861. v, ok := value.(string)
  27862. if !ok {
  27863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27864. }
  27865. m.SetOpenaiKey(v)
  27866. return nil
  27867. }
  27868. return fmt.Errorf("unknown Token field %s", name)
  27869. }
  27870. // AddedFields returns all numeric fields that were incremented/decremented during
  27871. // this mutation.
  27872. func (m *TokenMutation) AddedFields() []string {
  27873. var fields []string
  27874. if m.addorganization_id != nil {
  27875. fields = append(fields, token.FieldOrganizationID)
  27876. }
  27877. return fields
  27878. }
  27879. // AddedField returns the numeric value that was incremented/decremented on a field
  27880. // with the given name. The second boolean return value indicates that this field
  27881. // was not set, or was not defined in the schema.
  27882. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  27883. switch name {
  27884. case token.FieldOrganizationID:
  27885. return m.AddedOrganizationID()
  27886. }
  27887. return nil, false
  27888. }
  27889. // AddField adds the value to the field with the given name. It returns an error if
  27890. // the field is not defined in the schema, or if the type mismatched the field
  27891. // type.
  27892. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  27893. switch name {
  27894. case token.FieldOrganizationID:
  27895. v, ok := value.(int64)
  27896. if !ok {
  27897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27898. }
  27899. m.AddOrganizationID(v)
  27900. return nil
  27901. }
  27902. return fmt.Errorf("unknown Token numeric field %s", name)
  27903. }
  27904. // ClearedFields returns all nullable fields that were cleared during this
  27905. // mutation.
  27906. func (m *TokenMutation) ClearedFields() []string {
  27907. var fields []string
  27908. if m.FieldCleared(token.FieldDeletedAt) {
  27909. fields = append(fields, token.FieldDeletedAt)
  27910. }
  27911. if m.FieldCleared(token.FieldExpireAt) {
  27912. fields = append(fields, token.FieldExpireAt)
  27913. }
  27914. if m.FieldCleared(token.FieldToken) {
  27915. fields = append(fields, token.FieldToken)
  27916. }
  27917. if m.FieldCleared(token.FieldMAC) {
  27918. fields = append(fields, token.FieldMAC)
  27919. }
  27920. if m.FieldCleared(token.FieldCustomAgentBase) {
  27921. fields = append(fields, token.FieldCustomAgentBase)
  27922. }
  27923. if m.FieldCleared(token.FieldCustomAgentKey) {
  27924. fields = append(fields, token.FieldCustomAgentKey)
  27925. }
  27926. if m.FieldCleared(token.FieldOpenaiBase) {
  27927. fields = append(fields, token.FieldOpenaiBase)
  27928. }
  27929. if m.FieldCleared(token.FieldOpenaiKey) {
  27930. fields = append(fields, token.FieldOpenaiKey)
  27931. }
  27932. return fields
  27933. }
  27934. // FieldCleared returns a boolean indicating if a field with the given name was
  27935. // cleared in this mutation.
  27936. func (m *TokenMutation) FieldCleared(name string) bool {
  27937. _, ok := m.clearedFields[name]
  27938. return ok
  27939. }
  27940. // ClearField clears the value of the field with the given name. It returns an
  27941. // error if the field is not defined in the schema.
  27942. func (m *TokenMutation) ClearField(name string) error {
  27943. switch name {
  27944. case token.FieldDeletedAt:
  27945. m.ClearDeletedAt()
  27946. return nil
  27947. case token.FieldExpireAt:
  27948. m.ClearExpireAt()
  27949. return nil
  27950. case token.FieldToken:
  27951. m.ClearToken()
  27952. return nil
  27953. case token.FieldMAC:
  27954. m.ClearMAC()
  27955. return nil
  27956. case token.FieldCustomAgentBase:
  27957. m.ClearCustomAgentBase()
  27958. return nil
  27959. case token.FieldCustomAgentKey:
  27960. m.ClearCustomAgentKey()
  27961. return nil
  27962. case token.FieldOpenaiBase:
  27963. m.ClearOpenaiBase()
  27964. return nil
  27965. case token.FieldOpenaiKey:
  27966. m.ClearOpenaiKey()
  27967. return nil
  27968. }
  27969. return fmt.Errorf("unknown Token nullable field %s", name)
  27970. }
  27971. // ResetField resets all changes in the mutation for the field with the given name.
  27972. // It returns an error if the field is not defined in the schema.
  27973. func (m *TokenMutation) ResetField(name string) error {
  27974. switch name {
  27975. case token.FieldCreatedAt:
  27976. m.ResetCreatedAt()
  27977. return nil
  27978. case token.FieldUpdatedAt:
  27979. m.ResetUpdatedAt()
  27980. return nil
  27981. case token.FieldDeletedAt:
  27982. m.ResetDeletedAt()
  27983. return nil
  27984. case token.FieldExpireAt:
  27985. m.ResetExpireAt()
  27986. return nil
  27987. case token.FieldToken:
  27988. m.ResetToken()
  27989. return nil
  27990. case token.FieldMAC:
  27991. m.ResetMAC()
  27992. return nil
  27993. case token.FieldOrganizationID:
  27994. m.ResetOrganizationID()
  27995. return nil
  27996. case token.FieldAgentID:
  27997. m.ResetAgentID()
  27998. return nil
  27999. case token.FieldCustomAgentBase:
  28000. m.ResetCustomAgentBase()
  28001. return nil
  28002. case token.FieldCustomAgentKey:
  28003. m.ResetCustomAgentKey()
  28004. return nil
  28005. case token.FieldOpenaiBase:
  28006. m.ResetOpenaiBase()
  28007. return nil
  28008. case token.FieldOpenaiKey:
  28009. m.ResetOpenaiKey()
  28010. return nil
  28011. }
  28012. return fmt.Errorf("unknown Token field %s", name)
  28013. }
  28014. // AddedEdges returns all edge names that were set/added in this mutation.
  28015. func (m *TokenMutation) AddedEdges() []string {
  28016. edges := make([]string, 0, 1)
  28017. if m.agent != nil {
  28018. edges = append(edges, token.EdgeAgent)
  28019. }
  28020. return edges
  28021. }
  28022. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28023. // name in this mutation.
  28024. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28025. switch name {
  28026. case token.EdgeAgent:
  28027. if id := m.agent; id != nil {
  28028. return []ent.Value{*id}
  28029. }
  28030. }
  28031. return nil
  28032. }
  28033. // RemovedEdges returns all edge names that were removed in this mutation.
  28034. func (m *TokenMutation) RemovedEdges() []string {
  28035. edges := make([]string, 0, 1)
  28036. return edges
  28037. }
  28038. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28039. // the given name in this mutation.
  28040. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28041. return nil
  28042. }
  28043. // ClearedEdges returns all edge names that were cleared in this mutation.
  28044. func (m *TokenMutation) ClearedEdges() []string {
  28045. edges := make([]string, 0, 1)
  28046. if m.clearedagent {
  28047. edges = append(edges, token.EdgeAgent)
  28048. }
  28049. return edges
  28050. }
  28051. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28052. // was cleared in this mutation.
  28053. func (m *TokenMutation) EdgeCleared(name string) bool {
  28054. switch name {
  28055. case token.EdgeAgent:
  28056. return m.clearedagent
  28057. }
  28058. return false
  28059. }
  28060. // ClearEdge clears the value of the edge with the given name. It returns an error
  28061. // if that edge is not defined in the schema.
  28062. func (m *TokenMutation) ClearEdge(name string) error {
  28063. switch name {
  28064. case token.EdgeAgent:
  28065. m.ClearAgent()
  28066. return nil
  28067. }
  28068. return fmt.Errorf("unknown Token unique edge %s", name)
  28069. }
  28070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28071. // It returns an error if the edge is not defined in the schema.
  28072. func (m *TokenMutation) ResetEdge(name string) error {
  28073. switch name {
  28074. case token.EdgeAgent:
  28075. m.ResetAgent()
  28076. return nil
  28077. }
  28078. return fmt.Errorf("unknown Token edge %s", name)
  28079. }
  28080. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28081. type TutorialMutation struct {
  28082. config
  28083. op Op
  28084. typ string
  28085. id *uint64
  28086. created_at *time.Time
  28087. updated_at *time.Time
  28088. deleted_at *time.Time
  28089. index *int
  28090. addindex *int
  28091. title *string
  28092. content *string
  28093. organization_id *uint64
  28094. addorganization_id *int64
  28095. clearedFields map[string]struct{}
  28096. employee *uint64
  28097. clearedemployee bool
  28098. done bool
  28099. oldValue func(context.Context) (*Tutorial, error)
  28100. predicates []predicate.Tutorial
  28101. }
  28102. var _ ent.Mutation = (*TutorialMutation)(nil)
  28103. // tutorialOption allows management of the mutation configuration using functional options.
  28104. type tutorialOption func(*TutorialMutation)
  28105. // newTutorialMutation creates new mutation for the Tutorial entity.
  28106. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28107. m := &TutorialMutation{
  28108. config: c,
  28109. op: op,
  28110. typ: TypeTutorial,
  28111. clearedFields: make(map[string]struct{}),
  28112. }
  28113. for _, opt := range opts {
  28114. opt(m)
  28115. }
  28116. return m
  28117. }
  28118. // withTutorialID sets the ID field of the mutation.
  28119. func withTutorialID(id uint64) tutorialOption {
  28120. return func(m *TutorialMutation) {
  28121. var (
  28122. err error
  28123. once sync.Once
  28124. value *Tutorial
  28125. )
  28126. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28127. once.Do(func() {
  28128. if m.done {
  28129. err = errors.New("querying old values post mutation is not allowed")
  28130. } else {
  28131. value, err = m.Client().Tutorial.Get(ctx, id)
  28132. }
  28133. })
  28134. return value, err
  28135. }
  28136. m.id = &id
  28137. }
  28138. }
  28139. // withTutorial sets the old Tutorial of the mutation.
  28140. func withTutorial(node *Tutorial) tutorialOption {
  28141. return func(m *TutorialMutation) {
  28142. m.oldValue = func(context.Context) (*Tutorial, error) {
  28143. return node, nil
  28144. }
  28145. m.id = &node.ID
  28146. }
  28147. }
  28148. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28149. // executed in a transaction (ent.Tx), a transactional client is returned.
  28150. func (m TutorialMutation) Client() *Client {
  28151. client := &Client{config: m.config}
  28152. client.init()
  28153. return client
  28154. }
  28155. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28156. // it returns an error otherwise.
  28157. func (m TutorialMutation) Tx() (*Tx, error) {
  28158. if _, ok := m.driver.(*txDriver); !ok {
  28159. return nil, errors.New("ent: mutation is not running in a transaction")
  28160. }
  28161. tx := &Tx{config: m.config}
  28162. tx.init()
  28163. return tx, nil
  28164. }
  28165. // SetID sets the value of the id field. Note that this
  28166. // operation is only accepted on creation of Tutorial entities.
  28167. func (m *TutorialMutation) SetID(id uint64) {
  28168. m.id = &id
  28169. }
  28170. // ID returns the ID value in the mutation. Note that the ID is only available
  28171. // if it was provided to the builder or after it was returned from the database.
  28172. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28173. if m.id == nil {
  28174. return
  28175. }
  28176. return *m.id, true
  28177. }
  28178. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28179. // That means, if the mutation is applied within a transaction with an isolation level such
  28180. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28181. // or updated by the mutation.
  28182. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28183. switch {
  28184. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28185. id, exists := m.ID()
  28186. if exists {
  28187. return []uint64{id}, nil
  28188. }
  28189. fallthrough
  28190. case m.op.Is(OpUpdate | OpDelete):
  28191. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28192. default:
  28193. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28194. }
  28195. }
  28196. // SetCreatedAt sets the "created_at" field.
  28197. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28198. m.created_at = &t
  28199. }
  28200. // CreatedAt returns the value of the "created_at" field in the mutation.
  28201. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28202. v := m.created_at
  28203. if v == nil {
  28204. return
  28205. }
  28206. return *v, true
  28207. }
  28208. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28209. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28211. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28212. if !m.op.Is(OpUpdateOne) {
  28213. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28214. }
  28215. if m.id == nil || m.oldValue == nil {
  28216. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28217. }
  28218. oldValue, err := m.oldValue(ctx)
  28219. if err != nil {
  28220. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28221. }
  28222. return oldValue.CreatedAt, nil
  28223. }
  28224. // ResetCreatedAt resets all changes to the "created_at" field.
  28225. func (m *TutorialMutation) ResetCreatedAt() {
  28226. m.created_at = nil
  28227. }
  28228. // SetUpdatedAt sets the "updated_at" field.
  28229. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28230. m.updated_at = &t
  28231. }
  28232. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28233. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28234. v := m.updated_at
  28235. if v == nil {
  28236. return
  28237. }
  28238. return *v, true
  28239. }
  28240. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28241. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28243. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28244. if !m.op.Is(OpUpdateOne) {
  28245. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28246. }
  28247. if m.id == nil || m.oldValue == nil {
  28248. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28249. }
  28250. oldValue, err := m.oldValue(ctx)
  28251. if err != nil {
  28252. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28253. }
  28254. return oldValue.UpdatedAt, nil
  28255. }
  28256. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28257. func (m *TutorialMutation) ResetUpdatedAt() {
  28258. m.updated_at = nil
  28259. }
  28260. // SetDeletedAt sets the "deleted_at" field.
  28261. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28262. m.deleted_at = &t
  28263. }
  28264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28265. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28266. v := m.deleted_at
  28267. if v == nil {
  28268. return
  28269. }
  28270. return *v, true
  28271. }
  28272. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28273. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28275. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28276. if !m.op.Is(OpUpdateOne) {
  28277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28278. }
  28279. if m.id == nil || m.oldValue == nil {
  28280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28281. }
  28282. oldValue, err := m.oldValue(ctx)
  28283. if err != nil {
  28284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28285. }
  28286. return oldValue.DeletedAt, nil
  28287. }
  28288. // ClearDeletedAt clears the value of the "deleted_at" field.
  28289. func (m *TutorialMutation) ClearDeletedAt() {
  28290. m.deleted_at = nil
  28291. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28292. }
  28293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28294. func (m *TutorialMutation) DeletedAtCleared() bool {
  28295. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28296. return ok
  28297. }
  28298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28299. func (m *TutorialMutation) ResetDeletedAt() {
  28300. m.deleted_at = nil
  28301. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28302. }
  28303. // SetEmployeeID sets the "employee_id" field.
  28304. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28305. m.employee = &u
  28306. }
  28307. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28308. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28309. v := m.employee
  28310. if v == nil {
  28311. return
  28312. }
  28313. return *v, true
  28314. }
  28315. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28316. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28318. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28319. if !m.op.Is(OpUpdateOne) {
  28320. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28321. }
  28322. if m.id == nil || m.oldValue == nil {
  28323. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28324. }
  28325. oldValue, err := m.oldValue(ctx)
  28326. if err != nil {
  28327. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28328. }
  28329. return oldValue.EmployeeID, nil
  28330. }
  28331. // ResetEmployeeID resets all changes to the "employee_id" field.
  28332. func (m *TutorialMutation) ResetEmployeeID() {
  28333. m.employee = nil
  28334. }
  28335. // SetIndex sets the "index" field.
  28336. func (m *TutorialMutation) SetIndex(i int) {
  28337. m.index = &i
  28338. m.addindex = nil
  28339. }
  28340. // Index returns the value of the "index" field in the mutation.
  28341. func (m *TutorialMutation) Index() (r int, exists bool) {
  28342. v := m.index
  28343. if v == nil {
  28344. return
  28345. }
  28346. return *v, true
  28347. }
  28348. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28349. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28351. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28352. if !m.op.Is(OpUpdateOne) {
  28353. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28354. }
  28355. if m.id == nil || m.oldValue == nil {
  28356. return v, errors.New("OldIndex requires an ID field in the mutation")
  28357. }
  28358. oldValue, err := m.oldValue(ctx)
  28359. if err != nil {
  28360. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28361. }
  28362. return oldValue.Index, nil
  28363. }
  28364. // AddIndex adds i to the "index" field.
  28365. func (m *TutorialMutation) AddIndex(i int) {
  28366. if m.addindex != nil {
  28367. *m.addindex += i
  28368. } else {
  28369. m.addindex = &i
  28370. }
  28371. }
  28372. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28373. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28374. v := m.addindex
  28375. if v == nil {
  28376. return
  28377. }
  28378. return *v, true
  28379. }
  28380. // ResetIndex resets all changes to the "index" field.
  28381. func (m *TutorialMutation) ResetIndex() {
  28382. m.index = nil
  28383. m.addindex = nil
  28384. }
  28385. // SetTitle sets the "title" field.
  28386. func (m *TutorialMutation) SetTitle(s string) {
  28387. m.title = &s
  28388. }
  28389. // Title returns the value of the "title" field in the mutation.
  28390. func (m *TutorialMutation) Title() (r string, exists bool) {
  28391. v := m.title
  28392. if v == nil {
  28393. return
  28394. }
  28395. return *v, true
  28396. }
  28397. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28398. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28400. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28401. if !m.op.Is(OpUpdateOne) {
  28402. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28403. }
  28404. if m.id == nil || m.oldValue == nil {
  28405. return v, errors.New("OldTitle requires an ID field in the mutation")
  28406. }
  28407. oldValue, err := m.oldValue(ctx)
  28408. if err != nil {
  28409. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28410. }
  28411. return oldValue.Title, nil
  28412. }
  28413. // ResetTitle resets all changes to the "title" field.
  28414. func (m *TutorialMutation) ResetTitle() {
  28415. m.title = nil
  28416. }
  28417. // SetContent sets the "content" field.
  28418. func (m *TutorialMutation) SetContent(s string) {
  28419. m.content = &s
  28420. }
  28421. // Content returns the value of the "content" field in the mutation.
  28422. func (m *TutorialMutation) Content() (r string, exists bool) {
  28423. v := m.content
  28424. if v == nil {
  28425. return
  28426. }
  28427. return *v, true
  28428. }
  28429. // OldContent returns the old "content" field's value of the Tutorial entity.
  28430. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28432. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28433. if !m.op.Is(OpUpdateOne) {
  28434. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28435. }
  28436. if m.id == nil || m.oldValue == nil {
  28437. return v, errors.New("OldContent requires an ID field in the mutation")
  28438. }
  28439. oldValue, err := m.oldValue(ctx)
  28440. if err != nil {
  28441. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28442. }
  28443. return oldValue.Content, nil
  28444. }
  28445. // ResetContent resets all changes to the "content" field.
  28446. func (m *TutorialMutation) ResetContent() {
  28447. m.content = nil
  28448. }
  28449. // SetOrganizationID sets the "organization_id" field.
  28450. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28451. m.organization_id = &u
  28452. m.addorganization_id = nil
  28453. }
  28454. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28455. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28456. v := m.organization_id
  28457. if v == nil {
  28458. return
  28459. }
  28460. return *v, true
  28461. }
  28462. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28463. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28465. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28466. if !m.op.Is(OpUpdateOne) {
  28467. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28468. }
  28469. if m.id == nil || m.oldValue == nil {
  28470. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28471. }
  28472. oldValue, err := m.oldValue(ctx)
  28473. if err != nil {
  28474. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28475. }
  28476. return oldValue.OrganizationID, nil
  28477. }
  28478. // AddOrganizationID adds u to the "organization_id" field.
  28479. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28480. if m.addorganization_id != nil {
  28481. *m.addorganization_id += u
  28482. } else {
  28483. m.addorganization_id = &u
  28484. }
  28485. }
  28486. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28487. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28488. v := m.addorganization_id
  28489. if v == nil {
  28490. return
  28491. }
  28492. return *v, true
  28493. }
  28494. // ResetOrganizationID resets all changes to the "organization_id" field.
  28495. func (m *TutorialMutation) ResetOrganizationID() {
  28496. m.organization_id = nil
  28497. m.addorganization_id = nil
  28498. }
  28499. // ClearEmployee clears the "employee" edge to the Employee entity.
  28500. func (m *TutorialMutation) ClearEmployee() {
  28501. m.clearedemployee = true
  28502. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28503. }
  28504. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28505. func (m *TutorialMutation) EmployeeCleared() bool {
  28506. return m.clearedemployee
  28507. }
  28508. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28509. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28510. // EmployeeID instead. It exists only for internal usage by the builders.
  28511. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28512. if id := m.employee; id != nil {
  28513. ids = append(ids, *id)
  28514. }
  28515. return
  28516. }
  28517. // ResetEmployee resets all changes to the "employee" edge.
  28518. func (m *TutorialMutation) ResetEmployee() {
  28519. m.employee = nil
  28520. m.clearedemployee = false
  28521. }
  28522. // Where appends a list predicates to the TutorialMutation builder.
  28523. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28524. m.predicates = append(m.predicates, ps...)
  28525. }
  28526. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28527. // users can use type-assertion to append predicates that do not depend on any generated package.
  28528. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28529. p := make([]predicate.Tutorial, len(ps))
  28530. for i := range ps {
  28531. p[i] = ps[i]
  28532. }
  28533. m.Where(p...)
  28534. }
  28535. // Op returns the operation name.
  28536. func (m *TutorialMutation) Op() Op {
  28537. return m.op
  28538. }
  28539. // SetOp allows setting the mutation operation.
  28540. func (m *TutorialMutation) SetOp(op Op) {
  28541. m.op = op
  28542. }
  28543. // Type returns the node type of this mutation (Tutorial).
  28544. func (m *TutorialMutation) Type() string {
  28545. return m.typ
  28546. }
  28547. // Fields returns all fields that were changed during this mutation. Note that in
  28548. // order to get all numeric fields that were incremented/decremented, call
  28549. // AddedFields().
  28550. func (m *TutorialMutation) Fields() []string {
  28551. fields := make([]string, 0, 8)
  28552. if m.created_at != nil {
  28553. fields = append(fields, tutorial.FieldCreatedAt)
  28554. }
  28555. if m.updated_at != nil {
  28556. fields = append(fields, tutorial.FieldUpdatedAt)
  28557. }
  28558. if m.deleted_at != nil {
  28559. fields = append(fields, tutorial.FieldDeletedAt)
  28560. }
  28561. if m.employee != nil {
  28562. fields = append(fields, tutorial.FieldEmployeeID)
  28563. }
  28564. if m.index != nil {
  28565. fields = append(fields, tutorial.FieldIndex)
  28566. }
  28567. if m.title != nil {
  28568. fields = append(fields, tutorial.FieldTitle)
  28569. }
  28570. if m.content != nil {
  28571. fields = append(fields, tutorial.FieldContent)
  28572. }
  28573. if m.organization_id != nil {
  28574. fields = append(fields, tutorial.FieldOrganizationID)
  28575. }
  28576. return fields
  28577. }
  28578. // Field returns the value of a field with the given name. The second boolean
  28579. // return value indicates that this field was not set, or was not defined in the
  28580. // schema.
  28581. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28582. switch name {
  28583. case tutorial.FieldCreatedAt:
  28584. return m.CreatedAt()
  28585. case tutorial.FieldUpdatedAt:
  28586. return m.UpdatedAt()
  28587. case tutorial.FieldDeletedAt:
  28588. return m.DeletedAt()
  28589. case tutorial.FieldEmployeeID:
  28590. return m.EmployeeID()
  28591. case tutorial.FieldIndex:
  28592. return m.Index()
  28593. case tutorial.FieldTitle:
  28594. return m.Title()
  28595. case tutorial.FieldContent:
  28596. return m.Content()
  28597. case tutorial.FieldOrganizationID:
  28598. return m.OrganizationID()
  28599. }
  28600. return nil, false
  28601. }
  28602. // OldField returns the old value of the field from the database. An error is
  28603. // returned if the mutation operation is not UpdateOne, or the query to the
  28604. // database failed.
  28605. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28606. switch name {
  28607. case tutorial.FieldCreatedAt:
  28608. return m.OldCreatedAt(ctx)
  28609. case tutorial.FieldUpdatedAt:
  28610. return m.OldUpdatedAt(ctx)
  28611. case tutorial.FieldDeletedAt:
  28612. return m.OldDeletedAt(ctx)
  28613. case tutorial.FieldEmployeeID:
  28614. return m.OldEmployeeID(ctx)
  28615. case tutorial.FieldIndex:
  28616. return m.OldIndex(ctx)
  28617. case tutorial.FieldTitle:
  28618. return m.OldTitle(ctx)
  28619. case tutorial.FieldContent:
  28620. return m.OldContent(ctx)
  28621. case tutorial.FieldOrganizationID:
  28622. return m.OldOrganizationID(ctx)
  28623. }
  28624. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28625. }
  28626. // SetField sets the value of a field with the given name. It returns an error if
  28627. // the field is not defined in the schema, or if the type mismatched the field
  28628. // type.
  28629. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28630. switch name {
  28631. case tutorial.FieldCreatedAt:
  28632. v, ok := value.(time.Time)
  28633. if !ok {
  28634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28635. }
  28636. m.SetCreatedAt(v)
  28637. return nil
  28638. case tutorial.FieldUpdatedAt:
  28639. v, ok := value.(time.Time)
  28640. if !ok {
  28641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28642. }
  28643. m.SetUpdatedAt(v)
  28644. return nil
  28645. case tutorial.FieldDeletedAt:
  28646. v, ok := value.(time.Time)
  28647. if !ok {
  28648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28649. }
  28650. m.SetDeletedAt(v)
  28651. return nil
  28652. case tutorial.FieldEmployeeID:
  28653. v, ok := value.(uint64)
  28654. if !ok {
  28655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28656. }
  28657. m.SetEmployeeID(v)
  28658. return nil
  28659. case tutorial.FieldIndex:
  28660. v, ok := value.(int)
  28661. if !ok {
  28662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28663. }
  28664. m.SetIndex(v)
  28665. return nil
  28666. case tutorial.FieldTitle:
  28667. v, ok := value.(string)
  28668. if !ok {
  28669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28670. }
  28671. m.SetTitle(v)
  28672. return nil
  28673. case tutorial.FieldContent:
  28674. v, ok := value.(string)
  28675. if !ok {
  28676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28677. }
  28678. m.SetContent(v)
  28679. return nil
  28680. case tutorial.FieldOrganizationID:
  28681. v, ok := value.(uint64)
  28682. if !ok {
  28683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28684. }
  28685. m.SetOrganizationID(v)
  28686. return nil
  28687. }
  28688. return fmt.Errorf("unknown Tutorial field %s", name)
  28689. }
  28690. // AddedFields returns all numeric fields that were incremented/decremented during
  28691. // this mutation.
  28692. func (m *TutorialMutation) AddedFields() []string {
  28693. var fields []string
  28694. if m.addindex != nil {
  28695. fields = append(fields, tutorial.FieldIndex)
  28696. }
  28697. if m.addorganization_id != nil {
  28698. fields = append(fields, tutorial.FieldOrganizationID)
  28699. }
  28700. return fields
  28701. }
  28702. // AddedField returns the numeric value that was incremented/decremented on a field
  28703. // with the given name. The second boolean return value indicates that this field
  28704. // was not set, or was not defined in the schema.
  28705. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28706. switch name {
  28707. case tutorial.FieldIndex:
  28708. return m.AddedIndex()
  28709. case tutorial.FieldOrganizationID:
  28710. return m.AddedOrganizationID()
  28711. }
  28712. return nil, false
  28713. }
  28714. // AddField adds the value to the field with the given name. It returns an error if
  28715. // the field is not defined in the schema, or if the type mismatched the field
  28716. // type.
  28717. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28718. switch name {
  28719. case tutorial.FieldIndex:
  28720. v, ok := value.(int)
  28721. if !ok {
  28722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28723. }
  28724. m.AddIndex(v)
  28725. return nil
  28726. case tutorial.FieldOrganizationID:
  28727. v, ok := value.(int64)
  28728. if !ok {
  28729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28730. }
  28731. m.AddOrganizationID(v)
  28732. return nil
  28733. }
  28734. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28735. }
  28736. // ClearedFields returns all nullable fields that were cleared during this
  28737. // mutation.
  28738. func (m *TutorialMutation) ClearedFields() []string {
  28739. var fields []string
  28740. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28741. fields = append(fields, tutorial.FieldDeletedAt)
  28742. }
  28743. return fields
  28744. }
  28745. // FieldCleared returns a boolean indicating if a field with the given name was
  28746. // cleared in this mutation.
  28747. func (m *TutorialMutation) FieldCleared(name string) bool {
  28748. _, ok := m.clearedFields[name]
  28749. return ok
  28750. }
  28751. // ClearField clears the value of the field with the given name. It returns an
  28752. // error if the field is not defined in the schema.
  28753. func (m *TutorialMutation) ClearField(name string) error {
  28754. switch name {
  28755. case tutorial.FieldDeletedAt:
  28756. m.ClearDeletedAt()
  28757. return nil
  28758. }
  28759. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28760. }
  28761. // ResetField resets all changes in the mutation for the field with the given name.
  28762. // It returns an error if the field is not defined in the schema.
  28763. func (m *TutorialMutation) ResetField(name string) error {
  28764. switch name {
  28765. case tutorial.FieldCreatedAt:
  28766. m.ResetCreatedAt()
  28767. return nil
  28768. case tutorial.FieldUpdatedAt:
  28769. m.ResetUpdatedAt()
  28770. return nil
  28771. case tutorial.FieldDeletedAt:
  28772. m.ResetDeletedAt()
  28773. return nil
  28774. case tutorial.FieldEmployeeID:
  28775. m.ResetEmployeeID()
  28776. return nil
  28777. case tutorial.FieldIndex:
  28778. m.ResetIndex()
  28779. return nil
  28780. case tutorial.FieldTitle:
  28781. m.ResetTitle()
  28782. return nil
  28783. case tutorial.FieldContent:
  28784. m.ResetContent()
  28785. return nil
  28786. case tutorial.FieldOrganizationID:
  28787. m.ResetOrganizationID()
  28788. return nil
  28789. }
  28790. return fmt.Errorf("unknown Tutorial field %s", name)
  28791. }
  28792. // AddedEdges returns all edge names that were set/added in this mutation.
  28793. func (m *TutorialMutation) AddedEdges() []string {
  28794. edges := make([]string, 0, 1)
  28795. if m.employee != nil {
  28796. edges = append(edges, tutorial.EdgeEmployee)
  28797. }
  28798. return edges
  28799. }
  28800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28801. // name in this mutation.
  28802. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28803. switch name {
  28804. case tutorial.EdgeEmployee:
  28805. if id := m.employee; id != nil {
  28806. return []ent.Value{*id}
  28807. }
  28808. }
  28809. return nil
  28810. }
  28811. // RemovedEdges returns all edge names that were removed in this mutation.
  28812. func (m *TutorialMutation) RemovedEdges() []string {
  28813. edges := make([]string, 0, 1)
  28814. return edges
  28815. }
  28816. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28817. // the given name in this mutation.
  28818. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28819. return nil
  28820. }
  28821. // ClearedEdges returns all edge names that were cleared in this mutation.
  28822. func (m *TutorialMutation) ClearedEdges() []string {
  28823. edges := make([]string, 0, 1)
  28824. if m.clearedemployee {
  28825. edges = append(edges, tutorial.EdgeEmployee)
  28826. }
  28827. return edges
  28828. }
  28829. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28830. // was cleared in this mutation.
  28831. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28832. switch name {
  28833. case tutorial.EdgeEmployee:
  28834. return m.clearedemployee
  28835. }
  28836. return false
  28837. }
  28838. // ClearEdge clears the value of the edge with the given name. It returns an error
  28839. // if that edge is not defined in the schema.
  28840. func (m *TutorialMutation) ClearEdge(name string) error {
  28841. switch name {
  28842. case tutorial.EdgeEmployee:
  28843. m.ClearEmployee()
  28844. return nil
  28845. }
  28846. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  28847. }
  28848. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28849. // It returns an error if the edge is not defined in the schema.
  28850. func (m *TutorialMutation) ResetEdge(name string) error {
  28851. switch name {
  28852. case tutorial.EdgeEmployee:
  28853. m.ResetEmployee()
  28854. return nil
  28855. }
  28856. return fmt.Errorf("unknown Tutorial edge %s", name)
  28857. }
  28858. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  28859. type UsageDetailMutation struct {
  28860. config
  28861. op Op
  28862. typ string
  28863. id *uint64
  28864. created_at *time.Time
  28865. updated_at *time.Time
  28866. status *uint8
  28867. addstatus *int8
  28868. _type *int
  28869. add_type *int
  28870. bot_id *string
  28871. receiver_id *string
  28872. app *int
  28873. addapp *int
  28874. session_id *uint64
  28875. addsession_id *int64
  28876. request *string
  28877. response *string
  28878. original_data *custom_types.OriginalData
  28879. total_tokens *uint64
  28880. addtotal_tokens *int64
  28881. prompt_tokens *uint64
  28882. addprompt_tokens *int64
  28883. completion_tokens *uint64
  28884. addcompletion_tokens *int64
  28885. organization_id *uint64
  28886. addorganization_id *int64
  28887. clearedFields map[string]struct{}
  28888. done bool
  28889. oldValue func(context.Context) (*UsageDetail, error)
  28890. predicates []predicate.UsageDetail
  28891. }
  28892. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  28893. // usagedetailOption allows management of the mutation configuration using functional options.
  28894. type usagedetailOption func(*UsageDetailMutation)
  28895. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  28896. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  28897. m := &UsageDetailMutation{
  28898. config: c,
  28899. op: op,
  28900. typ: TypeUsageDetail,
  28901. clearedFields: make(map[string]struct{}),
  28902. }
  28903. for _, opt := range opts {
  28904. opt(m)
  28905. }
  28906. return m
  28907. }
  28908. // withUsageDetailID sets the ID field of the mutation.
  28909. func withUsageDetailID(id uint64) usagedetailOption {
  28910. return func(m *UsageDetailMutation) {
  28911. var (
  28912. err error
  28913. once sync.Once
  28914. value *UsageDetail
  28915. )
  28916. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28917. once.Do(func() {
  28918. if m.done {
  28919. err = errors.New("querying old values post mutation is not allowed")
  28920. } else {
  28921. value, err = m.Client().UsageDetail.Get(ctx, id)
  28922. }
  28923. })
  28924. return value, err
  28925. }
  28926. m.id = &id
  28927. }
  28928. }
  28929. // withUsageDetail sets the old UsageDetail of the mutation.
  28930. func withUsageDetail(node *UsageDetail) usagedetailOption {
  28931. return func(m *UsageDetailMutation) {
  28932. m.oldValue = func(context.Context) (*UsageDetail, error) {
  28933. return node, nil
  28934. }
  28935. m.id = &node.ID
  28936. }
  28937. }
  28938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28939. // executed in a transaction (ent.Tx), a transactional client is returned.
  28940. func (m UsageDetailMutation) Client() *Client {
  28941. client := &Client{config: m.config}
  28942. client.init()
  28943. return client
  28944. }
  28945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28946. // it returns an error otherwise.
  28947. func (m UsageDetailMutation) Tx() (*Tx, error) {
  28948. if _, ok := m.driver.(*txDriver); !ok {
  28949. return nil, errors.New("ent: mutation is not running in a transaction")
  28950. }
  28951. tx := &Tx{config: m.config}
  28952. tx.init()
  28953. return tx, nil
  28954. }
  28955. // SetID sets the value of the id field. Note that this
  28956. // operation is only accepted on creation of UsageDetail entities.
  28957. func (m *UsageDetailMutation) SetID(id uint64) {
  28958. m.id = &id
  28959. }
  28960. // ID returns the ID value in the mutation. Note that the ID is only available
  28961. // if it was provided to the builder or after it was returned from the database.
  28962. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  28963. if m.id == nil {
  28964. return
  28965. }
  28966. return *m.id, true
  28967. }
  28968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28969. // That means, if the mutation is applied within a transaction with an isolation level such
  28970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28971. // or updated by the mutation.
  28972. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  28973. switch {
  28974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28975. id, exists := m.ID()
  28976. if exists {
  28977. return []uint64{id}, nil
  28978. }
  28979. fallthrough
  28980. case m.op.Is(OpUpdate | OpDelete):
  28981. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  28982. default:
  28983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28984. }
  28985. }
  28986. // SetCreatedAt sets the "created_at" field.
  28987. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  28988. m.created_at = &t
  28989. }
  28990. // CreatedAt returns the value of the "created_at" field in the mutation.
  28991. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  28992. v := m.created_at
  28993. if v == nil {
  28994. return
  28995. }
  28996. return *v, true
  28997. }
  28998. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  28999. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29001. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29002. if !m.op.Is(OpUpdateOne) {
  29003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29004. }
  29005. if m.id == nil || m.oldValue == nil {
  29006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29007. }
  29008. oldValue, err := m.oldValue(ctx)
  29009. if err != nil {
  29010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29011. }
  29012. return oldValue.CreatedAt, nil
  29013. }
  29014. // ResetCreatedAt resets all changes to the "created_at" field.
  29015. func (m *UsageDetailMutation) ResetCreatedAt() {
  29016. m.created_at = nil
  29017. }
  29018. // SetUpdatedAt sets the "updated_at" field.
  29019. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29020. m.updated_at = &t
  29021. }
  29022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29023. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29024. v := m.updated_at
  29025. if v == nil {
  29026. return
  29027. }
  29028. return *v, true
  29029. }
  29030. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29031. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29033. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29034. if !m.op.Is(OpUpdateOne) {
  29035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29036. }
  29037. if m.id == nil || m.oldValue == nil {
  29038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29039. }
  29040. oldValue, err := m.oldValue(ctx)
  29041. if err != nil {
  29042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29043. }
  29044. return oldValue.UpdatedAt, nil
  29045. }
  29046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29047. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29048. m.updated_at = nil
  29049. }
  29050. // SetStatus sets the "status" field.
  29051. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29052. m.status = &u
  29053. m.addstatus = nil
  29054. }
  29055. // Status returns the value of the "status" field in the mutation.
  29056. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29057. v := m.status
  29058. if v == nil {
  29059. return
  29060. }
  29061. return *v, true
  29062. }
  29063. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29064. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29066. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29067. if !m.op.Is(OpUpdateOne) {
  29068. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29069. }
  29070. if m.id == nil || m.oldValue == nil {
  29071. return v, errors.New("OldStatus requires an ID field in the mutation")
  29072. }
  29073. oldValue, err := m.oldValue(ctx)
  29074. if err != nil {
  29075. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29076. }
  29077. return oldValue.Status, nil
  29078. }
  29079. // AddStatus adds u to the "status" field.
  29080. func (m *UsageDetailMutation) AddStatus(u int8) {
  29081. if m.addstatus != nil {
  29082. *m.addstatus += u
  29083. } else {
  29084. m.addstatus = &u
  29085. }
  29086. }
  29087. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29088. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29089. v := m.addstatus
  29090. if v == nil {
  29091. return
  29092. }
  29093. return *v, true
  29094. }
  29095. // ClearStatus clears the value of the "status" field.
  29096. func (m *UsageDetailMutation) ClearStatus() {
  29097. m.status = nil
  29098. m.addstatus = nil
  29099. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29100. }
  29101. // StatusCleared returns if the "status" field was cleared in this mutation.
  29102. func (m *UsageDetailMutation) StatusCleared() bool {
  29103. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29104. return ok
  29105. }
  29106. // ResetStatus resets all changes to the "status" field.
  29107. func (m *UsageDetailMutation) ResetStatus() {
  29108. m.status = nil
  29109. m.addstatus = nil
  29110. delete(m.clearedFields, usagedetail.FieldStatus)
  29111. }
  29112. // SetType sets the "type" field.
  29113. func (m *UsageDetailMutation) SetType(i int) {
  29114. m._type = &i
  29115. m.add_type = nil
  29116. }
  29117. // GetType returns the value of the "type" field in the mutation.
  29118. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29119. v := m._type
  29120. if v == nil {
  29121. return
  29122. }
  29123. return *v, true
  29124. }
  29125. // OldType returns the old "type" field's value of the UsageDetail entity.
  29126. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29128. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29129. if !m.op.Is(OpUpdateOne) {
  29130. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29131. }
  29132. if m.id == nil || m.oldValue == nil {
  29133. return v, errors.New("OldType requires an ID field in the mutation")
  29134. }
  29135. oldValue, err := m.oldValue(ctx)
  29136. if err != nil {
  29137. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29138. }
  29139. return oldValue.Type, nil
  29140. }
  29141. // AddType adds i to the "type" field.
  29142. func (m *UsageDetailMutation) AddType(i int) {
  29143. if m.add_type != nil {
  29144. *m.add_type += i
  29145. } else {
  29146. m.add_type = &i
  29147. }
  29148. }
  29149. // AddedType returns the value that was added to the "type" field in this mutation.
  29150. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29151. v := m.add_type
  29152. if v == nil {
  29153. return
  29154. }
  29155. return *v, true
  29156. }
  29157. // ClearType clears the value of the "type" field.
  29158. func (m *UsageDetailMutation) ClearType() {
  29159. m._type = nil
  29160. m.add_type = nil
  29161. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29162. }
  29163. // TypeCleared returns if the "type" field was cleared in this mutation.
  29164. func (m *UsageDetailMutation) TypeCleared() bool {
  29165. _, ok := m.clearedFields[usagedetail.FieldType]
  29166. return ok
  29167. }
  29168. // ResetType resets all changes to the "type" field.
  29169. func (m *UsageDetailMutation) ResetType() {
  29170. m._type = nil
  29171. m.add_type = nil
  29172. delete(m.clearedFields, usagedetail.FieldType)
  29173. }
  29174. // SetBotID sets the "bot_id" field.
  29175. func (m *UsageDetailMutation) SetBotID(s string) {
  29176. m.bot_id = &s
  29177. }
  29178. // BotID returns the value of the "bot_id" field in the mutation.
  29179. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29180. v := m.bot_id
  29181. if v == nil {
  29182. return
  29183. }
  29184. return *v, true
  29185. }
  29186. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29187. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29189. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29190. if !m.op.Is(OpUpdateOne) {
  29191. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29192. }
  29193. if m.id == nil || m.oldValue == nil {
  29194. return v, errors.New("OldBotID requires an ID field in the mutation")
  29195. }
  29196. oldValue, err := m.oldValue(ctx)
  29197. if err != nil {
  29198. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29199. }
  29200. return oldValue.BotID, nil
  29201. }
  29202. // ResetBotID resets all changes to the "bot_id" field.
  29203. func (m *UsageDetailMutation) ResetBotID() {
  29204. m.bot_id = nil
  29205. }
  29206. // SetReceiverID sets the "receiver_id" field.
  29207. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29208. m.receiver_id = &s
  29209. }
  29210. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29211. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29212. v := m.receiver_id
  29213. if v == nil {
  29214. return
  29215. }
  29216. return *v, true
  29217. }
  29218. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29219. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29221. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29222. if !m.op.Is(OpUpdateOne) {
  29223. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29224. }
  29225. if m.id == nil || m.oldValue == nil {
  29226. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29227. }
  29228. oldValue, err := m.oldValue(ctx)
  29229. if err != nil {
  29230. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29231. }
  29232. return oldValue.ReceiverID, nil
  29233. }
  29234. // ResetReceiverID resets all changes to the "receiver_id" field.
  29235. func (m *UsageDetailMutation) ResetReceiverID() {
  29236. m.receiver_id = nil
  29237. }
  29238. // SetApp sets the "app" field.
  29239. func (m *UsageDetailMutation) SetApp(i int) {
  29240. m.app = &i
  29241. m.addapp = nil
  29242. }
  29243. // App returns the value of the "app" field in the mutation.
  29244. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29245. v := m.app
  29246. if v == nil {
  29247. return
  29248. }
  29249. return *v, true
  29250. }
  29251. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29252. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29254. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29255. if !m.op.Is(OpUpdateOne) {
  29256. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29257. }
  29258. if m.id == nil || m.oldValue == nil {
  29259. return v, errors.New("OldApp requires an ID field in the mutation")
  29260. }
  29261. oldValue, err := m.oldValue(ctx)
  29262. if err != nil {
  29263. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29264. }
  29265. return oldValue.App, nil
  29266. }
  29267. // AddApp adds i to the "app" field.
  29268. func (m *UsageDetailMutation) AddApp(i int) {
  29269. if m.addapp != nil {
  29270. *m.addapp += i
  29271. } else {
  29272. m.addapp = &i
  29273. }
  29274. }
  29275. // AddedApp returns the value that was added to the "app" field in this mutation.
  29276. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29277. v := m.addapp
  29278. if v == nil {
  29279. return
  29280. }
  29281. return *v, true
  29282. }
  29283. // ClearApp clears the value of the "app" field.
  29284. func (m *UsageDetailMutation) ClearApp() {
  29285. m.app = nil
  29286. m.addapp = nil
  29287. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29288. }
  29289. // AppCleared returns if the "app" field was cleared in this mutation.
  29290. func (m *UsageDetailMutation) AppCleared() bool {
  29291. _, ok := m.clearedFields[usagedetail.FieldApp]
  29292. return ok
  29293. }
  29294. // ResetApp resets all changes to the "app" field.
  29295. func (m *UsageDetailMutation) ResetApp() {
  29296. m.app = nil
  29297. m.addapp = nil
  29298. delete(m.clearedFields, usagedetail.FieldApp)
  29299. }
  29300. // SetSessionID sets the "session_id" field.
  29301. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29302. m.session_id = &u
  29303. m.addsession_id = nil
  29304. }
  29305. // SessionID returns the value of the "session_id" field in the mutation.
  29306. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29307. v := m.session_id
  29308. if v == nil {
  29309. return
  29310. }
  29311. return *v, true
  29312. }
  29313. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29314. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29316. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29317. if !m.op.Is(OpUpdateOne) {
  29318. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29319. }
  29320. if m.id == nil || m.oldValue == nil {
  29321. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29322. }
  29323. oldValue, err := m.oldValue(ctx)
  29324. if err != nil {
  29325. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29326. }
  29327. return oldValue.SessionID, nil
  29328. }
  29329. // AddSessionID adds u to the "session_id" field.
  29330. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29331. if m.addsession_id != nil {
  29332. *m.addsession_id += u
  29333. } else {
  29334. m.addsession_id = &u
  29335. }
  29336. }
  29337. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29338. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29339. v := m.addsession_id
  29340. if v == nil {
  29341. return
  29342. }
  29343. return *v, true
  29344. }
  29345. // ClearSessionID clears the value of the "session_id" field.
  29346. func (m *UsageDetailMutation) ClearSessionID() {
  29347. m.session_id = nil
  29348. m.addsession_id = nil
  29349. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29350. }
  29351. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29352. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29353. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29354. return ok
  29355. }
  29356. // ResetSessionID resets all changes to the "session_id" field.
  29357. func (m *UsageDetailMutation) ResetSessionID() {
  29358. m.session_id = nil
  29359. m.addsession_id = nil
  29360. delete(m.clearedFields, usagedetail.FieldSessionID)
  29361. }
  29362. // SetRequest sets the "request" field.
  29363. func (m *UsageDetailMutation) SetRequest(s string) {
  29364. m.request = &s
  29365. }
  29366. // Request returns the value of the "request" field in the mutation.
  29367. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29368. v := m.request
  29369. if v == nil {
  29370. return
  29371. }
  29372. return *v, true
  29373. }
  29374. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29375. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29377. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29378. if !m.op.Is(OpUpdateOne) {
  29379. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29380. }
  29381. if m.id == nil || m.oldValue == nil {
  29382. return v, errors.New("OldRequest requires an ID field in the mutation")
  29383. }
  29384. oldValue, err := m.oldValue(ctx)
  29385. if err != nil {
  29386. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29387. }
  29388. return oldValue.Request, nil
  29389. }
  29390. // ResetRequest resets all changes to the "request" field.
  29391. func (m *UsageDetailMutation) ResetRequest() {
  29392. m.request = nil
  29393. }
  29394. // SetResponse sets the "response" field.
  29395. func (m *UsageDetailMutation) SetResponse(s string) {
  29396. m.response = &s
  29397. }
  29398. // Response returns the value of the "response" field in the mutation.
  29399. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29400. v := m.response
  29401. if v == nil {
  29402. return
  29403. }
  29404. return *v, true
  29405. }
  29406. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29407. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29409. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29410. if !m.op.Is(OpUpdateOne) {
  29411. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29412. }
  29413. if m.id == nil || m.oldValue == nil {
  29414. return v, errors.New("OldResponse requires an ID field in the mutation")
  29415. }
  29416. oldValue, err := m.oldValue(ctx)
  29417. if err != nil {
  29418. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29419. }
  29420. return oldValue.Response, nil
  29421. }
  29422. // ResetResponse resets all changes to the "response" field.
  29423. func (m *UsageDetailMutation) ResetResponse() {
  29424. m.response = nil
  29425. }
  29426. // SetOriginalData sets the "original_data" field.
  29427. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29428. m.original_data = &ctd
  29429. }
  29430. // OriginalData returns the value of the "original_data" field in the mutation.
  29431. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29432. v := m.original_data
  29433. if v == nil {
  29434. return
  29435. }
  29436. return *v, true
  29437. }
  29438. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29439. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29441. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29442. if !m.op.Is(OpUpdateOne) {
  29443. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29444. }
  29445. if m.id == nil || m.oldValue == nil {
  29446. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29447. }
  29448. oldValue, err := m.oldValue(ctx)
  29449. if err != nil {
  29450. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29451. }
  29452. return oldValue.OriginalData, nil
  29453. }
  29454. // ResetOriginalData resets all changes to the "original_data" field.
  29455. func (m *UsageDetailMutation) ResetOriginalData() {
  29456. m.original_data = nil
  29457. }
  29458. // SetTotalTokens sets the "total_tokens" field.
  29459. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29460. m.total_tokens = &u
  29461. m.addtotal_tokens = nil
  29462. }
  29463. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29464. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29465. v := m.total_tokens
  29466. if v == nil {
  29467. return
  29468. }
  29469. return *v, true
  29470. }
  29471. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29472. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29474. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29475. if !m.op.Is(OpUpdateOne) {
  29476. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29477. }
  29478. if m.id == nil || m.oldValue == nil {
  29479. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29480. }
  29481. oldValue, err := m.oldValue(ctx)
  29482. if err != nil {
  29483. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29484. }
  29485. return oldValue.TotalTokens, nil
  29486. }
  29487. // AddTotalTokens adds u to the "total_tokens" field.
  29488. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29489. if m.addtotal_tokens != nil {
  29490. *m.addtotal_tokens += u
  29491. } else {
  29492. m.addtotal_tokens = &u
  29493. }
  29494. }
  29495. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29496. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29497. v := m.addtotal_tokens
  29498. if v == nil {
  29499. return
  29500. }
  29501. return *v, true
  29502. }
  29503. // ClearTotalTokens clears the value of the "total_tokens" field.
  29504. func (m *UsageDetailMutation) ClearTotalTokens() {
  29505. m.total_tokens = nil
  29506. m.addtotal_tokens = nil
  29507. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29508. }
  29509. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29510. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29511. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29512. return ok
  29513. }
  29514. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29515. func (m *UsageDetailMutation) ResetTotalTokens() {
  29516. m.total_tokens = nil
  29517. m.addtotal_tokens = nil
  29518. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29519. }
  29520. // SetPromptTokens sets the "prompt_tokens" field.
  29521. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29522. m.prompt_tokens = &u
  29523. m.addprompt_tokens = nil
  29524. }
  29525. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29526. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29527. v := m.prompt_tokens
  29528. if v == nil {
  29529. return
  29530. }
  29531. return *v, true
  29532. }
  29533. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29534. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29536. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29537. if !m.op.Is(OpUpdateOne) {
  29538. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29539. }
  29540. if m.id == nil || m.oldValue == nil {
  29541. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29542. }
  29543. oldValue, err := m.oldValue(ctx)
  29544. if err != nil {
  29545. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29546. }
  29547. return oldValue.PromptTokens, nil
  29548. }
  29549. // AddPromptTokens adds u to the "prompt_tokens" field.
  29550. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29551. if m.addprompt_tokens != nil {
  29552. *m.addprompt_tokens += u
  29553. } else {
  29554. m.addprompt_tokens = &u
  29555. }
  29556. }
  29557. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29558. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29559. v := m.addprompt_tokens
  29560. if v == nil {
  29561. return
  29562. }
  29563. return *v, true
  29564. }
  29565. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29566. func (m *UsageDetailMutation) ClearPromptTokens() {
  29567. m.prompt_tokens = nil
  29568. m.addprompt_tokens = nil
  29569. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29570. }
  29571. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29572. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29573. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29574. return ok
  29575. }
  29576. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29577. func (m *UsageDetailMutation) ResetPromptTokens() {
  29578. m.prompt_tokens = nil
  29579. m.addprompt_tokens = nil
  29580. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29581. }
  29582. // SetCompletionTokens sets the "completion_tokens" field.
  29583. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29584. m.completion_tokens = &u
  29585. m.addcompletion_tokens = nil
  29586. }
  29587. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29588. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29589. v := m.completion_tokens
  29590. if v == nil {
  29591. return
  29592. }
  29593. return *v, true
  29594. }
  29595. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29596. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29598. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29599. if !m.op.Is(OpUpdateOne) {
  29600. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29601. }
  29602. if m.id == nil || m.oldValue == nil {
  29603. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29604. }
  29605. oldValue, err := m.oldValue(ctx)
  29606. if err != nil {
  29607. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29608. }
  29609. return oldValue.CompletionTokens, nil
  29610. }
  29611. // AddCompletionTokens adds u to the "completion_tokens" field.
  29612. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29613. if m.addcompletion_tokens != nil {
  29614. *m.addcompletion_tokens += u
  29615. } else {
  29616. m.addcompletion_tokens = &u
  29617. }
  29618. }
  29619. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29620. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29621. v := m.addcompletion_tokens
  29622. if v == nil {
  29623. return
  29624. }
  29625. return *v, true
  29626. }
  29627. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29628. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29629. m.completion_tokens = nil
  29630. m.addcompletion_tokens = nil
  29631. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29632. }
  29633. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29634. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29635. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29636. return ok
  29637. }
  29638. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29639. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29640. m.completion_tokens = nil
  29641. m.addcompletion_tokens = nil
  29642. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29643. }
  29644. // SetOrganizationID sets the "organization_id" field.
  29645. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29646. m.organization_id = &u
  29647. m.addorganization_id = nil
  29648. }
  29649. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29650. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29651. v := m.organization_id
  29652. if v == nil {
  29653. return
  29654. }
  29655. return *v, true
  29656. }
  29657. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29658. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29660. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29661. if !m.op.Is(OpUpdateOne) {
  29662. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29663. }
  29664. if m.id == nil || m.oldValue == nil {
  29665. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29666. }
  29667. oldValue, err := m.oldValue(ctx)
  29668. if err != nil {
  29669. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29670. }
  29671. return oldValue.OrganizationID, nil
  29672. }
  29673. // AddOrganizationID adds u to the "organization_id" field.
  29674. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29675. if m.addorganization_id != nil {
  29676. *m.addorganization_id += u
  29677. } else {
  29678. m.addorganization_id = &u
  29679. }
  29680. }
  29681. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29682. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29683. v := m.addorganization_id
  29684. if v == nil {
  29685. return
  29686. }
  29687. return *v, true
  29688. }
  29689. // ClearOrganizationID clears the value of the "organization_id" field.
  29690. func (m *UsageDetailMutation) ClearOrganizationID() {
  29691. m.organization_id = nil
  29692. m.addorganization_id = nil
  29693. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29694. }
  29695. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29696. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29697. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29698. return ok
  29699. }
  29700. // ResetOrganizationID resets all changes to the "organization_id" field.
  29701. func (m *UsageDetailMutation) ResetOrganizationID() {
  29702. m.organization_id = nil
  29703. m.addorganization_id = nil
  29704. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29705. }
  29706. // Where appends a list predicates to the UsageDetailMutation builder.
  29707. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29708. m.predicates = append(m.predicates, ps...)
  29709. }
  29710. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29711. // users can use type-assertion to append predicates that do not depend on any generated package.
  29712. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29713. p := make([]predicate.UsageDetail, len(ps))
  29714. for i := range ps {
  29715. p[i] = ps[i]
  29716. }
  29717. m.Where(p...)
  29718. }
  29719. // Op returns the operation name.
  29720. func (m *UsageDetailMutation) Op() Op {
  29721. return m.op
  29722. }
  29723. // SetOp allows setting the mutation operation.
  29724. func (m *UsageDetailMutation) SetOp(op Op) {
  29725. m.op = op
  29726. }
  29727. // Type returns the node type of this mutation (UsageDetail).
  29728. func (m *UsageDetailMutation) Type() string {
  29729. return m.typ
  29730. }
  29731. // Fields returns all fields that were changed during this mutation. Note that in
  29732. // order to get all numeric fields that were incremented/decremented, call
  29733. // AddedFields().
  29734. func (m *UsageDetailMutation) Fields() []string {
  29735. fields := make([]string, 0, 15)
  29736. if m.created_at != nil {
  29737. fields = append(fields, usagedetail.FieldCreatedAt)
  29738. }
  29739. if m.updated_at != nil {
  29740. fields = append(fields, usagedetail.FieldUpdatedAt)
  29741. }
  29742. if m.status != nil {
  29743. fields = append(fields, usagedetail.FieldStatus)
  29744. }
  29745. if m._type != nil {
  29746. fields = append(fields, usagedetail.FieldType)
  29747. }
  29748. if m.bot_id != nil {
  29749. fields = append(fields, usagedetail.FieldBotID)
  29750. }
  29751. if m.receiver_id != nil {
  29752. fields = append(fields, usagedetail.FieldReceiverID)
  29753. }
  29754. if m.app != nil {
  29755. fields = append(fields, usagedetail.FieldApp)
  29756. }
  29757. if m.session_id != nil {
  29758. fields = append(fields, usagedetail.FieldSessionID)
  29759. }
  29760. if m.request != nil {
  29761. fields = append(fields, usagedetail.FieldRequest)
  29762. }
  29763. if m.response != nil {
  29764. fields = append(fields, usagedetail.FieldResponse)
  29765. }
  29766. if m.original_data != nil {
  29767. fields = append(fields, usagedetail.FieldOriginalData)
  29768. }
  29769. if m.total_tokens != nil {
  29770. fields = append(fields, usagedetail.FieldTotalTokens)
  29771. }
  29772. if m.prompt_tokens != nil {
  29773. fields = append(fields, usagedetail.FieldPromptTokens)
  29774. }
  29775. if m.completion_tokens != nil {
  29776. fields = append(fields, usagedetail.FieldCompletionTokens)
  29777. }
  29778. if m.organization_id != nil {
  29779. fields = append(fields, usagedetail.FieldOrganizationID)
  29780. }
  29781. return fields
  29782. }
  29783. // Field returns the value of a field with the given name. The second boolean
  29784. // return value indicates that this field was not set, or was not defined in the
  29785. // schema.
  29786. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29787. switch name {
  29788. case usagedetail.FieldCreatedAt:
  29789. return m.CreatedAt()
  29790. case usagedetail.FieldUpdatedAt:
  29791. return m.UpdatedAt()
  29792. case usagedetail.FieldStatus:
  29793. return m.Status()
  29794. case usagedetail.FieldType:
  29795. return m.GetType()
  29796. case usagedetail.FieldBotID:
  29797. return m.BotID()
  29798. case usagedetail.FieldReceiverID:
  29799. return m.ReceiverID()
  29800. case usagedetail.FieldApp:
  29801. return m.App()
  29802. case usagedetail.FieldSessionID:
  29803. return m.SessionID()
  29804. case usagedetail.FieldRequest:
  29805. return m.Request()
  29806. case usagedetail.FieldResponse:
  29807. return m.Response()
  29808. case usagedetail.FieldOriginalData:
  29809. return m.OriginalData()
  29810. case usagedetail.FieldTotalTokens:
  29811. return m.TotalTokens()
  29812. case usagedetail.FieldPromptTokens:
  29813. return m.PromptTokens()
  29814. case usagedetail.FieldCompletionTokens:
  29815. return m.CompletionTokens()
  29816. case usagedetail.FieldOrganizationID:
  29817. return m.OrganizationID()
  29818. }
  29819. return nil, false
  29820. }
  29821. // OldField returns the old value of the field from the database. An error is
  29822. // returned if the mutation operation is not UpdateOne, or the query to the
  29823. // database failed.
  29824. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29825. switch name {
  29826. case usagedetail.FieldCreatedAt:
  29827. return m.OldCreatedAt(ctx)
  29828. case usagedetail.FieldUpdatedAt:
  29829. return m.OldUpdatedAt(ctx)
  29830. case usagedetail.FieldStatus:
  29831. return m.OldStatus(ctx)
  29832. case usagedetail.FieldType:
  29833. return m.OldType(ctx)
  29834. case usagedetail.FieldBotID:
  29835. return m.OldBotID(ctx)
  29836. case usagedetail.FieldReceiverID:
  29837. return m.OldReceiverID(ctx)
  29838. case usagedetail.FieldApp:
  29839. return m.OldApp(ctx)
  29840. case usagedetail.FieldSessionID:
  29841. return m.OldSessionID(ctx)
  29842. case usagedetail.FieldRequest:
  29843. return m.OldRequest(ctx)
  29844. case usagedetail.FieldResponse:
  29845. return m.OldResponse(ctx)
  29846. case usagedetail.FieldOriginalData:
  29847. return m.OldOriginalData(ctx)
  29848. case usagedetail.FieldTotalTokens:
  29849. return m.OldTotalTokens(ctx)
  29850. case usagedetail.FieldPromptTokens:
  29851. return m.OldPromptTokens(ctx)
  29852. case usagedetail.FieldCompletionTokens:
  29853. return m.OldCompletionTokens(ctx)
  29854. case usagedetail.FieldOrganizationID:
  29855. return m.OldOrganizationID(ctx)
  29856. }
  29857. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  29858. }
  29859. // SetField sets the value of a field with the given name. It returns an error if
  29860. // the field is not defined in the schema, or if the type mismatched the field
  29861. // type.
  29862. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  29863. switch name {
  29864. case usagedetail.FieldCreatedAt:
  29865. v, ok := value.(time.Time)
  29866. if !ok {
  29867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29868. }
  29869. m.SetCreatedAt(v)
  29870. return nil
  29871. case usagedetail.FieldUpdatedAt:
  29872. v, ok := value.(time.Time)
  29873. if !ok {
  29874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29875. }
  29876. m.SetUpdatedAt(v)
  29877. return nil
  29878. case usagedetail.FieldStatus:
  29879. v, ok := value.(uint8)
  29880. if !ok {
  29881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29882. }
  29883. m.SetStatus(v)
  29884. return nil
  29885. case usagedetail.FieldType:
  29886. v, ok := value.(int)
  29887. if !ok {
  29888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29889. }
  29890. m.SetType(v)
  29891. return nil
  29892. case usagedetail.FieldBotID:
  29893. v, ok := value.(string)
  29894. if !ok {
  29895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29896. }
  29897. m.SetBotID(v)
  29898. return nil
  29899. case usagedetail.FieldReceiverID:
  29900. v, ok := value.(string)
  29901. if !ok {
  29902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29903. }
  29904. m.SetReceiverID(v)
  29905. return nil
  29906. case usagedetail.FieldApp:
  29907. v, ok := value.(int)
  29908. if !ok {
  29909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29910. }
  29911. m.SetApp(v)
  29912. return nil
  29913. case usagedetail.FieldSessionID:
  29914. v, ok := value.(uint64)
  29915. if !ok {
  29916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29917. }
  29918. m.SetSessionID(v)
  29919. return nil
  29920. case usagedetail.FieldRequest:
  29921. v, ok := value.(string)
  29922. if !ok {
  29923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29924. }
  29925. m.SetRequest(v)
  29926. return nil
  29927. case usagedetail.FieldResponse:
  29928. v, ok := value.(string)
  29929. if !ok {
  29930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29931. }
  29932. m.SetResponse(v)
  29933. return nil
  29934. case usagedetail.FieldOriginalData:
  29935. v, ok := value.(custom_types.OriginalData)
  29936. if !ok {
  29937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29938. }
  29939. m.SetOriginalData(v)
  29940. return nil
  29941. case usagedetail.FieldTotalTokens:
  29942. v, ok := value.(uint64)
  29943. if !ok {
  29944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29945. }
  29946. m.SetTotalTokens(v)
  29947. return nil
  29948. case usagedetail.FieldPromptTokens:
  29949. v, ok := value.(uint64)
  29950. if !ok {
  29951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29952. }
  29953. m.SetPromptTokens(v)
  29954. return nil
  29955. case usagedetail.FieldCompletionTokens:
  29956. v, ok := value.(uint64)
  29957. if !ok {
  29958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29959. }
  29960. m.SetCompletionTokens(v)
  29961. return nil
  29962. case usagedetail.FieldOrganizationID:
  29963. v, ok := value.(uint64)
  29964. if !ok {
  29965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29966. }
  29967. m.SetOrganizationID(v)
  29968. return nil
  29969. }
  29970. return fmt.Errorf("unknown UsageDetail field %s", name)
  29971. }
  29972. // AddedFields returns all numeric fields that were incremented/decremented during
  29973. // this mutation.
  29974. func (m *UsageDetailMutation) AddedFields() []string {
  29975. var fields []string
  29976. if m.addstatus != nil {
  29977. fields = append(fields, usagedetail.FieldStatus)
  29978. }
  29979. if m.add_type != nil {
  29980. fields = append(fields, usagedetail.FieldType)
  29981. }
  29982. if m.addapp != nil {
  29983. fields = append(fields, usagedetail.FieldApp)
  29984. }
  29985. if m.addsession_id != nil {
  29986. fields = append(fields, usagedetail.FieldSessionID)
  29987. }
  29988. if m.addtotal_tokens != nil {
  29989. fields = append(fields, usagedetail.FieldTotalTokens)
  29990. }
  29991. if m.addprompt_tokens != nil {
  29992. fields = append(fields, usagedetail.FieldPromptTokens)
  29993. }
  29994. if m.addcompletion_tokens != nil {
  29995. fields = append(fields, usagedetail.FieldCompletionTokens)
  29996. }
  29997. if m.addorganization_id != nil {
  29998. fields = append(fields, usagedetail.FieldOrganizationID)
  29999. }
  30000. return fields
  30001. }
  30002. // AddedField returns the numeric value that was incremented/decremented on a field
  30003. // with the given name. The second boolean return value indicates that this field
  30004. // was not set, or was not defined in the schema.
  30005. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30006. switch name {
  30007. case usagedetail.FieldStatus:
  30008. return m.AddedStatus()
  30009. case usagedetail.FieldType:
  30010. return m.AddedType()
  30011. case usagedetail.FieldApp:
  30012. return m.AddedApp()
  30013. case usagedetail.FieldSessionID:
  30014. return m.AddedSessionID()
  30015. case usagedetail.FieldTotalTokens:
  30016. return m.AddedTotalTokens()
  30017. case usagedetail.FieldPromptTokens:
  30018. return m.AddedPromptTokens()
  30019. case usagedetail.FieldCompletionTokens:
  30020. return m.AddedCompletionTokens()
  30021. case usagedetail.FieldOrganizationID:
  30022. return m.AddedOrganizationID()
  30023. }
  30024. return nil, false
  30025. }
  30026. // AddField adds the value to the field with the given name. It returns an error if
  30027. // the field is not defined in the schema, or if the type mismatched the field
  30028. // type.
  30029. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30030. switch name {
  30031. case usagedetail.FieldStatus:
  30032. v, ok := value.(int8)
  30033. if !ok {
  30034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30035. }
  30036. m.AddStatus(v)
  30037. return nil
  30038. case usagedetail.FieldType:
  30039. v, ok := value.(int)
  30040. if !ok {
  30041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30042. }
  30043. m.AddType(v)
  30044. return nil
  30045. case usagedetail.FieldApp:
  30046. v, ok := value.(int)
  30047. if !ok {
  30048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30049. }
  30050. m.AddApp(v)
  30051. return nil
  30052. case usagedetail.FieldSessionID:
  30053. v, ok := value.(int64)
  30054. if !ok {
  30055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30056. }
  30057. m.AddSessionID(v)
  30058. return nil
  30059. case usagedetail.FieldTotalTokens:
  30060. v, ok := value.(int64)
  30061. if !ok {
  30062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30063. }
  30064. m.AddTotalTokens(v)
  30065. return nil
  30066. case usagedetail.FieldPromptTokens:
  30067. v, ok := value.(int64)
  30068. if !ok {
  30069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30070. }
  30071. m.AddPromptTokens(v)
  30072. return nil
  30073. case usagedetail.FieldCompletionTokens:
  30074. v, ok := value.(int64)
  30075. if !ok {
  30076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30077. }
  30078. m.AddCompletionTokens(v)
  30079. return nil
  30080. case usagedetail.FieldOrganizationID:
  30081. v, ok := value.(int64)
  30082. if !ok {
  30083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30084. }
  30085. m.AddOrganizationID(v)
  30086. return nil
  30087. }
  30088. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30089. }
  30090. // ClearedFields returns all nullable fields that were cleared during this
  30091. // mutation.
  30092. func (m *UsageDetailMutation) ClearedFields() []string {
  30093. var fields []string
  30094. if m.FieldCleared(usagedetail.FieldStatus) {
  30095. fields = append(fields, usagedetail.FieldStatus)
  30096. }
  30097. if m.FieldCleared(usagedetail.FieldType) {
  30098. fields = append(fields, usagedetail.FieldType)
  30099. }
  30100. if m.FieldCleared(usagedetail.FieldApp) {
  30101. fields = append(fields, usagedetail.FieldApp)
  30102. }
  30103. if m.FieldCleared(usagedetail.FieldSessionID) {
  30104. fields = append(fields, usagedetail.FieldSessionID)
  30105. }
  30106. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30107. fields = append(fields, usagedetail.FieldTotalTokens)
  30108. }
  30109. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30110. fields = append(fields, usagedetail.FieldPromptTokens)
  30111. }
  30112. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30113. fields = append(fields, usagedetail.FieldCompletionTokens)
  30114. }
  30115. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30116. fields = append(fields, usagedetail.FieldOrganizationID)
  30117. }
  30118. return fields
  30119. }
  30120. // FieldCleared returns a boolean indicating if a field with the given name was
  30121. // cleared in this mutation.
  30122. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30123. _, ok := m.clearedFields[name]
  30124. return ok
  30125. }
  30126. // ClearField clears the value of the field with the given name. It returns an
  30127. // error if the field is not defined in the schema.
  30128. func (m *UsageDetailMutation) ClearField(name string) error {
  30129. switch name {
  30130. case usagedetail.FieldStatus:
  30131. m.ClearStatus()
  30132. return nil
  30133. case usagedetail.FieldType:
  30134. m.ClearType()
  30135. return nil
  30136. case usagedetail.FieldApp:
  30137. m.ClearApp()
  30138. return nil
  30139. case usagedetail.FieldSessionID:
  30140. m.ClearSessionID()
  30141. return nil
  30142. case usagedetail.FieldTotalTokens:
  30143. m.ClearTotalTokens()
  30144. return nil
  30145. case usagedetail.FieldPromptTokens:
  30146. m.ClearPromptTokens()
  30147. return nil
  30148. case usagedetail.FieldCompletionTokens:
  30149. m.ClearCompletionTokens()
  30150. return nil
  30151. case usagedetail.FieldOrganizationID:
  30152. m.ClearOrganizationID()
  30153. return nil
  30154. }
  30155. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30156. }
  30157. // ResetField resets all changes in the mutation for the field with the given name.
  30158. // It returns an error if the field is not defined in the schema.
  30159. func (m *UsageDetailMutation) ResetField(name string) error {
  30160. switch name {
  30161. case usagedetail.FieldCreatedAt:
  30162. m.ResetCreatedAt()
  30163. return nil
  30164. case usagedetail.FieldUpdatedAt:
  30165. m.ResetUpdatedAt()
  30166. return nil
  30167. case usagedetail.FieldStatus:
  30168. m.ResetStatus()
  30169. return nil
  30170. case usagedetail.FieldType:
  30171. m.ResetType()
  30172. return nil
  30173. case usagedetail.FieldBotID:
  30174. m.ResetBotID()
  30175. return nil
  30176. case usagedetail.FieldReceiverID:
  30177. m.ResetReceiverID()
  30178. return nil
  30179. case usagedetail.FieldApp:
  30180. m.ResetApp()
  30181. return nil
  30182. case usagedetail.FieldSessionID:
  30183. m.ResetSessionID()
  30184. return nil
  30185. case usagedetail.FieldRequest:
  30186. m.ResetRequest()
  30187. return nil
  30188. case usagedetail.FieldResponse:
  30189. m.ResetResponse()
  30190. return nil
  30191. case usagedetail.FieldOriginalData:
  30192. m.ResetOriginalData()
  30193. return nil
  30194. case usagedetail.FieldTotalTokens:
  30195. m.ResetTotalTokens()
  30196. return nil
  30197. case usagedetail.FieldPromptTokens:
  30198. m.ResetPromptTokens()
  30199. return nil
  30200. case usagedetail.FieldCompletionTokens:
  30201. m.ResetCompletionTokens()
  30202. return nil
  30203. case usagedetail.FieldOrganizationID:
  30204. m.ResetOrganizationID()
  30205. return nil
  30206. }
  30207. return fmt.Errorf("unknown UsageDetail field %s", name)
  30208. }
  30209. // AddedEdges returns all edge names that were set/added in this mutation.
  30210. func (m *UsageDetailMutation) AddedEdges() []string {
  30211. edges := make([]string, 0, 0)
  30212. return edges
  30213. }
  30214. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30215. // name in this mutation.
  30216. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30217. return nil
  30218. }
  30219. // RemovedEdges returns all edge names that were removed in this mutation.
  30220. func (m *UsageDetailMutation) RemovedEdges() []string {
  30221. edges := make([]string, 0, 0)
  30222. return edges
  30223. }
  30224. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30225. // the given name in this mutation.
  30226. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30227. return nil
  30228. }
  30229. // ClearedEdges returns all edge names that were cleared in this mutation.
  30230. func (m *UsageDetailMutation) ClearedEdges() []string {
  30231. edges := make([]string, 0, 0)
  30232. return edges
  30233. }
  30234. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30235. // was cleared in this mutation.
  30236. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30237. return false
  30238. }
  30239. // ClearEdge clears the value of the edge with the given name. It returns an error
  30240. // if that edge is not defined in the schema.
  30241. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30242. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30243. }
  30244. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30245. // It returns an error if the edge is not defined in the schema.
  30246. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30247. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30248. }
  30249. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30250. type UsageStatisticDayMutation struct {
  30251. config
  30252. op Op
  30253. typ string
  30254. id *uint64
  30255. created_at *time.Time
  30256. updated_at *time.Time
  30257. status *uint8
  30258. addstatus *int8
  30259. deleted_at *time.Time
  30260. addtime *uint64
  30261. addaddtime *int64
  30262. _type *int
  30263. add_type *int
  30264. bot_id *string
  30265. organization_id *uint64
  30266. addorganization_id *int64
  30267. ai_response *uint64
  30268. addai_response *int64
  30269. sop_run *uint64
  30270. addsop_run *int64
  30271. total_friend *uint64
  30272. addtotal_friend *int64
  30273. total_group *uint64
  30274. addtotal_group *int64
  30275. account_balance *uint64
  30276. addaccount_balance *int64
  30277. consume_token *uint64
  30278. addconsume_token *int64
  30279. active_user *uint64
  30280. addactive_user *int64
  30281. new_user *int64
  30282. addnew_user *int64
  30283. label_dist *[]custom_types.LabelDist
  30284. appendlabel_dist []custom_types.LabelDist
  30285. clearedFields map[string]struct{}
  30286. done bool
  30287. oldValue func(context.Context) (*UsageStatisticDay, error)
  30288. predicates []predicate.UsageStatisticDay
  30289. }
  30290. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30291. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30292. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30293. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30294. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30295. m := &UsageStatisticDayMutation{
  30296. config: c,
  30297. op: op,
  30298. typ: TypeUsageStatisticDay,
  30299. clearedFields: make(map[string]struct{}),
  30300. }
  30301. for _, opt := range opts {
  30302. opt(m)
  30303. }
  30304. return m
  30305. }
  30306. // withUsageStatisticDayID sets the ID field of the mutation.
  30307. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30308. return func(m *UsageStatisticDayMutation) {
  30309. var (
  30310. err error
  30311. once sync.Once
  30312. value *UsageStatisticDay
  30313. )
  30314. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30315. once.Do(func() {
  30316. if m.done {
  30317. err = errors.New("querying old values post mutation is not allowed")
  30318. } else {
  30319. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30320. }
  30321. })
  30322. return value, err
  30323. }
  30324. m.id = &id
  30325. }
  30326. }
  30327. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30328. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30329. return func(m *UsageStatisticDayMutation) {
  30330. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30331. return node, nil
  30332. }
  30333. m.id = &node.ID
  30334. }
  30335. }
  30336. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30337. // executed in a transaction (ent.Tx), a transactional client is returned.
  30338. func (m UsageStatisticDayMutation) Client() *Client {
  30339. client := &Client{config: m.config}
  30340. client.init()
  30341. return client
  30342. }
  30343. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30344. // it returns an error otherwise.
  30345. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30346. if _, ok := m.driver.(*txDriver); !ok {
  30347. return nil, errors.New("ent: mutation is not running in a transaction")
  30348. }
  30349. tx := &Tx{config: m.config}
  30350. tx.init()
  30351. return tx, nil
  30352. }
  30353. // SetID sets the value of the id field. Note that this
  30354. // operation is only accepted on creation of UsageStatisticDay entities.
  30355. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30356. m.id = &id
  30357. }
  30358. // ID returns the ID value in the mutation. Note that the ID is only available
  30359. // if it was provided to the builder or after it was returned from the database.
  30360. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30361. if m.id == nil {
  30362. return
  30363. }
  30364. return *m.id, true
  30365. }
  30366. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30367. // That means, if the mutation is applied within a transaction with an isolation level such
  30368. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30369. // or updated by the mutation.
  30370. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30371. switch {
  30372. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30373. id, exists := m.ID()
  30374. if exists {
  30375. return []uint64{id}, nil
  30376. }
  30377. fallthrough
  30378. case m.op.Is(OpUpdate | OpDelete):
  30379. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30380. default:
  30381. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30382. }
  30383. }
  30384. // SetCreatedAt sets the "created_at" field.
  30385. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30386. m.created_at = &t
  30387. }
  30388. // CreatedAt returns the value of the "created_at" field in the mutation.
  30389. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30390. v := m.created_at
  30391. if v == nil {
  30392. return
  30393. }
  30394. return *v, true
  30395. }
  30396. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30397. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30399. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30400. if !m.op.Is(OpUpdateOne) {
  30401. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30402. }
  30403. if m.id == nil || m.oldValue == nil {
  30404. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30405. }
  30406. oldValue, err := m.oldValue(ctx)
  30407. if err != nil {
  30408. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30409. }
  30410. return oldValue.CreatedAt, nil
  30411. }
  30412. // ResetCreatedAt resets all changes to the "created_at" field.
  30413. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30414. m.created_at = nil
  30415. }
  30416. // SetUpdatedAt sets the "updated_at" field.
  30417. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30418. m.updated_at = &t
  30419. }
  30420. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30421. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30422. v := m.updated_at
  30423. if v == nil {
  30424. return
  30425. }
  30426. return *v, true
  30427. }
  30428. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30429. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30431. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30432. if !m.op.Is(OpUpdateOne) {
  30433. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30434. }
  30435. if m.id == nil || m.oldValue == nil {
  30436. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30437. }
  30438. oldValue, err := m.oldValue(ctx)
  30439. if err != nil {
  30440. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30441. }
  30442. return oldValue.UpdatedAt, nil
  30443. }
  30444. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30445. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30446. m.updated_at = nil
  30447. }
  30448. // SetStatus sets the "status" field.
  30449. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30450. m.status = &u
  30451. m.addstatus = nil
  30452. }
  30453. // Status returns the value of the "status" field in the mutation.
  30454. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30455. v := m.status
  30456. if v == nil {
  30457. return
  30458. }
  30459. return *v, true
  30460. }
  30461. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30462. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30464. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30465. if !m.op.Is(OpUpdateOne) {
  30466. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30467. }
  30468. if m.id == nil || m.oldValue == nil {
  30469. return v, errors.New("OldStatus requires an ID field in the mutation")
  30470. }
  30471. oldValue, err := m.oldValue(ctx)
  30472. if err != nil {
  30473. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30474. }
  30475. return oldValue.Status, nil
  30476. }
  30477. // AddStatus adds u to the "status" field.
  30478. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30479. if m.addstatus != nil {
  30480. *m.addstatus += u
  30481. } else {
  30482. m.addstatus = &u
  30483. }
  30484. }
  30485. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30486. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30487. v := m.addstatus
  30488. if v == nil {
  30489. return
  30490. }
  30491. return *v, true
  30492. }
  30493. // ClearStatus clears the value of the "status" field.
  30494. func (m *UsageStatisticDayMutation) ClearStatus() {
  30495. m.status = nil
  30496. m.addstatus = nil
  30497. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30498. }
  30499. // StatusCleared returns if the "status" field was cleared in this mutation.
  30500. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30501. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30502. return ok
  30503. }
  30504. // ResetStatus resets all changes to the "status" field.
  30505. func (m *UsageStatisticDayMutation) ResetStatus() {
  30506. m.status = nil
  30507. m.addstatus = nil
  30508. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30509. }
  30510. // SetDeletedAt sets the "deleted_at" field.
  30511. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30512. m.deleted_at = &t
  30513. }
  30514. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30515. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30516. v := m.deleted_at
  30517. if v == nil {
  30518. return
  30519. }
  30520. return *v, true
  30521. }
  30522. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30523. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30525. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30526. if !m.op.Is(OpUpdateOne) {
  30527. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30528. }
  30529. if m.id == nil || m.oldValue == nil {
  30530. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30531. }
  30532. oldValue, err := m.oldValue(ctx)
  30533. if err != nil {
  30534. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30535. }
  30536. return oldValue.DeletedAt, nil
  30537. }
  30538. // ClearDeletedAt clears the value of the "deleted_at" field.
  30539. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30540. m.deleted_at = nil
  30541. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30542. }
  30543. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30544. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30545. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30546. return ok
  30547. }
  30548. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30549. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30550. m.deleted_at = nil
  30551. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30552. }
  30553. // SetAddtime sets the "addtime" field.
  30554. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30555. m.addtime = &u
  30556. m.addaddtime = nil
  30557. }
  30558. // Addtime returns the value of the "addtime" field in the mutation.
  30559. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30560. v := m.addtime
  30561. if v == nil {
  30562. return
  30563. }
  30564. return *v, true
  30565. }
  30566. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30567. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30569. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30570. if !m.op.Is(OpUpdateOne) {
  30571. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30572. }
  30573. if m.id == nil || m.oldValue == nil {
  30574. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30575. }
  30576. oldValue, err := m.oldValue(ctx)
  30577. if err != nil {
  30578. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30579. }
  30580. return oldValue.Addtime, nil
  30581. }
  30582. // AddAddtime adds u to the "addtime" field.
  30583. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30584. if m.addaddtime != nil {
  30585. *m.addaddtime += u
  30586. } else {
  30587. m.addaddtime = &u
  30588. }
  30589. }
  30590. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30591. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30592. v := m.addaddtime
  30593. if v == nil {
  30594. return
  30595. }
  30596. return *v, true
  30597. }
  30598. // ResetAddtime resets all changes to the "addtime" field.
  30599. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30600. m.addtime = nil
  30601. m.addaddtime = nil
  30602. }
  30603. // SetType sets the "type" field.
  30604. func (m *UsageStatisticDayMutation) SetType(i int) {
  30605. m._type = &i
  30606. m.add_type = nil
  30607. }
  30608. // GetType returns the value of the "type" field in the mutation.
  30609. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30610. v := m._type
  30611. if v == nil {
  30612. return
  30613. }
  30614. return *v, true
  30615. }
  30616. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30617. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30619. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30620. if !m.op.Is(OpUpdateOne) {
  30621. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30622. }
  30623. if m.id == nil || m.oldValue == nil {
  30624. return v, errors.New("OldType requires an ID field in the mutation")
  30625. }
  30626. oldValue, err := m.oldValue(ctx)
  30627. if err != nil {
  30628. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30629. }
  30630. return oldValue.Type, nil
  30631. }
  30632. // AddType adds i to the "type" field.
  30633. func (m *UsageStatisticDayMutation) AddType(i int) {
  30634. if m.add_type != nil {
  30635. *m.add_type += i
  30636. } else {
  30637. m.add_type = &i
  30638. }
  30639. }
  30640. // AddedType returns the value that was added to the "type" field in this mutation.
  30641. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30642. v := m.add_type
  30643. if v == nil {
  30644. return
  30645. }
  30646. return *v, true
  30647. }
  30648. // ResetType resets all changes to the "type" field.
  30649. func (m *UsageStatisticDayMutation) ResetType() {
  30650. m._type = nil
  30651. m.add_type = nil
  30652. }
  30653. // SetBotID sets the "bot_id" field.
  30654. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30655. m.bot_id = &s
  30656. }
  30657. // BotID returns the value of the "bot_id" field in the mutation.
  30658. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30659. v := m.bot_id
  30660. if v == nil {
  30661. return
  30662. }
  30663. return *v, true
  30664. }
  30665. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30666. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30668. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30669. if !m.op.Is(OpUpdateOne) {
  30670. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30671. }
  30672. if m.id == nil || m.oldValue == nil {
  30673. return v, errors.New("OldBotID requires an ID field in the mutation")
  30674. }
  30675. oldValue, err := m.oldValue(ctx)
  30676. if err != nil {
  30677. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30678. }
  30679. return oldValue.BotID, nil
  30680. }
  30681. // ClearBotID clears the value of the "bot_id" field.
  30682. func (m *UsageStatisticDayMutation) ClearBotID() {
  30683. m.bot_id = nil
  30684. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30685. }
  30686. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30687. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30688. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30689. return ok
  30690. }
  30691. // ResetBotID resets all changes to the "bot_id" field.
  30692. func (m *UsageStatisticDayMutation) ResetBotID() {
  30693. m.bot_id = nil
  30694. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30695. }
  30696. // SetOrganizationID sets the "organization_id" field.
  30697. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30698. m.organization_id = &u
  30699. m.addorganization_id = nil
  30700. }
  30701. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30702. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30703. v := m.organization_id
  30704. if v == nil {
  30705. return
  30706. }
  30707. return *v, true
  30708. }
  30709. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30710. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30712. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30713. if !m.op.Is(OpUpdateOne) {
  30714. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30715. }
  30716. if m.id == nil || m.oldValue == nil {
  30717. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30718. }
  30719. oldValue, err := m.oldValue(ctx)
  30720. if err != nil {
  30721. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30722. }
  30723. return oldValue.OrganizationID, nil
  30724. }
  30725. // AddOrganizationID adds u to the "organization_id" field.
  30726. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30727. if m.addorganization_id != nil {
  30728. *m.addorganization_id += u
  30729. } else {
  30730. m.addorganization_id = &u
  30731. }
  30732. }
  30733. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30734. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30735. v := m.addorganization_id
  30736. if v == nil {
  30737. return
  30738. }
  30739. return *v, true
  30740. }
  30741. // ClearOrganizationID clears the value of the "organization_id" field.
  30742. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30743. m.organization_id = nil
  30744. m.addorganization_id = nil
  30745. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30746. }
  30747. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30748. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30749. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30750. return ok
  30751. }
  30752. // ResetOrganizationID resets all changes to the "organization_id" field.
  30753. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30754. m.organization_id = nil
  30755. m.addorganization_id = nil
  30756. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30757. }
  30758. // SetAiResponse sets the "ai_response" field.
  30759. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30760. m.ai_response = &u
  30761. m.addai_response = nil
  30762. }
  30763. // AiResponse returns the value of the "ai_response" field in the mutation.
  30764. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30765. v := m.ai_response
  30766. if v == nil {
  30767. return
  30768. }
  30769. return *v, true
  30770. }
  30771. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30772. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30774. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30775. if !m.op.Is(OpUpdateOne) {
  30776. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30777. }
  30778. if m.id == nil || m.oldValue == nil {
  30779. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30780. }
  30781. oldValue, err := m.oldValue(ctx)
  30782. if err != nil {
  30783. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30784. }
  30785. return oldValue.AiResponse, nil
  30786. }
  30787. // AddAiResponse adds u to the "ai_response" field.
  30788. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30789. if m.addai_response != nil {
  30790. *m.addai_response += u
  30791. } else {
  30792. m.addai_response = &u
  30793. }
  30794. }
  30795. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30796. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30797. v := m.addai_response
  30798. if v == nil {
  30799. return
  30800. }
  30801. return *v, true
  30802. }
  30803. // ResetAiResponse resets all changes to the "ai_response" field.
  30804. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30805. m.ai_response = nil
  30806. m.addai_response = nil
  30807. }
  30808. // SetSopRun sets the "sop_run" field.
  30809. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30810. m.sop_run = &u
  30811. m.addsop_run = nil
  30812. }
  30813. // SopRun returns the value of the "sop_run" field in the mutation.
  30814. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30815. v := m.sop_run
  30816. if v == nil {
  30817. return
  30818. }
  30819. return *v, true
  30820. }
  30821. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  30822. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30824. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30825. if !m.op.Is(OpUpdateOne) {
  30826. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30827. }
  30828. if m.id == nil || m.oldValue == nil {
  30829. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30830. }
  30831. oldValue, err := m.oldValue(ctx)
  30832. if err != nil {
  30833. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30834. }
  30835. return oldValue.SopRun, nil
  30836. }
  30837. // AddSopRun adds u to the "sop_run" field.
  30838. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30839. if m.addsop_run != nil {
  30840. *m.addsop_run += u
  30841. } else {
  30842. m.addsop_run = &u
  30843. }
  30844. }
  30845. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30846. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  30847. v := m.addsop_run
  30848. if v == nil {
  30849. return
  30850. }
  30851. return *v, true
  30852. }
  30853. // ResetSopRun resets all changes to the "sop_run" field.
  30854. func (m *UsageStatisticDayMutation) ResetSopRun() {
  30855. m.sop_run = nil
  30856. m.addsop_run = nil
  30857. }
  30858. // SetTotalFriend sets the "total_friend" field.
  30859. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  30860. m.total_friend = &u
  30861. m.addtotal_friend = nil
  30862. }
  30863. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30864. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  30865. v := m.total_friend
  30866. if v == nil {
  30867. return
  30868. }
  30869. return *v, true
  30870. }
  30871. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  30872. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30874. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30875. if !m.op.Is(OpUpdateOne) {
  30876. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30877. }
  30878. if m.id == nil || m.oldValue == nil {
  30879. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30880. }
  30881. oldValue, err := m.oldValue(ctx)
  30882. if err != nil {
  30883. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30884. }
  30885. return oldValue.TotalFriend, nil
  30886. }
  30887. // AddTotalFriend adds u to the "total_friend" field.
  30888. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  30889. if m.addtotal_friend != nil {
  30890. *m.addtotal_friend += u
  30891. } else {
  30892. m.addtotal_friend = &u
  30893. }
  30894. }
  30895. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30896. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  30897. v := m.addtotal_friend
  30898. if v == nil {
  30899. return
  30900. }
  30901. return *v, true
  30902. }
  30903. // ResetTotalFriend resets all changes to the "total_friend" field.
  30904. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  30905. m.total_friend = nil
  30906. m.addtotal_friend = nil
  30907. }
  30908. // SetTotalGroup sets the "total_group" field.
  30909. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30910. m.total_group = &u
  30911. m.addtotal_group = nil
  30912. }
  30913. // TotalGroup returns the value of the "total_group" field in the mutation.
  30914. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30915. v := m.total_group
  30916. if v == nil {
  30917. return
  30918. }
  30919. return *v, true
  30920. }
  30921. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  30922. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30924. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30925. if !m.op.Is(OpUpdateOne) {
  30926. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30927. }
  30928. if m.id == nil || m.oldValue == nil {
  30929. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30930. }
  30931. oldValue, err := m.oldValue(ctx)
  30932. if err != nil {
  30933. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30934. }
  30935. return oldValue.TotalGroup, nil
  30936. }
  30937. // AddTotalGroup adds u to the "total_group" field.
  30938. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  30939. if m.addtotal_group != nil {
  30940. *m.addtotal_group += u
  30941. } else {
  30942. m.addtotal_group = &u
  30943. }
  30944. }
  30945. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30946. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  30947. v := m.addtotal_group
  30948. if v == nil {
  30949. return
  30950. }
  30951. return *v, true
  30952. }
  30953. // ResetTotalGroup resets all changes to the "total_group" field.
  30954. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  30955. m.total_group = nil
  30956. m.addtotal_group = nil
  30957. }
  30958. // SetAccountBalance sets the "account_balance" field.
  30959. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  30960. m.account_balance = &u
  30961. m.addaccount_balance = nil
  30962. }
  30963. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30964. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  30965. v := m.account_balance
  30966. if v == nil {
  30967. return
  30968. }
  30969. return *v, true
  30970. }
  30971. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  30972. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30974. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30975. if !m.op.Is(OpUpdateOne) {
  30976. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30977. }
  30978. if m.id == nil || m.oldValue == nil {
  30979. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30980. }
  30981. oldValue, err := m.oldValue(ctx)
  30982. if err != nil {
  30983. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30984. }
  30985. return oldValue.AccountBalance, nil
  30986. }
  30987. // AddAccountBalance adds u to the "account_balance" field.
  30988. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  30989. if m.addaccount_balance != nil {
  30990. *m.addaccount_balance += u
  30991. } else {
  30992. m.addaccount_balance = &u
  30993. }
  30994. }
  30995. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30996. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  30997. v := m.addaccount_balance
  30998. if v == nil {
  30999. return
  31000. }
  31001. return *v, true
  31002. }
  31003. // ResetAccountBalance resets all changes to the "account_balance" field.
  31004. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31005. m.account_balance = nil
  31006. m.addaccount_balance = nil
  31007. }
  31008. // SetConsumeToken sets the "consume_token" field.
  31009. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31010. m.consume_token = &u
  31011. m.addconsume_token = nil
  31012. }
  31013. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31014. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31015. v := m.consume_token
  31016. if v == nil {
  31017. return
  31018. }
  31019. return *v, true
  31020. }
  31021. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31022. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31024. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31025. if !m.op.Is(OpUpdateOne) {
  31026. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31027. }
  31028. if m.id == nil || m.oldValue == nil {
  31029. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31030. }
  31031. oldValue, err := m.oldValue(ctx)
  31032. if err != nil {
  31033. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31034. }
  31035. return oldValue.ConsumeToken, nil
  31036. }
  31037. // AddConsumeToken adds u to the "consume_token" field.
  31038. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31039. if m.addconsume_token != nil {
  31040. *m.addconsume_token += u
  31041. } else {
  31042. m.addconsume_token = &u
  31043. }
  31044. }
  31045. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31046. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31047. v := m.addconsume_token
  31048. if v == nil {
  31049. return
  31050. }
  31051. return *v, true
  31052. }
  31053. // ResetConsumeToken resets all changes to the "consume_token" field.
  31054. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31055. m.consume_token = nil
  31056. m.addconsume_token = nil
  31057. }
  31058. // SetActiveUser sets the "active_user" field.
  31059. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31060. m.active_user = &u
  31061. m.addactive_user = nil
  31062. }
  31063. // ActiveUser returns the value of the "active_user" field in the mutation.
  31064. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31065. v := m.active_user
  31066. if v == nil {
  31067. return
  31068. }
  31069. return *v, true
  31070. }
  31071. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31072. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31074. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31075. if !m.op.Is(OpUpdateOne) {
  31076. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31077. }
  31078. if m.id == nil || m.oldValue == nil {
  31079. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31080. }
  31081. oldValue, err := m.oldValue(ctx)
  31082. if err != nil {
  31083. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31084. }
  31085. return oldValue.ActiveUser, nil
  31086. }
  31087. // AddActiveUser adds u to the "active_user" field.
  31088. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31089. if m.addactive_user != nil {
  31090. *m.addactive_user += u
  31091. } else {
  31092. m.addactive_user = &u
  31093. }
  31094. }
  31095. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31096. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31097. v := m.addactive_user
  31098. if v == nil {
  31099. return
  31100. }
  31101. return *v, true
  31102. }
  31103. // ResetActiveUser resets all changes to the "active_user" field.
  31104. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31105. m.active_user = nil
  31106. m.addactive_user = nil
  31107. }
  31108. // SetNewUser sets the "new_user" field.
  31109. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31110. m.new_user = &i
  31111. m.addnew_user = nil
  31112. }
  31113. // NewUser returns the value of the "new_user" field in the mutation.
  31114. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31115. v := m.new_user
  31116. if v == nil {
  31117. return
  31118. }
  31119. return *v, true
  31120. }
  31121. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31122. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31124. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31125. if !m.op.Is(OpUpdateOne) {
  31126. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31127. }
  31128. if m.id == nil || m.oldValue == nil {
  31129. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31130. }
  31131. oldValue, err := m.oldValue(ctx)
  31132. if err != nil {
  31133. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31134. }
  31135. return oldValue.NewUser, nil
  31136. }
  31137. // AddNewUser adds i to the "new_user" field.
  31138. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31139. if m.addnew_user != nil {
  31140. *m.addnew_user += i
  31141. } else {
  31142. m.addnew_user = &i
  31143. }
  31144. }
  31145. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31146. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31147. v := m.addnew_user
  31148. if v == nil {
  31149. return
  31150. }
  31151. return *v, true
  31152. }
  31153. // ResetNewUser resets all changes to the "new_user" field.
  31154. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31155. m.new_user = nil
  31156. m.addnew_user = nil
  31157. }
  31158. // SetLabelDist sets the "label_dist" field.
  31159. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31160. m.label_dist = &ctd
  31161. m.appendlabel_dist = nil
  31162. }
  31163. // LabelDist returns the value of the "label_dist" field in the mutation.
  31164. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31165. v := m.label_dist
  31166. if v == nil {
  31167. return
  31168. }
  31169. return *v, true
  31170. }
  31171. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31172. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31174. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31175. if !m.op.Is(OpUpdateOne) {
  31176. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31177. }
  31178. if m.id == nil || m.oldValue == nil {
  31179. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31180. }
  31181. oldValue, err := m.oldValue(ctx)
  31182. if err != nil {
  31183. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31184. }
  31185. return oldValue.LabelDist, nil
  31186. }
  31187. // AppendLabelDist adds ctd to the "label_dist" field.
  31188. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31189. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31190. }
  31191. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31192. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31193. if len(m.appendlabel_dist) == 0 {
  31194. return nil, false
  31195. }
  31196. return m.appendlabel_dist, true
  31197. }
  31198. // ResetLabelDist resets all changes to the "label_dist" field.
  31199. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31200. m.label_dist = nil
  31201. m.appendlabel_dist = nil
  31202. }
  31203. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31204. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31205. m.predicates = append(m.predicates, ps...)
  31206. }
  31207. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31208. // users can use type-assertion to append predicates that do not depend on any generated package.
  31209. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31210. p := make([]predicate.UsageStatisticDay, len(ps))
  31211. for i := range ps {
  31212. p[i] = ps[i]
  31213. }
  31214. m.Where(p...)
  31215. }
  31216. // Op returns the operation name.
  31217. func (m *UsageStatisticDayMutation) Op() Op {
  31218. return m.op
  31219. }
  31220. // SetOp allows setting the mutation operation.
  31221. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31222. m.op = op
  31223. }
  31224. // Type returns the node type of this mutation (UsageStatisticDay).
  31225. func (m *UsageStatisticDayMutation) Type() string {
  31226. return m.typ
  31227. }
  31228. // Fields returns all fields that were changed during this mutation. Note that in
  31229. // order to get all numeric fields that were incremented/decremented, call
  31230. // AddedFields().
  31231. func (m *UsageStatisticDayMutation) Fields() []string {
  31232. fields := make([]string, 0, 17)
  31233. if m.created_at != nil {
  31234. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31235. }
  31236. if m.updated_at != nil {
  31237. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31238. }
  31239. if m.status != nil {
  31240. fields = append(fields, usagestatisticday.FieldStatus)
  31241. }
  31242. if m.deleted_at != nil {
  31243. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31244. }
  31245. if m.addtime != nil {
  31246. fields = append(fields, usagestatisticday.FieldAddtime)
  31247. }
  31248. if m._type != nil {
  31249. fields = append(fields, usagestatisticday.FieldType)
  31250. }
  31251. if m.bot_id != nil {
  31252. fields = append(fields, usagestatisticday.FieldBotID)
  31253. }
  31254. if m.organization_id != nil {
  31255. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31256. }
  31257. if m.ai_response != nil {
  31258. fields = append(fields, usagestatisticday.FieldAiResponse)
  31259. }
  31260. if m.sop_run != nil {
  31261. fields = append(fields, usagestatisticday.FieldSopRun)
  31262. }
  31263. if m.total_friend != nil {
  31264. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31265. }
  31266. if m.total_group != nil {
  31267. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31268. }
  31269. if m.account_balance != nil {
  31270. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31271. }
  31272. if m.consume_token != nil {
  31273. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31274. }
  31275. if m.active_user != nil {
  31276. fields = append(fields, usagestatisticday.FieldActiveUser)
  31277. }
  31278. if m.new_user != nil {
  31279. fields = append(fields, usagestatisticday.FieldNewUser)
  31280. }
  31281. if m.label_dist != nil {
  31282. fields = append(fields, usagestatisticday.FieldLabelDist)
  31283. }
  31284. return fields
  31285. }
  31286. // Field returns the value of a field with the given name. The second boolean
  31287. // return value indicates that this field was not set, or was not defined in the
  31288. // schema.
  31289. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31290. switch name {
  31291. case usagestatisticday.FieldCreatedAt:
  31292. return m.CreatedAt()
  31293. case usagestatisticday.FieldUpdatedAt:
  31294. return m.UpdatedAt()
  31295. case usagestatisticday.FieldStatus:
  31296. return m.Status()
  31297. case usagestatisticday.FieldDeletedAt:
  31298. return m.DeletedAt()
  31299. case usagestatisticday.FieldAddtime:
  31300. return m.Addtime()
  31301. case usagestatisticday.FieldType:
  31302. return m.GetType()
  31303. case usagestatisticday.FieldBotID:
  31304. return m.BotID()
  31305. case usagestatisticday.FieldOrganizationID:
  31306. return m.OrganizationID()
  31307. case usagestatisticday.FieldAiResponse:
  31308. return m.AiResponse()
  31309. case usagestatisticday.FieldSopRun:
  31310. return m.SopRun()
  31311. case usagestatisticday.FieldTotalFriend:
  31312. return m.TotalFriend()
  31313. case usagestatisticday.FieldTotalGroup:
  31314. return m.TotalGroup()
  31315. case usagestatisticday.FieldAccountBalance:
  31316. return m.AccountBalance()
  31317. case usagestatisticday.FieldConsumeToken:
  31318. return m.ConsumeToken()
  31319. case usagestatisticday.FieldActiveUser:
  31320. return m.ActiveUser()
  31321. case usagestatisticday.FieldNewUser:
  31322. return m.NewUser()
  31323. case usagestatisticday.FieldLabelDist:
  31324. return m.LabelDist()
  31325. }
  31326. return nil, false
  31327. }
  31328. // OldField returns the old value of the field from the database. An error is
  31329. // returned if the mutation operation is not UpdateOne, or the query to the
  31330. // database failed.
  31331. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31332. switch name {
  31333. case usagestatisticday.FieldCreatedAt:
  31334. return m.OldCreatedAt(ctx)
  31335. case usagestatisticday.FieldUpdatedAt:
  31336. return m.OldUpdatedAt(ctx)
  31337. case usagestatisticday.FieldStatus:
  31338. return m.OldStatus(ctx)
  31339. case usagestatisticday.FieldDeletedAt:
  31340. return m.OldDeletedAt(ctx)
  31341. case usagestatisticday.FieldAddtime:
  31342. return m.OldAddtime(ctx)
  31343. case usagestatisticday.FieldType:
  31344. return m.OldType(ctx)
  31345. case usagestatisticday.FieldBotID:
  31346. return m.OldBotID(ctx)
  31347. case usagestatisticday.FieldOrganizationID:
  31348. return m.OldOrganizationID(ctx)
  31349. case usagestatisticday.FieldAiResponse:
  31350. return m.OldAiResponse(ctx)
  31351. case usagestatisticday.FieldSopRun:
  31352. return m.OldSopRun(ctx)
  31353. case usagestatisticday.FieldTotalFriend:
  31354. return m.OldTotalFriend(ctx)
  31355. case usagestatisticday.FieldTotalGroup:
  31356. return m.OldTotalGroup(ctx)
  31357. case usagestatisticday.FieldAccountBalance:
  31358. return m.OldAccountBalance(ctx)
  31359. case usagestatisticday.FieldConsumeToken:
  31360. return m.OldConsumeToken(ctx)
  31361. case usagestatisticday.FieldActiveUser:
  31362. return m.OldActiveUser(ctx)
  31363. case usagestatisticday.FieldNewUser:
  31364. return m.OldNewUser(ctx)
  31365. case usagestatisticday.FieldLabelDist:
  31366. return m.OldLabelDist(ctx)
  31367. }
  31368. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31369. }
  31370. // SetField sets the value of a field with the given name. It returns an error if
  31371. // the field is not defined in the schema, or if the type mismatched the field
  31372. // type.
  31373. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31374. switch name {
  31375. case usagestatisticday.FieldCreatedAt:
  31376. v, ok := value.(time.Time)
  31377. if !ok {
  31378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31379. }
  31380. m.SetCreatedAt(v)
  31381. return nil
  31382. case usagestatisticday.FieldUpdatedAt:
  31383. v, ok := value.(time.Time)
  31384. if !ok {
  31385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31386. }
  31387. m.SetUpdatedAt(v)
  31388. return nil
  31389. case usagestatisticday.FieldStatus:
  31390. v, ok := value.(uint8)
  31391. if !ok {
  31392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31393. }
  31394. m.SetStatus(v)
  31395. return nil
  31396. case usagestatisticday.FieldDeletedAt:
  31397. v, ok := value.(time.Time)
  31398. if !ok {
  31399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31400. }
  31401. m.SetDeletedAt(v)
  31402. return nil
  31403. case usagestatisticday.FieldAddtime:
  31404. v, ok := value.(uint64)
  31405. if !ok {
  31406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31407. }
  31408. m.SetAddtime(v)
  31409. return nil
  31410. case usagestatisticday.FieldType:
  31411. v, ok := value.(int)
  31412. if !ok {
  31413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31414. }
  31415. m.SetType(v)
  31416. return nil
  31417. case usagestatisticday.FieldBotID:
  31418. v, ok := value.(string)
  31419. if !ok {
  31420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31421. }
  31422. m.SetBotID(v)
  31423. return nil
  31424. case usagestatisticday.FieldOrganizationID:
  31425. v, ok := value.(uint64)
  31426. if !ok {
  31427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31428. }
  31429. m.SetOrganizationID(v)
  31430. return nil
  31431. case usagestatisticday.FieldAiResponse:
  31432. v, ok := value.(uint64)
  31433. if !ok {
  31434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31435. }
  31436. m.SetAiResponse(v)
  31437. return nil
  31438. case usagestatisticday.FieldSopRun:
  31439. v, ok := value.(uint64)
  31440. if !ok {
  31441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31442. }
  31443. m.SetSopRun(v)
  31444. return nil
  31445. case usagestatisticday.FieldTotalFriend:
  31446. v, ok := value.(uint64)
  31447. if !ok {
  31448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31449. }
  31450. m.SetTotalFriend(v)
  31451. return nil
  31452. case usagestatisticday.FieldTotalGroup:
  31453. v, ok := value.(uint64)
  31454. if !ok {
  31455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31456. }
  31457. m.SetTotalGroup(v)
  31458. return nil
  31459. case usagestatisticday.FieldAccountBalance:
  31460. v, ok := value.(uint64)
  31461. if !ok {
  31462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31463. }
  31464. m.SetAccountBalance(v)
  31465. return nil
  31466. case usagestatisticday.FieldConsumeToken:
  31467. v, ok := value.(uint64)
  31468. if !ok {
  31469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31470. }
  31471. m.SetConsumeToken(v)
  31472. return nil
  31473. case usagestatisticday.FieldActiveUser:
  31474. v, ok := value.(uint64)
  31475. if !ok {
  31476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31477. }
  31478. m.SetActiveUser(v)
  31479. return nil
  31480. case usagestatisticday.FieldNewUser:
  31481. v, ok := value.(int64)
  31482. if !ok {
  31483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31484. }
  31485. m.SetNewUser(v)
  31486. return nil
  31487. case usagestatisticday.FieldLabelDist:
  31488. v, ok := value.([]custom_types.LabelDist)
  31489. if !ok {
  31490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31491. }
  31492. m.SetLabelDist(v)
  31493. return nil
  31494. }
  31495. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31496. }
  31497. // AddedFields returns all numeric fields that were incremented/decremented during
  31498. // this mutation.
  31499. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31500. var fields []string
  31501. if m.addstatus != nil {
  31502. fields = append(fields, usagestatisticday.FieldStatus)
  31503. }
  31504. if m.addaddtime != nil {
  31505. fields = append(fields, usagestatisticday.FieldAddtime)
  31506. }
  31507. if m.add_type != nil {
  31508. fields = append(fields, usagestatisticday.FieldType)
  31509. }
  31510. if m.addorganization_id != nil {
  31511. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31512. }
  31513. if m.addai_response != nil {
  31514. fields = append(fields, usagestatisticday.FieldAiResponse)
  31515. }
  31516. if m.addsop_run != nil {
  31517. fields = append(fields, usagestatisticday.FieldSopRun)
  31518. }
  31519. if m.addtotal_friend != nil {
  31520. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31521. }
  31522. if m.addtotal_group != nil {
  31523. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31524. }
  31525. if m.addaccount_balance != nil {
  31526. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31527. }
  31528. if m.addconsume_token != nil {
  31529. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31530. }
  31531. if m.addactive_user != nil {
  31532. fields = append(fields, usagestatisticday.FieldActiveUser)
  31533. }
  31534. if m.addnew_user != nil {
  31535. fields = append(fields, usagestatisticday.FieldNewUser)
  31536. }
  31537. return fields
  31538. }
  31539. // AddedField returns the numeric value that was incremented/decremented on a field
  31540. // with the given name. The second boolean return value indicates that this field
  31541. // was not set, or was not defined in the schema.
  31542. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31543. switch name {
  31544. case usagestatisticday.FieldStatus:
  31545. return m.AddedStatus()
  31546. case usagestatisticday.FieldAddtime:
  31547. return m.AddedAddtime()
  31548. case usagestatisticday.FieldType:
  31549. return m.AddedType()
  31550. case usagestatisticday.FieldOrganizationID:
  31551. return m.AddedOrganizationID()
  31552. case usagestatisticday.FieldAiResponse:
  31553. return m.AddedAiResponse()
  31554. case usagestatisticday.FieldSopRun:
  31555. return m.AddedSopRun()
  31556. case usagestatisticday.FieldTotalFriend:
  31557. return m.AddedTotalFriend()
  31558. case usagestatisticday.FieldTotalGroup:
  31559. return m.AddedTotalGroup()
  31560. case usagestatisticday.FieldAccountBalance:
  31561. return m.AddedAccountBalance()
  31562. case usagestatisticday.FieldConsumeToken:
  31563. return m.AddedConsumeToken()
  31564. case usagestatisticday.FieldActiveUser:
  31565. return m.AddedActiveUser()
  31566. case usagestatisticday.FieldNewUser:
  31567. return m.AddedNewUser()
  31568. }
  31569. return nil, false
  31570. }
  31571. // AddField adds the value to the field with the given name. It returns an error if
  31572. // the field is not defined in the schema, or if the type mismatched the field
  31573. // type.
  31574. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31575. switch name {
  31576. case usagestatisticday.FieldStatus:
  31577. v, ok := value.(int8)
  31578. if !ok {
  31579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31580. }
  31581. m.AddStatus(v)
  31582. return nil
  31583. case usagestatisticday.FieldAddtime:
  31584. v, ok := value.(int64)
  31585. if !ok {
  31586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31587. }
  31588. m.AddAddtime(v)
  31589. return nil
  31590. case usagestatisticday.FieldType:
  31591. v, ok := value.(int)
  31592. if !ok {
  31593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31594. }
  31595. m.AddType(v)
  31596. return nil
  31597. case usagestatisticday.FieldOrganizationID:
  31598. v, ok := value.(int64)
  31599. if !ok {
  31600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31601. }
  31602. m.AddOrganizationID(v)
  31603. return nil
  31604. case usagestatisticday.FieldAiResponse:
  31605. v, ok := value.(int64)
  31606. if !ok {
  31607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31608. }
  31609. m.AddAiResponse(v)
  31610. return nil
  31611. case usagestatisticday.FieldSopRun:
  31612. v, ok := value.(int64)
  31613. if !ok {
  31614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31615. }
  31616. m.AddSopRun(v)
  31617. return nil
  31618. case usagestatisticday.FieldTotalFriend:
  31619. v, ok := value.(int64)
  31620. if !ok {
  31621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31622. }
  31623. m.AddTotalFriend(v)
  31624. return nil
  31625. case usagestatisticday.FieldTotalGroup:
  31626. v, ok := value.(int64)
  31627. if !ok {
  31628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31629. }
  31630. m.AddTotalGroup(v)
  31631. return nil
  31632. case usagestatisticday.FieldAccountBalance:
  31633. v, ok := value.(int64)
  31634. if !ok {
  31635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31636. }
  31637. m.AddAccountBalance(v)
  31638. return nil
  31639. case usagestatisticday.FieldConsumeToken:
  31640. v, ok := value.(int64)
  31641. if !ok {
  31642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31643. }
  31644. m.AddConsumeToken(v)
  31645. return nil
  31646. case usagestatisticday.FieldActiveUser:
  31647. v, ok := value.(int64)
  31648. if !ok {
  31649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31650. }
  31651. m.AddActiveUser(v)
  31652. return nil
  31653. case usagestatisticday.FieldNewUser:
  31654. v, ok := value.(int64)
  31655. if !ok {
  31656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31657. }
  31658. m.AddNewUser(v)
  31659. return nil
  31660. }
  31661. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31662. }
  31663. // ClearedFields returns all nullable fields that were cleared during this
  31664. // mutation.
  31665. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31666. var fields []string
  31667. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31668. fields = append(fields, usagestatisticday.FieldStatus)
  31669. }
  31670. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31671. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31672. }
  31673. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31674. fields = append(fields, usagestatisticday.FieldBotID)
  31675. }
  31676. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31677. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31678. }
  31679. return fields
  31680. }
  31681. // FieldCleared returns a boolean indicating if a field with the given name was
  31682. // cleared in this mutation.
  31683. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31684. _, ok := m.clearedFields[name]
  31685. return ok
  31686. }
  31687. // ClearField clears the value of the field with the given name. It returns an
  31688. // error if the field is not defined in the schema.
  31689. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31690. switch name {
  31691. case usagestatisticday.FieldStatus:
  31692. m.ClearStatus()
  31693. return nil
  31694. case usagestatisticday.FieldDeletedAt:
  31695. m.ClearDeletedAt()
  31696. return nil
  31697. case usagestatisticday.FieldBotID:
  31698. m.ClearBotID()
  31699. return nil
  31700. case usagestatisticday.FieldOrganizationID:
  31701. m.ClearOrganizationID()
  31702. return nil
  31703. }
  31704. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31705. }
  31706. // ResetField resets all changes in the mutation for the field with the given name.
  31707. // It returns an error if the field is not defined in the schema.
  31708. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31709. switch name {
  31710. case usagestatisticday.FieldCreatedAt:
  31711. m.ResetCreatedAt()
  31712. return nil
  31713. case usagestatisticday.FieldUpdatedAt:
  31714. m.ResetUpdatedAt()
  31715. return nil
  31716. case usagestatisticday.FieldStatus:
  31717. m.ResetStatus()
  31718. return nil
  31719. case usagestatisticday.FieldDeletedAt:
  31720. m.ResetDeletedAt()
  31721. return nil
  31722. case usagestatisticday.FieldAddtime:
  31723. m.ResetAddtime()
  31724. return nil
  31725. case usagestatisticday.FieldType:
  31726. m.ResetType()
  31727. return nil
  31728. case usagestatisticday.FieldBotID:
  31729. m.ResetBotID()
  31730. return nil
  31731. case usagestatisticday.FieldOrganizationID:
  31732. m.ResetOrganizationID()
  31733. return nil
  31734. case usagestatisticday.FieldAiResponse:
  31735. m.ResetAiResponse()
  31736. return nil
  31737. case usagestatisticday.FieldSopRun:
  31738. m.ResetSopRun()
  31739. return nil
  31740. case usagestatisticday.FieldTotalFriend:
  31741. m.ResetTotalFriend()
  31742. return nil
  31743. case usagestatisticday.FieldTotalGroup:
  31744. m.ResetTotalGroup()
  31745. return nil
  31746. case usagestatisticday.FieldAccountBalance:
  31747. m.ResetAccountBalance()
  31748. return nil
  31749. case usagestatisticday.FieldConsumeToken:
  31750. m.ResetConsumeToken()
  31751. return nil
  31752. case usagestatisticday.FieldActiveUser:
  31753. m.ResetActiveUser()
  31754. return nil
  31755. case usagestatisticday.FieldNewUser:
  31756. m.ResetNewUser()
  31757. return nil
  31758. case usagestatisticday.FieldLabelDist:
  31759. m.ResetLabelDist()
  31760. return nil
  31761. }
  31762. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31763. }
  31764. // AddedEdges returns all edge names that were set/added in this mutation.
  31765. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31766. edges := make([]string, 0, 0)
  31767. return edges
  31768. }
  31769. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31770. // name in this mutation.
  31771. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31772. return nil
  31773. }
  31774. // RemovedEdges returns all edge names that were removed in this mutation.
  31775. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31776. edges := make([]string, 0, 0)
  31777. return edges
  31778. }
  31779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31780. // the given name in this mutation.
  31781. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31782. return nil
  31783. }
  31784. // ClearedEdges returns all edge names that were cleared in this mutation.
  31785. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31786. edges := make([]string, 0, 0)
  31787. return edges
  31788. }
  31789. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31790. // was cleared in this mutation.
  31791. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31792. return false
  31793. }
  31794. // ClearEdge clears the value of the edge with the given name. It returns an error
  31795. // if that edge is not defined in the schema.
  31796. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31797. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31798. }
  31799. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31800. // It returns an error if the edge is not defined in the schema.
  31801. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31802. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31803. }
  31804. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31805. type UsageStatisticHourMutation struct {
  31806. config
  31807. op Op
  31808. typ string
  31809. id *uint64
  31810. created_at *time.Time
  31811. updated_at *time.Time
  31812. status *uint8
  31813. addstatus *int8
  31814. deleted_at *time.Time
  31815. addtime *uint64
  31816. addaddtime *int64
  31817. _type *int
  31818. add_type *int
  31819. bot_id *string
  31820. organization_id *uint64
  31821. addorganization_id *int64
  31822. ai_response *uint64
  31823. addai_response *int64
  31824. sop_run *uint64
  31825. addsop_run *int64
  31826. total_friend *uint64
  31827. addtotal_friend *int64
  31828. total_group *uint64
  31829. addtotal_group *int64
  31830. account_balance *uint64
  31831. addaccount_balance *int64
  31832. consume_token *uint64
  31833. addconsume_token *int64
  31834. active_user *uint64
  31835. addactive_user *int64
  31836. new_user *int64
  31837. addnew_user *int64
  31838. label_dist *[]custom_types.LabelDist
  31839. appendlabel_dist []custom_types.LabelDist
  31840. clearedFields map[string]struct{}
  31841. done bool
  31842. oldValue func(context.Context) (*UsageStatisticHour, error)
  31843. predicates []predicate.UsageStatisticHour
  31844. }
  31845. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  31846. // usagestatistichourOption allows management of the mutation configuration using functional options.
  31847. type usagestatistichourOption func(*UsageStatisticHourMutation)
  31848. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  31849. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  31850. m := &UsageStatisticHourMutation{
  31851. config: c,
  31852. op: op,
  31853. typ: TypeUsageStatisticHour,
  31854. clearedFields: make(map[string]struct{}),
  31855. }
  31856. for _, opt := range opts {
  31857. opt(m)
  31858. }
  31859. return m
  31860. }
  31861. // withUsageStatisticHourID sets the ID field of the mutation.
  31862. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  31863. return func(m *UsageStatisticHourMutation) {
  31864. var (
  31865. err error
  31866. once sync.Once
  31867. value *UsageStatisticHour
  31868. )
  31869. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  31870. once.Do(func() {
  31871. if m.done {
  31872. err = errors.New("querying old values post mutation is not allowed")
  31873. } else {
  31874. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  31875. }
  31876. })
  31877. return value, err
  31878. }
  31879. m.id = &id
  31880. }
  31881. }
  31882. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  31883. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  31884. return func(m *UsageStatisticHourMutation) {
  31885. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  31886. return node, nil
  31887. }
  31888. m.id = &node.ID
  31889. }
  31890. }
  31891. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31892. // executed in a transaction (ent.Tx), a transactional client is returned.
  31893. func (m UsageStatisticHourMutation) Client() *Client {
  31894. client := &Client{config: m.config}
  31895. client.init()
  31896. return client
  31897. }
  31898. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31899. // it returns an error otherwise.
  31900. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  31901. if _, ok := m.driver.(*txDriver); !ok {
  31902. return nil, errors.New("ent: mutation is not running in a transaction")
  31903. }
  31904. tx := &Tx{config: m.config}
  31905. tx.init()
  31906. return tx, nil
  31907. }
  31908. // SetID sets the value of the id field. Note that this
  31909. // operation is only accepted on creation of UsageStatisticHour entities.
  31910. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31911. m.id = &id
  31912. }
  31913. // ID returns the ID value in the mutation. Note that the ID is only available
  31914. // if it was provided to the builder or after it was returned from the database.
  31915. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31916. if m.id == nil {
  31917. return
  31918. }
  31919. return *m.id, true
  31920. }
  31921. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31922. // That means, if the mutation is applied within a transaction with an isolation level such
  31923. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31924. // or updated by the mutation.
  31925. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  31926. switch {
  31927. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31928. id, exists := m.ID()
  31929. if exists {
  31930. return []uint64{id}, nil
  31931. }
  31932. fallthrough
  31933. case m.op.Is(OpUpdate | OpDelete):
  31934. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  31935. default:
  31936. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31937. }
  31938. }
  31939. // SetCreatedAt sets the "created_at" field.
  31940. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  31941. m.created_at = &t
  31942. }
  31943. // CreatedAt returns the value of the "created_at" field in the mutation.
  31944. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  31945. v := m.created_at
  31946. if v == nil {
  31947. return
  31948. }
  31949. return *v, true
  31950. }
  31951. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  31952. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31954. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31955. if !m.op.Is(OpUpdateOne) {
  31956. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31957. }
  31958. if m.id == nil || m.oldValue == nil {
  31959. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31960. }
  31961. oldValue, err := m.oldValue(ctx)
  31962. if err != nil {
  31963. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31964. }
  31965. return oldValue.CreatedAt, nil
  31966. }
  31967. // ResetCreatedAt resets all changes to the "created_at" field.
  31968. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  31969. m.created_at = nil
  31970. }
  31971. // SetUpdatedAt sets the "updated_at" field.
  31972. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  31973. m.updated_at = &t
  31974. }
  31975. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31976. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  31977. v := m.updated_at
  31978. if v == nil {
  31979. return
  31980. }
  31981. return *v, true
  31982. }
  31983. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  31984. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31986. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31987. if !m.op.Is(OpUpdateOne) {
  31988. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31989. }
  31990. if m.id == nil || m.oldValue == nil {
  31991. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31992. }
  31993. oldValue, err := m.oldValue(ctx)
  31994. if err != nil {
  31995. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31996. }
  31997. return oldValue.UpdatedAt, nil
  31998. }
  31999. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32000. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32001. m.updated_at = nil
  32002. }
  32003. // SetStatus sets the "status" field.
  32004. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32005. m.status = &u
  32006. m.addstatus = nil
  32007. }
  32008. // Status returns the value of the "status" field in the mutation.
  32009. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32010. v := m.status
  32011. if v == nil {
  32012. return
  32013. }
  32014. return *v, true
  32015. }
  32016. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32017. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32019. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32020. if !m.op.Is(OpUpdateOne) {
  32021. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32022. }
  32023. if m.id == nil || m.oldValue == nil {
  32024. return v, errors.New("OldStatus requires an ID field in the mutation")
  32025. }
  32026. oldValue, err := m.oldValue(ctx)
  32027. if err != nil {
  32028. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32029. }
  32030. return oldValue.Status, nil
  32031. }
  32032. // AddStatus adds u to the "status" field.
  32033. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32034. if m.addstatus != nil {
  32035. *m.addstatus += u
  32036. } else {
  32037. m.addstatus = &u
  32038. }
  32039. }
  32040. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32041. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32042. v := m.addstatus
  32043. if v == nil {
  32044. return
  32045. }
  32046. return *v, true
  32047. }
  32048. // ClearStatus clears the value of the "status" field.
  32049. func (m *UsageStatisticHourMutation) ClearStatus() {
  32050. m.status = nil
  32051. m.addstatus = nil
  32052. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32053. }
  32054. // StatusCleared returns if the "status" field was cleared in this mutation.
  32055. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32056. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32057. return ok
  32058. }
  32059. // ResetStatus resets all changes to the "status" field.
  32060. func (m *UsageStatisticHourMutation) ResetStatus() {
  32061. m.status = nil
  32062. m.addstatus = nil
  32063. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32064. }
  32065. // SetDeletedAt sets the "deleted_at" field.
  32066. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32067. m.deleted_at = &t
  32068. }
  32069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32070. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32071. v := m.deleted_at
  32072. if v == nil {
  32073. return
  32074. }
  32075. return *v, true
  32076. }
  32077. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32078. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32080. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32081. if !m.op.Is(OpUpdateOne) {
  32082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32083. }
  32084. if m.id == nil || m.oldValue == nil {
  32085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32086. }
  32087. oldValue, err := m.oldValue(ctx)
  32088. if err != nil {
  32089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32090. }
  32091. return oldValue.DeletedAt, nil
  32092. }
  32093. // ClearDeletedAt clears the value of the "deleted_at" field.
  32094. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32095. m.deleted_at = nil
  32096. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32097. }
  32098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32099. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32100. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32101. return ok
  32102. }
  32103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32104. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32105. m.deleted_at = nil
  32106. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32107. }
  32108. // SetAddtime sets the "addtime" field.
  32109. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32110. m.addtime = &u
  32111. m.addaddtime = nil
  32112. }
  32113. // Addtime returns the value of the "addtime" field in the mutation.
  32114. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32115. v := m.addtime
  32116. if v == nil {
  32117. return
  32118. }
  32119. return *v, true
  32120. }
  32121. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32122. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32124. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32125. if !m.op.Is(OpUpdateOne) {
  32126. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32127. }
  32128. if m.id == nil || m.oldValue == nil {
  32129. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32130. }
  32131. oldValue, err := m.oldValue(ctx)
  32132. if err != nil {
  32133. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32134. }
  32135. return oldValue.Addtime, nil
  32136. }
  32137. // AddAddtime adds u to the "addtime" field.
  32138. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32139. if m.addaddtime != nil {
  32140. *m.addaddtime += u
  32141. } else {
  32142. m.addaddtime = &u
  32143. }
  32144. }
  32145. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32146. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32147. v := m.addaddtime
  32148. if v == nil {
  32149. return
  32150. }
  32151. return *v, true
  32152. }
  32153. // ResetAddtime resets all changes to the "addtime" field.
  32154. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32155. m.addtime = nil
  32156. m.addaddtime = nil
  32157. }
  32158. // SetType sets the "type" field.
  32159. func (m *UsageStatisticHourMutation) SetType(i int) {
  32160. m._type = &i
  32161. m.add_type = nil
  32162. }
  32163. // GetType returns the value of the "type" field in the mutation.
  32164. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32165. v := m._type
  32166. if v == nil {
  32167. return
  32168. }
  32169. return *v, true
  32170. }
  32171. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32172. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32174. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32175. if !m.op.Is(OpUpdateOne) {
  32176. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32177. }
  32178. if m.id == nil || m.oldValue == nil {
  32179. return v, errors.New("OldType requires an ID field in the mutation")
  32180. }
  32181. oldValue, err := m.oldValue(ctx)
  32182. if err != nil {
  32183. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32184. }
  32185. return oldValue.Type, nil
  32186. }
  32187. // AddType adds i to the "type" field.
  32188. func (m *UsageStatisticHourMutation) AddType(i int) {
  32189. if m.add_type != nil {
  32190. *m.add_type += i
  32191. } else {
  32192. m.add_type = &i
  32193. }
  32194. }
  32195. // AddedType returns the value that was added to the "type" field in this mutation.
  32196. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32197. v := m.add_type
  32198. if v == nil {
  32199. return
  32200. }
  32201. return *v, true
  32202. }
  32203. // ResetType resets all changes to the "type" field.
  32204. func (m *UsageStatisticHourMutation) ResetType() {
  32205. m._type = nil
  32206. m.add_type = nil
  32207. }
  32208. // SetBotID sets the "bot_id" field.
  32209. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32210. m.bot_id = &s
  32211. }
  32212. // BotID returns the value of the "bot_id" field in the mutation.
  32213. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32214. v := m.bot_id
  32215. if v == nil {
  32216. return
  32217. }
  32218. return *v, true
  32219. }
  32220. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32221. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32223. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32224. if !m.op.Is(OpUpdateOne) {
  32225. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32226. }
  32227. if m.id == nil || m.oldValue == nil {
  32228. return v, errors.New("OldBotID requires an ID field in the mutation")
  32229. }
  32230. oldValue, err := m.oldValue(ctx)
  32231. if err != nil {
  32232. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32233. }
  32234. return oldValue.BotID, nil
  32235. }
  32236. // ClearBotID clears the value of the "bot_id" field.
  32237. func (m *UsageStatisticHourMutation) ClearBotID() {
  32238. m.bot_id = nil
  32239. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32240. }
  32241. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32242. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32243. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32244. return ok
  32245. }
  32246. // ResetBotID resets all changes to the "bot_id" field.
  32247. func (m *UsageStatisticHourMutation) ResetBotID() {
  32248. m.bot_id = nil
  32249. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32250. }
  32251. // SetOrganizationID sets the "organization_id" field.
  32252. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32253. m.organization_id = &u
  32254. m.addorganization_id = nil
  32255. }
  32256. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32257. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32258. v := m.organization_id
  32259. if v == nil {
  32260. return
  32261. }
  32262. return *v, true
  32263. }
  32264. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32265. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32267. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32268. if !m.op.Is(OpUpdateOne) {
  32269. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32270. }
  32271. if m.id == nil || m.oldValue == nil {
  32272. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32273. }
  32274. oldValue, err := m.oldValue(ctx)
  32275. if err != nil {
  32276. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32277. }
  32278. return oldValue.OrganizationID, nil
  32279. }
  32280. // AddOrganizationID adds u to the "organization_id" field.
  32281. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32282. if m.addorganization_id != nil {
  32283. *m.addorganization_id += u
  32284. } else {
  32285. m.addorganization_id = &u
  32286. }
  32287. }
  32288. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32289. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32290. v := m.addorganization_id
  32291. if v == nil {
  32292. return
  32293. }
  32294. return *v, true
  32295. }
  32296. // ClearOrganizationID clears the value of the "organization_id" field.
  32297. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32298. m.organization_id = nil
  32299. m.addorganization_id = nil
  32300. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32301. }
  32302. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32303. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32304. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32305. return ok
  32306. }
  32307. // ResetOrganizationID resets all changes to the "organization_id" field.
  32308. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32309. m.organization_id = nil
  32310. m.addorganization_id = nil
  32311. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32312. }
  32313. // SetAiResponse sets the "ai_response" field.
  32314. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32315. m.ai_response = &u
  32316. m.addai_response = nil
  32317. }
  32318. // AiResponse returns the value of the "ai_response" field in the mutation.
  32319. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32320. v := m.ai_response
  32321. if v == nil {
  32322. return
  32323. }
  32324. return *v, true
  32325. }
  32326. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32327. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32329. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32330. if !m.op.Is(OpUpdateOne) {
  32331. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32332. }
  32333. if m.id == nil || m.oldValue == nil {
  32334. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32335. }
  32336. oldValue, err := m.oldValue(ctx)
  32337. if err != nil {
  32338. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32339. }
  32340. return oldValue.AiResponse, nil
  32341. }
  32342. // AddAiResponse adds u to the "ai_response" field.
  32343. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32344. if m.addai_response != nil {
  32345. *m.addai_response += u
  32346. } else {
  32347. m.addai_response = &u
  32348. }
  32349. }
  32350. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32351. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32352. v := m.addai_response
  32353. if v == nil {
  32354. return
  32355. }
  32356. return *v, true
  32357. }
  32358. // ResetAiResponse resets all changes to the "ai_response" field.
  32359. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32360. m.ai_response = nil
  32361. m.addai_response = nil
  32362. }
  32363. // SetSopRun sets the "sop_run" field.
  32364. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32365. m.sop_run = &u
  32366. m.addsop_run = nil
  32367. }
  32368. // SopRun returns the value of the "sop_run" field in the mutation.
  32369. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32370. v := m.sop_run
  32371. if v == nil {
  32372. return
  32373. }
  32374. return *v, true
  32375. }
  32376. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32377. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32379. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32380. if !m.op.Is(OpUpdateOne) {
  32381. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32382. }
  32383. if m.id == nil || m.oldValue == nil {
  32384. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32385. }
  32386. oldValue, err := m.oldValue(ctx)
  32387. if err != nil {
  32388. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32389. }
  32390. return oldValue.SopRun, nil
  32391. }
  32392. // AddSopRun adds u to the "sop_run" field.
  32393. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32394. if m.addsop_run != nil {
  32395. *m.addsop_run += u
  32396. } else {
  32397. m.addsop_run = &u
  32398. }
  32399. }
  32400. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32401. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32402. v := m.addsop_run
  32403. if v == nil {
  32404. return
  32405. }
  32406. return *v, true
  32407. }
  32408. // ResetSopRun resets all changes to the "sop_run" field.
  32409. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32410. m.sop_run = nil
  32411. m.addsop_run = nil
  32412. }
  32413. // SetTotalFriend sets the "total_friend" field.
  32414. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32415. m.total_friend = &u
  32416. m.addtotal_friend = nil
  32417. }
  32418. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32419. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32420. v := m.total_friend
  32421. if v == nil {
  32422. return
  32423. }
  32424. return *v, true
  32425. }
  32426. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32427. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32429. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32430. if !m.op.Is(OpUpdateOne) {
  32431. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32432. }
  32433. if m.id == nil || m.oldValue == nil {
  32434. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32435. }
  32436. oldValue, err := m.oldValue(ctx)
  32437. if err != nil {
  32438. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32439. }
  32440. return oldValue.TotalFriend, nil
  32441. }
  32442. // AddTotalFriend adds u to the "total_friend" field.
  32443. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32444. if m.addtotal_friend != nil {
  32445. *m.addtotal_friend += u
  32446. } else {
  32447. m.addtotal_friend = &u
  32448. }
  32449. }
  32450. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32451. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32452. v := m.addtotal_friend
  32453. if v == nil {
  32454. return
  32455. }
  32456. return *v, true
  32457. }
  32458. // ResetTotalFriend resets all changes to the "total_friend" field.
  32459. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32460. m.total_friend = nil
  32461. m.addtotal_friend = nil
  32462. }
  32463. // SetTotalGroup sets the "total_group" field.
  32464. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32465. m.total_group = &u
  32466. m.addtotal_group = nil
  32467. }
  32468. // TotalGroup returns the value of the "total_group" field in the mutation.
  32469. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32470. v := m.total_group
  32471. if v == nil {
  32472. return
  32473. }
  32474. return *v, true
  32475. }
  32476. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32477. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32479. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32480. if !m.op.Is(OpUpdateOne) {
  32481. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32482. }
  32483. if m.id == nil || m.oldValue == nil {
  32484. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32485. }
  32486. oldValue, err := m.oldValue(ctx)
  32487. if err != nil {
  32488. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32489. }
  32490. return oldValue.TotalGroup, nil
  32491. }
  32492. // AddTotalGroup adds u to the "total_group" field.
  32493. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32494. if m.addtotal_group != nil {
  32495. *m.addtotal_group += u
  32496. } else {
  32497. m.addtotal_group = &u
  32498. }
  32499. }
  32500. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32501. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32502. v := m.addtotal_group
  32503. if v == nil {
  32504. return
  32505. }
  32506. return *v, true
  32507. }
  32508. // ResetTotalGroup resets all changes to the "total_group" field.
  32509. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32510. m.total_group = nil
  32511. m.addtotal_group = nil
  32512. }
  32513. // SetAccountBalance sets the "account_balance" field.
  32514. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32515. m.account_balance = &u
  32516. m.addaccount_balance = nil
  32517. }
  32518. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32519. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32520. v := m.account_balance
  32521. if v == nil {
  32522. return
  32523. }
  32524. return *v, true
  32525. }
  32526. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32527. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32529. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32530. if !m.op.Is(OpUpdateOne) {
  32531. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32532. }
  32533. if m.id == nil || m.oldValue == nil {
  32534. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32535. }
  32536. oldValue, err := m.oldValue(ctx)
  32537. if err != nil {
  32538. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32539. }
  32540. return oldValue.AccountBalance, nil
  32541. }
  32542. // AddAccountBalance adds u to the "account_balance" field.
  32543. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32544. if m.addaccount_balance != nil {
  32545. *m.addaccount_balance += u
  32546. } else {
  32547. m.addaccount_balance = &u
  32548. }
  32549. }
  32550. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32551. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32552. v := m.addaccount_balance
  32553. if v == nil {
  32554. return
  32555. }
  32556. return *v, true
  32557. }
  32558. // ResetAccountBalance resets all changes to the "account_balance" field.
  32559. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32560. m.account_balance = nil
  32561. m.addaccount_balance = nil
  32562. }
  32563. // SetConsumeToken sets the "consume_token" field.
  32564. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32565. m.consume_token = &u
  32566. m.addconsume_token = nil
  32567. }
  32568. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32569. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32570. v := m.consume_token
  32571. if v == nil {
  32572. return
  32573. }
  32574. return *v, true
  32575. }
  32576. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32577. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32579. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32580. if !m.op.Is(OpUpdateOne) {
  32581. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32582. }
  32583. if m.id == nil || m.oldValue == nil {
  32584. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32585. }
  32586. oldValue, err := m.oldValue(ctx)
  32587. if err != nil {
  32588. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32589. }
  32590. return oldValue.ConsumeToken, nil
  32591. }
  32592. // AddConsumeToken adds u to the "consume_token" field.
  32593. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32594. if m.addconsume_token != nil {
  32595. *m.addconsume_token += u
  32596. } else {
  32597. m.addconsume_token = &u
  32598. }
  32599. }
  32600. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32601. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32602. v := m.addconsume_token
  32603. if v == nil {
  32604. return
  32605. }
  32606. return *v, true
  32607. }
  32608. // ResetConsumeToken resets all changes to the "consume_token" field.
  32609. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32610. m.consume_token = nil
  32611. m.addconsume_token = nil
  32612. }
  32613. // SetActiveUser sets the "active_user" field.
  32614. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32615. m.active_user = &u
  32616. m.addactive_user = nil
  32617. }
  32618. // ActiveUser returns the value of the "active_user" field in the mutation.
  32619. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32620. v := m.active_user
  32621. if v == nil {
  32622. return
  32623. }
  32624. return *v, true
  32625. }
  32626. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32627. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32629. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32630. if !m.op.Is(OpUpdateOne) {
  32631. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32632. }
  32633. if m.id == nil || m.oldValue == nil {
  32634. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32635. }
  32636. oldValue, err := m.oldValue(ctx)
  32637. if err != nil {
  32638. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32639. }
  32640. return oldValue.ActiveUser, nil
  32641. }
  32642. // AddActiveUser adds u to the "active_user" field.
  32643. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32644. if m.addactive_user != nil {
  32645. *m.addactive_user += u
  32646. } else {
  32647. m.addactive_user = &u
  32648. }
  32649. }
  32650. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32651. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32652. v := m.addactive_user
  32653. if v == nil {
  32654. return
  32655. }
  32656. return *v, true
  32657. }
  32658. // ResetActiveUser resets all changes to the "active_user" field.
  32659. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32660. m.active_user = nil
  32661. m.addactive_user = nil
  32662. }
  32663. // SetNewUser sets the "new_user" field.
  32664. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32665. m.new_user = &i
  32666. m.addnew_user = nil
  32667. }
  32668. // NewUser returns the value of the "new_user" field in the mutation.
  32669. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32670. v := m.new_user
  32671. if v == nil {
  32672. return
  32673. }
  32674. return *v, true
  32675. }
  32676. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32677. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32679. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32680. if !m.op.Is(OpUpdateOne) {
  32681. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32682. }
  32683. if m.id == nil || m.oldValue == nil {
  32684. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32685. }
  32686. oldValue, err := m.oldValue(ctx)
  32687. if err != nil {
  32688. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32689. }
  32690. return oldValue.NewUser, nil
  32691. }
  32692. // AddNewUser adds i to the "new_user" field.
  32693. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32694. if m.addnew_user != nil {
  32695. *m.addnew_user += i
  32696. } else {
  32697. m.addnew_user = &i
  32698. }
  32699. }
  32700. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32701. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32702. v := m.addnew_user
  32703. if v == nil {
  32704. return
  32705. }
  32706. return *v, true
  32707. }
  32708. // ResetNewUser resets all changes to the "new_user" field.
  32709. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32710. m.new_user = nil
  32711. m.addnew_user = nil
  32712. }
  32713. // SetLabelDist sets the "label_dist" field.
  32714. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32715. m.label_dist = &ctd
  32716. m.appendlabel_dist = nil
  32717. }
  32718. // LabelDist returns the value of the "label_dist" field in the mutation.
  32719. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32720. v := m.label_dist
  32721. if v == nil {
  32722. return
  32723. }
  32724. return *v, true
  32725. }
  32726. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32727. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32729. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32730. if !m.op.Is(OpUpdateOne) {
  32731. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32732. }
  32733. if m.id == nil || m.oldValue == nil {
  32734. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32735. }
  32736. oldValue, err := m.oldValue(ctx)
  32737. if err != nil {
  32738. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32739. }
  32740. return oldValue.LabelDist, nil
  32741. }
  32742. // AppendLabelDist adds ctd to the "label_dist" field.
  32743. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32744. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32745. }
  32746. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32747. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32748. if len(m.appendlabel_dist) == 0 {
  32749. return nil, false
  32750. }
  32751. return m.appendlabel_dist, true
  32752. }
  32753. // ResetLabelDist resets all changes to the "label_dist" field.
  32754. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32755. m.label_dist = nil
  32756. m.appendlabel_dist = nil
  32757. }
  32758. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32759. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32760. m.predicates = append(m.predicates, ps...)
  32761. }
  32762. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32763. // users can use type-assertion to append predicates that do not depend on any generated package.
  32764. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32765. p := make([]predicate.UsageStatisticHour, len(ps))
  32766. for i := range ps {
  32767. p[i] = ps[i]
  32768. }
  32769. m.Where(p...)
  32770. }
  32771. // Op returns the operation name.
  32772. func (m *UsageStatisticHourMutation) Op() Op {
  32773. return m.op
  32774. }
  32775. // SetOp allows setting the mutation operation.
  32776. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32777. m.op = op
  32778. }
  32779. // Type returns the node type of this mutation (UsageStatisticHour).
  32780. func (m *UsageStatisticHourMutation) Type() string {
  32781. return m.typ
  32782. }
  32783. // Fields returns all fields that were changed during this mutation. Note that in
  32784. // order to get all numeric fields that were incremented/decremented, call
  32785. // AddedFields().
  32786. func (m *UsageStatisticHourMutation) Fields() []string {
  32787. fields := make([]string, 0, 17)
  32788. if m.created_at != nil {
  32789. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32790. }
  32791. if m.updated_at != nil {
  32792. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32793. }
  32794. if m.status != nil {
  32795. fields = append(fields, usagestatistichour.FieldStatus)
  32796. }
  32797. if m.deleted_at != nil {
  32798. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32799. }
  32800. if m.addtime != nil {
  32801. fields = append(fields, usagestatistichour.FieldAddtime)
  32802. }
  32803. if m._type != nil {
  32804. fields = append(fields, usagestatistichour.FieldType)
  32805. }
  32806. if m.bot_id != nil {
  32807. fields = append(fields, usagestatistichour.FieldBotID)
  32808. }
  32809. if m.organization_id != nil {
  32810. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32811. }
  32812. if m.ai_response != nil {
  32813. fields = append(fields, usagestatistichour.FieldAiResponse)
  32814. }
  32815. if m.sop_run != nil {
  32816. fields = append(fields, usagestatistichour.FieldSopRun)
  32817. }
  32818. if m.total_friend != nil {
  32819. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32820. }
  32821. if m.total_group != nil {
  32822. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32823. }
  32824. if m.account_balance != nil {
  32825. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32826. }
  32827. if m.consume_token != nil {
  32828. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32829. }
  32830. if m.active_user != nil {
  32831. fields = append(fields, usagestatistichour.FieldActiveUser)
  32832. }
  32833. if m.new_user != nil {
  32834. fields = append(fields, usagestatistichour.FieldNewUser)
  32835. }
  32836. if m.label_dist != nil {
  32837. fields = append(fields, usagestatistichour.FieldLabelDist)
  32838. }
  32839. return fields
  32840. }
  32841. // Field returns the value of a field with the given name. The second boolean
  32842. // return value indicates that this field was not set, or was not defined in the
  32843. // schema.
  32844. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32845. switch name {
  32846. case usagestatistichour.FieldCreatedAt:
  32847. return m.CreatedAt()
  32848. case usagestatistichour.FieldUpdatedAt:
  32849. return m.UpdatedAt()
  32850. case usagestatistichour.FieldStatus:
  32851. return m.Status()
  32852. case usagestatistichour.FieldDeletedAt:
  32853. return m.DeletedAt()
  32854. case usagestatistichour.FieldAddtime:
  32855. return m.Addtime()
  32856. case usagestatistichour.FieldType:
  32857. return m.GetType()
  32858. case usagestatistichour.FieldBotID:
  32859. return m.BotID()
  32860. case usagestatistichour.FieldOrganizationID:
  32861. return m.OrganizationID()
  32862. case usagestatistichour.FieldAiResponse:
  32863. return m.AiResponse()
  32864. case usagestatistichour.FieldSopRun:
  32865. return m.SopRun()
  32866. case usagestatistichour.FieldTotalFriend:
  32867. return m.TotalFriend()
  32868. case usagestatistichour.FieldTotalGroup:
  32869. return m.TotalGroup()
  32870. case usagestatistichour.FieldAccountBalance:
  32871. return m.AccountBalance()
  32872. case usagestatistichour.FieldConsumeToken:
  32873. return m.ConsumeToken()
  32874. case usagestatistichour.FieldActiveUser:
  32875. return m.ActiveUser()
  32876. case usagestatistichour.FieldNewUser:
  32877. return m.NewUser()
  32878. case usagestatistichour.FieldLabelDist:
  32879. return m.LabelDist()
  32880. }
  32881. return nil, false
  32882. }
  32883. // OldField returns the old value of the field from the database. An error is
  32884. // returned if the mutation operation is not UpdateOne, or the query to the
  32885. // database failed.
  32886. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32887. switch name {
  32888. case usagestatistichour.FieldCreatedAt:
  32889. return m.OldCreatedAt(ctx)
  32890. case usagestatistichour.FieldUpdatedAt:
  32891. return m.OldUpdatedAt(ctx)
  32892. case usagestatistichour.FieldStatus:
  32893. return m.OldStatus(ctx)
  32894. case usagestatistichour.FieldDeletedAt:
  32895. return m.OldDeletedAt(ctx)
  32896. case usagestatistichour.FieldAddtime:
  32897. return m.OldAddtime(ctx)
  32898. case usagestatistichour.FieldType:
  32899. return m.OldType(ctx)
  32900. case usagestatistichour.FieldBotID:
  32901. return m.OldBotID(ctx)
  32902. case usagestatistichour.FieldOrganizationID:
  32903. return m.OldOrganizationID(ctx)
  32904. case usagestatistichour.FieldAiResponse:
  32905. return m.OldAiResponse(ctx)
  32906. case usagestatistichour.FieldSopRun:
  32907. return m.OldSopRun(ctx)
  32908. case usagestatistichour.FieldTotalFriend:
  32909. return m.OldTotalFriend(ctx)
  32910. case usagestatistichour.FieldTotalGroup:
  32911. return m.OldTotalGroup(ctx)
  32912. case usagestatistichour.FieldAccountBalance:
  32913. return m.OldAccountBalance(ctx)
  32914. case usagestatistichour.FieldConsumeToken:
  32915. return m.OldConsumeToken(ctx)
  32916. case usagestatistichour.FieldActiveUser:
  32917. return m.OldActiveUser(ctx)
  32918. case usagestatistichour.FieldNewUser:
  32919. return m.OldNewUser(ctx)
  32920. case usagestatistichour.FieldLabelDist:
  32921. return m.OldLabelDist(ctx)
  32922. }
  32923. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32924. }
  32925. // SetField sets the value of a field with the given name. It returns an error if
  32926. // the field is not defined in the schema, or if the type mismatched the field
  32927. // type.
  32928. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  32929. switch name {
  32930. case usagestatistichour.FieldCreatedAt:
  32931. v, ok := value.(time.Time)
  32932. if !ok {
  32933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32934. }
  32935. m.SetCreatedAt(v)
  32936. return nil
  32937. case usagestatistichour.FieldUpdatedAt:
  32938. v, ok := value.(time.Time)
  32939. if !ok {
  32940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32941. }
  32942. m.SetUpdatedAt(v)
  32943. return nil
  32944. case usagestatistichour.FieldStatus:
  32945. v, ok := value.(uint8)
  32946. if !ok {
  32947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32948. }
  32949. m.SetStatus(v)
  32950. return nil
  32951. case usagestatistichour.FieldDeletedAt:
  32952. v, ok := value.(time.Time)
  32953. if !ok {
  32954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32955. }
  32956. m.SetDeletedAt(v)
  32957. return nil
  32958. case usagestatistichour.FieldAddtime:
  32959. v, ok := value.(uint64)
  32960. if !ok {
  32961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32962. }
  32963. m.SetAddtime(v)
  32964. return nil
  32965. case usagestatistichour.FieldType:
  32966. v, ok := value.(int)
  32967. if !ok {
  32968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32969. }
  32970. m.SetType(v)
  32971. return nil
  32972. case usagestatistichour.FieldBotID:
  32973. v, ok := value.(string)
  32974. if !ok {
  32975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32976. }
  32977. m.SetBotID(v)
  32978. return nil
  32979. case usagestatistichour.FieldOrganizationID:
  32980. v, ok := value.(uint64)
  32981. if !ok {
  32982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32983. }
  32984. m.SetOrganizationID(v)
  32985. return nil
  32986. case usagestatistichour.FieldAiResponse:
  32987. v, ok := value.(uint64)
  32988. if !ok {
  32989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32990. }
  32991. m.SetAiResponse(v)
  32992. return nil
  32993. case usagestatistichour.FieldSopRun:
  32994. v, ok := value.(uint64)
  32995. if !ok {
  32996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32997. }
  32998. m.SetSopRun(v)
  32999. return nil
  33000. case usagestatistichour.FieldTotalFriend:
  33001. v, ok := value.(uint64)
  33002. if !ok {
  33003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33004. }
  33005. m.SetTotalFriend(v)
  33006. return nil
  33007. case usagestatistichour.FieldTotalGroup:
  33008. v, ok := value.(uint64)
  33009. if !ok {
  33010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33011. }
  33012. m.SetTotalGroup(v)
  33013. return nil
  33014. case usagestatistichour.FieldAccountBalance:
  33015. v, ok := value.(uint64)
  33016. if !ok {
  33017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33018. }
  33019. m.SetAccountBalance(v)
  33020. return nil
  33021. case usagestatistichour.FieldConsumeToken:
  33022. v, ok := value.(uint64)
  33023. if !ok {
  33024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33025. }
  33026. m.SetConsumeToken(v)
  33027. return nil
  33028. case usagestatistichour.FieldActiveUser:
  33029. v, ok := value.(uint64)
  33030. if !ok {
  33031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33032. }
  33033. m.SetActiveUser(v)
  33034. return nil
  33035. case usagestatistichour.FieldNewUser:
  33036. v, ok := value.(int64)
  33037. if !ok {
  33038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33039. }
  33040. m.SetNewUser(v)
  33041. return nil
  33042. case usagestatistichour.FieldLabelDist:
  33043. v, ok := value.([]custom_types.LabelDist)
  33044. if !ok {
  33045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33046. }
  33047. m.SetLabelDist(v)
  33048. return nil
  33049. }
  33050. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33051. }
  33052. // AddedFields returns all numeric fields that were incremented/decremented during
  33053. // this mutation.
  33054. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33055. var fields []string
  33056. if m.addstatus != nil {
  33057. fields = append(fields, usagestatistichour.FieldStatus)
  33058. }
  33059. if m.addaddtime != nil {
  33060. fields = append(fields, usagestatistichour.FieldAddtime)
  33061. }
  33062. if m.add_type != nil {
  33063. fields = append(fields, usagestatistichour.FieldType)
  33064. }
  33065. if m.addorganization_id != nil {
  33066. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33067. }
  33068. if m.addai_response != nil {
  33069. fields = append(fields, usagestatistichour.FieldAiResponse)
  33070. }
  33071. if m.addsop_run != nil {
  33072. fields = append(fields, usagestatistichour.FieldSopRun)
  33073. }
  33074. if m.addtotal_friend != nil {
  33075. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33076. }
  33077. if m.addtotal_group != nil {
  33078. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33079. }
  33080. if m.addaccount_balance != nil {
  33081. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33082. }
  33083. if m.addconsume_token != nil {
  33084. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33085. }
  33086. if m.addactive_user != nil {
  33087. fields = append(fields, usagestatistichour.FieldActiveUser)
  33088. }
  33089. if m.addnew_user != nil {
  33090. fields = append(fields, usagestatistichour.FieldNewUser)
  33091. }
  33092. return fields
  33093. }
  33094. // AddedField returns the numeric value that was incremented/decremented on a field
  33095. // with the given name. The second boolean return value indicates that this field
  33096. // was not set, or was not defined in the schema.
  33097. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33098. switch name {
  33099. case usagestatistichour.FieldStatus:
  33100. return m.AddedStatus()
  33101. case usagestatistichour.FieldAddtime:
  33102. return m.AddedAddtime()
  33103. case usagestatistichour.FieldType:
  33104. return m.AddedType()
  33105. case usagestatistichour.FieldOrganizationID:
  33106. return m.AddedOrganizationID()
  33107. case usagestatistichour.FieldAiResponse:
  33108. return m.AddedAiResponse()
  33109. case usagestatistichour.FieldSopRun:
  33110. return m.AddedSopRun()
  33111. case usagestatistichour.FieldTotalFriend:
  33112. return m.AddedTotalFriend()
  33113. case usagestatistichour.FieldTotalGroup:
  33114. return m.AddedTotalGroup()
  33115. case usagestatistichour.FieldAccountBalance:
  33116. return m.AddedAccountBalance()
  33117. case usagestatistichour.FieldConsumeToken:
  33118. return m.AddedConsumeToken()
  33119. case usagestatistichour.FieldActiveUser:
  33120. return m.AddedActiveUser()
  33121. case usagestatistichour.FieldNewUser:
  33122. return m.AddedNewUser()
  33123. }
  33124. return nil, false
  33125. }
  33126. // AddField adds the value to the field with the given name. It returns an error if
  33127. // the field is not defined in the schema, or if the type mismatched the field
  33128. // type.
  33129. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33130. switch name {
  33131. case usagestatistichour.FieldStatus:
  33132. v, ok := value.(int8)
  33133. if !ok {
  33134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33135. }
  33136. m.AddStatus(v)
  33137. return nil
  33138. case usagestatistichour.FieldAddtime:
  33139. v, ok := value.(int64)
  33140. if !ok {
  33141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33142. }
  33143. m.AddAddtime(v)
  33144. return nil
  33145. case usagestatistichour.FieldType:
  33146. v, ok := value.(int)
  33147. if !ok {
  33148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33149. }
  33150. m.AddType(v)
  33151. return nil
  33152. case usagestatistichour.FieldOrganizationID:
  33153. v, ok := value.(int64)
  33154. if !ok {
  33155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33156. }
  33157. m.AddOrganizationID(v)
  33158. return nil
  33159. case usagestatistichour.FieldAiResponse:
  33160. v, ok := value.(int64)
  33161. if !ok {
  33162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33163. }
  33164. m.AddAiResponse(v)
  33165. return nil
  33166. case usagestatistichour.FieldSopRun:
  33167. v, ok := value.(int64)
  33168. if !ok {
  33169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33170. }
  33171. m.AddSopRun(v)
  33172. return nil
  33173. case usagestatistichour.FieldTotalFriend:
  33174. v, ok := value.(int64)
  33175. if !ok {
  33176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33177. }
  33178. m.AddTotalFriend(v)
  33179. return nil
  33180. case usagestatistichour.FieldTotalGroup:
  33181. v, ok := value.(int64)
  33182. if !ok {
  33183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33184. }
  33185. m.AddTotalGroup(v)
  33186. return nil
  33187. case usagestatistichour.FieldAccountBalance:
  33188. v, ok := value.(int64)
  33189. if !ok {
  33190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33191. }
  33192. m.AddAccountBalance(v)
  33193. return nil
  33194. case usagestatistichour.FieldConsumeToken:
  33195. v, ok := value.(int64)
  33196. if !ok {
  33197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33198. }
  33199. m.AddConsumeToken(v)
  33200. return nil
  33201. case usagestatistichour.FieldActiveUser:
  33202. v, ok := value.(int64)
  33203. if !ok {
  33204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33205. }
  33206. m.AddActiveUser(v)
  33207. return nil
  33208. case usagestatistichour.FieldNewUser:
  33209. v, ok := value.(int64)
  33210. if !ok {
  33211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33212. }
  33213. m.AddNewUser(v)
  33214. return nil
  33215. }
  33216. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33217. }
  33218. // ClearedFields returns all nullable fields that were cleared during this
  33219. // mutation.
  33220. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33221. var fields []string
  33222. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33223. fields = append(fields, usagestatistichour.FieldStatus)
  33224. }
  33225. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33226. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33227. }
  33228. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33229. fields = append(fields, usagestatistichour.FieldBotID)
  33230. }
  33231. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33232. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33233. }
  33234. return fields
  33235. }
  33236. // FieldCleared returns a boolean indicating if a field with the given name was
  33237. // cleared in this mutation.
  33238. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33239. _, ok := m.clearedFields[name]
  33240. return ok
  33241. }
  33242. // ClearField clears the value of the field with the given name. It returns an
  33243. // error if the field is not defined in the schema.
  33244. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33245. switch name {
  33246. case usagestatistichour.FieldStatus:
  33247. m.ClearStatus()
  33248. return nil
  33249. case usagestatistichour.FieldDeletedAt:
  33250. m.ClearDeletedAt()
  33251. return nil
  33252. case usagestatistichour.FieldBotID:
  33253. m.ClearBotID()
  33254. return nil
  33255. case usagestatistichour.FieldOrganizationID:
  33256. m.ClearOrganizationID()
  33257. return nil
  33258. }
  33259. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33260. }
  33261. // ResetField resets all changes in the mutation for the field with the given name.
  33262. // It returns an error if the field is not defined in the schema.
  33263. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33264. switch name {
  33265. case usagestatistichour.FieldCreatedAt:
  33266. m.ResetCreatedAt()
  33267. return nil
  33268. case usagestatistichour.FieldUpdatedAt:
  33269. m.ResetUpdatedAt()
  33270. return nil
  33271. case usagestatistichour.FieldStatus:
  33272. m.ResetStatus()
  33273. return nil
  33274. case usagestatistichour.FieldDeletedAt:
  33275. m.ResetDeletedAt()
  33276. return nil
  33277. case usagestatistichour.FieldAddtime:
  33278. m.ResetAddtime()
  33279. return nil
  33280. case usagestatistichour.FieldType:
  33281. m.ResetType()
  33282. return nil
  33283. case usagestatistichour.FieldBotID:
  33284. m.ResetBotID()
  33285. return nil
  33286. case usagestatistichour.FieldOrganizationID:
  33287. m.ResetOrganizationID()
  33288. return nil
  33289. case usagestatistichour.FieldAiResponse:
  33290. m.ResetAiResponse()
  33291. return nil
  33292. case usagestatistichour.FieldSopRun:
  33293. m.ResetSopRun()
  33294. return nil
  33295. case usagestatistichour.FieldTotalFriend:
  33296. m.ResetTotalFriend()
  33297. return nil
  33298. case usagestatistichour.FieldTotalGroup:
  33299. m.ResetTotalGroup()
  33300. return nil
  33301. case usagestatistichour.FieldAccountBalance:
  33302. m.ResetAccountBalance()
  33303. return nil
  33304. case usagestatistichour.FieldConsumeToken:
  33305. m.ResetConsumeToken()
  33306. return nil
  33307. case usagestatistichour.FieldActiveUser:
  33308. m.ResetActiveUser()
  33309. return nil
  33310. case usagestatistichour.FieldNewUser:
  33311. m.ResetNewUser()
  33312. return nil
  33313. case usagestatistichour.FieldLabelDist:
  33314. m.ResetLabelDist()
  33315. return nil
  33316. }
  33317. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33318. }
  33319. // AddedEdges returns all edge names that were set/added in this mutation.
  33320. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33321. edges := make([]string, 0, 0)
  33322. return edges
  33323. }
  33324. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33325. // name in this mutation.
  33326. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33327. return nil
  33328. }
  33329. // RemovedEdges returns all edge names that were removed in this mutation.
  33330. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33331. edges := make([]string, 0, 0)
  33332. return edges
  33333. }
  33334. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33335. // the given name in this mutation.
  33336. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33337. return nil
  33338. }
  33339. // ClearedEdges returns all edge names that were cleared in this mutation.
  33340. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33341. edges := make([]string, 0, 0)
  33342. return edges
  33343. }
  33344. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33345. // was cleared in this mutation.
  33346. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33347. return false
  33348. }
  33349. // ClearEdge clears the value of the edge with the given name. It returns an error
  33350. // if that edge is not defined in the schema.
  33351. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33352. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33353. }
  33354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33355. // It returns an error if the edge is not defined in the schema.
  33356. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33357. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33358. }
  33359. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33360. type UsageStatisticMonthMutation struct {
  33361. config
  33362. op Op
  33363. typ string
  33364. id *uint64
  33365. created_at *time.Time
  33366. updated_at *time.Time
  33367. status *uint8
  33368. addstatus *int8
  33369. deleted_at *time.Time
  33370. addtime *uint64
  33371. addaddtime *int64
  33372. _type *int
  33373. add_type *int
  33374. bot_id *string
  33375. organization_id *uint64
  33376. addorganization_id *int64
  33377. ai_response *uint64
  33378. addai_response *int64
  33379. sop_run *uint64
  33380. addsop_run *int64
  33381. total_friend *uint64
  33382. addtotal_friend *int64
  33383. total_group *uint64
  33384. addtotal_group *int64
  33385. account_balance *uint64
  33386. addaccount_balance *int64
  33387. consume_token *uint64
  33388. addconsume_token *int64
  33389. active_user *uint64
  33390. addactive_user *int64
  33391. new_user *int64
  33392. addnew_user *int64
  33393. label_dist *[]custom_types.LabelDist
  33394. appendlabel_dist []custom_types.LabelDist
  33395. clearedFields map[string]struct{}
  33396. done bool
  33397. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33398. predicates []predicate.UsageStatisticMonth
  33399. }
  33400. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33401. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33402. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33403. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33404. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33405. m := &UsageStatisticMonthMutation{
  33406. config: c,
  33407. op: op,
  33408. typ: TypeUsageStatisticMonth,
  33409. clearedFields: make(map[string]struct{}),
  33410. }
  33411. for _, opt := range opts {
  33412. opt(m)
  33413. }
  33414. return m
  33415. }
  33416. // withUsageStatisticMonthID sets the ID field of the mutation.
  33417. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33418. return func(m *UsageStatisticMonthMutation) {
  33419. var (
  33420. err error
  33421. once sync.Once
  33422. value *UsageStatisticMonth
  33423. )
  33424. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33425. once.Do(func() {
  33426. if m.done {
  33427. err = errors.New("querying old values post mutation is not allowed")
  33428. } else {
  33429. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33430. }
  33431. })
  33432. return value, err
  33433. }
  33434. m.id = &id
  33435. }
  33436. }
  33437. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33438. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33439. return func(m *UsageStatisticMonthMutation) {
  33440. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33441. return node, nil
  33442. }
  33443. m.id = &node.ID
  33444. }
  33445. }
  33446. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33447. // executed in a transaction (ent.Tx), a transactional client is returned.
  33448. func (m UsageStatisticMonthMutation) Client() *Client {
  33449. client := &Client{config: m.config}
  33450. client.init()
  33451. return client
  33452. }
  33453. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33454. // it returns an error otherwise.
  33455. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33456. if _, ok := m.driver.(*txDriver); !ok {
  33457. return nil, errors.New("ent: mutation is not running in a transaction")
  33458. }
  33459. tx := &Tx{config: m.config}
  33460. tx.init()
  33461. return tx, nil
  33462. }
  33463. // SetID sets the value of the id field. Note that this
  33464. // operation is only accepted on creation of UsageStatisticMonth entities.
  33465. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33466. m.id = &id
  33467. }
  33468. // ID returns the ID value in the mutation. Note that the ID is only available
  33469. // if it was provided to the builder or after it was returned from the database.
  33470. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33471. if m.id == nil {
  33472. return
  33473. }
  33474. return *m.id, true
  33475. }
  33476. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33477. // That means, if the mutation is applied within a transaction with an isolation level such
  33478. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33479. // or updated by the mutation.
  33480. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33481. switch {
  33482. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33483. id, exists := m.ID()
  33484. if exists {
  33485. return []uint64{id}, nil
  33486. }
  33487. fallthrough
  33488. case m.op.Is(OpUpdate | OpDelete):
  33489. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33490. default:
  33491. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33492. }
  33493. }
  33494. // SetCreatedAt sets the "created_at" field.
  33495. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33496. m.created_at = &t
  33497. }
  33498. // CreatedAt returns the value of the "created_at" field in the mutation.
  33499. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33500. v := m.created_at
  33501. if v == nil {
  33502. return
  33503. }
  33504. return *v, true
  33505. }
  33506. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33507. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33509. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33510. if !m.op.Is(OpUpdateOne) {
  33511. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33512. }
  33513. if m.id == nil || m.oldValue == nil {
  33514. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33515. }
  33516. oldValue, err := m.oldValue(ctx)
  33517. if err != nil {
  33518. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33519. }
  33520. return oldValue.CreatedAt, nil
  33521. }
  33522. // ResetCreatedAt resets all changes to the "created_at" field.
  33523. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33524. m.created_at = nil
  33525. }
  33526. // SetUpdatedAt sets the "updated_at" field.
  33527. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33528. m.updated_at = &t
  33529. }
  33530. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33531. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33532. v := m.updated_at
  33533. if v == nil {
  33534. return
  33535. }
  33536. return *v, true
  33537. }
  33538. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33539. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33541. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33542. if !m.op.Is(OpUpdateOne) {
  33543. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33544. }
  33545. if m.id == nil || m.oldValue == nil {
  33546. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33547. }
  33548. oldValue, err := m.oldValue(ctx)
  33549. if err != nil {
  33550. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33551. }
  33552. return oldValue.UpdatedAt, nil
  33553. }
  33554. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33555. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33556. m.updated_at = nil
  33557. }
  33558. // SetStatus sets the "status" field.
  33559. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33560. m.status = &u
  33561. m.addstatus = nil
  33562. }
  33563. // Status returns the value of the "status" field in the mutation.
  33564. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33565. v := m.status
  33566. if v == nil {
  33567. return
  33568. }
  33569. return *v, true
  33570. }
  33571. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33572. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33574. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33575. if !m.op.Is(OpUpdateOne) {
  33576. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33577. }
  33578. if m.id == nil || m.oldValue == nil {
  33579. return v, errors.New("OldStatus requires an ID field in the mutation")
  33580. }
  33581. oldValue, err := m.oldValue(ctx)
  33582. if err != nil {
  33583. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33584. }
  33585. return oldValue.Status, nil
  33586. }
  33587. // AddStatus adds u to the "status" field.
  33588. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33589. if m.addstatus != nil {
  33590. *m.addstatus += u
  33591. } else {
  33592. m.addstatus = &u
  33593. }
  33594. }
  33595. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33596. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33597. v := m.addstatus
  33598. if v == nil {
  33599. return
  33600. }
  33601. return *v, true
  33602. }
  33603. // ClearStatus clears the value of the "status" field.
  33604. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33605. m.status = nil
  33606. m.addstatus = nil
  33607. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33608. }
  33609. // StatusCleared returns if the "status" field was cleared in this mutation.
  33610. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33611. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33612. return ok
  33613. }
  33614. // ResetStatus resets all changes to the "status" field.
  33615. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33616. m.status = nil
  33617. m.addstatus = nil
  33618. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33619. }
  33620. // SetDeletedAt sets the "deleted_at" field.
  33621. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33622. m.deleted_at = &t
  33623. }
  33624. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33625. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33626. v := m.deleted_at
  33627. if v == nil {
  33628. return
  33629. }
  33630. return *v, true
  33631. }
  33632. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33633. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33635. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33636. if !m.op.Is(OpUpdateOne) {
  33637. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33638. }
  33639. if m.id == nil || m.oldValue == nil {
  33640. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33641. }
  33642. oldValue, err := m.oldValue(ctx)
  33643. if err != nil {
  33644. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33645. }
  33646. return oldValue.DeletedAt, nil
  33647. }
  33648. // ClearDeletedAt clears the value of the "deleted_at" field.
  33649. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33650. m.deleted_at = nil
  33651. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33652. }
  33653. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33654. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33655. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33656. return ok
  33657. }
  33658. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33659. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33660. m.deleted_at = nil
  33661. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33662. }
  33663. // SetAddtime sets the "addtime" field.
  33664. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33665. m.addtime = &u
  33666. m.addaddtime = nil
  33667. }
  33668. // Addtime returns the value of the "addtime" field in the mutation.
  33669. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33670. v := m.addtime
  33671. if v == nil {
  33672. return
  33673. }
  33674. return *v, true
  33675. }
  33676. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33677. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33679. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33680. if !m.op.Is(OpUpdateOne) {
  33681. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33682. }
  33683. if m.id == nil || m.oldValue == nil {
  33684. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33685. }
  33686. oldValue, err := m.oldValue(ctx)
  33687. if err != nil {
  33688. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33689. }
  33690. return oldValue.Addtime, nil
  33691. }
  33692. // AddAddtime adds u to the "addtime" field.
  33693. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33694. if m.addaddtime != nil {
  33695. *m.addaddtime += u
  33696. } else {
  33697. m.addaddtime = &u
  33698. }
  33699. }
  33700. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33701. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33702. v := m.addaddtime
  33703. if v == nil {
  33704. return
  33705. }
  33706. return *v, true
  33707. }
  33708. // ResetAddtime resets all changes to the "addtime" field.
  33709. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33710. m.addtime = nil
  33711. m.addaddtime = nil
  33712. }
  33713. // SetType sets the "type" field.
  33714. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33715. m._type = &i
  33716. m.add_type = nil
  33717. }
  33718. // GetType returns the value of the "type" field in the mutation.
  33719. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33720. v := m._type
  33721. if v == nil {
  33722. return
  33723. }
  33724. return *v, true
  33725. }
  33726. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33727. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33729. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33730. if !m.op.Is(OpUpdateOne) {
  33731. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33732. }
  33733. if m.id == nil || m.oldValue == nil {
  33734. return v, errors.New("OldType requires an ID field in the mutation")
  33735. }
  33736. oldValue, err := m.oldValue(ctx)
  33737. if err != nil {
  33738. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33739. }
  33740. return oldValue.Type, nil
  33741. }
  33742. // AddType adds i to the "type" field.
  33743. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33744. if m.add_type != nil {
  33745. *m.add_type += i
  33746. } else {
  33747. m.add_type = &i
  33748. }
  33749. }
  33750. // AddedType returns the value that was added to the "type" field in this mutation.
  33751. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33752. v := m.add_type
  33753. if v == nil {
  33754. return
  33755. }
  33756. return *v, true
  33757. }
  33758. // ResetType resets all changes to the "type" field.
  33759. func (m *UsageStatisticMonthMutation) ResetType() {
  33760. m._type = nil
  33761. m.add_type = nil
  33762. }
  33763. // SetBotID sets the "bot_id" field.
  33764. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33765. m.bot_id = &s
  33766. }
  33767. // BotID returns the value of the "bot_id" field in the mutation.
  33768. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33769. v := m.bot_id
  33770. if v == nil {
  33771. return
  33772. }
  33773. return *v, true
  33774. }
  33775. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33776. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33778. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33779. if !m.op.Is(OpUpdateOne) {
  33780. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33781. }
  33782. if m.id == nil || m.oldValue == nil {
  33783. return v, errors.New("OldBotID requires an ID field in the mutation")
  33784. }
  33785. oldValue, err := m.oldValue(ctx)
  33786. if err != nil {
  33787. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33788. }
  33789. return oldValue.BotID, nil
  33790. }
  33791. // ClearBotID clears the value of the "bot_id" field.
  33792. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33793. m.bot_id = nil
  33794. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33795. }
  33796. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33797. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33798. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33799. return ok
  33800. }
  33801. // ResetBotID resets all changes to the "bot_id" field.
  33802. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33803. m.bot_id = nil
  33804. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33805. }
  33806. // SetOrganizationID sets the "organization_id" field.
  33807. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33808. m.organization_id = &u
  33809. m.addorganization_id = nil
  33810. }
  33811. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33812. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33813. v := m.organization_id
  33814. if v == nil {
  33815. return
  33816. }
  33817. return *v, true
  33818. }
  33819. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33820. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33822. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33823. if !m.op.Is(OpUpdateOne) {
  33824. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33825. }
  33826. if m.id == nil || m.oldValue == nil {
  33827. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33828. }
  33829. oldValue, err := m.oldValue(ctx)
  33830. if err != nil {
  33831. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33832. }
  33833. return oldValue.OrganizationID, nil
  33834. }
  33835. // AddOrganizationID adds u to the "organization_id" field.
  33836. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33837. if m.addorganization_id != nil {
  33838. *m.addorganization_id += u
  33839. } else {
  33840. m.addorganization_id = &u
  33841. }
  33842. }
  33843. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33844. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33845. v := m.addorganization_id
  33846. if v == nil {
  33847. return
  33848. }
  33849. return *v, true
  33850. }
  33851. // ClearOrganizationID clears the value of the "organization_id" field.
  33852. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  33853. m.organization_id = nil
  33854. m.addorganization_id = nil
  33855. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  33856. }
  33857. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33858. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  33859. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  33860. return ok
  33861. }
  33862. // ResetOrganizationID resets all changes to the "organization_id" field.
  33863. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  33864. m.organization_id = nil
  33865. m.addorganization_id = nil
  33866. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  33867. }
  33868. // SetAiResponse sets the "ai_response" field.
  33869. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  33870. m.ai_response = &u
  33871. m.addai_response = nil
  33872. }
  33873. // AiResponse returns the value of the "ai_response" field in the mutation.
  33874. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  33875. v := m.ai_response
  33876. if v == nil {
  33877. return
  33878. }
  33879. return *v, true
  33880. }
  33881. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  33882. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33884. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33885. if !m.op.Is(OpUpdateOne) {
  33886. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33887. }
  33888. if m.id == nil || m.oldValue == nil {
  33889. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33890. }
  33891. oldValue, err := m.oldValue(ctx)
  33892. if err != nil {
  33893. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33894. }
  33895. return oldValue.AiResponse, nil
  33896. }
  33897. // AddAiResponse adds u to the "ai_response" field.
  33898. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  33899. if m.addai_response != nil {
  33900. *m.addai_response += u
  33901. } else {
  33902. m.addai_response = &u
  33903. }
  33904. }
  33905. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33906. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33907. v := m.addai_response
  33908. if v == nil {
  33909. return
  33910. }
  33911. return *v, true
  33912. }
  33913. // ResetAiResponse resets all changes to the "ai_response" field.
  33914. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33915. m.ai_response = nil
  33916. m.addai_response = nil
  33917. }
  33918. // SetSopRun sets the "sop_run" field.
  33919. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33920. m.sop_run = &u
  33921. m.addsop_run = nil
  33922. }
  33923. // SopRun returns the value of the "sop_run" field in the mutation.
  33924. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  33925. v := m.sop_run
  33926. if v == nil {
  33927. return
  33928. }
  33929. return *v, true
  33930. }
  33931. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  33932. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33934. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33935. if !m.op.Is(OpUpdateOne) {
  33936. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33937. }
  33938. if m.id == nil || m.oldValue == nil {
  33939. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33940. }
  33941. oldValue, err := m.oldValue(ctx)
  33942. if err != nil {
  33943. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33944. }
  33945. return oldValue.SopRun, nil
  33946. }
  33947. // AddSopRun adds u to the "sop_run" field.
  33948. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  33949. if m.addsop_run != nil {
  33950. *m.addsop_run += u
  33951. } else {
  33952. m.addsop_run = &u
  33953. }
  33954. }
  33955. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33956. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  33957. v := m.addsop_run
  33958. if v == nil {
  33959. return
  33960. }
  33961. return *v, true
  33962. }
  33963. // ResetSopRun resets all changes to the "sop_run" field.
  33964. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  33965. m.sop_run = nil
  33966. m.addsop_run = nil
  33967. }
  33968. // SetTotalFriend sets the "total_friend" field.
  33969. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  33970. m.total_friend = &u
  33971. m.addtotal_friend = nil
  33972. }
  33973. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33974. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  33975. v := m.total_friend
  33976. if v == nil {
  33977. return
  33978. }
  33979. return *v, true
  33980. }
  33981. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  33982. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33984. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33985. if !m.op.Is(OpUpdateOne) {
  33986. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33987. }
  33988. if m.id == nil || m.oldValue == nil {
  33989. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33990. }
  33991. oldValue, err := m.oldValue(ctx)
  33992. if err != nil {
  33993. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33994. }
  33995. return oldValue.TotalFriend, nil
  33996. }
  33997. // AddTotalFriend adds u to the "total_friend" field.
  33998. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  33999. if m.addtotal_friend != nil {
  34000. *m.addtotal_friend += u
  34001. } else {
  34002. m.addtotal_friend = &u
  34003. }
  34004. }
  34005. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34006. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34007. v := m.addtotal_friend
  34008. if v == nil {
  34009. return
  34010. }
  34011. return *v, true
  34012. }
  34013. // ResetTotalFriend resets all changes to the "total_friend" field.
  34014. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34015. m.total_friend = nil
  34016. m.addtotal_friend = nil
  34017. }
  34018. // SetTotalGroup sets the "total_group" field.
  34019. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34020. m.total_group = &u
  34021. m.addtotal_group = nil
  34022. }
  34023. // TotalGroup returns the value of the "total_group" field in the mutation.
  34024. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34025. v := m.total_group
  34026. if v == nil {
  34027. return
  34028. }
  34029. return *v, true
  34030. }
  34031. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34032. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34034. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34035. if !m.op.Is(OpUpdateOne) {
  34036. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34037. }
  34038. if m.id == nil || m.oldValue == nil {
  34039. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34040. }
  34041. oldValue, err := m.oldValue(ctx)
  34042. if err != nil {
  34043. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34044. }
  34045. return oldValue.TotalGroup, nil
  34046. }
  34047. // AddTotalGroup adds u to the "total_group" field.
  34048. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34049. if m.addtotal_group != nil {
  34050. *m.addtotal_group += u
  34051. } else {
  34052. m.addtotal_group = &u
  34053. }
  34054. }
  34055. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34056. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34057. v := m.addtotal_group
  34058. if v == nil {
  34059. return
  34060. }
  34061. return *v, true
  34062. }
  34063. // ResetTotalGroup resets all changes to the "total_group" field.
  34064. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34065. m.total_group = nil
  34066. m.addtotal_group = nil
  34067. }
  34068. // SetAccountBalance sets the "account_balance" field.
  34069. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34070. m.account_balance = &u
  34071. m.addaccount_balance = nil
  34072. }
  34073. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34074. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34075. v := m.account_balance
  34076. if v == nil {
  34077. return
  34078. }
  34079. return *v, true
  34080. }
  34081. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34082. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34084. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34085. if !m.op.Is(OpUpdateOne) {
  34086. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34087. }
  34088. if m.id == nil || m.oldValue == nil {
  34089. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34090. }
  34091. oldValue, err := m.oldValue(ctx)
  34092. if err != nil {
  34093. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34094. }
  34095. return oldValue.AccountBalance, nil
  34096. }
  34097. // AddAccountBalance adds u to the "account_balance" field.
  34098. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34099. if m.addaccount_balance != nil {
  34100. *m.addaccount_balance += u
  34101. } else {
  34102. m.addaccount_balance = &u
  34103. }
  34104. }
  34105. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34106. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34107. v := m.addaccount_balance
  34108. if v == nil {
  34109. return
  34110. }
  34111. return *v, true
  34112. }
  34113. // ResetAccountBalance resets all changes to the "account_balance" field.
  34114. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34115. m.account_balance = nil
  34116. m.addaccount_balance = nil
  34117. }
  34118. // SetConsumeToken sets the "consume_token" field.
  34119. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34120. m.consume_token = &u
  34121. m.addconsume_token = nil
  34122. }
  34123. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34124. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34125. v := m.consume_token
  34126. if v == nil {
  34127. return
  34128. }
  34129. return *v, true
  34130. }
  34131. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34132. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34134. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34135. if !m.op.Is(OpUpdateOne) {
  34136. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34137. }
  34138. if m.id == nil || m.oldValue == nil {
  34139. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34140. }
  34141. oldValue, err := m.oldValue(ctx)
  34142. if err != nil {
  34143. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34144. }
  34145. return oldValue.ConsumeToken, nil
  34146. }
  34147. // AddConsumeToken adds u to the "consume_token" field.
  34148. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34149. if m.addconsume_token != nil {
  34150. *m.addconsume_token += u
  34151. } else {
  34152. m.addconsume_token = &u
  34153. }
  34154. }
  34155. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34156. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34157. v := m.addconsume_token
  34158. if v == nil {
  34159. return
  34160. }
  34161. return *v, true
  34162. }
  34163. // ResetConsumeToken resets all changes to the "consume_token" field.
  34164. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34165. m.consume_token = nil
  34166. m.addconsume_token = nil
  34167. }
  34168. // SetActiveUser sets the "active_user" field.
  34169. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34170. m.active_user = &u
  34171. m.addactive_user = nil
  34172. }
  34173. // ActiveUser returns the value of the "active_user" field in the mutation.
  34174. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34175. v := m.active_user
  34176. if v == nil {
  34177. return
  34178. }
  34179. return *v, true
  34180. }
  34181. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34182. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34184. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34185. if !m.op.Is(OpUpdateOne) {
  34186. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34187. }
  34188. if m.id == nil || m.oldValue == nil {
  34189. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34190. }
  34191. oldValue, err := m.oldValue(ctx)
  34192. if err != nil {
  34193. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34194. }
  34195. return oldValue.ActiveUser, nil
  34196. }
  34197. // AddActiveUser adds u to the "active_user" field.
  34198. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34199. if m.addactive_user != nil {
  34200. *m.addactive_user += u
  34201. } else {
  34202. m.addactive_user = &u
  34203. }
  34204. }
  34205. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34206. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34207. v := m.addactive_user
  34208. if v == nil {
  34209. return
  34210. }
  34211. return *v, true
  34212. }
  34213. // ResetActiveUser resets all changes to the "active_user" field.
  34214. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34215. m.active_user = nil
  34216. m.addactive_user = nil
  34217. }
  34218. // SetNewUser sets the "new_user" field.
  34219. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34220. m.new_user = &i
  34221. m.addnew_user = nil
  34222. }
  34223. // NewUser returns the value of the "new_user" field in the mutation.
  34224. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34225. v := m.new_user
  34226. if v == nil {
  34227. return
  34228. }
  34229. return *v, true
  34230. }
  34231. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34232. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34234. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34235. if !m.op.Is(OpUpdateOne) {
  34236. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34237. }
  34238. if m.id == nil || m.oldValue == nil {
  34239. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34240. }
  34241. oldValue, err := m.oldValue(ctx)
  34242. if err != nil {
  34243. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34244. }
  34245. return oldValue.NewUser, nil
  34246. }
  34247. // AddNewUser adds i to the "new_user" field.
  34248. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34249. if m.addnew_user != nil {
  34250. *m.addnew_user += i
  34251. } else {
  34252. m.addnew_user = &i
  34253. }
  34254. }
  34255. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34256. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34257. v := m.addnew_user
  34258. if v == nil {
  34259. return
  34260. }
  34261. return *v, true
  34262. }
  34263. // ResetNewUser resets all changes to the "new_user" field.
  34264. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34265. m.new_user = nil
  34266. m.addnew_user = nil
  34267. }
  34268. // SetLabelDist sets the "label_dist" field.
  34269. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34270. m.label_dist = &ctd
  34271. m.appendlabel_dist = nil
  34272. }
  34273. // LabelDist returns the value of the "label_dist" field in the mutation.
  34274. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34275. v := m.label_dist
  34276. if v == nil {
  34277. return
  34278. }
  34279. return *v, true
  34280. }
  34281. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34282. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34284. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34285. if !m.op.Is(OpUpdateOne) {
  34286. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34287. }
  34288. if m.id == nil || m.oldValue == nil {
  34289. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34290. }
  34291. oldValue, err := m.oldValue(ctx)
  34292. if err != nil {
  34293. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34294. }
  34295. return oldValue.LabelDist, nil
  34296. }
  34297. // AppendLabelDist adds ctd to the "label_dist" field.
  34298. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34299. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34300. }
  34301. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34302. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34303. if len(m.appendlabel_dist) == 0 {
  34304. return nil, false
  34305. }
  34306. return m.appendlabel_dist, true
  34307. }
  34308. // ResetLabelDist resets all changes to the "label_dist" field.
  34309. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34310. m.label_dist = nil
  34311. m.appendlabel_dist = nil
  34312. }
  34313. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34314. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34315. m.predicates = append(m.predicates, ps...)
  34316. }
  34317. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34318. // users can use type-assertion to append predicates that do not depend on any generated package.
  34319. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34320. p := make([]predicate.UsageStatisticMonth, len(ps))
  34321. for i := range ps {
  34322. p[i] = ps[i]
  34323. }
  34324. m.Where(p...)
  34325. }
  34326. // Op returns the operation name.
  34327. func (m *UsageStatisticMonthMutation) Op() Op {
  34328. return m.op
  34329. }
  34330. // SetOp allows setting the mutation operation.
  34331. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34332. m.op = op
  34333. }
  34334. // Type returns the node type of this mutation (UsageStatisticMonth).
  34335. func (m *UsageStatisticMonthMutation) Type() string {
  34336. return m.typ
  34337. }
  34338. // Fields returns all fields that were changed during this mutation. Note that in
  34339. // order to get all numeric fields that were incremented/decremented, call
  34340. // AddedFields().
  34341. func (m *UsageStatisticMonthMutation) Fields() []string {
  34342. fields := make([]string, 0, 17)
  34343. if m.created_at != nil {
  34344. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34345. }
  34346. if m.updated_at != nil {
  34347. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34348. }
  34349. if m.status != nil {
  34350. fields = append(fields, usagestatisticmonth.FieldStatus)
  34351. }
  34352. if m.deleted_at != nil {
  34353. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34354. }
  34355. if m.addtime != nil {
  34356. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34357. }
  34358. if m._type != nil {
  34359. fields = append(fields, usagestatisticmonth.FieldType)
  34360. }
  34361. if m.bot_id != nil {
  34362. fields = append(fields, usagestatisticmonth.FieldBotID)
  34363. }
  34364. if m.organization_id != nil {
  34365. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34366. }
  34367. if m.ai_response != nil {
  34368. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34369. }
  34370. if m.sop_run != nil {
  34371. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34372. }
  34373. if m.total_friend != nil {
  34374. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34375. }
  34376. if m.total_group != nil {
  34377. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34378. }
  34379. if m.account_balance != nil {
  34380. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34381. }
  34382. if m.consume_token != nil {
  34383. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34384. }
  34385. if m.active_user != nil {
  34386. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34387. }
  34388. if m.new_user != nil {
  34389. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34390. }
  34391. if m.label_dist != nil {
  34392. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34393. }
  34394. return fields
  34395. }
  34396. // Field returns the value of a field with the given name. The second boolean
  34397. // return value indicates that this field was not set, or was not defined in the
  34398. // schema.
  34399. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34400. switch name {
  34401. case usagestatisticmonth.FieldCreatedAt:
  34402. return m.CreatedAt()
  34403. case usagestatisticmonth.FieldUpdatedAt:
  34404. return m.UpdatedAt()
  34405. case usagestatisticmonth.FieldStatus:
  34406. return m.Status()
  34407. case usagestatisticmonth.FieldDeletedAt:
  34408. return m.DeletedAt()
  34409. case usagestatisticmonth.FieldAddtime:
  34410. return m.Addtime()
  34411. case usagestatisticmonth.FieldType:
  34412. return m.GetType()
  34413. case usagestatisticmonth.FieldBotID:
  34414. return m.BotID()
  34415. case usagestatisticmonth.FieldOrganizationID:
  34416. return m.OrganizationID()
  34417. case usagestatisticmonth.FieldAiResponse:
  34418. return m.AiResponse()
  34419. case usagestatisticmonth.FieldSopRun:
  34420. return m.SopRun()
  34421. case usagestatisticmonth.FieldTotalFriend:
  34422. return m.TotalFriend()
  34423. case usagestatisticmonth.FieldTotalGroup:
  34424. return m.TotalGroup()
  34425. case usagestatisticmonth.FieldAccountBalance:
  34426. return m.AccountBalance()
  34427. case usagestatisticmonth.FieldConsumeToken:
  34428. return m.ConsumeToken()
  34429. case usagestatisticmonth.FieldActiveUser:
  34430. return m.ActiveUser()
  34431. case usagestatisticmonth.FieldNewUser:
  34432. return m.NewUser()
  34433. case usagestatisticmonth.FieldLabelDist:
  34434. return m.LabelDist()
  34435. }
  34436. return nil, false
  34437. }
  34438. // OldField returns the old value of the field from the database. An error is
  34439. // returned if the mutation operation is not UpdateOne, or the query to the
  34440. // database failed.
  34441. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34442. switch name {
  34443. case usagestatisticmonth.FieldCreatedAt:
  34444. return m.OldCreatedAt(ctx)
  34445. case usagestatisticmonth.FieldUpdatedAt:
  34446. return m.OldUpdatedAt(ctx)
  34447. case usagestatisticmonth.FieldStatus:
  34448. return m.OldStatus(ctx)
  34449. case usagestatisticmonth.FieldDeletedAt:
  34450. return m.OldDeletedAt(ctx)
  34451. case usagestatisticmonth.FieldAddtime:
  34452. return m.OldAddtime(ctx)
  34453. case usagestatisticmonth.FieldType:
  34454. return m.OldType(ctx)
  34455. case usagestatisticmonth.FieldBotID:
  34456. return m.OldBotID(ctx)
  34457. case usagestatisticmonth.FieldOrganizationID:
  34458. return m.OldOrganizationID(ctx)
  34459. case usagestatisticmonth.FieldAiResponse:
  34460. return m.OldAiResponse(ctx)
  34461. case usagestatisticmonth.FieldSopRun:
  34462. return m.OldSopRun(ctx)
  34463. case usagestatisticmonth.FieldTotalFriend:
  34464. return m.OldTotalFriend(ctx)
  34465. case usagestatisticmonth.FieldTotalGroup:
  34466. return m.OldTotalGroup(ctx)
  34467. case usagestatisticmonth.FieldAccountBalance:
  34468. return m.OldAccountBalance(ctx)
  34469. case usagestatisticmonth.FieldConsumeToken:
  34470. return m.OldConsumeToken(ctx)
  34471. case usagestatisticmonth.FieldActiveUser:
  34472. return m.OldActiveUser(ctx)
  34473. case usagestatisticmonth.FieldNewUser:
  34474. return m.OldNewUser(ctx)
  34475. case usagestatisticmonth.FieldLabelDist:
  34476. return m.OldLabelDist(ctx)
  34477. }
  34478. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34479. }
  34480. // SetField sets the value of a field with the given name. It returns an error if
  34481. // the field is not defined in the schema, or if the type mismatched the field
  34482. // type.
  34483. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34484. switch name {
  34485. case usagestatisticmonth.FieldCreatedAt:
  34486. v, ok := value.(time.Time)
  34487. if !ok {
  34488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34489. }
  34490. m.SetCreatedAt(v)
  34491. return nil
  34492. case usagestatisticmonth.FieldUpdatedAt:
  34493. v, ok := value.(time.Time)
  34494. if !ok {
  34495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34496. }
  34497. m.SetUpdatedAt(v)
  34498. return nil
  34499. case usagestatisticmonth.FieldStatus:
  34500. v, ok := value.(uint8)
  34501. if !ok {
  34502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34503. }
  34504. m.SetStatus(v)
  34505. return nil
  34506. case usagestatisticmonth.FieldDeletedAt:
  34507. v, ok := value.(time.Time)
  34508. if !ok {
  34509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34510. }
  34511. m.SetDeletedAt(v)
  34512. return nil
  34513. case usagestatisticmonth.FieldAddtime:
  34514. v, ok := value.(uint64)
  34515. if !ok {
  34516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34517. }
  34518. m.SetAddtime(v)
  34519. return nil
  34520. case usagestatisticmonth.FieldType:
  34521. v, ok := value.(int)
  34522. if !ok {
  34523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34524. }
  34525. m.SetType(v)
  34526. return nil
  34527. case usagestatisticmonth.FieldBotID:
  34528. v, ok := value.(string)
  34529. if !ok {
  34530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34531. }
  34532. m.SetBotID(v)
  34533. return nil
  34534. case usagestatisticmonth.FieldOrganizationID:
  34535. v, ok := value.(uint64)
  34536. if !ok {
  34537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34538. }
  34539. m.SetOrganizationID(v)
  34540. return nil
  34541. case usagestatisticmonth.FieldAiResponse:
  34542. v, ok := value.(uint64)
  34543. if !ok {
  34544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34545. }
  34546. m.SetAiResponse(v)
  34547. return nil
  34548. case usagestatisticmonth.FieldSopRun:
  34549. v, ok := value.(uint64)
  34550. if !ok {
  34551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34552. }
  34553. m.SetSopRun(v)
  34554. return nil
  34555. case usagestatisticmonth.FieldTotalFriend:
  34556. v, ok := value.(uint64)
  34557. if !ok {
  34558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34559. }
  34560. m.SetTotalFriend(v)
  34561. return nil
  34562. case usagestatisticmonth.FieldTotalGroup:
  34563. v, ok := value.(uint64)
  34564. if !ok {
  34565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34566. }
  34567. m.SetTotalGroup(v)
  34568. return nil
  34569. case usagestatisticmonth.FieldAccountBalance:
  34570. v, ok := value.(uint64)
  34571. if !ok {
  34572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34573. }
  34574. m.SetAccountBalance(v)
  34575. return nil
  34576. case usagestatisticmonth.FieldConsumeToken:
  34577. v, ok := value.(uint64)
  34578. if !ok {
  34579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34580. }
  34581. m.SetConsumeToken(v)
  34582. return nil
  34583. case usagestatisticmonth.FieldActiveUser:
  34584. v, ok := value.(uint64)
  34585. if !ok {
  34586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34587. }
  34588. m.SetActiveUser(v)
  34589. return nil
  34590. case usagestatisticmonth.FieldNewUser:
  34591. v, ok := value.(int64)
  34592. if !ok {
  34593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34594. }
  34595. m.SetNewUser(v)
  34596. return nil
  34597. case usagestatisticmonth.FieldLabelDist:
  34598. v, ok := value.([]custom_types.LabelDist)
  34599. if !ok {
  34600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34601. }
  34602. m.SetLabelDist(v)
  34603. return nil
  34604. }
  34605. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34606. }
  34607. // AddedFields returns all numeric fields that were incremented/decremented during
  34608. // this mutation.
  34609. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34610. var fields []string
  34611. if m.addstatus != nil {
  34612. fields = append(fields, usagestatisticmonth.FieldStatus)
  34613. }
  34614. if m.addaddtime != nil {
  34615. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34616. }
  34617. if m.add_type != nil {
  34618. fields = append(fields, usagestatisticmonth.FieldType)
  34619. }
  34620. if m.addorganization_id != nil {
  34621. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34622. }
  34623. if m.addai_response != nil {
  34624. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34625. }
  34626. if m.addsop_run != nil {
  34627. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34628. }
  34629. if m.addtotal_friend != nil {
  34630. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34631. }
  34632. if m.addtotal_group != nil {
  34633. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34634. }
  34635. if m.addaccount_balance != nil {
  34636. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34637. }
  34638. if m.addconsume_token != nil {
  34639. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34640. }
  34641. if m.addactive_user != nil {
  34642. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34643. }
  34644. if m.addnew_user != nil {
  34645. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34646. }
  34647. return fields
  34648. }
  34649. // AddedField returns the numeric value that was incremented/decremented on a field
  34650. // with the given name. The second boolean return value indicates that this field
  34651. // was not set, or was not defined in the schema.
  34652. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34653. switch name {
  34654. case usagestatisticmonth.FieldStatus:
  34655. return m.AddedStatus()
  34656. case usagestatisticmonth.FieldAddtime:
  34657. return m.AddedAddtime()
  34658. case usagestatisticmonth.FieldType:
  34659. return m.AddedType()
  34660. case usagestatisticmonth.FieldOrganizationID:
  34661. return m.AddedOrganizationID()
  34662. case usagestatisticmonth.FieldAiResponse:
  34663. return m.AddedAiResponse()
  34664. case usagestatisticmonth.FieldSopRun:
  34665. return m.AddedSopRun()
  34666. case usagestatisticmonth.FieldTotalFriend:
  34667. return m.AddedTotalFriend()
  34668. case usagestatisticmonth.FieldTotalGroup:
  34669. return m.AddedTotalGroup()
  34670. case usagestatisticmonth.FieldAccountBalance:
  34671. return m.AddedAccountBalance()
  34672. case usagestatisticmonth.FieldConsumeToken:
  34673. return m.AddedConsumeToken()
  34674. case usagestatisticmonth.FieldActiveUser:
  34675. return m.AddedActiveUser()
  34676. case usagestatisticmonth.FieldNewUser:
  34677. return m.AddedNewUser()
  34678. }
  34679. return nil, false
  34680. }
  34681. // AddField adds the value to the field with the given name. It returns an error if
  34682. // the field is not defined in the schema, or if the type mismatched the field
  34683. // type.
  34684. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34685. switch name {
  34686. case usagestatisticmonth.FieldStatus:
  34687. v, ok := value.(int8)
  34688. if !ok {
  34689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34690. }
  34691. m.AddStatus(v)
  34692. return nil
  34693. case usagestatisticmonth.FieldAddtime:
  34694. v, ok := value.(int64)
  34695. if !ok {
  34696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34697. }
  34698. m.AddAddtime(v)
  34699. return nil
  34700. case usagestatisticmonth.FieldType:
  34701. v, ok := value.(int)
  34702. if !ok {
  34703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34704. }
  34705. m.AddType(v)
  34706. return nil
  34707. case usagestatisticmonth.FieldOrganizationID:
  34708. v, ok := value.(int64)
  34709. if !ok {
  34710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34711. }
  34712. m.AddOrganizationID(v)
  34713. return nil
  34714. case usagestatisticmonth.FieldAiResponse:
  34715. v, ok := value.(int64)
  34716. if !ok {
  34717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34718. }
  34719. m.AddAiResponse(v)
  34720. return nil
  34721. case usagestatisticmonth.FieldSopRun:
  34722. v, ok := value.(int64)
  34723. if !ok {
  34724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34725. }
  34726. m.AddSopRun(v)
  34727. return nil
  34728. case usagestatisticmonth.FieldTotalFriend:
  34729. v, ok := value.(int64)
  34730. if !ok {
  34731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34732. }
  34733. m.AddTotalFriend(v)
  34734. return nil
  34735. case usagestatisticmonth.FieldTotalGroup:
  34736. v, ok := value.(int64)
  34737. if !ok {
  34738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34739. }
  34740. m.AddTotalGroup(v)
  34741. return nil
  34742. case usagestatisticmonth.FieldAccountBalance:
  34743. v, ok := value.(int64)
  34744. if !ok {
  34745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34746. }
  34747. m.AddAccountBalance(v)
  34748. return nil
  34749. case usagestatisticmonth.FieldConsumeToken:
  34750. v, ok := value.(int64)
  34751. if !ok {
  34752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34753. }
  34754. m.AddConsumeToken(v)
  34755. return nil
  34756. case usagestatisticmonth.FieldActiveUser:
  34757. v, ok := value.(int64)
  34758. if !ok {
  34759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34760. }
  34761. m.AddActiveUser(v)
  34762. return nil
  34763. case usagestatisticmonth.FieldNewUser:
  34764. v, ok := value.(int64)
  34765. if !ok {
  34766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34767. }
  34768. m.AddNewUser(v)
  34769. return nil
  34770. }
  34771. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34772. }
  34773. // ClearedFields returns all nullable fields that were cleared during this
  34774. // mutation.
  34775. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34776. var fields []string
  34777. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34778. fields = append(fields, usagestatisticmonth.FieldStatus)
  34779. }
  34780. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34781. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34782. }
  34783. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34784. fields = append(fields, usagestatisticmonth.FieldBotID)
  34785. }
  34786. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34787. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34788. }
  34789. return fields
  34790. }
  34791. // FieldCleared returns a boolean indicating if a field with the given name was
  34792. // cleared in this mutation.
  34793. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34794. _, ok := m.clearedFields[name]
  34795. return ok
  34796. }
  34797. // ClearField clears the value of the field with the given name. It returns an
  34798. // error if the field is not defined in the schema.
  34799. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34800. switch name {
  34801. case usagestatisticmonth.FieldStatus:
  34802. m.ClearStatus()
  34803. return nil
  34804. case usagestatisticmonth.FieldDeletedAt:
  34805. m.ClearDeletedAt()
  34806. return nil
  34807. case usagestatisticmonth.FieldBotID:
  34808. m.ClearBotID()
  34809. return nil
  34810. case usagestatisticmonth.FieldOrganizationID:
  34811. m.ClearOrganizationID()
  34812. return nil
  34813. }
  34814. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34815. }
  34816. // ResetField resets all changes in the mutation for the field with the given name.
  34817. // It returns an error if the field is not defined in the schema.
  34818. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34819. switch name {
  34820. case usagestatisticmonth.FieldCreatedAt:
  34821. m.ResetCreatedAt()
  34822. return nil
  34823. case usagestatisticmonth.FieldUpdatedAt:
  34824. m.ResetUpdatedAt()
  34825. return nil
  34826. case usagestatisticmonth.FieldStatus:
  34827. m.ResetStatus()
  34828. return nil
  34829. case usagestatisticmonth.FieldDeletedAt:
  34830. m.ResetDeletedAt()
  34831. return nil
  34832. case usagestatisticmonth.FieldAddtime:
  34833. m.ResetAddtime()
  34834. return nil
  34835. case usagestatisticmonth.FieldType:
  34836. m.ResetType()
  34837. return nil
  34838. case usagestatisticmonth.FieldBotID:
  34839. m.ResetBotID()
  34840. return nil
  34841. case usagestatisticmonth.FieldOrganizationID:
  34842. m.ResetOrganizationID()
  34843. return nil
  34844. case usagestatisticmonth.FieldAiResponse:
  34845. m.ResetAiResponse()
  34846. return nil
  34847. case usagestatisticmonth.FieldSopRun:
  34848. m.ResetSopRun()
  34849. return nil
  34850. case usagestatisticmonth.FieldTotalFriend:
  34851. m.ResetTotalFriend()
  34852. return nil
  34853. case usagestatisticmonth.FieldTotalGroup:
  34854. m.ResetTotalGroup()
  34855. return nil
  34856. case usagestatisticmonth.FieldAccountBalance:
  34857. m.ResetAccountBalance()
  34858. return nil
  34859. case usagestatisticmonth.FieldConsumeToken:
  34860. m.ResetConsumeToken()
  34861. return nil
  34862. case usagestatisticmonth.FieldActiveUser:
  34863. m.ResetActiveUser()
  34864. return nil
  34865. case usagestatisticmonth.FieldNewUser:
  34866. m.ResetNewUser()
  34867. return nil
  34868. case usagestatisticmonth.FieldLabelDist:
  34869. m.ResetLabelDist()
  34870. return nil
  34871. }
  34872. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34873. }
  34874. // AddedEdges returns all edge names that were set/added in this mutation.
  34875. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  34876. edges := make([]string, 0, 0)
  34877. return edges
  34878. }
  34879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34880. // name in this mutation.
  34881. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  34882. return nil
  34883. }
  34884. // RemovedEdges returns all edge names that were removed in this mutation.
  34885. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  34886. edges := make([]string, 0, 0)
  34887. return edges
  34888. }
  34889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34890. // the given name in this mutation.
  34891. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  34892. return nil
  34893. }
  34894. // ClearedEdges returns all edge names that were cleared in this mutation.
  34895. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  34896. edges := make([]string, 0, 0)
  34897. return edges
  34898. }
  34899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34900. // was cleared in this mutation.
  34901. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  34902. return false
  34903. }
  34904. // ClearEdge clears the value of the edge with the given name. It returns an error
  34905. // if that edge is not defined in the schema.
  34906. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34907. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34908. }
  34909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34910. // It returns an error if the edge is not defined in the schema.
  34911. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34912. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34913. }
  34914. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34915. type UsageTotalMutation struct {
  34916. config
  34917. op Op
  34918. typ string
  34919. id *uint64
  34920. created_at *time.Time
  34921. updated_at *time.Time
  34922. status *uint8
  34923. addstatus *int8
  34924. _type *int
  34925. add_type *int
  34926. bot_id *string
  34927. total_tokens *uint64
  34928. addtotal_tokens *int64
  34929. start_index *uint64
  34930. addstart_index *int64
  34931. end_index *uint64
  34932. addend_index *int64
  34933. organization_id *uint64
  34934. addorganization_id *int64
  34935. clearedFields map[string]struct{}
  34936. done bool
  34937. oldValue func(context.Context) (*UsageTotal, error)
  34938. predicates []predicate.UsageTotal
  34939. }
  34940. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  34941. // usagetotalOption allows management of the mutation configuration using functional options.
  34942. type usagetotalOption func(*UsageTotalMutation)
  34943. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  34944. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  34945. m := &UsageTotalMutation{
  34946. config: c,
  34947. op: op,
  34948. typ: TypeUsageTotal,
  34949. clearedFields: make(map[string]struct{}),
  34950. }
  34951. for _, opt := range opts {
  34952. opt(m)
  34953. }
  34954. return m
  34955. }
  34956. // withUsageTotalID sets the ID field of the mutation.
  34957. func withUsageTotalID(id uint64) usagetotalOption {
  34958. return func(m *UsageTotalMutation) {
  34959. var (
  34960. err error
  34961. once sync.Once
  34962. value *UsageTotal
  34963. )
  34964. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  34965. once.Do(func() {
  34966. if m.done {
  34967. err = errors.New("querying old values post mutation is not allowed")
  34968. } else {
  34969. value, err = m.Client().UsageTotal.Get(ctx, id)
  34970. }
  34971. })
  34972. return value, err
  34973. }
  34974. m.id = &id
  34975. }
  34976. }
  34977. // withUsageTotal sets the old UsageTotal of the mutation.
  34978. func withUsageTotal(node *UsageTotal) usagetotalOption {
  34979. return func(m *UsageTotalMutation) {
  34980. m.oldValue = func(context.Context) (*UsageTotal, error) {
  34981. return node, nil
  34982. }
  34983. m.id = &node.ID
  34984. }
  34985. }
  34986. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34987. // executed in a transaction (ent.Tx), a transactional client is returned.
  34988. func (m UsageTotalMutation) Client() *Client {
  34989. client := &Client{config: m.config}
  34990. client.init()
  34991. return client
  34992. }
  34993. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34994. // it returns an error otherwise.
  34995. func (m UsageTotalMutation) Tx() (*Tx, error) {
  34996. if _, ok := m.driver.(*txDriver); !ok {
  34997. return nil, errors.New("ent: mutation is not running in a transaction")
  34998. }
  34999. tx := &Tx{config: m.config}
  35000. tx.init()
  35001. return tx, nil
  35002. }
  35003. // SetID sets the value of the id field. Note that this
  35004. // operation is only accepted on creation of UsageTotal entities.
  35005. func (m *UsageTotalMutation) SetID(id uint64) {
  35006. m.id = &id
  35007. }
  35008. // ID returns the ID value in the mutation. Note that the ID is only available
  35009. // if it was provided to the builder or after it was returned from the database.
  35010. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35011. if m.id == nil {
  35012. return
  35013. }
  35014. return *m.id, true
  35015. }
  35016. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35017. // That means, if the mutation is applied within a transaction with an isolation level such
  35018. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35019. // or updated by the mutation.
  35020. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35021. switch {
  35022. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35023. id, exists := m.ID()
  35024. if exists {
  35025. return []uint64{id}, nil
  35026. }
  35027. fallthrough
  35028. case m.op.Is(OpUpdate | OpDelete):
  35029. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35030. default:
  35031. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35032. }
  35033. }
  35034. // SetCreatedAt sets the "created_at" field.
  35035. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35036. m.created_at = &t
  35037. }
  35038. // CreatedAt returns the value of the "created_at" field in the mutation.
  35039. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35040. v := m.created_at
  35041. if v == nil {
  35042. return
  35043. }
  35044. return *v, true
  35045. }
  35046. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35047. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35049. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35050. if !m.op.Is(OpUpdateOne) {
  35051. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35052. }
  35053. if m.id == nil || m.oldValue == nil {
  35054. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35055. }
  35056. oldValue, err := m.oldValue(ctx)
  35057. if err != nil {
  35058. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35059. }
  35060. return oldValue.CreatedAt, nil
  35061. }
  35062. // ResetCreatedAt resets all changes to the "created_at" field.
  35063. func (m *UsageTotalMutation) ResetCreatedAt() {
  35064. m.created_at = nil
  35065. }
  35066. // SetUpdatedAt sets the "updated_at" field.
  35067. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35068. m.updated_at = &t
  35069. }
  35070. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35071. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35072. v := m.updated_at
  35073. if v == nil {
  35074. return
  35075. }
  35076. return *v, true
  35077. }
  35078. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35079. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35081. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35082. if !m.op.Is(OpUpdateOne) {
  35083. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35084. }
  35085. if m.id == nil || m.oldValue == nil {
  35086. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35087. }
  35088. oldValue, err := m.oldValue(ctx)
  35089. if err != nil {
  35090. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35091. }
  35092. return oldValue.UpdatedAt, nil
  35093. }
  35094. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35095. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35096. m.updated_at = nil
  35097. }
  35098. // SetStatus sets the "status" field.
  35099. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35100. m.status = &u
  35101. m.addstatus = nil
  35102. }
  35103. // Status returns the value of the "status" field in the mutation.
  35104. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35105. v := m.status
  35106. if v == nil {
  35107. return
  35108. }
  35109. return *v, true
  35110. }
  35111. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35112. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35114. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35115. if !m.op.Is(OpUpdateOne) {
  35116. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35117. }
  35118. if m.id == nil || m.oldValue == nil {
  35119. return v, errors.New("OldStatus requires an ID field in the mutation")
  35120. }
  35121. oldValue, err := m.oldValue(ctx)
  35122. if err != nil {
  35123. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35124. }
  35125. return oldValue.Status, nil
  35126. }
  35127. // AddStatus adds u to the "status" field.
  35128. func (m *UsageTotalMutation) AddStatus(u int8) {
  35129. if m.addstatus != nil {
  35130. *m.addstatus += u
  35131. } else {
  35132. m.addstatus = &u
  35133. }
  35134. }
  35135. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35136. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35137. v := m.addstatus
  35138. if v == nil {
  35139. return
  35140. }
  35141. return *v, true
  35142. }
  35143. // ClearStatus clears the value of the "status" field.
  35144. func (m *UsageTotalMutation) ClearStatus() {
  35145. m.status = nil
  35146. m.addstatus = nil
  35147. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35148. }
  35149. // StatusCleared returns if the "status" field was cleared in this mutation.
  35150. func (m *UsageTotalMutation) StatusCleared() bool {
  35151. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35152. return ok
  35153. }
  35154. // ResetStatus resets all changes to the "status" field.
  35155. func (m *UsageTotalMutation) ResetStatus() {
  35156. m.status = nil
  35157. m.addstatus = nil
  35158. delete(m.clearedFields, usagetotal.FieldStatus)
  35159. }
  35160. // SetType sets the "type" field.
  35161. func (m *UsageTotalMutation) SetType(i int) {
  35162. m._type = &i
  35163. m.add_type = nil
  35164. }
  35165. // GetType returns the value of the "type" field in the mutation.
  35166. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35167. v := m._type
  35168. if v == nil {
  35169. return
  35170. }
  35171. return *v, true
  35172. }
  35173. // OldType returns the old "type" field's value of the UsageTotal entity.
  35174. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35176. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35177. if !m.op.Is(OpUpdateOne) {
  35178. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35179. }
  35180. if m.id == nil || m.oldValue == nil {
  35181. return v, errors.New("OldType requires an ID field in the mutation")
  35182. }
  35183. oldValue, err := m.oldValue(ctx)
  35184. if err != nil {
  35185. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35186. }
  35187. return oldValue.Type, nil
  35188. }
  35189. // AddType adds i to the "type" field.
  35190. func (m *UsageTotalMutation) AddType(i int) {
  35191. if m.add_type != nil {
  35192. *m.add_type += i
  35193. } else {
  35194. m.add_type = &i
  35195. }
  35196. }
  35197. // AddedType returns the value that was added to the "type" field in this mutation.
  35198. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35199. v := m.add_type
  35200. if v == nil {
  35201. return
  35202. }
  35203. return *v, true
  35204. }
  35205. // ClearType clears the value of the "type" field.
  35206. func (m *UsageTotalMutation) ClearType() {
  35207. m._type = nil
  35208. m.add_type = nil
  35209. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35210. }
  35211. // TypeCleared returns if the "type" field was cleared in this mutation.
  35212. func (m *UsageTotalMutation) TypeCleared() bool {
  35213. _, ok := m.clearedFields[usagetotal.FieldType]
  35214. return ok
  35215. }
  35216. // ResetType resets all changes to the "type" field.
  35217. func (m *UsageTotalMutation) ResetType() {
  35218. m._type = nil
  35219. m.add_type = nil
  35220. delete(m.clearedFields, usagetotal.FieldType)
  35221. }
  35222. // SetBotID sets the "bot_id" field.
  35223. func (m *UsageTotalMutation) SetBotID(s string) {
  35224. m.bot_id = &s
  35225. }
  35226. // BotID returns the value of the "bot_id" field in the mutation.
  35227. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35228. v := m.bot_id
  35229. if v == nil {
  35230. return
  35231. }
  35232. return *v, true
  35233. }
  35234. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35235. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35237. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35238. if !m.op.Is(OpUpdateOne) {
  35239. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35240. }
  35241. if m.id == nil || m.oldValue == nil {
  35242. return v, errors.New("OldBotID requires an ID field in the mutation")
  35243. }
  35244. oldValue, err := m.oldValue(ctx)
  35245. if err != nil {
  35246. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35247. }
  35248. return oldValue.BotID, nil
  35249. }
  35250. // ResetBotID resets all changes to the "bot_id" field.
  35251. func (m *UsageTotalMutation) ResetBotID() {
  35252. m.bot_id = nil
  35253. }
  35254. // SetTotalTokens sets the "total_tokens" field.
  35255. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35256. m.total_tokens = &u
  35257. m.addtotal_tokens = nil
  35258. }
  35259. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35260. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35261. v := m.total_tokens
  35262. if v == nil {
  35263. return
  35264. }
  35265. return *v, true
  35266. }
  35267. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35268. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35270. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35271. if !m.op.Is(OpUpdateOne) {
  35272. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35273. }
  35274. if m.id == nil || m.oldValue == nil {
  35275. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35276. }
  35277. oldValue, err := m.oldValue(ctx)
  35278. if err != nil {
  35279. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35280. }
  35281. return oldValue.TotalTokens, nil
  35282. }
  35283. // AddTotalTokens adds u to the "total_tokens" field.
  35284. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35285. if m.addtotal_tokens != nil {
  35286. *m.addtotal_tokens += u
  35287. } else {
  35288. m.addtotal_tokens = &u
  35289. }
  35290. }
  35291. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35292. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35293. v := m.addtotal_tokens
  35294. if v == nil {
  35295. return
  35296. }
  35297. return *v, true
  35298. }
  35299. // ClearTotalTokens clears the value of the "total_tokens" field.
  35300. func (m *UsageTotalMutation) ClearTotalTokens() {
  35301. m.total_tokens = nil
  35302. m.addtotal_tokens = nil
  35303. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35304. }
  35305. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35306. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35307. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35308. return ok
  35309. }
  35310. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35311. func (m *UsageTotalMutation) ResetTotalTokens() {
  35312. m.total_tokens = nil
  35313. m.addtotal_tokens = nil
  35314. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35315. }
  35316. // SetStartIndex sets the "start_index" field.
  35317. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35318. m.start_index = &u
  35319. m.addstart_index = nil
  35320. }
  35321. // StartIndex returns the value of the "start_index" field in the mutation.
  35322. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35323. v := m.start_index
  35324. if v == nil {
  35325. return
  35326. }
  35327. return *v, true
  35328. }
  35329. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35330. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35332. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35333. if !m.op.Is(OpUpdateOne) {
  35334. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35335. }
  35336. if m.id == nil || m.oldValue == nil {
  35337. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35338. }
  35339. oldValue, err := m.oldValue(ctx)
  35340. if err != nil {
  35341. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35342. }
  35343. return oldValue.StartIndex, nil
  35344. }
  35345. // AddStartIndex adds u to the "start_index" field.
  35346. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35347. if m.addstart_index != nil {
  35348. *m.addstart_index += u
  35349. } else {
  35350. m.addstart_index = &u
  35351. }
  35352. }
  35353. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35354. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35355. v := m.addstart_index
  35356. if v == nil {
  35357. return
  35358. }
  35359. return *v, true
  35360. }
  35361. // ClearStartIndex clears the value of the "start_index" field.
  35362. func (m *UsageTotalMutation) ClearStartIndex() {
  35363. m.start_index = nil
  35364. m.addstart_index = nil
  35365. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35366. }
  35367. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35368. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35369. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35370. return ok
  35371. }
  35372. // ResetStartIndex resets all changes to the "start_index" field.
  35373. func (m *UsageTotalMutation) ResetStartIndex() {
  35374. m.start_index = nil
  35375. m.addstart_index = nil
  35376. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35377. }
  35378. // SetEndIndex sets the "end_index" field.
  35379. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35380. m.end_index = &u
  35381. m.addend_index = nil
  35382. }
  35383. // EndIndex returns the value of the "end_index" field in the mutation.
  35384. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35385. v := m.end_index
  35386. if v == nil {
  35387. return
  35388. }
  35389. return *v, true
  35390. }
  35391. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35392. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35394. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35395. if !m.op.Is(OpUpdateOne) {
  35396. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35397. }
  35398. if m.id == nil || m.oldValue == nil {
  35399. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35400. }
  35401. oldValue, err := m.oldValue(ctx)
  35402. if err != nil {
  35403. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35404. }
  35405. return oldValue.EndIndex, nil
  35406. }
  35407. // AddEndIndex adds u to the "end_index" field.
  35408. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35409. if m.addend_index != nil {
  35410. *m.addend_index += u
  35411. } else {
  35412. m.addend_index = &u
  35413. }
  35414. }
  35415. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35416. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35417. v := m.addend_index
  35418. if v == nil {
  35419. return
  35420. }
  35421. return *v, true
  35422. }
  35423. // ClearEndIndex clears the value of the "end_index" field.
  35424. func (m *UsageTotalMutation) ClearEndIndex() {
  35425. m.end_index = nil
  35426. m.addend_index = nil
  35427. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35428. }
  35429. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35430. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35431. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35432. return ok
  35433. }
  35434. // ResetEndIndex resets all changes to the "end_index" field.
  35435. func (m *UsageTotalMutation) ResetEndIndex() {
  35436. m.end_index = nil
  35437. m.addend_index = nil
  35438. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35439. }
  35440. // SetOrganizationID sets the "organization_id" field.
  35441. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35442. m.organization_id = &u
  35443. m.addorganization_id = nil
  35444. }
  35445. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35446. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35447. v := m.organization_id
  35448. if v == nil {
  35449. return
  35450. }
  35451. return *v, true
  35452. }
  35453. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35454. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35456. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35457. if !m.op.Is(OpUpdateOne) {
  35458. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35459. }
  35460. if m.id == nil || m.oldValue == nil {
  35461. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35462. }
  35463. oldValue, err := m.oldValue(ctx)
  35464. if err != nil {
  35465. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35466. }
  35467. return oldValue.OrganizationID, nil
  35468. }
  35469. // AddOrganizationID adds u to the "organization_id" field.
  35470. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35471. if m.addorganization_id != nil {
  35472. *m.addorganization_id += u
  35473. } else {
  35474. m.addorganization_id = &u
  35475. }
  35476. }
  35477. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35478. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35479. v := m.addorganization_id
  35480. if v == nil {
  35481. return
  35482. }
  35483. return *v, true
  35484. }
  35485. // ClearOrganizationID clears the value of the "organization_id" field.
  35486. func (m *UsageTotalMutation) ClearOrganizationID() {
  35487. m.organization_id = nil
  35488. m.addorganization_id = nil
  35489. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35490. }
  35491. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35492. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35493. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35494. return ok
  35495. }
  35496. // ResetOrganizationID resets all changes to the "organization_id" field.
  35497. func (m *UsageTotalMutation) ResetOrganizationID() {
  35498. m.organization_id = nil
  35499. m.addorganization_id = nil
  35500. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35501. }
  35502. // Where appends a list predicates to the UsageTotalMutation builder.
  35503. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35504. m.predicates = append(m.predicates, ps...)
  35505. }
  35506. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35507. // users can use type-assertion to append predicates that do not depend on any generated package.
  35508. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35509. p := make([]predicate.UsageTotal, len(ps))
  35510. for i := range ps {
  35511. p[i] = ps[i]
  35512. }
  35513. m.Where(p...)
  35514. }
  35515. // Op returns the operation name.
  35516. func (m *UsageTotalMutation) Op() Op {
  35517. return m.op
  35518. }
  35519. // SetOp allows setting the mutation operation.
  35520. func (m *UsageTotalMutation) SetOp(op Op) {
  35521. m.op = op
  35522. }
  35523. // Type returns the node type of this mutation (UsageTotal).
  35524. func (m *UsageTotalMutation) Type() string {
  35525. return m.typ
  35526. }
  35527. // Fields returns all fields that were changed during this mutation. Note that in
  35528. // order to get all numeric fields that were incremented/decremented, call
  35529. // AddedFields().
  35530. func (m *UsageTotalMutation) Fields() []string {
  35531. fields := make([]string, 0, 9)
  35532. if m.created_at != nil {
  35533. fields = append(fields, usagetotal.FieldCreatedAt)
  35534. }
  35535. if m.updated_at != nil {
  35536. fields = append(fields, usagetotal.FieldUpdatedAt)
  35537. }
  35538. if m.status != nil {
  35539. fields = append(fields, usagetotal.FieldStatus)
  35540. }
  35541. if m._type != nil {
  35542. fields = append(fields, usagetotal.FieldType)
  35543. }
  35544. if m.bot_id != nil {
  35545. fields = append(fields, usagetotal.FieldBotID)
  35546. }
  35547. if m.total_tokens != nil {
  35548. fields = append(fields, usagetotal.FieldTotalTokens)
  35549. }
  35550. if m.start_index != nil {
  35551. fields = append(fields, usagetotal.FieldStartIndex)
  35552. }
  35553. if m.end_index != nil {
  35554. fields = append(fields, usagetotal.FieldEndIndex)
  35555. }
  35556. if m.organization_id != nil {
  35557. fields = append(fields, usagetotal.FieldOrganizationID)
  35558. }
  35559. return fields
  35560. }
  35561. // Field returns the value of a field with the given name. The second boolean
  35562. // return value indicates that this field was not set, or was not defined in the
  35563. // schema.
  35564. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35565. switch name {
  35566. case usagetotal.FieldCreatedAt:
  35567. return m.CreatedAt()
  35568. case usagetotal.FieldUpdatedAt:
  35569. return m.UpdatedAt()
  35570. case usagetotal.FieldStatus:
  35571. return m.Status()
  35572. case usagetotal.FieldType:
  35573. return m.GetType()
  35574. case usagetotal.FieldBotID:
  35575. return m.BotID()
  35576. case usagetotal.FieldTotalTokens:
  35577. return m.TotalTokens()
  35578. case usagetotal.FieldStartIndex:
  35579. return m.StartIndex()
  35580. case usagetotal.FieldEndIndex:
  35581. return m.EndIndex()
  35582. case usagetotal.FieldOrganizationID:
  35583. return m.OrganizationID()
  35584. }
  35585. return nil, false
  35586. }
  35587. // OldField returns the old value of the field from the database. An error is
  35588. // returned if the mutation operation is not UpdateOne, or the query to the
  35589. // database failed.
  35590. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35591. switch name {
  35592. case usagetotal.FieldCreatedAt:
  35593. return m.OldCreatedAt(ctx)
  35594. case usagetotal.FieldUpdatedAt:
  35595. return m.OldUpdatedAt(ctx)
  35596. case usagetotal.FieldStatus:
  35597. return m.OldStatus(ctx)
  35598. case usagetotal.FieldType:
  35599. return m.OldType(ctx)
  35600. case usagetotal.FieldBotID:
  35601. return m.OldBotID(ctx)
  35602. case usagetotal.FieldTotalTokens:
  35603. return m.OldTotalTokens(ctx)
  35604. case usagetotal.FieldStartIndex:
  35605. return m.OldStartIndex(ctx)
  35606. case usagetotal.FieldEndIndex:
  35607. return m.OldEndIndex(ctx)
  35608. case usagetotal.FieldOrganizationID:
  35609. return m.OldOrganizationID(ctx)
  35610. }
  35611. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35612. }
  35613. // SetField sets the value of a field with the given name. It returns an error if
  35614. // the field is not defined in the schema, or if the type mismatched the field
  35615. // type.
  35616. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35617. switch name {
  35618. case usagetotal.FieldCreatedAt:
  35619. v, ok := value.(time.Time)
  35620. if !ok {
  35621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35622. }
  35623. m.SetCreatedAt(v)
  35624. return nil
  35625. case usagetotal.FieldUpdatedAt:
  35626. v, ok := value.(time.Time)
  35627. if !ok {
  35628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35629. }
  35630. m.SetUpdatedAt(v)
  35631. return nil
  35632. case usagetotal.FieldStatus:
  35633. v, ok := value.(uint8)
  35634. if !ok {
  35635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35636. }
  35637. m.SetStatus(v)
  35638. return nil
  35639. case usagetotal.FieldType:
  35640. v, ok := value.(int)
  35641. if !ok {
  35642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35643. }
  35644. m.SetType(v)
  35645. return nil
  35646. case usagetotal.FieldBotID:
  35647. v, ok := value.(string)
  35648. if !ok {
  35649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35650. }
  35651. m.SetBotID(v)
  35652. return nil
  35653. case usagetotal.FieldTotalTokens:
  35654. v, ok := value.(uint64)
  35655. if !ok {
  35656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35657. }
  35658. m.SetTotalTokens(v)
  35659. return nil
  35660. case usagetotal.FieldStartIndex:
  35661. v, ok := value.(uint64)
  35662. if !ok {
  35663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35664. }
  35665. m.SetStartIndex(v)
  35666. return nil
  35667. case usagetotal.FieldEndIndex:
  35668. v, ok := value.(uint64)
  35669. if !ok {
  35670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35671. }
  35672. m.SetEndIndex(v)
  35673. return nil
  35674. case usagetotal.FieldOrganizationID:
  35675. v, ok := value.(uint64)
  35676. if !ok {
  35677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35678. }
  35679. m.SetOrganizationID(v)
  35680. return nil
  35681. }
  35682. return fmt.Errorf("unknown UsageTotal field %s", name)
  35683. }
  35684. // AddedFields returns all numeric fields that were incremented/decremented during
  35685. // this mutation.
  35686. func (m *UsageTotalMutation) AddedFields() []string {
  35687. var fields []string
  35688. if m.addstatus != nil {
  35689. fields = append(fields, usagetotal.FieldStatus)
  35690. }
  35691. if m.add_type != nil {
  35692. fields = append(fields, usagetotal.FieldType)
  35693. }
  35694. if m.addtotal_tokens != nil {
  35695. fields = append(fields, usagetotal.FieldTotalTokens)
  35696. }
  35697. if m.addstart_index != nil {
  35698. fields = append(fields, usagetotal.FieldStartIndex)
  35699. }
  35700. if m.addend_index != nil {
  35701. fields = append(fields, usagetotal.FieldEndIndex)
  35702. }
  35703. if m.addorganization_id != nil {
  35704. fields = append(fields, usagetotal.FieldOrganizationID)
  35705. }
  35706. return fields
  35707. }
  35708. // AddedField returns the numeric value that was incremented/decremented on a field
  35709. // with the given name. The second boolean return value indicates that this field
  35710. // was not set, or was not defined in the schema.
  35711. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35712. switch name {
  35713. case usagetotal.FieldStatus:
  35714. return m.AddedStatus()
  35715. case usagetotal.FieldType:
  35716. return m.AddedType()
  35717. case usagetotal.FieldTotalTokens:
  35718. return m.AddedTotalTokens()
  35719. case usagetotal.FieldStartIndex:
  35720. return m.AddedStartIndex()
  35721. case usagetotal.FieldEndIndex:
  35722. return m.AddedEndIndex()
  35723. case usagetotal.FieldOrganizationID:
  35724. return m.AddedOrganizationID()
  35725. }
  35726. return nil, false
  35727. }
  35728. // AddField adds the value to the field with the given name. It returns an error if
  35729. // the field is not defined in the schema, or if the type mismatched the field
  35730. // type.
  35731. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35732. switch name {
  35733. case usagetotal.FieldStatus:
  35734. v, ok := value.(int8)
  35735. if !ok {
  35736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35737. }
  35738. m.AddStatus(v)
  35739. return nil
  35740. case usagetotal.FieldType:
  35741. v, ok := value.(int)
  35742. if !ok {
  35743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35744. }
  35745. m.AddType(v)
  35746. return nil
  35747. case usagetotal.FieldTotalTokens:
  35748. v, ok := value.(int64)
  35749. if !ok {
  35750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35751. }
  35752. m.AddTotalTokens(v)
  35753. return nil
  35754. case usagetotal.FieldStartIndex:
  35755. v, ok := value.(int64)
  35756. if !ok {
  35757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35758. }
  35759. m.AddStartIndex(v)
  35760. return nil
  35761. case usagetotal.FieldEndIndex:
  35762. v, ok := value.(int64)
  35763. if !ok {
  35764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35765. }
  35766. m.AddEndIndex(v)
  35767. return nil
  35768. case usagetotal.FieldOrganizationID:
  35769. v, ok := value.(int64)
  35770. if !ok {
  35771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35772. }
  35773. m.AddOrganizationID(v)
  35774. return nil
  35775. }
  35776. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35777. }
  35778. // ClearedFields returns all nullable fields that were cleared during this
  35779. // mutation.
  35780. func (m *UsageTotalMutation) ClearedFields() []string {
  35781. var fields []string
  35782. if m.FieldCleared(usagetotal.FieldStatus) {
  35783. fields = append(fields, usagetotal.FieldStatus)
  35784. }
  35785. if m.FieldCleared(usagetotal.FieldType) {
  35786. fields = append(fields, usagetotal.FieldType)
  35787. }
  35788. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35789. fields = append(fields, usagetotal.FieldTotalTokens)
  35790. }
  35791. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35792. fields = append(fields, usagetotal.FieldStartIndex)
  35793. }
  35794. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35795. fields = append(fields, usagetotal.FieldEndIndex)
  35796. }
  35797. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35798. fields = append(fields, usagetotal.FieldOrganizationID)
  35799. }
  35800. return fields
  35801. }
  35802. // FieldCleared returns a boolean indicating if a field with the given name was
  35803. // cleared in this mutation.
  35804. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35805. _, ok := m.clearedFields[name]
  35806. return ok
  35807. }
  35808. // ClearField clears the value of the field with the given name. It returns an
  35809. // error if the field is not defined in the schema.
  35810. func (m *UsageTotalMutation) ClearField(name string) error {
  35811. switch name {
  35812. case usagetotal.FieldStatus:
  35813. m.ClearStatus()
  35814. return nil
  35815. case usagetotal.FieldType:
  35816. m.ClearType()
  35817. return nil
  35818. case usagetotal.FieldTotalTokens:
  35819. m.ClearTotalTokens()
  35820. return nil
  35821. case usagetotal.FieldStartIndex:
  35822. m.ClearStartIndex()
  35823. return nil
  35824. case usagetotal.FieldEndIndex:
  35825. m.ClearEndIndex()
  35826. return nil
  35827. case usagetotal.FieldOrganizationID:
  35828. m.ClearOrganizationID()
  35829. return nil
  35830. }
  35831. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35832. }
  35833. // ResetField resets all changes in the mutation for the field with the given name.
  35834. // It returns an error if the field is not defined in the schema.
  35835. func (m *UsageTotalMutation) ResetField(name string) error {
  35836. switch name {
  35837. case usagetotal.FieldCreatedAt:
  35838. m.ResetCreatedAt()
  35839. return nil
  35840. case usagetotal.FieldUpdatedAt:
  35841. m.ResetUpdatedAt()
  35842. return nil
  35843. case usagetotal.FieldStatus:
  35844. m.ResetStatus()
  35845. return nil
  35846. case usagetotal.FieldType:
  35847. m.ResetType()
  35848. return nil
  35849. case usagetotal.FieldBotID:
  35850. m.ResetBotID()
  35851. return nil
  35852. case usagetotal.FieldTotalTokens:
  35853. m.ResetTotalTokens()
  35854. return nil
  35855. case usagetotal.FieldStartIndex:
  35856. m.ResetStartIndex()
  35857. return nil
  35858. case usagetotal.FieldEndIndex:
  35859. m.ResetEndIndex()
  35860. return nil
  35861. case usagetotal.FieldOrganizationID:
  35862. m.ResetOrganizationID()
  35863. return nil
  35864. }
  35865. return fmt.Errorf("unknown UsageTotal field %s", name)
  35866. }
  35867. // AddedEdges returns all edge names that were set/added in this mutation.
  35868. func (m *UsageTotalMutation) AddedEdges() []string {
  35869. edges := make([]string, 0, 0)
  35870. return edges
  35871. }
  35872. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35873. // name in this mutation.
  35874. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  35875. return nil
  35876. }
  35877. // RemovedEdges returns all edge names that were removed in this mutation.
  35878. func (m *UsageTotalMutation) RemovedEdges() []string {
  35879. edges := make([]string, 0, 0)
  35880. return edges
  35881. }
  35882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35883. // the given name in this mutation.
  35884. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  35885. return nil
  35886. }
  35887. // ClearedEdges returns all edge names that were cleared in this mutation.
  35888. func (m *UsageTotalMutation) ClearedEdges() []string {
  35889. edges := make([]string, 0, 0)
  35890. return edges
  35891. }
  35892. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35893. // was cleared in this mutation.
  35894. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  35895. return false
  35896. }
  35897. // ClearEdge clears the value of the edge with the given name. It returns an error
  35898. // if that edge is not defined in the schema.
  35899. func (m *UsageTotalMutation) ClearEdge(name string) error {
  35900. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  35901. }
  35902. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35903. // It returns an error if the edge is not defined in the schema.
  35904. func (m *UsageTotalMutation) ResetEdge(name string) error {
  35905. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35906. }
  35907. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35908. type WhatsappMutation struct {
  35909. config
  35910. op Op
  35911. typ string
  35912. id *uint64
  35913. created_at *time.Time
  35914. updated_at *time.Time
  35915. status *uint8
  35916. addstatus *int8
  35917. deleted_at *time.Time
  35918. wa_id *string
  35919. wa_name *string
  35920. callback *string
  35921. account *string
  35922. cc *string
  35923. phone *string
  35924. cc_phone *string
  35925. phone_name *string
  35926. phone_status *int8
  35927. addphone_status *int8
  35928. organization_id *uint64
  35929. addorganization_id *int64
  35930. api_base *string
  35931. api_key *string
  35932. allow_list *[]string
  35933. appendallow_list []string
  35934. group_allow_list *[]string
  35935. appendgroup_allow_list []string
  35936. block_list *[]string
  35937. appendblock_list []string
  35938. group_block_list *[]string
  35939. appendgroup_block_list []string
  35940. clearedFields map[string]struct{}
  35941. agent *uint64
  35942. clearedagent bool
  35943. done bool
  35944. oldValue func(context.Context) (*Whatsapp, error)
  35945. predicates []predicate.Whatsapp
  35946. }
  35947. var _ ent.Mutation = (*WhatsappMutation)(nil)
  35948. // whatsappOption allows management of the mutation configuration using functional options.
  35949. type whatsappOption func(*WhatsappMutation)
  35950. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  35951. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  35952. m := &WhatsappMutation{
  35953. config: c,
  35954. op: op,
  35955. typ: TypeWhatsapp,
  35956. clearedFields: make(map[string]struct{}),
  35957. }
  35958. for _, opt := range opts {
  35959. opt(m)
  35960. }
  35961. return m
  35962. }
  35963. // withWhatsappID sets the ID field of the mutation.
  35964. func withWhatsappID(id uint64) whatsappOption {
  35965. return func(m *WhatsappMutation) {
  35966. var (
  35967. err error
  35968. once sync.Once
  35969. value *Whatsapp
  35970. )
  35971. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  35972. once.Do(func() {
  35973. if m.done {
  35974. err = errors.New("querying old values post mutation is not allowed")
  35975. } else {
  35976. value, err = m.Client().Whatsapp.Get(ctx, id)
  35977. }
  35978. })
  35979. return value, err
  35980. }
  35981. m.id = &id
  35982. }
  35983. }
  35984. // withWhatsapp sets the old Whatsapp of the mutation.
  35985. func withWhatsapp(node *Whatsapp) whatsappOption {
  35986. return func(m *WhatsappMutation) {
  35987. m.oldValue = func(context.Context) (*Whatsapp, error) {
  35988. return node, nil
  35989. }
  35990. m.id = &node.ID
  35991. }
  35992. }
  35993. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35994. // executed in a transaction (ent.Tx), a transactional client is returned.
  35995. func (m WhatsappMutation) Client() *Client {
  35996. client := &Client{config: m.config}
  35997. client.init()
  35998. return client
  35999. }
  36000. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36001. // it returns an error otherwise.
  36002. func (m WhatsappMutation) Tx() (*Tx, error) {
  36003. if _, ok := m.driver.(*txDriver); !ok {
  36004. return nil, errors.New("ent: mutation is not running in a transaction")
  36005. }
  36006. tx := &Tx{config: m.config}
  36007. tx.init()
  36008. return tx, nil
  36009. }
  36010. // SetID sets the value of the id field. Note that this
  36011. // operation is only accepted on creation of Whatsapp entities.
  36012. func (m *WhatsappMutation) SetID(id uint64) {
  36013. m.id = &id
  36014. }
  36015. // ID returns the ID value in the mutation. Note that the ID is only available
  36016. // if it was provided to the builder or after it was returned from the database.
  36017. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36018. if m.id == nil {
  36019. return
  36020. }
  36021. return *m.id, true
  36022. }
  36023. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36024. // That means, if the mutation is applied within a transaction with an isolation level such
  36025. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36026. // or updated by the mutation.
  36027. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36028. switch {
  36029. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36030. id, exists := m.ID()
  36031. if exists {
  36032. return []uint64{id}, nil
  36033. }
  36034. fallthrough
  36035. case m.op.Is(OpUpdate | OpDelete):
  36036. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36037. default:
  36038. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36039. }
  36040. }
  36041. // SetCreatedAt sets the "created_at" field.
  36042. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36043. m.created_at = &t
  36044. }
  36045. // CreatedAt returns the value of the "created_at" field in the mutation.
  36046. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36047. v := m.created_at
  36048. if v == nil {
  36049. return
  36050. }
  36051. return *v, true
  36052. }
  36053. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36054. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36056. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36057. if !m.op.Is(OpUpdateOne) {
  36058. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36059. }
  36060. if m.id == nil || m.oldValue == nil {
  36061. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36062. }
  36063. oldValue, err := m.oldValue(ctx)
  36064. if err != nil {
  36065. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36066. }
  36067. return oldValue.CreatedAt, nil
  36068. }
  36069. // ResetCreatedAt resets all changes to the "created_at" field.
  36070. func (m *WhatsappMutation) ResetCreatedAt() {
  36071. m.created_at = nil
  36072. }
  36073. // SetUpdatedAt sets the "updated_at" field.
  36074. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36075. m.updated_at = &t
  36076. }
  36077. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36078. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36079. v := m.updated_at
  36080. if v == nil {
  36081. return
  36082. }
  36083. return *v, true
  36084. }
  36085. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36086. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36088. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36089. if !m.op.Is(OpUpdateOne) {
  36090. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36091. }
  36092. if m.id == nil || m.oldValue == nil {
  36093. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36094. }
  36095. oldValue, err := m.oldValue(ctx)
  36096. if err != nil {
  36097. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36098. }
  36099. return oldValue.UpdatedAt, nil
  36100. }
  36101. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36102. func (m *WhatsappMutation) ResetUpdatedAt() {
  36103. m.updated_at = nil
  36104. }
  36105. // SetStatus sets the "status" field.
  36106. func (m *WhatsappMutation) SetStatus(u uint8) {
  36107. m.status = &u
  36108. m.addstatus = nil
  36109. }
  36110. // Status returns the value of the "status" field in the mutation.
  36111. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36112. v := m.status
  36113. if v == nil {
  36114. return
  36115. }
  36116. return *v, true
  36117. }
  36118. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36119. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36121. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36122. if !m.op.Is(OpUpdateOne) {
  36123. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36124. }
  36125. if m.id == nil || m.oldValue == nil {
  36126. return v, errors.New("OldStatus requires an ID field in the mutation")
  36127. }
  36128. oldValue, err := m.oldValue(ctx)
  36129. if err != nil {
  36130. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36131. }
  36132. return oldValue.Status, nil
  36133. }
  36134. // AddStatus adds u to the "status" field.
  36135. func (m *WhatsappMutation) AddStatus(u int8) {
  36136. if m.addstatus != nil {
  36137. *m.addstatus += u
  36138. } else {
  36139. m.addstatus = &u
  36140. }
  36141. }
  36142. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36143. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36144. v := m.addstatus
  36145. if v == nil {
  36146. return
  36147. }
  36148. return *v, true
  36149. }
  36150. // ClearStatus clears the value of the "status" field.
  36151. func (m *WhatsappMutation) ClearStatus() {
  36152. m.status = nil
  36153. m.addstatus = nil
  36154. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36155. }
  36156. // StatusCleared returns if the "status" field was cleared in this mutation.
  36157. func (m *WhatsappMutation) StatusCleared() bool {
  36158. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36159. return ok
  36160. }
  36161. // ResetStatus resets all changes to the "status" field.
  36162. func (m *WhatsappMutation) ResetStatus() {
  36163. m.status = nil
  36164. m.addstatus = nil
  36165. delete(m.clearedFields, whatsapp.FieldStatus)
  36166. }
  36167. // SetDeletedAt sets the "deleted_at" field.
  36168. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36169. m.deleted_at = &t
  36170. }
  36171. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36172. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36173. v := m.deleted_at
  36174. if v == nil {
  36175. return
  36176. }
  36177. return *v, true
  36178. }
  36179. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36182. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36183. if !m.op.Is(OpUpdateOne) {
  36184. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36185. }
  36186. if m.id == nil || m.oldValue == nil {
  36187. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36188. }
  36189. oldValue, err := m.oldValue(ctx)
  36190. if err != nil {
  36191. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36192. }
  36193. return oldValue.DeletedAt, nil
  36194. }
  36195. // ClearDeletedAt clears the value of the "deleted_at" field.
  36196. func (m *WhatsappMutation) ClearDeletedAt() {
  36197. m.deleted_at = nil
  36198. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36199. }
  36200. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36201. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36202. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36203. return ok
  36204. }
  36205. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36206. func (m *WhatsappMutation) ResetDeletedAt() {
  36207. m.deleted_at = nil
  36208. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36209. }
  36210. // SetWaID sets the "wa_id" field.
  36211. func (m *WhatsappMutation) SetWaID(s string) {
  36212. m.wa_id = &s
  36213. }
  36214. // WaID returns the value of the "wa_id" field in the mutation.
  36215. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36216. v := m.wa_id
  36217. if v == nil {
  36218. return
  36219. }
  36220. return *v, true
  36221. }
  36222. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36223. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36225. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36226. if !m.op.Is(OpUpdateOne) {
  36227. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36228. }
  36229. if m.id == nil || m.oldValue == nil {
  36230. return v, errors.New("OldWaID requires an ID field in the mutation")
  36231. }
  36232. oldValue, err := m.oldValue(ctx)
  36233. if err != nil {
  36234. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36235. }
  36236. return oldValue.WaID, nil
  36237. }
  36238. // ClearWaID clears the value of the "wa_id" field.
  36239. func (m *WhatsappMutation) ClearWaID() {
  36240. m.wa_id = nil
  36241. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36242. }
  36243. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36244. func (m *WhatsappMutation) WaIDCleared() bool {
  36245. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36246. return ok
  36247. }
  36248. // ResetWaID resets all changes to the "wa_id" field.
  36249. func (m *WhatsappMutation) ResetWaID() {
  36250. m.wa_id = nil
  36251. delete(m.clearedFields, whatsapp.FieldWaID)
  36252. }
  36253. // SetWaName sets the "wa_name" field.
  36254. func (m *WhatsappMutation) SetWaName(s string) {
  36255. m.wa_name = &s
  36256. }
  36257. // WaName returns the value of the "wa_name" field in the mutation.
  36258. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36259. v := m.wa_name
  36260. if v == nil {
  36261. return
  36262. }
  36263. return *v, true
  36264. }
  36265. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36266. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36268. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36269. if !m.op.Is(OpUpdateOne) {
  36270. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36271. }
  36272. if m.id == nil || m.oldValue == nil {
  36273. return v, errors.New("OldWaName requires an ID field in the mutation")
  36274. }
  36275. oldValue, err := m.oldValue(ctx)
  36276. if err != nil {
  36277. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36278. }
  36279. return oldValue.WaName, nil
  36280. }
  36281. // ClearWaName clears the value of the "wa_name" field.
  36282. func (m *WhatsappMutation) ClearWaName() {
  36283. m.wa_name = nil
  36284. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36285. }
  36286. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36287. func (m *WhatsappMutation) WaNameCleared() bool {
  36288. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36289. return ok
  36290. }
  36291. // ResetWaName resets all changes to the "wa_name" field.
  36292. func (m *WhatsappMutation) ResetWaName() {
  36293. m.wa_name = nil
  36294. delete(m.clearedFields, whatsapp.FieldWaName)
  36295. }
  36296. // SetCallback sets the "callback" field.
  36297. func (m *WhatsappMutation) SetCallback(s string) {
  36298. m.callback = &s
  36299. }
  36300. // Callback returns the value of the "callback" field in the mutation.
  36301. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36302. v := m.callback
  36303. if v == nil {
  36304. return
  36305. }
  36306. return *v, true
  36307. }
  36308. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36309. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36311. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36312. if !m.op.Is(OpUpdateOne) {
  36313. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36314. }
  36315. if m.id == nil || m.oldValue == nil {
  36316. return v, errors.New("OldCallback requires an ID field in the mutation")
  36317. }
  36318. oldValue, err := m.oldValue(ctx)
  36319. if err != nil {
  36320. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36321. }
  36322. return oldValue.Callback, nil
  36323. }
  36324. // ClearCallback clears the value of the "callback" field.
  36325. func (m *WhatsappMutation) ClearCallback() {
  36326. m.callback = nil
  36327. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36328. }
  36329. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36330. func (m *WhatsappMutation) CallbackCleared() bool {
  36331. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36332. return ok
  36333. }
  36334. // ResetCallback resets all changes to the "callback" field.
  36335. func (m *WhatsappMutation) ResetCallback() {
  36336. m.callback = nil
  36337. delete(m.clearedFields, whatsapp.FieldCallback)
  36338. }
  36339. // SetAgentID sets the "agent_id" field.
  36340. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36341. m.agent = &u
  36342. }
  36343. // AgentID returns the value of the "agent_id" field in the mutation.
  36344. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36345. v := m.agent
  36346. if v == nil {
  36347. return
  36348. }
  36349. return *v, true
  36350. }
  36351. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36352. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36354. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36355. if !m.op.Is(OpUpdateOne) {
  36356. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36357. }
  36358. if m.id == nil || m.oldValue == nil {
  36359. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36360. }
  36361. oldValue, err := m.oldValue(ctx)
  36362. if err != nil {
  36363. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36364. }
  36365. return oldValue.AgentID, nil
  36366. }
  36367. // ResetAgentID resets all changes to the "agent_id" field.
  36368. func (m *WhatsappMutation) ResetAgentID() {
  36369. m.agent = nil
  36370. }
  36371. // SetAccount sets the "account" field.
  36372. func (m *WhatsappMutation) SetAccount(s string) {
  36373. m.account = &s
  36374. }
  36375. // Account returns the value of the "account" field in the mutation.
  36376. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36377. v := m.account
  36378. if v == nil {
  36379. return
  36380. }
  36381. return *v, true
  36382. }
  36383. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36384. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36386. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36387. if !m.op.Is(OpUpdateOne) {
  36388. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36389. }
  36390. if m.id == nil || m.oldValue == nil {
  36391. return v, errors.New("OldAccount requires an ID field in the mutation")
  36392. }
  36393. oldValue, err := m.oldValue(ctx)
  36394. if err != nil {
  36395. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36396. }
  36397. return oldValue.Account, nil
  36398. }
  36399. // ClearAccount clears the value of the "account" field.
  36400. func (m *WhatsappMutation) ClearAccount() {
  36401. m.account = nil
  36402. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36403. }
  36404. // AccountCleared returns if the "account" field was cleared in this mutation.
  36405. func (m *WhatsappMutation) AccountCleared() bool {
  36406. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36407. return ok
  36408. }
  36409. // ResetAccount resets all changes to the "account" field.
  36410. func (m *WhatsappMutation) ResetAccount() {
  36411. m.account = nil
  36412. delete(m.clearedFields, whatsapp.FieldAccount)
  36413. }
  36414. // SetCc sets the "cc" field.
  36415. func (m *WhatsappMutation) SetCc(s string) {
  36416. m.cc = &s
  36417. }
  36418. // Cc returns the value of the "cc" field in the mutation.
  36419. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36420. v := m.cc
  36421. if v == nil {
  36422. return
  36423. }
  36424. return *v, true
  36425. }
  36426. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36427. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36429. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36430. if !m.op.Is(OpUpdateOne) {
  36431. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36432. }
  36433. if m.id == nil || m.oldValue == nil {
  36434. return v, errors.New("OldCc requires an ID field in the mutation")
  36435. }
  36436. oldValue, err := m.oldValue(ctx)
  36437. if err != nil {
  36438. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36439. }
  36440. return oldValue.Cc, nil
  36441. }
  36442. // ResetCc resets all changes to the "cc" field.
  36443. func (m *WhatsappMutation) ResetCc() {
  36444. m.cc = nil
  36445. }
  36446. // SetPhone sets the "phone" field.
  36447. func (m *WhatsappMutation) SetPhone(s string) {
  36448. m.phone = &s
  36449. }
  36450. // Phone returns the value of the "phone" field in the mutation.
  36451. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36452. v := m.phone
  36453. if v == nil {
  36454. return
  36455. }
  36456. return *v, true
  36457. }
  36458. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36459. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36461. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36462. if !m.op.Is(OpUpdateOne) {
  36463. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36464. }
  36465. if m.id == nil || m.oldValue == nil {
  36466. return v, errors.New("OldPhone requires an ID field in the mutation")
  36467. }
  36468. oldValue, err := m.oldValue(ctx)
  36469. if err != nil {
  36470. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36471. }
  36472. return oldValue.Phone, nil
  36473. }
  36474. // ResetPhone resets all changes to the "phone" field.
  36475. func (m *WhatsappMutation) ResetPhone() {
  36476. m.phone = nil
  36477. }
  36478. // SetCcPhone sets the "cc_phone" field.
  36479. func (m *WhatsappMutation) SetCcPhone(s string) {
  36480. m.cc_phone = &s
  36481. }
  36482. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36483. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36484. v := m.cc_phone
  36485. if v == nil {
  36486. return
  36487. }
  36488. return *v, true
  36489. }
  36490. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36491. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36493. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36494. if !m.op.Is(OpUpdateOne) {
  36495. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36496. }
  36497. if m.id == nil || m.oldValue == nil {
  36498. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36499. }
  36500. oldValue, err := m.oldValue(ctx)
  36501. if err != nil {
  36502. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36503. }
  36504. return oldValue.CcPhone, nil
  36505. }
  36506. // ResetCcPhone resets all changes to the "cc_phone" field.
  36507. func (m *WhatsappMutation) ResetCcPhone() {
  36508. m.cc_phone = nil
  36509. }
  36510. // SetPhoneName sets the "phone_name" field.
  36511. func (m *WhatsappMutation) SetPhoneName(s string) {
  36512. m.phone_name = &s
  36513. }
  36514. // PhoneName returns the value of the "phone_name" field in the mutation.
  36515. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36516. v := m.phone_name
  36517. if v == nil {
  36518. return
  36519. }
  36520. return *v, true
  36521. }
  36522. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36523. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36525. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36526. if !m.op.Is(OpUpdateOne) {
  36527. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36528. }
  36529. if m.id == nil || m.oldValue == nil {
  36530. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36531. }
  36532. oldValue, err := m.oldValue(ctx)
  36533. if err != nil {
  36534. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36535. }
  36536. return oldValue.PhoneName, nil
  36537. }
  36538. // ResetPhoneName resets all changes to the "phone_name" field.
  36539. func (m *WhatsappMutation) ResetPhoneName() {
  36540. m.phone_name = nil
  36541. }
  36542. // SetPhoneStatus sets the "phone_status" field.
  36543. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36544. m.phone_status = &i
  36545. m.addphone_status = nil
  36546. }
  36547. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36548. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36549. v := m.phone_status
  36550. if v == nil {
  36551. return
  36552. }
  36553. return *v, true
  36554. }
  36555. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36556. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36558. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36559. if !m.op.Is(OpUpdateOne) {
  36560. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36561. }
  36562. if m.id == nil || m.oldValue == nil {
  36563. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36564. }
  36565. oldValue, err := m.oldValue(ctx)
  36566. if err != nil {
  36567. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36568. }
  36569. return oldValue.PhoneStatus, nil
  36570. }
  36571. // AddPhoneStatus adds i to the "phone_status" field.
  36572. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36573. if m.addphone_status != nil {
  36574. *m.addphone_status += i
  36575. } else {
  36576. m.addphone_status = &i
  36577. }
  36578. }
  36579. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36580. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36581. v := m.addphone_status
  36582. if v == nil {
  36583. return
  36584. }
  36585. return *v, true
  36586. }
  36587. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36588. func (m *WhatsappMutation) ResetPhoneStatus() {
  36589. m.phone_status = nil
  36590. m.addphone_status = nil
  36591. }
  36592. // SetOrganizationID sets the "organization_id" field.
  36593. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36594. m.organization_id = &u
  36595. m.addorganization_id = nil
  36596. }
  36597. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36598. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36599. v := m.organization_id
  36600. if v == nil {
  36601. return
  36602. }
  36603. return *v, true
  36604. }
  36605. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36606. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36608. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36609. if !m.op.Is(OpUpdateOne) {
  36610. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36611. }
  36612. if m.id == nil || m.oldValue == nil {
  36613. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36614. }
  36615. oldValue, err := m.oldValue(ctx)
  36616. if err != nil {
  36617. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36618. }
  36619. return oldValue.OrganizationID, nil
  36620. }
  36621. // AddOrganizationID adds u to the "organization_id" field.
  36622. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36623. if m.addorganization_id != nil {
  36624. *m.addorganization_id += u
  36625. } else {
  36626. m.addorganization_id = &u
  36627. }
  36628. }
  36629. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36630. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36631. v := m.addorganization_id
  36632. if v == nil {
  36633. return
  36634. }
  36635. return *v, true
  36636. }
  36637. // ClearOrganizationID clears the value of the "organization_id" field.
  36638. func (m *WhatsappMutation) ClearOrganizationID() {
  36639. m.organization_id = nil
  36640. m.addorganization_id = nil
  36641. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36642. }
  36643. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36644. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36645. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36646. return ok
  36647. }
  36648. // ResetOrganizationID resets all changes to the "organization_id" field.
  36649. func (m *WhatsappMutation) ResetOrganizationID() {
  36650. m.organization_id = nil
  36651. m.addorganization_id = nil
  36652. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36653. }
  36654. // SetAPIBase sets the "api_base" field.
  36655. func (m *WhatsappMutation) SetAPIBase(s string) {
  36656. m.api_base = &s
  36657. }
  36658. // APIBase returns the value of the "api_base" field in the mutation.
  36659. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36660. v := m.api_base
  36661. if v == nil {
  36662. return
  36663. }
  36664. return *v, true
  36665. }
  36666. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36667. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36669. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36670. if !m.op.Is(OpUpdateOne) {
  36671. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36672. }
  36673. if m.id == nil || m.oldValue == nil {
  36674. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36675. }
  36676. oldValue, err := m.oldValue(ctx)
  36677. if err != nil {
  36678. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36679. }
  36680. return oldValue.APIBase, nil
  36681. }
  36682. // ClearAPIBase clears the value of the "api_base" field.
  36683. func (m *WhatsappMutation) ClearAPIBase() {
  36684. m.api_base = nil
  36685. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36686. }
  36687. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36688. func (m *WhatsappMutation) APIBaseCleared() bool {
  36689. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36690. return ok
  36691. }
  36692. // ResetAPIBase resets all changes to the "api_base" field.
  36693. func (m *WhatsappMutation) ResetAPIBase() {
  36694. m.api_base = nil
  36695. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36696. }
  36697. // SetAPIKey sets the "api_key" field.
  36698. func (m *WhatsappMutation) SetAPIKey(s string) {
  36699. m.api_key = &s
  36700. }
  36701. // APIKey returns the value of the "api_key" field in the mutation.
  36702. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36703. v := m.api_key
  36704. if v == nil {
  36705. return
  36706. }
  36707. return *v, true
  36708. }
  36709. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36710. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36712. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36713. if !m.op.Is(OpUpdateOne) {
  36714. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36715. }
  36716. if m.id == nil || m.oldValue == nil {
  36717. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36718. }
  36719. oldValue, err := m.oldValue(ctx)
  36720. if err != nil {
  36721. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36722. }
  36723. return oldValue.APIKey, nil
  36724. }
  36725. // ClearAPIKey clears the value of the "api_key" field.
  36726. func (m *WhatsappMutation) ClearAPIKey() {
  36727. m.api_key = nil
  36728. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36729. }
  36730. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36731. func (m *WhatsappMutation) APIKeyCleared() bool {
  36732. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36733. return ok
  36734. }
  36735. // ResetAPIKey resets all changes to the "api_key" field.
  36736. func (m *WhatsappMutation) ResetAPIKey() {
  36737. m.api_key = nil
  36738. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36739. }
  36740. // SetAllowList sets the "allow_list" field.
  36741. func (m *WhatsappMutation) SetAllowList(s []string) {
  36742. m.allow_list = &s
  36743. m.appendallow_list = nil
  36744. }
  36745. // AllowList returns the value of the "allow_list" field in the mutation.
  36746. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36747. v := m.allow_list
  36748. if v == nil {
  36749. return
  36750. }
  36751. return *v, true
  36752. }
  36753. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36754. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36756. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36757. if !m.op.Is(OpUpdateOne) {
  36758. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36759. }
  36760. if m.id == nil || m.oldValue == nil {
  36761. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36762. }
  36763. oldValue, err := m.oldValue(ctx)
  36764. if err != nil {
  36765. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36766. }
  36767. return oldValue.AllowList, nil
  36768. }
  36769. // AppendAllowList adds s to the "allow_list" field.
  36770. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36771. m.appendallow_list = append(m.appendallow_list, s...)
  36772. }
  36773. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36774. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36775. if len(m.appendallow_list) == 0 {
  36776. return nil, false
  36777. }
  36778. return m.appendallow_list, true
  36779. }
  36780. // ClearAllowList clears the value of the "allow_list" field.
  36781. func (m *WhatsappMutation) ClearAllowList() {
  36782. m.allow_list = nil
  36783. m.appendallow_list = nil
  36784. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36785. }
  36786. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36787. func (m *WhatsappMutation) AllowListCleared() bool {
  36788. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36789. return ok
  36790. }
  36791. // ResetAllowList resets all changes to the "allow_list" field.
  36792. func (m *WhatsappMutation) ResetAllowList() {
  36793. m.allow_list = nil
  36794. m.appendallow_list = nil
  36795. delete(m.clearedFields, whatsapp.FieldAllowList)
  36796. }
  36797. // SetGroupAllowList sets the "group_allow_list" field.
  36798. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36799. m.group_allow_list = &s
  36800. m.appendgroup_allow_list = nil
  36801. }
  36802. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36803. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36804. v := m.group_allow_list
  36805. if v == nil {
  36806. return
  36807. }
  36808. return *v, true
  36809. }
  36810. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36811. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36813. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36814. if !m.op.Is(OpUpdateOne) {
  36815. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36816. }
  36817. if m.id == nil || m.oldValue == nil {
  36818. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36819. }
  36820. oldValue, err := m.oldValue(ctx)
  36821. if err != nil {
  36822. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36823. }
  36824. return oldValue.GroupAllowList, nil
  36825. }
  36826. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36827. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36828. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36829. }
  36830. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36831. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36832. if len(m.appendgroup_allow_list) == 0 {
  36833. return nil, false
  36834. }
  36835. return m.appendgroup_allow_list, true
  36836. }
  36837. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36838. func (m *WhatsappMutation) ClearGroupAllowList() {
  36839. m.group_allow_list = nil
  36840. m.appendgroup_allow_list = nil
  36841. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36842. }
  36843. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36844. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36845. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  36846. return ok
  36847. }
  36848. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36849. func (m *WhatsappMutation) ResetGroupAllowList() {
  36850. m.group_allow_list = nil
  36851. m.appendgroup_allow_list = nil
  36852. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  36853. }
  36854. // SetBlockList sets the "block_list" field.
  36855. func (m *WhatsappMutation) SetBlockList(s []string) {
  36856. m.block_list = &s
  36857. m.appendblock_list = nil
  36858. }
  36859. // BlockList returns the value of the "block_list" field in the mutation.
  36860. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  36861. v := m.block_list
  36862. if v == nil {
  36863. return
  36864. }
  36865. return *v, true
  36866. }
  36867. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  36868. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36870. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36871. if !m.op.Is(OpUpdateOne) {
  36872. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36873. }
  36874. if m.id == nil || m.oldValue == nil {
  36875. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36876. }
  36877. oldValue, err := m.oldValue(ctx)
  36878. if err != nil {
  36879. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36880. }
  36881. return oldValue.BlockList, nil
  36882. }
  36883. // AppendBlockList adds s to the "block_list" field.
  36884. func (m *WhatsappMutation) AppendBlockList(s []string) {
  36885. m.appendblock_list = append(m.appendblock_list, s...)
  36886. }
  36887. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36888. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  36889. if len(m.appendblock_list) == 0 {
  36890. return nil, false
  36891. }
  36892. return m.appendblock_list, true
  36893. }
  36894. // ClearBlockList clears the value of the "block_list" field.
  36895. func (m *WhatsappMutation) ClearBlockList() {
  36896. m.block_list = nil
  36897. m.appendblock_list = nil
  36898. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  36899. }
  36900. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  36901. func (m *WhatsappMutation) BlockListCleared() bool {
  36902. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  36903. return ok
  36904. }
  36905. // ResetBlockList resets all changes to the "block_list" field.
  36906. func (m *WhatsappMutation) ResetBlockList() {
  36907. m.block_list = nil
  36908. m.appendblock_list = nil
  36909. delete(m.clearedFields, whatsapp.FieldBlockList)
  36910. }
  36911. // SetGroupBlockList sets the "group_block_list" field.
  36912. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36913. m.group_block_list = &s
  36914. m.appendgroup_block_list = nil
  36915. }
  36916. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36917. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36918. v := m.group_block_list
  36919. if v == nil {
  36920. return
  36921. }
  36922. return *v, true
  36923. }
  36924. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  36925. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36927. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  36928. if !m.op.Is(OpUpdateOne) {
  36929. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  36930. }
  36931. if m.id == nil || m.oldValue == nil {
  36932. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  36933. }
  36934. oldValue, err := m.oldValue(ctx)
  36935. if err != nil {
  36936. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  36937. }
  36938. return oldValue.GroupBlockList, nil
  36939. }
  36940. // AppendGroupBlockList adds s to the "group_block_list" field.
  36941. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  36942. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  36943. }
  36944. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  36945. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  36946. if len(m.appendgroup_block_list) == 0 {
  36947. return nil, false
  36948. }
  36949. return m.appendgroup_block_list, true
  36950. }
  36951. // ClearGroupBlockList clears the value of the "group_block_list" field.
  36952. func (m *WhatsappMutation) ClearGroupBlockList() {
  36953. m.group_block_list = nil
  36954. m.appendgroup_block_list = nil
  36955. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  36956. }
  36957. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  36958. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  36959. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  36960. return ok
  36961. }
  36962. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  36963. func (m *WhatsappMutation) ResetGroupBlockList() {
  36964. m.group_block_list = nil
  36965. m.appendgroup_block_list = nil
  36966. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  36967. }
  36968. // ClearAgent clears the "agent" edge to the Agent entity.
  36969. func (m *WhatsappMutation) ClearAgent() {
  36970. m.clearedagent = true
  36971. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  36972. }
  36973. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  36974. func (m *WhatsappMutation) AgentCleared() bool {
  36975. return m.clearedagent
  36976. }
  36977. // AgentIDs returns the "agent" edge IDs in the mutation.
  36978. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36979. // AgentID instead. It exists only for internal usage by the builders.
  36980. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  36981. if id := m.agent; id != nil {
  36982. ids = append(ids, *id)
  36983. }
  36984. return
  36985. }
  36986. // ResetAgent resets all changes to the "agent" edge.
  36987. func (m *WhatsappMutation) ResetAgent() {
  36988. m.agent = nil
  36989. m.clearedagent = false
  36990. }
  36991. // Where appends a list predicates to the WhatsappMutation builder.
  36992. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  36993. m.predicates = append(m.predicates, ps...)
  36994. }
  36995. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  36996. // users can use type-assertion to append predicates that do not depend on any generated package.
  36997. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  36998. p := make([]predicate.Whatsapp, len(ps))
  36999. for i := range ps {
  37000. p[i] = ps[i]
  37001. }
  37002. m.Where(p...)
  37003. }
  37004. // Op returns the operation name.
  37005. func (m *WhatsappMutation) Op() Op {
  37006. return m.op
  37007. }
  37008. // SetOp allows setting the mutation operation.
  37009. func (m *WhatsappMutation) SetOp(op Op) {
  37010. m.op = op
  37011. }
  37012. // Type returns the node type of this mutation (Whatsapp).
  37013. func (m *WhatsappMutation) Type() string {
  37014. return m.typ
  37015. }
  37016. // Fields returns all fields that were changed during this mutation. Note that in
  37017. // order to get all numeric fields that were incremented/decremented, call
  37018. // AddedFields().
  37019. func (m *WhatsappMutation) Fields() []string {
  37020. fields := make([]string, 0, 21)
  37021. if m.created_at != nil {
  37022. fields = append(fields, whatsapp.FieldCreatedAt)
  37023. }
  37024. if m.updated_at != nil {
  37025. fields = append(fields, whatsapp.FieldUpdatedAt)
  37026. }
  37027. if m.status != nil {
  37028. fields = append(fields, whatsapp.FieldStatus)
  37029. }
  37030. if m.deleted_at != nil {
  37031. fields = append(fields, whatsapp.FieldDeletedAt)
  37032. }
  37033. if m.wa_id != nil {
  37034. fields = append(fields, whatsapp.FieldWaID)
  37035. }
  37036. if m.wa_name != nil {
  37037. fields = append(fields, whatsapp.FieldWaName)
  37038. }
  37039. if m.callback != nil {
  37040. fields = append(fields, whatsapp.FieldCallback)
  37041. }
  37042. if m.agent != nil {
  37043. fields = append(fields, whatsapp.FieldAgentID)
  37044. }
  37045. if m.account != nil {
  37046. fields = append(fields, whatsapp.FieldAccount)
  37047. }
  37048. if m.cc != nil {
  37049. fields = append(fields, whatsapp.FieldCc)
  37050. }
  37051. if m.phone != nil {
  37052. fields = append(fields, whatsapp.FieldPhone)
  37053. }
  37054. if m.cc_phone != nil {
  37055. fields = append(fields, whatsapp.FieldCcPhone)
  37056. }
  37057. if m.phone_name != nil {
  37058. fields = append(fields, whatsapp.FieldPhoneName)
  37059. }
  37060. if m.phone_status != nil {
  37061. fields = append(fields, whatsapp.FieldPhoneStatus)
  37062. }
  37063. if m.organization_id != nil {
  37064. fields = append(fields, whatsapp.FieldOrganizationID)
  37065. }
  37066. if m.api_base != nil {
  37067. fields = append(fields, whatsapp.FieldAPIBase)
  37068. }
  37069. if m.api_key != nil {
  37070. fields = append(fields, whatsapp.FieldAPIKey)
  37071. }
  37072. if m.allow_list != nil {
  37073. fields = append(fields, whatsapp.FieldAllowList)
  37074. }
  37075. if m.group_allow_list != nil {
  37076. fields = append(fields, whatsapp.FieldGroupAllowList)
  37077. }
  37078. if m.block_list != nil {
  37079. fields = append(fields, whatsapp.FieldBlockList)
  37080. }
  37081. if m.group_block_list != nil {
  37082. fields = append(fields, whatsapp.FieldGroupBlockList)
  37083. }
  37084. return fields
  37085. }
  37086. // Field returns the value of a field with the given name. The second boolean
  37087. // return value indicates that this field was not set, or was not defined in the
  37088. // schema.
  37089. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37090. switch name {
  37091. case whatsapp.FieldCreatedAt:
  37092. return m.CreatedAt()
  37093. case whatsapp.FieldUpdatedAt:
  37094. return m.UpdatedAt()
  37095. case whatsapp.FieldStatus:
  37096. return m.Status()
  37097. case whatsapp.FieldDeletedAt:
  37098. return m.DeletedAt()
  37099. case whatsapp.FieldWaID:
  37100. return m.WaID()
  37101. case whatsapp.FieldWaName:
  37102. return m.WaName()
  37103. case whatsapp.FieldCallback:
  37104. return m.Callback()
  37105. case whatsapp.FieldAgentID:
  37106. return m.AgentID()
  37107. case whatsapp.FieldAccount:
  37108. return m.Account()
  37109. case whatsapp.FieldCc:
  37110. return m.Cc()
  37111. case whatsapp.FieldPhone:
  37112. return m.Phone()
  37113. case whatsapp.FieldCcPhone:
  37114. return m.CcPhone()
  37115. case whatsapp.FieldPhoneName:
  37116. return m.PhoneName()
  37117. case whatsapp.FieldPhoneStatus:
  37118. return m.PhoneStatus()
  37119. case whatsapp.FieldOrganizationID:
  37120. return m.OrganizationID()
  37121. case whatsapp.FieldAPIBase:
  37122. return m.APIBase()
  37123. case whatsapp.FieldAPIKey:
  37124. return m.APIKey()
  37125. case whatsapp.FieldAllowList:
  37126. return m.AllowList()
  37127. case whatsapp.FieldGroupAllowList:
  37128. return m.GroupAllowList()
  37129. case whatsapp.FieldBlockList:
  37130. return m.BlockList()
  37131. case whatsapp.FieldGroupBlockList:
  37132. return m.GroupBlockList()
  37133. }
  37134. return nil, false
  37135. }
  37136. // OldField returns the old value of the field from the database. An error is
  37137. // returned if the mutation operation is not UpdateOne, or the query to the
  37138. // database failed.
  37139. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37140. switch name {
  37141. case whatsapp.FieldCreatedAt:
  37142. return m.OldCreatedAt(ctx)
  37143. case whatsapp.FieldUpdatedAt:
  37144. return m.OldUpdatedAt(ctx)
  37145. case whatsapp.FieldStatus:
  37146. return m.OldStatus(ctx)
  37147. case whatsapp.FieldDeletedAt:
  37148. return m.OldDeletedAt(ctx)
  37149. case whatsapp.FieldWaID:
  37150. return m.OldWaID(ctx)
  37151. case whatsapp.FieldWaName:
  37152. return m.OldWaName(ctx)
  37153. case whatsapp.FieldCallback:
  37154. return m.OldCallback(ctx)
  37155. case whatsapp.FieldAgentID:
  37156. return m.OldAgentID(ctx)
  37157. case whatsapp.FieldAccount:
  37158. return m.OldAccount(ctx)
  37159. case whatsapp.FieldCc:
  37160. return m.OldCc(ctx)
  37161. case whatsapp.FieldPhone:
  37162. return m.OldPhone(ctx)
  37163. case whatsapp.FieldCcPhone:
  37164. return m.OldCcPhone(ctx)
  37165. case whatsapp.FieldPhoneName:
  37166. return m.OldPhoneName(ctx)
  37167. case whatsapp.FieldPhoneStatus:
  37168. return m.OldPhoneStatus(ctx)
  37169. case whatsapp.FieldOrganizationID:
  37170. return m.OldOrganizationID(ctx)
  37171. case whatsapp.FieldAPIBase:
  37172. return m.OldAPIBase(ctx)
  37173. case whatsapp.FieldAPIKey:
  37174. return m.OldAPIKey(ctx)
  37175. case whatsapp.FieldAllowList:
  37176. return m.OldAllowList(ctx)
  37177. case whatsapp.FieldGroupAllowList:
  37178. return m.OldGroupAllowList(ctx)
  37179. case whatsapp.FieldBlockList:
  37180. return m.OldBlockList(ctx)
  37181. case whatsapp.FieldGroupBlockList:
  37182. return m.OldGroupBlockList(ctx)
  37183. }
  37184. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37185. }
  37186. // SetField sets the value of a field with the given name. It returns an error if
  37187. // the field is not defined in the schema, or if the type mismatched the field
  37188. // type.
  37189. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37190. switch name {
  37191. case whatsapp.FieldCreatedAt:
  37192. v, ok := value.(time.Time)
  37193. if !ok {
  37194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37195. }
  37196. m.SetCreatedAt(v)
  37197. return nil
  37198. case whatsapp.FieldUpdatedAt:
  37199. v, ok := value.(time.Time)
  37200. if !ok {
  37201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37202. }
  37203. m.SetUpdatedAt(v)
  37204. return nil
  37205. case whatsapp.FieldStatus:
  37206. v, ok := value.(uint8)
  37207. if !ok {
  37208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37209. }
  37210. m.SetStatus(v)
  37211. return nil
  37212. case whatsapp.FieldDeletedAt:
  37213. v, ok := value.(time.Time)
  37214. if !ok {
  37215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37216. }
  37217. m.SetDeletedAt(v)
  37218. return nil
  37219. case whatsapp.FieldWaID:
  37220. v, ok := value.(string)
  37221. if !ok {
  37222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37223. }
  37224. m.SetWaID(v)
  37225. return nil
  37226. case whatsapp.FieldWaName:
  37227. v, ok := value.(string)
  37228. if !ok {
  37229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37230. }
  37231. m.SetWaName(v)
  37232. return nil
  37233. case whatsapp.FieldCallback:
  37234. v, ok := value.(string)
  37235. if !ok {
  37236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37237. }
  37238. m.SetCallback(v)
  37239. return nil
  37240. case whatsapp.FieldAgentID:
  37241. v, ok := value.(uint64)
  37242. if !ok {
  37243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37244. }
  37245. m.SetAgentID(v)
  37246. return nil
  37247. case whatsapp.FieldAccount:
  37248. v, ok := value.(string)
  37249. if !ok {
  37250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37251. }
  37252. m.SetAccount(v)
  37253. return nil
  37254. case whatsapp.FieldCc:
  37255. v, ok := value.(string)
  37256. if !ok {
  37257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37258. }
  37259. m.SetCc(v)
  37260. return nil
  37261. case whatsapp.FieldPhone:
  37262. v, ok := value.(string)
  37263. if !ok {
  37264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37265. }
  37266. m.SetPhone(v)
  37267. return nil
  37268. case whatsapp.FieldCcPhone:
  37269. v, ok := value.(string)
  37270. if !ok {
  37271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37272. }
  37273. m.SetCcPhone(v)
  37274. return nil
  37275. case whatsapp.FieldPhoneName:
  37276. v, ok := value.(string)
  37277. if !ok {
  37278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37279. }
  37280. m.SetPhoneName(v)
  37281. return nil
  37282. case whatsapp.FieldPhoneStatus:
  37283. v, ok := value.(int8)
  37284. if !ok {
  37285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37286. }
  37287. m.SetPhoneStatus(v)
  37288. return nil
  37289. case whatsapp.FieldOrganizationID:
  37290. v, ok := value.(uint64)
  37291. if !ok {
  37292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37293. }
  37294. m.SetOrganizationID(v)
  37295. return nil
  37296. case whatsapp.FieldAPIBase:
  37297. v, ok := value.(string)
  37298. if !ok {
  37299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37300. }
  37301. m.SetAPIBase(v)
  37302. return nil
  37303. case whatsapp.FieldAPIKey:
  37304. v, ok := value.(string)
  37305. if !ok {
  37306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37307. }
  37308. m.SetAPIKey(v)
  37309. return nil
  37310. case whatsapp.FieldAllowList:
  37311. v, ok := value.([]string)
  37312. if !ok {
  37313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37314. }
  37315. m.SetAllowList(v)
  37316. return nil
  37317. case whatsapp.FieldGroupAllowList:
  37318. v, ok := value.([]string)
  37319. if !ok {
  37320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37321. }
  37322. m.SetGroupAllowList(v)
  37323. return nil
  37324. case whatsapp.FieldBlockList:
  37325. v, ok := value.([]string)
  37326. if !ok {
  37327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37328. }
  37329. m.SetBlockList(v)
  37330. return nil
  37331. case whatsapp.FieldGroupBlockList:
  37332. v, ok := value.([]string)
  37333. if !ok {
  37334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37335. }
  37336. m.SetGroupBlockList(v)
  37337. return nil
  37338. }
  37339. return fmt.Errorf("unknown Whatsapp field %s", name)
  37340. }
  37341. // AddedFields returns all numeric fields that were incremented/decremented during
  37342. // this mutation.
  37343. func (m *WhatsappMutation) AddedFields() []string {
  37344. var fields []string
  37345. if m.addstatus != nil {
  37346. fields = append(fields, whatsapp.FieldStatus)
  37347. }
  37348. if m.addphone_status != nil {
  37349. fields = append(fields, whatsapp.FieldPhoneStatus)
  37350. }
  37351. if m.addorganization_id != nil {
  37352. fields = append(fields, whatsapp.FieldOrganizationID)
  37353. }
  37354. return fields
  37355. }
  37356. // AddedField returns the numeric value that was incremented/decremented on a field
  37357. // with the given name. The second boolean return value indicates that this field
  37358. // was not set, or was not defined in the schema.
  37359. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37360. switch name {
  37361. case whatsapp.FieldStatus:
  37362. return m.AddedStatus()
  37363. case whatsapp.FieldPhoneStatus:
  37364. return m.AddedPhoneStatus()
  37365. case whatsapp.FieldOrganizationID:
  37366. return m.AddedOrganizationID()
  37367. }
  37368. return nil, false
  37369. }
  37370. // AddField adds the value to the field with the given name. It returns an error if
  37371. // the field is not defined in the schema, or if the type mismatched the field
  37372. // type.
  37373. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37374. switch name {
  37375. case whatsapp.FieldStatus:
  37376. v, ok := value.(int8)
  37377. if !ok {
  37378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37379. }
  37380. m.AddStatus(v)
  37381. return nil
  37382. case whatsapp.FieldPhoneStatus:
  37383. v, ok := value.(int8)
  37384. if !ok {
  37385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37386. }
  37387. m.AddPhoneStatus(v)
  37388. return nil
  37389. case whatsapp.FieldOrganizationID:
  37390. v, ok := value.(int64)
  37391. if !ok {
  37392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37393. }
  37394. m.AddOrganizationID(v)
  37395. return nil
  37396. }
  37397. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37398. }
  37399. // ClearedFields returns all nullable fields that were cleared during this
  37400. // mutation.
  37401. func (m *WhatsappMutation) ClearedFields() []string {
  37402. var fields []string
  37403. if m.FieldCleared(whatsapp.FieldStatus) {
  37404. fields = append(fields, whatsapp.FieldStatus)
  37405. }
  37406. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37407. fields = append(fields, whatsapp.FieldDeletedAt)
  37408. }
  37409. if m.FieldCleared(whatsapp.FieldWaID) {
  37410. fields = append(fields, whatsapp.FieldWaID)
  37411. }
  37412. if m.FieldCleared(whatsapp.FieldWaName) {
  37413. fields = append(fields, whatsapp.FieldWaName)
  37414. }
  37415. if m.FieldCleared(whatsapp.FieldCallback) {
  37416. fields = append(fields, whatsapp.FieldCallback)
  37417. }
  37418. if m.FieldCleared(whatsapp.FieldAccount) {
  37419. fields = append(fields, whatsapp.FieldAccount)
  37420. }
  37421. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37422. fields = append(fields, whatsapp.FieldOrganizationID)
  37423. }
  37424. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37425. fields = append(fields, whatsapp.FieldAPIBase)
  37426. }
  37427. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37428. fields = append(fields, whatsapp.FieldAPIKey)
  37429. }
  37430. if m.FieldCleared(whatsapp.FieldAllowList) {
  37431. fields = append(fields, whatsapp.FieldAllowList)
  37432. }
  37433. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37434. fields = append(fields, whatsapp.FieldGroupAllowList)
  37435. }
  37436. if m.FieldCleared(whatsapp.FieldBlockList) {
  37437. fields = append(fields, whatsapp.FieldBlockList)
  37438. }
  37439. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37440. fields = append(fields, whatsapp.FieldGroupBlockList)
  37441. }
  37442. return fields
  37443. }
  37444. // FieldCleared returns a boolean indicating if a field with the given name was
  37445. // cleared in this mutation.
  37446. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37447. _, ok := m.clearedFields[name]
  37448. return ok
  37449. }
  37450. // ClearField clears the value of the field with the given name. It returns an
  37451. // error if the field is not defined in the schema.
  37452. func (m *WhatsappMutation) ClearField(name string) error {
  37453. switch name {
  37454. case whatsapp.FieldStatus:
  37455. m.ClearStatus()
  37456. return nil
  37457. case whatsapp.FieldDeletedAt:
  37458. m.ClearDeletedAt()
  37459. return nil
  37460. case whatsapp.FieldWaID:
  37461. m.ClearWaID()
  37462. return nil
  37463. case whatsapp.FieldWaName:
  37464. m.ClearWaName()
  37465. return nil
  37466. case whatsapp.FieldCallback:
  37467. m.ClearCallback()
  37468. return nil
  37469. case whatsapp.FieldAccount:
  37470. m.ClearAccount()
  37471. return nil
  37472. case whatsapp.FieldOrganizationID:
  37473. m.ClearOrganizationID()
  37474. return nil
  37475. case whatsapp.FieldAPIBase:
  37476. m.ClearAPIBase()
  37477. return nil
  37478. case whatsapp.FieldAPIKey:
  37479. m.ClearAPIKey()
  37480. return nil
  37481. case whatsapp.FieldAllowList:
  37482. m.ClearAllowList()
  37483. return nil
  37484. case whatsapp.FieldGroupAllowList:
  37485. m.ClearGroupAllowList()
  37486. return nil
  37487. case whatsapp.FieldBlockList:
  37488. m.ClearBlockList()
  37489. return nil
  37490. case whatsapp.FieldGroupBlockList:
  37491. m.ClearGroupBlockList()
  37492. return nil
  37493. }
  37494. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37495. }
  37496. // ResetField resets all changes in the mutation for the field with the given name.
  37497. // It returns an error if the field is not defined in the schema.
  37498. func (m *WhatsappMutation) ResetField(name string) error {
  37499. switch name {
  37500. case whatsapp.FieldCreatedAt:
  37501. m.ResetCreatedAt()
  37502. return nil
  37503. case whatsapp.FieldUpdatedAt:
  37504. m.ResetUpdatedAt()
  37505. return nil
  37506. case whatsapp.FieldStatus:
  37507. m.ResetStatus()
  37508. return nil
  37509. case whatsapp.FieldDeletedAt:
  37510. m.ResetDeletedAt()
  37511. return nil
  37512. case whatsapp.FieldWaID:
  37513. m.ResetWaID()
  37514. return nil
  37515. case whatsapp.FieldWaName:
  37516. m.ResetWaName()
  37517. return nil
  37518. case whatsapp.FieldCallback:
  37519. m.ResetCallback()
  37520. return nil
  37521. case whatsapp.FieldAgentID:
  37522. m.ResetAgentID()
  37523. return nil
  37524. case whatsapp.FieldAccount:
  37525. m.ResetAccount()
  37526. return nil
  37527. case whatsapp.FieldCc:
  37528. m.ResetCc()
  37529. return nil
  37530. case whatsapp.FieldPhone:
  37531. m.ResetPhone()
  37532. return nil
  37533. case whatsapp.FieldCcPhone:
  37534. m.ResetCcPhone()
  37535. return nil
  37536. case whatsapp.FieldPhoneName:
  37537. m.ResetPhoneName()
  37538. return nil
  37539. case whatsapp.FieldPhoneStatus:
  37540. m.ResetPhoneStatus()
  37541. return nil
  37542. case whatsapp.FieldOrganizationID:
  37543. m.ResetOrganizationID()
  37544. return nil
  37545. case whatsapp.FieldAPIBase:
  37546. m.ResetAPIBase()
  37547. return nil
  37548. case whatsapp.FieldAPIKey:
  37549. m.ResetAPIKey()
  37550. return nil
  37551. case whatsapp.FieldAllowList:
  37552. m.ResetAllowList()
  37553. return nil
  37554. case whatsapp.FieldGroupAllowList:
  37555. m.ResetGroupAllowList()
  37556. return nil
  37557. case whatsapp.FieldBlockList:
  37558. m.ResetBlockList()
  37559. return nil
  37560. case whatsapp.FieldGroupBlockList:
  37561. m.ResetGroupBlockList()
  37562. return nil
  37563. }
  37564. return fmt.Errorf("unknown Whatsapp field %s", name)
  37565. }
  37566. // AddedEdges returns all edge names that were set/added in this mutation.
  37567. func (m *WhatsappMutation) AddedEdges() []string {
  37568. edges := make([]string, 0, 1)
  37569. if m.agent != nil {
  37570. edges = append(edges, whatsapp.EdgeAgent)
  37571. }
  37572. return edges
  37573. }
  37574. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37575. // name in this mutation.
  37576. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37577. switch name {
  37578. case whatsapp.EdgeAgent:
  37579. if id := m.agent; id != nil {
  37580. return []ent.Value{*id}
  37581. }
  37582. }
  37583. return nil
  37584. }
  37585. // RemovedEdges returns all edge names that were removed in this mutation.
  37586. func (m *WhatsappMutation) RemovedEdges() []string {
  37587. edges := make([]string, 0, 1)
  37588. return edges
  37589. }
  37590. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37591. // the given name in this mutation.
  37592. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37593. return nil
  37594. }
  37595. // ClearedEdges returns all edge names that were cleared in this mutation.
  37596. func (m *WhatsappMutation) ClearedEdges() []string {
  37597. edges := make([]string, 0, 1)
  37598. if m.clearedagent {
  37599. edges = append(edges, whatsapp.EdgeAgent)
  37600. }
  37601. return edges
  37602. }
  37603. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37604. // was cleared in this mutation.
  37605. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37606. switch name {
  37607. case whatsapp.EdgeAgent:
  37608. return m.clearedagent
  37609. }
  37610. return false
  37611. }
  37612. // ClearEdge clears the value of the edge with the given name. It returns an error
  37613. // if that edge is not defined in the schema.
  37614. func (m *WhatsappMutation) ClearEdge(name string) error {
  37615. switch name {
  37616. case whatsapp.EdgeAgent:
  37617. m.ClearAgent()
  37618. return nil
  37619. }
  37620. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37621. }
  37622. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37623. // It returns an error if the edge is not defined in the schema.
  37624. func (m *WhatsappMutation) ResetEdge(name string) error {
  37625. switch name {
  37626. case whatsapp.EdgeAgent:
  37627. m.ResetAgent()
  37628. return nil
  37629. }
  37630. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37631. }
  37632. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37633. type WhatsappChannelMutation struct {
  37634. config
  37635. op Op
  37636. typ string
  37637. id *uint64
  37638. created_at *time.Time
  37639. updated_at *time.Time
  37640. status *uint8
  37641. addstatus *int8
  37642. deleted_at *time.Time
  37643. ak *string
  37644. sk *string
  37645. wa_id *string
  37646. wa_name *string
  37647. waba_id *uint64
  37648. addwaba_id *int64
  37649. business_id *uint64
  37650. addbusiness_id *int64
  37651. organization_id *uint64
  37652. addorganization_id *int64
  37653. verify_account *string
  37654. clearedFields map[string]struct{}
  37655. done bool
  37656. oldValue func(context.Context) (*WhatsappChannel, error)
  37657. predicates []predicate.WhatsappChannel
  37658. }
  37659. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37660. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37661. type whatsappchannelOption func(*WhatsappChannelMutation)
  37662. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37663. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37664. m := &WhatsappChannelMutation{
  37665. config: c,
  37666. op: op,
  37667. typ: TypeWhatsappChannel,
  37668. clearedFields: make(map[string]struct{}),
  37669. }
  37670. for _, opt := range opts {
  37671. opt(m)
  37672. }
  37673. return m
  37674. }
  37675. // withWhatsappChannelID sets the ID field of the mutation.
  37676. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37677. return func(m *WhatsappChannelMutation) {
  37678. var (
  37679. err error
  37680. once sync.Once
  37681. value *WhatsappChannel
  37682. )
  37683. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37684. once.Do(func() {
  37685. if m.done {
  37686. err = errors.New("querying old values post mutation is not allowed")
  37687. } else {
  37688. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37689. }
  37690. })
  37691. return value, err
  37692. }
  37693. m.id = &id
  37694. }
  37695. }
  37696. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37697. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37698. return func(m *WhatsappChannelMutation) {
  37699. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37700. return node, nil
  37701. }
  37702. m.id = &node.ID
  37703. }
  37704. }
  37705. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37706. // executed in a transaction (ent.Tx), a transactional client is returned.
  37707. func (m WhatsappChannelMutation) Client() *Client {
  37708. client := &Client{config: m.config}
  37709. client.init()
  37710. return client
  37711. }
  37712. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37713. // it returns an error otherwise.
  37714. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37715. if _, ok := m.driver.(*txDriver); !ok {
  37716. return nil, errors.New("ent: mutation is not running in a transaction")
  37717. }
  37718. tx := &Tx{config: m.config}
  37719. tx.init()
  37720. return tx, nil
  37721. }
  37722. // SetID sets the value of the id field. Note that this
  37723. // operation is only accepted on creation of WhatsappChannel entities.
  37724. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37725. m.id = &id
  37726. }
  37727. // ID returns the ID value in the mutation. Note that the ID is only available
  37728. // if it was provided to the builder or after it was returned from the database.
  37729. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37730. if m.id == nil {
  37731. return
  37732. }
  37733. return *m.id, true
  37734. }
  37735. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37736. // That means, if the mutation is applied within a transaction with an isolation level such
  37737. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37738. // or updated by the mutation.
  37739. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37740. switch {
  37741. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37742. id, exists := m.ID()
  37743. if exists {
  37744. return []uint64{id}, nil
  37745. }
  37746. fallthrough
  37747. case m.op.Is(OpUpdate | OpDelete):
  37748. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37749. default:
  37750. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37751. }
  37752. }
  37753. // SetCreatedAt sets the "created_at" field.
  37754. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37755. m.created_at = &t
  37756. }
  37757. // CreatedAt returns the value of the "created_at" field in the mutation.
  37758. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37759. v := m.created_at
  37760. if v == nil {
  37761. return
  37762. }
  37763. return *v, true
  37764. }
  37765. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37766. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37768. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37769. if !m.op.Is(OpUpdateOne) {
  37770. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37771. }
  37772. if m.id == nil || m.oldValue == nil {
  37773. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37774. }
  37775. oldValue, err := m.oldValue(ctx)
  37776. if err != nil {
  37777. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37778. }
  37779. return oldValue.CreatedAt, nil
  37780. }
  37781. // ResetCreatedAt resets all changes to the "created_at" field.
  37782. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37783. m.created_at = nil
  37784. }
  37785. // SetUpdatedAt sets the "updated_at" field.
  37786. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37787. m.updated_at = &t
  37788. }
  37789. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37790. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37791. v := m.updated_at
  37792. if v == nil {
  37793. return
  37794. }
  37795. return *v, true
  37796. }
  37797. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37798. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37800. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37801. if !m.op.Is(OpUpdateOne) {
  37802. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37803. }
  37804. if m.id == nil || m.oldValue == nil {
  37805. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37806. }
  37807. oldValue, err := m.oldValue(ctx)
  37808. if err != nil {
  37809. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37810. }
  37811. return oldValue.UpdatedAt, nil
  37812. }
  37813. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37814. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37815. m.updated_at = nil
  37816. }
  37817. // SetStatus sets the "status" field.
  37818. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37819. m.status = &u
  37820. m.addstatus = nil
  37821. }
  37822. // Status returns the value of the "status" field in the mutation.
  37823. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37824. v := m.status
  37825. if v == nil {
  37826. return
  37827. }
  37828. return *v, true
  37829. }
  37830. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37831. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37833. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37834. if !m.op.Is(OpUpdateOne) {
  37835. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37836. }
  37837. if m.id == nil || m.oldValue == nil {
  37838. return v, errors.New("OldStatus requires an ID field in the mutation")
  37839. }
  37840. oldValue, err := m.oldValue(ctx)
  37841. if err != nil {
  37842. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37843. }
  37844. return oldValue.Status, nil
  37845. }
  37846. // AddStatus adds u to the "status" field.
  37847. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  37848. if m.addstatus != nil {
  37849. *m.addstatus += u
  37850. } else {
  37851. m.addstatus = &u
  37852. }
  37853. }
  37854. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37855. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  37856. v := m.addstatus
  37857. if v == nil {
  37858. return
  37859. }
  37860. return *v, true
  37861. }
  37862. // ClearStatus clears the value of the "status" field.
  37863. func (m *WhatsappChannelMutation) ClearStatus() {
  37864. m.status = nil
  37865. m.addstatus = nil
  37866. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  37867. }
  37868. // StatusCleared returns if the "status" field was cleared in this mutation.
  37869. func (m *WhatsappChannelMutation) StatusCleared() bool {
  37870. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  37871. return ok
  37872. }
  37873. // ResetStatus resets all changes to the "status" field.
  37874. func (m *WhatsappChannelMutation) ResetStatus() {
  37875. m.status = nil
  37876. m.addstatus = nil
  37877. delete(m.clearedFields, whatsappchannel.FieldStatus)
  37878. }
  37879. // SetDeletedAt sets the "deleted_at" field.
  37880. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  37881. m.deleted_at = &t
  37882. }
  37883. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37884. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  37885. v := m.deleted_at
  37886. if v == nil {
  37887. return
  37888. }
  37889. return *v, true
  37890. }
  37891. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  37892. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37894. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37895. if !m.op.Is(OpUpdateOne) {
  37896. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37897. }
  37898. if m.id == nil || m.oldValue == nil {
  37899. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37900. }
  37901. oldValue, err := m.oldValue(ctx)
  37902. if err != nil {
  37903. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37904. }
  37905. return oldValue.DeletedAt, nil
  37906. }
  37907. // ClearDeletedAt clears the value of the "deleted_at" field.
  37908. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37909. m.deleted_at = nil
  37910. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37911. }
  37912. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37913. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37914. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37915. return ok
  37916. }
  37917. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37918. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37919. m.deleted_at = nil
  37920. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37921. }
  37922. // SetAk sets the "ak" field.
  37923. func (m *WhatsappChannelMutation) SetAk(s string) {
  37924. m.ak = &s
  37925. }
  37926. // Ak returns the value of the "ak" field in the mutation.
  37927. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  37928. v := m.ak
  37929. if v == nil {
  37930. return
  37931. }
  37932. return *v, true
  37933. }
  37934. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  37935. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37937. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  37938. if !m.op.Is(OpUpdateOne) {
  37939. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  37940. }
  37941. if m.id == nil || m.oldValue == nil {
  37942. return v, errors.New("OldAk requires an ID field in the mutation")
  37943. }
  37944. oldValue, err := m.oldValue(ctx)
  37945. if err != nil {
  37946. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  37947. }
  37948. return oldValue.Ak, nil
  37949. }
  37950. // ClearAk clears the value of the "ak" field.
  37951. func (m *WhatsappChannelMutation) ClearAk() {
  37952. m.ak = nil
  37953. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  37954. }
  37955. // AkCleared returns if the "ak" field was cleared in this mutation.
  37956. func (m *WhatsappChannelMutation) AkCleared() bool {
  37957. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  37958. return ok
  37959. }
  37960. // ResetAk resets all changes to the "ak" field.
  37961. func (m *WhatsappChannelMutation) ResetAk() {
  37962. m.ak = nil
  37963. delete(m.clearedFields, whatsappchannel.FieldAk)
  37964. }
  37965. // SetSk sets the "sk" field.
  37966. func (m *WhatsappChannelMutation) SetSk(s string) {
  37967. m.sk = &s
  37968. }
  37969. // Sk returns the value of the "sk" field in the mutation.
  37970. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  37971. v := m.sk
  37972. if v == nil {
  37973. return
  37974. }
  37975. return *v, true
  37976. }
  37977. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  37978. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37980. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  37981. if !m.op.Is(OpUpdateOne) {
  37982. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  37983. }
  37984. if m.id == nil || m.oldValue == nil {
  37985. return v, errors.New("OldSk requires an ID field in the mutation")
  37986. }
  37987. oldValue, err := m.oldValue(ctx)
  37988. if err != nil {
  37989. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  37990. }
  37991. return oldValue.Sk, nil
  37992. }
  37993. // ResetSk resets all changes to the "sk" field.
  37994. func (m *WhatsappChannelMutation) ResetSk() {
  37995. m.sk = nil
  37996. }
  37997. // SetWaID sets the "wa_id" field.
  37998. func (m *WhatsappChannelMutation) SetWaID(s string) {
  37999. m.wa_id = &s
  38000. }
  38001. // WaID returns the value of the "wa_id" field in the mutation.
  38002. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38003. v := m.wa_id
  38004. if v == nil {
  38005. return
  38006. }
  38007. return *v, true
  38008. }
  38009. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38010. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38012. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38013. if !m.op.Is(OpUpdateOne) {
  38014. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38015. }
  38016. if m.id == nil || m.oldValue == nil {
  38017. return v, errors.New("OldWaID requires an ID field in the mutation")
  38018. }
  38019. oldValue, err := m.oldValue(ctx)
  38020. if err != nil {
  38021. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38022. }
  38023. return oldValue.WaID, nil
  38024. }
  38025. // ClearWaID clears the value of the "wa_id" field.
  38026. func (m *WhatsappChannelMutation) ClearWaID() {
  38027. m.wa_id = nil
  38028. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38029. }
  38030. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38031. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38032. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38033. return ok
  38034. }
  38035. // ResetWaID resets all changes to the "wa_id" field.
  38036. func (m *WhatsappChannelMutation) ResetWaID() {
  38037. m.wa_id = nil
  38038. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38039. }
  38040. // SetWaName sets the "wa_name" field.
  38041. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38042. m.wa_name = &s
  38043. }
  38044. // WaName returns the value of the "wa_name" field in the mutation.
  38045. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38046. v := m.wa_name
  38047. if v == nil {
  38048. return
  38049. }
  38050. return *v, true
  38051. }
  38052. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38053. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38055. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38056. if !m.op.Is(OpUpdateOne) {
  38057. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38058. }
  38059. if m.id == nil || m.oldValue == nil {
  38060. return v, errors.New("OldWaName requires an ID field in the mutation")
  38061. }
  38062. oldValue, err := m.oldValue(ctx)
  38063. if err != nil {
  38064. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38065. }
  38066. return oldValue.WaName, nil
  38067. }
  38068. // ClearWaName clears the value of the "wa_name" field.
  38069. func (m *WhatsappChannelMutation) ClearWaName() {
  38070. m.wa_name = nil
  38071. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38072. }
  38073. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38074. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38075. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38076. return ok
  38077. }
  38078. // ResetWaName resets all changes to the "wa_name" field.
  38079. func (m *WhatsappChannelMutation) ResetWaName() {
  38080. m.wa_name = nil
  38081. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38082. }
  38083. // SetWabaID sets the "waba_id" field.
  38084. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38085. m.waba_id = &u
  38086. m.addwaba_id = nil
  38087. }
  38088. // WabaID returns the value of the "waba_id" field in the mutation.
  38089. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38090. v := m.waba_id
  38091. if v == nil {
  38092. return
  38093. }
  38094. return *v, true
  38095. }
  38096. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38097. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38099. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38100. if !m.op.Is(OpUpdateOne) {
  38101. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38102. }
  38103. if m.id == nil || m.oldValue == nil {
  38104. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38105. }
  38106. oldValue, err := m.oldValue(ctx)
  38107. if err != nil {
  38108. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38109. }
  38110. return oldValue.WabaID, nil
  38111. }
  38112. // AddWabaID adds u to the "waba_id" field.
  38113. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38114. if m.addwaba_id != nil {
  38115. *m.addwaba_id += u
  38116. } else {
  38117. m.addwaba_id = &u
  38118. }
  38119. }
  38120. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38121. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38122. v := m.addwaba_id
  38123. if v == nil {
  38124. return
  38125. }
  38126. return *v, true
  38127. }
  38128. // ResetWabaID resets all changes to the "waba_id" field.
  38129. func (m *WhatsappChannelMutation) ResetWabaID() {
  38130. m.waba_id = nil
  38131. m.addwaba_id = nil
  38132. }
  38133. // SetBusinessID sets the "business_id" field.
  38134. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38135. m.business_id = &u
  38136. m.addbusiness_id = nil
  38137. }
  38138. // BusinessID returns the value of the "business_id" field in the mutation.
  38139. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38140. v := m.business_id
  38141. if v == nil {
  38142. return
  38143. }
  38144. return *v, true
  38145. }
  38146. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38147. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38149. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38150. if !m.op.Is(OpUpdateOne) {
  38151. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38152. }
  38153. if m.id == nil || m.oldValue == nil {
  38154. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38155. }
  38156. oldValue, err := m.oldValue(ctx)
  38157. if err != nil {
  38158. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38159. }
  38160. return oldValue.BusinessID, nil
  38161. }
  38162. // AddBusinessID adds u to the "business_id" field.
  38163. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38164. if m.addbusiness_id != nil {
  38165. *m.addbusiness_id += u
  38166. } else {
  38167. m.addbusiness_id = &u
  38168. }
  38169. }
  38170. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38171. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38172. v := m.addbusiness_id
  38173. if v == nil {
  38174. return
  38175. }
  38176. return *v, true
  38177. }
  38178. // ResetBusinessID resets all changes to the "business_id" field.
  38179. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38180. m.business_id = nil
  38181. m.addbusiness_id = nil
  38182. }
  38183. // SetOrganizationID sets the "organization_id" field.
  38184. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38185. m.organization_id = &u
  38186. m.addorganization_id = nil
  38187. }
  38188. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38189. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38190. v := m.organization_id
  38191. if v == nil {
  38192. return
  38193. }
  38194. return *v, true
  38195. }
  38196. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38197. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38199. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38200. if !m.op.Is(OpUpdateOne) {
  38201. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38202. }
  38203. if m.id == nil || m.oldValue == nil {
  38204. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38205. }
  38206. oldValue, err := m.oldValue(ctx)
  38207. if err != nil {
  38208. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38209. }
  38210. return oldValue.OrganizationID, nil
  38211. }
  38212. // AddOrganizationID adds u to the "organization_id" field.
  38213. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38214. if m.addorganization_id != nil {
  38215. *m.addorganization_id += u
  38216. } else {
  38217. m.addorganization_id = &u
  38218. }
  38219. }
  38220. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38221. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38222. v := m.addorganization_id
  38223. if v == nil {
  38224. return
  38225. }
  38226. return *v, true
  38227. }
  38228. // ClearOrganizationID clears the value of the "organization_id" field.
  38229. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38230. m.organization_id = nil
  38231. m.addorganization_id = nil
  38232. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38233. }
  38234. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38235. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38236. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38237. return ok
  38238. }
  38239. // ResetOrganizationID resets all changes to the "organization_id" field.
  38240. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38241. m.organization_id = nil
  38242. m.addorganization_id = nil
  38243. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38244. }
  38245. // SetVerifyAccount sets the "verify_account" field.
  38246. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38247. m.verify_account = &s
  38248. }
  38249. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38250. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38251. v := m.verify_account
  38252. if v == nil {
  38253. return
  38254. }
  38255. return *v, true
  38256. }
  38257. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38258. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38260. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38261. if !m.op.Is(OpUpdateOne) {
  38262. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38263. }
  38264. if m.id == nil || m.oldValue == nil {
  38265. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38266. }
  38267. oldValue, err := m.oldValue(ctx)
  38268. if err != nil {
  38269. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38270. }
  38271. return oldValue.VerifyAccount, nil
  38272. }
  38273. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38274. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38275. m.verify_account = nil
  38276. }
  38277. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38278. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38279. m.predicates = append(m.predicates, ps...)
  38280. }
  38281. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38282. // users can use type-assertion to append predicates that do not depend on any generated package.
  38283. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38284. p := make([]predicate.WhatsappChannel, len(ps))
  38285. for i := range ps {
  38286. p[i] = ps[i]
  38287. }
  38288. m.Where(p...)
  38289. }
  38290. // Op returns the operation name.
  38291. func (m *WhatsappChannelMutation) Op() Op {
  38292. return m.op
  38293. }
  38294. // SetOp allows setting the mutation operation.
  38295. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38296. m.op = op
  38297. }
  38298. // Type returns the node type of this mutation (WhatsappChannel).
  38299. func (m *WhatsappChannelMutation) Type() string {
  38300. return m.typ
  38301. }
  38302. // Fields returns all fields that were changed during this mutation. Note that in
  38303. // order to get all numeric fields that were incremented/decremented, call
  38304. // AddedFields().
  38305. func (m *WhatsappChannelMutation) Fields() []string {
  38306. fields := make([]string, 0, 12)
  38307. if m.created_at != nil {
  38308. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38309. }
  38310. if m.updated_at != nil {
  38311. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38312. }
  38313. if m.status != nil {
  38314. fields = append(fields, whatsappchannel.FieldStatus)
  38315. }
  38316. if m.deleted_at != nil {
  38317. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38318. }
  38319. if m.ak != nil {
  38320. fields = append(fields, whatsappchannel.FieldAk)
  38321. }
  38322. if m.sk != nil {
  38323. fields = append(fields, whatsappchannel.FieldSk)
  38324. }
  38325. if m.wa_id != nil {
  38326. fields = append(fields, whatsappchannel.FieldWaID)
  38327. }
  38328. if m.wa_name != nil {
  38329. fields = append(fields, whatsappchannel.FieldWaName)
  38330. }
  38331. if m.waba_id != nil {
  38332. fields = append(fields, whatsappchannel.FieldWabaID)
  38333. }
  38334. if m.business_id != nil {
  38335. fields = append(fields, whatsappchannel.FieldBusinessID)
  38336. }
  38337. if m.organization_id != nil {
  38338. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38339. }
  38340. if m.verify_account != nil {
  38341. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38342. }
  38343. return fields
  38344. }
  38345. // Field returns the value of a field with the given name. The second boolean
  38346. // return value indicates that this field was not set, or was not defined in the
  38347. // schema.
  38348. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38349. switch name {
  38350. case whatsappchannel.FieldCreatedAt:
  38351. return m.CreatedAt()
  38352. case whatsappchannel.FieldUpdatedAt:
  38353. return m.UpdatedAt()
  38354. case whatsappchannel.FieldStatus:
  38355. return m.Status()
  38356. case whatsappchannel.FieldDeletedAt:
  38357. return m.DeletedAt()
  38358. case whatsappchannel.FieldAk:
  38359. return m.Ak()
  38360. case whatsappchannel.FieldSk:
  38361. return m.Sk()
  38362. case whatsappchannel.FieldWaID:
  38363. return m.WaID()
  38364. case whatsappchannel.FieldWaName:
  38365. return m.WaName()
  38366. case whatsappchannel.FieldWabaID:
  38367. return m.WabaID()
  38368. case whatsappchannel.FieldBusinessID:
  38369. return m.BusinessID()
  38370. case whatsappchannel.FieldOrganizationID:
  38371. return m.OrganizationID()
  38372. case whatsappchannel.FieldVerifyAccount:
  38373. return m.VerifyAccount()
  38374. }
  38375. return nil, false
  38376. }
  38377. // OldField returns the old value of the field from the database. An error is
  38378. // returned if the mutation operation is not UpdateOne, or the query to the
  38379. // database failed.
  38380. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38381. switch name {
  38382. case whatsappchannel.FieldCreatedAt:
  38383. return m.OldCreatedAt(ctx)
  38384. case whatsappchannel.FieldUpdatedAt:
  38385. return m.OldUpdatedAt(ctx)
  38386. case whatsappchannel.FieldStatus:
  38387. return m.OldStatus(ctx)
  38388. case whatsappchannel.FieldDeletedAt:
  38389. return m.OldDeletedAt(ctx)
  38390. case whatsappchannel.FieldAk:
  38391. return m.OldAk(ctx)
  38392. case whatsappchannel.FieldSk:
  38393. return m.OldSk(ctx)
  38394. case whatsappchannel.FieldWaID:
  38395. return m.OldWaID(ctx)
  38396. case whatsappchannel.FieldWaName:
  38397. return m.OldWaName(ctx)
  38398. case whatsappchannel.FieldWabaID:
  38399. return m.OldWabaID(ctx)
  38400. case whatsappchannel.FieldBusinessID:
  38401. return m.OldBusinessID(ctx)
  38402. case whatsappchannel.FieldOrganizationID:
  38403. return m.OldOrganizationID(ctx)
  38404. case whatsappchannel.FieldVerifyAccount:
  38405. return m.OldVerifyAccount(ctx)
  38406. }
  38407. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38408. }
  38409. // SetField sets the value of a field with the given name. It returns an error if
  38410. // the field is not defined in the schema, or if the type mismatched the field
  38411. // type.
  38412. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38413. switch name {
  38414. case whatsappchannel.FieldCreatedAt:
  38415. v, ok := value.(time.Time)
  38416. if !ok {
  38417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38418. }
  38419. m.SetCreatedAt(v)
  38420. return nil
  38421. case whatsappchannel.FieldUpdatedAt:
  38422. v, ok := value.(time.Time)
  38423. if !ok {
  38424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38425. }
  38426. m.SetUpdatedAt(v)
  38427. return nil
  38428. case whatsappchannel.FieldStatus:
  38429. v, ok := value.(uint8)
  38430. if !ok {
  38431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38432. }
  38433. m.SetStatus(v)
  38434. return nil
  38435. case whatsappchannel.FieldDeletedAt:
  38436. v, ok := value.(time.Time)
  38437. if !ok {
  38438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38439. }
  38440. m.SetDeletedAt(v)
  38441. return nil
  38442. case whatsappchannel.FieldAk:
  38443. v, ok := value.(string)
  38444. if !ok {
  38445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38446. }
  38447. m.SetAk(v)
  38448. return nil
  38449. case whatsappchannel.FieldSk:
  38450. v, ok := value.(string)
  38451. if !ok {
  38452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38453. }
  38454. m.SetSk(v)
  38455. return nil
  38456. case whatsappchannel.FieldWaID:
  38457. v, ok := value.(string)
  38458. if !ok {
  38459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38460. }
  38461. m.SetWaID(v)
  38462. return nil
  38463. case whatsappchannel.FieldWaName:
  38464. v, ok := value.(string)
  38465. if !ok {
  38466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38467. }
  38468. m.SetWaName(v)
  38469. return nil
  38470. case whatsappchannel.FieldWabaID:
  38471. v, ok := value.(uint64)
  38472. if !ok {
  38473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38474. }
  38475. m.SetWabaID(v)
  38476. return nil
  38477. case whatsappchannel.FieldBusinessID:
  38478. v, ok := value.(uint64)
  38479. if !ok {
  38480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38481. }
  38482. m.SetBusinessID(v)
  38483. return nil
  38484. case whatsappchannel.FieldOrganizationID:
  38485. v, ok := value.(uint64)
  38486. if !ok {
  38487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38488. }
  38489. m.SetOrganizationID(v)
  38490. return nil
  38491. case whatsappchannel.FieldVerifyAccount:
  38492. v, ok := value.(string)
  38493. if !ok {
  38494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38495. }
  38496. m.SetVerifyAccount(v)
  38497. return nil
  38498. }
  38499. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38500. }
  38501. // AddedFields returns all numeric fields that were incremented/decremented during
  38502. // this mutation.
  38503. func (m *WhatsappChannelMutation) AddedFields() []string {
  38504. var fields []string
  38505. if m.addstatus != nil {
  38506. fields = append(fields, whatsappchannel.FieldStatus)
  38507. }
  38508. if m.addwaba_id != nil {
  38509. fields = append(fields, whatsappchannel.FieldWabaID)
  38510. }
  38511. if m.addbusiness_id != nil {
  38512. fields = append(fields, whatsappchannel.FieldBusinessID)
  38513. }
  38514. if m.addorganization_id != nil {
  38515. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38516. }
  38517. return fields
  38518. }
  38519. // AddedField returns the numeric value that was incremented/decremented on a field
  38520. // with the given name. The second boolean return value indicates that this field
  38521. // was not set, or was not defined in the schema.
  38522. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38523. switch name {
  38524. case whatsappchannel.FieldStatus:
  38525. return m.AddedStatus()
  38526. case whatsappchannel.FieldWabaID:
  38527. return m.AddedWabaID()
  38528. case whatsappchannel.FieldBusinessID:
  38529. return m.AddedBusinessID()
  38530. case whatsappchannel.FieldOrganizationID:
  38531. return m.AddedOrganizationID()
  38532. }
  38533. return nil, false
  38534. }
  38535. // AddField adds the value to the field with the given name. It returns an error if
  38536. // the field is not defined in the schema, or if the type mismatched the field
  38537. // type.
  38538. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38539. switch name {
  38540. case whatsappchannel.FieldStatus:
  38541. v, ok := value.(int8)
  38542. if !ok {
  38543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38544. }
  38545. m.AddStatus(v)
  38546. return nil
  38547. case whatsappchannel.FieldWabaID:
  38548. v, ok := value.(int64)
  38549. if !ok {
  38550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38551. }
  38552. m.AddWabaID(v)
  38553. return nil
  38554. case whatsappchannel.FieldBusinessID:
  38555. v, ok := value.(int64)
  38556. if !ok {
  38557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38558. }
  38559. m.AddBusinessID(v)
  38560. return nil
  38561. case whatsappchannel.FieldOrganizationID:
  38562. v, ok := value.(int64)
  38563. if !ok {
  38564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38565. }
  38566. m.AddOrganizationID(v)
  38567. return nil
  38568. }
  38569. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38570. }
  38571. // ClearedFields returns all nullable fields that were cleared during this
  38572. // mutation.
  38573. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38574. var fields []string
  38575. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38576. fields = append(fields, whatsappchannel.FieldStatus)
  38577. }
  38578. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38579. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38580. }
  38581. if m.FieldCleared(whatsappchannel.FieldAk) {
  38582. fields = append(fields, whatsappchannel.FieldAk)
  38583. }
  38584. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38585. fields = append(fields, whatsappchannel.FieldWaID)
  38586. }
  38587. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38588. fields = append(fields, whatsappchannel.FieldWaName)
  38589. }
  38590. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38591. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38592. }
  38593. return fields
  38594. }
  38595. // FieldCleared returns a boolean indicating if a field with the given name was
  38596. // cleared in this mutation.
  38597. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38598. _, ok := m.clearedFields[name]
  38599. return ok
  38600. }
  38601. // ClearField clears the value of the field with the given name. It returns an
  38602. // error if the field is not defined in the schema.
  38603. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38604. switch name {
  38605. case whatsappchannel.FieldStatus:
  38606. m.ClearStatus()
  38607. return nil
  38608. case whatsappchannel.FieldDeletedAt:
  38609. m.ClearDeletedAt()
  38610. return nil
  38611. case whatsappchannel.FieldAk:
  38612. m.ClearAk()
  38613. return nil
  38614. case whatsappchannel.FieldWaID:
  38615. m.ClearWaID()
  38616. return nil
  38617. case whatsappchannel.FieldWaName:
  38618. m.ClearWaName()
  38619. return nil
  38620. case whatsappchannel.FieldOrganizationID:
  38621. m.ClearOrganizationID()
  38622. return nil
  38623. }
  38624. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38625. }
  38626. // ResetField resets all changes in the mutation for the field with the given name.
  38627. // It returns an error if the field is not defined in the schema.
  38628. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38629. switch name {
  38630. case whatsappchannel.FieldCreatedAt:
  38631. m.ResetCreatedAt()
  38632. return nil
  38633. case whatsappchannel.FieldUpdatedAt:
  38634. m.ResetUpdatedAt()
  38635. return nil
  38636. case whatsappchannel.FieldStatus:
  38637. m.ResetStatus()
  38638. return nil
  38639. case whatsappchannel.FieldDeletedAt:
  38640. m.ResetDeletedAt()
  38641. return nil
  38642. case whatsappchannel.FieldAk:
  38643. m.ResetAk()
  38644. return nil
  38645. case whatsappchannel.FieldSk:
  38646. m.ResetSk()
  38647. return nil
  38648. case whatsappchannel.FieldWaID:
  38649. m.ResetWaID()
  38650. return nil
  38651. case whatsappchannel.FieldWaName:
  38652. m.ResetWaName()
  38653. return nil
  38654. case whatsappchannel.FieldWabaID:
  38655. m.ResetWabaID()
  38656. return nil
  38657. case whatsappchannel.FieldBusinessID:
  38658. m.ResetBusinessID()
  38659. return nil
  38660. case whatsappchannel.FieldOrganizationID:
  38661. m.ResetOrganizationID()
  38662. return nil
  38663. case whatsappchannel.FieldVerifyAccount:
  38664. m.ResetVerifyAccount()
  38665. return nil
  38666. }
  38667. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38668. }
  38669. // AddedEdges returns all edge names that were set/added in this mutation.
  38670. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38671. edges := make([]string, 0, 0)
  38672. return edges
  38673. }
  38674. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38675. // name in this mutation.
  38676. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38677. return nil
  38678. }
  38679. // RemovedEdges returns all edge names that were removed in this mutation.
  38680. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38681. edges := make([]string, 0, 0)
  38682. return edges
  38683. }
  38684. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38685. // the given name in this mutation.
  38686. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38687. return nil
  38688. }
  38689. // ClearedEdges returns all edge names that were cleared in this mutation.
  38690. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38691. edges := make([]string, 0, 0)
  38692. return edges
  38693. }
  38694. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38695. // was cleared in this mutation.
  38696. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38697. return false
  38698. }
  38699. // ClearEdge clears the value of the edge with the given name. It returns an error
  38700. // if that edge is not defined in the schema.
  38701. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38702. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38703. }
  38704. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38705. // It returns an error if the edge is not defined in the schema.
  38706. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38707. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38708. }
  38709. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38710. type WorkExperienceMutation struct {
  38711. config
  38712. op Op
  38713. typ string
  38714. id *uint64
  38715. created_at *time.Time
  38716. updated_at *time.Time
  38717. deleted_at *time.Time
  38718. start_date *time.Time
  38719. end_date *time.Time
  38720. company *string
  38721. experience *string
  38722. organization_id *uint64
  38723. addorganization_id *int64
  38724. clearedFields map[string]struct{}
  38725. employee *uint64
  38726. clearedemployee bool
  38727. done bool
  38728. oldValue func(context.Context) (*WorkExperience, error)
  38729. predicates []predicate.WorkExperience
  38730. }
  38731. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38732. // workexperienceOption allows management of the mutation configuration using functional options.
  38733. type workexperienceOption func(*WorkExperienceMutation)
  38734. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38735. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38736. m := &WorkExperienceMutation{
  38737. config: c,
  38738. op: op,
  38739. typ: TypeWorkExperience,
  38740. clearedFields: make(map[string]struct{}),
  38741. }
  38742. for _, opt := range opts {
  38743. opt(m)
  38744. }
  38745. return m
  38746. }
  38747. // withWorkExperienceID sets the ID field of the mutation.
  38748. func withWorkExperienceID(id uint64) workexperienceOption {
  38749. return func(m *WorkExperienceMutation) {
  38750. var (
  38751. err error
  38752. once sync.Once
  38753. value *WorkExperience
  38754. )
  38755. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38756. once.Do(func() {
  38757. if m.done {
  38758. err = errors.New("querying old values post mutation is not allowed")
  38759. } else {
  38760. value, err = m.Client().WorkExperience.Get(ctx, id)
  38761. }
  38762. })
  38763. return value, err
  38764. }
  38765. m.id = &id
  38766. }
  38767. }
  38768. // withWorkExperience sets the old WorkExperience of the mutation.
  38769. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38770. return func(m *WorkExperienceMutation) {
  38771. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38772. return node, nil
  38773. }
  38774. m.id = &node.ID
  38775. }
  38776. }
  38777. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38778. // executed in a transaction (ent.Tx), a transactional client is returned.
  38779. func (m WorkExperienceMutation) Client() *Client {
  38780. client := &Client{config: m.config}
  38781. client.init()
  38782. return client
  38783. }
  38784. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38785. // it returns an error otherwise.
  38786. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38787. if _, ok := m.driver.(*txDriver); !ok {
  38788. return nil, errors.New("ent: mutation is not running in a transaction")
  38789. }
  38790. tx := &Tx{config: m.config}
  38791. tx.init()
  38792. return tx, nil
  38793. }
  38794. // SetID sets the value of the id field. Note that this
  38795. // operation is only accepted on creation of WorkExperience entities.
  38796. func (m *WorkExperienceMutation) SetID(id uint64) {
  38797. m.id = &id
  38798. }
  38799. // ID returns the ID value in the mutation. Note that the ID is only available
  38800. // if it was provided to the builder or after it was returned from the database.
  38801. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38802. if m.id == nil {
  38803. return
  38804. }
  38805. return *m.id, true
  38806. }
  38807. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38808. // That means, if the mutation is applied within a transaction with an isolation level such
  38809. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38810. // or updated by the mutation.
  38811. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38812. switch {
  38813. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38814. id, exists := m.ID()
  38815. if exists {
  38816. return []uint64{id}, nil
  38817. }
  38818. fallthrough
  38819. case m.op.Is(OpUpdate | OpDelete):
  38820. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38821. default:
  38822. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38823. }
  38824. }
  38825. // SetCreatedAt sets the "created_at" field.
  38826. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38827. m.created_at = &t
  38828. }
  38829. // CreatedAt returns the value of the "created_at" field in the mutation.
  38830. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38831. v := m.created_at
  38832. if v == nil {
  38833. return
  38834. }
  38835. return *v, true
  38836. }
  38837. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38838. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38840. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38841. if !m.op.Is(OpUpdateOne) {
  38842. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38843. }
  38844. if m.id == nil || m.oldValue == nil {
  38845. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38846. }
  38847. oldValue, err := m.oldValue(ctx)
  38848. if err != nil {
  38849. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38850. }
  38851. return oldValue.CreatedAt, nil
  38852. }
  38853. // ResetCreatedAt resets all changes to the "created_at" field.
  38854. func (m *WorkExperienceMutation) ResetCreatedAt() {
  38855. m.created_at = nil
  38856. }
  38857. // SetUpdatedAt sets the "updated_at" field.
  38858. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  38859. m.updated_at = &t
  38860. }
  38861. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38862. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  38863. v := m.updated_at
  38864. if v == nil {
  38865. return
  38866. }
  38867. return *v, true
  38868. }
  38869. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  38870. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38872. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38873. if !m.op.Is(OpUpdateOne) {
  38874. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38875. }
  38876. if m.id == nil || m.oldValue == nil {
  38877. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38878. }
  38879. oldValue, err := m.oldValue(ctx)
  38880. if err != nil {
  38881. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38882. }
  38883. return oldValue.UpdatedAt, nil
  38884. }
  38885. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38886. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  38887. m.updated_at = nil
  38888. }
  38889. // SetDeletedAt sets the "deleted_at" field.
  38890. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  38891. m.deleted_at = &t
  38892. }
  38893. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38894. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  38895. v := m.deleted_at
  38896. if v == nil {
  38897. return
  38898. }
  38899. return *v, true
  38900. }
  38901. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  38902. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38904. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38905. if !m.op.Is(OpUpdateOne) {
  38906. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38907. }
  38908. if m.id == nil || m.oldValue == nil {
  38909. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38910. }
  38911. oldValue, err := m.oldValue(ctx)
  38912. if err != nil {
  38913. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38914. }
  38915. return oldValue.DeletedAt, nil
  38916. }
  38917. // ClearDeletedAt clears the value of the "deleted_at" field.
  38918. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38919. m.deleted_at = nil
  38920. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38921. }
  38922. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38923. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  38924. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  38925. return ok
  38926. }
  38927. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38928. func (m *WorkExperienceMutation) ResetDeletedAt() {
  38929. m.deleted_at = nil
  38930. delete(m.clearedFields, workexperience.FieldDeletedAt)
  38931. }
  38932. // SetEmployeeID sets the "employee_id" field.
  38933. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  38934. m.employee = &u
  38935. }
  38936. // EmployeeID returns the value of the "employee_id" field in the mutation.
  38937. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  38938. v := m.employee
  38939. if v == nil {
  38940. return
  38941. }
  38942. return *v, true
  38943. }
  38944. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  38945. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38947. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  38948. if !m.op.Is(OpUpdateOne) {
  38949. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  38950. }
  38951. if m.id == nil || m.oldValue == nil {
  38952. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  38953. }
  38954. oldValue, err := m.oldValue(ctx)
  38955. if err != nil {
  38956. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  38957. }
  38958. return oldValue.EmployeeID, nil
  38959. }
  38960. // ResetEmployeeID resets all changes to the "employee_id" field.
  38961. func (m *WorkExperienceMutation) ResetEmployeeID() {
  38962. m.employee = nil
  38963. }
  38964. // SetStartDate sets the "start_date" field.
  38965. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  38966. m.start_date = &t
  38967. }
  38968. // StartDate returns the value of the "start_date" field in the mutation.
  38969. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  38970. v := m.start_date
  38971. if v == nil {
  38972. return
  38973. }
  38974. return *v, true
  38975. }
  38976. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  38977. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38979. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  38980. if !m.op.Is(OpUpdateOne) {
  38981. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  38982. }
  38983. if m.id == nil || m.oldValue == nil {
  38984. return v, errors.New("OldStartDate requires an ID field in the mutation")
  38985. }
  38986. oldValue, err := m.oldValue(ctx)
  38987. if err != nil {
  38988. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  38989. }
  38990. return oldValue.StartDate, nil
  38991. }
  38992. // ResetStartDate resets all changes to the "start_date" field.
  38993. func (m *WorkExperienceMutation) ResetStartDate() {
  38994. m.start_date = nil
  38995. }
  38996. // SetEndDate sets the "end_date" field.
  38997. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  38998. m.end_date = &t
  38999. }
  39000. // EndDate returns the value of the "end_date" field in the mutation.
  39001. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39002. v := m.end_date
  39003. if v == nil {
  39004. return
  39005. }
  39006. return *v, true
  39007. }
  39008. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39009. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39011. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39012. if !m.op.Is(OpUpdateOne) {
  39013. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39014. }
  39015. if m.id == nil || m.oldValue == nil {
  39016. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39017. }
  39018. oldValue, err := m.oldValue(ctx)
  39019. if err != nil {
  39020. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39021. }
  39022. return oldValue.EndDate, nil
  39023. }
  39024. // ResetEndDate resets all changes to the "end_date" field.
  39025. func (m *WorkExperienceMutation) ResetEndDate() {
  39026. m.end_date = nil
  39027. }
  39028. // SetCompany sets the "company" field.
  39029. func (m *WorkExperienceMutation) SetCompany(s string) {
  39030. m.company = &s
  39031. }
  39032. // Company returns the value of the "company" field in the mutation.
  39033. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39034. v := m.company
  39035. if v == nil {
  39036. return
  39037. }
  39038. return *v, true
  39039. }
  39040. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39041. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39043. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39044. if !m.op.Is(OpUpdateOne) {
  39045. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39046. }
  39047. if m.id == nil || m.oldValue == nil {
  39048. return v, errors.New("OldCompany requires an ID field in the mutation")
  39049. }
  39050. oldValue, err := m.oldValue(ctx)
  39051. if err != nil {
  39052. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39053. }
  39054. return oldValue.Company, nil
  39055. }
  39056. // ResetCompany resets all changes to the "company" field.
  39057. func (m *WorkExperienceMutation) ResetCompany() {
  39058. m.company = nil
  39059. }
  39060. // SetExperience sets the "experience" field.
  39061. func (m *WorkExperienceMutation) SetExperience(s string) {
  39062. m.experience = &s
  39063. }
  39064. // Experience returns the value of the "experience" field in the mutation.
  39065. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39066. v := m.experience
  39067. if v == nil {
  39068. return
  39069. }
  39070. return *v, true
  39071. }
  39072. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39073. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39075. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39076. if !m.op.Is(OpUpdateOne) {
  39077. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39078. }
  39079. if m.id == nil || m.oldValue == nil {
  39080. return v, errors.New("OldExperience requires an ID field in the mutation")
  39081. }
  39082. oldValue, err := m.oldValue(ctx)
  39083. if err != nil {
  39084. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39085. }
  39086. return oldValue.Experience, nil
  39087. }
  39088. // ResetExperience resets all changes to the "experience" field.
  39089. func (m *WorkExperienceMutation) ResetExperience() {
  39090. m.experience = nil
  39091. }
  39092. // SetOrganizationID sets the "organization_id" field.
  39093. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39094. m.organization_id = &u
  39095. m.addorganization_id = nil
  39096. }
  39097. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39098. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39099. v := m.organization_id
  39100. if v == nil {
  39101. return
  39102. }
  39103. return *v, true
  39104. }
  39105. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39106. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39108. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39109. if !m.op.Is(OpUpdateOne) {
  39110. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39111. }
  39112. if m.id == nil || m.oldValue == nil {
  39113. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39114. }
  39115. oldValue, err := m.oldValue(ctx)
  39116. if err != nil {
  39117. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39118. }
  39119. return oldValue.OrganizationID, nil
  39120. }
  39121. // AddOrganizationID adds u to the "organization_id" field.
  39122. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39123. if m.addorganization_id != nil {
  39124. *m.addorganization_id += u
  39125. } else {
  39126. m.addorganization_id = &u
  39127. }
  39128. }
  39129. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39130. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39131. v := m.addorganization_id
  39132. if v == nil {
  39133. return
  39134. }
  39135. return *v, true
  39136. }
  39137. // ResetOrganizationID resets all changes to the "organization_id" field.
  39138. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39139. m.organization_id = nil
  39140. m.addorganization_id = nil
  39141. }
  39142. // ClearEmployee clears the "employee" edge to the Employee entity.
  39143. func (m *WorkExperienceMutation) ClearEmployee() {
  39144. m.clearedemployee = true
  39145. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39146. }
  39147. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39148. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39149. return m.clearedemployee
  39150. }
  39151. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39152. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39153. // EmployeeID instead. It exists only for internal usage by the builders.
  39154. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39155. if id := m.employee; id != nil {
  39156. ids = append(ids, *id)
  39157. }
  39158. return
  39159. }
  39160. // ResetEmployee resets all changes to the "employee" edge.
  39161. func (m *WorkExperienceMutation) ResetEmployee() {
  39162. m.employee = nil
  39163. m.clearedemployee = false
  39164. }
  39165. // Where appends a list predicates to the WorkExperienceMutation builder.
  39166. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39167. m.predicates = append(m.predicates, ps...)
  39168. }
  39169. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39170. // users can use type-assertion to append predicates that do not depend on any generated package.
  39171. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39172. p := make([]predicate.WorkExperience, len(ps))
  39173. for i := range ps {
  39174. p[i] = ps[i]
  39175. }
  39176. m.Where(p...)
  39177. }
  39178. // Op returns the operation name.
  39179. func (m *WorkExperienceMutation) Op() Op {
  39180. return m.op
  39181. }
  39182. // SetOp allows setting the mutation operation.
  39183. func (m *WorkExperienceMutation) SetOp(op Op) {
  39184. m.op = op
  39185. }
  39186. // Type returns the node type of this mutation (WorkExperience).
  39187. func (m *WorkExperienceMutation) Type() string {
  39188. return m.typ
  39189. }
  39190. // Fields returns all fields that were changed during this mutation. Note that in
  39191. // order to get all numeric fields that were incremented/decremented, call
  39192. // AddedFields().
  39193. func (m *WorkExperienceMutation) Fields() []string {
  39194. fields := make([]string, 0, 9)
  39195. if m.created_at != nil {
  39196. fields = append(fields, workexperience.FieldCreatedAt)
  39197. }
  39198. if m.updated_at != nil {
  39199. fields = append(fields, workexperience.FieldUpdatedAt)
  39200. }
  39201. if m.deleted_at != nil {
  39202. fields = append(fields, workexperience.FieldDeletedAt)
  39203. }
  39204. if m.employee != nil {
  39205. fields = append(fields, workexperience.FieldEmployeeID)
  39206. }
  39207. if m.start_date != nil {
  39208. fields = append(fields, workexperience.FieldStartDate)
  39209. }
  39210. if m.end_date != nil {
  39211. fields = append(fields, workexperience.FieldEndDate)
  39212. }
  39213. if m.company != nil {
  39214. fields = append(fields, workexperience.FieldCompany)
  39215. }
  39216. if m.experience != nil {
  39217. fields = append(fields, workexperience.FieldExperience)
  39218. }
  39219. if m.organization_id != nil {
  39220. fields = append(fields, workexperience.FieldOrganizationID)
  39221. }
  39222. return fields
  39223. }
  39224. // Field returns the value of a field with the given name. The second boolean
  39225. // return value indicates that this field was not set, or was not defined in the
  39226. // schema.
  39227. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39228. switch name {
  39229. case workexperience.FieldCreatedAt:
  39230. return m.CreatedAt()
  39231. case workexperience.FieldUpdatedAt:
  39232. return m.UpdatedAt()
  39233. case workexperience.FieldDeletedAt:
  39234. return m.DeletedAt()
  39235. case workexperience.FieldEmployeeID:
  39236. return m.EmployeeID()
  39237. case workexperience.FieldStartDate:
  39238. return m.StartDate()
  39239. case workexperience.FieldEndDate:
  39240. return m.EndDate()
  39241. case workexperience.FieldCompany:
  39242. return m.Company()
  39243. case workexperience.FieldExperience:
  39244. return m.Experience()
  39245. case workexperience.FieldOrganizationID:
  39246. return m.OrganizationID()
  39247. }
  39248. return nil, false
  39249. }
  39250. // OldField returns the old value of the field from the database. An error is
  39251. // returned if the mutation operation is not UpdateOne, or the query to the
  39252. // database failed.
  39253. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39254. switch name {
  39255. case workexperience.FieldCreatedAt:
  39256. return m.OldCreatedAt(ctx)
  39257. case workexperience.FieldUpdatedAt:
  39258. return m.OldUpdatedAt(ctx)
  39259. case workexperience.FieldDeletedAt:
  39260. return m.OldDeletedAt(ctx)
  39261. case workexperience.FieldEmployeeID:
  39262. return m.OldEmployeeID(ctx)
  39263. case workexperience.FieldStartDate:
  39264. return m.OldStartDate(ctx)
  39265. case workexperience.FieldEndDate:
  39266. return m.OldEndDate(ctx)
  39267. case workexperience.FieldCompany:
  39268. return m.OldCompany(ctx)
  39269. case workexperience.FieldExperience:
  39270. return m.OldExperience(ctx)
  39271. case workexperience.FieldOrganizationID:
  39272. return m.OldOrganizationID(ctx)
  39273. }
  39274. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39275. }
  39276. // SetField sets the value of a field with the given name. It returns an error if
  39277. // the field is not defined in the schema, or if the type mismatched the field
  39278. // type.
  39279. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39280. switch name {
  39281. case workexperience.FieldCreatedAt:
  39282. v, ok := value.(time.Time)
  39283. if !ok {
  39284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39285. }
  39286. m.SetCreatedAt(v)
  39287. return nil
  39288. case workexperience.FieldUpdatedAt:
  39289. v, ok := value.(time.Time)
  39290. if !ok {
  39291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39292. }
  39293. m.SetUpdatedAt(v)
  39294. return nil
  39295. case workexperience.FieldDeletedAt:
  39296. v, ok := value.(time.Time)
  39297. if !ok {
  39298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39299. }
  39300. m.SetDeletedAt(v)
  39301. return nil
  39302. case workexperience.FieldEmployeeID:
  39303. v, ok := value.(uint64)
  39304. if !ok {
  39305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39306. }
  39307. m.SetEmployeeID(v)
  39308. return nil
  39309. case workexperience.FieldStartDate:
  39310. v, ok := value.(time.Time)
  39311. if !ok {
  39312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39313. }
  39314. m.SetStartDate(v)
  39315. return nil
  39316. case workexperience.FieldEndDate:
  39317. v, ok := value.(time.Time)
  39318. if !ok {
  39319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39320. }
  39321. m.SetEndDate(v)
  39322. return nil
  39323. case workexperience.FieldCompany:
  39324. v, ok := value.(string)
  39325. if !ok {
  39326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39327. }
  39328. m.SetCompany(v)
  39329. return nil
  39330. case workexperience.FieldExperience:
  39331. v, ok := value.(string)
  39332. if !ok {
  39333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39334. }
  39335. m.SetExperience(v)
  39336. return nil
  39337. case workexperience.FieldOrganizationID:
  39338. v, ok := value.(uint64)
  39339. if !ok {
  39340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39341. }
  39342. m.SetOrganizationID(v)
  39343. return nil
  39344. }
  39345. return fmt.Errorf("unknown WorkExperience field %s", name)
  39346. }
  39347. // AddedFields returns all numeric fields that were incremented/decremented during
  39348. // this mutation.
  39349. func (m *WorkExperienceMutation) AddedFields() []string {
  39350. var fields []string
  39351. if m.addorganization_id != nil {
  39352. fields = append(fields, workexperience.FieldOrganizationID)
  39353. }
  39354. return fields
  39355. }
  39356. // AddedField returns the numeric value that was incremented/decremented on a field
  39357. // with the given name. The second boolean return value indicates that this field
  39358. // was not set, or was not defined in the schema.
  39359. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39360. switch name {
  39361. case workexperience.FieldOrganizationID:
  39362. return m.AddedOrganizationID()
  39363. }
  39364. return nil, false
  39365. }
  39366. // AddField adds the value to the field with the given name. It returns an error if
  39367. // the field is not defined in the schema, or if the type mismatched the field
  39368. // type.
  39369. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39370. switch name {
  39371. case workexperience.FieldOrganizationID:
  39372. v, ok := value.(int64)
  39373. if !ok {
  39374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39375. }
  39376. m.AddOrganizationID(v)
  39377. return nil
  39378. }
  39379. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39380. }
  39381. // ClearedFields returns all nullable fields that were cleared during this
  39382. // mutation.
  39383. func (m *WorkExperienceMutation) ClearedFields() []string {
  39384. var fields []string
  39385. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39386. fields = append(fields, workexperience.FieldDeletedAt)
  39387. }
  39388. return fields
  39389. }
  39390. // FieldCleared returns a boolean indicating if a field with the given name was
  39391. // cleared in this mutation.
  39392. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39393. _, ok := m.clearedFields[name]
  39394. return ok
  39395. }
  39396. // ClearField clears the value of the field with the given name. It returns an
  39397. // error if the field is not defined in the schema.
  39398. func (m *WorkExperienceMutation) ClearField(name string) error {
  39399. switch name {
  39400. case workexperience.FieldDeletedAt:
  39401. m.ClearDeletedAt()
  39402. return nil
  39403. }
  39404. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39405. }
  39406. // ResetField resets all changes in the mutation for the field with the given name.
  39407. // It returns an error if the field is not defined in the schema.
  39408. func (m *WorkExperienceMutation) ResetField(name string) error {
  39409. switch name {
  39410. case workexperience.FieldCreatedAt:
  39411. m.ResetCreatedAt()
  39412. return nil
  39413. case workexperience.FieldUpdatedAt:
  39414. m.ResetUpdatedAt()
  39415. return nil
  39416. case workexperience.FieldDeletedAt:
  39417. m.ResetDeletedAt()
  39418. return nil
  39419. case workexperience.FieldEmployeeID:
  39420. m.ResetEmployeeID()
  39421. return nil
  39422. case workexperience.FieldStartDate:
  39423. m.ResetStartDate()
  39424. return nil
  39425. case workexperience.FieldEndDate:
  39426. m.ResetEndDate()
  39427. return nil
  39428. case workexperience.FieldCompany:
  39429. m.ResetCompany()
  39430. return nil
  39431. case workexperience.FieldExperience:
  39432. m.ResetExperience()
  39433. return nil
  39434. case workexperience.FieldOrganizationID:
  39435. m.ResetOrganizationID()
  39436. return nil
  39437. }
  39438. return fmt.Errorf("unknown WorkExperience field %s", name)
  39439. }
  39440. // AddedEdges returns all edge names that were set/added in this mutation.
  39441. func (m *WorkExperienceMutation) AddedEdges() []string {
  39442. edges := make([]string, 0, 1)
  39443. if m.employee != nil {
  39444. edges = append(edges, workexperience.EdgeEmployee)
  39445. }
  39446. return edges
  39447. }
  39448. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39449. // name in this mutation.
  39450. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39451. switch name {
  39452. case workexperience.EdgeEmployee:
  39453. if id := m.employee; id != nil {
  39454. return []ent.Value{*id}
  39455. }
  39456. }
  39457. return nil
  39458. }
  39459. // RemovedEdges returns all edge names that were removed in this mutation.
  39460. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39461. edges := make([]string, 0, 1)
  39462. return edges
  39463. }
  39464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39465. // the given name in this mutation.
  39466. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39467. return nil
  39468. }
  39469. // ClearedEdges returns all edge names that were cleared in this mutation.
  39470. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39471. edges := make([]string, 0, 1)
  39472. if m.clearedemployee {
  39473. edges = append(edges, workexperience.EdgeEmployee)
  39474. }
  39475. return edges
  39476. }
  39477. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39478. // was cleared in this mutation.
  39479. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39480. switch name {
  39481. case workexperience.EdgeEmployee:
  39482. return m.clearedemployee
  39483. }
  39484. return false
  39485. }
  39486. // ClearEdge clears the value of the edge with the given name. It returns an error
  39487. // if that edge is not defined in the schema.
  39488. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39489. switch name {
  39490. case workexperience.EdgeEmployee:
  39491. m.ClearEmployee()
  39492. return nil
  39493. }
  39494. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39495. }
  39496. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39497. // It returns an error if the edge is not defined in the schema.
  39498. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39499. switch name {
  39500. case workexperience.EdgeEmployee:
  39501. m.ResetEmployee()
  39502. return nil
  39503. }
  39504. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39505. }
  39506. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39507. type WpChatroomMutation struct {
  39508. config
  39509. op Op
  39510. typ string
  39511. id *uint64
  39512. created_at *time.Time
  39513. updated_at *time.Time
  39514. status *uint8
  39515. addstatus *int8
  39516. wx_wxid *string
  39517. chatroom_id *string
  39518. nickname *string
  39519. owner *string
  39520. avatar *string
  39521. member_list *[]string
  39522. appendmember_list []string
  39523. clearedFields map[string]struct{}
  39524. done bool
  39525. oldValue func(context.Context) (*WpChatroom, error)
  39526. predicates []predicate.WpChatroom
  39527. }
  39528. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39529. // wpchatroomOption allows management of the mutation configuration using functional options.
  39530. type wpchatroomOption func(*WpChatroomMutation)
  39531. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39532. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39533. m := &WpChatroomMutation{
  39534. config: c,
  39535. op: op,
  39536. typ: TypeWpChatroom,
  39537. clearedFields: make(map[string]struct{}),
  39538. }
  39539. for _, opt := range opts {
  39540. opt(m)
  39541. }
  39542. return m
  39543. }
  39544. // withWpChatroomID sets the ID field of the mutation.
  39545. func withWpChatroomID(id uint64) wpchatroomOption {
  39546. return func(m *WpChatroomMutation) {
  39547. var (
  39548. err error
  39549. once sync.Once
  39550. value *WpChatroom
  39551. )
  39552. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39553. once.Do(func() {
  39554. if m.done {
  39555. err = errors.New("querying old values post mutation is not allowed")
  39556. } else {
  39557. value, err = m.Client().WpChatroom.Get(ctx, id)
  39558. }
  39559. })
  39560. return value, err
  39561. }
  39562. m.id = &id
  39563. }
  39564. }
  39565. // withWpChatroom sets the old WpChatroom of the mutation.
  39566. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39567. return func(m *WpChatroomMutation) {
  39568. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39569. return node, nil
  39570. }
  39571. m.id = &node.ID
  39572. }
  39573. }
  39574. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39575. // executed in a transaction (ent.Tx), a transactional client is returned.
  39576. func (m WpChatroomMutation) Client() *Client {
  39577. client := &Client{config: m.config}
  39578. client.init()
  39579. return client
  39580. }
  39581. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39582. // it returns an error otherwise.
  39583. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39584. if _, ok := m.driver.(*txDriver); !ok {
  39585. return nil, errors.New("ent: mutation is not running in a transaction")
  39586. }
  39587. tx := &Tx{config: m.config}
  39588. tx.init()
  39589. return tx, nil
  39590. }
  39591. // SetID sets the value of the id field. Note that this
  39592. // operation is only accepted on creation of WpChatroom entities.
  39593. func (m *WpChatroomMutation) SetID(id uint64) {
  39594. m.id = &id
  39595. }
  39596. // ID returns the ID value in the mutation. Note that the ID is only available
  39597. // if it was provided to the builder or after it was returned from the database.
  39598. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39599. if m.id == nil {
  39600. return
  39601. }
  39602. return *m.id, true
  39603. }
  39604. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39605. // That means, if the mutation is applied within a transaction with an isolation level such
  39606. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39607. // or updated by the mutation.
  39608. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39609. switch {
  39610. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39611. id, exists := m.ID()
  39612. if exists {
  39613. return []uint64{id}, nil
  39614. }
  39615. fallthrough
  39616. case m.op.Is(OpUpdate | OpDelete):
  39617. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39618. default:
  39619. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39620. }
  39621. }
  39622. // SetCreatedAt sets the "created_at" field.
  39623. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39624. m.created_at = &t
  39625. }
  39626. // CreatedAt returns the value of the "created_at" field in the mutation.
  39627. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39628. v := m.created_at
  39629. if v == nil {
  39630. return
  39631. }
  39632. return *v, true
  39633. }
  39634. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39635. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39637. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39638. if !m.op.Is(OpUpdateOne) {
  39639. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39640. }
  39641. if m.id == nil || m.oldValue == nil {
  39642. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39643. }
  39644. oldValue, err := m.oldValue(ctx)
  39645. if err != nil {
  39646. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39647. }
  39648. return oldValue.CreatedAt, nil
  39649. }
  39650. // ResetCreatedAt resets all changes to the "created_at" field.
  39651. func (m *WpChatroomMutation) ResetCreatedAt() {
  39652. m.created_at = nil
  39653. }
  39654. // SetUpdatedAt sets the "updated_at" field.
  39655. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39656. m.updated_at = &t
  39657. }
  39658. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39659. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39660. v := m.updated_at
  39661. if v == nil {
  39662. return
  39663. }
  39664. return *v, true
  39665. }
  39666. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39667. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39669. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39670. if !m.op.Is(OpUpdateOne) {
  39671. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39672. }
  39673. if m.id == nil || m.oldValue == nil {
  39674. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39675. }
  39676. oldValue, err := m.oldValue(ctx)
  39677. if err != nil {
  39678. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39679. }
  39680. return oldValue.UpdatedAt, nil
  39681. }
  39682. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39683. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39684. m.updated_at = nil
  39685. }
  39686. // SetStatus sets the "status" field.
  39687. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39688. m.status = &u
  39689. m.addstatus = nil
  39690. }
  39691. // Status returns the value of the "status" field in the mutation.
  39692. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39693. v := m.status
  39694. if v == nil {
  39695. return
  39696. }
  39697. return *v, true
  39698. }
  39699. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39700. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39702. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39703. if !m.op.Is(OpUpdateOne) {
  39704. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39705. }
  39706. if m.id == nil || m.oldValue == nil {
  39707. return v, errors.New("OldStatus requires an ID field in the mutation")
  39708. }
  39709. oldValue, err := m.oldValue(ctx)
  39710. if err != nil {
  39711. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39712. }
  39713. return oldValue.Status, nil
  39714. }
  39715. // AddStatus adds u to the "status" field.
  39716. func (m *WpChatroomMutation) AddStatus(u int8) {
  39717. if m.addstatus != nil {
  39718. *m.addstatus += u
  39719. } else {
  39720. m.addstatus = &u
  39721. }
  39722. }
  39723. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39724. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39725. v := m.addstatus
  39726. if v == nil {
  39727. return
  39728. }
  39729. return *v, true
  39730. }
  39731. // ClearStatus clears the value of the "status" field.
  39732. func (m *WpChatroomMutation) ClearStatus() {
  39733. m.status = nil
  39734. m.addstatus = nil
  39735. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39736. }
  39737. // StatusCleared returns if the "status" field was cleared in this mutation.
  39738. func (m *WpChatroomMutation) StatusCleared() bool {
  39739. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39740. return ok
  39741. }
  39742. // ResetStatus resets all changes to the "status" field.
  39743. func (m *WpChatroomMutation) ResetStatus() {
  39744. m.status = nil
  39745. m.addstatus = nil
  39746. delete(m.clearedFields, wpchatroom.FieldStatus)
  39747. }
  39748. // SetWxWxid sets the "wx_wxid" field.
  39749. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39750. m.wx_wxid = &s
  39751. }
  39752. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39753. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39754. v := m.wx_wxid
  39755. if v == nil {
  39756. return
  39757. }
  39758. return *v, true
  39759. }
  39760. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39761. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39763. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39764. if !m.op.Is(OpUpdateOne) {
  39765. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39766. }
  39767. if m.id == nil || m.oldValue == nil {
  39768. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39769. }
  39770. oldValue, err := m.oldValue(ctx)
  39771. if err != nil {
  39772. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39773. }
  39774. return oldValue.WxWxid, nil
  39775. }
  39776. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39777. func (m *WpChatroomMutation) ResetWxWxid() {
  39778. m.wx_wxid = nil
  39779. }
  39780. // SetChatroomID sets the "chatroom_id" field.
  39781. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39782. m.chatroom_id = &s
  39783. }
  39784. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39785. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39786. v := m.chatroom_id
  39787. if v == nil {
  39788. return
  39789. }
  39790. return *v, true
  39791. }
  39792. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39793. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39795. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39796. if !m.op.Is(OpUpdateOne) {
  39797. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39798. }
  39799. if m.id == nil || m.oldValue == nil {
  39800. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39801. }
  39802. oldValue, err := m.oldValue(ctx)
  39803. if err != nil {
  39804. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39805. }
  39806. return oldValue.ChatroomID, nil
  39807. }
  39808. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39809. func (m *WpChatroomMutation) ResetChatroomID() {
  39810. m.chatroom_id = nil
  39811. }
  39812. // SetNickname sets the "nickname" field.
  39813. func (m *WpChatroomMutation) SetNickname(s string) {
  39814. m.nickname = &s
  39815. }
  39816. // Nickname returns the value of the "nickname" field in the mutation.
  39817. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39818. v := m.nickname
  39819. if v == nil {
  39820. return
  39821. }
  39822. return *v, true
  39823. }
  39824. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39825. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39827. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39828. if !m.op.Is(OpUpdateOne) {
  39829. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39830. }
  39831. if m.id == nil || m.oldValue == nil {
  39832. return v, errors.New("OldNickname requires an ID field in the mutation")
  39833. }
  39834. oldValue, err := m.oldValue(ctx)
  39835. if err != nil {
  39836. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39837. }
  39838. return oldValue.Nickname, nil
  39839. }
  39840. // ResetNickname resets all changes to the "nickname" field.
  39841. func (m *WpChatroomMutation) ResetNickname() {
  39842. m.nickname = nil
  39843. }
  39844. // SetOwner sets the "owner" field.
  39845. func (m *WpChatroomMutation) SetOwner(s string) {
  39846. m.owner = &s
  39847. }
  39848. // Owner returns the value of the "owner" field in the mutation.
  39849. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  39850. v := m.owner
  39851. if v == nil {
  39852. return
  39853. }
  39854. return *v, true
  39855. }
  39856. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  39857. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39859. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  39860. if !m.op.Is(OpUpdateOne) {
  39861. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  39862. }
  39863. if m.id == nil || m.oldValue == nil {
  39864. return v, errors.New("OldOwner requires an ID field in the mutation")
  39865. }
  39866. oldValue, err := m.oldValue(ctx)
  39867. if err != nil {
  39868. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  39869. }
  39870. return oldValue.Owner, nil
  39871. }
  39872. // ResetOwner resets all changes to the "owner" field.
  39873. func (m *WpChatroomMutation) ResetOwner() {
  39874. m.owner = nil
  39875. }
  39876. // SetAvatar sets the "avatar" field.
  39877. func (m *WpChatroomMutation) SetAvatar(s string) {
  39878. m.avatar = &s
  39879. }
  39880. // Avatar returns the value of the "avatar" field in the mutation.
  39881. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  39882. v := m.avatar
  39883. if v == nil {
  39884. return
  39885. }
  39886. return *v, true
  39887. }
  39888. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  39889. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39891. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39892. if !m.op.Is(OpUpdateOne) {
  39893. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39894. }
  39895. if m.id == nil || m.oldValue == nil {
  39896. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39897. }
  39898. oldValue, err := m.oldValue(ctx)
  39899. if err != nil {
  39900. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39901. }
  39902. return oldValue.Avatar, nil
  39903. }
  39904. // ResetAvatar resets all changes to the "avatar" field.
  39905. func (m *WpChatroomMutation) ResetAvatar() {
  39906. m.avatar = nil
  39907. }
  39908. // SetMemberList sets the "member_list" field.
  39909. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39910. m.member_list = &s
  39911. m.appendmember_list = nil
  39912. }
  39913. // MemberList returns the value of the "member_list" field in the mutation.
  39914. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39915. v := m.member_list
  39916. if v == nil {
  39917. return
  39918. }
  39919. return *v, true
  39920. }
  39921. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  39922. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39924. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  39925. if !m.op.Is(OpUpdateOne) {
  39926. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  39927. }
  39928. if m.id == nil || m.oldValue == nil {
  39929. return v, errors.New("OldMemberList requires an ID field in the mutation")
  39930. }
  39931. oldValue, err := m.oldValue(ctx)
  39932. if err != nil {
  39933. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  39934. }
  39935. return oldValue.MemberList, nil
  39936. }
  39937. // AppendMemberList adds s to the "member_list" field.
  39938. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  39939. m.appendmember_list = append(m.appendmember_list, s...)
  39940. }
  39941. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  39942. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  39943. if len(m.appendmember_list) == 0 {
  39944. return nil, false
  39945. }
  39946. return m.appendmember_list, true
  39947. }
  39948. // ResetMemberList resets all changes to the "member_list" field.
  39949. func (m *WpChatroomMutation) ResetMemberList() {
  39950. m.member_list = nil
  39951. m.appendmember_list = nil
  39952. }
  39953. // Where appends a list predicates to the WpChatroomMutation builder.
  39954. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  39955. m.predicates = append(m.predicates, ps...)
  39956. }
  39957. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  39958. // users can use type-assertion to append predicates that do not depend on any generated package.
  39959. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  39960. p := make([]predicate.WpChatroom, len(ps))
  39961. for i := range ps {
  39962. p[i] = ps[i]
  39963. }
  39964. m.Where(p...)
  39965. }
  39966. // Op returns the operation name.
  39967. func (m *WpChatroomMutation) Op() Op {
  39968. return m.op
  39969. }
  39970. // SetOp allows setting the mutation operation.
  39971. func (m *WpChatroomMutation) SetOp(op Op) {
  39972. m.op = op
  39973. }
  39974. // Type returns the node type of this mutation (WpChatroom).
  39975. func (m *WpChatroomMutation) Type() string {
  39976. return m.typ
  39977. }
  39978. // Fields returns all fields that were changed during this mutation. Note that in
  39979. // order to get all numeric fields that were incremented/decremented, call
  39980. // AddedFields().
  39981. func (m *WpChatroomMutation) Fields() []string {
  39982. fields := make([]string, 0, 9)
  39983. if m.created_at != nil {
  39984. fields = append(fields, wpchatroom.FieldCreatedAt)
  39985. }
  39986. if m.updated_at != nil {
  39987. fields = append(fields, wpchatroom.FieldUpdatedAt)
  39988. }
  39989. if m.status != nil {
  39990. fields = append(fields, wpchatroom.FieldStatus)
  39991. }
  39992. if m.wx_wxid != nil {
  39993. fields = append(fields, wpchatroom.FieldWxWxid)
  39994. }
  39995. if m.chatroom_id != nil {
  39996. fields = append(fields, wpchatroom.FieldChatroomID)
  39997. }
  39998. if m.nickname != nil {
  39999. fields = append(fields, wpchatroom.FieldNickname)
  40000. }
  40001. if m.owner != nil {
  40002. fields = append(fields, wpchatroom.FieldOwner)
  40003. }
  40004. if m.avatar != nil {
  40005. fields = append(fields, wpchatroom.FieldAvatar)
  40006. }
  40007. if m.member_list != nil {
  40008. fields = append(fields, wpchatroom.FieldMemberList)
  40009. }
  40010. return fields
  40011. }
  40012. // Field returns the value of a field with the given name. The second boolean
  40013. // return value indicates that this field was not set, or was not defined in the
  40014. // schema.
  40015. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40016. switch name {
  40017. case wpchatroom.FieldCreatedAt:
  40018. return m.CreatedAt()
  40019. case wpchatroom.FieldUpdatedAt:
  40020. return m.UpdatedAt()
  40021. case wpchatroom.FieldStatus:
  40022. return m.Status()
  40023. case wpchatroom.FieldWxWxid:
  40024. return m.WxWxid()
  40025. case wpchatroom.FieldChatroomID:
  40026. return m.ChatroomID()
  40027. case wpchatroom.FieldNickname:
  40028. return m.Nickname()
  40029. case wpchatroom.FieldOwner:
  40030. return m.Owner()
  40031. case wpchatroom.FieldAvatar:
  40032. return m.Avatar()
  40033. case wpchatroom.FieldMemberList:
  40034. return m.MemberList()
  40035. }
  40036. return nil, false
  40037. }
  40038. // OldField returns the old value of the field from the database. An error is
  40039. // returned if the mutation operation is not UpdateOne, or the query to the
  40040. // database failed.
  40041. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40042. switch name {
  40043. case wpchatroom.FieldCreatedAt:
  40044. return m.OldCreatedAt(ctx)
  40045. case wpchatroom.FieldUpdatedAt:
  40046. return m.OldUpdatedAt(ctx)
  40047. case wpchatroom.FieldStatus:
  40048. return m.OldStatus(ctx)
  40049. case wpchatroom.FieldWxWxid:
  40050. return m.OldWxWxid(ctx)
  40051. case wpchatroom.FieldChatroomID:
  40052. return m.OldChatroomID(ctx)
  40053. case wpchatroom.FieldNickname:
  40054. return m.OldNickname(ctx)
  40055. case wpchatroom.FieldOwner:
  40056. return m.OldOwner(ctx)
  40057. case wpchatroom.FieldAvatar:
  40058. return m.OldAvatar(ctx)
  40059. case wpchatroom.FieldMemberList:
  40060. return m.OldMemberList(ctx)
  40061. }
  40062. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40063. }
  40064. // SetField sets the value of a field with the given name. It returns an error if
  40065. // the field is not defined in the schema, or if the type mismatched the field
  40066. // type.
  40067. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40068. switch name {
  40069. case wpchatroom.FieldCreatedAt:
  40070. v, ok := value.(time.Time)
  40071. if !ok {
  40072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40073. }
  40074. m.SetCreatedAt(v)
  40075. return nil
  40076. case wpchatroom.FieldUpdatedAt:
  40077. v, ok := value.(time.Time)
  40078. if !ok {
  40079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40080. }
  40081. m.SetUpdatedAt(v)
  40082. return nil
  40083. case wpchatroom.FieldStatus:
  40084. v, ok := value.(uint8)
  40085. if !ok {
  40086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40087. }
  40088. m.SetStatus(v)
  40089. return nil
  40090. case wpchatroom.FieldWxWxid:
  40091. v, ok := value.(string)
  40092. if !ok {
  40093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40094. }
  40095. m.SetWxWxid(v)
  40096. return nil
  40097. case wpchatroom.FieldChatroomID:
  40098. v, ok := value.(string)
  40099. if !ok {
  40100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40101. }
  40102. m.SetChatroomID(v)
  40103. return nil
  40104. case wpchatroom.FieldNickname:
  40105. v, ok := value.(string)
  40106. if !ok {
  40107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40108. }
  40109. m.SetNickname(v)
  40110. return nil
  40111. case wpchatroom.FieldOwner:
  40112. v, ok := value.(string)
  40113. if !ok {
  40114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40115. }
  40116. m.SetOwner(v)
  40117. return nil
  40118. case wpchatroom.FieldAvatar:
  40119. v, ok := value.(string)
  40120. if !ok {
  40121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40122. }
  40123. m.SetAvatar(v)
  40124. return nil
  40125. case wpchatroom.FieldMemberList:
  40126. v, ok := value.([]string)
  40127. if !ok {
  40128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40129. }
  40130. m.SetMemberList(v)
  40131. return nil
  40132. }
  40133. return fmt.Errorf("unknown WpChatroom field %s", name)
  40134. }
  40135. // AddedFields returns all numeric fields that were incremented/decremented during
  40136. // this mutation.
  40137. func (m *WpChatroomMutation) AddedFields() []string {
  40138. var fields []string
  40139. if m.addstatus != nil {
  40140. fields = append(fields, wpchatroom.FieldStatus)
  40141. }
  40142. return fields
  40143. }
  40144. // AddedField returns the numeric value that was incremented/decremented on a field
  40145. // with the given name. The second boolean return value indicates that this field
  40146. // was not set, or was not defined in the schema.
  40147. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40148. switch name {
  40149. case wpchatroom.FieldStatus:
  40150. return m.AddedStatus()
  40151. }
  40152. return nil, false
  40153. }
  40154. // AddField adds the value to the field with the given name. It returns an error if
  40155. // the field is not defined in the schema, or if the type mismatched the field
  40156. // type.
  40157. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40158. switch name {
  40159. case wpchatroom.FieldStatus:
  40160. v, ok := value.(int8)
  40161. if !ok {
  40162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40163. }
  40164. m.AddStatus(v)
  40165. return nil
  40166. }
  40167. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40168. }
  40169. // ClearedFields returns all nullable fields that were cleared during this
  40170. // mutation.
  40171. func (m *WpChatroomMutation) ClearedFields() []string {
  40172. var fields []string
  40173. if m.FieldCleared(wpchatroom.FieldStatus) {
  40174. fields = append(fields, wpchatroom.FieldStatus)
  40175. }
  40176. return fields
  40177. }
  40178. // FieldCleared returns a boolean indicating if a field with the given name was
  40179. // cleared in this mutation.
  40180. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40181. _, ok := m.clearedFields[name]
  40182. return ok
  40183. }
  40184. // ClearField clears the value of the field with the given name. It returns an
  40185. // error if the field is not defined in the schema.
  40186. func (m *WpChatroomMutation) ClearField(name string) error {
  40187. switch name {
  40188. case wpchatroom.FieldStatus:
  40189. m.ClearStatus()
  40190. return nil
  40191. }
  40192. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40193. }
  40194. // ResetField resets all changes in the mutation for the field with the given name.
  40195. // It returns an error if the field is not defined in the schema.
  40196. func (m *WpChatroomMutation) ResetField(name string) error {
  40197. switch name {
  40198. case wpchatroom.FieldCreatedAt:
  40199. m.ResetCreatedAt()
  40200. return nil
  40201. case wpchatroom.FieldUpdatedAt:
  40202. m.ResetUpdatedAt()
  40203. return nil
  40204. case wpchatroom.FieldStatus:
  40205. m.ResetStatus()
  40206. return nil
  40207. case wpchatroom.FieldWxWxid:
  40208. m.ResetWxWxid()
  40209. return nil
  40210. case wpchatroom.FieldChatroomID:
  40211. m.ResetChatroomID()
  40212. return nil
  40213. case wpchatroom.FieldNickname:
  40214. m.ResetNickname()
  40215. return nil
  40216. case wpchatroom.FieldOwner:
  40217. m.ResetOwner()
  40218. return nil
  40219. case wpchatroom.FieldAvatar:
  40220. m.ResetAvatar()
  40221. return nil
  40222. case wpchatroom.FieldMemberList:
  40223. m.ResetMemberList()
  40224. return nil
  40225. }
  40226. return fmt.Errorf("unknown WpChatroom field %s", name)
  40227. }
  40228. // AddedEdges returns all edge names that were set/added in this mutation.
  40229. func (m *WpChatroomMutation) AddedEdges() []string {
  40230. edges := make([]string, 0, 0)
  40231. return edges
  40232. }
  40233. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40234. // name in this mutation.
  40235. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40236. return nil
  40237. }
  40238. // RemovedEdges returns all edge names that were removed in this mutation.
  40239. func (m *WpChatroomMutation) RemovedEdges() []string {
  40240. edges := make([]string, 0, 0)
  40241. return edges
  40242. }
  40243. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40244. // the given name in this mutation.
  40245. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40246. return nil
  40247. }
  40248. // ClearedEdges returns all edge names that were cleared in this mutation.
  40249. func (m *WpChatroomMutation) ClearedEdges() []string {
  40250. edges := make([]string, 0, 0)
  40251. return edges
  40252. }
  40253. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40254. // was cleared in this mutation.
  40255. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40256. return false
  40257. }
  40258. // ClearEdge clears the value of the edge with the given name. It returns an error
  40259. // if that edge is not defined in the schema.
  40260. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40261. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40262. }
  40263. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40264. // It returns an error if the edge is not defined in the schema.
  40265. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40266. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40267. }
  40268. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40269. type WpChatroomMemberMutation struct {
  40270. config
  40271. op Op
  40272. typ string
  40273. id *uint64
  40274. created_at *time.Time
  40275. updated_at *time.Time
  40276. status *uint8
  40277. addstatus *int8
  40278. wx_wxid *string
  40279. wxid *string
  40280. nickname *string
  40281. avatar *string
  40282. clearedFields map[string]struct{}
  40283. done bool
  40284. oldValue func(context.Context) (*WpChatroomMember, error)
  40285. predicates []predicate.WpChatroomMember
  40286. }
  40287. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40288. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40289. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40290. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40291. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40292. m := &WpChatroomMemberMutation{
  40293. config: c,
  40294. op: op,
  40295. typ: TypeWpChatroomMember,
  40296. clearedFields: make(map[string]struct{}),
  40297. }
  40298. for _, opt := range opts {
  40299. opt(m)
  40300. }
  40301. return m
  40302. }
  40303. // withWpChatroomMemberID sets the ID field of the mutation.
  40304. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40305. return func(m *WpChatroomMemberMutation) {
  40306. var (
  40307. err error
  40308. once sync.Once
  40309. value *WpChatroomMember
  40310. )
  40311. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40312. once.Do(func() {
  40313. if m.done {
  40314. err = errors.New("querying old values post mutation is not allowed")
  40315. } else {
  40316. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40317. }
  40318. })
  40319. return value, err
  40320. }
  40321. m.id = &id
  40322. }
  40323. }
  40324. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40325. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40326. return func(m *WpChatroomMemberMutation) {
  40327. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40328. return node, nil
  40329. }
  40330. m.id = &node.ID
  40331. }
  40332. }
  40333. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40334. // executed in a transaction (ent.Tx), a transactional client is returned.
  40335. func (m WpChatroomMemberMutation) Client() *Client {
  40336. client := &Client{config: m.config}
  40337. client.init()
  40338. return client
  40339. }
  40340. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40341. // it returns an error otherwise.
  40342. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40343. if _, ok := m.driver.(*txDriver); !ok {
  40344. return nil, errors.New("ent: mutation is not running in a transaction")
  40345. }
  40346. tx := &Tx{config: m.config}
  40347. tx.init()
  40348. return tx, nil
  40349. }
  40350. // SetID sets the value of the id field. Note that this
  40351. // operation is only accepted on creation of WpChatroomMember entities.
  40352. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40353. m.id = &id
  40354. }
  40355. // ID returns the ID value in the mutation. Note that the ID is only available
  40356. // if it was provided to the builder or after it was returned from the database.
  40357. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40358. if m.id == nil {
  40359. return
  40360. }
  40361. return *m.id, true
  40362. }
  40363. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40364. // That means, if the mutation is applied within a transaction with an isolation level such
  40365. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40366. // or updated by the mutation.
  40367. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40368. switch {
  40369. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40370. id, exists := m.ID()
  40371. if exists {
  40372. return []uint64{id}, nil
  40373. }
  40374. fallthrough
  40375. case m.op.Is(OpUpdate | OpDelete):
  40376. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40377. default:
  40378. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40379. }
  40380. }
  40381. // SetCreatedAt sets the "created_at" field.
  40382. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40383. m.created_at = &t
  40384. }
  40385. // CreatedAt returns the value of the "created_at" field in the mutation.
  40386. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40387. v := m.created_at
  40388. if v == nil {
  40389. return
  40390. }
  40391. return *v, true
  40392. }
  40393. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40394. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40396. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40397. if !m.op.Is(OpUpdateOne) {
  40398. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40399. }
  40400. if m.id == nil || m.oldValue == nil {
  40401. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40402. }
  40403. oldValue, err := m.oldValue(ctx)
  40404. if err != nil {
  40405. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40406. }
  40407. return oldValue.CreatedAt, nil
  40408. }
  40409. // ResetCreatedAt resets all changes to the "created_at" field.
  40410. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40411. m.created_at = nil
  40412. }
  40413. // SetUpdatedAt sets the "updated_at" field.
  40414. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40415. m.updated_at = &t
  40416. }
  40417. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40418. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40419. v := m.updated_at
  40420. if v == nil {
  40421. return
  40422. }
  40423. return *v, true
  40424. }
  40425. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40426. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40428. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40429. if !m.op.Is(OpUpdateOne) {
  40430. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40431. }
  40432. if m.id == nil || m.oldValue == nil {
  40433. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40434. }
  40435. oldValue, err := m.oldValue(ctx)
  40436. if err != nil {
  40437. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40438. }
  40439. return oldValue.UpdatedAt, nil
  40440. }
  40441. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40442. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40443. m.updated_at = nil
  40444. }
  40445. // SetStatus sets the "status" field.
  40446. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40447. m.status = &u
  40448. m.addstatus = nil
  40449. }
  40450. // Status returns the value of the "status" field in the mutation.
  40451. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40452. v := m.status
  40453. if v == nil {
  40454. return
  40455. }
  40456. return *v, true
  40457. }
  40458. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40459. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40461. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40462. if !m.op.Is(OpUpdateOne) {
  40463. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40464. }
  40465. if m.id == nil || m.oldValue == nil {
  40466. return v, errors.New("OldStatus requires an ID field in the mutation")
  40467. }
  40468. oldValue, err := m.oldValue(ctx)
  40469. if err != nil {
  40470. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40471. }
  40472. return oldValue.Status, nil
  40473. }
  40474. // AddStatus adds u to the "status" field.
  40475. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40476. if m.addstatus != nil {
  40477. *m.addstatus += u
  40478. } else {
  40479. m.addstatus = &u
  40480. }
  40481. }
  40482. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40483. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40484. v := m.addstatus
  40485. if v == nil {
  40486. return
  40487. }
  40488. return *v, true
  40489. }
  40490. // ClearStatus clears the value of the "status" field.
  40491. func (m *WpChatroomMemberMutation) ClearStatus() {
  40492. m.status = nil
  40493. m.addstatus = nil
  40494. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40495. }
  40496. // StatusCleared returns if the "status" field was cleared in this mutation.
  40497. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40498. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40499. return ok
  40500. }
  40501. // ResetStatus resets all changes to the "status" field.
  40502. func (m *WpChatroomMemberMutation) ResetStatus() {
  40503. m.status = nil
  40504. m.addstatus = nil
  40505. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40506. }
  40507. // SetWxWxid sets the "wx_wxid" field.
  40508. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40509. m.wx_wxid = &s
  40510. }
  40511. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40512. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40513. v := m.wx_wxid
  40514. if v == nil {
  40515. return
  40516. }
  40517. return *v, true
  40518. }
  40519. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40520. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40522. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40523. if !m.op.Is(OpUpdateOne) {
  40524. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40525. }
  40526. if m.id == nil || m.oldValue == nil {
  40527. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40528. }
  40529. oldValue, err := m.oldValue(ctx)
  40530. if err != nil {
  40531. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40532. }
  40533. return oldValue.WxWxid, nil
  40534. }
  40535. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40536. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40537. m.wx_wxid = nil
  40538. }
  40539. // SetWxid sets the "wxid" field.
  40540. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40541. m.wxid = &s
  40542. }
  40543. // Wxid returns the value of the "wxid" field in the mutation.
  40544. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40545. v := m.wxid
  40546. if v == nil {
  40547. return
  40548. }
  40549. return *v, true
  40550. }
  40551. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40552. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40554. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40555. if !m.op.Is(OpUpdateOne) {
  40556. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40557. }
  40558. if m.id == nil || m.oldValue == nil {
  40559. return v, errors.New("OldWxid requires an ID field in the mutation")
  40560. }
  40561. oldValue, err := m.oldValue(ctx)
  40562. if err != nil {
  40563. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40564. }
  40565. return oldValue.Wxid, nil
  40566. }
  40567. // ResetWxid resets all changes to the "wxid" field.
  40568. func (m *WpChatroomMemberMutation) ResetWxid() {
  40569. m.wxid = nil
  40570. }
  40571. // SetNickname sets the "nickname" field.
  40572. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40573. m.nickname = &s
  40574. }
  40575. // Nickname returns the value of the "nickname" field in the mutation.
  40576. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40577. v := m.nickname
  40578. if v == nil {
  40579. return
  40580. }
  40581. return *v, true
  40582. }
  40583. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40584. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40586. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40587. if !m.op.Is(OpUpdateOne) {
  40588. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40589. }
  40590. if m.id == nil || m.oldValue == nil {
  40591. return v, errors.New("OldNickname requires an ID field in the mutation")
  40592. }
  40593. oldValue, err := m.oldValue(ctx)
  40594. if err != nil {
  40595. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40596. }
  40597. return oldValue.Nickname, nil
  40598. }
  40599. // ResetNickname resets all changes to the "nickname" field.
  40600. func (m *WpChatroomMemberMutation) ResetNickname() {
  40601. m.nickname = nil
  40602. }
  40603. // SetAvatar sets the "avatar" field.
  40604. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40605. m.avatar = &s
  40606. }
  40607. // Avatar returns the value of the "avatar" field in the mutation.
  40608. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40609. v := m.avatar
  40610. if v == nil {
  40611. return
  40612. }
  40613. return *v, true
  40614. }
  40615. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40616. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40618. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40619. if !m.op.Is(OpUpdateOne) {
  40620. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40621. }
  40622. if m.id == nil || m.oldValue == nil {
  40623. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40624. }
  40625. oldValue, err := m.oldValue(ctx)
  40626. if err != nil {
  40627. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40628. }
  40629. return oldValue.Avatar, nil
  40630. }
  40631. // ResetAvatar resets all changes to the "avatar" field.
  40632. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40633. m.avatar = nil
  40634. }
  40635. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40636. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40637. m.predicates = append(m.predicates, ps...)
  40638. }
  40639. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40640. // users can use type-assertion to append predicates that do not depend on any generated package.
  40641. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40642. p := make([]predicate.WpChatroomMember, len(ps))
  40643. for i := range ps {
  40644. p[i] = ps[i]
  40645. }
  40646. m.Where(p...)
  40647. }
  40648. // Op returns the operation name.
  40649. func (m *WpChatroomMemberMutation) Op() Op {
  40650. return m.op
  40651. }
  40652. // SetOp allows setting the mutation operation.
  40653. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40654. m.op = op
  40655. }
  40656. // Type returns the node type of this mutation (WpChatroomMember).
  40657. func (m *WpChatroomMemberMutation) Type() string {
  40658. return m.typ
  40659. }
  40660. // Fields returns all fields that were changed during this mutation. Note that in
  40661. // order to get all numeric fields that were incremented/decremented, call
  40662. // AddedFields().
  40663. func (m *WpChatroomMemberMutation) Fields() []string {
  40664. fields := make([]string, 0, 7)
  40665. if m.created_at != nil {
  40666. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40667. }
  40668. if m.updated_at != nil {
  40669. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40670. }
  40671. if m.status != nil {
  40672. fields = append(fields, wpchatroommember.FieldStatus)
  40673. }
  40674. if m.wx_wxid != nil {
  40675. fields = append(fields, wpchatroommember.FieldWxWxid)
  40676. }
  40677. if m.wxid != nil {
  40678. fields = append(fields, wpchatroommember.FieldWxid)
  40679. }
  40680. if m.nickname != nil {
  40681. fields = append(fields, wpchatroommember.FieldNickname)
  40682. }
  40683. if m.avatar != nil {
  40684. fields = append(fields, wpchatroommember.FieldAvatar)
  40685. }
  40686. return fields
  40687. }
  40688. // Field returns the value of a field with the given name. The second boolean
  40689. // return value indicates that this field was not set, or was not defined in the
  40690. // schema.
  40691. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40692. switch name {
  40693. case wpchatroommember.FieldCreatedAt:
  40694. return m.CreatedAt()
  40695. case wpchatroommember.FieldUpdatedAt:
  40696. return m.UpdatedAt()
  40697. case wpchatroommember.FieldStatus:
  40698. return m.Status()
  40699. case wpchatroommember.FieldWxWxid:
  40700. return m.WxWxid()
  40701. case wpchatroommember.FieldWxid:
  40702. return m.Wxid()
  40703. case wpchatroommember.FieldNickname:
  40704. return m.Nickname()
  40705. case wpchatroommember.FieldAvatar:
  40706. return m.Avatar()
  40707. }
  40708. return nil, false
  40709. }
  40710. // OldField returns the old value of the field from the database. An error is
  40711. // returned if the mutation operation is not UpdateOne, or the query to the
  40712. // database failed.
  40713. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40714. switch name {
  40715. case wpchatroommember.FieldCreatedAt:
  40716. return m.OldCreatedAt(ctx)
  40717. case wpchatroommember.FieldUpdatedAt:
  40718. return m.OldUpdatedAt(ctx)
  40719. case wpchatroommember.FieldStatus:
  40720. return m.OldStatus(ctx)
  40721. case wpchatroommember.FieldWxWxid:
  40722. return m.OldWxWxid(ctx)
  40723. case wpchatroommember.FieldWxid:
  40724. return m.OldWxid(ctx)
  40725. case wpchatroommember.FieldNickname:
  40726. return m.OldNickname(ctx)
  40727. case wpchatroommember.FieldAvatar:
  40728. return m.OldAvatar(ctx)
  40729. }
  40730. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40731. }
  40732. // SetField sets the value of a field with the given name. It returns an error if
  40733. // the field is not defined in the schema, or if the type mismatched the field
  40734. // type.
  40735. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40736. switch name {
  40737. case wpchatroommember.FieldCreatedAt:
  40738. v, ok := value.(time.Time)
  40739. if !ok {
  40740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40741. }
  40742. m.SetCreatedAt(v)
  40743. return nil
  40744. case wpchatroommember.FieldUpdatedAt:
  40745. v, ok := value.(time.Time)
  40746. if !ok {
  40747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40748. }
  40749. m.SetUpdatedAt(v)
  40750. return nil
  40751. case wpchatroommember.FieldStatus:
  40752. v, ok := value.(uint8)
  40753. if !ok {
  40754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40755. }
  40756. m.SetStatus(v)
  40757. return nil
  40758. case wpchatroommember.FieldWxWxid:
  40759. v, ok := value.(string)
  40760. if !ok {
  40761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40762. }
  40763. m.SetWxWxid(v)
  40764. return nil
  40765. case wpchatroommember.FieldWxid:
  40766. v, ok := value.(string)
  40767. if !ok {
  40768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40769. }
  40770. m.SetWxid(v)
  40771. return nil
  40772. case wpchatroommember.FieldNickname:
  40773. v, ok := value.(string)
  40774. if !ok {
  40775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40776. }
  40777. m.SetNickname(v)
  40778. return nil
  40779. case wpchatroommember.FieldAvatar:
  40780. v, ok := value.(string)
  40781. if !ok {
  40782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40783. }
  40784. m.SetAvatar(v)
  40785. return nil
  40786. }
  40787. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40788. }
  40789. // AddedFields returns all numeric fields that were incremented/decremented during
  40790. // this mutation.
  40791. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40792. var fields []string
  40793. if m.addstatus != nil {
  40794. fields = append(fields, wpchatroommember.FieldStatus)
  40795. }
  40796. return fields
  40797. }
  40798. // AddedField returns the numeric value that was incremented/decremented on a field
  40799. // with the given name. The second boolean return value indicates that this field
  40800. // was not set, or was not defined in the schema.
  40801. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40802. switch name {
  40803. case wpchatroommember.FieldStatus:
  40804. return m.AddedStatus()
  40805. }
  40806. return nil, false
  40807. }
  40808. // AddField adds the value to the field with the given name. It returns an error if
  40809. // the field is not defined in the schema, or if the type mismatched the field
  40810. // type.
  40811. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40812. switch name {
  40813. case wpchatroommember.FieldStatus:
  40814. v, ok := value.(int8)
  40815. if !ok {
  40816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40817. }
  40818. m.AddStatus(v)
  40819. return nil
  40820. }
  40821. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40822. }
  40823. // ClearedFields returns all nullable fields that were cleared during this
  40824. // mutation.
  40825. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40826. var fields []string
  40827. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40828. fields = append(fields, wpchatroommember.FieldStatus)
  40829. }
  40830. return fields
  40831. }
  40832. // FieldCleared returns a boolean indicating if a field with the given name was
  40833. // cleared in this mutation.
  40834. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40835. _, ok := m.clearedFields[name]
  40836. return ok
  40837. }
  40838. // ClearField clears the value of the field with the given name. It returns an
  40839. // error if the field is not defined in the schema.
  40840. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40841. switch name {
  40842. case wpchatroommember.FieldStatus:
  40843. m.ClearStatus()
  40844. return nil
  40845. }
  40846. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  40847. }
  40848. // ResetField resets all changes in the mutation for the field with the given name.
  40849. // It returns an error if the field is not defined in the schema.
  40850. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  40851. switch name {
  40852. case wpchatroommember.FieldCreatedAt:
  40853. m.ResetCreatedAt()
  40854. return nil
  40855. case wpchatroommember.FieldUpdatedAt:
  40856. m.ResetUpdatedAt()
  40857. return nil
  40858. case wpchatroommember.FieldStatus:
  40859. m.ResetStatus()
  40860. return nil
  40861. case wpchatroommember.FieldWxWxid:
  40862. m.ResetWxWxid()
  40863. return nil
  40864. case wpchatroommember.FieldWxid:
  40865. m.ResetWxid()
  40866. return nil
  40867. case wpchatroommember.FieldNickname:
  40868. m.ResetNickname()
  40869. return nil
  40870. case wpchatroommember.FieldAvatar:
  40871. m.ResetAvatar()
  40872. return nil
  40873. }
  40874. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40875. }
  40876. // AddedEdges returns all edge names that were set/added in this mutation.
  40877. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  40878. edges := make([]string, 0, 0)
  40879. return edges
  40880. }
  40881. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40882. // name in this mutation.
  40883. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  40884. return nil
  40885. }
  40886. // RemovedEdges returns all edge names that were removed in this mutation.
  40887. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  40888. edges := make([]string, 0, 0)
  40889. return edges
  40890. }
  40891. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40892. // the given name in this mutation.
  40893. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  40894. return nil
  40895. }
  40896. // ClearedEdges returns all edge names that were cleared in this mutation.
  40897. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  40898. edges := make([]string, 0, 0)
  40899. return edges
  40900. }
  40901. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40902. // was cleared in this mutation.
  40903. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  40904. return false
  40905. }
  40906. // ClearEdge clears the value of the edge with the given name. It returns an error
  40907. // if that edge is not defined in the schema.
  40908. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40909. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40910. }
  40911. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40912. // It returns an error if the edge is not defined in the schema.
  40913. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40914. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40915. }
  40916. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40917. type WxMutation struct {
  40918. config
  40919. op Op
  40920. typ string
  40921. id *uint64
  40922. created_at *time.Time
  40923. updated_at *time.Time
  40924. status *uint8
  40925. addstatus *int8
  40926. deleted_at *time.Time
  40927. port *string
  40928. process_id *string
  40929. callback *string
  40930. wxid *string
  40931. account *string
  40932. nickname *string
  40933. tel *string
  40934. head_big *string
  40935. organization_id *uint64
  40936. addorganization_id *int64
  40937. api_base *string
  40938. api_key *string
  40939. allow_list *[]string
  40940. appendallow_list []string
  40941. group_allow_list *[]string
  40942. appendgroup_allow_list []string
  40943. block_list *[]string
  40944. appendblock_list []string
  40945. group_block_list *[]string
  40946. appendgroup_block_list []string
  40947. ctype *uint64
  40948. addctype *int64
  40949. clearedFields map[string]struct{}
  40950. server *uint64
  40951. clearedserver bool
  40952. agent *uint64
  40953. clearedagent bool
  40954. done bool
  40955. oldValue func(context.Context) (*Wx, error)
  40956. predicates []predicate.Wx
  40957. }
  40958. var _ ent.Mutation = (*WxMutation)(nil)
  40959. // wxOption allows management of the mutation configuration using functional options.
  40960. type wxOption func(*WxMutation)
  40961. // newWxMutation creates new mutation for the Wx entity.
  40962. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  40963. m := &WxMutation{
  40964. config: c,
  40965. op: op,
  40966. typ: TypeWx,
  40967. clearedFields: make(map[string]struct{}),
  40968. }
  40969. for _, opt := range opts {
  40970. opt(m)
  40971. }
  40972. return m
  40973. }
  40974. // withWxID sets the ID field of the mutation.
  40975. func withWxID(id uint64) wxOption {
  40976. return func(m *WxMutation) {
  40977. var (
  40978. err error
  40979. once sync.Once
  40980. value *Wx
  40981. )
  40982. m.oldValue = func(ctx context.Context) (*Wx, error) {
  40983. once.Do(func() {
  40984. if m.done {
  40985. err = errors.New("querying old values post mutation is not allowed")
  40986. } else {
  40987. value, err = m.Client().Wx.Get(ctx, id)
  40988. }
  40989. })
  40990. return value, err
  40991. }
  40992. m.id = &id
  40993. }
  40994. }
  40995. // withWx sets the old Wx of the mutation.
  40996. func withWx(node *Wx) wxOption {
  40997. return func(m *WxMutation) {
  40998. m.oldValue = func(context.Context) (*Wx, error) {
  40999. return node, nil
  41000. }
  41001. m.id = &node.ID
  41002. }
  41003. }
  41004. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41005. // executed in a transaction (ent.Tx), a transactional client is returned.
  41006. func (m WxMutation) Client() *Client {
  41007. client := &Client{config: m.config}
  41008. client.init()
  41009. return client
  41010. }
  41011. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41012. // it returns an error otherwise.
  41013. func (m WxMutation) Tx() (*Tx, error) {
  41014. if _, ok := m.driver.(*txDriver); !ok {
  41015. return nil, errors.New("ent: mutation is not running in a transaction")
  41016. }
  41017. tx := &Tx{config: m.config}
  41018. tx.init()
  41019. return tx, nil
  41020. }
  41021. // SetID sets the value of the id field. Note that this
  41022. // operation is only accepted on creation of Wx entities.
  41023. func (m *WxMutation) SetID(id uint64) {
  41024. m.id = &id
  41025. }
  41026. // ID returns the ID value in the mutation. Note that the ID is only available
  41027. // if it was provided to the builder or after it was returned from the database.
  41028. func (m *WxMutation) ID() (id uint64, exists bool) {
  41029. if m.id == nil {
  41030. return
  41031. }
  41032. return *m.id, true
  41033. }
  41034. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41035. // That means, if the mutation is applied within a transaction with an isolation level such
  41036. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41037. // or updated by the mutation.
  41038. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41039. switch {
  41040. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41041. id, exists := m.ID()
  41042. if exists {
  41043. return []uint64{id}, nil
  41044. }
  41045. fallthrough
  41046. case m.op.Is(OpUpdate | OpDelete):
  41047. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41048. default:
  41049. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41050. }
  41051. }
  41052. // SetCreatedAt sets the "created_at" field.
  41053. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41054. m.created_at = &t
  41055. }
  41056. // CreatedAt returns the value of the "created_at" field in the mutation.
  41057. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41058. v := m.created_at
  41059. if v == nil {
  41060. return
  41061. }
  41062. return *v, true
  41063. }
  41064. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41065. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41067. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41068. if !m.op.Is(OpUpdateOne) {
  41069. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41070. }
  41071. if m.id == nil || m.oldValue == nil {
  41072. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41073. }
  41074. oldValue, err := m.oldValue(ctx)
  41075. if err != nil {
  41076. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41077. }
  41078. return oldValue.CreatedAt, nil
  41079. }
  41080. // ResetCreatedAt resets all changes to the "created_at" field.
  41081. func (m *WxMutation) ResetCreatedAt() {
  41082. m.created_at = nil
  41083. }
  41084. // SetUpdatedAt sets the "updated_at" field.
  41085. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41086. m.updated_at = &t
  41087. }
  41088. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41089. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41090. v := m.updated_at
  41091. if v == nil {
  41092. return
  41093. }
  41094. return *v, true
  41095. }
  41096. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41097. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41099. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41100. if !m.op.Is(OpUpdateOne) {
  41101. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41102. }
  41103. if m.id == nil || m.oldValue == nil {
  41104. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41105. }
  41106. oldValue, err := m.oldValue(ctx)
  41107. if err != nil {
  41108. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41109. }
  41110. return oldValue.UpdatedAt, nil
  41111. }
  41112. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41113. func (m *WxMutation) ResetUpdatedAt() {
  41114. m.updated_at = nil
  41115. }
  41116. // SetStatus sets the "status" field.
  41117. func (m *WxMutation) SetStatus(u uint8) {
  41118. m.status = &u
  41119. m.addstatus = nil
  41120. }
  41121. // Status returns the value of the "status" field in the mutation.
  41122. func (m *WxMutation) Status() (r uint8, exists bool) {
  41123. v := m.status
  41124. if v == nil {
  41125. return
  41126. }
  41127. return *v, true
  41128. }
  41129. // OldStatus returns the old "status" field's value of the Wx entity.
  41130. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41132. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41133. if !m.op.Is(OpUpdateOne) {
  41134. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41135. }
  41136. if m.id == nil || m.oldValue == nil {
  41137. return v, errors.New("OldStatus requires an ID field in the mutation")
  41138. }
  41139. oldValue, err := m.oldValue(ctx)
  41140. if err != nil {
  41141. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41142. }
  41143. return oldValue.Status, nil
  41144. }
  41145. // AddStatus adds u to the "status" field.
  41146. func (m *WxMutation) AddStatus(u int8) {
  41147. if m.addstatus != nil {
  41148. *m.addstatus += u
  41149. } else {
  41150. m.addstatus = &u
  41151. }
  41152. }
  41153. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41154. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41155. v := m.addstatus
  41156. if v == nil {
  41157. return
  41158. }
  41159. return *v, true
  41160. }
  41161. // ClearStatus clears the value of the "status" field.
  41162. func (m *WxMutation) ClearStatus() {
  41163. m.status = nil
  41164. m.addstatus = nil
  41165. m.clearedFields[wx.FieldStatus] = struct{}{}
  41166. }
  41167. // StatusCleared returns if the "status" field was cleared in this mutation.
  41168. func (m *WxMutation) StatusCleared() bool {
  41169. _, ok := m.clearedFields[wx.FieldStatus]
  41170. return ok
  41171. }
  41172. // ResetStatus resets all changes to the "status" field.
  41173. func (m *WxMutation) ResetStatus() {
  41174. m.status = nil
  41175. m.addstatus = nil
  41176. delete(m.clearedFields, wx.FieldStatus)
  41177. }
  41178. // SetDeletedAt sets the "deleted_at" field.
  41179. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41180. m.deleted_at = &t
  41181. }
  41182. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41183. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41184. v := m.deleted_at
  41185. if v == nil {
  41186. return
  41187. }
  41188. return *v, true
  41189. }
  41190. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41191. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41193. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41194. if !m.op.Is(OpUpdateOne) {
  41195. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41196. }
  41197. if m.id == nil || m.oldValue == nil {
  41198. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41199. }
  41200. oldValue, err := m.oldValue(ctx)
  41201. if err != nil {
  41202. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41203. }
  41204. return oldValue.DeletedAt, nil
  41205. }
  41206. // ClearDeletedAt clears the value of the "deleted_at" field.
  41207. func (m *WxMutation) ClearDeletedAt() {
  41208. m.deleted_at = nil
  41209. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41210. }
  41211. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41212. func (m *WxMutation) DeletedAtCleared() bool {
  41213. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41214. return ok
  41215. }
  41216. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41217. func (m *WxMutation) ResetDeletedAt() {
  41218. m.deleted_at = nil
  41219. delete(m.clearedFields, wx.FieldDeletedAt)
  41220. }
  41221. // SetServerID sets the "server_id" field.
  41222. func (m *WxMutation) SetServerID(u uint64) {
  41223. m.server = &u
  41224. }
  41225. // ServerID returns the value of the "server_id" field in the mutation.
  41226. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41227. v := m.server
  41228. if v == nil {
  41229. return
  41230. }
  41231. return *v, true
  41232. }
  41233. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41234. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41236. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41237. if !m.op.Is(OpUpdateOne) {
  41238. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41239. }
  41240. if m.id == nil || m.oldValue == nil {
  41241. return v, errors.New("OldServerID requires an ID field in the mutation")
  41242. }
  41243. oldValue, err := m.oldValue(ctx)
  41244. if err != nil {
  41245. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41246. }
  41247. return oldValue.ServerID, nil
  41248. }
  41249. // ClearServerID clears the value of the "server_id" field.
  41250. func (m *WxMutation) ClearServerID() {
  41251. m.server = nil
  41252. m.clearedFields[wx.FieldServerID] = struct{}{}
  41253. }
  41254. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41255. func (m *WxMutation) ServerIDCleared() bool {
  41256. _, ok := m.clearedFields[wx.FieldServerID]
  41257. return ok
  41258. }
  41259. // ResetServerID resets all changes to the "server_id" field.
  41260. func (m *WxMutation) ResetServerID() {
  41261. m.server = nil
  41262. delete(m.clearedFields, wx.FieldServerID)
  41263. }
  41264. // SetPort sets the "port" field.
  41265. func (m *WxMutation) SetPort(s string) {
  41266. m.port = &s
  41267. }
  41268. // Port returns the value of the "port" field in the mutation.
  41269. func (m *WxMutation) Port() (r string, exists bool) {
  41270. v := m.port
  41271. if v == nil {
  41272. return
  41273. }
  41274. return *v, true
  41275. }
  41276. // OldPort returns the old "port" field's value of the Wx entity.
  41277. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41279. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41280. if !m.op.Is(OpUpdateOne) {
  41281. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41282. }
  41283. if m.id == nil || m.oldValue == nil {
  41284. return v, errors.New("OldPort requires an ID field in the mutation")
  41285. }
  41286. oldValue, err := m.oldValue(ctx)
  41287. if err != nil {
  41288. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41289. }
  41290. return oldValue.Port, nil
  41291. }
  41292. // ResetPort resets all changes to the "port" field.
  41293. func (m *WxMutation) ResetPort() {
  41294. m.port = nil
  41295. }
  41296. // SetProcessID sets the "process_id" field.
  41297. func (m *WxMutation) SetProcessID(s string) {
  41298. m.process_id = &s
  41299. }
  41300. // ProcessID returns the value of the "process_id" field in the mutation.
  41301. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41302. v := m.process_id
  41303. if v == nil {
  41304. return
  41305. }
  41306. return *v, true
  41307. }
  41308. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41309. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41311. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41312. if !m.op.Is(OpUpdateOne) {
  41313. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41314. }
  41315. if m.id == nil || m.oldValue == nil {
  41316. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41317. }
  41318. oldValue, err := m.oldValue(ctx)
  41319. if err != nil {
  41320. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41321. }
  41322. return oldValue.ProcessID, nil
  41323. }
  41324. // ResetProcessID resets all changes to the "process_id" field.
  41325. func (m *WxMutation) ResetProcessID() {
  41326. m.process_id = nil
  41327. }
  41328. // SetCallback sets the "callback" field.
  41329. func (m *WxMutation) SetCallback(s string) {
  41330. m.callback = &s
  41331. }
  41332. // Callback returns the value of the "callback" field in the mutation.
  41333. func (m *WxMutation) Callback() (r string, exists bool) {
  41334. v := m.callback
  41335. if v == nil {
  41336. return
  41337. }
  41338. return *v, true
  41339. }
  41340. // OldCallback returns the old "callback" field's value of the Wx entity.
  41341. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41343. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41344. if !m.op.Is(OpUpdateOne) {
  41345. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41346. }
  41347. if m.id == nil || m.oldValue == nil {
  41348. return v, errors.New("OldCallback requires an ID field in the mutation")
  41349. }
  41350. oldValue, err := m.oldValue(ctx)
  41351. if err != nil {
  41352. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41353. }
  41354. return oldValue.Callback, nil
  41355. }
  41356. // ResetCallback resets all changes to the "callback" field.
  41357. func (m *WxMutation) ResetCallback() {
  41358. m.callback = nil
  41359. }
  41360. // SetWxid sets the "wxid" field.
  41361. func (m *WxMutation) SetWxid(s string) {
  41362. m.wxid = &s
  41363. }
  41364. // Wxid returns the value of the "wxid" field in the mutation.
  41365. func (m *WxMutation) Wxid() (r string, exists bool) {
  41366. v := m.wxid
  41367. if v == nil {
  41368. return
  41369. }
  41370. return *v, true
  41371. }
  41372. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41373. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41375. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41376. if !m.op.Is(OpUpdateOne) {
  41377. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41378. }
  41379. if m.id == nil || m.oldValue == nil {
  41380. return v, errors.New("OldWxid requires an ID field in the mutation")
  41381. }
  41382. oldValue, err := m.oldValue(ctx)
  41383. if err != nil {
  41384. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41385. }
  41386. return oldValue.Wxid, nil
  41387. }
  41388. // ResetWxid resets all changes to the "wxid" field.
  41389. func (m *WxMutation) ResetWxid() {
  41390. m.wxid = nil
  41391. }
  41392. // SetAccount sets the "account" field.
  41393. func (m *WxMutation) SetAccount(s string) {
  41394. m.account = &s
  41395. }
  41396. // Account returns the value of the "account" field in the mutation.
  41397. func (m *WxMutation) Account() (r string, exists bool) {
  41398. v := m.account
  41399. if v == nil {
  41400. return
  41401. }
  41402. return *v, true
  41403. }
  41404. // OldAccount returns the old "account" field's value of the Wx entity.
  41405. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41407. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41408. if !m.op.Is(OpUpdateOne) {
  41409. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41410. }
  41411. if m.id == nil || m.oldValue == nil {
  41412. return v, errors.New("OldAccount requires an ID field in the mutation")
  41413. }
  41414. oldValue, err := m.oldValue(ctx)
  41415. if err != nil {
  41416. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41417. }
  41418. return oldValue.Account, nil
  41419. }
  41420. // ResetAccount resets all changes to the "account" field.
  41421. func (m *WxMutation) ResetAccount() {
  41422. m.account = nil
  41423. }
  41424. // SetNickname sets the "nickname" field.
  41425. func (m *WxMutation) SetNickname(s string) {
  41426. m.nickname = &s
  41427. }
  41428. // Nickname returns the value of the "nickname" field in the mutation.
  41429. func (m *WxMutation) Nickname() (r string, exists bool) {
  41430. v := m.nickname
  41431. if v == nil {
  41432. return
  41433. }
  41434. return *v, true
  41435. }
  41436. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41437. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41439. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41440. if !m.op.Is(OpUpdateOne) {
  41441. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41442. }
  41443. if m.id == nil || m.oldValue == nil {
  41444. return v, errors.New("OldNickname requires an ID field in the mutation")
  41445. }
  41446. oldValue, err := m.oldValue(ctx)
  41447. if err != nil {
  41448. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41449. }
  41450. return oldValue.Nickname, nil
  41451. }
  41452. // ResetNickname resets all changes to the "nickname" field.
  41453. func (m *WxMutation) ResetNickname() {
  41454. m.nickname = nil
  41455. }
  41456. // SetTel sets the "tel" field.
  41457. func (m *WxMutation) SetTel(s string) {
  41458. m.tel = &s
  41459. }
  41460. // Tel returns the value of the "tel" field in the mutation.
  41461. func (m *WxMutation) Tel() (r string, exists bool) {
  41462. v := m.tel
  41463. if v == nil {
  41464. return
  41465. }
  41466. return *v, true
  41467. }
  41468. // OldTel returns the old "tel" field's value of the Wx entity.
  41469. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41471. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41472. if !m.op.Is(OpUpdateOne) {
  41473. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41474. }
  41475. if m.id == nil || m.oldValue == nil {
  41476. return v, errors.New("OldTel requires an ID field in the mutation")
  41477. }
  41478. oldValue, err := m.oldValue(ctx)
  41479. if err != nil {
  41480. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41481. }
  41482. return oldValue.Tel, nil
  41483. }
  41484. // ResetTel resets all changes to the "tel" field.
  41485. func (m *WxMutation) ResetTel() {
  41486. m.tel = nil
  41487. }
  41488. // SetHeadBig sets the "head_big" field.
  41489. func (m *WxMutation) SetHeadBig(s string) {
  41490. m.head_big = &s
  41491. }
  41492. // HeadBig returns the value of the "head_big" field in the mutation.
  41493. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41494. v := m.head_big
  41495. if v == nil {
  41496. return
  41497. }
  41498. return *v, true
  41499. }
  41500. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41501. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41503. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41504. if !m.op.Is(OpUpdateOne) {
  41505. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41506. }
  41507. if m.id == nil || m.oldValue == nil {
  41508. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41509. }
  41510. oldValue, err := m.oldValue(ctx)
  41511. if err != nil {
  41512. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41513. }
  41514. return oldValue.HeadBig, nil
  41515. }
  41516. // ResetHeadBig resets all changes to the "head_big" field.
  41517. func (m *WxMutation) ResetHeadBig() {
  41518. m.head_big = nil
  41519. }
  41520. // SetOrganizationID sets the "organization_id" field.
  41521. func (m *WxMutation) SetOrganizationID(u uint64) {
  41522. m.organization_id = &u
  41523. m.addorganization_id = nil
  41524. }
  41525. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41526. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41527. v := m.organization_id
  41528. if v == nil {
  41529. return
  41530. }
  41531. return *v, true
  41532. }
  41533. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41534. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41536. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41537. if !m.op.Is(OpUpdateOne) {
  41538. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41539. }
  41540. if m.id == nil || m.oldValue == nil {
  41541. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41542. }
  41543. oldValue, err := m.oldValue(ctx)
  41544. if err != nil {
  41545. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41546. }
  41547. return oldValue.OrganizationID, nil
  41548. }
  41549. // AddOrganizationID adds u to the "organization_id" field.
  41550. func (m *WxMutation) AddOrganizationID(u int64) {
  41551. if m.addorganization_id != nil {
  41552. *m.addorganization_id += u
  41553. } else {
  41554. m.addorganization_id = &u
  41555. }
  41556. }
  41557. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41558. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41559. v := m.addorganization_id
  41560. if v == nil {
  41561. return
  41562. }
  41563. return *v, true
  41564. }
  41565. // ClearOrganizationID clears the value of the "organization_id" field.
  41566. func (m *WxMutation) ClearOrganizationID() {
  41567. m.organization_id = nil
  41568. m.addorganization_id = nil
  41569. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41570. }
  41571. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41572. func (m *WxMutation) OrganizationIDCleared() bool {
  41573. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41574. return ok
  41575. }
  41576. // ResetOrganizationID resets all changes to the "organization_id" field.
  41577. func (m *WxMutation) ResetOrganizationID() {
  41578. m.organization_id = nil
  41579. m.addorganization_id = nil
  41580. delete(m.clearedFields, wx.FieldOrganizationID)
  41581. }
  41582. // SetAgentID sets the "agent_id" field.
  41583. func (m *WxMutation) SetAgentID(u uint64) {
  41584. m.agent = &u
  41585. }
  41586. // AgentID returns the value of the "agent_id" field in the mutation.
  41587. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41588. v := m.agent
  41589. if v == nil {
  41590. return
  41591. }
  41592. return *v, true
  41593. }
  41594. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41595. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41597. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41598. if !m.op.Is(OpUpdateOne) {
  41599. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41600. }
  41601. if m.id == nil || m.oldValue == nil {
  41602. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41603. }
  41604. oldValue, err := m.oldValue(ctx)
  41605. if err != nil {
  41606. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41607. }
  41608. return oldValue.AgentID, nil
  41609. }
  41610. // ResetAgentID resets all changes to the "agent_id" field.
  41611. func (m *WxMutation) ResetAgentID() {
  41612. m.agent = nil
  41613. }
  41614. // SetAPIBase sets the "api_base" field.
  41615. func (m *WxMutation) SetAPIBase(s string) {
  41616. m.api_base = &s
  41617. }
  41618. // APIBase returns the value of the "api_base" field in the mutation.
  41619. func (m *WxMutation) APIBase() (r string, exists bool) {
  41620. v := m.api_base
  41621. if v == nil {
  41622. return
  41623. }
  41624. return *v, true
  41625. }
  41626. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41627. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41629. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41630. if !m.op.Is(OpUpdateOne) {
  41631. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41632. }
  41633. if m.id == nil || m.oldValue == nil {
  41634. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41635. }
  41636. oldValue, err := m.oldValue(ctx)
  41637. if err != nil {
  41638. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41639. }
  41640. return oldValue.APIBase, nil
  41641. }
  41642. // ClearAPIBase clears the value of the "api_base" field.
  41643. func (m *WxMutation) ClearAPIBase() {
  41644. m.api_base = nil
  41645. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41646. }
  41647. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41648. func (m *WxMutation) APIBaseCleared() bool {
  41649. _, ok := m.clearedFields[wx.FieldAPIBase]
  41650. return ok
  41651. }
  41652. // ResetAPIBase resets all changes to the "api_base" field.
  41653. func (m *WxMutation) ResetAPIBase() {
  41654. m.api_base = nil
  41655. delete(m.clearedFields, wx.FieldAPIBase)
  41656. }
  41657. // SetAPIKey sets the "api_key" field.
  41658. func (m *WxMutation) SetAPIKey(s string) {
  41659. m.api_key = &s
  41660. }
  41661. // APIKey returns the value of the "api_key" field in the mutation.
  41662. func (m *WxMutation) APIKey() (r string, exists bool) {
  41663. v := m.api_key
  41664. if v == nil {
  41665. return
  41666. }
  41667. return *v, true
  41668. }
  41669. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41670. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41672. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41673. if !m.op.Is(OpUpdateOne) {
  41674. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41675. }
  41676. if m.id == nil || m.oldValue == nil {
  41677. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41678. }
  41679. oldValue, err := m.oldValue(ctx)
  41680. if err != nil {
  41681. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41682. }
  41683. return oldValue.APIKey, nil
  41684. }
  41685. // ClearAPIKey clears the value of the "api_key" field.
  41686. func (m *WxMutation) ClearAPIKey() {
  41687. m.api_key = nil
  41688. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41689. }
  41690. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41691. func (m *WxMutation) APIKeyCleared() bool {
  41692. _, ok := m.clearedFields[wx.FieldAPIKey]
  41693. return ok
  41694. }
  41695. // ResetAPIKey resets all changes to the "api_key" field.
  41696. func (m *WxMutation) ResetAPIKey() {
  41697. m.api_key = nil
  41698. delete(m.clearedFields, wx.FieldAPIKey)
  41699. }
  41700. // SetAllowList sets the "allow_list" field.
  41701. func (m *WxMutation) SetAllowList(s []string) {
  41702. m.allow_list = &s
  41703. m.appendallow_list = nil
  41704. }
  41705. // AllowList returns the value of the "allow_list" field in the mutation.
  41706. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41707. v := m.allow_list
  41708. if v == nil {
  41709. return
  41710. }
  41711. return *v, true
  41712. }
  41713. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41714. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41716. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41717. if !m.op.Is(OpUpdateOne) {
  41718. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41719. }
  41720. if m.id == nil || m.oldValue == nil {
  41721. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41722. }
  41723. oldValue, err := m.oldValue(ctx)
  41724. if err != nil {
  41725. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41726. }
  41727. return oldValue.AllowList, nil
  41728. }
  41729. // AppendAllowList adds s to the "allow_list" field.
  41730. func (m *WxMutation) AppendAllowList(s []string) {
  41731. m.appendallow_list = append(m.appendallow_list, s...)
  41732. }
  41733. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41734. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41735. if len(m.appendallow_list) == 0 {
  41736. return nil, false
  41737. }
  41738. return m.appendallow_list, true
  41739. }
  41740. // ResetAllowList resets all changes to the "allow_list" field.
  41741. func (m *WxMutation) ResetAllowList() {
  41742. m.allow_list = nil
  41743. m.appendallow_list = nil
  41744. }
  41745. // SetGroupAllowList sets the "group_allow_list" field.
  41746. func (m *WxMutation) SetGroupAllowList(s []string) {
  41747. m.group_allow_list = &s
  41748. m.appendgroup_allow_list = nil
  41749. }
  41750. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41751. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41752. v := m.group_allow_list
  41753. if v == nil {
  41754. return
  41755. }
  41756. return *v, true
  41757. }
  41758. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41759. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41761. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41762. if !m.op.Is(OpUpdateOne) {
  41763. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41764. }
  41765. if m.id == nil || m.oldValue == nil {
  41766. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41767. }
  41768. oldValue, err := m.oldValue(ctx)
  41769. if err != nil {
  41770. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41771. }
  41772. return oldValue.GroupAllowList, nil
  41773. }
  41774. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41775. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41776. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41777. }
  41778. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41779. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41780. if len(m.appendgroup_allow_list) == 0 {
  41781. return nil, false
  41782. }
  41783. return m.appendgroup_allow_list, true
  41784. }
  41785. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41786. func (m *WxMutation) ResetGroupAllowList() {
  41787. m.group_allow_list = nil
  41788. m.appendgroup_allow_list = nil
  41789. }
  41790. // SetBlockList sets the "block_list" field.
  41791. func (m *WxMutation) SetBlockList(s []string) {
  41792. m.block_list = &s
  41793. m.appendblock_list = nil
  41794. }
  41795. // BlockList returns the value of the "block_list" field in the mutation.
  41796. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41797. v := m.block_list
  41798. if v == nil {
  41799. return
  41800. }
  41801. return *v, true
  41802. }
  41803. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41804. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41806. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41807. if !m.op.Is(OpUpdateOne) {
  41808. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41809. }
  41810. if m.id == nil || m.oldValue == nil {
  41811. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41812. }
  41813. oldValue, err := m.oldValue(ctx)
  41814. if err != nil {
  41815. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41816. }
  41817. return oldValue.BlockList, nil
  41818. }
  41819. // AppendBlockList adds s to the "block_list" field.
  41820. func (m *WxMutation) AppendBlockList(s []string) {
  41821. m.appendblock_list = append(m.appendblock_list, s...)
  41822. }
  41823. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41824. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41825. if len(m.appendblock_list) == 0 {
  41826. return nil, false
  41827. }
  41828. return m.appendblock_list, true
  41829. }
  41830. // ResetBlockList resets all changes to the "block_list" field.
  41831. func (m *WxMutation) ResetBlockList() {
  41832. m.block_list = nil
  41833. m.appendblock_list = nil
  41834. }
  41835. // SetGroupBlockList sets the "group_block_list" field.
  41836. func (m *WxMutation) SetGroupBlockList(s []string) {
  41837. m.group_block_list = &s
  41838. m.appendgroup_block_list = nil
  41839. }
  41840. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41841. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41842. v := m.group_block_list
  41843. if v == nil {
  41844. return
  41845. }
  41846. return *v, true
  41847. }
  41848. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  41849. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41851. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41852. if !m.op.Is(OpUpdateOne) {
  41853. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41854. }
  41855. if m.id == nil || m.oldValue == nil {
  41856. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41857. }
  41858. oldValue, err := m.oldValue(ctx)
  41859. if err != nil {
  41860. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41861. }
  41862. return oldValue.GroupBlockList, nil
  41863. }
  41864. // AppendGroupBlockList adds s to the "group_block_list" field.
  41865. func (m *WxMutation) AppendGroupBlockList(s []string) {
  41866. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41867. }
  41868. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41869. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  41870. if len(m.appendgroup_block_list) == 0 {
  41871. return nil, false
  41872. }
  41873. return m.appendgroup_block_list, true
  41874. }
  41875. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41876. func (m *WxMutation) ResetGroupBlockList() {
  41877. m.group_block_list = nil
  41878. m.appendgroup_block_list = nil
  41879. }
  41880. // SetCtype sets the "ctype" field.
  41881. func (m *WxMutation) SetCtype(u uint64) {
  41882. m.ctype = &u
  41883. m.addctype = nil
  41884. }
  41885. // Ctype returns the value of the "ctype" field in the mutation.
  41886. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  41887. v := m.ctype
  41888. if v == nil {
  41889. return
  41890. }
  41891. return *v, true
  41892. }
  41893. // OldCtype returns the old "ctype" field's value of the Wx entity.
  41894. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41896. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  41897. if !m.op.Is(OpUpdateOne) {
  41898. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  41899. }
  41900. if m.id == nil || m.oldValue == nil {
  41901. return v, errors.New("OldCtype requires an ID field in the mutation")
  41902. }
  41903. oldValue, err := m.oldValue(ctx)
  41904. if err != nil {
  41905. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  41906. }
  41907. return oldValue.Ctype, nil
  41908. }
  41909. // AddCtype adds u to the "ctype" field.
  41910. func (m *WxMutation) AddCtype(u int64) {
  41911. if m.addctype != nil {
  41912. *m.addctype += u
  41913. } else {
  41914. m.addctype = &u
  41915. }
  41916. }
  41917. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  41918. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  41919. v := m.addctype
  41920. if v == nil {
  41921. return
  41922. }
  41923. return *v, true
  41924. }
  41925. // ClearCtype clears the value of the "ctype" field.
  41926. func (m *WxMutation) ClearCtype() {
  41927. m.ctype = nil
  41928. m.addctype = nil
  41929. m.clearedFields[wx.FieldCtype] = struct{}{}
  41930. }
  41931. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  41932. func (m *WxMutation) CtypeCleared() bool {
  41933. _, ok := m.clearedFields[wx.FieldCtype]
  41934. return ok
  41935. }
  41936. // ResetCtype resets all changes to the "ctype" field.
  41937. func (m *WxMutation) ResetCtype() {
  41938. m.ctype = nil
  41939. m.addctype = nil
  41940. delete(m.clearedFields, wx.FieldCtype)
  41941. }
  41942. // ClearServer clears the "server" edge to the Server entity.
  41943. func (m *WxMutation) ClearServer() {
  41944. m.clearedserver = true
  41945. m.clearedFields[wx.FieldServerID] = struct{}{}
  41946. }
  41947. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  41948. func (m *WxMutation) ServerCleared() bool {
  41949. return m.ServerIDCleared() || m.clearedserver
  41950. }
  41951. // ServerIDs returns the "server" edge IDs in the mutation.
  41952. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41953. // ServerID instead. It exists only for internal usage by the builders.
  41954. func (m *WxMutation) ServerIDs() (ids []uint64) {
  41955. if id := m.server; id != nil {
  41956. ids = append(ids, *id)
  41957. }
  41958. return
  41959. }
  41960. // ResetServer resets all changes to the "server" edge.
  41961. func (m *WxMutation) ResetServer() {
  41962. m.server = nil
  41963. m.clearedserver = false
  41964. }
  41965. // ClearAgent clears the "agent" edge to the Agent entity.
  41966. func (m *WxMutation) ClearAgent() {
  41967. m.clearedagent = true
  41968. m.clearedFields[wx.FieldAgentID] = struct{}{}
  41969. }
  41970. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41971. func (m *WxMutation) AgentCleared() bool {
  41972. return m.clearedagent
  41973. }
  41974. // AgentIDs returns the "agent" edge IDs in the mutation.
  41975. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41976. // AgentID instead. It exists only for internal usage by the builders.
  41977. func (m *WxMutation) AgentIDs() (ids []uint64) {
  41978. if id := m.agent; id != nil {
  41979. ids = append(ids, *id)
  41980. }
  41981. return
  41982. }
  41983. // ResetAgent resets all changes to the "agent" edge.
  41984. func (m *WxMutation) ResetAgent() {
  41985. m.agent = nil
  41986. m.clearedagent = false
  41987. }
  41988. // Where appends a list predicates to the WxMutation builder.
  41989. func (m *WxMutation) Where(ps ...predicate.Wx) {
  41990. m.predicates = append(m.predicates, ps...)
  41991. }
  41992. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  41993. // users can use type-assertion to append predicates that do not depend on any generated package.
  41994. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  41995. p := make([]predicate.Wx, len(ps))
  41996. for i := range ps {
  41997. p[i] = ps[i]
  41998. }
  41999. m.Where(p...)
  42000. }
  42001. // Op returns the operation name.
  42002. func (m *WxMutation) Op() Op {
  42003. return m.op
  42004. }
  42005. // SetOp allows setting the mutation operation.
  42006. func (m *WxMutation) SetOp(op Op) {
  42007. m.op = op
  42008. }
  42009. // Type returns the node type of this mutation (Wx).
  42010. func (m *WxMutation) Type() string {
  42011. return m.typ
  42012. }
  42013. // Fields returns all fields that were changed during this mutation. Note that in
  42014. // order to get all numeric fields that were incremented/decremented, call
  42015. // AddedFields().
  42016. func (m *WxMutation) Fields() []string {
  42017. fields := make([]string, 0, 22)
  42018. if m.created_at != nil {
  42019. fields = append(fields, wx.FieldCreatedAt)
  42020. }
  42021. if m.updated_at != nil {
  42022. fields = append(fields, wx.FieldUpdatedAt)
  42023. }
  42024. if m.status != nil {
  42025. fields = append(fields, wx.FieldStatus)
  42026. }
  42027. if m.deleted_at != nil {
  42028. fields = append(fields, wx.FieldDeletedAt)
  42029. }
  42030. if m.server != nil {
  42031. fields = append(fields, wx.FieldServerID)
  42032. }
  42033. if m.port != nil {
  42034. fields = append(fields, wx.FieldPort)
  42035. }
  42036. if m.process_id != nil {
  42037. fields = append(fields, wx.FieldProcessID)
  42038. }
  42039. if m.callback != nil {
  42040. fields = append(fields, wx.FieldCallback)
  42041. }
  42042. if m.wxid != nil {
  42043. fields = append(fields, wx.FieldWxid)
  42044. }
  42045. if m.account != nil {
  42046. fields = append(fields, wx.FieldAccount)
  42047. }
  42048. if m.nickname != nil {
  42049. fields = append(fields, wx.FieldNickname)
  42050. }
  42051. if m.tel != nil {
  42052. fields = append(fields, wx.FieldTel)
  42053. }
  42054. if m.head_big != nil {
  42055. fields = append(fields, wx.FieldHeadBig)
  42056. }
  42057. if m.organization_id != nil {
  42058. fields = append(fields, wx.FieldOrganizationID)
  42059. }
  42060. if m.agent != nil {
  42061. fields = append(fields, wx.FieldAgentID)
  42062. }
  42063. if m.api_base != nil {
  42064. fields = append(fields, wx.FieldAPIBase)
  42065. }
  42066. if m.api_key != nil {
  42067. fields = append(fields, wx.FieldAPIKey)
  42068. }
  42069. if m.allow_list != nil {
  42070. fields = append(fields, wx.FieldAllowList)
  42071. }
  42072. if m.group_allow_list != nil {
  42073. fields = append(fields, wx.FieldGroupAllowList)
  42074. }
  42075. if m.block_list != nil {
  42076. fields = append(fields, wx.FieldBlockList)
  42077. }
  42078. if m.group_block_list != nil {
  42079. fields = append(fields, wx.FieldGroupBlockList)
  42080. }
  42081. if m.ctype != nil {
  42082. fields = append(fields, wx.FieldCtype)
  42083. }
  42084. return fields
  42085. }
  42086. // Field returns the value of a field with the given name. The second boolean
  42087. // return value indicates that this field was not set, or was not defined in the
  42088. // schema.
  42089. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42090. switch name {
  42091. case wx.FieldCreatedAt:
  42092. return m.CreatedAt()
  42093. case wx.FieldUpdatedAt:
  42094. return m.UpdatedAt()
  42095. case wx.FieldStatus:
  42096. return m.Status()
  42097. case wx.FieldDeletedAt:
  42098. return m.DeletedAt()
  42099. case wx.FieldServerID:
  42100. return m.ServerID()
  42101. case wx.FieldPort:
  42102. return m.Port()
  42103. case wx.FieldProcessID:
  42104. return m.ProcessID()
  42105. case wx.FieldCallback:
  42106. return m.Callback()
  42107. case wx.FieldWxid:
  42108. return m.Wxid()
  42109. case wx.FieldAccount:
  42110. return m.Account()
  42111. case wx.FieldNickname:
  42112. return m.Nickname()
  42113. case wx.FieldTel:
  42114. return m.Tel()
  42115. case wx.FieldHeadBig:
  42116. return m.HeadBig()
  42117. case wx.FieldOrganizationID:
  42118. return m.OrganizationID()
  42119. case wx.FieldAgentID:
  42120. return m.AgentID()
  42121. case wx.FieldAPIBase:
  42122. return m.APIBase()
  42123. case wx.FieldAPIKey:
  42124. return m.APIKey()
  42125. case wx.FieldAllowList:
  42126. return m.AllowList()
  42127. case wx.FieldGroupAllowList:
  42128. return m.GroupAllowList()
  42129. case wx.FieldBlockList:
  42130. return m.BlockList()
  42131. case wx.FieldGroupBlockList:
  42132. return m.GroupBlockList()
  42133. case wx.FieldCtype:
  42134. return m.Ctype()
  42135. }
  42136. return nil, false
  42137. }
  42138. // OldField returns the old value of the field from the database. An error is
  42139. // returned if the mutation operation is not UpdateOne, or the query to the
  42140. // database failed.
  42141. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42142. switch name {
  42143. case wx.FieldCreatedAt:
  42144. return m.OldCreatedAt(ctx)
  42145. case wx.FieldUpdatedAt:
  42146. return m.OldUpdatedAt(ctx)
  42147. case wx.FieldStatus:
  42148. return m.OldStatus(ctx)
  42149. case wx.FieldDeletedAt:
  42150. return m.OldDeletedAt(ctx)
  42151. case wx.FieldServerID:
  42152. return m.OldServerID(ctx)
  42153. case wx.FieldPort:
  42154. return m.OldPort(ctx)
  42155. case wx.FieldProcessID:
  42156. return m.OldProcessID(ctx)
  42157. case wx.FieldCallback:
  42158. return m.OldCallback(ctx)
  42159. case wx.FieldWxid:
  42160. return m.OldWxid(ctx)
  42161. case wx.FieldAccount:
  42162. return m.OldAccount(ctx)
  42163. case wx.FieldNickname:
  42164. return m.OldNickname(ctx)
  42165. case wx.FieldTel:
  42166. return m.OldTel(ctx)
  42167. case wx.FieldHeadBig:
  42168. return m.OldHeadBig(ctx)
  42169. case wx.FieldOrganizationID:
  42170. return m.OldOrganizationID(ctx)
  42171. case wx.FieldAgentID:
  42172. return m.OldAgentID(ctx)
  42173. case wx.FieldAPIBase:
  42174. return m.OldAPIBase(ctx)
  42175. case wx.FieldAPIKey:
  42176. return m.OldAPIKey(ctx)
  42177. case wx.FieldAllowList:
  42178. return m.OldAllowList(ctx)
  42179. case wx.FieldGroupAllowList:
  42180. return m.OldGroupAllowList(ctx)
  42181. case wx.FieldBlockList:
  42182. return m.OldBlockList(ctx)
  42183. case wx.FieldGroupBlockList:
  42184. return m.OldGroupBlockList(ctx)
  42185. case wx.FieldCtype:
  42186. return m.OldCtype(ctx)
  42187. }
  42188. return nil, fmt.Errorf("unknown Wx field %s", name)
  42189. }
  42190. // SetField sets the value of a field with the given name. It returns an error if
  42191. // the field is not defined in the schema, or if the type mismatched the field
  42192. // type.
  42193. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42194. switch name {
  42195. case wx.FieldCreatedAt:
  42196. v, ok := value.(time.Time)
  42197. if !ok {
  42198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42199. }
  42200. m.SetCreatedAt(v)
  42201. return nil
  42202. case wx.FieldUpdatedAt:
  42203. v, ok := value.(time.Time)
  42204. if !ok {
  42205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42206. }
  42207. m.SetUpdatedAt(v)
  42208. return nil
  42209. case wx.FieldStatus:
  42210. v, ok := value.(uint8)
  42211. if !ok {
  42212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42213. }
  42214. m.SetStatus(v)
  42215. return nil
  42216. case wx.FieldDeletedAt:
  42217. v, ok := value.(time.Time)
  42218. if !ok {
  42219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42220. }
  42221. m.SetDeletedAt(v)
  42222. return nil
  42223. case wx.FieldServerID:
  42224. v, ok := value.(uint64)
  42225. if !ok {
  42226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42227. }
  42228. m.SetServerID(v)
  42229. return nil
  42230. case wx.FieldPort:
  42231. v, ok := value.(string)
  42232. if !ok {
  42233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42234. }
  42235. m.SetPort(v)
  42236. return nil
  42237. case wx.FieldProcessID:
  42238. v, ok := value.(string)
  42239. if !ok {
  42240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42241. }
  42242. m.SetProcessID(v)
  42243. return nil
  42244. case wx.FieldCallback:
  42245. v, ok := value.(string)
  42246. if !ok {
  42247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42248. }
  42249. m.SetCallback(v)
  42250. return nil
  42251. case wx.FieldWxid:
  42252. v, ok := value.(string)
  42253. if !ok {
  42254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42255. }
  42256. m.SetWxid(v)
  42257. return nil
  42258. case wx.FieldAccount:
  42259. v, ok := value.(string)
  42260. if !ok {
  42261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42262. }
  42263. m.SetAccount(v)
  42264. return nil
  42265. case wx.FieldNickname:
  42266. v, ok := value.(string)
  42267. if !ok {
  42268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42269. }
  42270. m.SetNickname(v)
  42271. return nil
  42272. case wx.FieldTel:
  42273. v, ok := value.(string)
  42274. if !ok {
  42275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42276. }
  42277. m.SetTel(v)
  42278. return nil
  42279. case wx.FieldHeadBig:
  42280. v, ok := value.(string)
  42281. if !ok {
  42282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42283. }
  42284. m.SetHeadBig(v)
  42285. return nil
  42286. case wx.FieldOrganizationID:
  42287. v, ok := value.(uint64)
  42288. if !ok {
  42289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42290. }
  42291. m.SetOrganizationID(v)
  42292. return nil
  42293. case wx.FieldAgentID:
  42294. v, ok := value.(uint64)
  42295. if !ok {
  42296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42297. }
  42298. m.SetAgentID(v)
  42299. return nil
  42300. case wx.FieldAPIBase:
  42301. v, ok := value.(string)
  42302. if !ok {
  42303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42304. }
  42305. m.SetAPIBase(v)
  42306. return nil
  42307. case wx.FieldAPIKey:
  42308. v, ok := value.(string)
  42309. if !ok {
  42310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42311. }
  42312. m.SetAPIKey(v)
  42313. return nil
  42314. case wx.FieldAllowList:
  42315. v, ok := value.([]string)
  42316. if !ok {
  42317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42318. }
  42319. m.SetAllowList(v)
  42320. return nil
  42321. case wx.FieldGroupAllowList:
  42322. v, ok := value.([]string)
  42323. if !ok {
  42324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42325. }
  42326. m.SetGroupAllowList(v)
  42327. return nil
  42328. case wx.FieldBlockList:
  42329. v, ok := value.([]string)
  42330. if !ok {
  42331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42332. }
  42333. m.SetBlockList(v)
  42334. return nil
  42335. case wx.FieldGroupBlockList:
  42336. v, ok := value.([]string)
  42337. if !ok {
  42338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42339. }
  42340. m.SetGroupBlockList(v)
  42341. return nil
  42342. case wx.FieldCtype:
  42343. v, ok := value.(uint64)
  42344. if !ok {
  42345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42346. }
  42347. m.SetCtype(v)
  42348. return nil
  42349. }
  42350. return fmt.Errorf("unknown Wx field %s", name)
  42351. }
  42352. // AddedFields returns all numeric fields that were incremented/decremented during
  42353. // this mutation.
  42354. func (m *WxMutation) AddedFields() []string {
  42355. var fields []string
  42356. if m.addstatus != nil {
  42357. fields = append(fields, wx.FieldStatus)
  42358. }
  42359. if m.addorganization_id != nil {
  42360. fields = append(fields, wx.FieldOrganizationID)
  42361. }
  42362. if m.addctype != nil {
  42363. fields = append(fields, wx.FieldCtype)
  42364. }
  42365. return fields
  42366. }
  42367. // AddedField returns the numeric value that was incremented/decremented on a field
  42368. // with the given name. The second boolean return value indicates that this field
  42369. // was not set, or was not defined in the schema.
  42370. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42371. switch name {
  42372. case wx.FieldStatus:
  42373. return m.AddedStatus()
  42374. case wx.FieldOrganizationID:
  42375. return m.AddedOrganizationID()
  42376. case wx.FieldCtype:
  42377. return m.AddedCtype()
  42378. }
  42379. return nil, false
  42380. }
  42381. // AddField adds the value to the field with the given name. It returns an error if
  42382. // the field is not defined in the schema, or if the type mismatched the field
  42383. // type.
  42384. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42385. switch name {
  42386. case wx.FieldStatus:
  42387. v, ok := value.(int8)
  42388. if !ok {
  42389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42390. }
  42391. m.AddStatus(v)
  42392. return nil
  42393. case wx.FieldOrganizationID:
  42394. v, ok := value.(int64)
  42395. if !ok {
  42396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42397. }
  42398. m.AddOrganizationID(v)
  42399. return nil
  42400. case wx.FieldCtype:
  42401. v, ok := value.(int64)
  42402. if !ok {
  42403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42404. }
  42405. m.AddCtype(v)
  42406. return nil
  42407. }
  42408. return fmt.Errorf("unknown Wx numeric field %s", name)
  42409. }
  42410. // ClearedFields returns all nullable fields that were cleared during this
  42411. // mutation.
  42412. func (m *WxMutation) ClearedFields() []string {
  42413. var fields []string
  42414. if m.FieldCleared(wx.FieldStatus) {
  42415. fields = append(fields, wx.FieldStatus)
  42416. }
  42417. if m.FieldCleared(wx.FieldDeletedAt) {
  42418. fields = append(fields, wx.FieldDeletedAt)
  42419. }
  42420. if m.FieldCleared(wx.FieldServerID) {
  42421. fields = append(fields, wx.FieldServerID)
  42422. }
  42423. if m.FieldCleared(wx.FieldOrganizationID) {
  42424. fields = append(fields, wx.FieldOrganizationID)
  42425. }
  42426. if m.FieldCleared(wx.FieldAPIBase) {
  42427. fields = append(fields, wx.FieldAPIBase)
  42428. }
  42429. if m.FieldCleared(wx.FieldAPIKey) {
  42430. fields = append(fields, wx.FieldAPIKey)
  42431. }
  42432. if m.FieldCleared(wx.FieldCtype) {
  42433. fields = append(fields, wx.FieldCtype)
  42434. }
  42435. return fields
  42436. }
  42437. // FieldCleared returns a boolean indicating if a field with the given name was
  42438. // cleared in this mutation.
  42439. func (m *WxMutation) FieldCleared(name string) bool {
  42440. _, ok := m.clearedFields[name]
  42441. return ok
  42442. }
  42443. // ClearField clears the value of the field with the given name. It returns an
  42444. // error if the field is not defined in the schema.
  42445. func (m *WxMutation) ClearField(name string) error {
  42446. switch name {
  42447. case wx.FieldStatus:
  42448. m.ClearStatus()
  42449. return nil
  42450. case wx.FieldDeletedAt:
  42451. m.ClearDeletedAt()
  42452. return nil
  42453. case wx.FieldServerID:
  42454. m.ClearServerID()
  42455. return nil
  42456. case wx.FieldOrganizationID:
  42457. m.ClearOrganizationID()
  42458. return nil
  42459. case wx.FieldAPIBase:
  42460. m.ClearAPIBase()
  42461. return nil
  42462. case wx.FieldAPIKey:
  42463. m.ClearAPIKey()
  42464. return nil
  42465. case wx.FieldCtype:
  42466. m.ClearCtype()
  42467. return nil
  42468. }
  42469. return fmt.Errorf("unknown Wx nullable field %s", name)
  42470. }
  42471. // ResetField resets all changes in the mutation for the field with the given name.
  42472. // It returns an error if the field is not defined in the schema.
  42473. func (m *WxMutation) ResetField(name string) error {
  42474. switch name {
  42475. case wx.FieldCreatedAt:
  42476. m.ResetCreatedAt()
  42477. return nil
  42478. case wx.FieldUpdatedAt:
  42479. m.ResetUpdatedAt()
  42480. return nil
  42481. case wx.FieldStatus:
  42482. m.ResetStatus()
  42483. return nil
  42484. case wx.FieldDeletedAt:
  42485. m.ResetDeletedAt()
  42486. return nil
  42487. case wx.FieldServerID:
  42488. m.ResetServerID()
  42489. return nil
  42490. case wx.FieldPort:
  42491. m.ResetPort()
  42492. return nil
  42493. case wx.FieldProcessID:
  42494. m.ResetProcessID()
  42495. return nil
  42496. case wx.FieldCallback:
  42497. m.ResetCallback()
  42498. return nil
  42499. case wx.FieldWxid:
  42500. m.ResetWxid()
  42501. return nil
  42502. case wx.FieldAccount:
  42503. m.ResetAccount()
  42504. return nil
  42505. case wx.FieldNickname:
  42506. m.ResetNickname()
  42507. return nil
  42508. case wx.FieldTel:
  42509. m.ResetTel()
  42510. return nil
  42511. case wx.FieldHeadBig:
  42512. m.ResetHeadBig()
  42513. return nil
  42514. case wx.FieldOrganizationID:
  42515. m.ResetOrganizationID()
  42516. return nil
  42517. case wx.FieldAgentID:
  42518. m.ResetAgentID()
  42519. return nil
  42520. case wx.FieldAPIBase:
  42521. m.ResetAPIBase()
  42522. return nil
  42523. case wx.FieldAPIKey:
  42524. m.ResetAPIKey()
  42525. return nil
  42526. case wx.FieldAllowList:
  42527. m.ResetAllowList()
  42528. return nil
  42529. case wx.FieldGroupAllowList:
  42530. m.ResetGroupAllowList()
  42531. return nil
  42532. case wx.FieldBlockList:
  42533. m.ResetBlockList()
  42534. return nil
  42535. case wx.FieldGroupBlockList:
  42536. m.ResetGroupBlockList()
  42537. return nil
  42538. case wx.FieldCtype:
  42539. m.ResetCtype()
  42540. return nil
  42541. }
  42542. return fmt.Errorf("unknown Wx field %s", name)
  42543. }
  42544. // AddedEdges returns all edge names that were set/added in this mutation.
  42545. func (m *WxMutation) AddedEdges() []string {
  42546. edges := make([]string, 0, 2)
  42547. if m.server != nil {
  42548. edges = append(edges, wx.EdgeServer)
  42549. }
  42550. if m.agent != nil {
  42551. edges = append(edges, wx.EdgeAgent)
  42552. }
  42553. return edges
  42554. }
  42555. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42556. // name in this mutation.
  42557. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42558. switch name {
  42559. case wx.EdgeServer:
  42560. if id := m.server; id != nil {
  42561. return []ent.Value{*id}
  42562. }
  42563. case wx.EdgeAgent:
  42564. if id := m.agent; id != nil {
  42565. return []ent.Value{*id}
  42566. }
  42567. }
  42568. return nil
  42569. }
  42570. // RemovedEdges returns all edge names that were removed in this mutation.
  42571. func (m *WxMutation) RemovedEdges() []string {
  42572. edges := make([]string, 0, 2)
  42573. return edges
  42574. }
  42575. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42576. // the given name in this mutation.
  42577. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42578. return nil
  42579. }
  42580. // ClearedEdges returns all edge names that were cleared in this mutation.
  42581. func (m *WxMutation) ClearedEdges() []string {
  42582. edges := make([]string, 0, 2)
  42583. if m.clearedserver {
  42584. edges = append(edges, wx.EdgeServer)
  42585. }
  42586. if m.clearedagent {
  42587. edges = append(edges, wx.EdgeAgent)
  42588. }
  42589. return edges
  42590. }
  42591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42592. // was cleared in this mutation.
  42593. func (m *WxMutation) EdgeCleared(name string) bool {
  42594. switch name {
  42595. case wx.EdgeServer:
  42596. return m.clearedserver
  42597. case wx.EdgeAgent:
  42598. return m.clearedagent
  42599. }
  42600. return false
  42601. }
  42602. // ClearEdge clears the value of the edge with the given name. It returns an error
  42603. // if that edge is not defined in the schema.
  42604. func (m *WxMutation) ClearEdge(name string) error {
  42605. switch name {
  42606. case wx.EdgeServer:
  42607. m.ClearServer()
  42608. return nil
  42609. case wx.EdgeAgent:
  42610. m.ClearAgent()
  42611. return nil
  42612. }
  42613. return fmt.Errorf("unknown Wx unique edge %s", name)
  42614. }
  42615. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42616. // It returns an error if the edge is not defined in the schema.
  42617. func (m *WxMutation) ResetEdge(name string) error {
  42618. switch name {
  42619. case wx.EdgeServer:
  42620. m.ResetServer()
  42621. return nil
  42622. case wx.EdgeAgent:
  42623. m.ResetAgent()
  42624. return nil
  42625. }
  42626. return fmt.Errorf("unknown Wx edge %s", name)
  42627. }
  42628. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42629. type WxCardMutation struct {
  42630. config
  42631. op Op
  42632. typ string
  42633. id *uint64
  42634. created_at *time.Time
  42635. updated_at *time.Time
  42636. deleted_at *time.Time
  42637. user_id *uint64
  42638. adduser_id *int64
  42639. wx_user_id *uint64
  42640. addwx_user_id *int64
  42641. avatar *string
  42642. logo *string
  42643. name *string
  42644. company *string
  42645. address *string
  42646. phone *string
  42647. official_account *string
  42648. wechat_account *string
  42649. email *string
  42650. api_base *string
  42651. api_key *string
  42652. ai_info *string
  42653. intro *string
  42654. clearedFields map[string]struct{}
  42655. done bool
  42656. oldValue func(context.Context) (*WxCard, error)
  42657. predicates []predicate.WxCard
  42658. }
  42659. var _ ent.Mutation = (*WxCardMutation)(nil)
  42660. // wxcardOption allows management of the mutation configuration using functional options.
  42661. type wxcardOption func(*WxCardMutation)
  42662. // newWxCardMutation creates new mutation for the WxCard entity.
  42663. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42664. m := &WxCardMutation{
  42665. config: c,
  42666. op: op,
  42667. typ: TypeWxCard,
  42668. clearedFields: make(map[string]struct{}),
  42669. }
  42670. for _, opt := range opts {
  42671. opt(m)
  42672. }
  42673. return m
  42674. }
  42675. // withWxCardID sets the ID field of the mutation.
  42676. func withWxCardID(id uint64) wxcardOption {
  42677. return func(m *WxCardMutation) {
  42678. var (
  42679. err error
  42680. once sync.Once
  42681. value *WxCard
  42682. )
  42683. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42684. once.Do(func() {
  42685. if m.done {
  42686. err = errors.New("querying old values post mutation is not allowed")
  42687. } else {
  42688. value, err = m.Client().WxCard.Get(ctx, id)
  42689. }
  42690. })
  42691. return value, err
  42692. }
  42693. m.id = &id
  42694. }
  42695. }
  42696. // withWxCard sets the old WxCard of the mutation.
  42697. func withWxCard(node *WxCard) wxcardOption {
  42698. return func(m *WxCardMutation) {
  42699. m.oldValue = func(context.Context) (*WxCard, error) {
  42700. return node, nil
  42701. }
  42702. m.id = &node.ID
  42703. }
  42704. }
  42705. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42706. // executed in a transaction (ent.Tx), a transactional client is returned.
  42707. func (m WxCardMutation) Client() *Client {
  42708. client := &Client{config: m.config}
  42709. client.init()
  42710. return client
  42711. }
  42712. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42713. // it returns an error otherwise.
  42714. func (m WxCardMutation) Tx() (*Tx, error) {
  42715. if _, ok := m.driver.(*txDriver); !ok {
  42716. return nil, errors.New("ent: mutation is not running in a transaction")
  42717. }
  42718. tx := &Tx{config: m.config}
  42719. tx.init()
  42720. return tx, nil
  42721. }
  42722. // SetID sets the value of the id field. Note that this
  42723. // operation is only accepted on creation of WxCard entities.
  42724. func (m *WxCardMutation) SetID(id uint64) {
  42725. m.id = &id
  42726. }
  42727. // ID returns the ID value in the mutation. Note that the ID is only available
  42728. // if it was provided to the builder or after it was returned from the database.
  42729. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42730. if m.id == nil {
  42731. return
  42732. }
  42733. return *m.id, true
  42734. }
  42735. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42736. // That means, if the mutation is applied within a transaction with an isolation level such
  42737. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42738. // or updated by the mutation.
  42739. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42740. switch {
  42741. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42742. id, exists := m.ID()
  42743. if exists {
  42744. return []uint64{id}, nil
  42745. }
  42746. fallthrough
  42747. case m.op.Is(OpUpdate | OpDelete):
  42748. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42749. default:
  42750. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42751. }
  42752. }
  42753. // SetCreatedAt sets the "created_at" field.
  42754. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42755. m.created_at = &t
  42756. }
  42757. // CreatedAt returns the value of the "created_at" field in the mutation.
  42758. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42759. v := m.created_at
  42760. if v == nil {
  42761. return
  42762. }
  42763. return *v, true
  42764. }
  42765. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42766. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42768. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42769. if !m.op.Is(OpUpdateOne) {
  42770. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42771. }
  42772. if m.id == nil || m.oldValue == nil {
  42773. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42774. }
  42775. oldValue, err := m.oldValue(ctx)
  42776. if err != nil {
  42777. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42778. }
  42779. return oldValue.CreatedAt, nil
  42780. }
  42781. // ResetCreatedAt resets all changes to the "created_at" field.
  42782. func (m *WxCardMutation) ResetCreatedAt() {
  42783. m.created_at = nil
  42784. }
  42785. // SetUpdatedAt sets the "updated_at" field.
  42786. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42787. m.updated_at = &t
  42788. }
  42789. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42790. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42791. v := m.updated_at
  42792. if v == nil {
  42793. return
  42794. }
  42795. return *v, true
  42796. }
  42797. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42798. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42800. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42801. if !m.op.Is(OpUpdateOne) {
  42802. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42803. }
  42804. if m.id == nil || m.oldValue == nil {
  42805. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42806. }
  42807. oldValue, err := m.oldValue(ctx)
  42808. if err != nil {
  42809. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42810. }
  42811. return oldValue.UpdatedAt, nil
  42812. }
  42813. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42814. func (m *WxCardMutation) ResetUpdatedAt() {
  42815. m.updated_at = nil
  42816. }
  42817. // SetDeletedAt sets the "deleted_at" field.
  42818. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42819. m.deleted_at = &t
  42820. }
  42821. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42822. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42823. v := m.deleted_at
  42824. if v == nil {
  42825. return
  42826. }
  42827. return *v, true
  42828. }
  42829. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42830. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42832. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42833. if !m.op.Is(OpUpdateOne) {
  42834. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42835. }
  42836. if m.id == nil || m.oldValue == nil {
  42837. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42838. }
  42839. oldValue, err := m.oldValue(ctx)
  42840. if err != nil {
  42841. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42842. }
  42843. return oldValue.DeletedAt, nil
  42844. }
  42845. // ClearDeletedAt clears the value of the "deleted_at" field.
  42846. func (m *WxCardMutation) ClearDeletedAt() {
  42847. m.deleted_at = nil
  42848. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  42849. }
  42850. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42851. func (m *WxCardMutation) DeletedAtCleared() bool {
  42852. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  42853. return ok
  42854. }
  42855. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42856. func (m *WxCardMutation) ResetDeletedAt() {
  42857. m.deleted_at = nil
  42858. delete(m.clearedFields, wxcard.FieldDeletedAt)
  42859. }
  42860. // SetUserID sets the "user_id" field.
  42861. func (m *WxCardMutation) SetUserID(u uint64) {
  42862. m.user_id = &u
  42863. m.adduser_id = nil
  42864. }
  42865. // UserID returns the value of the "user_id" field in the mutation.
  42866. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  42867. v := m.user_id
  42868. if v == nil {
  42869. return
  42870. }
  42871. return *v, true
  42872. }
  42873. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  42874. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42876. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42877. if !m.op.Is(OpUpdateOne) {
  42878. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42879. }
  42880. if m.id == nil || m.oldValue == nil {
  42881. return v, errors.New("OldUserID requires an ID field in the mutation")
  42882. }
  42883. oldValue, err := m.oldValue(ctx)
  42884. if err != nil {
  42885. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42886. }
  42887. return oldValue.UserID, nil
  42888. }
  42889. // AddUserID adds u to the "user_id" field.
  42890. func (m *WxCardMutation) AddUserID(u int64) {
  42891. if m.adduser_id != nil {
  42892. *m.adduser_id += u
  42893. } else {
  42894. m.adduser_id = &u
  42895. }
  42896. }
  42897. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42898. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  42899. v := m.adduser_id
  42900. if v == nil {
  42901. return
  42902. }
  42903. return *v, true
  42904. }
  42905. // ClearUserID clears the value of the "user_id" field.
  42906. func (m *WxCardMutation) ClearUserID() {
  42907. m.user_id = nil
  42908. m.adduser_id = nil
  42909. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  42910. }
  42911. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42912. func (m *WxCardMutation) UserIDCleared() bool {
  42913. _, ok := m.clearedFields[wxcard.FieldUserID]
  42914. return ok
  42915. }
  42916. // ResetUserID resets all changes to the "user_id" field.
  42917. func (m *WxCardMutation) ResetUserID() {
  42918. m.user_id = nil
  42919. m.adduser_id = nil
  42920. delete(m.clearedFields, wxcard.FieldUserID)
  42921. }
  42922. // SetWxUserID sets the "wx_user_id" field.
  42923. func (m *WxCardMutation) SetWxUserID(u uint64) {
  42924. m.wx_user_id = &u
  42925. m.addwx_user_id = nil
  42926. }
  42927. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  42928. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  42929. v := m.wx_user_id
  42930. if v == nil {
  42931. return
  42932. }
  42933. return *v, true
  42934. }
  42935. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  42936. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42938. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  42939. if !m.op.Is(OpUpdateOne) {
  42940. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  42941. }
  42942. if m.id == nil || m.oldValue == nil {
  42943. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  42944. }
  42945. oldValue, err := m.oldValue(ctx)
  42946. if err != nil {
  42947. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  42948. }
  42949. return oldValue.WxUserID, nil
  42950. }
  42951. // AddWxUserID adds u to the "wx_user_id" field.
  42952. func (m *WxCardMutation) AddWxUserID(u int64) {
  42953. if m.addwx_user_id != nil {
  42954. *m.addwx_user_id += u
  42955. } else {
  42956. m.addwx_user_id = &u
  42957. }
  42958. }
  42959. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  42960. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  42961. v := m.addwx_user_id
  42962. if v == nil {
  42963. return
  42964. }
  42965. return *v, true
  42966. }
  42967. // ClearWxUserID clears the value of the "wx_user_id" field.
  42968. func (m *WxCardMutation) ClearWxUserID() {
  42969. m.wx_user_id = nil
  42970. m.addwx_user_id = nil
  42971. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  42972. }
  42973. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  42974. func (m *WxCardMutation) WxUserIDCleared() bool {
  42975. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  42976. return ok
  42977. }
  42978. // ResetWxUserID resets all changes to the "wx_user_id" field.
  42979. func (m *WxCardMutation) ResetWxUserID() {
  42980. m.wx_user_id = nil
  42981. m.addwx_user_id = nil
  42982. delete(m.clearedFields, wxcard.FieldWxUserID)
  42983. }
  42984. // SetAvatar sets the "avatar" field.
  42985. func (m *WxCardMutation) SetAvatar(s string) {
  42986. m.avatar = &s
  42987. }
  42988. // Avatar returns the value of the "avatar" field in the mutation.
  42989. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  42990. v := m.avatar
  42991. if v == nil {
  42992. return
  42993. }
  42994. return *v, true
  42995. }
  42996. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  42997. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42999. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43000. if !m.op.Is(OpUpdateOne) {
  43001. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43002. }
  43003. if m.id == nil || m.oldValue == nil {
  43004. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43005. }
  43006. oldValue, err := m.oldValue(ctx)
  43007. if err != nil {
  43008. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43009. }
  43010. return oldValue.Avatar, nil
  43011. }
  43012. // ResetAvatar resets all changes to the "avatar" field.
  43013. func (m *WxCardMutation) ResetAvatar() {
  43014. m.avatar = nil
  43015. }
  43016. // SetLogo sets the "logo" field.
  43017. func (m *WxCardMutation) SetLogo(s string) {
  43018. m.logo = &s
  43019. }
  43020. // Logo returns the value of the "logo" field in the mutation.
  43021. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43022. v := m.logo
  43023. if v == nil {
  43024. return
  43025. }
  43026. return *v, true
  43027. }
  43028. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43029. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43031. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43032. if !m.op.Is(OpUpdateOne) {
  43033. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43034. }
  43035. if m.id == nil || m.oldValue == nil {
  43036. return v, errors.New("OldLogo requires an ID field in the mutation")
  43037. }
  43038. oldValue, err := m.oldValue(ctx)
  43039. if err != nil {
  43040. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43041. }
  43042. return oldValue.Logo, nil
  43043. }
  43044. // ResetLogo resets all changes to the "logo" field.
  43045. func (m *WxCardMutation) ResetLogo() {
  43046. m.logo = nil
  43047. }
  43048. // SetName sets the "name" field.
  43049. func (m *WxCardMutation) SetName(s string) {
  43050. m.name = &s
  43051. }
  43052. // Name returns the value of the "name" field in the mutation.
  43053. func (m *WxCardMutation) Name() (r string, exists bool) {
  43054. v := m.name
  43055. if v == nil {
  43056. return
  43057. }
  43058. return *v, true
  43059. }
  43060. // OldName returns the old "name" field's value of the WxCard entity.
  43061. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43063. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43064. if !m.op.Is(OpUpdateOne) {
  43065. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43066. }
  43067. if m.id == nil || m.oldValue == nil {
  43068. return v, errors.New("OldName requires an ID field in the mutation")
  43069. }
  43070. oldValue, err := m.oldValue(ctx)
  43071. if err != nil {
  43072. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43073. }
  43074. return oldValue.Name, nil
  43075. }
  43076. // ResetName resets all changes to the "name" field.
  43077. func (m *WxCardMutation) ResetName() {
  43078. m.name = nil
  43079. }
  43080. // SetCompany sets the "company" field.
  43081. func (m *WxCardMutation) SetCompany(s string) {
  43082. m.company = &s
  43083. }
  43084. // Company returns the value of the "company" field in the mutation.
  43085. func (m *WxCardMutation) Company() (r string, exists bool) {
  43086. v := m.company
  43087. if v == nil {
  43088. return
  43089. }
  43090. return *v, true
  43091. }
  43092. // OldCompany returns the old "company" field's value of the WxCard entity.
  43093. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43095. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43096. if !m.op.Is(OpUpdateOne) {
  43097. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43098. }
  43099. if m.id == nil || m.oldValue == nil {
  43100. return v, errors.New("OldCompany requires an ID field in the mutation")
  43101. }
  43102. oldValue, err := m.oldValue(ctx)
  43103. if err != nil {
  43104. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43105. }
  43106. return oldValue.Company, nil
  43107. }
  43108. // ResetCompany resets all changes to the "company" field.
  43109. func (m *WxCardMutation) ResetCompany() {
  43110. m.company = nil
  43111. }
  43112. // SetAddress sets the "address" field.
  43113. func (m *WxCardMutation) SetAddress(s string) {
  43114. m.address = &s
  43115. }
  43116. // Address returns the value of the "address" field in the mutation.
  43117. func (m *WxCardMutation) Address() (r string, exists bool) {
  43118. v := m.address
  43119. if v == nil {
  43120. return
  43121. }
  43122. return *v, true
  43123. }
  43124. // OldAddress returns the old "address" field's value of the WxCard entity.
  43125. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43127. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43128. if !m.op.Is(OpUpdateOne) {
  43129. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43130. }
  43131. if m.id == nil || m.oldValue == nil {
  43132. return v, errors.New("OldAddress requires an ID field in the mutation")
  43133. }
  43134. oldValue, err := m.oldValue(ctx)
  43135. if err != nil {
  43136. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43137. }
  43138. return oldValue.Address, nil
  43139. }
  43140. // ResetAddress resets all changes to the "address" field.
  43141. func (m *WxCardMutation) ResetAddress() {
  43142. m.address = nil
  43143. }
  43144. // SetPhone sets the "phone" field.
  43145. func (m *WxCardMutation) SetPhone(s string) {
  43146. m.phone = &s
  43147. }
  43148. // Phone returns the value of the "phone" field in the mutation.
  43149. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43150. v := m.phone
  43151. if v == nil {
  43152. return
  43153. }
  43154. return *v, true
  43155. }
  43156. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43157. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43159. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43160. if !m.op.Is(OpUpdateOne) {
  43161. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43162. }
  43163. if m.id == nil || m.oldValue == nil {
  43164. return v, errors.New("OldPhone requires an ID field in the mutation")
  43165. }
  43166. oldValue, err := m.oldValue(ctx)
  43167. if err != nil {
  43168. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43169. }
  43170. return oldValue.Phone, nil
  43171. }
  43172. // ResetPhone resets all changes to the "phone" field.
  43173. func (m *WxCardMutation) ResetPhone() {
  43174. m.phone = nil
  43175. }
  43176. // SetOfficialAccount sets the "official_account" field.
  43177. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43178. m.official_account = &s
  43179. }
  43180. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43181. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43182. v := m.official_account
  43183. if v == nil {
  43184. return
  43185. }
  43186. return *v, true
  43187. }
  43188. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43189. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43191. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43192. if !m.op.Is(OpUpdateOne) {
  43193. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43194. }
  43195. if m.id == nil || m.oldValue == nil {
  43196. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43197. }
  43198. oldValue, err := m.oldValue(ctx)
  43199. if err != nil {
  43200. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43201. }
  43202. return oldValue.OfficialAccount, nil
  43203. }
  43204. // ResetOfficialAccount resets all changes to the "official_account" field.
  43205. func (m *WxCardMutation) ResetOfficialAccount() {
  43206. m.official_account = nil
  43207. }
  43208. // SetWechatAccount sets the "wechat_account" field.
  43209. func (m *WxCardMutation) SetWechatAccount(s string) {
  43210. m.wechat_account = &s
  43211. }
  43212. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43213. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43214. v := m.wechat_account
  43215. if v == nil {
  43216. return
  43217. }
  43218. return *v, true
  43219. }
  43220. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43221. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43223. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43224. if !m.op.Is(OpUpdateOne) {
  43225. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43226. }
  43227. if m.id == nil || m.oldValue == nil {
  43228. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43229. }
  43230. oldValue, err := m.oldValue(ctx)
  43231. if err != nil {
  43232. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43233. }
  43234. return oldValue.WechatAccount, nil
  43235. }
  43236. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43237. func (m *WxCardMutation) ResetWechatAccount() {
  43238. m.wechat_account = nil
  43239. }
  43240. // SetEmail sets the "email" field.
  43241. func (m *WxCardMutation) SetEmail(s string) {
  43242. m.email = &s
  43243. }
  43244. // Email returns the value of the "email" field in the mutation.
  43245. func (m *WxCardMutation) Email() (r string, exists bool) {
  43246. v := m.email
  43247. if v == nil {
  43248. return
  43249. }
  43250. return *v, true
  43251. }
  43252. // OldEmail returns the old "email" field's value of the WxCard entity.
  43253. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43255. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43256. if !m.op.Is(OpUpdateOne) {
  43257. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43258. }
  43259. if m.id == nil || m.oldValue == nil {
  43260. return v, errors.New("OldEmail requires an ID field in the mutation")
  43261. }
  43262. oldValue, err := m.oldValue(ctx)
  43263. if err != nil {
  43264. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43265. }
  43266. return oldValue.Email, nil
  43267. }
  43268. // ClearEmail clears the value of the "email" field.
  43269. func (m *WxCardMutation) ClearEmail() {
  43270. m.email = nil
  43271. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43272. }
  43273. // EmailCleared returns if the "email" field was cleared in this mutation.
  43274. func (m *WxCardMutation) EmailCleared() bool {
  43275. _, ok := m.clearedFields[wxcard.FieldEmail]
  43276. return ok
  43277. }
  43278. // ResetEmail resets all changes to the "email" field.
  43279. func (m *WxCardMutation) ResetEmail() {
  43280. m.email = nil
  43281. delete(m.clearedFields, wxcard.FieldEmail)
  43282. }
  43283. // SetAPIBase sets the "api_base" field.
  43284. func (m *WxCardMutation) SetAPIBase(s string) {
  43285. m.api_base = &s
  43286. }
  43287. // APIBase returns the value of the "api_base" field in the mutation.
  43288. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43289. v := m.api_base
  43290. if v == nil {
  43291. return
  43292. }
  43293. return *v, true
  43294. }
  43295. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43296. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43298. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43299. if !m.op.Is(OpUpdateOne) {
  43300. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43301. }
  43302. if m.id == nil || m.oldValue == nil {
  43303. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43304. }
  43305. oldValue, err := m.oldValue(ctx)
  43306. if err != nil {
  43307. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43308. }
  43309. return oldValue.APIBase, nil
  43310. }
  43311. // ClearAPIBase clears the value of the "api_base" field.
  43312. func (m *WxCardMutation) ClearAPIBase() {
  43313. m.api_base = nil
  43314. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43315. }
  43316. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43317. func (m *WxCardMutation) APIBaseCleared() bool {
  43318. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43319. return ok
  43320. }
  43321. // ResetAPIBase resets all changes to the "api_base" field.
  43322. func (m *WxCardMutation) ResetAPIBase() {
  43323. m.api_base = nil
  43324. delete(m.clearedFields, wxcard.FieldAPIBase)
  43325. }
  43326. // SetAPIKey sets the "api_key" field.
  43327. func (m *WxCardMutation) SetAPIKey(s string) {
  43328. m.api_key = &s
  43329. }
  43330. // APIKey returns the value of the "api_key" field in the mutation.
  43331. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43332. v := m.api_key
  43333. if v == nil {
  43334. return
  43335. }
  43336. return *v, true
  43337. }
  43338. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43339. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43341. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43342. if !m.op.Is(OpUpdateOne) {
  43343. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43344. }
  43345. if m.id == nil || m.oldValue == nil {
  43346. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43347. }
  43348. oldValue, err := m.oldValue(ctx)
  43349. if err != nil {
  43350. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43351. }
  43352. return oldValue.APIKey, nil
  43353. }
  43354. // ClearAPIKey clears the value of the "api_key" field.
  43355. func (m *WxCardMutation) ClearAPIKey() {
  43356. m.api_key = nil
  43357. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43358. }
  43359. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43360. func (m *WxCardMutation) APIKeyCleared() bool {
  43361. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43362. return ok
  43363. }
  43364. // ResetAPIKey resets all changes to the "api_key" field.
  43365. func (m *WxCardMutation) ResetAPIKey() {
  43366. m.api_key = nil
  43367. delete(m.clearedFields, wxcard.FieldAPIKey)
  43368. }
  43369. // SetAiInfo sets the "ai_info" field.
  43370. func (m *WxCardMutation) SetAiInfo(s string) {
  43371. m.ai_info = &s
  43372. }
  43373. // AiInfo returns the value of the "ai_info" field in the mutation.
  43374. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43375. v := m.ai_info
  43376. if v == nil {
  43377. return
  43378. }
  43379. return *v, true
  43380. }
  43381. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43382. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43384. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43385. if !m.op.Is(OpUpdateOne) {
  43386. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43387. }
  43388. if m.id == nil || m.oldValue == nil {
  43389. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43390. }
  43391. oldValue, err := m.oldValue(ctx)
  43392. if err != nil {
  43393. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43394. }
  43395. return oldValue.AiInfo, nil
  43396. }
  43397. // ClearAiInfo clears the value of the "ai_info" field.
  43398. func (m *WxCardMutation) ClearAiInfo() {
  43399. m.ai_info = nil
  43400. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43401. }
  43402. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43403. func (m *WxCardMutation) AiInfoCleared() bool {
  43404. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43405. return ok
  43406. }
  43407. // ResetAiInfo resets all changes to the "ai_info" field.
  43408. func (m *WxCardMutation) ResetAiInfo() {
  43409. m.ai_info = nil
  43410. delete(m.clearedFields, wxcard.FieldAiInfo)
  43411. }
  43412. // SetIntro sets the "intro" field.
  43413. func (m *WxCardMutation) SetIntro(s string) {
  43414. m.intro = &s
  43415. }
  43416. // Intro returns the value of the "intro" field in the mutation.
  43417. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43418. v := m.intro
  43419. if v == nil {
  43420. return
  43421. }
  43422. return *v, true
  43423. }
  43424. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43425. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43427. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43428. if !m.op.Is(OpUpdateOne) {
  43429. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43430. }
  43431. if m.id == nil || m.oldValue == nil {
  43432. return v, errors.New("OldIntro requires an ID field in the mutation")
  43433. }
  43434. oldValue, err := m.oldValue(ctx)
  43435. if err != nil {
  43436. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43437. }
  43438. return oldValue.Intro, nil
  43439. }
  43440. // ClearIntro clears the value of the "intro" field.
  43441. func (m *WxCardMutation) ClearIntro() {
  43442. m.intro = nil
  43443. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43444. }
  43445. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43446. func (m *WxCardMutation) IntroCleared() bool {
  43447. _, ok := m.clearedFields[wxcard.FieldIntro]
  43448. return ok
  43449. }
  43450. // ResetIntro resets all changes to the "intro" field.
  43451. func (m *WxCardMutation) ResetIntro() {
  43452. m.intro = nil
  43453. delete(m.clearedFields, wxcard.FieldIntro)
  43454. }
  43455. // Where appends a list predicates to the WxCardMutation builder.
  43456. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43457. m.predicates = append(m.predicates, ps...)
  43458. }
  43459. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43460. // users can use type-assertion to append predicates that do not depend on any generated package.
  43461. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43462. p := make([]predicate.WxCard, len(ps))
  43463. for i := range ps {
  43464. p[i] = ps[i]
  43465. }
  43466. m.Where(p...)
  43467. }
  43468. // Op returns the operation name.
  43469. func (m *WxCardMutation) Op() Op {
  43470. return m.op
  43471. }
  43472. // SetOp allows setting the mutation operation.
  43473. func (m *WxCardMutation) SetOp(op Op) {
  43474. m.op = op
  43475. }
  43476. // Type returns the node type of this mutation (WxCard).
  43477. func (m *WxCardMutation) Type() string {
  43478. return m.typ
  43479. }
  43480. // Fields returns all fields that were changed during this mutation. Note that in
  43481. // order to get all numeric fields that were incremented/decremented, call
  43482. // AddedFields().
  43483. func (m *WxCardMutation) Fields() []string {
  43484. fields := make([]string, 0, 18)
  43485. if m.created_at != nil {
  43486. fields = append(fields, wxcard.FieldCreatedAt)
  43487. }
  43488. if m.updated_at != nil {
  43489. fields = append(fields, wxcard.FieldUpdatedAt)
  43490. }
  43491. if m.deleted_at != nil {
  43492. fields = append(fields, wxcard.FieldDeletedAt)
  43493. }
  43494. if m.user_id != nil {
  43495. fields = append(fields, wxcard.FieldUserID)
  43496. }
  43497. if m.wx_user_id != nil {
  43498. fields = append(fields, wxcard.FieldWxUserID)
  43499. }
  43500. if m.avatar != nil {
  43501. fields = append(fields, wxcard.FieldAvatar)
  43502. }
  43503. if m.logo != nil {
  43504. fields = append(fields, wxcard.FieldLogo)
  43505. }
  43506. if m.name != nil {
  43507. fields = append(fields, wxcard.FieldName)
  43508. }
  43509. if m.company != nil {
  43510. fields = append(fields, wxcard.FieldCompany)
  43511. }
  43512. if m.address != nil {
  43513. fields = append(fields, wxcard.FieldAddress)
  43514. }
  43515. if m.phone != nil {
  43516. fields = append(fields, wxcard.FieldPhone)
  43517. }
  43518. if m.official_account != nil {
  43519. fields = append(fields, wxcard.FieldOfficialAccount)
  43520. }
  43521. if m.wechat_account != nil {
  43522. fields = append(fields, wxcard.FieldWechatAccount)
  43523. }
  43524. if m.email != nil {
  43525. fields = append(fields, wxcard.FieldEmail)
  43526. }
  43527. if m.api_base != nil {
  43528. fields = append(fields, wxcard.FieldAPIBase)
  43529. }
  43530. if m.api_key != nil {
  43531. fields = append(fields, wxcard.FieldAPIKey)
  43532. }
  43533. if m.ai_info != nil {
  43534. fields = append(fields, wxcard.FieldAiInfo)
  43535. }
  43536. if m.intro != nil {
  43537. fields = append(fields, wxcard.FieldIntro)
  43538. }
  43539. return fields
  43540. }
  43541. // Field returns the value of a field with the given name. The second boolean
  43542. // return value indicates that this field was not set, or was not defined in the
  43543. // schema.
  43544. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43545. switch name {
  43546. case wxcard.FieldCreatedAt:
  43547. return m.CreatedAt()
  43548. case wxcard.FieldUpdatedAt:
  43549. return m.UpdatedAt()
  43550. case wxcard.FieldDeletedAt:
  43551. return m.DeletedAt()
  43552. case wxcard.FieldUserID:
  43553. return m.UserID()
  43554. case wxcard.FieldWxUserID:
  43555. return m.WxUserID()
  43556. case wxcard.FieldAvatar:
  43557. return m.Avatar()
  43558. case wxcard.FieldLogo:
  43559. return m.Logo()
  43560. case wxcard.FieldName:
  43561. return m.Name()
  43562. case wxcard.FieldCompany:
  43563. return m.Company()
  43564. case wxcard.FieldAddress:
  43565. return m.Address()
  43566. case wxcard.FieldPhone:
  43567. return m.Phone()
  43568. case wxcard.FieldOfficialAccount:
  43569. return m.OfficialAccount()
  43570. case wxcard.FieldWechatAccount:
  43571. return m.WechatAccount()
  43572. case wxcard.FieldEmail:
  43573. return m.Email()
  43574. case wxcard.FieldAPIBase:
  43575. return m.APIBase()
  43576. case wxcard.FieldAPIKey:
  43577. return m.APIKey()
  43578. case wxcard.FieldAiInfo:
  43579. return m.AiInfo()
  43580. case wxcard.FieldIntro:
  43581. return m.Intro()
  43582. }
  43583. return nil, false
  43584. }
  43585. // OldField returns the old value of the field from the database. An error is
  43586. // returned if the mutation operation is not UpdateOne, or the query to the
  43587. // database failed.
  43588. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43589. switch name {
  43590. case wxcard.FieldCreatedAt:
  43591. return m.OldCreatedAt(ctx)
  43592. case wxcard.FieldUpdatedAt:
  43593. return m.OldUpdatedAt(ctx)
  43594. case wxcard.FieldDeletedAt:
  43595. return m.OldDeletedAt(ctx)
  43596. case wxcard.FieldUserID:
  43597. return m.OldUserID(ctx)
  43598. case wxcard.FieldWxUserID:
  43599. return m.OldWxUserID(ctx)
  43600. case wxcard.FieldAvatar:
  43601. return m.OldAvatar(ctx)
  43602. case wxcard.FieldLogo:
  43603. return m.OldLogo(ctx)
  43604. case wxcard.FieldName:
  43605. return m.OldName(ctx)
  43606. case wxcard.FieldCompany:
  43607. return m.OldCompany(ctx)
  43608. case wxcard.FieldAddress:
  43609. return m.OldAddress(ctx)
  43610. case wxcard.FieldPhone:
  43611. return m.OldPhone(ctx)
  43612. case wxcard.FieldOfficialAccount:
  43613. return m.OldOfficialAccount(ctx)
  43614. case wxcard.FieldWechatAccount:
  43615. return m.OldWechatAccount(ctx)
  43616. case wxcard.FieldEmail:
  43617. return m.OldEmail(ctx)
  43618. case wxcard.FieldAPIBase:
  43619. return m.OldAPIBase(ctx)
  43620. case wxcard.FieldAPIKey:
  43621. return m.OldAPIKey(ctx)
  43622. case wxcard.FieldAiInfo:
  43623. return m.OldAiInfo(ctx)
  43624. case wxcard.FieldIntro:
  43625. return m.OldIntro(ctx)
  43626. }
  43627. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43628. }
  43629. // SetField sets the value of a field with the given name. It returns an error if
  43630. // the field is not defined in the schema, or if the type mismatched the field
  43631. // type.
  43632. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43633. switch name {
  43634. case wxcard.FieldCreatedAt:
  43635. v, ok := value.(time.Time)
  43636. if !ok {
  43637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43638. }
  43639. m.SetCreatedAt(v)
  43640. return nil
  43641. case wxcard.FieldUpdatedAt:
  43642. v, ok := value.(time.Time)
  43643. if !ok {
  43644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43645. }
  43646. m.SetUpdatedAt(v)
  43647. return nil
  43648. case wxcard.FieldDeletedAt:
  43649. v, ok := value.(time.Time)
  43650. if !ok {
  43651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43652. }
  43653. m.SetDeletedAt(v)
  43654. return nil
  43655. case wxcard.FieldUserID:
  43656. v, ok := value.(uint64)
  43657. if !ok {
  43658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43659. }
  43660. m.SetUserID(v)
  43661. return nil
  43662. case wxcard.FieldWxUserID:
  43663. v, ok := value.(uint64)
  43664. if !ok {
  43665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43666. }
  43667. m.SetWxUserID(v)
  43668. return nil
  43669. case wxcard.FieldAvatar:
  43670. v, ok := value.(string)
  43671. if !ok {
  43672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43673. }
  43674. m.SetAvatar(v)
  43675. return nil
  43676. case wxcard.FieldLogo:
  43677. v, ok := value.(string)
  43678. if !ok {
  43679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43680. }
  43681. m.SetLogo(v)
  43682. return nil
  43683. case wxcard.FieldName:
  43684. v, ok := value.(string)
  43685. if !ok {
  43686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43687. }
  43688. m.SetName(v)
  43689. return nil
  43690. case wxcard.FieldCompany:
  43691. v, ok := value.(string)
  43692. if !ok {
  43693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43694. }
  43695. m.SetCompany(v)
  43696. return nil
  43697. case wxcard.FieldAddress:
  43698. v, ok := value.(string)
  43699. if !ok {
  43700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43701. }
  43702. m.SetAddress(v)
  43703. return nil
  43704. case wxcard.FieldPhone:
  43705. v, ok := value.(string)
  43706. if !ok {
  43707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43708. }
  43709. m.SetPhone(v)
  43710. return nil
  43711. case wxcard.FieldOfficialAccount:
  43712. v, ok := value.(string)
  43713. if !ok {
  43714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43715. }
  43716. m.SetOfficialAccount(v)
  43717. return nil
  43718. case wxcard.FieldWechatAccount:
  43719. v, ok := value.(string)
  43720. if !ok {
  43721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43722. }
  43723. m.SetWechatAccount(v)
  43724. return nil
  43725. case wxcard.FieldEmail:
  43726. v, ok := value.(string)
  43727. if !ok {
  43728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43729. }
  43730. m.SetEmail(v)
  43731. return nil
  43732. case wxcard.FieldAPIBase:
  43733. v, ok := value.(string)
  43734. if !ok {
  43735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43736. }
  43737. m.SetAPIBase(v)
  43738. return nil
  43739. case wxcard.FieldAPIKey:
  43740. v, ok := value.(string)
  43741. if !ok {
  43742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43743. }
  43744. m.SetAPIKey(v)
  43745. return nil
  43746. case wxcard.FieldAiInfo:
  43747. v, ok := value.(string)
  43748. if !ok {
  43749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43750. }
  43751. m.SetAiInfo(v)
  43752. return nil
  43753. case wxcard.FieldIntro:
  43754. v, ok := value.(string)
  43755. if !ok {
  43756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43757. }
  43758. m.SetIntro(v)
  43759. return nil
  43760. }
  43761. return fmt.Errorf("unknown WxCard field %s", name)
  43762. }
  43763. // AddedFields returns all numeric fields that were incremented/decremented during
  43764. // this mutation.
  43765. func (m *WxCardMutation) AddedFields() []string {
  43766. var fields []string
  43767. if m.adduser_id != nil {
  43768. fields = append(fields, wxcard.FieldUserID)
  43769. }
  43770. if m.addwx_user_id != nil {
  43771. fields = append(fields, wxcard.FieldWxUserID)
  43772. }
  43773. return fields
  43774. }
  43775. // AddedField returns the numeric value that was incremented/decremented on a field
  43776. // with the given name. The second boolean return value indicates that this field
  43777. // was not set, or was not defined in the schema.
  43778. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43779. switch name {
  43780. case wxcard.FieldUserID:
  43781. return m.AddedUserID()
  43782. case wxcard.FieldWxUserID:
  43783. return m.AddedWxUserID()
  43784. }
  43785. return nil, false
  43786. }
  43787. // AddField adds the value to the field with the given name. It returns an error if
  43788. // the field is not defined in the schema, or if the type mismatched the field
  43789. // type.
  43790. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43791. switch name {
  43792. case wxcard.FieldUserID:
  43793. v, ok := value.(int64)
  43794. if !ok {
  43795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43796. }
  43797. m.AddUserID(v)
  43798. return nil
  43799. case wxcard.FieldWxUserID:
  43800. v, ok := value.(int64)
  43801. if !ok {
  43802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43803. }
  43804. m.AddWxUserID(v)
  43805. return nil
  43806. }
  43807. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43808. }
  43809. // ClearedFields returns all nullable fields that were cleared during this
  43810. // mutation.
  43811. func (m *WxCardMutation) ClearedFields() []string {
  43812. var fields []string
  43813. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43814. fields = append(fields, wxcard.FieldDeletedAt)
  43815. }
  43816. if m.FieldCleared(wxcard.FieldUserID) {
  43817. fields = append(fields, wxcard.FieldUserID)
  43818. }
  43819. if m.FieldCleared(wxcard.FieldWxUserID) {
  43820. fields = append(fields, wxcard.FieldWxUserID)
  43821. }
  43822. if m.FieldCleared(wxcard.FieldEmail) {
  43823. fields = append(fields, wxcard.FieldEmail)
  43824. }
  43825. if m.FieldCleared(wxcard.FieldAPIBase) {
  43826. fields = append(fields, wxcard.FieldAPIBase)
  43827. }
  43828. if m.FieldCleared(wxcard.FieldAPIKey) {
  43829. fields = append(fields, wxcard.FieldAPIKey)
  43830. }
  43831. if m.FieldCleared(wxcard.FieldAiInfo) {
  43832. fields = append(fields, wxcard.FieldAiInfo)
  43833. }
  43834. if m.FieldCleared(wxcard.FieldIntro) {
  43835. fields = append(fields, wxcard.FieldIntro)
  43836. }
  43837. return fields
  43838. }
  43839. // FieldCleared returns a boolean indicating if a field with the given name was
  43840. // cleared in this mutation.
  43841. func (m *WxCardMutation) FieldCleared(name string) bool {
  43842. _, ok := m.clearedFields[name]
  43843. return ok
  43844. }
  43845. // ClearField clears the value of the field with the given name. It returns an
  43846. // error if the field is not defined in the schema.
  43847. func (m *WxCardMutation) ClearField(name string) error {
  43848. switch name {
  43849. case wxcard.FieldDeletedAt:
  43850. m.ClearDeletedAt()
  43851. return nil
  43852. case wxcard.FieldUserID:
  43853. m.ClearUserID()
  43854. return nil
  43855. case wxcard.FieldWxUserID:
  43856. m.ClearWxUserID()
  43857. return nil
  43858. case wxcard.FieldEmail:
  43859. m.ClearEmail()
  43860. return nil
  43861. case wxcard.FieldAPIBase:
  43862. m.ClearAPIBase()
  43863. return nil
  43864. case wxcard.FieldAPIKey:
  43865. m.ClearAPIKey()
  43866. return nil
  43867. case wxcard.FieldAiInfo:
  43868. m.ClearAiInfo()
  43869. return nil
  43870. case wxcard.FieldIntro:
  43871. m.ClearIntro()
  43872. return nil
  43873. }
  43874. return fmt.Errorf("unknown WxCard nullable field %s", name)
  43875. }
  43876. // ResetField resets all changes in the mutation for the field with the given name.
  43877. // It returns an error if the field is not defined in the schema.
  43878. func (m *WxCardMutation) ResetField(name string) error {
  43879. switch name {
  43880. case wxcard.FieldCreatedAt:
  43881. m.ResetCreatedAt()
  43882. return nil
  43883. case wxcard.FieldUpdatedAt:
  43884. m.ResetUpdatedAt()
  43885. return nil
  43886. case wxcard.FieldDeletedAt:
  43887. m.ResetDeletedAt()
  43888. return nil
  43889. case wxcard.FieldUserID:
  43890. m.ResetUserID()
  43891. return nil
  43892. case wxcard.FieldWxUserID:
  43893. m.ResetWxUserID()
  43894. return nil
  43895. case wxcard.FieldAvatar:
  43896. m.ResetAvatar()
  43897. return nil
  43898. case wxcard.FieldLogo:
  43899. m.ResetLogo()
  43900. return nil
  43901. case wxcard.FieldName:
  43902. m.ResetName()
  43903. return nil
  43904. case wxcard.FieldCompany:
  43905. m.ResetCompany()
  43906. return nil
  43907. case wxcard.FieldAddress:
  43908. m.ResetAddress()
  43909. return nil
  43910. case wxcard.FieldPhone:
  43911. m.ResetPhone()
  43912. return nil
  43913. case wxcard.FieldOfficialAccount:
  43914. m.ResetOfficialAccount()
  43915. return nil
  43916. case wxcard.FieldWechatAccount:
  43917. m.ResetWechatAccount()
  43918. return nil
  43919. case wxcard.FieldEmail:
  43920. m.ResetEmail()
  43921. return nil
  43922. case wxcard.FieldAPIBase:
  43923. m.ResetAPIBase()
  43924. return nil
  43925. case wxcard.FieldAPIKey:
  43926. m.ResetAPIKey()
  43927. return nil
  43928. case wxcard.FieldAiInfo:
  43929. m.ResetAiInfo()
  43930. return nil
  43931. case wxcard.FieldIntro:
  43932. m.ResetIntro()
  43933. return nil
  43934. }
  43935. return fmt.Errorf("unknown WxCard field %s", name)
  43936. }
  43937. // AddedEdges returns all edge names that were set/added in this mutation.
  43938. func (m *WxCardMutation) AddedEdges() []string {
  43939. edges := make([]string, 0, 0)
  43940. return edges
  43941. }
  43942. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43943. // name in this mutation.
  43944. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  43945. return nil
  43946. }
  43947. // RemovedEdges returns all edge names that were removed in this mutation.
  43948. func (m *WxCardMutation) RemovedEdges() []string {
  43949. edges := make([]string, 0, 0)
  43950. return edges
  43951. }
  43952. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43953. // the given name in this mutation.
  43954. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  43955. return nil
  43956. }
  43957. // ClearedEdges returns all edge names that were cleared in this mutation.
  43958. func (m *WxCardMutation) ClearedEdges() []string {
  43959. edges := make([]string, 0, 0)
  43960. return edges
  43961. }
  43962. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43963. // was cleared in this mutation.
  43964. func (m *WxCardMutation) EdgeCleared(name string) bool {
  43965. return false
  43966. }
  43967. // ClearEdge clears the value of the edge with the given name. It returns an error
  43968. // if that edge is not defined in the schema.
  43969. func (m *WxCardMutation) ClearEdge(name string) error {
  43970. return fmt.Errorf("unknown WxCard unique edge %s", name)
  43971. }
  43972. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43973. // It returns an error if the edge is not defined in the schema.
  43974. func (m *WxCardMutation) ResetEdge(name string) error {
  43975. return fmt.Errorf("unknown WxCard edge %s", name)
  43976. }
  43977. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  43978. type WxCardUserMutation struct {
  43979. config
  43980. op Op
  43981. typ string
  43982. id *uint64
  43983. created_at *time.Time
  43984. updated_at *time.Time
  43985. deleted_at *time.Time
  43986. wxid *string
  43987. account *string
  43988. avatar *string
  43989. nickname *string
  43990. remark *string
  43991. phone *string
  43992. open_id *string
  43993. union_id *string
  43994. session_key *string
  43995. is_vip *int
  43996. addis_vip *int
  43997. clearedFields map[string]struct{}
  43998. done bool
  43999. oldValue func(context.Context) (*WxCardUser, error)
  44000. predicates []predicate.WxCardUser
  44001. }
  44002. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44003. // wxcarduserOption allows management of the mutation configuration using functional options.
  44004. type wxcarduserOption func(*WxCardUserMutation)
  44005. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44006. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44007. m := &WxCardUserMutation{
  44008. config: c,
  44009. op: op,
  44010. typ: TypeWxCardUser,
  44011. clearedFields: make(map[string]struct{}),
  44012. }
  44013. for _, opt := range opts {
  44014. opt(m)
  44015. }
  44016. return m
  44017. }
  44018. // withWxCardUserID sets the ID field of the mutation.
  44019. func withWxCardUserID(id uint64) wxcarduserOption {
  44020. return func(m *WxCardUserMutation) {
  44021. var (
  44022. err error
  44023. once sync.Once
  44024. value *WxCardUser
  44025. )
  44026. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44027. once.Do(func() {
  44028. if m.done {
  44029. err = errors.New("querying old values post mutation is not allowed")
  44030. } else {
  44031. value, err = m.Client().WxCardUser.Get(ctx, id)
  44032. }
  44033. })
  44034. return value, err
  44035. }
  44036. m.id = &id
  44037. }
  44038. }
  44039. // withWxCardUser sets the old WxCardUser of the mutation.
  44040. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44041. return func(m *WxCardUserMutation) {
  44042. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44043. return node, nil
  44044. }
  44045. m.id = &node.ID
  44046. }
  44047. }
  44048. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44049. // executed in a transaction (ent.Tx), a transactional client is returned.
  44050. func (m WxCardUserMutation) Client() *Client {
  44051. client := &Client{config: m.config}
  44052. client.init()
  44053. return client
  44054. }
  44055. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44056. // it returns an error otherwise.
  44057. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44058. if _, ok := m.driver.(*txDriver); !ok {
  44059. return nil, errors.New("ent: mutation is not running in a transaction")
  44060. }
  44061. tx := &Tx{config: m.config}
  44062. tx.init()
  44063. return tx, nil
  44064. }
  44065. // SetID sets the value of the id field. Note that this
  44066. // operation is only accepted on creation of WxCardUser entities.
  44067. func (m *WxCardUserMutation) SetID(id uint64) {
  44068. m.id = &id
  44069. }
  44070. // ID returns the ID value in the mutation. Note that the ID is only available
  44071. // if it was provided to the builder or after it was returned from the database.
  44072. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44073. if m.id == nil {
  44074. return
  44075. }
  44076. return *m.id, true
  44077. }
  44078. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44079. // That means, if the mutation is applied within a transaction with an isolation level such
  44080. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44081. // or updated by the mutation.
  44082. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44083. switch {
  44084. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44085. id, exists := m.ID()
  44086. if exists {
  44087. return []uint64{id}, nil
  44088. }
  44089. fallthrough
  44090. case m.op.Is(OpUpdate | OpDelete):
  44091. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44092. default:
  44093. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44094. }
  44095. }
  44096. // SetCreatedAt sets the "created_at" field.
  44097. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44098. m.created_at = &t
  44099. }
  44100. // CreatedAt returns the value of the "created_at" field in the mutation.
  44101. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44102. v := m.created_at
  44103. if v == nil {
  44104. return
  44105. }
  44106. return *v, true
  44107. }
  44108. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44109. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44111. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44112. if !m.op.Is(OpUpdateOne) {
  44113. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44114. }
  44115. if m.id == nil || m.oldValue == nil {
  44116. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44117. }
  44118. oldValue, err := m.oldValue(ctx)
  44119. if err != nil {
  44120. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44121. }
  44122. return oldValue.CreatedAt, nil
  44123. }
  44124. // ResetCreatedAt resets all changes to the "created_at" field.
  44125. func (m *WxCardUserMutation) ResetCreatedAt() {
  44126. m.created_at = nil
  44127. }
  44128. // SetUpdatedAt sets the "updated_at" field.
  44129. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44130. m.updated_at = &t
  44131. }
  44132. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44133. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44134. v := m.updated_at
  44135. if v == nil {
  44136. return
  44137. }
  44138. return *v, true
  44139. }
  44140. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44141. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44143. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44144. if !m.op.Is(OpUpdateOne) {
  44145. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44146. }
  44147. if m.id == nil || m.oldValue == nil {
  44148. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44149. }
  44150. oldValue, err := m.oldValue(ctx)
  44151. if err != nil {
  44152. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44153. }
  44154. return oldValue.UpdatedAt, nil
  44155. }
  44156. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44157. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44158. m.updated_at = nil
  44159. }
  44160. // SetDeletedAt sets the "deleted_at" field.
  44161. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44162. m.deleted_at = &t
  44163. }
  44164. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44165. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44166. v := m.deleted_at
  44167. if v == nil {
  44168. return
  44169. }
  44170. return *v, true
  44171. }
  44172. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44173. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44175. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44176. if !m.op.Is(OpUpdateOne) {
  44177. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44178. }
  44179. if m.id == nil || m.oldValue == nil {
  44180. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44181. }
  44182. oldValue, err := m.oldValue(ctx)
  44183. if err != nil {
  44184. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44185. }
  44186. return oldValue.DeletedAt, nil
  44187. }
  44188. // ClearDeletedAt clears the value of the "deleted_at" field.
  44189. func (m *WxCardUserMutation) ClearDeletedAt() {
  44190. m.deleted_at = nil
  44191. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44192. }
  44193. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44194. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44195. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44196. return ok
  44197. }
  44198. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44199. func (m *WxCardUserMutation) ResetDeletedAt() {
  44200. m.deleted_at = nil
  44201. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44202. }
  44203. // SetWxid sets the "wxid" field.
  44204. func (m *WxCardUserMutation) SetWxid(s string) {
  44205. m.wxid = &s
  44206. }
  44207. // Wxid returns the value of the "wxid" field in the mutation.
  44208. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44209. v := m.wxid
  44210. if v == nil {
  44211. return
  44212. }
  44213. return *v, true
  44214. }
  44215. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44216. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44218. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44219. if !m.op.Is(OpUpdateOne) {
  44220. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44221. }
  44222. if m.id == nil || m.oldValue == nil {
  44223. return v, errors.New("OldWxid requires an ID field in the mutation")
  44224. }
  44225. oldValue, err := m.oldValue(ctx)
  44226. if err != nil {
  44227. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44228. }
  44229. return oldValue.Wxid, nil
  44230. }
  44231. // ResetWxid resets all changes to the "wxid" field.
  44232. func (m *WxCardUserMutation) ResetWxid() {
  44233. m.wxid = nil
  44234. }
  44235. // SetAccount sets the "account" field.
  44236. func (m *WxCardUserMutation) SetAccount(s string) {
  44237. m.account = &s
  44238. }
  44239. // Account returns the value of the "account" field in the mutation.
  44240. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44241. v := m.account
  44242. if v == nil {
  44243. return
  44244. }
  44245. return *v, true
  44246. }
  44247. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44248. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44250. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44251. if !m.op.Is(OpUpdateOne) {
  44252. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44253. }
  44254. if m.id == nil || m.oldValue == nil {
  44255. return v, errors.New("OldAccount requires an ID field in the mutation")
  44256. }
  44257. oldValue, err := m.oldValue(ctx)
  44258. if err != nil {
  44259. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44260. }
  44261. return oldValue.Account, nil
  44262. }
  44263. // ResetAccount resets all changes to the "account" field.
  44264. func (m *WxCardUserMutation) ResetAccount() {
  44265. m.account = nil
  44266. }
  44267. // SetAvatar sets the "avatar" field.
  44268. func (m *WxCardUserMutation) SetAvatar(s string) {
  44269. m.avatar = &s
  44270. }
  44271. // Avatar returns the value of the "avatar" field in the mutation.
  44272. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44273. v := m.avatar
  44274. if v == nil {
  44275. return
  44276. }
  44277. return *v, true
  44278. }
  44279. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44280. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44282. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44283. if !m.op.Is(OpUpdateOne) {
  44284. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44285. }
  44286. if m.id == nil || m.oldValue == nil {
  44287. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44288. }
  44289. oldValue, err := m.oldValue(ctx)
  44290. if err != nil {
  44291. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44292. }
  44293. return oldValue.Avatar, nil
  44294. }
  44295. // ResetAvatar resets all changes to the "avatar" field.
  44296. func (m *WxCardUserMutation) ResetAvatar() {
  44297. m.avatar = nil
  44298. }
  44299. // SetNickname sets the "nickname" field.
  44300. func (m *WxCardUserMutation) SetNickname(s string) {
  44301. m.nickname = &s
  44302. }
  44303. // Nickname returns the value of the "nickname" field in the mutation.
  44304. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44305. v := m.nickname
  44306. if v == nil {
  44307. return
  44308. }
  44309. return *v, true
  44310. }
  44311. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44312. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44314. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44315. if !m.op.Is(OpUpdateOne) {
  44316. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44317. }
  44318. if m.id == nil || m.oldValue == nil {
  44319. return v, errors.New("OldNickname requires an ID field in the mutation")
  44320. }
  44321. oldValue, err := m.oldValue(ctx)
  44322. if err != nil {
  44323. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44324. }
  44325. return oldValue.Nickname, nil
  44326. }
  44327. // ResetNickname resets all changes to the "nickname" field.
  44328. func (m *WxCardUserMutation) ResetNickname() {
  44329. m.nickname = nil
  44330. }
  44331. // SetRemark sets the "remark" field.
  44332. func (m *WxCardUserMutation) SetRemark(s string) {
  44333. m.remark = &s
  44334. }
  44335. // Remark returns the value of the "remark" field in the mutation.
  44336. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44337. v := m.remark
  44338. if v == nil {
  44339. return
  44340. }
  44341. return *v, true
  44342. }
  44343. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44344. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44346. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44347. if !m.op.Is(OpUpdateOne) {
  44348. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44349. }
  44350. if m.id == nil || m.oldValue == nil {
  44351. return v, errors.New("OldRemark requires an ID field in the mutation")
  44352. }
  44353. oldValue, err := m.oldValue(ctx)
  44354. if err != nil {
  44355. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44356. }
  44357. return oldValue.Remark, nil
  44358. }
  44359. // ResetRemark resets all changes to the "remark" field.
  44360. func (m *WxCardUserMutation) ResetRemark() {
  44361. m.remark = nil
  44362. }
  44363. // SetPhone sets the "phone" field.
  44364. func (m *WxCardUserMutation) SetPhone(s string) {
  44365. m.phone = &s
  44366. }
  44367. // Phone returns the value of the "phone" field in the mutation.
  44368. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44369. v := m.phone
  44370. if v == nil {
  44371. return
  44372. }
  44373. return *v, true
  44374. }
  44375. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44376. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44378. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44379. if !m.op.Is(OpUpdateOne) {
  44380. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44381. }
  44382. if m.id == nil || m.oldValue == nil {
  44383. return v, errors.New("OldPhone requires an ID field in the mutation")
  44384. }
  44385. oldValue, err := m.oldValue(ctx)
  44386. if err != nil {
  44387. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44388. }
  44389. return oldValue.Phone, nil
  44390. }
  44391. // ResetPhone resets all changes to the "phone" field.
  44392. func (m *WxCardUserMutation) ResetPhone() {
  44393. m.phone = nil
  44394. }
  44395. // SetOpenID sets the "open_id" field.
  44396. func (m *WxCardUserMutation) SetOpenID(s string) {
  44397. m.open_id = &s
  44398. }
  44399. // OpenID returns the value of the "open_id" field in the mutation.
  44400. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44401. v := m.open_id
  44402. if v == nil {
  44403. return
  44404. }
  44405. return *v, true
  44406. }
  44407. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44408. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44410. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44411. if !m.op.Is(OpUpdateOne) {
  44412. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44413. }
  44414. if m.id == nil || m.oldValue == nil {
  44415. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44416. }
  44417. oldValue, err := m.oldValue(ctx)
  44418. if err != nil {
  44419. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44420. }
  44421. return oldValue.OpenID, nil
  44422. }
  44423. // ResetOpenID resets all changes to the "open_id" field.
  44424. func (m *WxCardUserMutation) ResetOpenID() {
  44425. m.open_id = nil
  44426. }
  44427. // SetUnionID sets the "union_id" field.
  44428. func (m *WxCardUserMutation) SetUnionID(s string) {
  44429. m.union_id = &s
  44430. }
  44431. // UnionID returns the value of the "union_id" field in the mutation.
  44432. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44433. v := m.union_id
  44434. if v == nil {
  44435. return
  44436. }
  44437. return *v, true
  44438. }
  44439. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44440. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44442. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44443. if !m.op.Is(OpUpdateOne) {
  44444. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44445. }
  44446. if m.id == nil || m.oldValue == nil {
  44447. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44448. }
  44449. oldValue, err := m.oldValue(ctx)
  44450. if err != nil {
  44451. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44452. }
  44453. return oldValue.UnionID, nil
  44454. }
  44455. // ResetUnionID resets all changes to the "union_id" field.
  44456. func (m *WxCardUserMutation) ResetUnionID() {
  44457. m.union_id = nil
  44458. }
  44459. // SetSessionKey sets the "session_key" field.
  44460. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44461. m.session_key = &s
  44462. }
  44463. // SessionKey returns the value of the "session_key" field in the mutation.
  44464. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44465. v := m.session_key
  44466. if v == nil {
  44467. return
  44468. }
  44469. return *v, true
  44470. }
  44471. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44472. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44474. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44475. if !m.op.Is(OpUpdateOne) {
  44476. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44477. }
  44478. if m.id == nil || m.oldValue == nil {
  44479. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44480. }
  44481. oldValue, err := m.oldValue(ctx)
  44482. if err != nil {
  44483. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44484. }
  44485. return oldValue.SessionKey, nil
  44486. }
  44487. // ResetSessionKey resets all changes to the "session_key" field.
  44488. func (m *WxCardUserMutation) ResetSessionKey() {
  44489. m.session_key = nil
  44490. }
  44491. // SetIsVip sets the "is_vip" field.
  44492. func (m *WxCardUserMutation) SetIsVip(i int) {
  44493. m.is_vip = &i
  44494. m.addis_vip = nil
  44495. }
  44496. // IsVip returns the value of the "is_vip" field in the mutation.
  44497. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44498. v := m.is_vip
  44499. if v == nil {
  44500. return
  44501. }
  44502. return *v, true
  44503. }
  44504. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44505. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44507. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44508. if !m.op.Is(OpUpdateOne) {
  44509. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44510. }
  44511. if m.id == nil || m.oldValue == nil {
  44512. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44513. }
  44514. oldValue, err := m.oldValue(ctx)
  44515. if err != nil {
  44516. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44517. }
  44518. return oldValue.IsVip, nil
  44519. }
  44520. // AddIsVip adds i to the "is_vip" field.
  44521. func (m *WxCardUserMutation) AddIsVip(i int) {
  44522. if m.addis_vip != nil {
  44523. *m.addis_vip += i
  44524. } else {
  44525. m.addis_vip = &i
  44526. }
  44527. }
  44528. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44529. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44530. v := m.addis_vip
  44531. if v == nil {
  44532. return
  44533. }
  44534. return *v, true
  44535. }
  44536. // ResetIsVip resets all changes to the "is_vip" field.
  44537. func (m *WxCardUserMutation) ResetIsVip() {
  44538. m.is_vip = nil
  44539. m.addis_vip = nil
  44540. }
  44541. // Where appends a list predicates to the WxCardUserMutation builder.
  44542. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44543. m.predicates = append(m.predicates, ps...)
  44544. }
  44545. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44546. // users can use type-assertion to append predicates that do not depend on any generated package.
  44547. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44548. p := make([]predicate.WxCardUser, len(ps))
  44549. for i := range ps {
  44550. p[i] = ps[i]
  44551. }
  44552. m.Where(p...)
  44553. }
  44554. // Op returns the operation name.
  44555. func (m *WxCardUserMutation) Op() Op {
  44556. return m.op
  44557. }
  44558. // SetOp allows setting the mutation operation.
  44559. func (m *WxCardUserMutation) SetOp(op Op) {
  44560. m.op = op
  44561. }
  44562. // Type returns the node type of this mutation (WxCardUser).
  44563. func (m *WxCardUserMutation) Type() string {
  44564. return m.typ
  44565. }
  44566. // Fields returns all fields that were changed during this mutation. Note that in
  44567. // order to get all numeric fields that were incremented/decremented, call
  44568. // AddedFields().
  44569. func (m *WxCardUserMutation) Fields() []string {
  44570. fields := make([]string, 0, 13)
  44571. if m.created_at != nil {
  44572. fields = append(fields, wxcarduser.FieldCreatedAt)
  44573. }
  44574. if m.updated_at != nil {
  44575. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44576. }
  44577. if m.deleted_at != nil {
  44578. fields = append(fields, wxcarduser.FieldDeletedAt)
  44579. }
  44580. if m.wxid != nil {
  44581. fields = append(fields, wxcarduser.FieldWxid)
  44582. }
  44583. if m.account != nil {
  44584. fields = append(fields, wxcarduser.FieldAccount)
  44585. }
  44586. if m.avatar != nil {
  44587. fields = append(fields, wxcarduser.FieldAvatar)
  44588. }
  44589. if m.nickname != nil {
  44590. fields = append(fields, wxcarduser.FieldNickname)
  44591. }
  44592. if m.remark != nil {
  44593. fields = append(fields, wxcarduser.FieldRemark)
  44594. }
  44595. if m.phone != nil {
  44596. fields = append(fields, wxcarduser.FieldPhone)
  44597. }
  44598. if m.open_id != nil {
  44599. fields = append(fields, wxcarduser.FieldOpenID)
  44600. }
  44601. if m.union_id != nil {
  44602. fields = append(fields, wxcarduser.FieldUnionID)
  44603. }
  44604. if m.session_key != nil {
  44605. fields = append(fields, wxcarduser.FieldSessionKey)
  44606. }
  44607. if m.is_vip != nil {
  44608. fields = append(fields, wxcarduser.FieldIsVip)
  44609. }
  44610. return fields
  44611. }
  44612. // Field returns the value of a field with the given name. The second boolean
  44613. // return value indicates that this field was not set, or was not defined in the
  44614. // schema.
  44615. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44616. switch name {
  44617. case wxcarduser.FieldCreatedAt:
  44618. return m.CreatedAt()
  44619. case wxcarduser.FieldUpdatedAt:
  44620. return m.UpdatedAt()
  44621. case wxcarduser.FieldDeletedAt:
  44622. return m.DeletedAt()
  44623. case wxcarduser.FieldWxid:
  44624. return m.Wxid()
  44625. case wxcarduser.FieldAccount:
  44626. return m.Account()
  44627. case wxcarduser.FieldAvatar:
  44628. return m.Avatar()
  44629. case wxcarduser.FieldNickname:
  44630. return m.Nickname()
  44631. case wxcarduser.FieldRemark:
  44632. return m.Remark()
  44633. case wxcarduser.FieldPhone:
  44634. return m.Phone()
  44635. case wxcarduser.FieldOpenID:
  44636. return m.OpenID()
  44637. case wxcarduser.FieldUnionID:
  44638. return m.UnionID()
  44639. case wxcarduser.FieldSessionKey:
  44640. return m.SessionKey()
  44641. case wxcarduser.FieldIsVip:
  44642. return m.IsVip()
  44643. }
  44644. return nil, false
  44645. }
  44646. // OldField returns the old value of the field from the database. An error is
  44647. // returned if the mutation operation is not UpdateOne, or the query to the
  44648. // database failed.
  44649. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44650. switch name {
  44651. case wxcarduser.FieldCreatedAt:
  44652. return m.OldCreatedAt(ctx)
  44653. case wxcarduser.FieldUpdatedAt:
  44654. return m.OldUpdatedAt(ctx)
  44655. case wxcarduser.FieldDeletedAt:
  44656. return m.OldDeletedAt(ctx)
  44657. case wxcarduser.FieldWxid:
  44658. return m.OldWxid(ctx)
  44659. case wxcarduser.FieldAccount:
  44660. return m.OldAccount(ctx)
  44661. case wxcarduser.FieldAvatar:
  44662. return m.OldAvatar(ctx)
  44663. case wxcarduser.FieldNickname:
  44664. return m.OldNickname(ctx)
  44665. case wxcarduser.FieldRemark:
  44666. return m.OldRemark(ctx)
  44667. case wxcarduser.FieldPhone:
  44668. return m.OldPhone(ctx)
  44669. case wxcarduser.FieldOpenID:
  44670. return m.OldOpenID(ctx)
  44671. case wxcarduser.FieldUnionID:
  44672. return m.OldUnionID(ctx)
  44673. case wxcarduser.FieldSessionKey:
  44674. return m.OldSessionKey(ctx)
  44675. case wxcarduser.FieldIsVip:
  44676. return m.OldIsVip(ctx)
  44677. }
  44678. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44679. }
  44680. // SetField sets the value of a field with the given name. It returns an error if
  44681. // the field is not defined in the schema, or if the type mismatched the field
  44682. // type.
  44683. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44684. switch name {
  44685. case wxcarduser.FieldCreatedAt:
  44686. v, ok := value.(time.Time)
  44687. if !ok {
  44688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44689. }
  44690. m.SetCreatedAt(v)
  44691. return nil
  44692. case wxcarduser.FieldUpdatedAt:
  44693. v, ok := value.(time.Time)
  44694. if !ok {
  44695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44696. }
  44697. m.SetUpdatedAt(v)
  44698. return nil
  44699. case wxcarduser.FieldDeletedAt:
  44700. v, ok := value.(time.Time)
  44701. if !ok {
  44702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44703. }
  44704. m.SetDeletedAt(v)
  44705. return nil
  44706. case wxcarduser.FieldWxid:
  44707. v, ok := value.(string)
  44708. if !ok {
  44709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44710. }
  44711. m.SetWxid(v)
  44712. return nil
  44713. case wxcarduser.FieldAccount:
  44714. v, ok := value.(string)
  44715. if !ok {
  44716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44717. }
  44718. m.SetAccount(v)
  44719. return nil
  44720. case wxcarduser.FieldAvatar:
  44721. v, ok := value.(string)
  44722. if !ok {
  44723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44724. }
  44725. m.SetAvatar(v)
  44726. return nil
  44727. case wxcarduser.FieldNickname:
  44728. v, ok := value.(string)
  44729. if !ok {
  44730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44731. }
  44732. m.SetNickname(v)
  44733. return nil
  44734. case wxcarduser.FieldRemark:
  44735. v, ok := value.(string)
  44736. if !ok {
  44737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44738. }
  44739. m.SetRemark(v)
  44740. return nil
  44741. case wxcarduser.FieldPhone:
  44742. v, ok := value.(string)
  44743. if !ok {
  44744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44745. }
  44746. m.SetPhone(v)
  44747. return nil
  44748. case wxcarduser.FieldOpenID:
  44749. v, ok := value.(string)
  44750. if !ok {
  44751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44752. }
  44753. m.SetOpenID(v)
  44754. return nil
  44755. case wxcarduser.FieldUnionID:
  44756. v, ok := value.(string)
  44757. if !ok {
  44758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44759. }
  44760. m.SetUnionID(v)
  44761. return nil
  44762. case wxcarduser.FieldSessionKey:
  44763. v, ok := value.(string)
  44764. if !ok {
  44765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44766. }
  44767. m.SetSessionKey(v)
  44768. return nil
  44769. case wxcarduser.FieldIsVip:
  44770. v, ok := value.(int)
  44771. if !ok {
  44772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44773. }
  44774. m.SetIsVip(v)
  44775. return nil
  44776. }
  44777. return fmt.Errorf("unknown WxCardUser field %s", name)
  44778. }
  44779. // AddedFields returns all numeric fields that were incremented/decremented during
  44780. // this mutation.
  44781. func (m *WxCardUserMutation) AddedFields() []string {
  44782. var fields []string
  44783. if m.addis_vip != nil {
  44784. fields = append(fields, wxcarduser.FieldIsVip)
  44785. }
  44786. return fields
  44787. }
  44788. // AddedField returns the numeric value that was incremented/decremented on a field
  44789. // with the given name. The second boolean return value indicates that this field
  44790. // was not set, or was not defined in the schema.
  44791. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44792. switch name {
  44793. case wxcarduser.FieldIsVip:
  44794. return m.AddedIsVip()
  44795. }
  44796. return nil, false
  44797. }
  44798. // AddField adds the value to the field with the given name. It returns an error if
  44799. // the field is not defined in the schema, or if the type mismatched the field
  44800. // type.
  44801. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44802. switch name {
  44803. case wxcarduser.FieldIsVip:
  44804. v, ok := value.(int)
  44805. if !ok {
  44806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44807. }
  44808. m.AddIsVip(v)
  44809. return nil
  44810. }
  44811. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44812. }
  44813. // ClearedFields returns all nullable fields that were cleared during this
  44814. // mutation.
  44815. func (m *WxCardUserMutation) ClearedFields() []string {
  44816. var fields []string
  44817. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44818. fields = append(fields, wxcarduser.FieldDeletedAt)
  44819. }
  44820. return fields
  44821. }
  44822. // FieldCleared returns a boolean indicating if a field with the given name was
  44823. // cleared in this mutation.
  44824. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44825. _, ok := m.clearedFields[name]
  44826. return ok
  44827. }
  44828. // ClearField clears the value of the field with the given name. It returns an
  44829. // error if the field is not defined in the schema.
  44830. func (m *WxCardUserMutation) ClearField(name string) error {
  44831. switch name {
  44832. case wxcarduser.FieldDeletedAt:
  44833. m.ClearDeletedAt()
  44834. return nil
  44835. }
  44836. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44837. }
  44838. // ResetField resets all changes in the mutation for the field with the given name.
  44839. // It returns an error if the field is not defined in the schema.
  44840. func (m *WxCardUserMutation) ResetField(name string) error {
  44841. switch name {
  44842. case wxcarduser.FieldCreatedAt:
  44843. m.ResetCreatedAt()
  44844. return nil
  44845. case wxcarduser.FieldUpdatedAt:
  44846. m.ResetUpdatedAt()
  44847. return nil
  44848. case wxcarduser.FieldDeletedAt:
  44849. m.ResetDeletedAt()
  44850. return nil
  44851. case wxcarduser.FieldWxid:
  44852. m.ResetWxid()
  44853. return nil
  44854. case wxcarduser.FieldAccount:
  44855. m.ResetAccount()
  44856. return nil
  44857. case wxcarduser.FieldAvatar:
  44858. m.ResetAvatar()
  44859. return nil
  44860. case wxcarduser.FieldNickname:
  44861. m.ResetNickname()
  44862. return nil
  44863. case wxcarduser.FieldRemark:
  44864. m.ResetRemark()
  44865. return nil
  44866. case wxcarduser.FieldPhone:
  44867. m.ResetPhone()
  44868. return nil
  44869. case wxcarduser.FieldOpenID:
  44870. m.ResetOpenID()
  44871. return nil
  44872. case wxcarduser.FieldUnionID:
  44873. m.ResetUnionID()
  44874. return nil
  44875. case wxcarduser.FieldSessionKey:
  44876. m.ResetSessionKey()
  44877. return nil
  44878. case wxcarduser.FieldIsVip:
  44879. m.ResetIsVip()
  44880. return nil
  44881. }
  44882. return fmt.Errorf("unknown WxCardUser field %s", name)
  44883. }
  44884. // AddedEdges returns all edge names that were set/added in this mutation.
  44885. func (m *WxCardUserMutation) AddedEdges() []string {
  44886. edges := make([]string, 0, 0)
  44887. return edges
  44888. }
  44889. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44890. // name in this mutation.
  44891. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  44892. return nil
  44893. }
  44894. // RemovedEdges returns all edge names that were removed in this mutation.
  44895. func (m *WxCardUserMutation) RemovedEdges() []string {
  44896. edges := make([]string, 0, 0)
  44897. return edges
  44898. }
  44899. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44900. // the given name in this mutation.
  44901. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  44902. return nil
  44903. }
  44904. // ClearedEdges returns all edge names that were cleared in this mutation.
  44905. func (m *WxCardUserMutation) ClearedEdges() []string {
  44906. edges := make([]string, 0, 0)
  44907. return edges
  44908. }
  44909. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44910. // was cleared in this mutation.
  44911. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  44912. return false
  44913. }
  44914. // ClearEdge clears the value of the edge with the given name. It returns an error
  44915. // if that edge is not defined in the schema.
  44916. func (m *WxCardUserMutation) ClearEdge(name string) error {
  44917. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  44918. }
  44919. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44920. // It returns an error if the edge is not defined in the schema.
  44921. func (m *WxCardUserMutation) ResetEdge(name string) error {
  44922. return fmt.Errorf("unknown WxCardUser edge %s", name)
  44923. }
  44924. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  44925. type WxCardVisitMutation struct {
  44926. config
  44927. op Op
  44928. typ string
  44929. id *uint64
  44930. created_at *time.Time
  44931. updated_at *time.Time
  44932. deleted_at *time.Time
  44933. user_id *uint64
  44934. adduser_id *int64
  44935. bot_id *uint64
  44936. addbot_id *int64
  44937. bot_type *uint8
  44938. addbot_type *int8
  44939. clearedFields map[string]struct{}
  44940. done bool
  44941. oldValue func(context.Context) (*WxCardVisit, error)
  44942. predicates []predicate.WxCardVisit
  44943. }
  44944. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  44945. // wxcardvisitOption allows management of the mutation configuration using functional options.
  44946. type wxcardvisitOption func(*WxCardVisitMutation)
  44947. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  44948. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  44949. m := &WxCardVisitMutation{
  44950. config: c,
  44951. op: op,
  44952. typ: TypeWxCardVisit,
  44953. clearedFields: make(map[string]struct{}),
  44954. }
  44955. for _, opt := range opts {
  44956. opt(m)
  44957. }
  44958. return m
  44959. }
  44960. // withWxCardVisitID sets the ID field of the mutation.
  44961. func withWxCardVisitID(id uint64) wxcardvisitOption {
  44962. return func(m *WxCardVisitMutation) {
  44963. var (
  44964. err error
  44965. once sync.Once
  44966. value *WxCardVisit
  44967. )
  44968. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  44969. once.Do(func() {
  44970. if m.done {
  44971. err = errors.New("querying old values post mutation is not allowed")
  44972. } else {
  44973. value, err = m.Client().WxCardVisit.Get(ctx, id)
  44974. }
  44975. })
  44976. return value, err
  44977. }
  44978. m.id = &id
  44979. }
  44980. }
  44981. // withWxCardVisit sets the old WxCardVisit of the mutation.
  44982. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  44983. return func(m *WxCardVisitMutation) {
  44984. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  44985. return node, nil
  44986. }
  44987. m.id = &node.ID
  44988. }
  44989. }
  44990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44991. // executed in a transaction (ent.Tx), a transactional client is returned.
  44992. func (m WxCardVisitMutation) Client() *Client {
  44993. client := &Client{config: m.config}
  44994. client.init()
  44995. return client
  44996. }
  44997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44998. // it returns an error otherwise.
  44999. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45000. if _, ok := m.driver.(*txDriver); !ok {
  45001. return nil, errors.New("ent: mutation is not running in a transaction")
  45002. }
  45003. tx := &Tx{config: m.config}
  45004. tx.init()
  45005. return tx, nil
  45006. }
  45007. // SetID sets the value of the id field. Note that this
  45008. // operation is only accepted on creation of WxCardVisit entities.
  45009. func (m *WxCardVisitMutation) SetID(id uint64) {
  45010. m.id = &id
  45011. }
  45012. // ID returns the ID value in the mutation. Note that the ID is only available
  45013. // if it was provided to the builder or after it was returned from the database.
  45014. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45015. if m.id == nil {
  45016. return
  45017. }
  45018. return *m.id, true
  45019. }
  45020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45021. // That means, if the mutation is applied within a transaction with an isolation level such
  45022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45023. // or updated by the mutation.
  45024. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45025. switch {
  45026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45027. id, exists := m.ID()
  45028. if exists {
  45029. return []uint64{id}, nil
  45030. }
  45031. fallthrough
  45032. case m.op.Is(OpUpdate | OpDelete):
  45033. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45034. default:
  45035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45036. }
  45037. }
  45038. // SetCreatedAt sets the "created_at" field.
  45039. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45040. m.created_at = &t
  45041. }
  45042. // CreatedAt returns the value of the "created_at" field in the mutation.
  45043. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45044. v := m.created_at
  45045. if v == nil {
  45046. return
  45047. }
  45048. return *v, true
  45049. }
  45050. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45051. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45053. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45054. if !m.op.Is(OpUpdateOne) {
  45055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45056. }
  45057. if m.id == nil || m.oldValue == nil {
  45058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45059. }
  45060. oldValue, err := m.oldValue(ctx)
  45061. if err != nil {
  45062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45063. }
  45064. return oldValue.CreatedAt, nil
  45065. }
  45066. // ResetCreatedAt resets all changes to the "created_at" field.
  45067. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45068. m.created_at = nil
  45069. }
  45070. // SetUpdatedAt sets the "updated_at" field.
  45071. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45072. m.updated_at = &t
  45073. }
  45074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45075. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45076. v := m.updated_at
  45077. if v == nil {
  45078. return
  45079. }
  45080. return *v, true
  45081. }
  45082. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45083. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45085. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45086. if !m.op.Is(OpUpdateOne) {
  45087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45088. }
  45089. if m.id == nil || m.oldValue == nil {
  45090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45091. }
  45092. oldValue, err := m.oldValue(ctx)
  45093. if err != nil {
  45094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45095. }
  45096. return oldValue.UpdatedAt, nil
  45097. }
  45098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45099. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45100. m.updated_at = nil
  45101. }
  45102. // SetDeletedAt sets the "deleted_at" field.
  45103. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45104. m.deleted_at = &t
  45105. }
  45106. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45107. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45108. v := m.deleted_at
  45109. if v == nil {
  45110. return
  45111. }
  45112. return *v, true
  45113. }
  45114. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45115. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45117. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45118. if !m.op.Is(OpUpdateOne) {
  45119. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45120. }
  45121. if m.id == nil || m.oldValue == nil {
  45122. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45123. }
  45124. oldValue, err := m.oldValue(ctx)
  45125. if err != nil {
  45126. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45127. }
  45128. return oldValue.DeletedAt, nil
  45129. }
  45130. // ClearDeletedAt clears the value of the "deleted_at" field.
  45131. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45132. m.deleted_at = nil
  45133. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45134. }
  45135. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45136. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45137. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45138. return ok
  45139. }
  45140. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45141. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45142. m.deleted_at = nil
  45143. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45144. }
  45145. // SetUserID sets the "user_id" field.
  45146. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45147. m.user_id = &u
  45148. m.adduser_id = nil
  45149. }
  45150. // UserID returns the value of the "user_id" field in the mutation.
  45151. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45152. v := m.user_id
  45153. if v == nil {
  45154. return
  45155. }
  45156. return *v, true
  45157. }
  45158. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45159. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45161. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45162. if !m.op.Is(OpUpdateOne) {
  45163. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45164. }
  45165. if m.id == nil || m.oldValue == nil {
  45166. return v, errors.New("OldUserID requires an ID field in the mutation")
  45167. }
  45168. oldValue, err := m.oldValue(ctx)
  45169. if err != nil {
  45170. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45171. }
  45172. return oldValue.UserID, nil
  45173. }
  45174. // AddUserID adds u to the "user_id" field.
  45175. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45176. if m.adduser_id != nil {
  45177. *m.adduser_id += u
  45178. } else {
  45179. m.adduser_id = &u
  45180. }
  45181. }
  45182. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45183. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45184. v := m.adduser_id
  45185. if v == nil {
  45186. return
  45187. }
  45188. return *v, true
  45189. }
  45190. // ClearUserID clears the value of the "user_id" field.
  45191. func (m *WxCardVisitMutation) ClearUserID() {
  45192. m.user_id = nil
  45193. m.adduser_id = nil
  45194. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45195. }
  45196. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45197. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45198. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45199. return ok
  45200. }
  45201. // ResetUserID resets all changes to the "user_id" field.
  45202. func (m *WxCardVisitMutation) ResetUserID() {
  45203. m.user_id = nil
  45204. m.adduser_id = nil
  45205. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45206. }
  45207. // SetBotID sets the "bot_id" field.
  45208. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45209. m.bot_id = &u
  45210. m.addbot_id = nil
  45211. }
  45212. // BotID returns the value of the "bot_id" field in the mutation.
  45213. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45214. v := m.bot_id
  45215. if v == nil {
  45216. return
  45217. }
  45218. return *v, true
  45219. }
  45220. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45221. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45223. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45224. if !m.op.Is(OpUpdateOne) {
  45225. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45226. }
  45227. if m.id == nil || m.oldValue == nil {
  45228. return v, errors.New("OldBotID requires an ID field in the mutation")
  45229. }
  45230. oldValue, err := m.oldValue(ctx)
  45231. if err != nil {
  45232. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45233. }
  45234. return oldValue.BotID, nil
  45235. }
  45236. // AddBotID adds u to the "bot_id" field.
  45237. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45238. if m.addbot_id != nil {
  45239. *m.addbot_id += u
  45240. } else {
  45241. m.addbot_id = &u
  45242. }
  45243. }
  45244. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45245. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45246. v := m.addbot_id
  45247. if v == nil {
  45248. return
  45249. }
  45250. return *v, true
  45251. }
  45252. // ResetBotID resets all changes to the "bot_id" field.
  45253. func (m *WxCardVisitMutation) ResetBotID() {
  45254. m.bot_id = nil
  45255. m.addbot_id = nil
  45256. }
  45257. // SetBotType sets the "bot_type" field.
  45258. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45259. m.bot_type = &u
  45260. m.addbot_type = nil
  45261. }
  45262. // BotType returns the value of the "bot_type" field in the mutation.
  45263. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45264. v := m.bot_type
  45265. if v == nil {
  45266. return
  45267. }
  45268. return *v, true
  45269. }
  45270. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45271. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45273. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45274. if !m.op.Is(OpUpdateOne) {
  45275. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45276. }
  45277. if m.id == nil || m.oldValue == nil {
  45278. return v, errors.New("OldBotType requires an ID field in the mutation")
  45279. }
  45280. oldValue, err := m.oldValue(ctx)
  45281. if err != nil {
  45282. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45283. }
  45284. return oldValue.BotType, nil
  45285. }
  45286. // AddBotType adds u to the "bot_type" field.
  45287. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45288. if m.addbot_type != nil {
  45289. *m.addbot_type += u
  45290. } else {
  45291. m.addbot_type = &u
  45292. }
  45293. }
  45294. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45295. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45296. v := m.addbot_type
  45297. if v == nil {
  45298. return
  45299. }
  45300. return *v, true
  45301. }
  45302. // ResetBotType resets all changes to the "bot_type" field.
  45303. func (m *WxCardVisitMutation) ResetBotType() {
  45304. m.bot_type = nil
  45305. m.addbot_type = nil
  45306. }
  45307. // Where appends a list predicates to the WxCardVisitMutation builder.
  45308. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45309. m.predicates = append(m.predicates, ps...)
  45310. }
  45311. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45312. // users can use type-assertion to append predicates that do not depend on any generated package.
  45313. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45314. p := make([]predicate.WxCardVisit, len(ps))
  45315. for i := range ps {
  45316. p[i] = ps[i]
  45317. }
  45318. m.Where(p...)
  45319. }
  45320. // Op returns the operation name.
  45321. func (m *WxCardVisitMutation) Op() Op {
  45322. return m.op
  45323. }
  45324. // SetOp allows setting the mutation operation.
  45325. func (m *WxCardVisitMutation) SetOp(op Op) {
  45326. m.op = op
  45327. }
  45328. // Type returns the node type of this mutation (WxCardVisit).
  45329. func (m *WxCardVisitMutation) Type() string {
  45330. return m.typ
  45331. }
  45332. // Fields returns all fields that were changed during this mutation. Note that in
  45333. // order to get all numeric fields that were incremented/decremented, call
  45334. // AddedFields().
  45335. func (m *WxCardVisitMutation) Fields() []string {
  45336. fields := make([]string, 0, 6)
  45337. if m.created_at != nil {
  45338. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45339. }
  45340. if m.updated_at != nil {
  45341. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45342. }
  45343. if m.deleted_at != nil {
  45344. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45345. }
  45346. if m.user_id != nil {
  45347. fields = append(fields, wxcardvisit.FieldUserID)
  45348. }
  45349. if m.bot_id != nil {
  45350. fields = append(fields, wxcardvisit.FieldBotID)
  45351. }
  45352. if m.bot_type != nil {
  45353. fields = append(fields, wxcardvisit.FieldBotType)
  45354. }
  45355. return fields
  45356. }
  45357. // Field returns the value of a field with the given name. The second boolean
  45358. // return value indicates that this field was not set, or was not defined in the
  45359. // schema.
  45360. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45361. switch name {
  45362. case wxcardvisit.FieldCreatedAt:
  45363. return m.CreatedAt()
  45364. case wxcardvisit.FieldUpdatedAt:
  45365. return m.UpdatedAt()
  45366. case wxcardvisit.FieldDeletedAt:
  45367. return m.DeletedAt()
  45368. case wxcardvisit.FieldUserID:
  45369. return m.UserID()
  45370. case wxcardvisit.FieldBotID:
  45371. return m.BotID()
  45372. case wxcardvisit.FieldBotType:
  45373. return m.BotType()
  45374. }
  45375. return nil, false
  45376. }
  45377. // OldField returns the old value of the field from the database. An error is
  45378. // returned if the mutation operation is not UpdateOne, or the query to the
  45379. // database failed.
  45380. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45381. switch name {
  45382. case wxcardvisit.FieldCreatedAt:
  45383. return m.OldCreatedAt(ctx)
  45384. case wxcardvisit.FieldUpdatedAt:
  45385. return m.OldUpdatedAt(ctx)
  45386. case wxcardvisit.FieldDeletedAt:
  45387. return m.OldDeletedAt(ctx)
  45388. case wxcardvisit.FieldUserID:
  45389. return m.OldUserID(ctx)
  45390. case wxcardvisit.FieldBotID:
  45391. return m.OldBotID(ctx)
  45392. case wxcardvisit.FieldBotType:
  45393. return m.OldBotType(ctx)
  45394. }
  45395. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45396. }
  45397. // SetField sets the value of a field with the given name. It returns an error if
  45398. // the field is not defined in the schema, or if the type mismatched the field
  45399. // type.
  45400. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45401. switch name {
  45402. case wxcardvisit.FieldCreatedAt:
  45403. v, ok := value.(time.Time)
  45404. if !ok {
  45405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45406. }
  45407. m.SetCreatedAt(v)
  45408. return nil
  45409. case wxcardvisit.FieldUpdatedAt:
  45410. v, ok := value.(time.Time)
  45411. if !ok {
  45412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45413. }
  45414. m.SetUpdatedAt(v)
  45415. return nil
  45416. case wxcardvisit.FieldDeletedAt:
  45417. v, ok := value.(time.Time)
  45418. if !ok {
  45419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45420. }
  45421. m.SetDeletedAt(v)
  45422. return nil
  45423. case wxcardvisit.FieldUserID:
  45424. v, ok := value.(uint64)
  45425. if !ok {
  45426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45427. }
  45428. m.SetUserID(v)
  45429. return nil
  45430. case wxcardvisit.FieldBotID:
  45431. v, ok := value.(uint64)
  45432. if !ok {
  45433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45434. }
  45435. m.SetBotID(v)
  45436. return nil
  45437. case wxcardvisit.FieldBotType:
  45438. v, ok := value.(uint8)
  45439. if !ok {
  45440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45441. }
  45442. m.SetBotType(v)
  45443. return nil
  45444. }
  45445. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45446. }
  45447. // AddedFields returns all numeric fields that were incremented/decremented during
  45448. // this mutation.
  45449. func (m *WxCardVisitMutation) AddedFields() []string {
  45450. var fields []string
  45451. if m.adduser_id != nil {
  45452. fields = append(fields, wxcardvisit.FieldUserID)
  45453. }
  45454. if m.addbot_id != nil {
  45455. fields = append(fields, wxcardvisit.FieldBotID)
  45456. }
  45457. if m.addbot_type != nil {
  45458. fields = append(fields, wxcardvisit.FieldBotType)
  45459. }
  45460. return fields
  45461. }
  45462. // AddedField returns the numeric value that was incremented/decremented on a field
  45463. // with the given name. The second boolean return value indicates that this field
  45464. // was not set, or was not defined in the schema.
  45465. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45466. switch name {
  45467. case wxcardvisit.FieldUserID:
  45468. return m.AddedUserID()
  45469. case wxcardvisit.FieldBotID:
  45470. return m.AddedBotID()
  45471. case wxcardvisit.FieldBotType:
  45472. return m.AddedBotType()
  45473. }
  45474. return nil, false
  45475. }
  45476. // AddField adds the value to the field with the given name. It returns an error if
  45477. // the field is not defined in the schema, or if the type mismatched the field
  45478. // type.
  45479. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45480. switch name {
  45481. case wxcardvisit.FieldUserID:
  45482. v, ok := value.(int64)
  45483. if !ok {
  45484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45485. }
  45486. m.AddUserID(v)
  45487. return nil
  45488. case wxcardvisit.FieldBotID:
  45489. v, ok := value.(int64)
  45490. if !ok {
  45491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45492. }
  45493. m.AddBotID(v)
  45494. return nil
  45495. case wxcardvisit.FieldBotType:
  45496. v, ok := value.(int8)
  45497. if !ok {
  45498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45499. }
  45500. m.AddBotType(v)
  45501. return nil
  45502. }
  45503. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45504. }
  45505. // ClearedFields returns all nullable fields that were cleared during this
  45506. // mutation.
  45507. func (m *WxCardVisitMutation) ClearedFields() []string {
  45508. var fields []string
  45509. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45510. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45511. }
  45512. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45513. fields = append(fields, wxcardvisit.FieldUserID)
  45514. }
  45515. return fields
  45516. }
  45517. // FieldCleared returns a boolean indicating if a field with the given name was
  45518. // cleared in this mutation.
  45519. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45520. _, ok := m.clearedFields[name]
  45521. return ok
  45522. }
  45523. // ClearField clears the value of the field with the given name. It returns an
  45524. // error if the field is not defined in the schema.
  45525. func (m *WxCardVisitMutation) ClearField(name string) error {
  45526. switch name {
  45527. case wxcardvisit.FieldDeletedAt:
  45528. m.ClearDeletedAt()
  45529. return nil
  45530. case wxcardvisit.FieldUserID:
  45531. m.ClearUserID()
  45532. return nil
  45533. }
  45534. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45535. }
  45536. // ResetField resets all changes in the mutation for the field with the given name.
  45537. // It returns an error if the field is not defined in the schema.
  45538. func (m *WxCardVisitMutation) ResetField(name string) error {
  45539. switch name {
  45540. case wxcardvisit.FieldCreatedAt:
  45541. m.ResetCreatedAt()
  45542. return nil
  45543. case wxcardvisit.FieldUpdatedAt:
  45544. m.ResetUpdatedAt()
  45545. return nil
  45546. case wxcardvisit.FieldDeletedAt:
  45547. m.ResetDeletedAt()
  45548. return nil
  45549. case wxcardvisit.FieldUserID:
  45550. m.ResetUserID()
  45551. return nil
  45552. case wxcardvisit.FieldBotID:
  45553. m.ResetBotID()
  45554. return nil
  45555. case wxcardvisit.FieldBotType:
  45556. m.ResetBotType()
  45557. return nil
  45558. }
  45559. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45560. }
  45561. // AddedEdges returns all edge names that were set/added in this mutation.
  45562. func (m *WxCardVisitMutation) AddedEdges() []string {
  45563. edges := make([]string, 0, 0)
  45564. return edges
  45565. }
  45566. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45567. // name in this mutation.
  45568. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45569. return nil
  45570. }
  45571. // RemovedEdges returns all edge names that were removed in this mutation.
  45572. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45573. edges := make([]string, 0, 0)
  45574. return edges
  45575. }
  45576. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45577. // the given name in this mutation.
  45578. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45579. return nil
  45580. }
  45581. // ClearedEdges returns all edge names that were cleared in this mutation.
  45582. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45583. edges := make([]string, 0, 0)
  45584. return edges
  45585. }
  45586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45587. // was cleared in this mutation.
  45588. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45589. return false
  45590. }
  45591. // ClearEdge clears the value of the edge with the given name. It returns an error
  45592. // if that edge is not defined in the schema.
  45593. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45594. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45595. }
  45596. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45597. // It returns an error if the edge is not defined in the schema.
  45598. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45599. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45600. }
  45601. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45602. type XunjiMutation struct {
  45603. config
  45604. op Op
  45605. typ string
  45606. id *uint64
  45607. created_at *time.Time
  45608. updated_at *time.Time
  45609. status *uint8
  45610. addstatus *int8
  45611. deleted_at *time.Time
  45612. app_key *string
  45613. app_secret *string
  45614. token *string
  45615. encoding_key *string
  45616. agent_id *uint64
  45617. addagent_id *int64
  45618. organization_id *uint64
  45619. addorganization_id *int64
  45620. wxid *string
  45621. api_base *string
  45622. api_key *string
  45623. clearedFields map[string]struct{}
  45624. done bool
  45625. oldValue func(context.Context) (*Xunji, error)
  45626. predicates []predicate.Xunji
  45627. }
  45628. var _ ent.Mutation = (*XunjiMutation)(nil)
  45629. // xunjiOption allows management of the mutation configuration using functional options.
  45630. type xunjiOption func(*XunjiMutation)
  45631. // newXunjiMutation creates new mutation for the Xunji entity.
  45632. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  45633. m := &XunjiMutation{
  45634. config: c,
  45635. op: op,
  45636. typ: TypeXunji,
  45637. clearedFields: make(map[string]struct{}),
  45638. }
  45639. for _, opt := range opts {
  45640. opt(m)
  45641. }
  45642. return m
  45643. }
  45644. // withXunjiID sets the ID field of the mutation.
  45645. func withXunjiID(id uint64) xunjiOption {
  45646. return func(m *XunjiMutation) {
  45647. var (
  45648. err error
  45649. once sync.Once
  45650. value *Xunji
  45651. )
  45652. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  45653. once.Do(func() {
  45654. if m.done {
  45655. err = errors.New("querying old values post mutation is not allowed")
  45656. } else {
  45657. value, err = m.Client().Xunji.Get(ctx, id)
  45658. }
  45659. })
  45660. return value, err
  45661. }
  45662. m.id = &id
  45663. }
  45664. }
  45665. // withXunji sets the old Xunji of the mutation.
  45666. func withXunji(node *Xunji) xunjiOption {
  45667. return func(m *XunjiMutation) {
  45668. m.oldValue = func(context.Context) (*Xunji, error) {
  45669. return node, nil
  45670. }
  45671. m.id = &node.ID
  45672. }
  45673. }
  45674. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45675. // executed in a transaction (ent.Tx), a transactional client is returned.
  45676. func (m XunjiMutation) Client() *Client {
  45677. client := &Client{config: m.config}
  45678. client.init()
  45679. return client
  45680. }
  45681. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45682. // it returns an error otherwise.
  45683. func (m XunjiMutation) Tx() (*Tx, error) {
  45684. if _, ok := m.driver.(*txDriver); !ok {
  45685. return nil, errors.New("ent: mutation is not running in a transaction")
  45686. }
  45687. tx := &Tx{config: m.config}
  45688. tx.init()
  45689. return tx, nil
  45690. }
  45691. // SetID sets the value of the id field. Note that this
  45692. // operation is only accepted on creation of Xunji entities.
  45693. func (m *XunjiMutation) SetID(id uint64) {
  45694. m.id = &id
  45695. }
  45696. // ID returns the ID value in the mutation. Note that the ID is only available
  45697. // if it was provided to the builder or after it was returned from the database.
  45698. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  45699. if m.id == nil {
  45700. return
  45701. }
  45702. return *m.id, true
  45703. }
  45704. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45705. // That means, if the mutation is applied within a transaction with an isolation level such
  45706. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45707. // or updated by the mutation.
  45708. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  45709. switch {
  45710. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45711. id, exists := m.ID()
  45712. if exists {
  45713. return []uint64{id}, nil
  45714. }
  45715. fallthrough
  45716. case m.op.Is(OpUpdate | OpDelete):
  45717. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  45718. default:
  45719. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45720. }
  45721. }
  45722. // SetCreatedAt sets the "created_at" field.
  45723. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  45724. m.created_at = &t
  45725. }
  45726. // CreatedAt returns the value of the "created_at" field in the mutation.
  45727. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  45728. v := m.created_at
  45729. if v == nil {
  45730. return
  45731. }
  45732. return *v, true
  45733. }
  45734. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  45735. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45737. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45738. if !m.op.Is(OpUpdateOne) {
  45739. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45740. }
  45741. if m.id == nil || m.oldValue == nil {
  45742. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45743. }
  45744. oldValue, err := m.oldValue(ctx)
  45745. if err != nil {
  45746. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45747. }
  45748. return oldValue.CreatedAt, nil
  45749. }
  45750. // ResetCreatedAt resets all changes to the "created_at" field.
  45751. func (m *XunjiMutation) ResetCreatedAt() {
  45752. m.created_at = nil
  45753. }
  45754. // SetUpdatedAt sets the "updated_at" field.
  45755. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  45756. m.updated_at = &t
  45757. }
  45758. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45759. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  45760. v := m.updated_at
  45761. if v == nil {
  45762. return
  45763. }
  45764. return *v, true
  45765. }
  45766. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  45767. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45769. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45770. if !m.op.Is(OpUpdateOne) {
  45771. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45772. }
  45773. if m.id == nil || m.oldValue == nil {
  45774. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45775. }
  45776. oldValue, err := m.oldValue(ctx)
  45777. if err != nil {
  45778. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45779. }
  45780. return oldValue.UpdatedAt, nil
  45781. }
  45782. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45783. func (m *XunjiMutation) ResetUpdatedAt() {
  45784. m.updated_at = nil
  45785. }
  45786. // SetStatus sets the "status" field.
  45787. func (m *XunjiMutation) SetStatus(u uint8) {
  45788. m.status = &u
  45789. m.addstatus = nil
  45790. }
  45791. // Status returns the value of the "status" field in the mutation.
  45792. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  45793. v := m.status
  45794. if v == nil {
  45795. return
  45796. }
  45797. return *v, true
  45798. }
  45799. // OldStatus returns the old "status" field's value of the Xunji entity.
  45800. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45802. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45803. if !m.op.Is(OpUpdateOne) {
  45804. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45805. }
  45806. if m.id == nil || m.oldValue == nil {
  45807. return v, errors.New("OldStatus requires an ID field in the mutation")
  45808. }
  45809. oldValue, err := m.oldValue(ctx)
  45810. if err != nil {
  45811. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45812. }
  45813. return oldValue.Status, nil
  45814. }
  45815. // AddStatus adds u to the "status" field.
  45816. func (m *XunjiMutation) AddStatus(u int8) {
  45817. if m.addstatus != nil {
  45818. *m.addstatus += u
  45819. } else {
  45820. m.addstatus = &u
  45821. }
  45822. }
  45823. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45824. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  45825. v := m.addstatus
  45826. if v == nil {
  45827. return
  45828. }
  45829. return *v, true
  45830. }
  45831. // ClearStatus clears the value of the "status" field.
  45832. func (m *XunjiMutation) ClearStatus() {
  45833. m.status = nil
  45834. m.addstatus = nil
  45835. m.clearedFields[xunji.FieldStatus] = struct{}{}
  45836. }
  45837. // StatusCleared returns if the "status" field was cleared in this mutation.
  45838. func (m *XunjiMutation) StatusCleared() bool {
  45839. _, ok := m.clearedFields[xunji.FieldStatus]
  45840. return ok
  45841. }
  45842. // ResetStatus resets all changes to the "status" field.
  45843. func (m *XunjiMutation) ResetStatus() {
  45844. m.status = nil
  45845. m.addstatus = nil
  45846. delete(m.clearedFields, xunji.FieldStatus)
  45847. }
  45848. // SetDeletedAt sets the "deleted_at" field.
  45849. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  45850. m.deleted_at = &t
  45851. }
  45852. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45853. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  45854. v := m.deleted_at
  45855. if v == nil {
  45856. return
  45857. }
  45858. return *v, true
  45859. }
  45860. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  45861. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45863. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45864. if !m.op.Is(OpUpdateOne) {
  45865. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45866. }
  45867. if m.id == nil || m.oldValue == nil {
  45868. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45869. }
  45870. oldValue, err := m.oldValue(ctx)
  45871. if err != nil {
  45872. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45873. }
  45874. return oldValue.DeletedAt, nil
  45875. }
  45876. // ClearDeletedAt clears the value of the "deleted_at" field.
  45877. func (m *XunjiMutation) ClearDeletedAt() {
  45878. m.deleted_at = nil
  45879. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  45880. }
  45881. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45882. func (m *XunjiMutation) DeletedAtCleared() bool {
  45883. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  45884. return ok
  45885. }
  45886. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45887. func (m *XunjiMutation) ResetDeletedAt() {
  45888. m.deleted_at = nil
  45889. delete(m.clearedFields, xunji.FieldDeletedAt)
  45890. }
  45891. // SetAppKey sets the "app_key" field.
  45892. func (m *XunjiMutation) SetAppKey(s string) {
  45893. m.app_key = &s
  45894. }
  45895. // AppKey returns the value of the "app_key" field in the mutation.
  45896. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  45897. v := m.app_key
  45898. if v == nil {
  45899. return
  45900. }
  45901. return *v, true
  45902. }
  45903. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  45904. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45906. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  45907. if !m.op.Is(OpUpdateOne) {
  45908. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  45909. }
  45910. if m.id == nil || m.oldValue == nil {
  45911. return v, errors.New("OldAppKey requires an ID field in the mutation")
  45912. }
  45913. oldValue, err := m.oldValue(ctx)
  45914. if err != nil {
  45915. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  45916. }
  45917. return oldValue.AppKey, nil
  45918. }
  45919. // ResetAppKey resets all changes to the "app_key" field.
  45920. func (m *XunjiMutation) ResetAppKey() {
  45921. m.app_key = nil
  45922. }
  45923. // SetAppSecret sets the "app_secret" field.
  45924. func (m *XunjiMutation) SetAppSecret(s string) {
  45925. m.app_secret = &s
  45926. }
  45927. // AppSecret returns the value of the "app_secret" field in the mutation.
  45928. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  45929. v := m.app_secret
  45930. if v == nil {
  45931. return
  45932. }
  45933. return *v, true
  45934. }
  45935. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  45936. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45938. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  45939. if !m.op.Is(OpUpdateOne) {
  45940. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  45941. }
  45942. if m.id == nil || m.oldValue == nil {
  45943. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  45944. }
  45945. oldValue, err := m.oldValue(ctx)
  45946. if err != nil {
  45947. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  45948. }
  45949. return oldValue.AppSecret, nil
  45950. }
  45951. // ResetAppSecret resets all changes to the "app_secret" field.
  45952. func (m *XunjiMutation) ResetAppSecret() {
  45953. m.app_secret = nil
  45954. }
  45955. // SetToken sets the "token" field.
  45956. func (m *XunjiMutation) SetToken(s string) {
  45957. m.token = &s
  45958. }
  45959. // Token returns the value of the "token" field in the mutation.
  45960. func (m *XunjiMutation) Token() (r string, exists bool) {
  45961. v := m.token
  45962. if v == nil {
  45963. return
  45964. }
  45965. return *v, true
  45966. }
  45967. // OldToken returns the old "token" field's value of the Xunji entity.
  45968. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45970. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  45971. if !m.op.Is(OpUpdateOne) {
  45972. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  45973. }
  45974. if m.id == nil || m.oldValue == nil {
  45975. return v, errors.New("OldToken requires an ID field in the mutation")
  45976. }
  45977. oldValue, err := m.oldValue(ctx)
  45978. if err != nil {
  45979. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  45980. }
  45981. return oldValue.Token, nil
  45982. }
  45983. // ResetToken resets all changes to the "token" field.
  45984. func (m *XunjiMutation) ResetToken() {
  45985. m.token = nil
  45986. }
  45987. // SetEncodingKey sets the "encoding_key" field.
  45988. func (m *XunjiMutation) SetEncodingKey(s string) {
  45989. m.encoding_key = &s
  45990. }
  45991. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  45992. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  45993. v := m.encoding_key
  45994. if v == nil {
  45995. return
  45996. }
  45997. return *v, true
  45998. }
  45999. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46000. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46002. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46003. if !m.op.Is(OpUpdateOne) {
  46004. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46005. }
  46006. if m.id == nil || m.oldValue == nil {
  46007. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46008. }
  46009. oldValue, err := m.oldValue(ctx)
  46010. if err != nil {
  46011. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46012. }
  46013. return oldValue.EncodingKey, nil
  46014. }
  46015. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46016. func (m *XunjiMutation) ResetEncodingKey() {
  46017. m.encoding_key = nil
  46018. }
  46019. // SetAgentID sets the "agent_id" field.
  46020. func (m *XunjiMutation) SetAgentID(u uint64) {
  46021. m.agent_id = &u
  46022. m.addagent_id = nil
  46023. }
  46024. // AgentID returns the value of the "agent_id" field in the mutation.
  46025. func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
  46026. v := m.agent_id
  46027. if v == nil {
  46028. return
  46029. }
  46030. return *v, true
  46031. }
  46032. // OldAgentID returns the old "agent_id" field's value of the Xunji entity.
  46033. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46035. func (m *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46036. if !m.op.Is(OpUpdateOne) {
  46037. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46038. }
  46039. if m.id == nil || m.oldValue == nil {
  46040. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46041. }
  46042. oldValue, err := m.oldValue(ctx)
  46043. if err != nil {
  46044. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46045. }
  46046. return oldValue.AgentID, nil
  46047. }
  46048. // AddAgentID adds u to the "agent_id" field.
  46049. func (m *XunjiMutation) AddAgentID(u int64) {
  46050. if m.addagent_id != nil {
  46051. *m.addagent_id += u
  46052. } else {
  46053. m.addagent_id = &u
  46054. }
  46055. }
  46056. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  46057. func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
  46058. v := m.addagent_id
  46059. if v == nil {
  46060. return
  46061. }
  46062. return *v, true
  46063. }
  46064. // ResetAgentID resets all changes to the "agent_id" field.
  46065. func (m *XunjiMutation) ResetAgentID() {
  46066. m.agent_id = nil
  46067. m.addagent_id = nil
  46068. }
  46069. // SetOrganizationID sets the "organization_id" field.
  46070. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46071. m.organization_id = &u
  46072. m.addorganization_id = nil
  46073. }
  46074. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46075. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46076. v := m.organization_id
  46077. if v == nil {
  46078. return
  46079. }
  46080. return *v, true
  46081. }
  46082. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46083. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46085. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46086. if !m.op.Is(OpUpdateOne) {
  46087. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46088. }
  46089. if m.id == nil || m.oldValue == nil {
  46090. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46091. }
  46092. oldValue, err := m.oldValue(ctx)
  46093. if err != nil {
  46094. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46095. }
  46096. return oldValue.OrganizationID, nil
  46097. }
  46098. // AddOrganizationID adds u to the "organization_id" field.
  46099. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46100. if m.addorganization_id != nil {
  46101. *m.addorganization_id += u
  46102. } else {
  46103. m.addorganization_id = &u
  46104. }
  46105. }
  46106. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46107. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46108. v := m.addorganization_id
  46109. if v == nil {
  46110. return
  46111. }
  46112. return *v, true
  46113. }
  46114. // ResetOrganizationID resets all changes to the "organization_id" field.
  46115. func (m *XunjiMutation) ResetOrganizationID() {
  46116. m.organization_id = nil
  46117. m.addorganization_id = nil
  46118. }
  46119. // SetWxid sets the "wxid" field.
  46120. func (m *XunjiMutation) SetWxid(s string) {
  46121. m.wxid = &s
  46122. }
  46123. // Wxid returns the value of the "wxid" field in the mutation.
  46124. func (m *XunjiMutation) Wxid() (r string, exists bool) {
  46125. v := m.wxid
  46126. if v == nil {
  46127. return
  46128. }
  46129. return *v, true
  46130. }
  46131. // OldWxid returns the old "wxid" field's value of the Xunji entity.
  46132. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46134. func (m *XunjiMutation) OldWxid(ctx context.Context) (v string, err error) {
  46135. if !m.op.Is(OpUpdateOne) {
  46136. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46137. }
  46138. if m.id == nil || m.oldValue == nil {
  46139. return v, errors.New("OldWxid requires an ID field in the mutation")
  46140. }
  46141. oldValue, err := m.oldValue(ctx)
  46142. if err != nil {
  46143. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46144. }
  46145. return oldValue.Wxid, nil
  46146. }
  46147. // ResetWxid resets all changes to the "wxid" field.
  46148. func (m *XunjiMutation) ResetWxid() {
  46149. m.wxid = nil
  46150. }
  46151. // SetAPIBase sets the "api_base" field.
  46152. func (m *XunjiMutation) SetAPIBase(s string) {
  46153. m.api_base = &s
  46154. }
  46155. // APIBase returns the value of the "api_base" field in the mutation.
  46156. func (m *XunjiMutation) APIBase() (r string, exists bool) {
  46157. v := m.api_base
  46158. if v == nil {
  46159. return
  46160. }
  46161. return *v, true
  46162. }
  46163. // OldAPIBase returns the old "api_base" field's value of the Xunji entity.
  46164. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46166. func (m *XunjiMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46167. if !m.op.Is(OpUpdateOne) {
  46168. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46169. }
  46170. if m.id == nil || m.oldValue == nil {
  46171. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46172. }
  46173. oldValue, err := m.oldValue(ctx)
  46174. if err != nil {
  46175. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46176. }
  46177. return oldValue.APIBase, nil
  46178. }
  46179. // ClearAPIBase clears the value of the "api_base" field.
  46180. func (m *XunjiMutation) ClearAPIBase() {
  46181. m.api_base = nil
  46182. m.clearedFields[xunji.FieldAPIBase] = struct{}{}
  46183. }
  46184. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46185. func (m *XunjiMutation) APIBaseCleared() bool {
  46186. _, ok := m.clearedFields[xunji.FieldAPIBase]
  46187. return ok
  46188. }
  46189. // ResetAPIBase resets all changes to the "api_base" field.
  46190. func (m *XunjiMutation) ResetAPIBase() {
  46191. m.api_base = nil
  46192. delete(m.clearedFields, xunji.FieldAPIBase)
  46193. }
  46194. // SetAPIKey sets the "api_key" field.
  46195. func (m *XunjiMutation) SetAPIKey(s string) {
  46196. m.api_key = &s
  46197. }
  46198. // APIKey returns the value of the "api_key" field in the mutation.
  46199. func (m *XunjiMutation) APIKey() (r string, exists bool) {
  46200. v := m.api_key
  46201. if v == nil {
  46202. return
  46203. }
  46204. return *v, true
  46205. }
  46206. // OldAPIKey returns the old "api_key" field's value of the Xunji entity.
  46207. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46209. func (m *XunjiMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46210. if !m.op.Is(OpUpdateOne) {
  46211. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46212. }
  46213. if m.id == nil || m.oldValue == nil {
  46214. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46215. }
  46216. oldValue, err := m.oldValue(ctx)
  46217. if err != nil {
  46218. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46219. }
  46220. return oldValue.APIKey, nil
  46221. }
  46222. // ClearAPIKey clears the value of the "api_key" field.
  46223. func (m *XunjiMutation) ClearAPIKey() {
  46224. m.api_key = nil
  46225. m.clearedFields[xunji.FieldAPIKey] = struct{}{}
  46226. }
  46227. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46228. func (m *XunjiMutation) APIKeyCleared() bool {
  46229. _, ok := m.clearedFields[xunji.FieldAPIKey]
  46230. return ok
  46231. }
  46232. // ResetAPIKey resets all changes to the "api_key" field.
  46233. func (m *XunjiMutation) ResetAPIKey() {
  46234. m.api_key = nil
  46235. delete(m.clearedFields, xunji.FieldAPIKey)
  46236. }
  46237. // Where appends a list predicates to the XunjiMutation builder.
  46238. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46239. m.predicates = append(m.predicates, ps...)
  46240. }
  46241. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46242. // users can use type-assertion to append predicates that do not depend on any generated package.
  46243. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46244. p := make([]predicate.Xunji, len(ps))
  46245. for i := range ps {
  46246. p[i] = ps[i]
  46247. }
  46248. m.Where(p...)
  46249. }
  46250. // Op returns the operation name.
  46251. func (m *XunjiMutation) Op() Op {
  46252. return m.op
  46253. }
  46254. // SetOp allows setting the mutation operation.
  46255. func (m *XunjiMutation) SetOp(op Op) {
  46256. m.op = op
  46257. }
  46258. // Type returns the node type of this mutation (Xunji).
  46259. func (m *XunjiMutation) Type() string {
  46260. return m.typ
  46261. }
  46262. // Fields returns all fields that were changed during this mutation. Note that in
  46263. // order to get all numeric fields that were incremented/decremented, call
  46264. // AddedFields().
  46265. func (m *XunjiMutation) Fields() []string {
  46266. fields := make([]string, 0, 13)
  46267. if m.created_at != nil {
  46268. fields = append(fields, xunji.FieldCreatedAt)
  46269. }
  46270. if m.updated_at != nil {
  46271. fields = append(fields, xunji.FieldUpdatedAt)
  46272. }
  46273. if m.status != nil {
  46274. fields = append(fields, xunji.FieldStatus)
  46275. }
  46276. if m.deleted_at != nil {
  46277. fields = append(fields, xunji.FieldDeletedAt)
  46278. }
  46279. if m.app_key != nil {
  46280. fields = append(fields, xunji.FieldAppKey)
  46281. }
  46282. if m.app_secret != nil {
  46283. fields = append(fields, xunji.FieldAppSecret)
  46284. }
  46285. if m.token != nil {
  46286. fields = append(fields, xunji.FieldToken)
  46287. }
  46288. if m.encoding_key != nil {
  46289. fields = append(fields, xunji.FieldEncodingKey)
  46290. }
  46291. if m.agent_id != nil {
  46292. fields = append(fields, xunji.FieldAgentID)
  46293. }
  46294. if m.organization_id != nil {
  46295. fields = append(fields, xunji.FieldOrganizationID)
  46296. }
  46297. if m.wxid != nil {
  46298. fields = append(fields, xunji.FieldWxid)
  46299. }
  46300. if m.api_base != nil {
  46301. fields = append(fields, xunji.FieldAPIBase)
  46302. }
  46303. if m.api_key != nil {
  46304. fields = append(fields, xunji.FieldAPIKey)
  46305. }
  46306. return fields
  46307. }
  46308. // Field returns the value of a field with the given name. The second boolean
  46309. // return value indicates that this field was not set, or was not defined in the
  46310. // schema.
  46311. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46312. switch name {
  46313. case xunji.FieldCreatedAt:
  46314. return m.CreatedAt()
  46315. case xunji.FieldUpdatedAt:
  46316. return m.UpdatedAt()
  46317. case xunji.FieldStatus:
  46318. return m.Status()
  46319. case xunji.FieldDeletedAt:
  46320. return m.DeletedAt()
  46321. case xunji.FieldAppKey:
  46322. return m.AppKey()
  46323. case xunji.FieldAppSecret:
  46324. return m.AppSecret()
  46325. case xunji.FieldToken:
  46326. return m.Token()
  46327. case xunji.FieldEncodingKey:
  46328. return m.EncodingKey()
  46329. case xunji.FieldAgentID:
  46330. return m.AgentID()
  46331. case xunji.FieldOrganizationID:
  46332. return m.OrganizationID()
  46333. case xunji.FieldWxid:
  46334. return m.Wxid()
  46335. case xunji.FieldAPIBase:
  46336. return m.APIBase()
  46337. case xunji.FieldAPIKey:
  46338. return m.APIKey()
  46339. }
  46340. return nil, false
  46341. }
  46342. // OldField returns the old value of the field from the database. An error is
  46343. // returned if the mutation operation is not UpdateOne, or the query to the
  46344. // database failed.
  46345. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46346. switch name {
  46347. case xunji.FieldCreatedAt:
  46348. return m.OldCreatedAt(ctx)
  46349. case xunji.FieldUpdatedAt:
  46350. return m.OldUpdatedAt(ctx)
  46351. case xunji.FieldStatus:
  46352. return m.OldStatus(ctx)
  46353. case xunji.FieldDeletedAt:
  46354. return m.OldDeletedAt(ctx)
  46355. case xunji.FieldAppKey:
  46356. return m.OldAppKey(ctx)
  46357. case xunji.FieldAppSecret:
  46358. return m.OldAppSecret(ctx)
  46359. case xunji.FieldToken:
  46360. return m.OldToken(ctx)
  46361. case xunji.FieldEncodingKey:
  46362. return m.OldEncodingKey(ctx)
  46363. case xunji.FieldAgentID:
  46364. return m.OldAgentID(ctx)
  46365. case xunji.FieldOrganizationID:
  46366. return m.OldOrganizationID(ctx)
  46367. case xunji.FieldWxid:
  46368. return m.OldWxid(ctx)
  46369. case xunji.FieldAPIBase:
  46370. return m.OldAPIBase(ctx)
  46371. case xunji.FieldAPIKey:
  46372. return m.OldAPIKey(ctx)
  46373. }
  46374. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46375. }
  46376. // SetField sets the value of a field with the given name. It returns an error if
  46377. // the field is not defined in the schema, or if the type mismatched the field
  46378. // type.
  46379. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46380. switch name {
  46381. case xunji.FieldCreatedAt:
  46382. v, ok := value.(time.Time)
  46383. if !ok {
  46384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46385. }
  46386. m.SetCreatedAt(v)
  46387. return nil
  46388. case xunji.FieldUpdatedAt:
  46389. v, ok := value.(time.Time)
  46390. if !ok {
  46391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46392. }
  46393. m.SetUpdatedAt(v)
  46394. return nil
  46395. case xunji.FieldStatus:
  46396. v, ok := value.(uint8)
  46397. if !ok {
  46398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46399. }
  46400. m.SetStatus(v)
  46401. return nil
  46402. case xunji.FieldDeletedAt:
  46403. v, ok := value.(time.Time)
  46404. if !ok {
  46405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46406. }
  46407. m.SetDeletedAt(v)
  46408. return nil
  46409. case xunji.FieldAppKey:
  46410. v, ok := value.(string)
  46411. if !ok {
  46412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46413. }
  46414. m.SetAppKey(v)
  46415. return nil
  46416. case xunji.FieldAppSecret:
  46417. v, ok := value.(string)
  46418. if !ok {
  46419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46420. }
  46421. m.SetAppSecret(v)
  46422. return nil
  46423. case xunji.FieldToken:
  46424. v, ok := value.(string)
  46425. if !ok {
  46426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46427. }
  46428. m.SetToken(v)
  46429. return nil
  46430. case xunji.FieldEncodingKey:
  46431. v, ok := value.(string)
  46432. if !ok {
  46433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46434. }
  46435. m.SetEncodingKey(v)
  46436. return nil
  46437. case xunji.FieldAgentID:
  46438. v, ok := value.(uint64)
  46439. if !ok {
  46440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46441. }
  46442. m.SetAgentID(v)
  46443. return nil
  46444. case xunji.FieldOrganizationID:
  46445. v, ok := value.(uint64)
  46446. if !ok {
  46447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46448. }
  46449. m.SetOrganizationID(v)
  46450. return nil
  46451. case xunji.FieldWxid:
  46452. v, ok := value.(string)
  46453. if !ok {
  46454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46455. }
  46456. m.SetWxid(v)
  46457. return nil
  46458. case xunji.FieldAPIBase:
  46459. v, ok := value.(string)
  46460. if !ok {
  46461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46462. }
  46463. m.SetAPIBase(v)
  46464. return nil
  46465. case xunji.FieldAPIKey:
  46466. v, ok := value.(string)
  46467. if !ok {
  46468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46469. }
  46470. m.SetAPIKey(v)
  46471. return nil
  46472. }
  46473. return fmt.Errorf("unknown Xunji field %s", name)
  46474. }
  46475. // AddedFields returns all numeric fields that were incremented/decremented during
  46476. // this mutation.
  46477. func (m *XunjiMutation) AddedFields() []string {
  46478. var fields []string
  46479. if m.addstatus != nil {
  46480. fields = append(fields, xunji.FieldStatus)
  46481. }
  46482. if m.addagent_id != nil {
  46483. fields = append(fields, xunji.FieldAgentID)
  46484. }
  46485. if m.addorganization_id != nil {
  46486. fields = append(fields, xunji.FieldOrganizationID)
  46487. }
  46488. return fields
  46489. }
  46490. // AddedField returns the numeric value that was incremented/decremented on a field
  46491. // with the given name. The second boolean return value indicates that this field
  46492. // was not set, or was not defined in the schema.
  46493. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46494. switch name {
  46495. case xunji.FieldStatus:
  46496. return m.AddedStatus()
  46497. case xunji.FieldAgentID:
  46498. return m.AddedAgentID()
  46499. case xunji.FieldOrganizationID:
  46500. return m.AddedOrganizationID()
  46501. }
  46502. return nil, false
  46503. }
  46504. // AddField adds the value to the field with the given name. It returns an error if
  46505. // the field is not defined in the schema, or if the type mismatched the field
  46506. // type.
  46507. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46508. switch name {
  46509. case xunji.FieldStatus:
  46510. v, ok := value.(int8)
  46511. if !ok {
  46512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46513. }
  46514. m.AddStatus(v)
  46515. return nil
  46516. case xunji.FieldAgentID:
  46517. v, ok := value.(int64)
  46518. if !ok {
  46519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46520. }
  46521. m.AddAgentID(v)
  46522. return nil
  46523. case xunji.FieldOrganizationID:
  46524. v, ok := value.(int64)
  46525. if !ok {
  46526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46527. }
  46528. m.AddOrganizationID(v)
  46529. return nil
  46530. }
  46531. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46532. }
  46533. // ClearedFields returns all nullable fields that were cleared during this
  46534. // mutation.
  46535. func (m *XunjiMutation) ClearedFields() []string {
  46536. var fields []string
  46537. if m.FieldCleared(xunji.FieldStatus) {
  46538. fields = append(fields, xunji.FieldStatus)
  46539. }
  46540. if m.FieldCleared(xunji.FieldDeletedAt) {
  46541. fields = append(fields, xunji.FieldDeletedAt)
  46542. }
  46543. if m.FieldCleared(xunji.FieldAPIBase) {
  46544. fields = append(fields, xunji.FieldAPIBase)
  46545. }
  46546. if m.FieldCleared(xunji.FieldAPIKey) {
  46547. fields = append(fields, xunji.FieldAPIKey)
  46548. }
  46549. return fields
  46550. }
  46551. // FieldCleared returns a boolean indicating if a field with the given name was
  46552. // cleared in this mutation.
  46553. func (m *XunjiMutation) FieldCleared(name string) bool {
  46554. _, ok := m.clearedFields[name]
  46555. return ok
  46556. }
  46557. // ClearField clears the value of the field with the given name. It returns an
  46558. // error if the field is not defined in the schema.
  46559. func (m *XunjiMutation) ClearField(name string) error {
  46560. switch name {
  46561. case xunji.FieldStatus:
  46562. m.ClearStatus()
  46563. return nil
  46564. case xunji.FieldDeletedAt:
  46565. m.ClearDeletedAt()
  46566. return nil
  46567. case xunji.FieldAPIBase:
  46568. m.ClearAPIBase()
  46569. return nil
  46570. case xunji.FieldAPIKey:
  46571. m.ClearAPIKey()
  46572. return nil
  46573. }
  46574. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46575. }
  46576. // ResetField resets all changes in the mutation for the field with the given name.
  46577. // It returns an error if the field is not defined in the schema.
  46578. func (m *XunjiMutation) ResetField(name string) error {
  46579. switch name {
  46580. case xunji.FieldCreatedAt:
  46581. m.ResetCreatedAt()
  46582. return nil
  46583. case xunji.FieldUpdatedAt:
  46584. m.ResetUpdatedAt()
  46585. return nil
  46586. case xunji.FieldStatus:
  46587. m.ResetStatus()
  46588. return nil
  46589. case xunji.FieldDeletedAt:
  46590. m.ResetDeletedAt()
  46591. return nil
  46592. case xunji.FieldAppKey:
  46593. m.ResetAppKey()
  46594. return nil
  46595. case xunji.FieldAppSecret:
  46596. m.ResetAppSecret()
  46597. return nil
  46598. case xunji.FieldToken:
  46599. m.ResetToken()
  46600. return nil
  46601. case xunji.FieldEncodingKey:
  46602. m.ResetEncodingKey()
  46603. return nil
  46604. case xunji.FieldAgentID:
  46605. m.ResetAgentID()
  46606. return nil
  46607. case xunji.FieldOrganizationID:
  46608. m.ResetOrganizationID()
  46609. return nil
  46610. case xunji.FieldWxid:
  46611. m.ResetWxid()
  46612. return nil
  46613. case xunji.FieldAPIBase:
  46614. m.ResetAPIBase()
  46615. return nil
  46616. case xunji.FieldAPIKey:
  46617. m.ResetAPIKey()
  46618. return nil
  46619. }
  46620. return fmt.Errorf("unknown Xunji field %s", name)
  46621. }
  46622. // AddedEdges returns all edge names that were set/added in this mutation.
  46623. func (m *XunjiMutation) AddedEdges() []string {
  46624. edges := make([]string, 0, 0)
  46625. return edges
  46626. }
  46627. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46628. // name in this mutation.
  46629. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46630. return nil
  46631. }
  46632. // RemovedEdges returns all edge names that were removed in this mutation.
  46633. func (m *XunjiMutation) RemovedEdges() []string {
  46634. edges := make([]string, 0, 0)
  46635. return edges
  46636. }
  46637. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46638. // the given name in this mutation.
  46639. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46640. return nil
  46641. }
  46642. // ClearedEdges returns all edge names that were cleared in this mutation.
  46643. func (m *XunjiMutation) ClearedEdges() []string {
  46644. edges := make([]string, 0, 0)
  46645. return edges
  46646. }
  46647. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46648. // was cleared in this mutation.
  46649. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46650. return false
  46651. }
  46652. // ClearEdge clears the value of the edge with the given name. It returns an error
  46653. // if that edge is not defined in the schema.
  46654. func (m *XunjiMutation) ClearEdge(name string) error {
  46655. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46656. }
  46657. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46658. // It returns an error if the edge is not defined in the schema.
  46659. func (m *XunjiMutation) ResetEdge(name string) error {
  46660. return fmt.Errorf("unknown Xunji edge %s", name)
  46661. }