mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432
  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. "wechat-api/ent/xunjiservice"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. TypeXunji = "Xunji"
  107. TypeXunjiService = "XunjiService"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. key_agent map[uint64]struct{}
  139. removedkey_agent map[uint64]struct{}
  140. clearedkey_agent bool
  141. xjs_agent map[uint64]struct{}
  142. removedxjs_agent map[uint64]struct{}
  143. clearedxjs_agent bool
  144. done bool
  145. oldValue func(context.Context) (*Agent, error)
  146. predicates []predicate.Agent
  147. }
  148. var _ ent.Mutation = (*AgentMutation)(nil)
  149. // agentOption allows management of the mutation configuration using functional options.
  150. type agentOption func(*AgentMutation)
  151. // newAgentMutation creates new mutation for the Agent entity.
  152. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  153. m := &AgentMutation{
  154. config: c,
  155. op: op,
  156. typ: TypeAgent,
  157. clearedFields: make(map[string]struct{}),
  158. }
  159. for _, opt := range opts {
  160. opt(m)
  161. }
  162. return m
  163. }
  164. // withAgentID sets the ID field of the mutation.
  165. func withAgentID(id uint64) agentOption {
  166. return func(m *AgentMutation) {
  167. var (
  168. err error
  169. once sync.Once
  170. value *Agent
  171. )
  172. m.oldValue = func(ctx context.Context) (*Agent, error) {
  173. once.Do(func() {
  174. if m.done {
  175. err = errors.New("querying old values post mutation is not allowed")
  176. } else {
  177. value, err = m.Client().Agent.Get(ctx, id)
  178. }
  179. })
  180. return value, err
  181. }
  182. m.id = &id
  183. }
  184. }
  185. // withAgent sets the old Agent of the mutation.
  186. func withAgent(node *Agent) agentOption {
  187. return func(m *AgentMutation) {
  188. m.oldValue = func(context.Context) (*Agent, error) {
  189. return node, nil
  190. }
  191. m.id = &node.ID
  192. }
  193. }
  194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  195. // executed in a transaction (ent.Tx), a transactional client is returned.
  196. func (m AgentMutation) Client() *Client {
  197. client := &Client{config: m.config}
  198. client.init()
  199. return client
  200. }
  201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  202. // it returns an error otherwise.
  203. func (m AgentMutation) Tx() (*Tx, error) {
  204. if _, ok := m.driver.(*txDriver); !ok {
  205. return nil, errors.New("ent: mutation is not running in a transaction")
  206. }
  207. tx := &Tx{config: m.config}
  208. tx.init()
  209. return tx, nil
  210. }
  211. // SetID sets the value of the id field. Note that this
  212. // operation is only accepted on creation of Agent entities.
  213. func (m *AgentMutation) SetID(id uint64) {
  214. m.id = &id
  215. }
  216. // ID returns the ID value in the mutation. Note that the ID is only available
  217. // if it was provided to the builder or after it was returned from the database.
  218. func (m *AgentMutation) ID() (id uint64, exists bool) {
  219. if m.id == nil {
  220. return
  221. }
  222. return *m.id, true
  223. }
  224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  225. // That means, if the mutation is applied within a transaction with an isolation level such
  226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  227. // or updated by the mutation.
  228. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  229. switch {
  230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  231. id, exists := m.ID()
  232. if exists {
  233. return []uint64{id}, nil
  234. }
  235. fallthrough
  236. case m.op.Is(OpUpdate | OpDelete):
  237. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  238. default:
  239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  240. }
  241. }
  242. // SetCreatedAt sets the "created_at" field.
  243. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  244. m.created_at = &t
  245. }
  246. // CreatedAt returns the value of the "created_at" field in the mutation.
  247. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  248. v := m.created_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  267. }
  268. return oldValue.CreatedAt, nil
  269. }
  270. // ResetCreatedAt resets all changes to the "created_at" field.
  271. func (m *AgentMutation) ResetCreatedAt() {
  272. m.created_at = nil
  273. }
  274. // SetUpdatedAt sets the "updated_at" field.
  275. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  276. m.updated_at = &t
  277. }
  278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  279. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  280. v := m.updated_at
  281. if v == nil {
  282. return
  283. }
  284. return *v, true
  285. }
  286. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  287. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  289. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  290. if !m.op.Is(OpUpdateOne) {
  291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  292. }
  293. if m.id == nil || m.oldValue == nil {
  294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  295. }
  296. oldValue, err := m.oldValue(ctx)
  297. if err != nil {
  298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  299. }
  300. return oldValue.UpdatedAt, nil
  301. }
  302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  303. func (m *AgentMutation) ResetUpdatedAt() {
  304. m.updated_at = nil
  305. }
  306. // SetDeletedAt sets the "deleted_at" field.
  307. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  308. m.deleted_at = &t
  309. }
  310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  311. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  312. v := m.deleted_at
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  331. }
  332. return oldValue.DeletedAt, nil
  333. }
  334. // ClearDeletedAt clears the value of the "deleted_at" field.
  335. func (m *AgentMutation) ClearDeletedAt() {
  336. m.deleted_at = nil
  337. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  338. }
  339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  340. func (m *AgentMutation) DeletedAtCleared() bool {
  341. _, ok := m.clearedFields[agent.FieldDeletedAt]
  342. return ok
  343. }
  344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  345. func (m *AgentMutation) ResetDeletedAt() {
  346. m.deleted_at = nil
  347. delete(m.clearedFields, agent.FieldDeletedAt)
  348. }
  349. // SetName sets the "name" field.
  350. func (m *AgentMutation) SetName(s string) {
  351. m.name = &s
  352. }
  353. // Name returns the value of the "name" field in the mutation.
  354. func (m *AgentMutation) Name() (r string, exists bool) {
  355. v := m.name
  356. if v == nil {
  357. return
  358. }
  359. return *v, true
  360. }
  361. // OldName returns the old "name" field's value of the Agent entity.
  362. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  364. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  365. if !m.op.Is(OpUpdateOne) {
  366. return v, errors.New("OldName is only allowed on UpdateOne operations")
  367. }
  368. if m.id == nil || m.oldValue == nil {
  369. return v, errors.New("OldName requires an ID field in the mutation")
  370. }
  371. oldValue, err := m.oldValue(ctx)
  372. if err != nil {
  373. return v, fmt.Errorf("querying old value for OldName: %w", err)
  374. }
  375. return oldValue.Name, nil
  376. }
  377. // ResetName resets all changes to the "name" field.
  378. func (m *AgentMutation) ResetName() {
  379. m.name = nil
  380. }
  381. // SetRole sets the "role" field.
  382. func (m *AgentMutation) SetRole(s string) {
  383. m.role = &s
  384. }
  385. // Role returns the value of the "role" field in the mutation.
  386. func (m *AgentMutation) Role() (r string, exists bool) {
  387. v := m.role
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldRole returns the old "role" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldRole requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  406. }
  407. return oldValue.Role, nil
  408. }
  409. // ResetRole resets all changes to the "role" field.
  410. func (m *AgentMutation) ResetRole() {
  411. m.role = nil
  412. }
  413. // SetStatus sets the "status" field.
  414. func (m *AgentMutation) SetStatus(i int) {
  415. m.status = &i
  416. m.addstatus = nil
  417. }
  418. // Status returns the value of the "status" field in the mutation.
  419. func (m *AgentMutation) Status() (r int, exists bool) {
  420. v := m.status
  421. if v == nil {
  422. return
  423. }
  424. return *v, true
  425. }
  426. // OldStatus returns the old "status" field's value of the Agent entity.
  427. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  429. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  430. if !m.op.Is(OpUpdateOne) {
  431. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  432. }
  433. if m.id == nil || m.oldValue == nil {
  434. return v, errors.New("OldStatus requires an ID field in the mutation")
  435. }
  436. oldValue, err := m.oldValue(ctx)
  437. if err != nil {
  438. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  439. }
  440. return oldValue.Status, nil
  441. }
  442. // AddStatus adds i to the "status" field.
  443. func (m *AgentMutation) AddStatus(i int) {
  444. if m.addstatus != nil {
  445. *m.addstatus += i
  446. } else {
  447. m.addstatus = &i
  448. }
  449. }
  450. // AddedStatus returns the value that was added to the "status" field in this mutation.
  451. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  452. v := m.addstatus
  453. if v == nil {
  454. return
  455. }
  456. return *v, true
  457. }
  458. // ClearStatus clears the value of the "status" field.
  459. func (m *AgentMutation) ClearStatus() {
  460. m.status = nil
  461. m.addstatus = nil
  462. m.clearedFields[agent.FieldStatus] = struct{}{}
  463. }
  464. // StatusCleared returns if the "status" field was cleared in this mutation.
  465. func (m *AgentMutation) StatusCleared() bool {
  466. _, ok := m.clearedFields[agent.FieldStatus]
  467. return ok
  468. }
  469. // ResetStatus resets all changes to the "status" field.
  470. func (m *AgentMutation) ResetStatus() {
  471. m.status = nil
  472. m.addstatus = nil
  473. delete(m.clearedFields, agent.FieldStatus)
  474. }
  475. // SetBackground sets the "background" field.
  476. func (m *AgentMutation) SetBackground(s string) {
  477. m.background = &s
  478. }
  479. // Background returns the value of the "background" field in the mutation.
  480. func (m *AgentMutation) Background() (r string, exists bool) {
  481. v := m.background
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldBackground returns the old "background" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldBackground requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  500. }
  501. return oldValue.Background, nil
  502. }
  503. // ClearBackground clears the value of the "background" field.
  504. func (m *AgentMutation) ClearBackground() {
  505. m.background = nil
  506. m.clearedFields[agent.FieldBackground] = struct{}{}
  507. }
  508. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  509. func (m *AgentMutation) BackgroundCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldBackground]
  511. return ok
  512. }
  513. // ResetBackground resets all changes to the "background" field.
  514. func (m *AgentMutation) ResetBackground() {
  515. m.background = nil
  516. delete(m.clearedFields, agent.FieldBackground)
  517. }
  518. // SetExamples sets the "examples" field.
  519. func (m *AgentMutation) SetExamples(s string) {
  520. m.examples = &s
  521. }
  522. // Examples returns the value of the "examples" field in the mutation.
  523. func (m *AgentMutation) Examples() (r string, exists bool) {
  524. v := m.examples
  525. if v == nil {
  526. return
  527. }
  528. return *v, true
  529. }
  530. // OldExamples returns the old "examples" field's value of the Agent entity.
  531. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  533. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  534. if !m.op.Is(OpUpdateOne) {
  535. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  536. }
  537. if m.id == nil || m.oldValue == nil {
  538. return v, errors.New("OldExamples requires an ID field in the mutation")
  539. }
  540. oldValue, err := m.oldValue(ctx)
  541. if err != nil {
  542. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  543. }
  544. return oldValue.Examples, nil
  545. }
  546. // ClearExamples clears the value of the "examples" field.
  547. func (m *AgentMutation) ClearExamples() {
  548. m.examples = nil
  549. m.clearedFields[agent.FieldExamples] = struct{}{}
  550. }
  551. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  552. func (m *AgentMutation) ExamplesCleared() bool {
  553. _, ok := m.clearedFields[agent.FieldExamples]
  554. return ok
  555. }
  556. // ResetExamples resets all changes to the "examples" field.
  557. func (m *AgentMutation) ResetExamples() {
  558. m.examples = nil
  559. delete(m.clearedFields, agent.FieldExamples)
  560. }
  561. // SetOrganizationID sets the "organization_id" field.
  562. func (m *AgentMutation) SetOrganizationID(u uint64) {
  563. m.organization_id = &u
  564. m.addorganization_id = nil
  565. }
  566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  567. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  568. v := m.organization_id
  569. if v == nil {
  570. return
  571. }
  572. return *v, true
  573. }
  574. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  575. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  577. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  578. if !m.op.Is(OpUpdateOne) {
  579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  580. }
  581. if m.id == nil || m.oldValue == nil {
  582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  583. }
  584. oldValue, err := m.oldValue(ctx)
  585. if err != nil {
  586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  587. }
  588. return oldValue.OrganizationID, nil
  589. }
  590. // AddOrganizationID adds u to the "organization_id" field.
  591. func (m *AgentMutation) AddOrganizationID(u int64) {
  592. if m.addorganization_id != nil {
  593. *m.addorganization_id += u
  594. } else {
  595. m.addorganization_id = &u
  596. }
  597. }
  598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  599. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  600. v := m.addorganization_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // ResetOrganizationID resets all changes to the "organization_id" field.
  607. func (m *AgentMutation) ResetOrganizationID() {
  608. m.organization_id = nil
  609. m.addorganization_id = nil
  610. }
  611. // SetDatasetID sets the "dataset_id" field.
  612. func (m *AgentMutation) SetDatasetID(s string) {
  613. m.dataset_id = &s
  614. }
  615. // DatasetID returns the value of the "dataset_id" field in the mutation.
  616. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  617. v := m.dataset_id
  618. if v == nil {
  619. return
  620. }
  621. return *v, true
  622. }
  623. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  624. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  626. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  627. if !m.op.Is(OpUpdateOne) {
  628. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  629. }
  630. if m.id == nil || m.oldValue == nil {
  631. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  632. }
  633. oldValue, err := m.oldValue(ctx)
  634. if err != nil {
  635. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  636. }
  637. return oldValue.DatasetID, nil
  638. }
  639. // ResetDatasetID resets all changes to the "dataset_id" field.
  640. func (m *AgentMutation) ResetDatasetID() {
  641. m.dataset_id = nil
  642. }
  643. // SetCollectionID sets the "collection_id" field.
  644. func (m *AgentMutation) SetCollectionID(s string) {
  645. m.collection_id = &s
  646. }
  647. // CollectionID returns the value of the "collection_id" field in the mutation.
  648. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  649. v := m.collection_id
  650. if v == nil {
  651. return
  652. }
  653. return *v, true
  654. }
  655. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  656. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  658. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  659. if !m.op.Is(OpUpdateOne) {
  660. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  661. }
  662. if m.id == nil || m.oldValue == nil {
  663. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  664. }
  665. oldValue, err := m.oldValue(ctx)
  666. if err != nil {
  667. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  668. }
  669. return oldValue.CollectionID, nil
  670. }
  671. // ResetCollectionID resets all changes to the "collection_id" field.
  672. func (m *AgentMutation) ResetCollectionID() {
  673. m.collection_id = nil
  674. }
  675. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  676. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  677. if m.wx_agent == nil {
  678. m.wx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. m.wx_agent[ids[i]] = struct{}{}
  682. }
  683. }
  684. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  685. func (m *AgentMutation) ClearWxAgent() {
  686. m.clearedwx_agent = true
  687. }
  688. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  689. func (m *AgentMutation) WxAgentCleared() bool {
  690. return m.clearedwx_agent
  691. }
  692. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  693. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  694. if m.removedwx_agent == nil {
  695. m.removedwx_agent = make(map[uint64]struct{})
  696. }
  697. for i := range ids {
  698. delete(m.wx_agent, ids[i])
  699. m.removedwx_agent[ids[i]] = struct{}{}
  700. }
  701. }
  702. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  703. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  704. for id := range m.removedwx_agent {
  705. ids = append(ids, id)
  706. }
  707. return
  708. }
  709. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  710. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  711. for id := range m.wx_agent {
  712. ids = append(ids, id)
  713. }
  714. return
  715. }
  716. // ResetWxAgent resets all changes to the "wx_agent" edge.
  717. func (m *AgentMutation) ResetWxAgent() {
  718. m.wx_agent = nil
  719. m.clearedwx_agent = false
  720. m.removedwx_agent = nil
  721. }
  722. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  723. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  724. if m.token_agent == nil {
  725. m.token_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. m.token_agent[ids[i]] = struct{}{}
  729. }
  730. }
  731. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  732. func (m *AgentMutation) ClearTokenAgent() {
  733. m.clearedtoken_agent = true
  734. }
  735. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  736. func (m *AgentMutation) TokenAgentCleared() bool {
  737. return m.clearedtoken_agent
  738. }
  739. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  740. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  741. if m.removedtoken_agent == nil {
  742. m.removedtoken_agent = make(map[uint64]struct{})
  743. }
  744. for i := range ids {
  745. delete(m.token_agent, ids[i])
  746. m.removedtoken_agent[ids[i]] = struct{}{}
  747. }
  748. }
  749. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  750. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  751. for id := range m.removedtoken_agent {
  752. ids = append(ids, id)
  753. }
  754. return
  755. }
  756. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  757. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  758. for id := range m.token_agent {
  759. ids = append(ids, id)
  760. }
  761. return
  762. }
  763. // ResetTokenAgent resets all changes to the "token_agent" edge.
  764. func (m *AgentMutation) ResetTokenAgent() {
  765. m.token_agent = nil
  766. m.clearedtoken_agent = false
  767. m.removedtoken_agent = nil
  768. }
  769. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  770. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  771. if m.wa_agent == nil {
  772. m.wa_agent = make(map[uint64]struct{})
  773. }
  774. for i := range ids {
  775. m.wa_agent[ids[i]] = struct{}{}
  776. }
  777. }
  778. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  779. func (m *AgentMutation) ClearWaAgent() {
  780. m.clearedwa_agent = true
  781. }
  782. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  783. func (m *AgentMutation) WaAgentCleared() bool {
  784. return m.clearedwa_agent
  785. }
  786. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  787. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  788. if m.removedwa_agent == nil {
  789. m.removedwa_agent = make(map[uint64]struct{})
  790. }
  791. for i := range ids {
  792. delete(m.wa_agent, ids[i])
  793. m.removedwa_agent[ids[i]] = struct{}{}
  794. }
  795. }
  796. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  797. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  798. for id := range m.removedwa_agent {
  799. ids = append(ids, id)
  800. }
  801. return
  802. }
  803. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  804. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  805. for id := range m.wa_agent {
  806. ids = append(ids, id)
  807. }
  808. return
  809. }
  810. // ResetWaAgent resets all changes to the "wa_agent" edge.
  811. func (m *AgentMutation) ResetWaAgent() {
  812. m.wa_agent = nil
  813. m.clearedwa_agent = false
  814. m.removedwa_agent = nil
  815. }
  816. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  817. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  818. if m.key_agent == nil {
  819. m.key_agent = make(map[uint64]struct{})
  820. }
  821. for i := range ids {
  822. m.key_agent[ids[i]] = struct{}{}
  823. }
  824. }
  825. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  826. func (m *AgentMutation) ClearKeyAgent() {
  827. m.clearedkey_agent = true
  828. }
  829. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  830. func (m *AgentMutation) KeyAgentCleared() bool {
  831. return m.clearedkey_agent
  832. }
  833. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  834. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  835. if m.removedkey_agent == nil {
  836. m.removedkey_agent = make(map[uint64]struct{})
  837. }
  838. for i := range ids {
  839. delete(m.key_agent, ids[i])
  840. m.removedkey_agent[ids[i]] = struct{}{}
  841. }
  842. }
  843. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  844. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  845. for id := range m.removedkey_agent {
  846. ids = append(ids, id)
  847. }
  848. return
  849. }
  850. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  851. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  852. for id := range m.key_agent {
  853. ids = append(ids, id)
  854. }
  855. return
  856. }
  857. // ResetKeyAgent resets all changes to the "key_agent" edge.
  858. func (m *AgentMutation) ResetKeyAgent() {
  859. m.key_agent = nil
  860. m.clearedkey_agent = false
  861. m.removedkey_agent = nil
  862. }
  863. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  864. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  865. if m.xjs_agent == nil {
  866. m.xjs_agent = make(map[uint64]struct{})
  867. }
  868. for i := range ids {
  869. m.xjs_agent[ids[i]] = struct{}{}
  870. }
  871. }
  872. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  873. func (m *AgentMutation) ClearXjsAgent() {
  874. m.clearedxjs_agent = true
  875. }
  876. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  877. func (m *AgentMutation) XjsAgentCleared() bool {
  878. return m.clearedxjs_agent
  879. }
  880. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  881. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  882. if m.removedxjs_agent == nil {
  883. m.removedxjs_agent = make(map[uint64]struct{})
  884. }
  885. for i := range ids {
  886. delete(m.xjs_agent, ids[i])
  887. m.removedxjs_agent[ids[i]] = struct{}{}
  888. }
  889. }
  890. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  891. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  892. for id := range m.removedxjs_agent {
  893. ids = append(ids, id)
  894. }
  895. return
  896. }
  897. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  898. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  899. for id := range m.xjs_agent {
  900. ids = append(ids, id)
  901. }
  902. return
  903. }
  904. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  905. func (m *AgentMutation) ResetXjsAgent() {
  906. m.xjs_agent = nil
  907. m.clearedxjs_agent = false
  908. m.removedxjs_agent = nil
  909. }
  910. // Where appends a list predicates to the AgentMutation builder.
  911. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  912. m.predicates = append(m.predicates, ps...)
  913. }
  914. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  915. // users can use type-assertion to append predicates that do not depend on any generated package.
  916. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  917. p := make([]predicate.Agent, len(ps))
  918. for i := range ps {
  919. p[i] = ps[i]
  920. }
  921. m.Where(p...)
  922. }
  923. // Op returns the operation name.
  924. func (m *AgentMutation) Op() Op {
  925. return m.op
  926. }
  927. // SetOp allows setting the mutation operation.
  928. func (m *AgentMutation) SetOp(op Op) {
  929. m.op = op
  930. }
  931. // Type returns the node type of this mutation (Agent).
  932. func (m *AgentMutation) Type() string {
  933. return m.typ
  934. }
  935. // Fields returns all fields that were changed during this mutation. Note that in
  936. // order to get all numeric fields that were incremented/decremented, call
  937. // AddedFields().
  938. func (m *AgentMutation) Fields() []string {
  939. fields := make([]string, 0, 11)
  940. if m.created_at != nil {
  941. fields = append(fields, agent.FieldCreatedAt)
  942. }
  943. if m.updated_at != nil {
  944. fields = append(fields, agent.FieldUpdatedAt)
  945. }
  946. if m.deleted_at != nil {
  947. fields = append(fields, agent.FieldDeletedAt)
  948. }
  949. if m.name != nil {
  950. fields = append(fields, agent.FieldName)
  951. }
  952. if m.role != nil {
  953. fields = append(fields, agent.FieldRole)
  954. }
  955. if m.status != nil {
  956. fields = append(fields, agent.FieldStatus)
  957. }
  958. if m.background != nil {
  959. fields = append(fields, agent.FieldBackground)
  960. }
  961. if m.examples != nil {
  962. fields = append(fields, agent.FieldExamples)
  963. }
  964. if m.organization_id != nil {
  965. fields = append(fields, agent.FieldOrganizationID)
  966. }
  967. if m.dataset_id != nil {
  968. fields = append(fields, agent.FieldDatasetID)
  969. }
  970. if m.collection_id != nil {
  971. fields = append(fields, agent.FieldCollectionID)
  972. }
  973. return fields
  974. }
  975. // Field returns the value of a field with the given name. The second boolean
  976. // return value indicates that this field was not set, or was not defined in the
  977. // schema.
  978. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  979. switch name {
  980. case agent.FieldCreatedAt:
  981. return m.CreatedAt()
  982. case agent.FieldUpdatedAt:
  983. return m.UpdatedAt()
  984. case agent.FieldDeletedAt:
  985. return m.DeletedAt()
  986. case agent.FieldName:
  987. return m.Name()
  988. case agent.FieldRole:
  989. return m.Role()
  990. case agent.FieldStatus:
  991. return m.Status()
  992. case agent.FieldBackground:
  993. return m.Background()
  994. case agent.FieldExamples:
  995. return m.Examples()
  996. case agent.FieldOrganizationID:
  997. return m.OrganizationID()
  998. case agent.FieldDatasetID:
  999. return m.DatasetID()
  1000. case agent.FieldCollectionID:
  1001. return m.CollectionID()
  1002. }
  1003. return nil, false
  1004. }
  1005. // OldField returns the old value of the field from the database. An error is
  1006. // returned if the mutation operation is not UpdateOne, or the query to the
  1007. // database failed.
  1008. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1009. switch name {
  1010. case agent.FieldCreatedAt:
  1011. return m.OldCreatedAt(ctx)
  1012. case agent.FieldUpdatedAt:
  1013. return m.OldUpdatedAt(ctx)
  1014. case agent.FieldDeletedAt:
  1015. return m.OldDeletedAt(ctx)
  1016. case agent.FieldName:
  1017. return m.OldName(ctx)
  1018. case agent.FieldRole:
  1019. return m.OldRole(ctx)
  1020. case agent.FieldStatus:
  1021. return m.OldStatus(ctx)
  1022. case agent.FieldBackground:
  1023. return m.OldBackground(ctx)
  1024. case agent.FieldExamples:
  1025. return m.OldExamples(ctx)
  1026. case agent.FieldOrganizationID:
  1027. return m.OldOrganizationID(ctx)
  1028. case agent.FieldDatasetID:
  1029. return m.OldDatasetID(ctx)
  1030. case agent.FieldCollectionID:
  1031. return m.OldCollectionID(ctx)
  1032. }
  1033. return nil, fmt.Errorf("unknown Agent field %s", name)
  1034. }
  1035. // SetField sets the value of a field with the given name. It returns an error if
  1036. // the field is not defined in the schema, or if the type mismatched the field
  1037. // type.
  1038. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1039. switch name {
  1040. case agent.FieldCreatedAt:
  1041. v, ok := value.(time.Time)
  1042. if !ok {
  1043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1044. }
  1045. m.SetCreatedAt(v)
  1046. return nil
  1047. case agent.FieldUpdatedAt:
  1048. v, ok := value.(time.Time)
  1049. if !ok {
  1050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1051. }
  1052. m.SetUpdatedAt(v)
  1053. return nil
  1054. case agent.FieldDeletedAt:
  1055. v, ok := value.(time.Time)
  1056. if !ok {
  1057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1058. }
  1059. m.SetDeletedAt(v)
  1060. return nil
  1061. case agent.FieldName:
  1062. v, ok := value.(string)
  1063. if !ok {
  1064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1065. }
  1066. m.SetName(v)
  1067. return nil
  1068. case agent.FieldRole:
  1069. v, ok := value.(string)
  1070. if !ok {
  1071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1072. }
  1073. m.SetRole(v)
  1074. return nil
  1075. case agent.FieldStatus:
  1076. v, ok := value.(int)
  1077. if !ok {
  1078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1079. }
  1080. m.SetStatus(v)
  1081. return nil
  1082. case agent.FieldBackground:
  1083. v, ok := value.(string)
  1084. if !ok {
  1085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1086. }
  1087. m.SetBackground(v)
  1088. return nil
  1089. case agent.FieldExamples:
  1090. v, ok := value.(string)
  1091. if !ok {
  1092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1093. }
  1094. m.SetExamples(v)
  1095. return nil
  1096. case agent.FieldOrganizationID:
  1097. v, ok := value.(uint64)
  1098. if !ok {
  1099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1100. }
  1101. m.SetOrganizationID(v)
  1102. return nil
  1103. case agent.FieldDatasetID:
  1104. v, ok := value.(string)
  1105. if !ok {
  1106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1107. }
  1108. m.SetDatasetID(v)
  1109. return nil
  1110. case agent.FieldCollectionID:
  1111. v, ok := value.(string)
  1112. if !ok {
  1113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1114. }
  1115. m.SetCollectionID(v)
  1116. return nil
  1117. }
  1118. return fmt.Errorf("unknown Agent field %s", name)
  1119. }
  1120. // AddedFields returns all numeric fields that were incremented/decremented during
  1121. // this mutation.
  1122. func (m *AgentMutation) AddedFields() []string {
  1123. var fields []string
  1124. if m.addstatus != nil {
  1125. fields = append(fields, agent.FieldStatus)
  1126. }
  1127. if m.addorganization_id != nil {
  1128. fields = append(fields, agent.FieldOrganizationID)
  1129. }
  1130. return fields
  1131. }
  1132. // AddedField returns the numeric value that was incremented/decremented on a field
  1133. // with the given name. The second boolean return value indicates that this field
  1134. // was not set, or was not defined in the schema.
  1135. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1136. switch name {
  1137. case agent.FieldStatus:
  1138. return m.AddedStatus()
  1139. case agent.FieldOrganizationID:
  1140. return m.AddedOrganizationID()
  1141. }
  1142. return nil, false
  1143. }
  1144. // AddField adds the value to the field with the given name. It returns an error if
  1145. // the field is not defined in the schema, or if the type mismatched the field
  1146. // type.
  1147. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1148. switch name {
  1149. case agent.FieldStatus:
  1150. v, ok := value.(int)
  1151. if !ok {
  1152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1153. }
  1154. m.AddStatus(v)
  1155. return nil
  1156. case agent.FieldOrganizationID:
  1157. v, ok := value.(int64)
  1158. if !ok {
  1159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1160. }
  1161. m.AddOrganizationID(v)
  1162. return nil
  1163. }
  1164. return fmt.Errorf("unknown Agent numeric field %s", name)
  1165. }
  1166. // ClearedFields returns all nullable fields that were cleared during this
  1167. // mutation.
  1168. func (m *AgentMutation) ClearedFields() []string {
  1169. var fields []string
  1170. if m.FieldCleared(agent.FieldDeletedAt) {
  1171. fields = append(fields, agent.FieldDeletedAt)
  1172. }
  1173. if m.FieldCleared(agent.FieldStatus) {
  1174. fields = append(fields, agent.FieldStatus)
  1175. }
  1176. if m.FieldCleared(agent.FieldBackground) {
  1177. fields = append(fields, agent.FieldBackground)
  1178. }
  1179. if m.FieldCleared(agent.FieldExamples) {
  1180. fields = append(fields, agent.FieldExamples)
  1181. }
  1182. return fields
  1183. }
  1184. // FieldCleared returns a boolean indicating if a field with the given name was
  1185. // cleared in this mutation.
  1186. func (m *AgentMutation) FieldCleared(name string) bool {
  1187. _, ok := m.clearedFields[name]
  1188. return ok
  1189. }
  1190. // ClearField clears the value of the field with the given name. It returns an
  1191. // error if the field is not defined in the schema.
  1192. func (m *AgentMutation) ClearField(name string) error {
  1193. switch name {
  1194. case agent.FieldDeletedAt:
  1195. m.ClearDeletedAt()
  1196. return nil
  1197. case agent.FieldStatus:
  1198. m.ClearStatus()
  1199. return nil
  1200. case agent.FieldBackground:
  1201. m.ClearBackground()
  1202. return nil
  1203. case agent.FieldExamples:
  1204. m.ClearExamples()
  1205. return nil
  1206. }
  1207. return fmt.Errorf("unknown Agent nullable field %s", name)
  1208. }
  1209. // ResetField resets all changes in the mutation for the field with the given name.
  1210. // It returns an error if the field is not defined in the schema.
  1211. func (m *AgentMutation) ResetField(name string) error {
  1212. switch name {
  1213. case agent.FieldCreatedAt:
  1214. m.ResetCreatedAt()
  1215. return nil
  1216. case agent.FieldUpdatedAt:
  1217. m.ResetUpdatedAt()
  1218. return nil
  1219. case agent.FieldDeletedAt:
  1220. m.ResetDeletedAt()
  1221. return nil
  1222. case agent.FieldName:
  1223. m.ResetName()
  1224. return nil
  1225. case agent.FieldRole:
  1226. m.ResetRole()
  1227. return nil
  1228. case agent.FieldStatus:
  1229. m.ResetStatus()
  1230. return nil
  1231. case agent.FieldBackground:
  1232. m.ResetBackground()
  1233. return nil
  1234. case agent.FieldExamples:
  1235. m.ResetExamples()
  1236. return nil
  1237. case agent.FieldOrganizationID:
  1238. m.ResetOrganizationID()
  1239. return nil
  1240. case agent.FieldDatasetID:
  1241. m.ResetDatasetID()
  1242. return nil
  1243. case agent.FieldCollectionID:
  1244. m.ResetCollectionID()
  1245. return nil
  1246. }
  1247. return fmt.Errorf("unknown Agent field %s", name)
  1248. }
  1249. // AddedEdges returns all edge names that were set/added in this mutation.
  1250. func (m *AgentMutation) AddedEdges() []string {
  1251. edges := make([]string, 0, 5)
  1252. if m.wx_agent != nil {
  1253. edges = append(edges, agent.EdgeWxAgent)
  1254. }
  1255. if m.token_agent != nil {
  1256. edges = append(edges, agent.EdgeTokenAgent)
  1257. }
  1258. if m.wa_agent != nil {
  1259. edges = append(edges, agent.EdgeWaAgent)
  1260. }
  1261. if m.key_agent != nil {
  1262. edges = append(edges, agent.EdgeKeyAgent)
  1263. }
  1264. if m.xjs_agent != nil {
  1265. edges = append(edges, agent.EdgeXjsAgent)
  1266. }
  1267. return edges
  1268. }
  1269. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1270. // name in this mutation.
  1271. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1272. switch name {
  1273. case agent.EdgeWxAgent:
  1274. ids := make([]ent.Value, 0, len(m.wx_agent))
  1275. for id := range m.wx_agent {
  1276. ids = append(ids, id)
  1277. }
  1278. return ids
  1279. case agent.EdgeTokenAgent:
  1280. ids := make([]ent.Value, 0, len(m.token_agent))
  1281. for id := range m.token_agent {
  1282. ids = append(ids, id)
  1283. }
  1284. return ids
  1285. case agent.EdgeWaAgent:
  1286. ids := make([]ent.Value, 0, len(m.wa_agent))
  1287. for id := range m.wa_agent {
  1288. ids = append(ids, id)
  1289. }
  1290. return ids
  1291. case agent.EdgeKeyAgent:
  1292. ids := make([]ent.Value, 0, len(m.key_agent))
  1293. for id := range m.key_agent {
  1294. ids = append(ids, id)
  1295. }
  1296. return ids
  1297. case agent.EdgeXjsAgent:
  1298. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1299. for id := range m.xjs_agent {
  1300. ids = append(ids, id)
  1301. }
  1302. return ids
  1303. }
  1304. return nil
  1305. }
  1306. // RemovedEdges returns all edge names that were removed in this mutation.
  1307. func (m *AgentMutation) RemovedEdges() []string {
  1308. edges := make([]string, 0, 5)
  1309. if m.removedwx_agent != nil {
  1310. edges = append(edges, agent.EdgeWxAgent)
  1311. }
  1312. if m.removedtoken_agent != nil {
  1313. edges = append(edges, agent.EdgeTokenAgent)
  1314. }
  1315. if m.removedwa_agent != nil {
  1316. edges = append(edges, agent.EdgeWaAgent)
  1317. }
  1318. if m.removedkey_agent != nil {
  1319. edges = append(edges, agent.EdgeKeyAgent)
  1320. }
  1321. if m.removedxjs_agent != nil {
  1322. edges = append(edges, agent.EdgeXjsAgent)
  1323. }
  1324. return edges
  1325. }
  1326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1327. // the given name in this mutation.
  1328. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1329. switch name {
  1330. case agent.EdgeWxAgent:
  1331. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1332. for id := range m.removedwx_agent {
  1333. ids = append(ids, id)
  1334. }
  1335. return ids
  1336. case agent.EdgeTokenAgent:
  1337. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1338. for id := range m.removedtoken_agent {
  1339. ids = append(ids, id)
  1340. }
  1341. return ids
  1342. case agent.EdgeWaAgent:
  1343. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1344. for id := range m.removedwa_agent {
  1345. ids = append(ids, id)
  1346. }
  1347. return ids
  1348. case agent.EdgeKeyAgent:
  1349. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1350. for id := range m.removedkey_agent {
  1351. ids = append(ids, id)
  1352. }
  1353. return ids
  1354. case agent.EdgeXjsAgent:
  1355. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1356. for id := range m.removedxjs_agent {
  1357. ids = append(ids, id)
  1358. }
  1359. return ids
  1360. }
  1361. return nil
  1362. }
  1363. // ClearedEdges returns all edge names that were cleared in this mutation.
  1364. func (m *AgentMutation) ClearedEdges() []string {
  1365. edges := make([]string, 0, 5)
  1366. if m.clearedwx_agent {
  1367. edges = append(edges, agent.EdgeWxAgent)
  1368. }
  1369. if m.clearedtoken_agent {
  1370. edges = append(edges, agent.EdgeTokenAgent)
  1371. }
  1372. if m.clearedwa_agent {
  1373. edges = append(edges, agent.EdgeWaAgent)
  1374. }
  1375. if m.clearedkey_agent {
  1376. edges = append(edges, agent.EdgeKeyAgent)
  1377. }
  1378. if m.clearedxjs_agent {
  1379. edges = append(edges, agent.EdgeXjsAgent)
  1380. }
  1381. return edges
  1382. }
  1383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1384. // was cleared in this mutation.
  1385. func (m *AgentMutation) EdgeCleared(name string) bool {
  1386. switch name {
  1387. case agent.EdgeWxAgent:
  1388. return m.clearedwx_agent
  1389. case agent.EdgeTokenAgent:
  1390. return m.clearedtoken_agent
  1391. case agent.EdgeWaAgent:
  1392. return m.clearedwa_agent
  1393. case agent.EdgeKeyAgent:
  1394. return m.clearedkey_agent
  1395. case agent.EdgeXjsAgent:
  1396. return m.clearedxjs_agent
  1397. }
  1398. return false
  1399. }
  1400. // ClearEdge clears the value of the edge with the given name. It returns an error
  1401. // if that edge is not defined in the schema.
  1402. func (m *AgentMutation) ClearEdge(name string) error {
  1403. switch name {
  1404. }
  1405. return fmt.Errorf("unknown Agent unique edge %s", name)
  1406. }
  1407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1408. // It returns an error if the edge is not defined in the schema.
  1409. func (m *AgentMutation) ResetEdge(name string) error {
  1410. switch name {
  1411. case agent.EdgeWxAgent:
  1412. m.ResetWxAgent()
  1413. return nil
  1414. case agent.EdgeTokenAgent:
  1415. m.ResetTokenAgent()
  1416. return nil
  1417. case agent.EdgeWaAgent:
  1418. m.ResetWaAgent()
  1419. return nil
  1420. case agent.EdgeKeyAgent:
  1421. m.ResetKeyAgent()
  1422. return nil
  1423. case agent.EdgeXjsAgent:
  1424. m.ResetXjsAgent()
  1425. return nil
  1426. }
  1427. return fmt.Errorf("unknown Agent edge %s", name)
  1428. }
  1429. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1430. type AgentBaseMutation struct {
  1431. config
  1432. op Op
  1433. typ string
  1434. id *string
  1435. q *string
  1436. a *string
  1437. chunk_index *uint64
  1438. addchunk_index *int64
  1439. indexes *[]string
  1440. appendindexes []string
  1441. dataset_id *string
  1442. collection_id *string
  1443. source_name *string
  1444. can_write *[]bool
  1445. appendcan_write []bool
  1446. is_owner *[]bool
  1447. appendis_owner []bool
  1448. clearedFields map[string]struct{}
  1449. wx_agent map[uint64]struct{}
  1450. removedwx_agent map[uint64]struct{}
  1451. clearedwx_agent bool
  1452. done bool
  1453. oldValue func(context.Context) (*AgentBase, error)
  1454. predicates []predicate.AgentBase
  1455. }
  1456. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1457. // agentbaseOption allows management of the mutation configuration using functional options.
  1458. type agentbaseOption func(*AgentBaseMutation)
  1459. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1460. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1461. m := &AgentBaseMutation{
  1462. config: c,
  1463. op: op,
  1464. typ: TypeAgentBase,
  1465. clearedFields: make(map[string]struct{}),
  1466. }
  1467. for _, opt := range opts {
  1468. opt(m)
  1469. }
  1470. return m
  1471. }
  1472. // withAgentBaseID sets the ID field of the mutation.
  1473. func withAgentBaseID(id string) agentbaseOption {
  1474. return func(m *AgentBaseMutation) {
  1475. var (
  1476. err error
  1477. once sync.Once
  1478. value *AgentBase
  1479. )
  1480. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1481. once.Do(func() {
  1482. if m.done {
  1483. err = errors.New("querying old values post mutation is not allowed")
  1484. } else {
  1485. value, err = m.Client().AgentBase.Get(ctx, id)
  1486. }
  1487. })
  1488. return value, err
  1489. }
  1490. m.id = &id
  1491. }
  1492. }
  1493. // withAgentBase sets the old AgentBase of the mutation.
  1494. func withAgentBase(node *AgentBase) agentbaseOption {
  1495. return func(m *AgentBaseMutation) {
  1496. m.oldValue = func(context.Context) (*AgentBase, error) {
  1497. return node, nil
  1498. }
  1499. m.id = &node.ID
  1500. }
  1501. }
  1502. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1503. // executed in a transaction (ent.Tx), a transactional client is returned.
  1504. func (m AgentBaseMutation) Client() *Client {
  1505. client := &Client{config: m.config}
  1506. client.init()
  1507. return client
  1508. }
  1509. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1510. // it returns an error otherwise.
  1511. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1512. if _, ok := m.driver.(*txDriver); !ok {
  1513. return nil, errors.New("ent: mutation is not running in a transaction")
  1514. }
  1515. tx := &Tx{config: m.config}
  1516. tx.init()
  1517. return tx, nil
  1518. }
  1519. // SetID sets the value of the id field. Note that this
  1520. // operation is only accepted on creation of AgentBase entities.
  1521. func (m *AgentBaseMutation) SetID(id string) {
  1522. m.id = &id
  1523. }
  1524. // ID returns the ID value in the mutation. Note that the ID is only available
  1525. // if it was provided to the builder or after it was returned from the database.
  1526. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1527. if m.id == nil {
  1528. return
  1529. }
  1530. return *m.id, true
  1531. }
  1532. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1533. // That means, if the mutation is applied within a transaction with an isolation level such
  1534. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1535. // or updated by the mutation.
  1536. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1537. switch {
  1538. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1539. id, exists := m.ID()
  1540. if exists {
  1541. return []string{id}, nil
  1542. }
  1543. fallthrough
  1544. case m.op.Is(OpUpdate | OpDelete):
  1545. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1546. default:
  1547. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1548. }
  1549. }
  1550. // SetQ sets the "q" field.
  1551. func (m *AgentBaseMutation) SetQ(s string) {
  1552. m.q = &s
  1553. }
  1554. // Q returns the value of the "q" field in the mutation.
  1555. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1556. v := m.q
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldQ returns the old "q" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldQ requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1575. }
  1576. return oldValue.Q, nil
  1577. }
  1578. // ClearQ clears the value of the "q" field.
  1579. func (m *AgentBaseMutation) ClearQ() {
  1580. m.q = nil
  1581. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1582. }
  1583. // QCleared returns if the "q" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) QCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldQ]
  1586. return ok
  1587. }
  1588. // ResetQ resets all changes to the "q" field.
  1589. func (m *AgentBaseMutation) ResetQ() {
  1590. m.q = nil
  1591. delete(m.clearedFields, agentbase.FieldQ)
  1592. }
  1593. // SetA sets the "a" field.
  1594. func (m *AgentBaseMutation) SetA(s string) {
  1595. m.a = &s
  1596. }
  1597. // A returns the value of the "a" field in the mutation.
  1598. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1599. v := m.a
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldA returns the old "a" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldA requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1618. }
  1619. return oldValue.A, nil
  1620. }
  1621. // ClearA clears the value of the "a" field.
  1622. func (m *AgentBaseMutation) ClearA() {
  1623. m.a = nil
  1624. m.clearedFields[agentbase.FieldA] = struct{}{}
  1625. }
  1626. // ACleared returns if the "a" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) ACleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldA]
  1629. return ok
  1630. }
  1631. // ResetA resets all changes to the "a" field.
  1632. func (m *AgentBaseMutation) ResetA() {
  1633. m.a = nil
  1634. delete(m.clearedFields, agentbase.FieldA)
  1635. }
  1636. // SetChunkIndex sets the "chunk_index" field.
  1637. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1638. m.chunk_index = &u
  1639. m.addchunk_index = nil
  1640. }
  1641. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1642. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1643. v := m.chunk_index
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1662. }
  1663. return oldValue.ChunkIndex, nil
  1664. }
  1665. // AddChunkIndex adds u to the "chunk_index" field.
  1666. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1667. if m.addchunk_index != nil {
  1668. *m.addchunk_index += u
  1669. } else {
  1670. m.addchunk_index = &u
  1671. }
  1672. }
  1673. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1674. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1675. v := m.addchunk_index
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1682. func (m *AgentBaseMutation) ResetChunkIndex() {
  1683. m.chunk_index = nil
  1684. m.addchunk_index = nil
  1685. }
  1686. // SetIndexes sets the "indexes" field.
  1687. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1688. m.indexes = &s
  1689. m.appendindexes = nil
  1690. }
  1691. // Indexes returns the value of the "indexes" field in the mutation.
  1692. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1693. v := m.indexes
  1694. if v == nil {
  1695. return
  1696. }
  1697. return *v, true
  1698. }
  1699. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1700. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1702. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1703. if !m.op.Is(OpUpdateOne) {
  1704. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1705. }
  1706. if m.id == nil || m.oldValue == nil {
  1707. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1708. }
  1709. oldValue, err := m.oldValue(ctx)
  1710. if err != nil {
  1711. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1712. }
  1713. return oldValue.Indexes, nil
  1714. }
  1715. // AppendIndexes adds s to the "indexes" field.
  1716. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1717. m.appendindexes = append(m.appendindexes, s...)
  1718. }
  1719. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1720. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1721. if len(m.appendindexes) == 0 {
  1722. return nil, false
  1723. }
  1724. return m.appendindexes, true
  1725. }
  1726. // ClearIndexes clears the value of the "indexes" field.
  1727. func (m *AgentBaseMutation) ClearIndexes() {
  1728. m.indexes = nil
  1729. m.appendindexes = nil
  1730. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1731. }
  1732. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1733. func (m *AgentBaseMutation) IndexesCleared() bool {
  1734. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1735. return ok
  1736. }
  1737. // ResetIndexes resets all changes to the "indexes" field.
  1738. func (m *AgentBaseMutation) ResetIndexes() {
  1739. m.indexes = nil
  1740. m.appendindexes = nil
  1741. delete(m.clearedFields, agentbase.FieldIndexes)
  1742. }
  1743. // SetDatasetID sets the "dataset_id" field.
  1744. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1745. m.dataset_id = &s
  1746. }
  1747. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1748. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1749. v := m.dataset_id
  1750. if v == nil {
  1751. return
  1752. }
  1753. return *v, true
  1754. }
  1755. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1756. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1758. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1759. if !m.op.Is(OpUpdateOne) {
  1760. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1761. }
  1762. if m.id == nil || m.oldValue == nil {
  1763. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1764. }
  1765. oldValue, err := m.oldValue(ctx)
  1766. if err != nil {
  1767. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1768. }
  1769. return oldValue.DatasetID, nil
  1770. }
  1771. // ClearDatasetID clears the value of the "dataset_id" field.
  1772. func (m *AgentBaseMutation) ClearDatasetID() {
  1773. m.dataset_id = nil
  1774. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1775. }
  1776. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1777. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1778. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1779. return ok
  1780. }
  1781. // ResetDatasetID resets all changes to the "dataset_id" field.
  1782. func (m *AgentBaseMutation) ResetDatasetID() {
  1783. m.dataset_id = nil
  1784. delete(m.clearedFields, agentbase.FieldDatasetID)
  1785. }
  1786. // SetCollectionID sets the "collection_id" field.
  1787. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1788. m.collection_id = &s
  1789. }
  1790. // CollectionID returns the value of the "collection_id" field in the mutation.
  1791. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1792. v := m.collection_id
  1793. if v == nil {
  1794. return
  1795. }
  1796. return *v, true
  1797. }
  1798. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1799. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1801. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1802. if !m.op.Is(OpUpdateOne) {
  1803. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1804. }
  1805. if m.id == nil || m.oldValue == nil {
  1806. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1807. }
  1808. oldValue, err := m.oldValue(ctx)
  1809. if err != nil {
  1810. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1811. }
  1812. return oldValue.CollectionID, nil
  1813. }
  1814. // ClearCollectionID clears the value of the "collection_id" field.
  1815. func (m *AgentBaseMutation) ClearCollectionID() {
  1816. m.collection_id = nil
  1817. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1818. }
  1819. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1820. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1821. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1822. return ok
  1823. }
  1824. // ResetCollectionID resets all changes to the "collection_id" field.
  1825. func (m *AgentBaseMutation) ResetCollectionID() {
  1826. m.collection_id = nil
  1827. delete(m.clearedFields, agentbase.FieldCollectionID)
  1828. }
  1829. // SetSourceName sets the "source_name" field.
  1830. func (m *AgentBaseMutation) SetSourceName(s string) {
  1831. m.source_name = &s
  1832. }
  1833. // SourceName returns the value of the "source_name" field in the mutation.
  1834. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1835. v := m.source_name
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1842. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1844. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1845. if !m.op.Is(OpUpdateOne) {
  1846. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1847. }
  1848. if m.id == nil || m.oldValue == nil {
  1849. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1850. }
  1851. oldValue, err := m.oldValue(ctx)
  1852. if err != nil {
  1853. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1854. }
  1855. return oldValue.SourceName, nil
  1856. }
  1857. // ClearSourceName clears the value of the "source_name" field.
  1858. func (m *AgentBaseMutation) ClearSourceName() {
  1859. m.source_name = nil
  1860. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1861. }
  1862. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1863. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1864. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1865. return ok
  1866. }
  1867. // ResetSourceName resets all changes to the "source_name" field.
  1868. func (m *AgentBaseMutation) ResetSourceName() {
  1869. m.source_name = nil
  1870. delete(m.clearedFields, agentbase.FieldSourceName)
  1871. }
  1872. // SetCanWrite sets the "can_write" field.
  1873. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1874. m.can_write = &b
  1875. m.appendcan_write = nil
  1876. }
  1877. // CanWrite returns the value of the "can_write" field in the mutation.
  1878. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1879. v := m.can_write
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1886. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1888. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1894. }
  1895. oldValue, err := m.oldValue(ctx)
  1896. if err != nil {
  1897. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1898. }
  1899. return oldValue.CanWrite, nil
  1900. }
  1901. // AppendCanWrite adds b to the "can_write" field.
  1902. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1903. m.appendcan_write = append(m.appendcan_write, b...)
  1904. }
  1905. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1906. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1907. if len(m.appendcan_write) == 0 {
  1908. return nil, false
  1909. }
  1910. return m.appendcan_write, true
  1911. }
  1912. // ClearCanWrite clears the value of the "can_write" field.
  1913. func (m *AgentBaseMutation) ClearCanWrite() {
  1914. m.can_write = nil
  1915. m.appendcan_write = nil
  1916. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1917. }
  1918. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1919. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1920. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1921. return ok
  1922. }
  1923. // ResetCanWrite resets all changes to the "can_write" field.
  1924. func (m *AgentBaseMutation) ResetCanWrite() {
  1925. m.can_write = nil
  1926. m.appendcan_write = nil
  1927. delete(m.clearedFields, agentbase.FieldCanWrite)
  1928. }
  1929. // SetIsOwner sets the "is_owner" field.
  1930. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1931. m.is_owner = &b
  1932. m.appendis_owner = nil
  1933. }
  1934. // IsOwner returns the value of the "is_owner" field in the mutation.
  1935. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1936. v := m.is_owner
  1937. if v == nil {
  1938. return
  1939. }
  1940. return *v, true
  1941. }
  1942. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1943. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1945. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1946. if !m.op.Is(OpUpdateOne) {
  1947. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1948. }
  1949. if m.id == nil || m.oldValue == nil {
  1950. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1951. }
  1952. oldValue, err := m.oldValue(ctx)
  1953. if err != nil {
  1954. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1955. }
  1956. return oldValue.IsOwner, nil
  1957. }
  1958. // AppendIsOwner adds b to the "is_owner" field.
  1959. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1960. m.appendis_owner = append(m.appendis_owner, b...)
  1961. }
  1962. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1963. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1964. if len(m.appendis_owner) == 0 {
  1965. return nil, false
  1966. }
  1967. return m.appendis_owner, true
  1968. }
  1969. // ClearIsOwner clears the value of the "is_owner" field.
  1970. func (m *AgentBaseMutation) ClearIsOwner() {
  1971. m.is_owner = nil
  1972. m.appendis_owner = nil
  1973. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1974. }
  1975. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1976. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1977. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1978. return ok
  1979. }
  1980. // ResetIsOwner resets all changes to the "is_owner" field.
  1981. func (m *AgentBaseMutation) ResetIsOwner() {
  1982. m.is_owner = nil
  1983. m.appendis_owner = nil
  1984. delete(m.clearedFields, agentbase.FieldIsOwner)
  1985. }
  1986. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1987. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1988. if m.wx_agent == nil {
  1989. m.wx_agent = make(map[uint64]struct{})
  1990. }
  1991. for i := range ids {
  1992. m.wx_agent[ids[i]] = struct{}{}
  1993. }
  1994. }
  1995. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1996. func (m *AgentBaseMutation) ClearWxAgent() {
  1997. m.clearedwx_agent = true
  1998. }
  1999. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2000. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2001. return m.clearedwx_agent
  2002. }
  2003. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2004. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2005. if m.removedwx_agent == nil {
  2006. m.removedwx_agent = make(map[uint64]struct{})
  2007. }
  2008. for i := range ids {
  2009. delete(m.wx_agent, ids[i])
  2010. m.removedwx_agent[ids[i]] = struct{}{}
  2011. }
  2012. }
  2013. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2014. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2015. for id := range m.removedwx_agent {
  2016. ids = append(ids, id)
  2017. }
  2018. return
  2019. }
  2020. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2021. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2022. for id := range m.wx_agent {
  2023. ids = append(ids, id)
  2024. }
  2025. return
  2026. }
  2027. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2028. func (m *AgentBaseMutation) ResetWxAgent() {
  2029. m.wx_agent = nil
  2030. m.clearedwx_agent = false
  2031. m.removedwx_agent = nil
  2032. }
  2033. // Where appends a list predicates to the AgentBaseMutation builder.
  2034. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2035. m.predicates = append(m.predicates, ps...)
  2036. }
  2037. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2038. // users can use type-assertion to append predicates that do not depend on any generated package.
  2039. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2040. p := make([]predicate.AgentBase, len(ps))
  2041. for i := range ps {
  2042. p[i] = ps[i]
  2043. }
  2044. m.Where(p...)
  2045. }
  2046. // Op returns the operation name.
  2047. func (m *AgentBaseMutation) Op() Op {
  2048. return m.op
  2049. }
  2050. // SetOp allows setting the mutation operation.
  2051. func (m *AgentBaseMutation) SetOp(op Op) {
  2052. m.op = op
  2053. }
  2054. // Type returns the node type of this mutation (AgentBase).
  2055. func (m *AgentBaseMutation) Type() string {
  2056. return m.typ
  2057. }
  2058. // Fields returns all fields that were changed during this mutation. Note that in
  2059. // order to get all numeric fields that were incremented/decremented, call
  2060. // AddedFields().
  2061. func (m *AgentBaseMutation) Fields() []string {
  2062. fields := make([]string, 0, 9)
  2063. if m.q != nil {
  2064. fields = append(fields, agentbase.FieldQ)
  2065. }
  2066. if m.a != nil {
  2067. fields = append(fields, agentbase.FieldA)
  2068. }
  2069. if m.chunk_index != nil {
  2070. fields = append(fields, agentbase.FieldChunkIndex)
  2071. }
  2072. if m.indexes != nil {
  2073. fields = append(fields, agentbase.FieldIndexes)
  2074. }
  2075. if m.dataset_id != nil {
  2076. fields = append(fields, agentbase.FieldDatasetID)
  2077. }
  2078. if m.collection_id != nil {
  2079. fields = append(fields, agentbase.FieldCollectionID)
  2080. }
  2081. if m.source_name != nil {
  2082. fields = append(fields, agentbase.FieldSourceName)
  2083. }
  2084. if m.can_write != nil {
  2085. fields = append(fields, agentbase.FieldCanWrite)
  2086. }
  2087. if m.is_owner != nil {
  2088. fields = append(fields, agentbase.FieldIsOwner)
  2089. }
  2090. return fields
  2091. }
  2092. // Field returns the value of a field with the given name. The second boolean
  2093. // return value indicates that this field was not set, or was not defined in the
  2094. // schema.
  2095. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2096. switch name {
  2097. case agentbase.FieldQ:
  2098. return m.Q()
  2099. case agentbase.FieldA:
  2100. return m.A()
  2101. case agentbase.FieldChunkIndex:
  2102. return m.ChunkIndex()
  2103. case agentbase.FieldIndexes:
  2104. return m.Indexes()
  2105. case agentbase.FieldDatasetID:
  2106. return m.DatasetID()
  2107. case agentbase.FieldCollectionID:
  2108. return m.CollectionID()
  2109. case agentbase.FieldSourceName:
  2110. return m.SourceName()
  2111. case agentbase.FieldCanWrite:
  2112. return m.CanWrite()
  2113. case agentbase.FieldIsOwner:
  2114. return m.IsOwner()
  2115. }
  2116. return nil, false
  2117. }
  2118. // OldField returns the old value of the field from the database. An error is
  2119. // returned if the mutation operation is not UpdateOne, or the query to the
  2120. // database failed.
  2121. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2122. switch name {
  2123. case agentbase.FieldQ:
  2124. return m.OldQ(ctx)
  2125. case agentbase.FieldA:
  2126. return m.OldA(ctx)
  2127. case agentbase.FieldChunkIndex:
  2128. return m.OldChunkIndex(ctx)
  2129. case agentbase.FieldIndexes:
  2130. return m.OldIndexes(ctx)
  2131. case agentbase.FieldDatasetID:
  2132. return m.OldDatasetID(ctx)
  2133. case agentbase.FieldCollectionID:
  2134. return m.OldCollectionID(ctx)
  2135. case agentbase.FieldSourceName:
  2136. return m.OldSourceName(ctx)
  2137. case agentbase.FieldCanWrite:
  2138. return m.OldCanWrite(ctx)
  2139. case agentbase.FieldIsOwner:
  2140. return m.OldIsOwner(ctx)
  2141. }
  2142. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2143. }
  2144. // SetField sets the value of a field with the given name. It returns an error if
  2145. // the field is not defined in the schema, or if the type mismatched the field
  2146. // type.
  2147. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2148. switch name {
  2149. case agentbase.FieldQ:
  2150. v, ok := value.(string)
  2151. if !ok {
  2152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2153. }
  2154. m.SetQ(v)
  2155. return nil
  2156. case agentbase.FieldA:
  2157. v, ok := value.(string)
  2158. if !ok {
  2159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2160. }
  2161. m.SetA(v)
  2162. return nil
  2163. case agentbase.FieldChunkIndex:
  2164. v, ok := value.(uint64)
  2165. if !ok {
  2166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2167. }
  2168. m.SetChunkIndex(v)
  2169. return nil
  2170. case agentbase.FieldIndexes:
  2171. v, ok := value.([]string)
  2172. if !ok {
  2173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2174. }
  2175. m.SetIndexes(v)
  2176. return nil
  2177. case agentbase.FieldDatasetID:
  2178. v, ok := value.(string)
  2179. if !ok {
  2180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2181. }
  2182. m.SetDatasetID(v)
  2183. return nil
  2184. case agentbase.FieldCollectionID:
  2185. v, ok := value.(string)
  2186. if !ok {
  2187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2188. }
  2189. m.SetCollectionID(v)
  2190. return nil
  2191. case agentbase.FieldSourceName:
  2192. v, ok := value.(string)
  2193. if !ok {
  2194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2195. }
  2196. m.SetSourceName(v)
  2197. return nil
  2198. case agentbase.FieldCanWrite:
  2199. v, ok := value.([]bool)
  2200. if !ok {
  2201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2202. }
  2203. m.SetCanWrite(v)
  2204. return nil
  2205. case agentbase.FieldIsOwner:
  2206. v, ok := value.([]bool)
  2207. if !ok {
  2208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2209. }
  2210. m.SetIsOwner(v)
  2211. return nil
  2212. }
  2213. return fmt.Errorf("unknown AgentBase field %s", name)
  2214. }
  2215. // AddedFields returns all numeric fields that were incremented/decremented during
  2216. // this mutation.
  2217. func (m *AgentBaseMutation) AddedFields() []string {
  2218. var fields []string
  2219. if m.addchunk_index != nil {
  2220. fields = append(fields, agentbase.FieldChunkIndex)
  2221. }
  2222. return fields
  2223. }
  2224. // AddedField returns the numeric value that was incremented/decremented on a field
  2225. // with the given name. The second boolean return value indicates that this field
  2226. // was not set, or was not defined in the schema.
  2227. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2228. switch name {
  2229. case agentbase.FieldChunkIndex:
  2230. return m.AddedChunkIndex()
  2231. }
  2232. return nil, false
  2233. }
  2234. // AddField adds the value to the field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2238. switch name {
  2239. case agentbase.FieldChunkIndex:
  2240. v, ok := value.(int64)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.AddChunkIndex(v)
  2245. return nil
  2246. }
  2247. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2248. }
  2249. // ClearedFields returns all nullable fields that were cleared during this
  2250. // mutation.
  2251. func (m *AgentBaseMutation) ClearedFields() []string {
  2252. var fields []string
  2253. if m.FieldCleared(agentbase.FieldQ) {
  2254. fields = append(fields, agentbase.FieldQ)
  2255. }
  2256. if m.FieldCleared(agentbase.FieldA) {
  2257. fields = append(fields, agentbase.FieldA)
  2258. }
  2259. if m.FieldCleared(agentbase.FieldIndexes) {
  2260. fields = append(fields, agentbase.FieldIndexes)
  2261. }
  2262. if m.FieldCleared(agentbase.FieldDatasetID) {
  2263. fields = append(fields, agentbase.FieldDatasetID)
  2264. }
  2265. if m.FieldCleared(agentbase.FieldCollectionID) {
  2266. fields = append(fields, agentbase.FieldCollectionID)
  2267. }
  2268. if m.FieldCleared(agentbase.FieldSourceName) {
  2269. fields = append(fields, agentbase.FieldSourceName)
  2270. }
  2271. if m.FieldCleared(agentbase.FieldCanWrite) {
  2272. fields = append(fields, agentbase.FieldCanWrite)
  2273. }
  2274. if m.FieldCleared(agentbase.FieldIsOwner) {
  2275. fields = append(fields, agentbase.FieldIsOwner)
  2276. }
  2277. return fields
  2278. }
  2279. // FieldCleared returns a boolean indicating if a field with the given name was
  2280. // cleared in this mutation.
  2281. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2282. _, ok := m.clearedFields[name]
  2283. return ok
  2284. }
  2285. // ClearField clears the value of the field with the given name. It returns an
  2286. // error if the field is not defined in the schema.
  2287. func (m *AgentBaseMutation) ClearField(name string) error {
  2288. switch name {
  2289. case agentbase.FieldQ:
  2290. m.ClearQ()
  2291. return nil
  2292. case agentbase.FieldA:
  2293. m.ClearA()
  2294. return nil
  2295. case agentbase.FieldIndexes:
  2296. m.ClearIndexes()
  2297. return nil
  2298. case agentbase.FieldDatasetID:
  2299. m.ClearDatasetID()
  2300. return nil
  2301. case agentbase.FieldCollectionID:
  2302. m.ClearCollectionID()
  2303. return nil
  2304. case agentbase.FieldSourceName:
  2305. m.ClearSourceName()
  2306. return nil
  2307. case agentbase.FieldCanWrite:
  2308. m.ClearCanWrite()
  2309. return nil
  2310. case agentbase.FieldIsOwner:
  2311. m.ClearIsOwner()
  2312. return nil
  2313. }
  2314. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2315. }
  2316. // ResetField resets all changes in the mutation for the field with the given name.
  2317. // It returns an error if the field is not defined in the schema.
  2318. func (m *AgentBaseMutation) ResetField(name string) error {
  2319. switch name {
  2320. case agentbase.FieldQ:
  2321. m.ResetQ()
  2322. return nil
  2323. case agentbase.FieldA:
  2324. m.ResetA()
  2325. return nil
  2326. case agentbase.FieldChunkIndex:
  2327. m.ResetChunkIndex()
  2328. return nil
  2329. case agentbase.FieldIndexes:
  2330. m.ResetIndexes()
  2331. return nil
  2332. case agentbase.FieldDatasetID:
  2333. m.ResetDatasetID()
  2334. return nil
  2335. case agentbase.FieldCollectionID:
  2336. m.ResetCollectionID()
  2337. return nil
  2338. case agentbase.FieldSourceName:
  2339. m.ResetSourceName()
  2340. return nil
  2341. case agentbase.FieldCanWrite:
  2342. m.ResetCanWrite()
  2343. return nil
  2344. case agentbase.FieldIsOwner:
  2345. m.ResetIsOwner()
  2346. return nil
  2347. }
  2348. return fmt.Errorf("unknown AgentBase field %s", name)
  2349. }
  2350. // AddedEdges returns all edge names that were set/added in this mutation.
  2351. func (m *AgentBaseMutation) AddedEdges() []string {
  2352. edges := make([]string, 0, 1)
  2353. if m.wx_agent != nil {
  2354. edges = append(edges, agentbase.EdgeWxAgent)
  2355. }
  2356. return edges
  2357. }
  2358. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2359. // name in this mutation.
  2360. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2361. switch name {
  2362. case agentbase.EdgeWxAgent:
  2363. ids := make([]ent.Value, 0, len(m.wx_agent))
  2364. for id := range m.wx_agent {
  2365. ids = append(ids, id)
  2366. }
  2367. return ids
  2368. }
  2369. return nil
  2370. }
  2371. // RemovedEdges returns all edge names that were removed in this mutation.
  2372. func (m *AgentBaseMutation) RemovedEdges() []string {
  2373. edges := make([]string, 0, 1)
  2374. if m.removedwx_agent != nil {
  2375. edges = append(edges, agentbase.EdgeWxAgent)
  2376. }
  2377. return edges
  2378. }
  2379. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2380. // the given name in this mutation.
  2381. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2382. switch name {
  2383. case agentbase.EdgeWxAgent:
  2384. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2385. for id := range m.removedwx_agent {
  2386. ids = append(ids, id)
  2387. }
  2388. return ids
  2389. }
  2390. return nil
  2391. }
  2392. // ClearedEdges returns all edge names that were cleared in this mutation.
  2393. func (m *AgentBaseMutation) ClearedEdges() []string {
  2394. edges := make([]string, 0, 1)
  2395. if m.clearedwx_agent {
  2396. edges = append(edges, agentbase.EdgeWxAgent)
  2397. }
  2398. return edges
  2399. }
  2400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2401. // was cleared in this mutation.
  2402. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2403. switch name {
  2404. case agentbase.EdgeWxAgent:
  2405. return m.clearedwx_agent
  2406. }
  2407. return false
  2408. }
  2409. // ClearEdge clears the value of the edge with the given name. It returns an error
  2410. // if that edge is not defined in the schema.
  2411. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2412. switch name {
  2413. }
  2414. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2415. }
  2416. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2417. // It returns an error if the edge is not defined in the schema.
  2418. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2419. switch name {
  2420. case agentbase.EdgeWxAgent:
  2421. m.ResetWxAgent()
  2422. return nil
  2423. }
  2424. return fmt.Errorf("unknown AgentBase edge %s", name)
  2425. }
  2426. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2427. type AliyunAvatarMutation struct {
  2428. config
  2429. op Op
  2430. typ string
  2431. id *uint64
  2432. created_at *time.Time
  2433. updated_at *time.Time
  2434. deleted_at *time.Time
  2435. user_id *uint64
  2436. adduser_id *int64
  2437. biz_id *string
  2438. access_key_id *string
  2439. access_key_secret *string
  2440. app_id *string
  2441. tenant_id *uint64
  2442. addtenant_id *int64
  2443. response *string
  2444. token *string
  2445. session_id *string
  2446. clearedFields map[string]struct{}
  2447. done bool
  2448. oldValue func(context.Context) (*AliyunAvatar, error)
  2449. predicates []predicate.AliyunAvatar
  2450. }
  2451. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2452. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2453. type aliyunavatarOption func(*AliyunAvatarMutation)
  2454. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2455. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2456. m := &AliyunAvatarMutation{
  2457. config: c,
  2458. op: op,
  2459. typ: TypeAliyunAvatar,
  2460. clearedFields: make(map[string]struct{}),
  2461. }
  2462. for _, opt := range opts {
  2463. opt(m)
  2464. }
  2465. return m
  2466. }
  2467. // withAliyunAvatarID sets the ID field of the mutation.
  2468. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2469. return func(m *AliyunAvatarMutation) {
  2470. var (
  2471. err error
  2472. once sync.Once
  2473. value *AliyunAvatar
  2474. )
  2475. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2476. once.Do(func() {
  2477. if m.done {
  2478. err = errors.New("querying old values post mutation is not allowed")
  2479. } else {
  2480. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2481. }
  2482. })
  2483. return value, err
  2484. }
  2485. m.id = &id
  2486. }
  2487. }
  2488. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2489. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2490. return func(m *AliyunAvatarMutation) {
  2491. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2492. return node, nil
  2493. }
  2494. m.id = &node.ID
  2495. }
  2496. }
  2497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2498. // executed in a transaction (ent.Tx), a transactional client is returned.
  2499. func (m AliyunAvatarMutation) Client() *Client {
  2500. client := &Client{config: m.config}
  2501. client.init()
  2502. return client
  2503. }
  2504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2505. // it returns an error otherwise.
  2506. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2507. if _, ok := m.driver.(*txDriver); !ok {
  2508. return nil, errors.New("ent: mutation is not running in a transaction")
  2509. }
  2510. tx := &Tx{config: m.config}
  2511. tx.init()
  2512. return tx, nil
  2513. }
  2514. // SetID sets the value of the id field. Note that this
  2515. // operation is only accepted on creation of AliyunAvatar entities.
  2516. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2517. m.id = &id
  2518. }
  2519. // ID returns the ID value in the mutation. Note that the ID is only available
  2520. // if it was provided to the builder or after it was returned from the database.
  2521. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2522. if m.id == nil {
  2523. return
  2524. }
  2525. return *m.id, true
  2526. }
  2527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2528. // That means, if the mutation is applied within a transaction with an isolation level such
  2529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2530. // or updated by the mutation.
  2531. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2532. switch {
  2533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2534. id, exists := m.ID()
  2535. if exists {
  2536. return []uint64{id}, nil
  2537. }
  2538. fallthrough
  2539. case m.op.Is(OpUpdate | OpDelete):
  2540. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2541. default:
  2542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2543. }
  2544. }
  2545. // SetCreatedAt sets the "created_at" field.
  2546. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2547. m.created_at = &t
  2548. }
  2549. // CreatedAt returns the value of the "created_at" field in the mutation.
  2550. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2551. v := m.created_at
  2552. if v == nil {
  2553. return
  2554. }
  2555. return *v, true
  2556. }
  2557. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2558. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2560. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2561. if !m.op.Is(OpUpdateOne) {
  2562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2563. }
  2564. if m.id == nil || m.oldValue == nil {
  2565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2566. }
  2567. oldValue, err := m.oldValue(ctx)
  2568. if err != nil {
  2569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2570. }
  2571. return oldValue.CreatedAt, nil
  2572. }
  2573. // ResetCreatedAt resets all changes to the "created_at" field.
  2574. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2575. m.created_at = nil
  2576. }
  2577. // SetUpdatedAt sets the "updated_at" field.
  2578. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2579. m.updated_at = &t
  2580. }
  2581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2582. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2583. v := m.updated_at
  2584. if v == nil {
  2585. return
  2586. }
  2587. return *v, true
  2588. }
  2589. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2590. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2592. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2593. if !m.op.Is(OpUpdateOne) {
  2594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2595. }
  2596. if m.id == nil || m.oldValue == nil {
  2597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2598. }
  2599. oldValue, err := m.oldValue(ctx)
  2600. if err != nil {
  2601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2602. }
  2603. return oldValue.UpdatedAt, nil
  2604. }
  2605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2606. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2607. m.updated_at = nil
  2608. }
  2609. // SetDeletedAt sets the "deleted_at" field.
  2610. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2611. m.deleted_at = &t
  2612. }
  2613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2614. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2615. v := m.deleted_at
  2616. if v == nil {
  2617. return
  2618. }
  2619. return *v, true
  2620. }
  2621. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2622. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2624. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2625. if !m.op.Is(OpUpdateOne) {
  2626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2627. }
  2628. if m.id == nil || m.oldValue == nil {
  2629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2630. }
  2631. oldValue, err := m.oldValue(ctx)
  2632. if err != nil {
  2633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2634. }
  2635. return oldValue.DeletedAt, nil
  2636. }
  2637. // ClearDeletedAt clears the value of the "deleted_at" field.
  2638. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2639. m.deleted_at = nil
  2640. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2641. }
  2642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2643. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2644. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2645. return ok
  2646. }
  2647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2648. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2649. m.deleted_at = nil
  2650. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2651. }
  2652. // SetUserID sets the "user_id" field.
  2653. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2654. m.user_id = &u
  2655. m.adduser_id = nil
  2656. }
  2657. // UserID returns the value of the "user_id" field in the mutation.
  2658. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2659. v := m.user_id
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldUserID requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2678. }
  2679. return oldValue.UserID, nil
  2680. }
  2681. // AddUserID adds u to the "user_id" field.
  2682. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2683. if m.adduser_id != nil {
  2684. *m.adduser_id += u
  2685. } else {
  2686. m.adduser_id = &u
  2687. }
  2688. }
  2689. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2690. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2691. v := m.adduser_id
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // ResetUserID resets all changes to the "user_id" field.
  2698. func (m *AliyunAvatarMutation) ResetUserID() {
  2699. m.user_id = nil
  2700. m.adduser_id = nil
  2701. }
  2702. // SetBizID sets the "biz_id" field.
  2703. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2704. m.biz_id = &s
  2705. }
  2706. // BizID returns the value of the "biz_id" field in the mutation.
  2707. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2708. v := m.biz_id
  2709. if v == nil {
  2710. return
  2711. }
  2712. return *v, true
  2713. }
  2714. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2715. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2717. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2718. if !m.op.Is(OpUpdateOne) {
  2719. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2720. }
  2721. if m.id == nil || m.oldValue == nil {
  2722. return v, errors.New("OldBizID requires an ID field in the mutation")
  2723. }
  2724. oldValue, err := m.oldValue(ctx)
  2725. if err != nil {
  2726. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2727. }
  2728. return oldValue.BizID, nil
  2729. }
  2730. // ResetBizID resets all changes to the "biz_id" field.
  2731. func (m *AliyunAvatarMutation) ResetBizID() {
  2732. m.biz_id = nil
  2733. }
  2734. // SetAccessKeyID sets the "access_key_id" field.
  2735. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2736. m.access_key_id = &s
  2737. }
  2738. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2739. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2740. v := m.access_key_id
  2741. if v == nil {
  2742. return
  2743. }
  2744. return *v, true
  2745. }
  2746. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2747. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2749. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2750. if !m.op.Is(OpUpdateOne) {
  2751. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2752. }
  2753. if m.id == nil || m.oldValue == nil {
  2754. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2755. }
  2756. oldValue, err := m.oldValue(ctx)
  2757. if err != nil {
  2758. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2759. }
  2760. return oldValue.AccessKeyID, nil
  2761. }
  2762. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2763. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2764. m.access_key_id = nil
  2765. }
  2766. // SetAccessKeySecret sets the "access_key_secret" field.
  2767. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2768. m.access_key_secret = &s
  2769. }
  2770. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2771. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2772. v := m.access_key_secret
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2779. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2791. }
  2792. return oldValue.AccessKeySecret, nil
  2793. }
  2794. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2795. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2796. m.access_key_secret = nil
  2797. }
  2798. // SetAppID sets the "app_id" field.
  2799. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2800. m.app_id = &s
  2801. }
  2802. // AppID returns the value of the "app_id" field in the mutation.
  2803. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2804. v := m.app_id
  2805. if v == nil {
  2806. return
  2807. }
  2808. return *v, true
  2809. }
  2810. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2811. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2813. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2814. if !m.op.Is(OpUpdateOne) {
  2815. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2816. }
  2817. if m.id == nil || m.oldValue == nil {
  2818. return v, errors.New("OldAppID requires an ID field in the mutation")
  2819. }
  2820. oldValue, err := m.oldValue(ctx)
  2821. if err != nil {
  2822. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2823. }
  2824. return oldValue.AppID, nil
  2825. }
  2826. // ClearAppID clears the value of the "app_id" field.
  2827. func (m *AliyunAvatarMutation) ClearAppID() {
  2828. m.app_id = nil
  2829. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2830. }
  2831. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2832. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2833. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2834. return ok
  2835. }
  2836. // ResetAppID resets all changes to the "app_id" field.
  2837. func (m *AliyunAvatarMutation) ResetAppID() {
  2838. m.app_id = nil
  2839. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2840. }
  2841. // SetTenantID sets the "tenant_id" field.
  2842. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2843. m.tenant_id = &u
  2844. m.addtenant_id = nil
  2845. }
  2846. // TenantID returns the value of the "tenant_id" field in the mutation.
  2847. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2848. v := m.tenant_id
  2849. if v == nil {
  2850. return
  2851. }
  2852. return *v, true
  2853. }
  2854. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2855. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2857. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2858. if !m.op.Is(OpUpdateOne) {
  2859. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2860. }
  2861. if m.id == nil || m.oldValue == nil {
  2862. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2863. }
  2864. oldValue, err := m.oldValue(ctx)
  2865. if err != nil {
  2866. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2867. }
  2868. return oldValue.TenantID, nil
  2869. }
  2870. // AddTenantID adds u to the "tenant_id" field.
  2871. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2872. if m.addtenant_id != nil {
  2873. *m.addtenant_id += u
  2874. } else {
  2875. m.addtenant_id = &u
  2876. }
  2877. }
  2878. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2879. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2880. v := m.addtenant_id
  2881. if v == nil {
  2882. return
  2883. }
  2884. return *v, true
  2885. }
  2886. // ResetTenantID resets all changes to the "tenant_id" field.
  2887. func (m *AliyunAvatarMutation) ResetTenantID() {
  2888. m.tenant_id = nil
  2889. m.addtenant_id = nil
  2890. }
  2891. // SetResponse sets the "response" field.
  2892. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2893. m.response = &s
  2894. }
  2895. // Response returns the value of the "response" field in the mutation.
  2896. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2897. v := m.response
  2898. if v == nil {
  2899. return
  2900. }
  2901. return *v, true
  2902. }
  2903. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2904. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2906. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2907. if !m.op.Is(OpUpdateOne) {
  2908. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2909. }
  2910. if m.id == nil || m.oldValue == nil {
  2911. return v, errors.New("OldResponse requires an ID field in the mutation")
  2912. }
  2913. oldValue, err := m.oldValue(ctx)
  2914. if err != nil {
  2915. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2916. }
  2917. return oldValue.Response, nil
  2918. }
  2919. // ResetResponse resets all changes to the "response" field.
  2920. func (m *AliyunAvatarMutation) ResetResponse() {
  2921. m.response = nil
  2922. }
  2923. // SetToken sets the "token" field.
  2924. func (m *AliyunAvatarMutation) SetToken(s string) {
  2925. m.token = &s
  2926. }
  2927. // Token returns the value of the "token" field in the mutation.
  2928. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2929. v := m.token
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2936. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldToken requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2948. }
  2949. return oldValue.Token, nil
  2950. }
  2951. // ResetToken resets all changes to the "token" field.
  2952. func (m *AliyunAvatarMutation) ResetToken() {
  2953. m.token = nil
  2954. }
  2955. // SetSessionID sets the "session_id" field.
  2956. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2957. m.session_id = &s
  2958. }
  2959. // SessionID returns the value of the "session_id" field in the mutation.
  2960. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2961. v := m.session_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2968. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2970. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2971. if !m.op.Is(OpUpdateOne) {
  2972. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2973. }
  2974. if m.id == nil || m.oldValue == nil {
  2975. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2976. }
  2977. oldValue, err := m.oldValue(ctx)
  2978. if err != nil {
  2979. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2980. }
  2981. return oldValue.SessionID, nil
  2982. }
  2983. // ResetSessionID resets all changes to the "session_id" field.
  2984. func (m *AliyunAvatarMutation) ResetSessionID() {
  2985. m.session_id = nil
  2986. }
  2987. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2988. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2989. m.predicates = append(m.predicates, ps...)
  2990. }
  2991. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2992. // users can use type-assertion to append predicates that do not depend on any generated package.
  2993. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2994. p := make([]predicate.AliyunAvatar, len(ps))
  2995. for i := range ps {
  2996. p[i] = ps[i]
  2997. }
  2998. m.Where(p...)
  2999. }
  3000. // Op returns the operation name.
  3001. func (m *AliyunAvatarMutation) Op() Op {
  3002. return m.op
  3003. }
  3004. // SetOp allows setting the mutation operation.
  3005. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3006. m.op = op
  3007. }
  3008. // Type returns the node type of this mutation (AliyunAvatar).
  3009. func (m *AliyunAvatarMutation) Type() string {
  3010. return m.typ
  3011. }
  3012. // Fields returns all fields that were changed during this mutation. Note that in
  3013. // order to get all numeric fields that were incremented/decremented, call
  3014. // AddedFields().
  3015. func (m *AliyunAvatarMutation) Fields() []string {
  3016. fields := make([]string, 0, 12)
  3017. if m.created_at != nil {
  3018. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3019. }
  3020. if m.updated_at != nil {
  3021. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3022. }
  3023. if m.deleted_at != nil {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.user_id != nil {
  3027. fields = append(fields, aliyunavatar.FieldUserID)
  3028. }
  3029. if m.biz_id != nil {
  3030. fields = append(fields, aliyunavatar.FieldBizID)
  3031. }
  3032. if m.access_key_id != nil {
  3033. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3034. }
  3035. if m.access_key_secret != nil {
  3036. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3037. }
  3038. if m.app_id != nil {
  3039. fields = append(fields, aliyunavatar.FieldAppID)
  3040. }
  3041. if m.tenant_id != nil {
  3042. fields = append(fields, aliyunavatar.FieldTenantID)
  3043. }
  3044. if m.response != nil {
  3045. fields = append(fields, aliyunavatar.FieldResponse)
  3046. }
  3047. if m.token != nil {
  3048. fields = append(fields, aliyunavatar.FieldToken)
  3049. }
  3050. if m.session_id != nil {
  3051. fields = append(fields, aliyunavatar.FieldSessionID)
  3052. }
  3053. return fields
  3054. }
  3055. // Field returns the value of a field with the given name. The second boolean
  3056. // return value indicates that this field was not set, or was not defined in the
  3057. // schema.
  3058. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3059. switch name {
  3060. case aliyunavatar.FieldCreatedAt:
  3061. return m.CreatedAt()
  3062. case aliyunavatar.FieldUpdatedAt:
  3063. return m.UpdatedAt()
  3064. case aliyunavatar.FieldDeletedAt:
  3065. return m.DeletedAt()
  3066. case aliyunavatar.FieldUserID:
  3067. return m.UserID()
  3068. case aliyunavatar.FieldBizID:
  3069. return m.BizID()
  3070. case aliyunavatar.FieldAccessKeyID:
  3071. return m.AccessKeyID()
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. return m.AccessKeySecret()
  3074. case aliyunavatar.FieldAppID:
  3075. return m.AppID()
  3076. case aliyunavatar.FieldTenantID:
  3077. return m.TenantID()
  3078. case aliyunavatar.FieldResponse:
  3079. return m.Response()
  3080. case aliyunavatar.FieldToken:
  3081. return m.Token()
  3082. case aliyunavatar.FieldSessionID:
  3083. return m.SessionID()
  3084. }
  3085. return nil, false
  3086. }
  3087. // OldField returns the old value of the field from the database. An error is
  3088. // returned if the mutation operation is not UpdateOne, or the query to the
  3089. // database failed.
  3090. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3091. switch name {
  3092. case aliyunavatar.FieldCreatedAt:
  3093. return m.OldCreatedAt(ctx)
  3094. case aliyunavatar.FieldUpdatedAt:
  3095. return m.OldUpdatedAt(ctx)
  3096. case aliyunavatar.FieldDeletedAt:
  3097. return m.OldDeletedAt(ctx)
  3098. case aliyunavatar.FieldUserID:
  3099. return m.OldUserID(ctx)
  3100. case aliyunavatar.FieldBizID:
  3101. return m.OldBizID(ctx)
  3102. case aliyunavatar.FieldAccessKeyID:
  3103. return m.OldAccessKeyID(ctx)
  3104. case aliyunavatar.FieldAccessKeySecret:
  3105. return m.OldAccessKeySecret(ctx)
  3106. case aliyunavatar.FieldAppID:
  3107. return m.OldAppID(ctx)
  3108. case aliyunavatar.FieldTenantID:
  3109. return m.OldTenantID(ctx)
  3110. case aliyunavatar.FieldResponse:
  3111. return m.OldResponse(ctx)
  3112. case aliyunavatar.FieldToken:
  3113. return m.OldToken(ctx)
  3114. case aliyunavatar.FieldSessionID:
  3115. return m.OldSessionID(ctx)
  3116. }
  3117. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3118. }
  3119. // SetField sets the value of a field with the given name. It returns an error if
  3120. // the field is not defined in the schema, or if the type mismatched the field
  3121. // type.
  3122. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3123. switch name {
  3124. case aliyunavatar.FieldCreatedAt:
  3125. v, ok := value.(time.Time)
  3126. if !ok {
  3127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3128. }
  3129. m.SetCreatedAt(v)
  3130. return nil
  3131. case aliyunavatar.FieldUpdatedAt:
  3132. v, ok := value.(time.Time)
  3133. if !ok {
  3134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3135. }
  3136. m.SetUpdatedAt(v)
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. v, ok := value.(time.Time)
  3140. if !ok {
  3141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3142. }
  3143. m.SetDeletedAt(v)
  3144. return nil
  3145. case aliyunavatar.FieldUserID:
  3146. v, ok := value.(uint64)
  3147. if !ok {
  3148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3149. }
  3150. m.SetUserID(v)
  3151. return nil
  3152. case aliyunavatar.FieldBizID:
  3153. v, ok := value.(string)
  3154. if !ok {
  3155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3156. }
  3157. m.SetBizID(v)
  3158. return nil
  3159. case aliyunavatar.FieldAccessKeyID:
  3160. v, ok := value.(string)
  3161. if !ok {
  3162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3163. }
  3164. m.SetAccessKeyID(v)
  3165. return nil
  3166. case aliyunavatar.FieldAccessKeySecret:
  3167. v, ok := value.(string)
  3168. if !ok {
  3169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3170. }
  3171. m.SetAccessKeySecret(v)
  3172. return nil
  3173. case aliyunavatar.FieldAppID:
  3174. v, ok := value.(string)
  3175. if !ok {
  3176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3177. }
  3178. m.SetAppID(v)
  3179. return nil
  3180. case aliyunavatar.FieldTenantID:
  3181. v, ok := value.(uint64)
  3182. if !ok {
  3183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3184. }
  3185. m.SetTenantID(v)
  3186. return nil
  3187. case aliyunavatar.FieldResponse:
  3188. v, ok := value.(string)
  3189. if !ok {
  3190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3191. }
  3192. m.SetResponse(v)
  3193. return nil
  3194. case aliyunavatar.FieldToken:
  3195. v, ok := value.(string)
  3196. if !ok {
  3197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3198. }
  3199. m.SetToken(v)
  3200. return nil
  3201. case aliyunavatar.FieldSessionID:
  3202. v, ok := value.(string)
  3203. if !ok {
  3204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3205. }
  3206. m.SetSessionID(v)
  3207. return nil
  3208. }
  3209. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3210. }
  3211. // AddedFields returns all numeric fields that were incremented/decremented during
  3212. // this mutation.
  3213. func (m *AliyunAvatarMutation) AddedFields() []string {
  3214. var fields []string
  3215. if m.adduser_id != nil {
  3216. fields = append(fields, aliyunavatar.FieldUserID)
  3217. }
  3218. if m.addtenant_id != nil {
  3219. fields = append(fields, aliyunavatar.FieldTenantID)
  3220. }
  3221. return fields
  3222. }
  3223. // AddedField returns the numeric value that was incremented/decremented on a field
  3224. // with the given name. The second boolean return value indicates that this field
  3225. // was not set, or was not defined in the schema.
  3226. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3227. switch name {
  3228. case aliyunavatar.FieldUserID:
  3229. return m.AddedUserID()
  3230. case aliyunavatar.FieldTenantID:
  3231. return m.AddedTenantID()
  3232. }
  3233. return nil, false
  3234. }
  3235. // AddField adds the value to the field with the given name. It returns an error if
  3236. // the field is not defined in the schema, or if the type mismatched the field
  3237. // type.
  3238. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3239. switch name {
  3240. case aliyunavatar.FieldUserID:
  3241. v, ok := value.(int64)
  3242. if !ok {
  3243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3244. }
  3245. m.AddUserID(v)
  3246. return nil
  3247. case aliyunavatar.FieldTenantID:
  3248. v, ok := value.(int64)
  3249. if !ok {
  3250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3251. }
  3252. m.AddTenantID(v)
  3253. return nil
  3254. }
  3255. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3256. }
  3257. // ClearedFields returns all nullable fields that were cleared during this
  3258. // mutation.
  3259. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3260. var fields []string
  3261. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3262. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3263. }
  3264. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3265. fields = append(fields, aliyunavatar.FieldAppID)
  3266. }
  3267. return fields
  3268. }
  3269. // FieldCleared returns a boolean indicating if a field with the given name was
  3270. // cleared in this mutation.
  3271. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3272. _, ok := m.clearedFields[name]
  3273. return ok
  3274. }
  3275. // ClearField clears the value of the field with the given name. It returns an
  3276. // error if the field is not defined in the schema.
  3277. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3278. switch name {
  3279. case aliyunavatar.FieldDeletedAt:
  3280. m.ClearDeletedAt()
  3281. return nil
  3282. case aliyunavatar.FieldAppID:
  3283. m.ClearAppID()
  3284. return nil
  3285. }
  3286. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3287. }
  3288. // ResetField resets all changes in the mutation for the field with the given name.
  3289. // It returns an error if the field is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3291. switch name {
  3292. case aliyunavatar.FieldCreatedAt:
  3293. m.ResetCreatedAt()
  3294. return nil
  3295. case aliyunavatar.FieldUpdatedAt:
  3296. m.ResetUpdatedAt()
  3297. return nil
  3298. case aliyunavatar.FieldDeletedAt:
  3299. m.ResetDeletedAt()
  3300. return nil
  3301. case aliyunavatar.FieldUserID:
  3302. m.ResetUserID()
  3303. return nil
  3304. case aliyunavatar.FieldBizID:
  3305. m.ResetBizID()
  3306. return nil
  3307. case aliyunavatar.FieldAccessKeyID:
  3308. m.ResetAccessKeyID()
  3309. return nil
  3310. case aliyunavatar.FieldAccessKeySecret:
  3311. m.ResetAccessKeySecret()
  3312. return nil
  3313. case aliyunavatar.FieldAppID:
  3314. m.ResetAppID()
  3315. return nil
  3316. case aliyunavatar.FieldTenantID:
  3317. m.ResetTenantID()
  3318. return nil
  3319. case aliyunavatar.FieldResponse:
  3320. m.ResetResponse()
  3321. return nil
  3322. case aliyunavatar.FieldToken:
  3323. m.ResetToken()
  3324. return nil
  3325. case aliyunavatar.FieldSessionID:
  3326. m.ResetSessionID()
  3327. return nil
  3328. }
  3329. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3330. }
  3331. // AddedEdges returns all edge names that were set/added in this mutation.
  3332. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3333. edges := make([]string, 0, 0)
  3334. return edges
  3335. }
  3336. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3337. // name in this mutation.
  3338. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3339. return nil
  3340. }
  3341. // RemovedEdges returns all edge names that were removed in this mutation.
  3342. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3343. edges := make([]string, 0, 0)
  3344. return edges
  3345. }
  3346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3347. // the given name in this mutation.
  3348. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3349. return nil
  3350. }
  3351. // ClearedEdges returns all edge names that were cleared in this mutation.
  3352. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3353. edges := make([]string, 0, 0)
  3354. return edges
  3355. }
  3356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3357. // was cleared in this mutation.
  3358. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3359. return false
  3360. }
  3361. // ClearEdge clears the value of the edge with the given name. It returns an error
  3362. // if that edge is not defined in the schema.
  3363. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3364. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3365. }
  3366. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3367. // It returns an error if the edge is not defined in the schema.
  3368. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3369. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3370. }
  3371. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3372. type AllocAgentMutation struct {
  3373. config
  3374. op Op
  3375. typ string
  3376. id *uint64
  3377. created_at *time.Time
  3378. updated_at *time.Time
  3379. deleted_at *time.Time
  3380. user_id *string
  3381. organization_id *uint64
  3382. addorganization_id *int64
  3383. agents *[]uint64
  3384. appendagents []uint64
  3385. status *int
  3386. addstatus *int
  3387. clearedFields map[string]struct{}
  3388. done bool
  3389. oldValue func(context.Context) (*AllocAgent, error)
  3390. predicates []predicate.AllocAgent
  3391. }
  3392. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3393. // allocagentOption allows management of the mutation configuration using functional options.
  3394. type allocagentOption func(*AllocAgentMutation)
  3395. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3396. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3397. m := &AllocAgentMutation{
  3398. config: c,
  3399. op: op,
  3400. typ: TypeAllocAgent,
  3401. clearedFields: make(map[string]struct{}),
  3402. }
  3403. for _, opt := range opts {
  3404. opt(m)
  3405. }
  3406. return m
  3407. }
  3408. // withAllocAgentID sets the ID field of the mutation.
  3409. func withAllocAgentID(id uint64) allocagentOption {
  3410. return func(m *AllocAgentMutation) {
  3411. var (
  3412. err error
  3413. once sync.Once
  3414. value *AllocAgent
  3415. )
  3416. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3417. once.Do(func() {
  3418. if m.done {
  3419. err = errors.New("querying old values post mutation is not allowed")
  3420. } else {
  3421. value, err = m.Client().AllocAgent.Get(ctx, id)
  3422. }
  3423. })
  3424. return value, err
  3425. }
  3426. m.id = &id
  3427. }
  3428. }
  3429. // withAllocAgent sets the old AllocAgent of the mutation.
  3430. func withAllocAgent(node *AllocAgent) allocagentOption {
  3431. return func(m *AllocAgentMutation) {
  3432. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3433. return node, nil
  3434. }
  3435. m.id = &node.ID
  3436. }
  3437. }
  3438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3439. // executed in a transaction (ent.Tx), a transactional client is returned.
  3440. func (m AllocAgentMutation) Client() *Client {
  3441. client := &Client{config: m.config}
  3442. client.init()
  3443. return client
  3444. }
  3445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3446. // it returns an error otherwise.
  3447. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3448. if _, ok := m.driver.(*txDriver); !ok {
  3449. return nil, errors.New("ent: mutation is not running in a transaction")
  3450. }
  3451. tx := &Tx{config: m.config}
  3452. tx.init()
  3453. return tx, nil
  3454. }
  3455. // SetID sets the value of the id field. Note that this
  3456. // operation is only accepted on creation of AllocAgent entities.
  3457. func (m *AllocAgentMutation) SetID(id uint64) {
  3458. m.id = &id
  3459. }
  3460. // ID returns the ID value in the mutation. Note that the ID is only available
  3461. // if it was provided to the builder or after it was returned from the database.
  3462. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3463. if m.id == nil {
  3464. return
  3465. }
  3466. return *m.id, true
  3467. }
  3468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3469. // That means, if the mutation is applied within a transaction with an isolation level such
  3470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3471. // or updated by the mutation.
  3472. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3473. switch {
  3474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3475. id, exists := m.ID()
  3476. if exists {
  3477. return []uint64{id}, nil
  3478. }
  3479. fallthrough
  3480. case m.op.Is(OpUpdate | OpDelete):
  3481. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3482. default:
  3483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3484. }
  3485. }
  3486. // SetCreatedAt sets the "created_at" field.
  3487. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3488. m.created_at = &t
  3489. }
  3490. // CreatedAt returns the value of the "created_at" field in the mutation.
  3491. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3492. v := m.created_at
  3493. if v == nil {
  3494. return
  3495. }
  3496. return *v, true
  3497. }
  3498. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3499. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3501. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3502. if !m.op.Is(OpUpdateOne) {
  3503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3504. }
  3505. if m.id == nil || m.oldValue == nil {
  3506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3507. }
  3508. oldValue, err := m.oldValue(ctx)
  3509. if err != nil {
  3510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3511. }
  3512. return oldValue.CreatedAt, nil
  3513. }
  3514. // ResetCreatedAt resets all changes to the "created_at" field.
  3515. func (m *AllocAgentMutation) ResetCreatedAt() {
  3516. m.created_at = nil
  3517. }
  3518. // SetUpdatedAt sets the "updated_at" field.
  3519. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3520. m.updated_at = &t
  3521. }
  3522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3523. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3524. v := m.updated_at
  3525. if v == nil {
  3526. return
  3527. }
  3528. return *v, true
  3529. }
  3530. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3531. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3533. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3534. if !m.op.Is(OpUpdateOne) {
  3535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3536. }
  3537. if m.id == nil || m.oldValue == nil {
  3538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3539. }
  3540. oldValue, err := m.oldValue(ctx)
  3541. if err != nil {
  3542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3543. }
  3544. return oldValue.UpdatedAt, nil
  3545. }
  3546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3547. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3548. m.updated_at = nil
  3549. }
  3550. // SetDeletedAt sets the "deleted_at" field.
  3551. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3552. m.deleted_at = &t
  3553. }
  3554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3555. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3556. v := m.deleted_at
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3563. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3575. }
  3576. return oldValue.DeletedAt, nil
  3577. }
  3578. // ClearDeletedAt clears the value of the "deleted_at" field.
  3579. func (m *AllocAgentMutation) ClearDeletedAt() {
  3580. m.deleted_at = nil
  3581. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3582. }
  3583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3584. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3585. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3586. return ok
  3587. }
  3588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3589. func (m *AllocAgentMutation) ResetDeletedAt() {
  3590. m.deleted_at = nil
  3591. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3592. }
  3593. // SetUserID sets the "user_id" field.
  3594. func (m *AllocAgentMutation) SetUserID(s string) {
  3595. m.user_id = &s
  3596. }
  3597. // UserID returns the value of the "user_id" field in the mutation.
  3598. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3599. v := m.user_id
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3606. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldUserID requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3618. }
  3619. return oldValue.UserID, nil
  3620. }
  3621. // ClearUserID clears the value of the "user_id" field.
  3622. func (m *AllocAgentMutation) ClearUserID() {
  3623. m.user_id = nil
  3624. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3625. }
  3626. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3627. func (m *AllocAgentMutation) UserIDCleared() bool {
  3628. _, ok := m.clearedFields[allocagent.FieldUserID]
  3629. return ok
  3630. }
  3631. // ResetUserID resets all changes to the "user_id" field.
  3632. func (m *AllocAgentMutation) ResetUserID() {
  3633. m.user_id = nil
  3634. delete(m.clearedFields, allocagent.FieldUserID)
  3635. }
  3636. // SetOrganizationID sets the "organization_id" field.
  3637. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3638. m.organization_id = &u
  3639. m.addorganization_id = nil
  3640. }
  3641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3642. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3643. v := m.organization_id
  3644. if v == nil {
  3645. return
  3646. }
  3647. return *v, true
  3648. }
  3649. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3650. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3652. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3653. if !m.op.Is(OpUpdateOne) {
  3654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3655. }
  3656. if m.id == nil || m.oldValue == nil {
  3657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3658. }
  3659. oldValue, err := m.oldValue(ctx)
  3660. if err != nil {
  3661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3662. }
  3663. return oldValue.OrganizationID, nil
  3664. }
  3665. // AddOrganizationID adds u to the "organization_id" field.
  3666. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3667. if m.addorganization_id != nil {
  3668. *m.addorganization_id += u
  3669. } else {
  3670. m.addorganization_id = &u
  3671. }
  3672. }
  3673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3674. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3675. v := m.addorganization_id
  3676. if v == nil {
  3677. return
  3678. }
  3679. return *v, true
  3680. }
  3681. // ClearOrganizationID clears the value of the "organization_id" field.
  3682. func (m *AllocAgentMutation) ClearOrganizationID() {
  3683. m.organization_id = nil
  3684. m.addorganization_id = nil
  3685. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3686. }
  3687. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3688. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3689. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3690. return ok
  3691. }
  3692. // ResetOrganizationID resets all changes to the "organization_id" field.
  3693. func (m *AllocAgentMutation) ResetOrganizationID() {
  3694. m.organization_id = nil
  3695. m.addorganization_id = nil
  3696. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3697. }
  3698. // SetAgents sets the "agents" field.
  3699. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3700. m.agents = &u
  3701. m.appendagents = nil
  3702. }
  3703. // Agents returns the value of the "agents" field in the mutation.
  3704. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3705. v := m.agents
  3706. if v == nil {
  3707. return
  3708. }
  3709. return *v, true
  3710. }
  3711. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3712. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3714. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3715. if !m.op.Is(OpUpdateOne) {
  3716. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3717. }
  3718. if m.id == nil || m.oldValue == nil {
  3719. return v, errors.New("OldAgents requires an ID field in the mutation")
  3720. }
  3721. oldValue, err := m.oldValue(ctx)
  3722. if err != nil {
  3723. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3724. }
  3725. return oldValue.Agents, nil
  3726. }
  3727. // AppendAgents adds u to the "agents" field.
  3728. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3729. m.appendagents = append(m.appendagents, u...)
  3730. }
  3731. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3732. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3733. if len(m.appendagents) == 0 {
  3734. return nil, false
  3735. }
  3736. return m.appendagents, true
  3737. }
  3738. // ResetAgents resets all changes to the "agents" field.
  3739. func (m *AllocAgentMutation) ResetAgents() {
  3740. m.agents = nil
  3741. m.appendagents = nil
  3742. }
  3743. // SetStatus sets the "status" field.
  3744. func (m *AllocAgentMutation) SetStatus(i int) {
  3745. m.status = &i
  3746. m.addstatus = nil
  3747. }
  3748. // Status returns the value of the "status" field in the mutation.
  3749. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3750. v := m.status
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3757. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldStatus requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3769. }
  3770. return oldValue.Status, nil
  3771. }
  3772. // AddStatus adds i to the "status" field.
  3773. func (m *AllocAgentMutation) AddStatus(i int) {
  3774. if m.addstatus != nil {
  3775. *m.addstatus += i
  3776. } else {
  3777. m.addstatus = &i
  3778. }
  3779. }
  3780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3781. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3782. v := m.addstatus
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearStatus clears the value of the "status" field.
  3789. func (m *AllocAgentMutation) ClearStatus() {
  3790. m.status = nil
  3791. m.addstatus = nil
  3792. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3793. }
  3794. // StatusCleared returns if the "status" field was cleared in this mutation.
  3795. func (m *AllocAgentMutation) StatusCleared() bool {
  3796. _, ok := m.clearedFields[allocagent.FieldStatus]
  3797. return ok
  3798. }
  3799. // ResetStatus resets all changes to the "status" field.
  3800. func (m *AllocAgentMutation) ResetStatus() {
  3801. m.status = nil
  3802. m.addstatus = nil
  3803. delete(m.clearedFields, allocagent.FieldStatus)
  3804. }
  3805. // Where appends a list predicates to the AllocAgentMutation builder.
  3806. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3807. m.predicates = append(m.predicates, ps...)
  3808. }
  3809. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3810. // users can use type-assertion to append predicates that do not depend on any generated package.
  3811. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3812. p := make([]predicate.AllocAgent, len(ps))
  3813. for i := range ps {
  3814. p[i] = ps[i]
  3815. }
  3816. m.Where(p...)
  3817. }
  3818. // Op returns the operation name.
  3819. func (m *AllocAgentMutation) Op() Op {
  3820. return m.op
  3821. }
  3822. // SetOp allows setting the mutation operation.
  3823. func (m *AllocAgentMutation) SetOp(op Op) {
  3824. m.op = op
  3825. }
  3826. // Type returns the node type of this mutation (AllocAgent).
  3827. func (m *AllocAgentMutation) Type() string {
  3828. return m.typ
  3829. }
  3830. // Fields returns all fields that were changed during this mutation. Note that in
  3831. // order to get all numeric fields that were incremented/decremented, call
  3832. // AddedFields().
  3833. func (m *AllocAgentMutation) Fields() []string {
  3834. fields := make([]string, 0, 7)
  3835. if m.created_at != nil {
  3836. fields = append(fields, allocagent.FieldCreatedAt)
  3837. }
  3838. if m.updated_at != nil {
  3839. fields = append(fields, allocagent.FieldUpdatedAt)
  3840. }
  3841. if m.deleted_at != nil {
  3842. fields = append(fields, allocagent.FieldDeletedAt)
  3843. }
  3844. if m.user_id != nil {
  3845. fields = append(fields, allocagent.FieldUserID)
  3846. }
  3847. if m.organization_id != nil {
  3848. fields = append(fields, allocagent.FieldOrganizationID)
  3849. }
  3850. if m.agents != nil {
  3851. fields = append(fields, allocagent.FieldAgents)
  3852. }
  3853. if m.status != nil {
  3854. fields = append(fields, allocagent.FieldStatus)
  3855. }
  3856. return fields
  3857. }
  3858. // Field returns the value of a field with the given name. The second boolean
  3859. // return value indicates that this field was not set, or was not defined in the
  3860. // schema.
  3861. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3862. switch name {
  3863. case allocagent.FieldCreatedAt:
  3864. return m.CreatedAt()
  3865. case allocagent.FieldUpdatedAt:
  3866. return m.UpdatedAt()
  3867. case allocagent.FieldDeletedAt:
  3868. return m.DeletedAt()
  3869. case allocagent.FieldUserID:
  3870. return m.UserID()
  3871. case allocagent.FieldOrganizationID:
  3872. return m.OrganizationID()
  3873. case allocagent.FieldAgents:
  3874. return m.Agents()
  3875. case allocagent.FieldStatus:
  3876. return m.Status()
  3877. }
  3878. return nil, false
  3879. }
  3880. // OldField returns the old value of the field from the database. An error is
  3881. // returned if the mutation operation is not UpdateOne, or the query to the
  3882. // database failed.
  3883. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3884. switch name {
  3885. case allocagent.FieldCreatedAt:
  3886. return m.OldCreatedAt(ctx)
  3887. case allocagent.FieldUpdatedAt:
  3888. return m.OldUpdatedAt(ctx)
  3889. case allocagent.FieldDeletedAt:
  3890. return m.OldDeletedAt(ctx)
  3891. case allocagent.FieldUserID:
  3892. return m.OldUserID(ctx)
  3893. case allocagent.FieldOrganizationID:
  3894. return m.OldOrganizationID(ctx)
  3895. case allocagent.FieldAgents:
  3896. return m.OldAgents(ctx)
  3897. case allocagent.FieldStatus:
  3898. return m.OldStatus(ctx)
  3899. }
  3900. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3901. }
  3902. // SetField sets the value of a field with the given name. It returns an error if
  3903. // the field is not defined in the schema, or if the type mismatched the field
  3904. // type.
  3905. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3906. switch name {
  3907. case allocagent.FieldCreatedAt:
  3908. v, ok := value.(time.Time)
  3909. if !ok {
  3910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3911. }
  3912. m.SetCreatedAt(v)
  3913. return nil
  3914. case allocagent.FieldUpdatedAt:
  3915. v, ok := value.(time.Time)
  3916. if !ok {
  3917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3918. }
  3919. m.SetUpdatedAt(v)
  3920. return nil
  3921. case allocagent.FieldDeletedAt:
  3922. v, ok := value.(time.Time)
  3923. if !ok {
  3924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3925. }
  3926. m.SetDeletedAt(v)
  3927. return nil
  3928. case allocagent.FieldUserID:
  3929. v, ok := value.(string)
  3930. if !ok {
  3931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3932. }
  3933. m.SetUserID(v)
  3934. return nil
  3935. case allocagent.FieldOrganizationID:
  3936. v, ok := value.(uint64)
  3937. if !ok {
  3938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3939. }
  3940. m.SetOrganizationID(v)
  3941. return nil
  3942. case allocagent.FieldAgents:
  3943. v, ok := value.([]uint64)
  3944. if !ok {
  3945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3946. }
  3947. m.SetAgents(v)
  3948. return nil
  3949. case allocagent.FieldStatus:
  3950. v, ok := value.(int)
  3951. if !ok {
  3952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3953. }
  3954. m.SetStatus(v)
  3955. return nil
  3956. }
  3957. return fmt.Errorf("unknown AllocAgent field %s", name)
  3958. }
  3959. // AddedFields returns all numeric fields that were incremented/decremented during
  3960. // this mutation.
  3961. func (m *AllocAgentMutation) AddedFields() []string {
  3962. var fields []string
  3963. if m.addorganization_id != nil {
  3964. fields = append(fields, allocagent.FieldOrganizationID)
  3965. }
  3966. if m.addstatus != nil {
  3967. fields = append(fields, allocagent.FieldStatus)
  3968. }
  3969. return fields
  3970. }
  3971. // AddedField returns the numeric value that was incremented/decremented on a field
  3972. // with the given name. The second boolean return value indicates that this field
  3973. // was not set, or was not defined in the schema.
  3974. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3975. switch name {
  3976. case allocagent.FieldOrganizationID:
  3977. return m.AddedOrganizationID()
  3978. case allocagent.FieldStatus:
  3979. return m.AddedStatus()
  3980. }
  3981. return nil, false
  3982. }
  3983. // AddField adds the value to the field with the given name. It returns an error if
  3984. // the field is not defined in the schema, or if the type mismatched the field
  3985. // type.
  3986. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3987. switch name {
  3988. case allocagent.FieldOrganizationID:
  3989. v, ok := value.(int64)
  3990. if !ok {
  3991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3992. }
  3993. m.AddOrganizationID(v)
  3994. return nil
  3995. case allocagent.FieldStatus:
  3996. v, ok := value.(int)
  3997. if !ok {
  3998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3999. }
  4000. m.AddStatus(v)
  4001. return nil
  4002. }
  4003. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4004. }
  4005. // ClearedFields returns all nullable fields that were cleared during this
  4006. // mutation.
  4007. func (m *AllocAgentMutation) ClearedFields() []string {
  4008. var fields []string
  4009. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4010. fields = append(fields, allocagent.FieldDeletedAt)
  4011. }
  4012. if m.FieldCleared(allocagent.FieldUserID) {
  4013. fields = append(fields, allocagent.FieldUserID)
  4014. }
  4015. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4016. fields = append(fields, allocagent.FieldOrganizationID)
  4017. }
  4018. if m.FieldCleared(allocagent.FieldStatus) {
  4019. fields = append(fields, allocagent.FieldStatus)
  4020. }
  4021. return fields
  4022. }
  4023. // FieldCleared returns a boolean indicating if a field with the given name was
  4024. // cleared in this mutation.
  4025. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4026. _, ok := m.clearedFields[name]
  4027. return ok
  4028. }
  4029. // ClearField clears the value of the field with the given name. It returns an
  4030. // error if the field is not defined in the schema.
  4031. func (m *AllocAgentMutation) ClearField(name string) error {
  4032. switch name {
  4033. case allocagent.FieldDeletedAt:
  4034. m.ClearDeletedAt()
  4035. return nil
  4036. case allocagent.FieldUserID:
  4037. m.ClearUserID()
  4038. return nil
  4039. case allocagent.FieldOrganizationID:
  4040. m.ClearOrganizationID()
  4041. return nil
  4042. case allocagent.FieldStatus:
  4043. m.ClearStatus()
  4044. return nil
  4045. }
  4046. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4047. }
  4048. // ResetField resets all changes in the mutation for the field with the given name.
  4049. // It returns an error if the field is not defined in the schema.
  4050. func (m *AllocAgentMutation) ResetField(name string) error {
  4051. switch name {
  4052. case allocagent.FieldCreatedAt:
  4053. m.ResetCreatedAt()
  4054. return nil
  4055. case allocagent.FieldUpdatedAt:
  4056. m.ResetUpdatedAt()
  4057. return nil
  4058. case allocagent.FieldDeletedAt:
  4059. m.ResetDeletedAt()
  4060. return nil
  4061. case allocagent.FieldUserID:
  4062. m.ResetUserID()
  4063. return nil
  4064. case allocagent.FieldOrganizationID:
  4065. m.ResetOrganizationID()
  4066. return nil
  4067. case allocagent.FieldAgents:
  4068. m.ResetAgents()
  4069. return nil
  4070. case allocagent.FieldStatus:
  4071. m.ResetStatus()
  4072. return nil
  4073. }
  4074. return fmt.Errorf("unknown AllocAgent field %s", name)
  4075. }
  4076. // AddedEdges returns all edge names that were set/added in this mutation.
  4077. func (m *AllocAgentMutation) AddedEdges() []string {
  4078. edges := make([]string, 0, 0)
  4079. return edges
  4080. }
  4081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4082. // name in this mutation.
  4083. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4084. return nil
  4085. }
  4086. // RemovedEdges returns all edge names that were removed in this mutation.
  4087. func (m *AllocAgentMutation) RemovedEdges() []string {
  4088. edges := make([]string, 0, 0)
  4089. return edges
  4090. }
  4091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4092. // the given name in this mutation.
  4093. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4094. return nil
  4095. }
  4096. // ClearedEdges returns all edge names that were cleared in this mutation.
  4097. func (m *AllocAgentMutation) ClearedEdges() []string {
  4098. edges := make([]string, 0, 0)
  4099. return edges
  4100. }
  4101. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4102. // was cleared in this mutation.
  4103. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4104. return false
  4105. }
  4106. // ClearEdge clears the value of the edge with the given name. It returns an error
  4107. // if that edge is not defined in the schema.
  4108. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4109. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4110. }
  4111. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4112. // It returns an error if the edge is not defined in the schema.
  4113. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4114. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4115. }
  4116. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4117. type ApiKeyMutation struct {
  4118. config
  4119. op Op
  4120. typ string
  4121. id *uint64
  4122. created_at *time.Time
  4123. updated_at *time.Time
  4124. deleted_at *time.Time
  4125. title *string
  4126. key *string
  4127. organization_id *uint64
  4128. addorganization_id *int64
  4129. custom_agent_base *string
  4130. custom_agent_key *string
  4131. openai_base *string
  4132. openai_key *string
  4133. clearedFields map[string]struct{}
  4134. agent *uint64
  4135. clearedagent bool
  4136. done bool
  4137. oldValue func(context.Context) (*ApiKey, error)
  4138. predicates []predicate.ApiKey
  4139. }
  4140. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4141. // apikeyOption allows management of the mutation configuration using functional options.
  4142. type apikeyOption func(*ApiKeyMutation)
  4143. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4144. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4145. m := &ApiKeyMutation{
  4146. config: c,
  4147. op: op,
  4148. typ: TypeApiKey,
  4149. clearedFields: make(map[string]struct{}),
  4150. }
  4151. for _, opt := range opts {
  4152. opt(m)
  4153. }
  4154. return m
  4155. }
  4156. // withApiKeyID sets the ID field of the mutation.
  4157. func withApiKeyID(id uint64) apikeyOption {
  4158. return func(m *ApiKeyMutation) {
  4159. var (
  4160. err error
  4161. once sync.Once
  4162. value *ApiKey
  4163. )
  4164. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4165. once.Do(func() {
  4166. if m.done {
  4167. err = errors.New("querying old values post mutation is not allowed")
  4168. } else {
  4169. value, err = m.Client().ApiKey.Get(ctx, id)
  4170. }
  4171. })
  4172. return value, err
  4173. }
  4174. m.id = &id
  4175. }
  4176. }
  4177. // withApiKey sets the old ApiKey of the mutation.
  4178. func withApiKey(node *ApiKey) apikeyOption {
  4179. return func(m *ApiKeyMutation) {
  4180. m.oldValue = func(context.Context) (*ApiKey, error) {
  4181. return node, nil
  4182. }
  4183. m.id = &node.ID
  4184. }
  4185. }
  4186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4187. // executed in a transaction (ent.Tx), a transactional client is returned.
  4188. func (m ApiKeyMutation) Client() *Client {
  4189. client := &Client{config: m.config}
  4190. client.init()
  4191. return client
  4192. }
  4193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4194. // it returns an error otherwise.
  4195. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4196. if _, ok := m.driver.(*txDriver); !ok {
  4197. return nil, errors.New("ent: mutation is not running in a transaction")
  4198. }
  4199. tx := &Tx{config: m.config}
  4200. tx.init()
  4201. return tx, nil
  4202. }
  4203. // SetID sets the value of the id field. Note that this
  4204. // operation is only accepted on creation of ApiKey entities.
  4205. func (m *ApiKeyMutation) SetID(id uint64) {
  4206. m.id = &id
  4207. }
  4208. // ID returns the ID value in the mutation. Note that the ID is only available
  4209. // if it was provided to the builder or after it was returned from the database.
  4210. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4211. if m.id == nil {
  4212. return
  4213. }
  4214. return *m.id, true
  4215. }
  4216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4217. // That means, if the mutation is applied within a transaction with an isolation level such
  4218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4219. // or updated by the mutation.
  4220. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4221. switch {
  4222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4223. id, exists := m.ID()
  4224. if exists {
  4225. return []uint64{id}, nil
  4226. }
  4227. fallthrough
  4228. case m.op.Is(OpUpdate | OpDelete):
  4229. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4230. default:
  4231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4232. }
  4233. }
  4234. // SetCreatedAt sets the "created_at" field.
  4235. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4236. m.created_at = &t
  4237. }
  4238. // CreatedAt returns the value of the "created_at" field in the mutation.
  4239. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4240. v := m.created_at
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4247. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4249. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4250. if !m.op.Is(OpUpdateOne) {
  4251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4252. }
  4253. if m.id == nil || m.oldValue == nil {
  4254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4255. }
  4256. oldValue, err := m.oldValue(ctx)
  4257. if err != nil {
  4258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4259. }
  4260. return oldValue.CreatedAt, nil
  4261. }
  4262. // ResetCreatedAt resets all changes to the "created_at" field.
  4263. func (m *ApiKeyMutation) ResetCreatedAt() {
  4264. m.created_at = nil
  4265. }
  4266. // SetUpdatedAt sets the "updated_at" field.
  4267. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4268. m.updated_at = &t
  4269. }
  4270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4271. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4272. v := m.updated_at
  4273. if v == nil {
  4274. return
  4275. }
  4276. return *v, true
  4277. }
  4278. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4279. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4281. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4282. if !m.op.Is(OpUpdateOne) {
  4283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4284. }
  4285. if m.id == nil || m.oldValue == nil {
  4286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4287. }
  4288. oldValue, err := m.oldValue(ctx)
  4289. if err != nil {
  4290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4291. }
  4292. return oldValue.UpdatedAt, nil
  4293. }
  4294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4295. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4296. m.updated_at = nil
  4297. }
  4298. // SetDeletedAt sets the "deleted_at" field.
  4299. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4300. m.deleted_at = &t
  4301. }
  4302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4303. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4304. v := m.deleted_at
  4305. if v == nil {
  4306. return
  4307. }
  4308. return *v, true
  4309. }
  4310. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4311. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4313. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4314. if !m.op.Is(OpUpdateOne) {
  4315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4316. }
  4317. if m.id == nil || m.oldValue == nil {
  4318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4319. }
  4320. oldValue, err := m.oldValue(ctx)
  4321. if err != nil {
  4322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4323. }
  4324. return oldValue.DeletedAt, nil
  4325. }
  4326. // ClearDeletedAt clears the value of the "deleted_at" field.
  4327. func (m *ApiKeyMutation) ClearDeletedAt() {
  4328. m.deleted_at = nil
  4329. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4330. }
  4331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4332. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4333. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4334. return ok
  4335. }
  4336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4337. func (m *ApiKeyMutation) ResetDeletedAt() {
  4338. m.deleted_at = nil
  4339. delete(m.clearedFields, apikey.FieldDeletedAt)
  4340. }
  4341. // SetTitle sets the "title" field.
  4342. func (m *ApiKeyMutation) SetTitle(s string) {
  4343. m.title = &s
  4344. }
  4345. // Title returns the value of the "title" field in the mutation.
  4346. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4347. v := m.title
  4348. if v == nil {
  4349. return
  4350. }
  4351. return *v, true
  4352. }
  4353. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4354. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4356. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4357. if !m.op.Is(OpUpdateOne) {
  4358. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4359. }
  4360. if m.id == nil || m.oldValue == nil {
  4361. return v, errors.New("OldTitle requires an ID field in the mutation")
  4362. }
  4363. oldValue, err := m.oldValue(ctx)
  4364. if err != nil {
  4365. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4366. }
  4367. return oldValue.Title, nil
  4368. }
  4369. // ClearTitle clears the value of the "title" field.
  4370. func (m *ApiKeyMutation) ClearTitle() {
  4371. m.title = nil
  4372. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4373. }
  4374. // TitleCleared returns if the "title" field was cleared in this mutation.
  4375. func (m *ApiKeyMutation) TitleCleared() bool {
  4376. _, ok := m.clearedFields[apikey.FieldTitle]
  4377. return ok
  4378. }
  4379. // ResetTitle resets all changes to the "title" field.
  4380. func (m *ApiKeyMutation) ResetTitle() {
  4381. m.title = nil
  4382. delete(m.clearedFields, apikey.FieldTitle)
  4383. }
  4384. // SetKey sets the "key" field.
  4385. func (m *ApiKeyMutation) SetKey(s string) {
  4386. m.key = &s
  4387. }
  4388. // Key returns the value of the "key" field in the mutation.
  4389. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4390. v := m.key
  4391. if v == nil {
  4392. return
  4393. }
  4394. return *v, true
  4395. }
  4396. // OldKey returns the old "key" field's value of the ApiKey entity.
  4397. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4399. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4400. if !m.op.Is(OpUpdateOne) {
  4401. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4402. }
  4403. if m.id == nil || m.oldValue == nil {
  4404. return v, errors.New("OldKey requires an ID field in the mutation")
  4405. }
  4406. oldValue, err := m.oldValue(ctx)
  4407. if err != nil {
  4408. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4409. }
  4410. return oldValue.Key, nil
  4411. }
  4412. // ClearKey clears the value of the "key" field.
  4413. func (m *ApiKeyMutation) ClearKey() {
  4414. m.key = nil
  4415. m.clearedFields[apikey.FieldKey] = struct{}{}
  4416. }
  4417. // KeyCleared returns if the "key" field was cleared in this mutation.
  4418. func (m *ApiKeyMutation) KeyCleared() bool {
  4419. _, ok := m.clearedFields[apikey.FieldKey]
  4420. return ok
  4421. }
  4422. // ResetKey resets all changes to the "key" field.
  4423. func (m *ApiKeyMutation) ResetKey() {
  4424. m.key = nil
  4425. delete(m.clearedFields, apikey.FieldKey)
  4426. }
  4427. // SetOrganizationID sets the "organization_id" field.
  4428. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4429. m.organization_id = &u
  4430. m.addorganization_id = nil
  4431. }
  4432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4433. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4434. v := m.organization_id
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4441. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4453. }
  4454. return oldValue.OrganizationID, nil
  4455. }
  4456. // AddOrganizationID adds u to the "organization_id" field.
  4457. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4458. if m.addorganization_id != nil {
  4459. *m.addorganization_id += u
  4460. } else {
  4461. m.addorganization_id = &u
  4462. }
  4463. }
  4464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4465. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4466. v := m.addorganization_id
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // ResetOrganizationID resets all changes to the "organization_id" field.
  4473. func (m *ApiKeyMutation) ResetOrganizationID() {
  4474. m.organization_id = nil
  4475. m.addorganization_id = nil
  4476. }
  4477. // SetAgentID sets the "agent_id" field.
  4478. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4479. m.agent = &u
  4480. }
  4481. // AgentID returns the value of the "agent_id" field in the mutation.
  4482. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4483. v := m.agent
  4484. if v == nil {
  4485. return
  4486. }
  4487. return *v, true
  4488. }
  4489. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4490. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4492. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4493. if !m.op.Is(OpUpdateOne) {
  4494. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4495. }
  4496. if m.id == nil || m.oldValue == nil {
  4497. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4498. }
  4499. oldValue, err := m.oldValue(ctx)
  4500. if err != nil {
  4501. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4502. }
  4503. return oldValue.AgentID, nil
  4504. }
  4505. // ResetAgentID resets all changes to the "agent_id" field.
  4506. func (m *ApiKeyMutation) ResetAgentID() {
  4507. m.agent = nil
  4508. }
  4509. // SetCustomAgentBase sets the "custom_agent_base" field.
  4510. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4511. m.custom_agent_base = &s
  4512. }
  4513. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4514. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4515. v := m.custom_agent_base
  4516. if v == nil {
  4517. return
  4518. }
  4519. return *v, true
  4520. }
  4521. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4522. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4524. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4525. if !m.op.Is(OpUpdateOne) {
  4526. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4527. }
  4528. if m.id == nil || m.oldValue == nil {
  4529. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4530. }
  4531. oldValue, err := m.oldValue(ctx)
  4532. if err != nil {
  4533. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4534. }
  4535. return oldValue.CustomAgentBase, nil
  4536. }
  4537. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4538. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4539. m.custom_agent_base = nil
  4540. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4541. }
  4542. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4543. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4544. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4545. return ok
  4546. }
  4547. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4548. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4549. m.custom_agent_base = nil
  4550. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4551. }
  4552. // SetCustomAgentKey sets the "custom_agent_key" field.
  4553. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4554. m.custom_agent_key = &s
  4555. }
  4556. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4557. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4558. v := m.custom_agent_key
  4559. if v == nil {
  4560. return
  4561. }
  4562. return *v, true
  4563. }
  4564. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4565. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4567. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4568. if !m.op.Is(OpUpdateOne) {
  4569. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4570. }
  4571. if m.id == nil || m.oldValue == nil {
  4572. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4573. }
  4574. oldValue, err := m.oldValue(ctx)
  4575. if err != nil {
  4576. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4577. }
  4578. return oldValue.CustomAgentKey, nil
  4579. }
  4580. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4581. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4582. m.custom_agent_key = nil
  4583. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4584. }
  4585. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4586. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4587. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4588. return ok
  4589. }
  4590. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4591. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4592. m.custom_agent_key = nil
  4593. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4594. }
  4595. // SetOpenaiBase sets the "openai_base" field.
  4596. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4597. m.openai_base = &s
  4598. }
  4599. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4600. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4601. v := m.openai_base
  4602. if v == nil {
  4603. return
  4604. }
  4605. return *v, true
  4606. }
  4607. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4608. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4610. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4611. if !m.op.Is(OpUpdateOne) {
  4612. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4613. }
  4614. if m.id == nil || m.oldValue == nil {
  4615. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4616. }
  4617. oldValue, err := m.oldValue(ctx)
  4618. if err != nil {
  4619. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4620. }
  4621. return oldValue.OpenaiBase, nil
  4622. }
  4623. // ClearOpenaiBase clears the value of the "openai_base" field.
  4624. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4625. m.openai_base = nil
  4626. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4627. }
  4628. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4629. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4630. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4631. return ok
  4632. }
  4633. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4634. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4635. m.openai_base = nil
  4636. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4637. }
  4638. // SetOpenaiKey sets the "openai_key" field.
  4639. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4640. m.openai_key = &s
  4641. }
  4642. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4643. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4644. v := m.openai_key
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4651. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4663. }
  4664. return oldValue.OpenaiKey, nil
  4665. }
  4666. // ClearOpenaiKey clears the value of the "openai_key" field.
  4667. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4668. m.openai_key = nil
  4669. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4670. }
  4671. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4672. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4673. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4674. return ok
  4675. }
  4676. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4677. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4678. m.openai_key = nil
  4679. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4680. }
  4681. // ClearAgent clears the "agent" edge to the Agent entity.
  4682. func (m *ApiKeyMutation) ClearAgent() {
  4683. m.clearedagent = true
  4684. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4685. }
  4686. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4687. func (m *ApiKeyMutation) AgentCleared() bool {
  4688. return m.clearedagent
  4689. }
  4690. // AgentIDs returns the "agent" edge IDs in the mutation.
  4691. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4692. // AgentID instead. It exists only for internal usage by the builders.
  4693. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4694. if id := m.agent; id != nil {
  4695. ids = append(ids, *id)
  4696. }
  4697. return
  4698. }
  4699. // ResetAgent resets all changes to the "agent" edge.
  4700. func (m *ApiKeyMutation) ResetAgent() {
  4701. m.agent = nil
  4702. m.clearedagent = false
  4703. }
  4704. // Where appends a list predicates to the ApiKeyMutation builder.
  4705. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4706. m.predicates = append(m.predicates, ps...)
  4707. }
  4708. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4709. // users can use type-assertion to append predicates that do not depend on any generated package.
  4710. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4711. p := make([]predicate.ApiKey, len(ps))
  4712. for i := range ps {
  4713. p[i] = ps[i]
  4714. }
  4715. m.Where(p...)
  4716. }
  4717. // Op returns the operation name.
  4718. func (m *ApiKeyMutation) Op() Op {
  4719. return m.op
  4720. }
  4721. // SetOp allows setting the mutation operation.
  4722. func (m *ApiKeyMutation) SetOp(op Op) {
  4723. m.op = op
  4724. }
  4725. // Type returns the node type of this mutation (ApiKey).
  4726. func (m *ApiKeyMutation) Type() string {
  4727. return m.typ
  4728. }
  4729. // Fields returns all fields that were changed during this mutation. Note that in
  4730. // order to get all numeric fields that were incremented/decremented, call
  4731. // AddedFields().
  4732. func (m *ApiKeyMutation) Fields() []string {
  4733. fields := make([]string, 0, 11)
  4734. if m.created_at != nil {
  4735. fields = append(fields, apikey.FieldCreatedAt)
  4736. }
  4737. if m.updated_at != nil {
  4738. fields = append(fields, apikey.FieldUpdatedAt)
  4739. }
  4740. if m.deleted_at != nil {
  4741. fields = append(fields, apikey.FieldDeletedAt)
  4742. }
  4743. if m.title != nil {
  4744. fields = append(fields, apikey.FieldTitle)
  4745. }
  4746. if m.key != nil {
  4747. fields = append(fields, apikey.FieldKey)
  4748. }
  4749. if m.organization_id != nil {
  4750. fields = append(fields, apikey.FieldOrganizationID)
  4751. }
  4752. if m.agent != nil {
  4753. fields = append(fields, apikey.FieldAgentID)
  4754. }
  4755. if m.custom_agent_base != nil {
  4756. fields = append(fields, apikey.FieldCustomAgentBase)
  4757. }
  4758. if m.custom_agent_key != nil {
  4759. fields = append(fields, apikey.FieldCustomAgentKey)
  4760. }
  4761. if m.openai_base != nil {
  4762. fields = append(fields, apikey.FieldOpenaiBase)
  4763. }
  4764. if m.openai_key != nil {
  4765. fields = append(fields, apikey.FieldOpenaiKey)
  4766. }
  4767. return fields
  4768. }
  4769. // Field returns the value of a field with the given name. The second boolean
  4770. // return value indicates that this field was not set, or was not defined in the
  4771. // schema.
  4772. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4773. switch name {
  4774. case apikey.FieldCreatedAt:
  4775. return m.CreatedAt()
  4776. case apikey.FieldUpdatedAt:
  4777. return m.UpdatedAt()
  4778. case apikey.FieldDeletedAt:
  4779. return m.DeletedAt()
  4780. case apikey.FieldTitle:
  4781. return m.Title()
  4782. case apikey.FieldKey:
  4783. return m.Key()
  4784. case apikey.FieldOrganizationID:
  4785. return m.OrganizationID()
  4786. case apikey.FieldAgentID:
  4787. return m.AgentID()
  4788. case apikey.FieldCustomAgentBase:
  4789. return m.CustomAgentBase()
  4790. case apikey.FieldCustomAgentKey:
  4791. return m.CustomAgentKey()
  4792. case apikey.FieldOpenaiBase:
  4793. return m.OpenaiBase()
  4794. case apikey.FieldOpenaiKey:
  4795. return m.OpenaiKey()
  4796. }
  4797. return nil, false
  4798. }
  4799. // OldField returns the old value of the field from the database. An error is
  4800. // returned if the mutation operation is not UpdateOne, or the query to the
  4801. // database failed.
  4802. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4803. switch name {
  4804. case apikey.FieldCreatedAt:
  4805. return m.OldCreatedAt(ctx)
  4806. case apikey.FieldUpdatedAt:
  4807. return m.OldUpdatedAt(ctx)
  4808. case apikey.FieldDeletedAt:
  4809. return m.OldDeletedAt(ctx)
  4810. case apikey.FieldTitle:
  4811. return m.OldTitle(ctx)
  4812. case apikey.FieldKey:
  4813. return m.OldKey(ctx)
  4814. case apikey.FieldOrganizationID:
  4815. return m.OldOrganizationID(ctx)
  4816. case apikey.FieldAgentID:
  4817. return m.OldAgentID(ctx)
  4818. case apikey.FieldCustomAgentBase:
  4819. return m.OldCustomAgentBase(ctx)
  4820. case apikey.FieldCustomAgentKey:
  4821. return m.OldCustomAgentKey(ctx)
  4822. case apikey.FieldOpenaiBase:
  4823. return m.OldOpenaiBase(ctx)
  4824. case apikey.FieldOpenaiKey:
  4825. return m.OldOpenaiKey(ctx)
  4826. }
  4827. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4828. }
  4829. // SetField sets the value of a field with the given name. It returns an error if
  4830. // the field is not defined in the schema, or if the type mismatched the field
  4831. // type.
  4832. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4833. switch name {
  4834. case apikey.FieldCreatedAt:
  4835. v, ok := value.(time.Time)
  4836. if !ok {
  4837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4838. }
  4839. m.SetCreatedAt(v)
  4840. return nil
  4841. case apikey.FieldUpdatedAt:
  4842. v, ok := value.(time.Time)
  4843. if !ok {
  4844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4845. }
  4846. m.SetUpdatedAt(v)
  4847. return nil
  4848. case apikey.FieldDeletedAt:
  4849. v, ok := value.(time.Time)
  4850. if !ok {
  4851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4852. }
  4853. m.SetDeletedAt(v)
  4854. return nil
  4855. case apikey.FieldTitle:
  4856. v, ok := value.(string)
  4857. if !ok {
  4858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4859. }
  4860. m.SetTitle(v)
  4861. return nil
  4862. case apikey.FieldKey:
  4863. v, ok := value.(string)
  4864. if !ok {
  4865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4866. }
  4867. m.SetKey(v)
  4868. return nil
  4869. case apikey.FieldOrganizationID:
  4870. v, ok := value.(uint64)
  4871. if !ok {
  4872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4873. }
  4874. m.SetOrganizationID(v)
  4875. return nil
  4876. case apikey.FieldAgentID:
  4877. v, ok := value.(uint64)
  4878. if !ok {
  4879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4880. }
  4881. m.SetAgentID(v)
  4882. return nil
  4883. case apikey.FieldCustomAgentBase:
  4884. v, ok := value.(string)
  4885. if !ok {
  4886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4887. }
  4888. m.SetCustomAgentBase(v)
  4889. return nil
  4890. case apikey.FieldCustomAgentKey:
  4891. v, ok := value.(string)
  4892. if !ok {
  4893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4894. }
  4895. m.SetCustomAgentKey(v)
  4896. return nil
  4897. case apikey.FieldOpenaiBase:
  4898. v, ok := value.(string)
  4899. if !ok {
  4900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4901. }
  4902. m.SetOpenaiBase(v)
  4903. return nil
  4904. case apikey.FieldOpenaiKey:
  4905. v, ok := value.(string)
  4906. if !ok {
  4907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4908. }
  4909. m.SetOpenaiKey(v)
  4910. return nil
  4911. }
  4912. return fmt.Errorf("unknown ApiKey field %s", name)
  4913. }
  4914. // AddedFields returns all numeric fields that were incremented/decremented during
  4915. // this mutation.
  4916. func (m *ApiKeyMutation) AddedFields() []string {
  4917. var fields []string
  4918. if m.addorganization_id != nil {
  4919. fields = append(fields, apikey.FieldOrganizationID)
  4920. }
  4921. return fields
  4922. }
  4923. // AddedField returns the numeric value that was incremented/decremented on a field
  4924. // with the given name. The second boolean return value indicates that this field
  4925. // was not set, or was not defined in the schema.
  4926. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4927. switch name {
  4928. case apikey.FieldOrganizationID:
  4929. return m.AddedOrganizationID()
  4930. }
  4931. return nil, false
  4932. }
  4933. // AddField adds the value to the field with the given name. It returns an error if
  4934. // the field is not defined in the schema, or if the type mismatched the field
  4935. // type.
  4936. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4937. switch name {
  4938. case apikey.FieldOrganizationID:
  4939. v, ok := value.(int64)
  4940. if !ok {
  4941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4942. }
  4943. m.AddOrganizationID(v)
  4944. return nil
  4945. }
  4946. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4947. }
  4948. // ClearedFields returns all nullable fields that were cleared during this
  4949. // mutation.
  4950. func (m *ApiKeyMutation) ClearedFields() []string {
  4951. var fields []string
  4952. if m.FieldCleared(apikey.FieldDeletedAt) {
  4953. fields = append(fields, apikey.FieldDeletedAt)
  4954. }
  4955. if m.FieldCleared(apikey.FieldTitle) {
  4956. fields = append(fields, apikey.FieldTitle)
  4957. }
  4958. if m.FieldCleared(apikey.FieldKey) {
  4959. fields = append(fields, apikey.FieldKey)
  4960. }
  4961. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4962. fields = append(fields, apikey.FieldCustomAgentBase)
  4963. }
  4964. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4965. fields = append(fields, apikey.FieldCustomAgentKey)
  4966. }
  4967. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4968. fields = append(fields, apikey.FieldOpenaiBase)
  4969. }
  4970. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4971. fields = append(fields, apikey.FieldOpenaiKey)
  4972. }
  4973. return fields
  4974. }
  4975. // FieldCleared returns a boolean indicating if a field with the given name was
  4976. // cleared in this mutation.
  4977. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4978. _, ok := m.clearedFields[name]
  4979. return ok
  4980. }
  4981. // ClearField clears the value of the field with the given name. It returns an
  4982. // error if the field is not defined in the schema.
  4983. func (m *ApiKeyMutation) ClearField(name string) error {
  4984. switch name {
  4985. case apikey.FieldDeletedAt:
  4986. m.ClearDeletedAt()
  4987. return nil
  4988. case apikey.FieldTitle:
  4989. m.ClearTitle()
  4990. return nil
  4991. case apikey.FieldKey:
  4992. m.ClearKey()
  4993. return nil
  4994. case apikey.FieldCustomAgentBase:
  4995. m.ClearCustomAgentBase()
  4996. return nil
  4997. case apikey.FieldCustomAgentKey:
  4998. m.ClearCustomAgentKey()
  4999. return nil
  5000. case apikey.FieldOpenaiBase:
  5001. m.ClearOpenaiBase()
  5002. return nil
  5003. case apikey.FieldOpenaiKey:
  5004. m.ClearOpenaiKey()
  5005. return nil
  5006. }
  5007. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5008. }
  5009. // ResetField resets all changes in the mutation for the field with the given name.
  5010. // It returns an error if the field is not defined in the schema.
  5011. func (m *ApiKeyMutation) ResetField(name string) error {
  5012. switch name {
  5013. case apikey.FieldCreatedAt:
  5014. m.ResetCreatedAt()
  5015. return nil
  5016. case apikey.FieldUpdatedAt:
  5017. m.ResetUpdatedAt()
  5018. return nil
  5019. case apikey.FieldDeletedAt:
  5020. m.ResetDeletedAt()
  5021. return nil
  5022. case apikey.FieldTitle:
  5023. m.ResetTitle()
  5024. return nil
  5025. case apikey.FieldKey:
  5026. m.ResetKey()
  5027. return nil
  5028. case apikey.FieldOrganizationID:
  5029. m.ResetOrganizationID()
  5030. return nil
  5031. case apikey.FieldAgentID:
  5032. m.ResetAgentID()
  5033. return nil
  5034. case apikey.FieldCustomAgentBase:
  5035. m.ResetCustomAgentBase()
  5036. return nil
  5037. case apikey.FieldCustomAgentKey:
  5038. m.ResetCustomAgentKey()
  5039. return nil
  5040. case apikey.FieldOpenaiBase:
  5041. m.ResetOpenaiBase()
  5042. return nil
  5043. case apikey.FieldOpenaiKey:
  5044. m.ResetOpenaiKey()
  5045. return nil
  5046. }
  5047. return fmt.Errorf("unknown ApiKey field %s", name)
  5048. }
  5049. // AddedEdges returns all edge names that were set/added in this mutation.
  5050. func (m *ApiKeyMutation) AddedEdges() []string {
  5051. edges := make([]string, 0, 1)
  5052. if m.agent != nil {
  5053. edges = append(edges, apikey.EdgeAgent)
  5054. }
  5055. return edges
  5056. }
  5057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5058. // name in this mutation.
  5059. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5060. switch name {
  5061. case apikey.EdgeAgent:
  5062. if id := m.agent; id != nil {
  5063. return []ent.Value{*id}
  5064. }
  5065. }
  5066. return nil
  5067. }
  5068. // RemovedEdges returns all edge names that were removed in this mutation.
  5069. func (m *ApiKeyMutation) RemovedEdges() []string {
  5070. edges := make([]string, 0, 1)
  5071. return edges
  5072. }
  5073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5074. // the given name in this mutation.
  5075. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5076. return nil
  5077. }
  5078. // ClearedEdges returns all edge names that were cleared in this mutation.
  5079. func (m *ApiKeyMutation) ClearedEdges() []string {
  5080. edges := make([]string, 0, 1)
  5081. if m.clearedagent {
  5082. edges = append(edges, apikey.EdgeAgent)
  5083. }
  5084. return edges
  5085. }
  5086. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5087. // was cleared in this mutation.
  5088. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5089. switch name {
  5090. case apikey.EdgeAgent:
  5091. return m.clearedagent
  5092. }
  5093. return false
  5094. }
  5095. // ClearEdge clears the value of the edge with the given name. It returns an error
  5096. // if that edge is not defined in the schema.
  5097. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5098. switch name {
  5099. case apikey.EdgeAgent:
  5100. m.ClearAgent()
  5101. return nil
  5102. }
  5103. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5104. }
  5105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5106. // It returns an error if the edge is not defined in the schema.
  5107. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5108. switch name {
  5109. case apikey.EdgeAgent:
  5110. m.ResetAgent()
  5111. return nil
  5112. }
  5113. return fmt.Errorf("unknown ApiKey edge %s", name)
  5114. }
  5115. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5116. type BatchMsgMutation struct {
  5117. config
  5118. op Op
  5119. typ string
  5120. id *uint64
  5121. created_at *time.Time
  5122. updated_at *time.Time
  5123. deleted_at *time.Time
  5124. status *uint8
  5125. addstatus *int8
  5126. batch_no *string
  5127. task_name *string
  5128. fromwxid *string
  5129. msg *string
  5130. tag *string
  5131. tagids *string
  5132. total *int32
  5133. addtotal *int32
  5134. success *int32
  5135. addsuccess *int32
  5136. fail *int32
  5137. addfail *int32
  5138. start_time *time.Time
  5139. stop_time *time.Time
  5140. send_time *time.Time
  5141. _type *int32
  5142. add_type *int32
  5143. organization_id *uint64
  5144. addorganization_id *int64
  5145. ctype *uint64
  5146. addctype *int64
  5147. cc *string
  5148. phone *string
  5149. template_name *string
  5150. template_code *string
  5151. lang *string
  5152. clearedFields map[string]struct{}
  5153. done bool
  5154. oldValue func(context.Context) (*BatchMsg, error)
  5155. predicates []predicate.BatchMsg
  5156. }
  5157. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5158. // batchmsgOption allows management of the mutation configuration using functional options.
  5159. type batchmsgOption func(*BatchMsgMutation)
  5160. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5161. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5162. m := &BatchMsgMutation{
  5163. config: c,
  5164. op: op,
  5165. typ: TypeBatchMsg,
  5166. clearedFields: make(map[string]struct{}),
  5167. }
  5168. for _, opt := range opts {
  5169. opt(m)
  5170. }
  5171. return m
  5172. }
  5173. // withBatchMsgID sets the ID field of the mutation.
  5174. func withBatchMsgID(id uint64) batchmsgOption {
  5175. return func(m *BatchMsgMutation) {
  5176. var (
  5177. err error
  5178. once sync.Once
  5179. value *BatchMsg
  5180. )
  5181. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5182. once.Do(func() {
  5183. if m.done {
  5184. err = errors.New("querying old values post mutation is not allowed")
  5185. } else {
  5186. value, err = m.Client().BatchMsg.Get(ctx, id)
  5187. }
  5188. })
  5189. return value, err
  5190. }
  5191. m.id = &id
  5192. }
  5193. }
  5194. // withBatchMsg sets the old BatchMsg of the mutation.
  5195. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5196. return func(m *BatchMsgMutation) {
  5197. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5198. return node, nil
  5199. }
  5200. m.id = &node.ID
  5201. }
  5202. }
  5203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5204. // executed in a transaction (ent.Tx), a transactional client is returned.
  5205. func (m BatchMsgMutation) Client() *Client {
  5206. client := &Client{config: m.config}
  5207. client.init()
  5208. return client
  5209. }
  5210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5211. // it returns an error otherwise.
  5212. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5213. if _, ok := m.driver.(*txDriver); !ok {
  5214. return nil, errors.New("ent: mutation is not running in a transaction")
  5215. }
  5216. tx := &Tx{config: m.config}
  5217. tx.init()
  5218. return tx, nil
  5219. }
  5220. // SetID sets the value of the id field. Note that this
  5221. // operation is only accepted on creation of BatchMsg entities.
  5222. func (m *BatchMsgMutation) SetID(id uint64) {
  5223. m.id = &id
  5224. }
  5225. // ID returns the ID value in the mutation. Note that the ID is only available
  5226. // if it was provided to the builder or after it was returned from the database.
  5227. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5228. if m.id == nil {
  5229. return
  5230. }
  5231. return *m.id, true
  5232. }
  5233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5234. // That means, if the mutation is applied within a transaction with an isolation level such
  5235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5236. // or updated by the mutation.
  5237. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5238. switch {
  5239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5240. id, exists := m.ID()
  5241. if exists {
  5242. return []uint64{id}, nil
  5243. }
  5244. fallthrough
  5245. case m.op.Is(OpUpdate | OpDelete):
  5246. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5247. default:
  5248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5249. }
  5250. }
  5251. // SetCreatedAt sets the "created_at" field.
  5252. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5253. m.created_at = &t
  5254. }
  5255. // CreatedAt returns the value of the "created_at" field in the mutation.
  5256. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5257. v := m.created_at
  5258. if v == nil {
  5259. return
  5260. }
  5261. return *v, true
  5262. }
  5263. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5264. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5266. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5267. if !m.op.Is(OpUpdateOne) {
  5268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5269. }
  5270. if m.id == nil || m.oldValue == nil {
  5271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5272. }
  5273. oldValue, err := m.oldValue(ctx)
  5274. if err != nil {
  5275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5276. }
  5277. return oldValue.CreatedAt, nil
  5278. }
  5279. // ResetCreatedAt resets all changes to the "created_at" field.
  5280. func (m *BatchMsgMutation) ResetCreatedAt() {
  5281. m.created_at = nil
  5282. }
  5283. // SetUpdatedAt sets the "updated_at" field.
  5284. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5285. m.updated_at = &t
  5286. }
  5287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5288. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5289. v := m.updated_at
  5290. if v == nil {
  5291. return
  5292. }
  5293. return *v, true
  5294. }
  5295. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5298. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5299. if !m.op.Is(OpUpdateOne) {
  5300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5301. }
  5302. if m.id == nil || m.oldValue == nil {
  5303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5304. }
  5305. oldValue, err := m.oldValue(ctx)
  5306. if err != nil {
  5307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5308. }
  5309. return oldValue.UpdatedAt, nil
  5310. }
  5311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5312. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5313. m.updated_at = nil
  5314. }
  5315. // SetDeletedAt sets the "deleted_at" field.
  5316. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5317. m.deleted_at = &t
  5318. }
  5319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5320. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5321. v := m.deleted_at
  5322. if v == nil {
  5323. return
  5324. }
  5325. return *v, true
  5326. }
  5327. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5330. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5331. if !m.op.Is(OpUpdateOne) {
  5332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5333. }
  5334. if m.id == nil || m.oldValue == nil {
  5335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5336. }
  5337. oldValue, err := m.oldValue(ctx)
  5338. if err != nil {
  5339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5340. }
  5341. return oldValue.DeletedAt, nil
  5342. }
  5343. // ClearDeletedAt clears the value of the "deleted_at" field.
  5344. func (m *BatchMsgMutation) ClearDeletedAt() {
  5345. m.deleted_at = nil
  5346. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5347. }
  5348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5349. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5350. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5351. return ok
  5352. }
  5353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5354. func (m *BatchMsgMutation) ResetDeletedAt() {
  5355. m.deleted_at = nil
  5356. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5357. }
  5358. // SetStatus sets the "status" field.
  5359. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5360. m.status = &u
  5361. m.addstatus = nil
  5362. }
  5363. // Status returns the value of the "status" field in the mutation.
  5364. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5365. v := m.status
  5366. if v == nil {
  5367. return
  5368. }
  5369. return *v, true
  5370. }
  5371. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5374. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5375. if !m.op.Is(OpUpdateOne) {
  5376. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5377. }
  5378. if m.id == nil || m.oldValue == nil {
  5379. return v, errors.New("OldStatus requires an ID field in the mutation")
  5380. }
  5381. oldValue, err := m.oldValue(ctx)
  5382. if err != nil {
  5383. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5384. }
  5385. return oldValue.Status, nil
  5386. }
  5387. // AddStatus adds u to the "status" field.
  5388. func (m *BatchMsgMutation) AddStatus(u int8) {
  5389. if m.addstatus != nil {
  5390. *m.addstatus += u
  5391. } else {
  5392. m.addstatus = &u
  5393. }
  5394. }
  5395. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5396. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5397. v := m.addstatus
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // ClearStatus clears the value of the "status" field.
  5404. func (m *BatchMsgMutation) ClearStatus() {
  5405. m.status = nil
  5406. m.addstatus = nil
  5407. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5408. }
  5409. // StatusCleared returns if the "status" field was cleared in this mutation.
  5410. func (m *BatchMsgMutation) StatusCleared() bool {
  5411. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5412. return ok
  5413. }
  5414. // ResetStatus resets all changes to the "status" field.
  5415. func (m *BatchMsgMutation) ResetStatus() {
  5416. m.status = nil
  5417. m.addstatus = nil
  5418. delete(m.clearedFields, batchmsg.FieldStatus)
  5419. }
  5420. // SetBatchNo sets the "batch_no" field.
  5421. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5422. m.batch_no = &s
  5423. }
  5424. // BatchNo returns the value of the "batch_no" field in the mutation.
  5425. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5426. v := m.batch_no
  5427. if v == nil {
  5428. return
  5429. }
  5430. return *v, true
  5431. }
  5432. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5433. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5435. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5436. if !m.op.Is(OpUpdateOne) {
  5437. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5438. }
  5439. if m.id == nil || m.oldValue == nil {
  5440. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5441. }
  5442. oldValue, err := m.oldValue(ctx)
  5443. if err != nil {
  5444. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5445. }
  5446. return oldValue.BatchNo, nil
  5447. }
  5448. // ClearBatchNo clears the value of the "batch_no" field.
  5449. func (m *BatchMsgMutation) ClearBatchNo() {
  5450. m.batch_no = nil
  5451. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5452. }
  5453. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5454. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5455. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5456. return ok
  5457. }
  5458. // ResetBatchNo resets all changes to the "batch_no" field.
  5459. func (m *BatchMsgMutation) ResetBatchNo() {
  5460. m.batch_no = nil
  5461. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5462. }
  5463. // SetTaskName sets the "task_name" field.
  5464. func (m *BatchMsgMutation) SetTaskName(s string) {
  5465. m.task_name = &s
  5466. }
  5467. // TaskName returns the value of the "task_name" field in the mutation.
  5468. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5469. v := m.task_name
  5470. if v == nil {
  5471. return
  5472. }
  5473. return *v, true
  5474. }
  5475. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5476. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5478. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5479. if !m.op.Is(OpUpdateOne) {
  5480. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5481. }
  5482. if m.id == nil || m.oldValue == nil {
  5483. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5484. }
  5485. oldValue, err := m.oldValue(ctx)
  5486. if err != nil {
  5487. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5488. }
  5489. return oldValue.TaskName, nil
  5490. }
  5491. // ClearTaskName clears the value of the "task_name" field.
  5492. func (m *BatchMsgMutation) ClearTaskName() {
  5493. m.task_name = nil
  5494. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5495. }
  5496. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5497. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5498. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5499. return ok
  5500. }
  5501. // ResetTaskName resets all changes to the "task_name" field.
  5502. func (m *BatchMsgMutation) ResetTaskName() {
  5503. m.task_name = nil
  5504. delete(m.clearedFields, batchmsg.FieldTaskName)
  5505. }
  5506. // SetFromwxid sets the "fromwxid" field.
  5507. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5508. m.fromwxid = &s
  5509. }
  5510. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5511. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5512. v := m.fromwxid
  5513. if v == nil {
  5514. return
  5515. }
  5516. return *v, true
  5517. }
  5518. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5519. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5521. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5522. if !m.op.Is(OpUpdateOne) {
  5523. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5524. }
  5525. if m.id == nil || m.oldValue == nil {
  5526. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5527. }
  5528. oldValue, err := m.oldValue(ctx)
  5529. if err != nil {
  5530. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5531. }
  5532. return oldValue.Fromwxid, nil
  5533. }
  5534. // ClearFromwxid clears the value of the "fromwxid" field.
  5535. func (m *BatchMsgMutation) ClearFromwxid() {
  5536. m.fromwxid = nil
  5537. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5538. }
  5539. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5540. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5541. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5542. return ok
  5543. }
  5544. // ResetFromwxid resets all changes to the "fromwxid" field.
  5545. func (m *BatchMsgMutation) ResetFromwxid() {
  5546. m.fromwxid = nil
  5547. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5548. }
  5549. // SetMsg sets the "msg" field.
  5550. func (m *BatchMsgMutation) SetMsg(s string) {
  5551. m.msg = &s
  5552. }
  5553. // Msg returns the value of the "msg" field in the mutation.
  5554. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5555. v := m.msg
  5556. if v == nil {
  5557. return
  5558. }
  5559. return *v, true
  5560. }
  5561. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5564. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5565. if !m.op.Is(OpUpdateOne) {
  5566. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5567. }
  5568. if m.id == nil || m.oldValue == nil {
  5569. return v, errors.New("OldMsg requires an ID field in the mutation")
  5570. }
  5571. oldValue, err := m.oldValue(ctx)
  5572. if err != nil {
  5573. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5574. }
  5575. return oldValue.Msg, nil
  5576. }
  5577. // ClearMsg clears the value of the "msg" field.
  5578. func (m *BatchMsgMutation) ClearMsg() {
  5579. m.msg = nil
  5580. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5581. }
  5582. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5583. func (m *BatchMsgMutation) MsgCleared() bool {
  5584. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5585. return ok
  5586. }
  5587. // ResetMsg resets all changes to the "msg" field.
  5588. func (m *BatchMsgMutation) ResetMsg() {
  5589. m.msg = nil
  5590. delete(m.clearedFields, batchmsg.FieldMsg)
  5591. }
  5592. // SetTag sets the "tag" field.
  5593. func (m *BatchMsgMutation) SetTag(s string) {
  5594. m.tag = &s
  5595. }
  5596. // Tag returns the value of the "tag" field in the mutation.
  5597. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5598. v := m.tag
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5605. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5607. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5608. if !m.op.Is(OpUpdateOne) {
  5609. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5610. }
  5611. if m.id == nil || m.oldValue == nil {
  5612. return v, errors.New("OldTag requires an ID field in the mutation")
  5613. }
  5614. oldValue, err := m.oldValue(ctx)
  5615. if err != nil {
  5616. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5617. }
  5618. return oldValue.Tag, nil
  5619. }
  5620. // ClearTag clears the value of the "tag" field.
  5621. func (m *BatchMsgMutation) ClearTag() {
  5622. m.tag = nil
  5623. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5624. }
  5625. // TagCleared returns if the "tag" field was cleared in this mutation.
  5626. func (m *BatchMsgMutation) TagCleared() bool {
  5627. _, ok := m.clearedFields[batchmsg.FieldTag]
  5628. return ok
  5629. }
  5630. // ResetTag resets all changes to the "tag" field.
  5631. func (m *BatchMsgMutation) ResetTag() {
  5632. m.tag = nil
  5633. delete(m.clearedFields, batchmsg.FieldTag)
  5634. }
  5635. // SetTagids sets the "tagids" field.
  5636. func (m *BatchMsgMutation) SetTagids(s string) {
  5637. m.tagids = &s
  5638. }
  5639. // Tagids returns the value of the "tagids" field in the mutation.
  5640. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5641. v := m.tagids
  5642. if v == nil {
  5643. return
  5644. }
  5645. return *v, true
  5646. }
  5647. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5650. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5651. if !m.op.Is(OpUpdateOne) {
  5652. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5653. }
  5654. if m.id == nil || m.oldValue == nil {
  5655. return v, errors.New("OldTagids requires an ID field in the mutation")
  5656. }
  5657. oldValue, err := m.oldValue(ctx)
  5658. if err != nil {
  5659. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5660. }
  5661. return oldValue.Tagids, nil
  5662. }
  5663. // ClearTagids clears the value of the "tagids" field.
  5664. func (m *BatchMsgMutation) ClearTagids() {
  5665. m.tagids = nil
  5666. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5667. }
  5668. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5669. func (m *BatchMsgMutation) TagidsCleared() bool {
  5670. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5671. return ok
  5672. }
  5673. // ResetTagids resets all changes to the "tagids" field.
  5674. func (m *BatchMsgMutation) ResetTagids() {
  5675. m.tagids = nil
  5676. delete(m.clearedFields, batchmsg.FieldTagids)
  5677. }
  5678. // SetTotal sets the "total" field.
  5679. func (m *BatchMsgMutation) SetTotal(i int32) {
  5680. m.total = &i
  5681. m.addtotal = nil
  5682. }
  5683. // Total returns the value of the "total" field in the mutation.
  5684. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5685. v := m.total
  5686. if v == nil {
  5687. return
  5688. }
  5689. return *v, true
  5690. }
  5691. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5692. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5694. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5695. if !m.op.Is(OpUpdateOne) {
  5696. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5697. }
  5698. if m.id == nil || m.oldValue == nil {
  5699. return v, errors.New("OldTotal requires an ID field in the mutation")
  5700. }
  5701. oldValue, err := m.oldValue(ctx)
  5702. if err != nil {
  5703. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5704. }
  5705. return oldValue.Total, nil
  5706. }
  5707. // AddTotal adds i to the "total" field.
  5708. func (m *BatchMsgMutation) AddTotal(i int32) {
  5709. if m.addtotal != nil {
  5710. *m.addtotal += i
  5711. } else {
  5712. m.addtotal = &i
  5713. }
  5714. }
  5715. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5716. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5717. v := m.addtotal
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // ClearTotal clears the value of the "total" field.
  5724. func (m *BatchMsgMutation) ClearTotal() {
  5725. m.total = nil
  5726. m.addtotal = nil
  5727. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5728. }
  5729. // TotalCleared returns if the "total" field was cleared in this mutation.
  5730. func (m *BatchMsgMutation) TotalCleared() bool {
  5731. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5732. return ok
  5733. }
  5734. // ResetTotal resets all changes to the "total" field.
  5735. func (m *BatchMsgMutation) ResetTotal() {
  5736. m.total = nil
  5737. m.addtotal = nil
  5738. delete(m.clearedFields, batchmsg.FieldTotal)
  5739. }
  5740. // SetSuccess sets the "success" field.
  5741. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5742. m.success = &i
  5743. m.addsuccess = nil
  5744. }
  5745. // Success returns the value of the "success" field in the mutation.
  5746. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5747. v := m.success
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5766. }
  5767. return oldValue.Success, nil
  5768. }
  5769. // AddSuccess adds i to the "success" field.
  5770. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5771. if m.addsuccess != nil {
  5772. *m.addsuccess += i
  5773. } else {
  5774. m.addsuccess = &i
  5775. }
  5776. }
  5777. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5778. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5779. v := m.addsuccess
  5780. if v == nil {
  5781. return
  5782. }
  5783. return *v, true
  5784. }
  5785. // ClearSuccess clears the value of the "success" field.
  5786. func (m *BatchMsgMutation) ClearSuccess() {
  5787. m.success = nil
  5788. m.addsuccess = nil
  5789. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5790. }
  5791. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5792. func (m *BatchMsgMutation) SuccessCleared() bool {
  5793. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5794. return ok
  5795. }
  5796. // ResetSuccess resets all changes to the "success" field.
  5797. func (m *BatchMsgMutation) ResetSuccess() {
  5798. m.success = nil
  5799. m.addsuccess = nil
  5800. delete(m.clearedFields, batchmsg.FieldSuccess)
  5801. }
  5802. // SetFail sets the "fail" field.
  5803. func (m *BatchMsgMutation) SetFail(i int32) {
  5804. m.fail = &i
  5805. m.addfail = nil
  5806. }
  5807. // Fail returns the value of the "fail" field in the mutation.
  5808. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5809. v := m.fail
  5810. if v == nil {
  5811. return
  5812. }
  5813. return *v, true
  5814. }
  5815. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5816. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5818. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5819. if !m.op.Is(OpUpdateOne) {
  5820. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5821. }
  5822. if m.id == nil || m.oldValue == nil {
  5823. return v, errors.New("OldFail requires an ID field in the mutation")
  5824. }
  5825. oldValue, err := m.oldValue(ctx)
  5826. if err != nil {
  5827. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5828. }
  5829. return oldValue.Fail, nil
  5830. }
  5831. // AddFail adds i to the "fail" field.
  5832. func (m *BatchMsgMutation) AddFail(i int32) {
  5833. if m.addfail != nil {
  5834. *m.addfail += i
  5835. } else {
  5836. m.addfail = &i
  5837. }
  5838. }
  5839. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5840. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5841. v := m.addfail
  5842. if v == nil {
  5843. return
  5844. }
  5845. return *v, true
  5846. }
  5847. // ClearFail clears the value of the "fail" field.
  5848. func (m *BatchMsgMutation) ClearFail() {
  5849. m.fail = nil
  5850. m.addfail = nil
  5851. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5852. }
  5853. // FailCleared returns if the "fail" field was cleared in this mutation.
  5854. func (m *BatchMsgMutation) FailCleared() bool {
  5855. _, ok := m.clearedFields[batchmsg.FieldFail]
  5856. return ok
  5857. }
  5858. // ResetFail resets all changes to the "fail" field.
  5859. func (m *BatchMsgMutation) ResetFail() {
  5860. m.fail = nil
  5861. m.addfail = nil
  5862. delete(m.clearedFields, batchmsg.FieldFail)
  5863. }
  5864. // SetStartTime sets the "start_time" field.
  5865. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5866. m.start_time = &t
  5867. }
  5868. // StartTime returns the value of the "start_time" field in the mutation.
  5869. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5870. v := m.start_time
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5877. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5889. }
  5890. return oldValue.StartTime, nil
  5891. }
  5892. // ClearStartTime clears the value of the "start_time" field.
  5893. func (m *BatchMsgMutation) ClearStartTime() {
  5894. m.start_time = nil
  5895. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5896. }
  5897. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5898. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5899. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5900. return ok
  5901. }
  5902. // ResetStartTime resets all changes to the "start_time" field.
  5903. func (m *BatchMsgMutation) ResetStartTime() {
  5904. m.start_time = nil
  5905. delete(m.clearedFields, batchmsg.FieldStartTime)
  5906. }
  5907. // SetStopTime sets the "stop_time" field.
  5908. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5909. m.stop_time = &t
  5910. }
  5911. // StopTime returns the value of the "stop_time" field in the mutation.
  5912. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5913. v := m.stop_time
  5914. if v == nil {
  5915. return
  5916. }
  5917. return *v, true
  5918. }
  5919. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5920. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5922. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5923. if !m.op.Is(OpUpdateOne) {
  5924. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5925. }
  5926. if m.id == nil || m.oldValue == nil {
  5927. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5928. }
  5929. oldValue, err := m.oldValue(ctx)
  5930. if err != nil {
  5931. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5932. }
  5933. return oldValue.StopTime, nil
  5934. }
  5935. // ClearStopTime clears the value of the "stop_time" field.
  5936. func (m *BatchMsgMutation) ClearStopTime() {
  5937. m.stop_time = nil
  5938. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5939. }
  5940. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5941. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5942. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5943. return ok
  5944. }
  5945. // ResetStopTime resets all changes to the "stop_time" field.
  5946. func (m *BatchMsgMutation) ResetStopTime() {
  5947. m.stop_time = nil
  5948. delete(m.clearedFields, batchmsg.FieldStopTime)
  5949. }
  5950. // SetSendTime sets the "send_time" field.
  5951. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5952. m.send_time = &t
  5953. }
  5954. // SendTime returns the value of the "send_time" field in the mutation.
  5955. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5956. v := m.send_time
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5963. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5965. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5966. if !m.op.Is(OpUpdateOne) {
  5967. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5968. }
  5969. if m.id == nil || m.oldValue == nil {
  5970. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5971. }
  5972. oldValue, err := m.oldValue(ctx)
  5973. if err != nil {
  5974. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5975. }
  5976. return oldValue.SendTime, nil
  5977. }
  5978. // ClearSendTime clears the value of the "send_time" field.
  5979. func (m *BatchMsgMutation) ClearSendTime() {
  5980. m.send_time = nil
  5981. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5982. }
  5983. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5984. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5985. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5986. return ok
  5987. }
  5988. // ResetSendTime resets all changes to the "send_time" field.
  5989. func (m *BatchMsgMutation) ResetSendTime() {
  5990. m.send_time = nil
  5991. delete(m.clearedFields, batchmsg.FieldSendTime)
  5992. }
  5993. // SetType sets the "type" field.
  5994. func (m *BatchMsgMutation) SetType(i int32) {
  5995. m._type = &i
  5996. m.add_type = nil
  5997. }
  5998. // GetType returns the value of the "type" field in the mutation.
  5999. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6000. v := m._type
  6001. if v == nil {
  6002. return
  6003. }
  6004. return *v, true
  6005. }
  6006. // OldType returns the old "type" field's value of the BatchMsg entity.
  6007. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6009. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6010. if !m.op.Is(OpUpdateOne) {
  6011. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6012. }
  6013. if m.id == nil || m.oldValue == nil {
  6014. return v, errors.New("OldType requires an ID field in the mutation")
  6015. }
  6016. oldValue, err := m.oldValue(ctx)
  6017. if err != nil {
  6018. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6019. }
  6020. return oldValue.Type, nil
  6021. }
  6022. // AddType adds i to the "type" field.
  6023. func (m *BatchMsgMutation) AddType(i int32) {
  6024. if m.add_type != nil {
  6025. *m.add_type += i
  6026. } else {
  6027. m.add_type = &i
  6028. }
  6029. }
  6030. // AddedType returns the value that was added to the "type" field in this mutation.
  6031. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6032. v := m.add_type
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // ClearType clears the value of the "type" field.
  6039. func (m *BatchMsgMutation) ClearType() {
  6040. m._type = nil
  6041. m.add_type = nil
  6042. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6043. }
  6044. // TypeCleared returns if the "type" field was cleared in this mutation.
  6045. func (m *BatchMsgMutation) TypeCleared() bool {
  6046. _, ok := m.clearedFields[batchmsg.FieldType]
  6047. return ok
  6048. }
  6049. // ResetType resets all changes to the "type" field.
  6050. func (m *BatchMsgMutation) ResetType() {
  6051. m._type = nil
  6052. m.add_type = nil
  6053. delete(m.clearedFields, batchmsg.FieldType)
  6054. }
  6055. // SetOrganizationID sets the "organization_id" field.
  6056. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6057. m.organization_id = &u
  6058. m.addorganization_id = nil
  6059. }
  6060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6061. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6062. v := m.organization_id
  6063. if v == nil {
  6064. return
  6065. }
  6066. return *v, true
  6067. }
  6068. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6069. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6071. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6072. if !m.op.Is(OpUpdateOne) {
  6073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6074. }
  6075. if m.id == nil || m.oldValue == nil {
  6076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6077. }
  6078. oldValue, err := m.oldValue(ctx)
  6079. if err != nil {
  6080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6081. }
  6082. return oldValue.OrganizationID, nil
  6083. }
  6084. // AddOrganizationID adds u to the "organization_id" field.
  6085. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6086. if m.addorganization_id != nil {
  6087. *m.addorganization_id += u
  6088. } else {
  6089. m.addorganization_id = &u
  6090. }
  6091. }
  6092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6093. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6094. v := m.addorganization_id
  6095. if v == nil {
  6096. return
  6097. }
  6098. return *v, true
  6099. }
  6100. // ResetOrganizationID resets all changes to the "organization_id" field.
  6101. func (m *BatchMsgMutation) ResetOrganizationID() {
  6102. m.organization_id = nil
  6103. m.addorganization_id = nil
  6104. }
  6105. // SetCtype sets the "ctype" field.
  6106. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6107. m.ctype = &u
  6108. m.addctype = nil
  6109. }
  6110. // Ctype returns the value of the "ctype" field in the mutation.
  6111. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6112. v := m.ctype
  6113. if v == nil {
  6114. return
  6115. }
  6116. return *v, true
  6117. }
  6118. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6119. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6121. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6122. if !m.op.Is(OpUpdateOne) {
  6123. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6124. }
  6125. if m.id == nil || m.oldValue == nil {
  6126. return v, errors.New("OldCtype requires an ID field in the mutation")
  6127. }
  6128. oldValue, err := m.oldValue(ctx)
  6129. if err != nil {
  6130. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6131. }
  6132. return oldValue.Ctype, nil
  6133. }
  6134. // AddCtype adds u to the "ctype" field.
  6135. func (m *BatchMsgMutation) AddCtype(u int64) {
  6136. if m.addctype != nil {
  6137. *m.addctype += u
  6138. } else {
  6139. m.addctype = &u
  6140. }
  6141. }
  6142. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6143. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6144. v := m.addctype
  6145. if v == nil {
  6146. return
  6147. }
  6148. return *v, true
  6149. }
  6150. // ResetCtype resets all changes to the "ctype" field.
  6151. func (m *BatchMsgMutation) ResetCtype() {
  6152. m.ctype = nil
  6153. m.addctype = nil
  6154. }
  6155. // SetCc sets the "cc" field.
  6156. func (m *BatchMsgMutation) SetCc(s string) {
  6157. m.cc = &s
  6158. }
  6159. // Cc returns the value of the "cc" field in the mutation.
  6160. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6161. v := m.cc
  6162. if v == nil {
  6163. return
  6164. }
  6165. return *v, true
  6166. }
  6167. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6170. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6171. if !m.op.Is(OpUpdateOne) {
  6172. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6173. }
  6174. if m.id == nil || m.oldValue == nil {
  6175. return v, errors.New("OldCc requires an ID field in the mutation")
  6176. }
  6177. oldValue, err := m.oldValue(ctx)
  6178. if err != nil {
  6179. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6180. }
  6181. return oldValue.Cc, nil
  6182. }
  6183. // ClearCc clears the value of the "cc" field.
  6184. func (m *BatchMsgMutation) ClearCc() {
  6185. m.cc = nil
  6186. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6187. }
  6188. // CcCleared returns if the "cc" field was cleared in this mutation.
  6189. func (m *BatchMsgMutation) CcCleared() bool {
  6190. _, ok := m.clearedFields[batchmsg.FieldCc]
  6191. return ok
  6192. }
  6193. // ResetCc resets all changes to the "cc" field.
  6194. func (m *BatchMsgMutation) ResetCc() {
  6195. m.cc = nil
  6196. delete(m.clearedFields, batchmsg.FieldCc)
  6197. }
  6198. // SetPhone sets the "phone" field.
  6199. func (m *BatchMsgMutation) SetPhone(s string) {
  6200. m.phone = &s
  6201. }
  6202. // Phone returns the value of the "phone" field in the mutation.
  6203. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6204. v := m.phone
  6205. if v == nil {
  6206. return
  6207. }
  6208. return *v, true
  6209. }
  6210. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6211. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6213. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6214. if !m.op.Is(OpUpdateOne) {
  6215. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6216. }
  6217. if m.id == nil || m.oldValue == nil {
  6218. return v, errors.New("OldPhone requires an ID field in the mutation")
  6219. }
  6220. oldValue, err := m.oldValue(ctx)
  6221. if err != nil {
  6222. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6223. }
  6224. return oldValue.Phone, nil
  6225. }
  6226. // ClearPhone clears the value of the "phone" field.
  6227. func (m *BatchMsgMutation) ClearPhone() {
  6228. m.phone = nil
  6229. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6230. }
  6231. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6232. func (m *BatchMsgMutation) PhoneCleared() bool {
  6233. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6234. return ok
  6235. }
  6236. // ResetPhone resets all changes to the "phone" field.
  6237. func (m *BatchMsgMutation) ResetPhone() {
  6238. m.phone = nil
  6239. delete(m.clearedFields, batchmsg.FieldPhone)
  6240. }
  6241. // SetTemplateName sets the "template_name" field.
  6242. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6243. m.template_name = &s
  6244. }
  6245. // TemplateName returns the value of the "template_name" field in the mutation.
  6246. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6247. v := m.template_name
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6254. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6266. }
  6267. return oldValue.TemplateName, nil
  6268. }
  6269. // ClearTemplateName clears the value of the "template_name" field.
  6270. func (m *BatchMsgMutation) ClearTemplateName() {
  6271. m.template_name = nil
  6272. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6273. }
  6274. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6275. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6276. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6277. return ok
  6278. }
  6279. // ResetTemplateName resets all changes to the "template_name" field.
  6280. func (m *BatchMsgMutation) ResetTemplateName() {
  6281. m.template_name = nil
  6282. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6283. }
  6284. // SetTemplateCode sets the "template_code" field.
  6285. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6286. m.template_code = &s
  6287. }
  6288. // TemplateCode returns the value of the "template_code" field in the mutation.
  6289. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6290. v := m.template_code
  6291. if v == nil {
  6292. return
  6293. }
  6294. return *v, true
  6295. }
  6296. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6297. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6299. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6300. if !m.op.Is(OpUpdateOne) {
  6301. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6302. }
  6303. if m.id == nil || m.oldValue == nil {
  6304. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6305. }
  6306. oldValue, err := m.oldValue(ctx)
  6307. if err != nil {
  6308. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6309. }
  6310. return oldValue.TemplateCode, nil
  6311. }
  6312. // ClearTemplateCode clears the value of the "template_code" field.
  6313. func (m *BatchMsgMutation) ClearTemplateCode() {
  6314. m.template_code = nil
  6315. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6316. }
  6317. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6318. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6319. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6320. return ok
  6321. }
  6322. // ResetTemplateCode resets all changes to the "template_code" field.
  6323. func (m *BatchMsgMutation) ResetTemplateCode() {
  6324. m.template_code = nil
  6325. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6326. }
  6327. // SetLang sets the "lang" field.
  6328. func (m *BatchMsgMutation) SetLang(s string) {
  6329. m.lang = &s
  6330. }
  6331. // Lang returns the value of the "lang" field in the mutation.
  6332. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6333. v := m.lang
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6340. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6342. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6343. if !m.op.Is(OpUpdateOne) {
  6344. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6345. }
  6346. if m.id == nil || m.oldValue == nil {
  6347. return v, errors.New("OldLang requires an ID field in the mutation")
  6348. }
  6349. oldValue, err := m.oldValue(ctx)
  6350. if err != nil {
  6351. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6352. }
  6353. return oldValue.Lang, nil
  6354. }
  6355. // ClearLang clears the value of the "lang" field.
  6356. func (m *BatchMsgMutation) ClearLang() {
  6357. m.lang = nil
  6358. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6359. }
  6360. // LangCleared returns if the "lang" field was cleared in this mutation.
  6361. func (m *BatchMsgMutation) LangCleared() bool {
  6362. _, ok := m.clearedFields[batchmsg.FieldLang]
  6363. return ok
  6364. }
  6365. // ResetLang resets all changes to the "lang" field.
  6366. func (m *BatchMsgMutation) ResetLang() {
  6367. m.lang = nil
  6368. delete(m.clearedFields, batchmsg.FieldLang)
  6369. }
  6370. // Where appends a list predicates to the BatchMsgMutation builder.
  6371. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6372. m.predicates = append(m.predicates, ps...)
  6373. }
  6374. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6375. // users can use type-assertion to append predicates that do not depend on any generated package.
  6376. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6377. p := make([]predicate.BatchMsg, len(ps))
  6378. for i := range ps {
  6379. p[i] = ps[i]
  6380. }
  6381. m.Where(p...)
  6382. }
  6383. // Op returns the operation name.
  6384. func (m *BatchMsgMutation) Op() Op {
  6385. return m.op
  6386. }
  6387. // SetOp allows setting the mutation operation.
  6388. func (m *BatchMsgMutation) SetOp(op Op) {
  6389. m.op = op
  6390. }
  6391. // Type returns the node type of this mutation (BatchMsg).
  6392. func (m *BatchMsgMutation) Type() string {
  6393. return m.typ
  6394. }
  6395. // Fields returns all fields that were changed during this mutation. Note that in
  6396. // order to get all numeric fields that were incremented/decremented, call
  6397. // AddedFields().
  6398. func (m *BatchMsgMutation) Fields() []string {
  6399. fields := make([]string, 0, 24)
  6400. if m.created_at != nil {
  6401. fields = append(fields, batchmsg.FieldCreatedAt)
  6402. }
  6403. if m.updated_at != nil {
  6404. fields = append(fields, batchmsg.FieldUpdatedAt)
  6405. }
  6406. if m.deleted_at != nil {
  6407. fields = append(fields, batchmsg.FieldDeletedAt)
  6408. }
  6409. if m.status != nil {
  6410. fields = append(fields, batchmsg.FieldStatus)
  6411. }
  6412. if m.batch_no != nil {
  6413. fields = append(fields, batchmsg.FieldBatchNo)
  6414. }
  6415. if m.task_name != nil {
  6416. fields = append(fields, batchmsg.FieldTaskName)
  6417. }
  6418. if m.fromwxid != nil {
  6419. fields = append(fields, batchmsg.FieldFromwxid)
  6420. }
  6421. if m.msg != nil {
  6422. fields = append(fields, batchmsg.FieldMsg)
  6423. }
  6424. if m.tag != nil {
  6425. fields = append(fields, batchmsg.FieldTag)
  6426. }
  6427. if m.tagids != nil {
  6428. fields = append(fields, batchmsg.FieldTagids)
  6429. }
  6430. if m.total != nil {
  6431. fields = append(fields, batchmsg.FieldTotal)
  6432. }
  6433. if m.success != nil {
  6434. fields = append(fields, batchmsg.FieldSuccess)
  6435. }
  6436. if m.fail != nil {
  6437. fields = append(fields, batchmsg.FieldFail)
  6438. }
  6439. if m.start_time != nil {
  6440. fields = append(fields, batchmsg.FieldStartTime)
  6441. }
  6442. if m.stop_time != nil {
  6443. fields = append(fields, batchmsg.FieldStopTime)
  6444. }
  6445. if m.send_time != nil {
  6446. fields = append(fields, batchmsg.FieldSendTime)
  6447. }
  6448. if m._type != nil {
  6449. fields = append(fields, batchmsg.FieldType)
  6450. }
  6451. if m.organization_id != nil {
  6452. fields = append(fields, batchmsg.FieldOrganizationID)
  6453. }
  6454. if m.ctype != nil {
  6455. fields = append(fields, batchmsg.FieldCtype)
  6456. }
  6457. if m.cc != nil {
  6458. fields = append(fields, batchmsg.FieldCc)
  6459. }
  6460. if m.phone != nil {
  6461. fields = append(fields, batchmsg.FieldPhone)
  6462. }
  6463. if m.template_name != nil {
  6464. fields = append(fields, batchmsg.FieldTemplateName)
  6465. }
  6466. if m.template_code != nil {
  6467. fields = append(fields, batchmsg.FieldTemplateCode)
  6468. }
  6469. if m.lang != nil {
  6470. fields = append(fields, batchmsg.FieldLang)
  6471. }
  6472. return fields
  6473. }
  6474. // Field returns the value of a field with the given name. The second boolean
  6475. // return value indicates that this field was not set, or was not defined in the
  6476. // schema.
  6477. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6478. switch name {
  6479. case batchmsg.FieldCreatedAt:
  6480. return m.CreatedAt()
  6481. case batchmsg.FieldUpdatedAt:
  6482. return m.UpdatedAt()
  6483. case batchmsg.FieldDeletedAt:
  6484. return m.DeletedAt()
  6485. case batchmsg.FieldStatus:
  6486. return m.Status()
  6487. case batchmsg.FieldBatchNo:
  6488. return m.BatchNo()
  6489. case batchmsg.FieldTaskName:
  6490. return m.TaskName()
  6491. case batchmsg.FieldFromwxid:
  6492. return m.Fromwxid()
  6493. case batchmsg.FieldMsg:
  6494. return m.Msg()
  6495. case batchmsg.FieldTag:
  6496. return m.Tag()
  6497. case batchmsg.FieldTagids:
  6498. return m.Tagids()
  6499. case batchmsg.FieldTotal:
  6500. return m.Total()
  6501. case batchmsg.FieldSuccess:
  6502. return m.Success()
  6503. case batchmsg.FieldFail:
  6504. return m.Fail()
  6505. case batchmsg.FieldStartTime:
  6506. return m.StartTime()
  6507. case batchmsg.FieldStopTime:
  6508. return m.StopTime()
  6509. case batchmsg.FieldSendTime:
  6510. return m.SendTime()
  6511. case batchmsg.FieldType:
  6512. return m.GetType()
  6513. case batchmsg.FieldOrganizationID:
  6514. return m.OrganizationID()
  6515. case batchmsg.FieldCtype:
  6516. return m.Ctype()
  6517. case batchmsg.FieldCc:
  6518. return m.Cc()
  6519. case batchmsg.FieldPhone:
  6520. return m.Phone()
  6521. case batchmsg.FieldTemplateName:
  6522. return m.TemplateName()
  6523. case batchmsg.FieldTemplateCode:
  6524. return m.TemplateCode()
  6525. case batchmsg.FieldLang:
  6526. return m.Lang()
  6527. }
  6528. return nil, false
  6529. }
  6530. // OldField returns the old value of the field from the database. An error is
  6531. // returned if the mutation operation is not UpdateOne, or the query to the
  6532. // database failed.
  6533. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6534. switch name {
  6535. case batchmsg.FieldCreatedAt:
  6536. return m.OldCreatedAt(ctx)
  6537. case batchmsg.FieldUpdatedAt:
  6538. return m.OldUpdatedAt(ctx)
  6539. case batchmsg.FieldDeletedAt:
  6540. return m.OldDeletedAt(ctx)
  6541. case batchmsg.FieldStatus:
  6542. return m.OldStatus(ctx)
  6543. case batchmsg.FieldBatchNo:
  6544. return m.OldBatchNo(ctx)
  6545. case batchmsg.FieldTaskName:
  6546. return m.OldTaskName(ctx)
  6547. case batchmsg.FieldFromwxid:
  6548. return m.OldFromwxid(ctx)
  6549. case batchmsg.FieldMsg:
  6550. return m.OldMsg(ctx)
  6551. case batchmsg.FieldTag:
  6552. return m.OldTag(ctx)
  6553. case batchmsg.FieldTagids:
  6554. return m.OldTagids(ctx)
  6555. case batchmsg.FieldTotal:
  6556. return m.OldTotal(ctx)
  6557. case batchmsg.FieldSuccess:
  6558. return m.OldSuccess(ctx)
  6559. case batchmsg.FieldFail:
  6560. return m.OldFail(ctx)
  6561. case batchmsg.FieldStartTime:
  6562. return m.OldStartTime(ctx)
  6563. case batchmsg.FieldStopTime:
  6564. return m.OldStopTime(ctx)
  6565. case batchmsg.FieldSendTime:
  6566. return m.OldSendTime(ctx)
  6567. case batchmsg.FieldType:
  6568. return m.OldType(ctx)
  6569. case batchmsg.FieldOrganizationID:
  6570. return m.OldOrganizationID(ctx)
  6571. case batchmsg.FieldCtype:
  6572. return m.OldCtype(ctx)
  6573. case batchmsg.FieldCc:
  6574. return m.OldCc(ctx)
  6575. case batchmsg.FieldPhone:
  6576. return m.OldPhone(ctx)
  6577. case batchmsg.FieldTemplateName:
  6578. return m.OldTemplateName(ctx)
  6579. case batchmsg.FieldTemplateCode:
  6580. return m.OldTemplateCode(ctx)
  6581. case batchmsg.FieldLang:
  6582. return m.OldLang(ctx)
  6583. }
  6584. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6585. }
  6586. // SetField sets the value of a field with the given name. It returns an error if
  6587. // the field is not defined in the schema, or if the type mismatched the field
  6588. // type.
  6589. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6590. switch name {
  6591. case batchmsg.FieldCreatedAt:
  6592. v, ok := value.(time.Time)
  6593. if !ok {
  6594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6595. }
  6596. m.SetCreatedAt(v)
  6597. return nil
  6598. case batchmsg.FieldUpdatedAt:
  6599. v, ok := value.(time.Time)
  6600. if !ok {
  6601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6602. }
  6603. m.SetUpdatedAt(v)
  6604. return nil
  6605. case batchmsg.FieldDeletedAt:
  6606. v, ok := value.(time.Time)
  6607. if !ok {
  6608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6609. }
  6610. m.SetDeletedAt(v)
  6611. return nil
  6612. case batchmsg.FieldStatus:
  6613. v, ok := value.(uint8)
  6614. if !ok {
  6615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6616. }
  6617. m.SetStatus(v)
  6618. return nil
  6619. case batchmsg.FieldBatchNo:
  6620. v, ok := value.(string)
  6621. if !ok {
  6622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6623. }
  6624. m.SetBatchNo(v)
  6625. return nil
  6626. case batchmsg.FieldTaskName:
  6627. v, ok := value.(string)
  6628. if !ok {
  6629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6630. }
  6631. m.SetTaskName(v)
  6632. return nil
  6633. case batchmsg.FieldFromwxid:
  6634. v, ok := value.(string)
  6635. if !ok {
  6636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6637. }
  6638. m.SetFromwxid(v)
  6639. return nil
  6640. case batchmsg.FieldMsg:
  6641. v, ok := value.(string)
  6642. if !ok {
  6643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6644. }
  6645. m.SetMsg(v)
  6646. return nil
  6647. case batchmsg.FieldTag:
  6648. v, ok := value.(string)
  6649. if !ok {
  6650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6651. }
  6652. m.SetTag(v)
  6653. return nil
  6654. case batchmsg.FieldTagids:
  6655. v, ok := value.(string)
  6656. if !ok {
  6657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6658. }
  6659. m.SetTagids(v)
  6660. return nil
  6661. case batchmsg.FieldTotal:
  6662. v, ok := value.(int32)
  6663. if !ok {
  6664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6665. }
  6666. m.SetTotal(v)
  6667. return nil
  6668. case batchmsg.FieldSuccess:
  6669. v, ok := value.(int32)
  6670. if !ok {
  6671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6672. }
  6673. m.SetSuccess(v)
  6674. return nil
  6675. case batchmsg.FieldFail:
  6676. v, ok := value.(int32)
  6677. if !ok {
  6678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6679. }
  6680. m.SetFail(v)
  6681. return nil
  6682. case batchmsg.FieldStartTime:
  6683. v, ok := value.(time.Time)
  6684. if !ok {
  6685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6686. }
  6687. m.SetStartTime(v)
  6688. return nil
  6689. case batchmsg.FieldStopTime:
  6690. v, ok := value.(time.Time)
  6691. if !ok {
  6692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6693. }
  6694. m.SetStopTime(v)
  6695. return nil
  6696. case batchmsg.FieldSendTime:
  6697. v, ok := value.(time.Time)
  6698. if !ok {
  6699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6700. }
  6701. m.SetSendTime(v)
  6702. return nil
  6703. case batchmsg.FieldType:
  6704. v, ok := value.(int32)
  6705. if !ok {
  6706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6707. }
  6708. m.SetType(v)
  6709. return nil
  6710. case batchmsg.FieldOrganizationID:
  6711. v, ok := value.(uint64)
  6712. if !ok {
  6713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6714. }
  6715. m.SetOrganizationID(v)
  6716. return nil
  6717. case batchmsg.FieldCtype:
  6718. v, ok := value.(uint64)
  6719. if !ok {
  6720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6721. }
  6722. m.SetCtype(v)
  6723. return nil
  6724. case batchmsg.FieldCc:
  6725. v, ok := value.(string)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCc(v)
  6730. return nil
  6731. case batchmsg.FieldPhone:
  6732. v, ok := value.(string)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetPhone(v)
  6737. return nil
  6738. case batchmsg.FieldTemplateName:
  6739. v, ok := value.(string)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetTemplateName(v)
  6744. return nil
  6745. case batchmsg.FieldTemplateCode:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetTemplateCode(v)
  6751. return nil
  6752. case batchmsg.FieldLang:
  6753. v, ok := value.(string)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetLang(v)
  6758. return nil
  6759. }
  6760. return fmt.Errorf("unknown BatchMsg field %s", name)
  6761. }
  6762. // AddedFields returns all numeric fields that were incremented/decremented during
  6763. // this mutation.
  6764. func (m *BatchMsgMutation) AddedFields() []string {
  6765. var fields []string
  6766. if m.addstatus != nil {
  6767. fields = append(fields, batchmsg.FieldStatus)
  6768. }
  6769. if m.addtotal != nil {
  6770. fields = append(fields, batchmsg.FieldTotal)
  6771. }
  6772. if m.addsuccess != nil {
  6773. fields = append(fields, batchmsg.FieldSuccess)
  6774. }
  6775. if m.addfail != nil {
  6776. fields = append(fields, batchmsg.FieldFail)
  6777. }
  6778. if m.add_type != nil {
  6779. fields = append(fields, batchmsg.FieldType)
  6780. }
  6781. if m.addorganization_id != nil {
  6782. fields = append(fields, batchmsg.FieldOrganizationID)
  6783. }
  6784. if m.addctype != nil {
  6785. fields = append(fields, batchmsg.FieldCtype)
  6786. }
  6787. return fields
  6788. }
  6789. // AddedField returns the numeric value that was incremented/decremented on a field
  6790. // with the given name. The second boolean return value indicates that this field
  6791. // was not set, or was not defined in the schema.
  6792. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6793. switch name {
  6794. case batchmsg.FieldStatus:
  6795. return m.AddedStatus()
  6796. case batchmsg.FieldTotal:
  6797. return m.AddedTotal()
  6798. case batchmsg.FieldSuccess:
  6799. return m.AddedSuccess()
  6800. case batchmsg.FieldFail:
  6801. return m.AddedFail()
  6802. case batchmsg.FieldType:
  6803. return m.AddedType()
  6804. case batchmsg.FieldOrganizationID:
  6805. return m.AddedOrganizationID()
  6806. case batchmsg.FieldCtype:
  6807. return m.AddedCtype()
  6808. }
  6809. return nil, false
  6810. }
  6811. // AddField adds the value to the field with the given name. It returns an error if
  6812. // the field is not defined in the schema, or if the type mismatched the field
  6813. // type.
  6814. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6815. switch name {
  6816. case batchmsg.FieldStatus:
  6817. v, ok := value.(int8)
  6818. if !ok {
  6819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6820. }
  6821. m.AddStatus(v)
  6822. return nil
  6823. case batchmsg.FieldTotal:
  6824. v, ok := value.(int32)
  6825. if !ok {
  6826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6827. }
  6828. m.AddTotal(v)
  6829. return nil
  6830. case batchmsg.FieldSuccess:
  6831. v, ok := value.(int32)
  6832. if !ok {
  6833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6834. }
  6835. m.AddSuccess(v)
  6836. return nil
  6837. case batchmsg.FieldFail:
  6838. v, ok := value.(int32)
  6839. if !ok {
  6840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6841. }
  6842. m.AddFail(v)
  6843. return nil
  6844. case batchmsg.FieldType:
  6845. v, ok := value.(int32)
  6846. if !ok {
  6847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6848. }
  6849. m.AddType(v)
  6850. return nil
  6851. case batchmsg.FieldOrganizationID:
  6852. v, ok := value.(int64)
  6853. if !ok {
  6854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6855. }
  6856. m.AddOrganizationID(v)
  6857. return nil
  6858. case batchmsg.FieldCtype:
  6859. v, ok := value.(int64)
  6860. if !ok {
  6861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6862. }
  6863. m.AddCtype(v)
  6864. return nil
  6865. }
  6866. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6867. }
  6868. // ClearedFields returns all nullable fields that were cleared during this
  6869. // mutation.
  6870. func (m *BatchMsgMutation) ClearedFields() []string {
  6871. var fields []string
  6872. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6873. fields = append(fields, batchmsg.FieldDeletedAt)
  6874. }
  6875. if m.FieldCleared(batchmsg.FieldStatus) {
  6876. fields = append(fields, batchmsg.FieldStatus)
  6877. }
  6878. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6879. fields = append(fields, batchmsg.FieldBatchNo)
  6880. }
  6881. if m.FieldCleared(batchmsg.FieldTaskName) {
  6882. fields = append(fields, batchmsg.FieldTaskName)
  6883. }
  6884. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6885. fields = append(fields, batchmsg.FieldFromwxid)
  6886. }
  6887. if m.FieldCleared(batchmsg.FieldMsg) {
  6888. fields = append(fields, batchmsg.FieldMsg)
  6889. }
  6890. if m.FieldCleared(batchmsg.FieldTag) {
  6891. fields = append(fields, batchmsg.FieldTag)
  6892. }
  6893. if m.FieldCleared(batchmsg.FieldTagids) {
  6894. fields = append(fields, batchmsg.FieldTagids)
  6895. }
  6896. if m.FieldCleared(batchmsg.FieldTotal) {
  6897. fields = append(fields, batchmsg.FieldTotal)
  6898. }
  6899. if m.FieldCleared(batchmsg.FieldSuccess) {
  6900. fields = append(fields, batchmsg.FieldSuccess)
  6901. }
  6902. if m.FieldCleared(batchmsg.FieldFail) {
  6903. fields = append(fields, batchmsg.FieldFail)
  6904. }
  6905. if m.FieldCleared(batchmsg.FieldStartTime) {
  6906. fields = append(fields, batchmsg.FieldStartTime)
  6907. }
  6908. if m.FieldCleared(batchmsg.FieldStopTime) {
  6909. fields = append(fields, batchmsg.FieldStopTime)
  6910. }
  6911. if m.FieldCleared(batchmsg.FieldSendTime) {
  6912. fields = append(fields, batchmsg.FieldSendTime)
  6913. }
  6914. if m.FieldCleared(batchmsg.FieldType) {
  6915. fields = append(fields, batchmsg.FieldType)
  6916. }
  6917. if m.FieldCleared(batchmsg.FieldCc) {
  6918. fields = append(fields, batchmsg.FieldCc)
  6919. }
  6920. if m.FieldCleared(batchmsg.FieldPhone) {
  6921. fields = append(fields, batchmsg.FieldPhone)
  6922. }
  6923. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6924. fields = append(fields, batchmsg.FieldTemplateName)
  6925. }
  6926. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6927. fields = append(fields, batchmsg.FieldTemplateCode)
  6928. }
  6929. if m.FieldCleared(batchmsg.FieldLang) {
  6930. fields = append(fields, batchmsg.FieldLang)
  6931. }
  6932. return fields
  6933. }
  6934. // FieldCleared returns a boolean indicating if a field with the given name was
  6935. // cleared in this mutation.
  6936. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6937. _, ok := m.clearedFields[name]
  6938. return ok
  6939. }
  6940. // ClearField clears the value of the field with the given name. It returns an
  6941. // error if the field is not defined in the schema.
  6942. func (m *BatchMsgMutation) ClearField(name string) error {
  6943. switch name {
  6944. case batchmsg.FieldDeletedAt:
  6945. m.ClearDeletedAt()
  6946. return nil
  6947. case batchmsg.FieldStatus:
  6948. m.ClearStatus()
  6949. return nil
  6950. case batchmsg.FieldBatchNo:
  6951. m.ClearBatchNo()
  6952. return nil
  6953. case batchmsg.FieldTaskName:
  6954. m.ClearTaskName()
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. m.ClearFromwxid()
  6958. return nil
  6959. case batchmsg.FieldMsg:
  6960. m.ClearMsg()
  6961. return nil
  6962. case batchmsg.FieldTag:
  6963. m.ClearTag()
  6964. return nil
  6965. case batchmsg.FieldTagids:
  6966. m.ClearTagids()
  6967. return nil
  6968. case batchmsg.FieldTotal:
  6969. m.ClearTotal()
  6970. return nil
  6971. case batchmsg.FieldSuccess:
  6972. m.ClearSuccess()
  6973. return nil
  6974. case batchmsg.FieldFail:
  6975. m.ClearFail()
  6976. return nil
  6977. case batchmsg.FieldStartTime:
  6978. m.ClearStartTime()
  6979. return nil
  6980. case batchmsg.FieldStopTime:
  6981. m.ClearStopTime()
  6982. return nil
  6983. case batchmsg.FieldSendTime:
  6984. m.ClearSendTime()
  6985. return nil
  6986. case batchmsg.FieldType:
  6987. m.ClearType()
  6988. return nil
  6989. case batchmsg.FieldCc:
  6990. m.ClearCc()
  6991. return nil
  6992. case batchmsg.FieldPhone:
  6993. m.ClearPhone()
  6994. return nil
  6995. case batchmsg.FieldTemplateName:
  6996. m.ClearTemplateName()
  6997. return nil
  6998. case batchmsg.FieldTemplateCode:
  6999. m.ClearTemplateCode()
  7000. return nil
  7001. case batchmsg.FieldLang:
  7002. m.ClearLang()
  7003. return nil
  7004. }
  7005. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7006. }
  7007. // ResetField resets all changes in the mutation for the field with the given name.
  7008. // It returns an error if the field is not defined in the schema.
  7009. func (m *BatchMsgMutation) ResetField(name string) error {
  7010. switch name {
  7011. case batchmsg.FieldCreatedAt:
  7012. m.ResetCreatedAt()
  7013. return nil
  7014. case batchmsg.FieldUpdatedAt:
  7015. m.ResetUpdatedAt()
  7016. return nil
  7017. case batchmsg.FieldDeletedAt:
  7018. m.ResetDeletedAt()
  7019. return nil
  7020. case batchmsg.FieldStatus:
  7021. m.ResetStatus()
  7022. return nil
  7023. case batchmsg.FieldBatchNo:
  7024. m.ResetBatchNo()
  7025. return nil
  7026. case batchmsg.FieldTaskName:
  7027. m.ResetTaskName()
  7028. return nil
  7029. case batchmsg.FieldFromwxid:
  7030. m.ResetFromwxid()
  7031. return nil
  7032. case batchmsg.FieldMsg:
  7033. m.ResetMsg()
  7034. return nil
  7035. case batchmsg.FieldTag:
  7036. m.ResetTag()
  7037. return nil
  7038. case batchmsg.FieldTagids:
  7039. m.ResetTagids()
  7040. return nil
  7041. case batchmsg.FieldTotal:
  7042. m.ResetTotal()
  7043. return nil
  7044. case batchmsg.FieldSuccess:
  7045. m.ResetSuccess()
  7046. return nil
  7047. case batchmsg.FieldFail:
  7048. m.ResetFail()
  7049. return nil
  7050. case batchmsg.FieldStartTime:
  7051. m.ResetStartTime()
  7052. return nil
  7053. case batchmsg.FieldStopTime:
  7054. m.ResetStopTime()
  7055. return nil
  7056. case batchmsg.FieldSendTime:
  7057. m.ResetSendTime()
  7058. return nil
  7059. case batchmsg.FieldType:
  7060. m.ResetType()
  7061. return nil
  7062. case batchmsg.FieldOrganizationID:
  7063. m.ResetOrganizationID()
  7064. return nil
  7065. case batchmsg.FieldCtype:
  7066. m.ResetCtype()
  7067. return nil
  7068. case batchmsg.FieldCc:
  7069. m.ResetCc()
  7070. return nil
  7071. case batchmsg.FieldPhone:
  7072. m.ResetPhone()
  7073. return nil
  7074. case batchmsg.FieldTemplateName:
  7075. m.ResetTemplateName()
  7076. return nil
  7077. case batchmsg.FieldTemplateCode:
  7078. m.ResetTemplateCode()
  7079. return nil
  7080. case batchmsg.FieldLang:
  7081. m.ResetLang()
  7082. return nil
  7083. }
  7084. return fmt.Errorf("unknown BatchMsg field %s", name)
  7085. }
  7086. // AddedEdges returns all edge names that were set/added in this mutation.
  7087. func (m *BatchMsgMutation) AddedEdges() []string {
  7088. edges := make([]string, 0, 0)
  7089. return edges
  7090. }
  7091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7092. // name in this mutation.
  7093. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7094. return nil
  7095. }
  7096. // RemovedEdges returns all edge names that were removed in this mutation.
  7097. func (m *BatchMsgMutation) RemovedEdges() []string {
  7098. edges := make([]string, 0, 0)
  7099. return edges
  7100. }
  7101. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7102. // the given name in this mutation.
  7103. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7104. return nil
  7105. }
  7106. // ClearedEdges returns all edge names that were cleared in this mutation.
  7107. func (m *BatchMsgMutation) ClearedEdges() []string {
  7108. edges := make([]string, 0, 0)
  7109. return edges
  7110. }
  7111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7112. // was cleared in this mutation.
  7113. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7114. return false
  7115. }
  7116. // ClearEdge clears the value of the edge with the given name. It returns an error
  7117. // if that edge is not defined in the schema.
  7118. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7119. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7120. }
  7121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7122. // It returns an error if the edge is not defined in the schema.
  7123. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7124. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7125. }
  7126. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7127. type CategoryMutation struct {
  7128. config
  7129. op Op
  7130. typ string
  7131. id *uint64
  7132. created_at *time.Time
  7133. updated_at *time.Time
  7134. deleted_at *time.Time
  7135. name *string
  7136. organization_id *uint64
  7137. addorganization_id *int64
  7138. clearedFields map[string]struct{}
  7139. done bool
  7140. oldValue func(context.Context) (*Category, error)
  7141. predicates []predicate.Category
  7142. }
  7143. var _ ent.Mutation = (*CategoryMutation)(nil)
  7144. // categoryOption allows management of the mutation configuration using functional options.
  7145. type categoryOption func(*CategoryMutation)
  7146. // newCategoryMutation creates new mutation for the Category entity.
  7147. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7148. m := &CategoryMutation{
  7149. config: c,
  7150. op: op,
  7151. typ: TypeCategory,
  7152. clearedFields: make(map[string]struct{}),
  7153. }
  7154. for _, opt := range opts {
  7155. opt(m)
  7156. }
  7157. return m
  7158. }
  7159. // withCategoryID sets the ID field of the mutation.
  7160. func withCategoryID(id uint64) categoryOption {
  7161. return func(m *CategoryMutation) {
  7162. var (
  7163. err error
  7164. once sync.Once
  7165. value *Category
  7166. )
  7167. m.oldValue = func(ctx context.Context) (*Category, error) {
  7168. once.Do(func() {
  7169. if m.done {
  7170. err = errors.New("querying old values post mutation is not allowed")
  7171. } else {
  7172. value, err = m.Client().Category.Get(ctx, id)
  7173. }
  7174. })
  7175. return value, err
  7176. }
  7177. m.id = &id
  7178. }
  7179. }
  7180. // withCategory sets the old Category of the mutation.
  7181. func withCategory(node *Category) categoryOption {
  7182. return func(m *CategoryMutation) {
  7183. m.oldValue = func(context.Context) (*Category, error) {
  7184. return node, nil
  7185. }
  7186. m.id = &node.ID
  7187. }
  7188. }
  7189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7190. // executed in a transaction (ent.Tx), a transactional client is returned.
  7191. func (m CategoryMutation) Client() *Client {
  7192. client := &Client{config: m.config}
  7193. client.init()
  7194. return client
  7195. }
  7196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7197. // it returns an error otherwise.
  7198. func (m CategoryMutation) Tx() (*Tx, error) {
  7199. if _, ok := m.driver.(*txDriver); !ok {
  7200. return nil, errors.New("ent: mutation is not running in a transaction")
  7201. }
  7202. tx := &Tx{config: m.config}
  7203. tx.init()
  7204. return tx, nil
  7205. }
  7206. // SetID sets the value of the id field. Note that this
  7207. // operation is only accepted on creation of Category entities.
  7208. func (m *CategoryMutation) SetID(id uint64) {
  7209. m.id = &id
  7210. }
  7211. // ID returns the ID value in the mutation. Note that the ID is only available
  7212. // if it was provided to the builder or after it was returned from the database.
  7213. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7214. if m.id == nil {
  7215. return
  7216. }
  7217. return *m.id, true
  7218. }
  7219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7220. // That means, if the mutation is applied within a transaction with an isolation level such
  7221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7222. // or updated by the mutation.
  7223. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7224. switch {
  7225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7226. id, exists := m.ID()
  7227. if exists {
  7228. return []uint64{id}, nil
  7229. }
  7230. fallthrough
  7231. case m.op.Is(OpUpdate | OpDelete):
  7232. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7233. default:
  7234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7235. }
  7236. }
  7237. // SetCreatedAt sets the "created_at" field.
  7238. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7239. m.created_at = &t
  7240. }
  7241. // CreatedAt returns the value of the "created_at" field in the mutation.
  7242. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7243. v := m.created_at
  7244. if v == nil {
  7245. return
  7246. }
  7247. return *v, true
  7248. }
  7249. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7250. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7252. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7253. if !m.op.Is(OpUpdateOne) {
  7254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7255. }
  7256. if m.id == nil || m.oldValue == nil {
  7257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7258. }
  7259. oldValue, err := m.oldValue(ctx)
  7260. if err != nil {
  7261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7262. }
  7263. return oldValue.CreatedAt, nil
  7264. }
  7265. // ResetCreatedAt resets all changes to the "created_at" field.
  7266. func (m *CategoryMutation) ResetCreatedAt() {
  7267. m.created_at = nil
  7268. }
  7269. // SetUpdatedAt sets the "updated_at" field.
  7270. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7271. m.updated_at = &t
  7272. }
  7273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7274. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7275. v := m.updated_at
  7276. if v == nil {
  7277. return
  7278. }
  7279. return *v, true
  7280. }
  7281. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7282. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7284. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7285. if !m.op.Is(OpUpdateOne) {
  7286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7287. }
  7288. if m.id == nil || m.oldValue == nil {
  7289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7290. }
  7291. oldValue, err := m.oldValue(ctx)
  7292. if err != nil {
  7293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7294. }
  7295. return oldValue.UpdatedAt, nil
  7296. }
  7297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7298. func (m *CategoryMutation) ResetUpdatedAt() {
  7299. m.updated_at = nil
  7300. }
  7301. // SetDeletedAt sets the "deleted_at" field.
  7302. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7303. m.deleted_at = &t
  7304. }
  7305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7306. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7307. v := m.deleted_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7314. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7326. }
  7327. return oldValue.DeletedAt, nil
  7328. }
  7329. // ClearDeletedAt clears the value of the "deleted_at" field.
  7330. func (m *CategoryMutation) ClearDeletedAt() {
  7331. m.deleted_at = nil
  7332. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7333. }
  7334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7335. func (m *CategoryMutation) DeletedAtCleared() bool {
  7336. _, ok := m.clearedFields[category.FieldDeletedAt]
  7337. return ok
  7338. }
  7339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7340. func (m *CategoryMutation) ResetDeletedAt() {
  7341. m.deleted_at = nil
  7342. delete(m.clearedFields, category.FieldDeletedAt)
  7343. }
  7344. // SetName sets the "name" field.
  7345. func (m *CategoryMutation) SetName(s string) {
  7346. m.name = &s
  7347. }
  7348. // Name returns the value of the "name" field in the mutation.
  7349. func (m *CategoryMutation) Name() (r string, exists bool) {
  7350. v := m.name
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldName returns the old "name" field's value of the Category entity.
  7357. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldName requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7369. }
  7370. return oldValue.Name, nil
  7371. }
  7372. // ResetName resets all changes to the "name" field.
  7373. func (m *CategoryMutation) ResetName() {
  7374. m.name = nil
  7375. }
  7376. // SetOrganizationID sets the "organization_id" field.
  7377. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7378. m.organization_id = &u
  7379. m.addorganization_id = nil
  7380. }
  7381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7382. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7383. v := m.organization_id
  7384. if v == nil {
  7385. return
  7386. }
  7387. return *v, true
  7388. }
  7389. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7390. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7392. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7393. if !m.op.Is(OpUpdateOne) {
  7394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7395. }
  7396. if m.id == nil || m.oldValue == nil {
  7397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7398. }
  7399. oldValue, err := m.oldValue(ctx)
  7400. if err != nil {
  7401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7402. }
  7403. return oldValue.OrganizationID, nil
  7404. }
  7405. // AddOrganizationID adds u to the "organization_id" field.
  7406. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7407. if m.addorganization_id != nil {
  7408. *m.addorganization_id += u
  7409. } else {
  7410. m.addorganization_id = &u
  7411. }
  7412. }
  7413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7414. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7415. v := m.addorganization_id
  7416. if v == nil {
  7417. return
  7418. }
  7419. return *v, true
  7420. }
  7421. // ResetOrganizationID resets all changes to the "organization_id" field.
  7422. func (m *CategoryMutation) ResetOrganizationID() {
  7423. m.organization_id = nil
  7424. m.addorganization_id = nil
  7425. }
  7426. // Where appends a list predicates to the CategoryMutation builder.
  7427. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7428. m.predicates = append(m.predicates, ps...)
  7429. }
  7430. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7431. // users can use type-assertion to append predicates that do not depend on any generated package.
  7432. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7433. p := make([]predicate.Category, len(ps))
  7434. for i := range ps {
  7435. p[i] = ps[i]
  7436. }
  7437. m.Where(p...)
  7438. }
  7439. // Op returns the operation name.
  7440. func (m *CategoryMutation) Op() Op {
  7441. return m.op
  7442. }
  7443. // SetOp allows setting the mutation operation.
  7444. func (m *CategoryMutation) SetOp(op Op) {
  7445. m.op = op
  7446. }
  7447. // Type returns the node type of this mutation (Category).
  7448. func (m *CategoryMutation) Type() string {
  7449. return m.typ
  7450. }
  7451. // Fields returns all fields that were changed during this mutation. Note that in
  7452. // order to get all numeric fields that were incremented/decremented, call
  7453. // AddedFields().
  7454. func (m *CategoryMutation) Fields() []string {
  7455. fields := make([]string, 0, 5)
  7456. if m.created_at != nil {
  7457. fields = append(fields, category.FieldCreatedAt)
  7458. }
  7459. if m.updated_at != nil {
  7460. fields = append(fields, category.FieldUpdatedAt)
  7461. }
  7462. if m.deleted_at != nil {
  7463. fields = append(fields, category.FieldDeletedAt)
  7464. }
  7465. if m.name != nil {
  7466. fields = append(fields, category.FieldName)
  7467. }
  7468. if m.organization_id != nil {
  7469. fields = append(fields, category.FieldOrganizationID)
  7470. }
  7471. return fields
  7472. }
  7473. // Field returns the value of a field with the given name. The second boolean
  7474. // return value indicates that this field was not set, or was not defined in the
  7475. // schema.
  7476. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7477. switch name {
  7478. case category.FieldCreatedAt:
  7479. return m.CreatedAt()
  7480. case category.FieldUpdatedAt:
  7481. return m.UpdatedAt()
  7482. case category.FieldDeletedAt:
  7483. return m.DeletedAt()
  7484. case category.FieldName:
  7485. return m.Name()
  7486. case category.FieldOrganizationID:
  7487. return m.OrganizationID()
  7488. }
  7489. return nil, false
  7490. }
  7491. // OldField returns the old value of the field from the database. An error is
  7492. // returned if the mutation operation is not UpdateOne, or the query to the
  7493. // database failed.
  7494. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7495. switch name {
  7496. case category.FieldCreatedAt:
  7497. return m.OldCreatedAt(ctx)
  7498. case category.FieldUpdatedAt:
  7499. return m.OldUpdatedAt(ctx)
  7500. case category.FieldDeletedAt:
  7501. return m.OldDeletedAt(ctx)
  7502. case category.FieldName:
  7503. return m.OldName(ctx)
  7504. case category.FieldOrganizationID:
  7505. return m.OldOrganizationID(ctx)
  7506. }
  7507. return nil, fmt.Errorf("unknown Category field %s", name)
  7508. }
  7509. // SetField sets the value of a field with the given name. It returns an error if
  7510. // the field is not defined in the schema, or if the type mismatched the field
  7511. // type.
  7512. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7513. switch name {
  7514. case category.FieldCreatedAt:
  7515. v, ok := value.(time.Time)
  7516. if !ok {
  7517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7518. }
  7519. m.SetCreatedAt(v)
  7520. return nil
  7521. case category.FieldUpdatedAt:
  7522. v, ok := value.(time.Time)
  7523. if !ok {
  7524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7525. }
  7526. m.SetUpdatedAt(v)
  7527. return nil
  7528. case category.FieldDeletedAt:
  7529. v, ok := value.(time.Time)
  7530. if !ok {
  7531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7532. }
  7533. m.SetDeletedAt(v)
  7534. return nil
  7535. case category.FieldName:
  7536. v, ok := value.(string)
  7537. if !ok {
  7538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7539. }
  7540. m.SetName(v)
  7541. return nil
  7542. case category.FieldOrganizationID:
  7543. v, ok := value.(uint64)
  7544. if !ok {
  7545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7546. }
  7547. m.SetOrganizationID(v)
  7548. return nil
  7549. }
  7550. return fmt.Errorf("unknown Category field %s", name)
  7551. }
  7552. // AddedFields returns all numeric fields that were incremented/decremented during
  7553. // this mutation.
  7554. func (m *CategoryMutation) AddedFields() []string {
  7555. var fields []string
  7556. if m.addorganization_id != nil {
  7557. fields = append(fields, category.FieldOrganizationID)
  7558. }
  7559. return fields
  7560. }
  7561. // AddedField returns the numeric value that was incremented/decremented on a field
  7562. // with the given name. The second boolean return value indicates that this field
  7563. // was not set, or was not defined in the schema.
  7564. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7565. switch name {
  7566. case category.FieldOrganizationID:
  7567. return m.AddedOrganizationID()
  7568. }
  7569. return nil, false
  7570. }
  7571. // AddField adds the value to the field with the given name. It returns an error if
  7572. // the field is not defined in the schema, or if the type mismatched the field
  7573. // type.
  7574. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7575. switch name {
  7576. case category.FieldOrganizationID:
  7577. v, ok := value.(int64)
  7578. if !ok {
  7579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7580. }
  7581. m.AddOrganizationID(v)
  7582. return nil
  7583. }
  7584. return fmt.Errorf("unknown Category numeric field %s", name)
  7585. }
  7586. // ClearedFields returns all nullable fields that were cleared during this
  7587. // mutation.
  7588. func (m *CategoryMutation) ClearedFields() []string {
  7589. var fields []string
  7590. if m.FieldCleared(category.FieldDeletedAt) {
  7591. fields = append(fields, category.FieldDeletedAt)
  7592. }
  7593. return fields
  7594. }
  7595. // FieldCleared returns a boolean indicating if a field with the given name was
  7596. // cleared in this mutation.
  7597. func (m *CategoryMutation) FieldCleared(name string) bool {
  7598. _, ok := m.clearedFields[name]
  7599. return ok
  7600. }
  7601. // ClearField clears the value of the field with the given name. It returns an
  7602. // error if the field is not defined in the schema.
  7603. func (m *CategoryMutation) ClearField(name string) error {
  7604. switch name {
  7605. case category.FieldDeletedAt:
  7606. m.ClearDeletedAt()
  7607. return nil
  7608. }
  7609. return fmt.Errorf("unknown Category nullable field %s", name)
  7610. }
  7611. // ResetField resets all changes in the mutation for the field with the given name.
  7612. // It returns an error if the field is not defined in the schema.
  7613. func (m *CategoryMutation) ResetField(name string) error {
  7614. switch name {
  7615. case category.FieldCreatedAt:
  7616. m.ResetCreatedAt()
  7617. return nil
  7618. case category.FieldUpdatedAt:
  7619. m.ResetUpdatedAt()
  7620. return nil
  7621. case category.FieldDeletedAt:
  7622. m.ResetDeletedAt()
  7623. return nil
  7624. case category.FieldName:
  7625. m.ResetName()
  7626. return nil
  7627. case category.FieldOrganizationID:
  7628. m.ResetOrganizationID()
  7629. return nil
  7630. }
  7631. return fmt.Errorf("unknown Category field %s", name)
  7632. }
  7633. // AddedEdges returns all edge names that were set/added in this mutation.
  7634. func (m *CategoryMutation) AddedEdges() []string {
  7635. edges := make([]string, 0, 0)
  7636. return edges
  7637. }
  7638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7639. // name in this mutation.
  7640. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7641. return nil
  7642. }
  7643. // RemovedEdges returns all edge names that were removed in this mutation.
  7644. func (m *CategoryMutation) RemovedEdges() []string {
  7645. edges := make([]string, 0, 0)
  7646. return edges
  7647. }
  7648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7649. // the given name in this mutation.
  7650. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7651. return nil
  7652. }
  7653. // ClearedEdges returns all edge names that were cleared in this mutation.
  7654. func (m *CategoryMutation) ClearedEdges() []string {
  7655. edges := make([]string, 0, 0)
  7656. return edges
  7657. }
  7658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7659. // was cleared in this mutation.
  7660. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7661. return false
  7662. }
  7663. // ClearEdge clears the value of the edge with the given name. It returns an error
  7664. // if that edge is not defined in the schema.
  7665. func (m *CategoryMutation) ClearEdge(name string) error {
  7666. return fmt.Errorf("unknown Category unique edge %s", name)
  7667. }
  7668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7669. // It returns an error if the edge is not defined in the schema.
  7670. func (m *CategoryMutation) ResetEdge(name string) error {
  7671. return fmt.Errorf("unknown Category edge %s", name)
  7672. }
  7673. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7674. type ChatRecordsMutation struct {
  7675. config
  7676. op Op
  7677. typ string
  7678. id *uint64
  7679. created_at *time.Time
  7680. updated_at *time.Time
  7681. deleted_at *time.Time
  7682. content *string
  7683. content_type *uint8
  7684. addcontent_type *int8
  7685. session_id *uint64
  7686. addsession_id *int64
  7687. user_id *uint64
  7688. adduser_id *int64
  7689. bot_id *uint64
  7690. addbot_id *int64
  7691. bot_type *uint8
  7692. addbot_type *int8
  7693. clearedFields map[string]struct{}
  7694. done bool
  7695. oldValue func(context.Context) (*ChatRecords, error)
  7696. predicates []predicate.ChatRecords
  7697. }
  7698. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7699. // chatrecordsOption allows management of the mutation configuration using functional options.
  7700. type chatrecordsOption func(*ChatRecordsMutation)
  7701. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7702. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7703. m := &ChatRecordsMutation{
  7704. config: c,
  7705. op: op,
  7706. typ: TypeChatRecords,
  7707. clearedFields: make(map[string]struct{}),
  7708. }
  7709. for _, opt := range opts {
  7710. opt(m)
  7711. }
  7712. return m
  7713. }
  7714. // withChatRecordsID sets the ID field of the mutation.
  7715. func withChatRecordsID(id uint64) chatrecordsOption {
  7716. return func(m *ChatRecordsMutation) {
  7717. var (
  7718. err error
  7719. once sync.Once
  7720. value *ChatRecords
  7721. )
  7722. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7723. once.Do(func() {
  7724. if m.done {
  7725. err = errors.New("querying old values post mutation is not allowed")
  7726. } else {
  7727. value, err = m.Client().ChatRecords.Get(ctx, id)
  7728. }
  7729. })
  7730. return value, err
  7731. }
  7732. m.id = &id
  7733. }
  7734. }
  7735. // withChatRecords sets the old ChatRecords of the mutation.
  7736. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7737. return func(m *ChatRecordsMutation) {
  7738. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7739. return node, nil
  7740. }
  7741. m.id = &node.ID
  7742. }
  7743. }
  7744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7745. // executed in a transaction (ent.Tx), a transactional client is returned.
  7746. func (m ChatRecordsMutation) Client() *Client {
  7747. client := &Client{config: m.config}
  7748. client.init()
  7749. return client
  7750. }
  7751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7752. // it returns an error otherwise.
  7753. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7754. if _, ok := m.driver.(*txDriver); !ok {
  7755. return nil, errors.New("ent: mutation is not running in a transaction")
  7756. }
  7757. tx := &Tx{config: m.config}
  7758. tx.init()
  7759. return tx, nil
  7760. }
  7761. // SetID sets the value of the id field. Note that this
  7762. // operation is only accepted on creation of ChatRecords entities.
  7763. func (m *ChatRecordsMutation) SetID(id uint64) {
  7764. m.id = &id
  7765. }
  7766. // ID returns the ID value in the mutation. Note that the ID is only available
  7767. // if it was provided to the builder or after it was returned from the database.
  7768. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7769. if m.id == nil {
  7770. return
  7771. }
  7772. return *m.id, true
  7773. }
  7774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7775. // That means, if the mutation is applied within a transaction with an isolation level such
  7776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7777. // or updated by the mutation.
  7778. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7779. switch {
  7780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7781. id, exists := m.ID()
  7782. if exists {
  7783. return []uint64{id}, nil
  7784. }
  7785. fallthrough
  7786. case m.op.Is(OpUpdate | OpDelete):
  7787. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7788. default:
  7789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7790. }
  7791. }
  7792. // SetCreatedAt sets the "created_at" field.
  7793. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7794. m.created_at = &t
  7795. }
  7796. // CreatedAt returns the value of the "created_at" field in the mutation.
  7797. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7798. v := m.created_at
  7799. if v == nil {
  7800. return
  7801. }
  7802. return *v, true
  7803. }
  7804. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7805. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7807. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7808. if !m.op.Is(OpUpdateOne) {
  7809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7810. }
  7811. if m.id == nil || m.oldValue == nil {
  7812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7813. }
  7814. oldValue, err := m.oldValue(ctx)
  7815. if err != nil {
  7816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7817. }
  7818. return oldValue.CreatedAt, nil
  7819. }
  7820. // ResetCreatedAt resets all changes to the "created_at" field.
  7821. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7822. m.created_at = nil
  7823. }
  7824. // SetUpdatedAt sets the "updated_at" field.
  7825. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7826. m.updated_at = &t
  7827. }
  7828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7829. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7830. v := m.updated_at
  7831. if v == nil {
  7832. return
  7833. }
  7834. return *v, true
  7835. }
  7836. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7837. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7839. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7840. if !m.op.Is(OpUpdateOne) {
  7841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7842. }
  7843. if m.id == nil || m.oldValue == nil {
  7844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7845. }
  7846. oldValue, err := m.oldValue(ctx)
  7847. if err != nil {
  7848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7849. }
  7850. return oldValue.UpdatedAt, nil
  7851. }
  7852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7853. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7854. m.updated_at = nil
  7855. }
  7856. // SetDeletedAt sets the "deleted_at" field.
  7857. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7858. m.deleted_at = &t
  7859. }
  7860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7861. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7862. v := m.deleted_at
  7863. if v == nil {
  7864. return
  7865. }
  7866. return *v, true
  7867. }
  7868. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7869. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7871. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7872. if !m.op.Is(OpUpdateOne) {
  7873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7874. }
  7875. if m.id == nil || m.oldValue == nil {
  7876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7877. }
  7878. oldValue, err := m.oldValue(ctx)
  7879. if err != nil {
  7880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7881. }
  7882. return oldValue.DeletedAt, nil
  7883. }
  7884. // ClearDeletedAt clears the value of the "deleted_at" field.
  7885. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7886. m.deleted_at = nil
  7887. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7888. }
  7889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7890. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7891. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7892. return ok
  7893. }
  7894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7895. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7896. m.deleted_at = nil
  7897. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7898. }
  7899. // SetContent sets the "content" field.
  7900. func (m *ChatRecordsMutation) SetContent(s string) {
  7901. m.content = &s
  7902. }
  7903. // Content returns the value of the "content" field in the mutation.
  7904. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7905. v := m.content
  7906. if v == nil {
  7907. return
  7908. }
  7909. return *v, true
  7910. }
  7911. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7912. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7914. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7915. if !m.op.Is(OpUpdateOne) {
  7916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7917. }
  7918. if m.id == nil || m.oldValue == nil {
  7919. return v, errors.New("OldContent requires an ID field in the mutation")
  7920. }
  7921. oldValue, err := m.oldValue(ctx)
  7922. if err != nil {
  7923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7924. }
  7925. return oldValue.Content, nil
  7926. }
  7927. // ResetContent resets all changes to the "content" field.
  7928. func (m *ChatRecordsMutation) ResetContent() {
  7929. m.content = nil
  7930. }
  7931. // SetContentType sets the "content_type" field.
  7932. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7933. m.content_type = &u
  7934. m.addcontent_type = nil
  7935. }
  7936. // ContentType returns the value of the "content_type" field in the mutation.
  7937. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7938. v := m.content_type
  7939. if v == nil {
  7940. return
  7941. }
  7942. return *v, true
  7943. }
  7944. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7945. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7947. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7948. if !m.op.Is(OpUpdateOne) {
  7949. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7950. }
  7951. if m.id == nil || m.oldValue == nil {
  7952. return v, errors.New("OldContentType requires an ID field in the mutation")
  7953. }
  7954. oldValue, err := m.oldValue(ctx)
  7955. if err != nil {
  7956. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7957. }
  7958. return oldValue.ContentType, nil
  7959. }
  7960. // AddContentType adds u to the "content_type" field.
  7961. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7962. if m.addcontent_type != nil {
  7963. *m.addcontent_type += u
  7964. } else {
  7965. m.addcontent_type = &u
  7966. }
  7967. }
  7968. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7969. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7970. v := m.addcontent_type
  7971. if v == nil {
  7972. return
  7973. }
  7974. return *v, true
  7975. }
  7976. // ResetContentType resets all changes to the "content_type" field.
  7977. func (m *ChatRecordsMutation) ResetContentType() {
  7978. m.content_type = nil
  7979. m.addcontent_type = nil
  7980. }
  7981. // SetSessionID sets the "session_id" field.
  7982. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7983. m.session_id = &u
  7984. m.addsession_id = nil
  7985. }
  7986. // SessionID returns the value of the "session_id" field in the mutation.
  7987. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7988. v := m.session_id
  7989. if v == nil {
  7990. return
  7991. }
  7992. return *v, true
  7993. }
  7994. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7995. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7997. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7998. if !m.op.Is(OpUpdateOne) {
  7999. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8000. }
  8001. if m.id == nil || m.oldValue == nil {
  8002. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8003. }
  8004. oldValue, err := m.oldValue(ctx)
  8005. if err != nil {
  8006. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8007. }
  8008. return oldValue.SessionID, nil
  8009. }
  8010. // AddSessionID adds u to the "session_id" field.
  8011. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8012. if m.addsession_id != nil {
  8013. *m.addsession_id += u
  8014. } else {
  8015. m.addsession_id = &u
  8016. }
  8017. }
  8018. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8019. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8020. v := m.addsession_id
  8021. if v == nil {
  8022. return
  8023. }
  8024. return *v, true
  8025. }
  8026. // ResetSessionID resets all changes to the "session_id" field.
  8027. func (m *ChatRecordsMutation) ResetSessionID() {
  8028. m.session_id = nil
  8029. m.addsession_id = nil
  8030. }
  8031. // SetUserID sets the "user_id" field.
  8032. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8033. m.user_id = &u
  8034. m.adduser_id = nil
  8035. }
  8036. // UserID returns the value of the "user_id" field in the mutation.
  8037. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8038. v := m.user_id
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8045. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldUserID requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8057. }
  8058. return oldValue.UserID, nil
  8059. }
  8060. // AddUserID adds u to the "user_id" field.
  8061. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8062. if m.adduser_id != nil {
  8063. *m.adduser_id += u
  8064. } else {
  8065. m.adduser_id = &u
  8066. }
  8067. }
  8068. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8069. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8070. v := m.adduser_id
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // ResetUserID resets all changes to the "user_id" field.
  8077. func (m *ChatRecordsMutation) ResetUserID() {
  8078. m.user_id = nil
  8079. m.adduser_id = nil
  8080. }
  8081. // SetBotID sets the "bot_id" field.
  8082. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8083. m.bot_id = &u
  8084. m.addbot_id = nil
  8085. }
  8086. // BotID returns the value of the "bot_id" field in the mutation.
  8087. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8088. v := m.bot_id
  8089. if v == nil {
  8090. return
  8091. }
  8092. return *v, true
  8093. }
  8094. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8095. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8097. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8098. if !m.op.Is(OpUpdateOne) {
  8099. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8100. }
  8101. if m.id == nil || m.oldValue == nil {
  8102. return v, errors.New("OldBotID requires an ID field in the mutation")
  8103. }
  8104. oldValue, err := m.oldValue(ctx)
  8105. if err != nil {
  8106. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8107. }
  8108. return oldValue.BotID, nil
  8109. }
  8110. // AddBotID adds u to the "bot_id" field.
  8111. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8112. if m.addbot_id != nil {
  8113. *m.addbot_id += u
  8114. } else {
  8115. m.addbot_id = &u
  8116. }
  8117. }
  8118. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8119. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8120. v := m.addbot_id
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // ResetBotID resets all changes to the "bot_id" field.
  8127. func (m *ChatRecordsMutation) ResetBotID() {
  8128. m.bot_id = nil
  8129. m.addbot_id = nil
  8130. }
  8131. // SetBotType sets the "bot_type" field.
  8132. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8133. m.bot_type = &u
  8134. m.addbot_type = nil
  8135. }
  8136. // BotType returns the value of the "bot_type" field in the mutation.
  8137. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8138. v := m.bot_type
  8139. if v == nil {
  8140. return
  8141. }
  8142. return *v, true
  8143. }
  8144. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8145. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8147. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8148. if !m.op.Is(OpUpdateOne) {
  8149. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8150. }
  8151. if m.id == nil || m.oldValue == nil {
  8152. return v, errors.New("OldBotType requires an ID field in the mutation")
  8153. }
  8154. oldValue, err := m.oldValue(ctx)
  8155. if err != nil {
  8156. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8157. }
  8158. return oldValue.BotType, nil
  8159. }
  8160. // AddBotType adds u to the "bot_type" field.
  8161. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8162. if m.addbot_type != nil {
  8163. *m.addbot_type += u
  8164. } else {
  8165. m.addbot_type = &u
  8166. }
  8167. }
  8168. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8169. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8170. v := m.addbot_type
  8171. if v == nil {
  8172. return
  8173. }
  8174. return *v, true
  8175. }
  8176. // ResetBotType resets all changes to the "bot_type" field.
  8177. func (m *ChatRecordsMutation) ResetBotType() {
  8178. m.bot_type = nil
  8179. m.addbot_type = nil
  8180. }
  8181. // Where appends a list predicates to the ChatRecordsMutation builder.
  8182. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8183. m.predicates = append(m.predicates, ps...)
  8184. }
  8185. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8186. // users can use type-assertion to append predicates that do not depend on any generated package.
  8187. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8188. p := make([]predicate.ChatRecords, len(ps))
  8189. for i := range ps {
  8190. p[i] = ps[i]
  8191. }
  8192. m.Where(p...)
  8193. }
  8194. // Op returns the operation name.
  8195. func (m *ChatRecordsMutation) Op() Op {
  8196. return m.op
  8197. }
  8198. // SetOp allows setting the mutation operation.
  8199. func (m *ChatRecordsMutation) SetOp(op Op) {
  8200. m.op = op
  8201. }
  8202. // Type returns the node type of this mutation (ChatRecords).
  8203. func (m *ChatRecordsMutation) Type() string {
  8204. return m.typ
  8205. }
  8206. // Fields returns all fields that were changed during this mutation. Note that in
  8207. // order to get all numeric fields that were incremented/decremented, call
  8208. // AddedFields().
  8209. func (m *ChatRecordsMutation) Fields() []string {
  8210. fields := make([]string, 0, 9)
  8211. if m.created_at != nil {
  8212. fields = append(fields, chatrecords.FieldCreatedAt)
  8213. }
  8214. if m.updated_at != nil {
  8215. fields = append(fields, chatrecords.FieldUpdatedAt)
  8216. }
  8217. if m.deleted_at != nil {
  8218. fields = append(fields, chatrecords.FieldDeletedAt)
  8219. }
  8220. if m.content != nil {
  8221. fields = append(fields, chatrecords.FieldContent)
  8222. }
  8223. if m.content_type != nil {
  8224. fields = append(fields, chatrecords.FieldContentType)
  8225. }
  8226. if m.session_id != nil {
  8227. fields = append(fields, chatrecords.FieldSessionID)
  8228. }
  8229. if m.user_id != nil {
  8230. fields = append(fields, chatrecords.FieldUserID)
  8231. }
  8232. if m.bot_id != nil {
  8233. fields = append(fields, chatrecords.FieldBotID)
  8234. }
  8235. if m.bot_type != nil {
  8236. fields = append(fields, chatrecords.FieldBotType)
  8237. }
  8238. return fields
  8239. }
  8240. // Field returns the value of a field with the given name. The second boolean
  8241. // return value indicates that this field was not set, or was not defined in the
  8242. // schema.
  8243. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8244. switch name {
  8245. case chatrecords.FieldCreatedAt:
  8246. return m.CreatedAt()
  8247. case chatrecords.FieldUpdatedAt:
  8248. return m.UpdatedAt()
  8249. case chatrecords.FieldDeletedAt:
  8250. return m.DeletedAt()
  8251. case chatrecords.FieldContent:
  8252. return m.Content()
  8253. case chatrecords.FieldContentType:
  8254. return m.ContentType()
  8255. case chatrecords.FieldSessionID:
  8256. return m.SessionID()
  8257. case chatrecords.FieldUserID:
  8258. return m.UserID()
  8259. case chatrecords.FieldBotID:
  8260. return m.BotID()
  8261. case chatrecords.FieldBotType:
  8262. return m.BotType()
  8263. }
  8264. return nil, false
  8265. }
  8266. // OldField returns the old value of the field from the database. An error is
  8267. // returned if the mutation operation is not UpdateOne, or the query to the
  8268. // database failed.
  8269. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8270. switch name {
  8271. case chatrecords.FieldCreatedAt:
  8272. return m.OldCreatedAt(ctx)
  8273. case chatrecords.FieldUpdatedAt:
  8274. return m.OldUpdatedAt(ctx)
  8275. case chatrecords.FieldDeletedAt:
  8276. return m.OldDeletedAt(ctx)
  8277. case chatrecords.FieldContent:
  8278. return m.OldContent(ctx)
  8279. case chatrecords.FieldContentType:
  8280. return m.OldContentType(ctx)
  8281. case chatrecords.FieldSessionID:
  8282. return m.OldSessionID(ctx)
  8283. case chatrecords.FieldUserID:
  8284. return m.OldUserID(ctx)
  8285. case chatrecords.FieldBotID:
  8286. return m.OldBotID(ctx)
  8287. case chatrecords.FieldBotType:
  8288. return m.OldBotType(ctx)
  8289. }
  8290. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8291. }
  8292. // SetField sets the value of a field with the given name. It returns an error if
  8293. // the field is not defined in the schema, or if the type mismatched the field
  8294. // type.
  8295. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8296. switch name {
  8297. case chatrecords.FieldCreatedAt:
  8298. v, ok := value.(time.Time)
  8299. if !ok {
  8300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8301. }
  8302. m.SetCreatedAt(v)
  8303. return nil
  8304. case chatrecords.FieldUpdatedAt:
  8305. v, ok := value.(time.Time)
  8306. if !ok {
  8307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8308. }
  8309. m.SetUpdatedAt(v)
  8310. return nil
  8311. case chatrecords.FieldDeletedAt:
  8312. v, ok := value.(time.Time)
  8313. if !ok {
  8314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8315. }
  8316. m.SetDeletedAt(v)
  8317. return nil
  8318. case chatrecords.FieldContent:
  8319. v, ok := value.(string)
  8320. if !ok {
  8321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8322. }
  8323. m.SetContent(v)
  8324. return nil
  8325. case chatrecords.FieldContentType:
  8326. v, ok := value.(uint8)
  8327. if !ok {
  8328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8329. }
  8330. m.SetContentType(v)
  8331. return nil
  8332. case chatrecords.FieldSessionID:
  8333. v, ok := value.(uint64)
  8334. if !ok {
  8335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8336. }
  8337. m.SetSessionID(v)
  8338. return nil
  8339. case chatrecords.FieldUserID:
  8340. v, ok := value.(uint64)
  8341. if !ok {
  8342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8343. }
  8344. m.SetUserID(v)
  8345. return nil
  8346. case chatrecords.FieldBotID:
  8347. v, ok := value.(uint64)
  8348. if !ok {
  8349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8350. }
  8351. m.SetBotID(v)
  8352. return nil
  8353. case chatrecords.FieldBotType:
  8354. v, ok := value.(uint8)
  8355. if !ok {
  8356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8357. }
  8358. m.SetBotType(v)
  8359. return nil
  8360. }
  8361. return fmt.Errorf("unknown ChatRecords field %s", name)
  8362. }
  8363. // AddedFields returns all numeric fields that were incremented/decremented during
  8364. // this mutation.
  8365. func (m *ChatRecordsMutation) AddedFields() []string {
  8366. var fields []string
  8367. if m.addcontent_type != nil {
  8368. fields = append(fields, chatrecords.FieldContentType)
  8369. }
  8370. if m.addsession_id != nil {
  8371. fields = append(fields, chatrecords.FieldSessionID)
  8372. }
  8373. if m.adduser_id != nil {
  8374. fields = append(fields, chatrecords.FieldUserID)
  8375. }
  8376. if m.addbot_id != nil {
  8377. fields = append(fields, chatrecords.FieldBotID)
  8378. }
  8379. if m.addbot_type != nil {
  8380. fields = append(fields, chatrecords.FieldBotType)
  8381. }
  8382. return fields
  8383. }
  8384. // AddedField returns the numeric value that was incremented/decremented on a field
  8385. // with the given name. The second boolean return value indicates that this field
  8386. // was not set, or was not defined in the schema.
  8387. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8388. switch name {
  8389. case chatrecords.FieldContentType:
  8390. return m.AddedContentType()
  8391. case chatrecords.FieldSessionID:
  8392. return m.AddedSessionID()
  8393. case chatrecords.FieldUserID:
  8394. return m.AddedUserID()
  8395. case chatrecords.FieldBotID:
  8396. return m.AddedBotID()
  8397. case chatrecords.FieldBotType:
  8398. return m.AddedBotType()
  8399. }
  8400. return nil, false
  8401. }
  8402. // AddField adds the value to the field with the given name. It returns an error if
  8403. // the field is not defined in the schema, or if the type mismatched the field
  8404. // type.
  8405. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8406. switch name {
  8407. case chatrecords.FieldContentType:
  8408. v, ok := value.(int8)
  8409. if !ok {
  8410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8411. }
  8412. m.AddContentType(v)
  8413. return nil
  8414. case chatrecords.FieldSessionID:
  8415. v, ok := value.(int64)
  8416. if !ok {
  8417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8418. }
  8419. m.AddSessionID(v)
  8420. return nil
  8421. case chatrecords.FieldUserID:
  8422. v, ok := value.(int64)
  8423. if !ok {
  8424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8425. }
  8426. m.AddUserID(v)
  8427. return nil
  8428. case chatrecords.FieldBotID:
  8429. v, ok := value.(int64)
  8430. if !ok {
  8431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8432. }
  8433. m.AddBotID(v)
  8434. return nil
  8435. case chatrecords.FieldBotType:
  8436. v, ok := value.(int8)
  8437. if !ok {
  8438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8439. }
  8440. m.AddBotType(v)
  8441. return nil
  8442. }
  8443. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8444. }
  8445. // ClearedFields returns all nullable fields that were cleared during this
  8446. // mutation.
  8447. func (m *ChatRecordsMutation) ClearedFields() []string {
  8448. var fields []string
  8449. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8450. fields = append(fields, chatrecords.FieldDeletedAt)
  8451. }
  8452. return fields
  8453. }
  8454. // FieldCleared returns a boolean indicating if a field with the given name was
  8455. // cleared in this mutation.
  8456. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8457. _, ok := m.clearedFields[name]
  8458. return ok
  8459. }
  8460. // ClearField clears the value of the field with the given name. It returns an
  8461. // error if the field is not defined in the schema.
  8462. func (m *ChatRecordsMutation) ClearField(name string) error {
  8463. switch name {
  8464. case chatrecords.FieldDeletedAt:
  8465. m.ClearDeletedAt()
  8466. return nil
  8467. }
  8468. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8469. }
  8470. // ResetField resets all changes in the mutation for the field with the given name.
  8471. // It returns an error if the field is not defined in the schema.
  8472. func (m *ChatRecordsMutation) ResetField(name string) error {
  8473. switch name {
  8474. case chatrecords.FieldCreatedAt:
  8475. m.ResetCreatedAt()
  8476. return nil
  8477. case chatrecords.FieldUpdatedAt:
  8478. m.ResetUpdatedAt()
  8479. return nil
  8480. case chatrecords.FieldDeletedAt:
  8481. m.ResetDeletedAt()
  8482. return nil
  8483. case chatrecords.FieldContent:
  8484. m.ResetContent()
  8485. return nil
  8486. case chatrecords.FieldContentType:
  8487. m.ResetContentType()
  8488. return nil
  8489. case chatrecords.FieldSessionID:
  8490. m.ResetSessionID()
  8491. return nil
  8492. case chatrecords.FieldUserID:
  8493. m.ResetUserID()
  8494. return nil
  8495. case chatrecords.FieldBotID:
  8496. m.ResetBotID()
  8497. return nil
  8498. case chatrecords.FieldBotType:
  8499. m.ResetBotType()
  8500. return nil
  8501. }
  8502. return fmt.Errorf("unknown ChatRecords field %s", name)
  8503. }
  8504. // AddedEdges returns all edge names that were set/added in this mutation.
  8505. func (m *ChatRecordsMutation) AddedEdges() []string {
  8506. edges := make([]string, 0, 0)
  8507. return edges
  8508. }
  8509. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8510. // name in this mutation.
  8511. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8512. return nil
  8513. }
  8514. // RemovedEdges returns all edge names that were removed in this mutation.
  8515. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8516. edges := make([]string, 0, 0)
  8517. return edges
  8518. }
  8519. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8520. // the given name in this mutation.
  8521. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8522. return nil
  8523. }
  8524. // ClearedEdges returns all edge names that were cleared in this mutation.
  8525. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8526. edges := make([]string, 0, 0)
  8527. return edges
  8528. }
  8529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8530. // was cleared in this mutation.
  8531. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8532. return false
  8533. }
  8534. // ClearEdge clears the value of the edge with the given name. It returns an error
  8535. // if that edge is not defined in the schema.
  8536. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8537. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8538. }
  8539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8540. // It returns an error if the edge is not defined in the schema.
  8541. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8542. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8543. }
  8544. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8545. type ChatSessionMutation struct {
  8546. config
  8547. op Op
  8548. typ string
  8549. id *uint64
  8550. created_at *time.Time
  8551. updated_at *time.Time
  8552. deleted_at *time.Time
  8553. name *string
  8554. user_id *uint64
  8555. adduser_id *int64
  8556. bot_id *uint64
  8557. addbot_id *int64
  8558. bot_type *uint8
  8559. addbot_type *int8
  8560. clearedFields map[string]struct{}
  8561. done bool
  8562. oldValue func(context.Context) (*ChatSession, error)
  8563. predicates []predicate.ChatSession
  8564. }
  8565. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8566. // chatsessionOption allows management of the mutation configuration using functional options.
  8567. type chatsessionOption func(*ChatSessionMutation)
  8568. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8569. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8570. m := &ChatSessionMutation{
  8571. config: c,
  8572. op: op,
  8573. typ: TypeChatSession,
  8574. clearedFields: make(map[string]struct{}),
  8575. }
  8576. for _, opt := range opts {
  8577. opt(m)
  8578. }
  8579. return m
  8580. }
  8581. // withChatSessionID sets the ID field of the mutation.
  8582. func withChatSessionID(id uint64) chatsessionOption {
  8583. return func(m *ChatSessionMutation) {
  8584. var (
  8585. err error
  8586. once sync.Once
  8587. value *ChatSession
  8588. )
  8589. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8590. once.Do(func() {
  8591. if m.done {
  8592. err = errors.New("querying old values post mutation is not allowed")
  8593. } else {
  8594. value, err = m.Client().ChatSession.Get(ctx, id)
  8595. }
  8596. })
  8597. return value, err
  8598. }
  8599. m.id = &id
  8600. }
  8601. }
  8602. // withChatSession sets the old ChatSession of the mutation.
  8603. func withChatSession(node *ChatSession) chatsessionOption {
  8604. return func(m *ChatSessionMutation) {
  8605. m.oldValue = func(context.Context) (*ChatSession, error) {
  8606. return node, nil
  8607. }
  8608. m.id = &node.ID
  8609. }
  8610. }
  8611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8612. // executed in a transaction (ent.Tx), a transactional client is returned.
  8613. func (m ChatSessionMutation) Client() *Client {
  8614. client := &Client{config: m.config}
  8615. client.init()
  8616. return client
  8617. }
  8618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8619. // it returns an error otherwise.
  8620. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8621. if _, ok := m.driver.(*txDriver); !ok {
  8622. return nil, errors.New("ent: mutation is not running in a transaction")
  8623. }
  8624. tx := &Tx{config: m.config}
  8625. tx.init()
  8626. return tx, nil
  8627. }
  8628. // SetID sets the value of the id field. Note that this
  8629. // operation is only accepted on creation of ChatSession entities.
  8630. func (m *ChatSessionMutation) SetID(id uint64) {
  8631. m.id = &id
  8632. }
  8633. // ID returns the ID value in the mutation. Note that the ID is only available
  8634. // if it was provided to the builder or after it was returned from the database.
  8635. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8636. if m.id == nil {
  8637. return
  8638. }
  8639. return *m.id, true
  8640. }
  8641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8642. // That means, if the mutation is applied within a transaction with an isolation level such
  8643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8644. // or updated by the mutation.
  8645. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8646. switch {
  8647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8648. id, exists := m.ID()
  8649. if exists {
  8650. return []uint64{id}, nil
  8651. }
  8652. fallthrough
  8653. case m.op.Is(OpUpdate | OpDelete):
  8654. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8655. default:
  8656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8657. }
  8658. }
  8659. // SetCreatedAt sets the "created_at" field.
  8660. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8661. m.created_at = &t
  8662. }
  8663. // CreatedAt returns the value of the "created_at" field in the mutation.
  8664. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8665. v := m.created_at
  8666. if v == nil {
  8667. return
  8668. }
  8669. return *v, true
  8670. }
  8671. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8672. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8674. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8675. if !m.op.Is(OpUpdateOne) {
  8676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8677. }
  8678. if m.id == nil || m.oldValue == nil {
  8679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8680. }
  8681. oldValue, err := m.oldValue(ctx)
  8682. if err != nil {
  8683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8684. }
  8685. return oldValue.CreatedAt, nil
  8686. }
  8687. // ResetCreatedAt resets all changes to the "created_at" field.
  8688. func (m *ChatSessionMutation) ResetCreatedAt() {
  8689. m.created_at = nil
  8690. }
  8691. // SetUpdatedAt sets the "updated_at" field.
  8692. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8693. m.updated_at = &t
  8694. }
  8695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8696. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8697. v := m.updated_at
  8698. if v == nil {
  8699. return
  8700. }
  8701. return *v, true
  8702. }
  8703. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8704. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8706. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8707. if !m.op.Is(OpUpdateOne) {
  8708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8709. }
  8710. if m.id == nil || m.oldValue == nil {
  8711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8712. }
  8713. oldValue, err := m.oldValue(ctx)
  8714. if err != nil {
  8715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8716. }
  8717. return oldValue.UpdatedAt, nil
  8718. }
  8719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8720. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8721. m.updated_at = nil
  8722. }
  8723. // SetDeletedAt sets the "deleted_at" field.
  8724. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8725. m.deleted_at = &t
  8726. }
  8727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8728. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8729. v := m.deleted_at
  8730. if v == nil {
  8731. return
  8732. }
  8733. return *v, true
  8734. }
  8735. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8736. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8738. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8739. if !m.op.Is(OpUpdateOne) {
  8740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8741. }
  8742. if m.id == nil || m.oldValue == nil {
  8743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8744. }
  8745. oldValue, err := m.oldValue(ctx)
  8746. if err != nil {
  8747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8748. }
  8749. return oldValue.DeletedAt, nil
  8750. }
  8751. // ClearDeletedAt clears the value of the "deleted_at" field.
  8752. func (m *ChatSessionMutation) ClearDeletedAt() {
  8753. m.deleted_at = nil
  8754. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8755. }
  8756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8757. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8758. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8759. return ok
  8760. }
  8761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8762. func (m *ChatSessionMutation) ResetDeletedAt() {
  8763. m.deleted_at = nil
  8764. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8765. }
  8766. // SetName sets the "name" field.
  8767. func (m *ChatSessionMutation) SetName(s string) {
  8768. m.name = &s
  8769. }
  8770. // Name returns the value of the "name" field in the mutation.
  8771. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8772. v := m.name
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldName returns the old "name" field's value of the ChatSession entity.
  8779. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldName requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8791. }
  8792. return oldValue.Name, nil
  8793. }
  8794. // ResetName resets all changes to the "name" field.
  8795. func (m *ChatSessionMutation) ResetName() {
  8796. m.name = nil
  8797. }
  8798. // SetUserID sets the "user_id" field.
  8799. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8800. m.user_id = &u
  8801. m.adduser_id = nil
  8802. }
  8803. // UserID returns the value of the "user_id" field in the mutation.
  8804. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8805. v := m.user_id
  8806. if v == nil {
  8807. return
  8808. }
  8809. return *v, true
  8810. }
  8811. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8812. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8814. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8815. if !m.op.Is(OpUpdateOne) {
  8816. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8817. }
  8818. if m.id == nil || m.oldValue == nil {
  8819. return v, errors.New("OldUserID requires an ID field in the mutation")
  8820. }
  8821. oldValue, err := m.oldValue(ctx)
  8822. if err != nil {
  8823. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8824. }
  8825. return oldValue.UserID, nil
  8826. }
  8827. // AddUserID adds u to the "user_id" field.
  8828. func (m *ChatSessionMutation) AddUserID(u int64) {
  8829. if m.adduser_id != nil {
  8830. *m.adduser_id += u
  8831. } else {
  8832. m.adduser_id = &u
  8833. }
  8834. }
  8835. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8836. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8837. v := m.adduser_id
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // ResetUserID resets all changes to the "user_id" field.
  8844. func (m *ChatSessionMutation) ResetUserID() {
  8845. m.user_id = nil
  8846. m.adduser_id = nil
  8847. }
  8848. // SetBotID sets the "bot_id" field.
  8849. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8850. m.bot_id = &u
  8851. m.addbot_id = nil
  8852. }
  8853. // BotID returns the value of the "bot_id" field in the mutation.
  8854. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8855. v := m.bot_id
  8856. if v == nil {
  8857. return
  8858. }
  8859. return *v, true
  8860. }
  8861. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8862. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8864. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8865. if !m.op.Is(OpUpdateOne) {
  8866. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8867. }
  8868. if m.id == nil || m.oldValue == nil {
  8869. return v, errors.New("OldBotID requires an ID field in the mutation")
  8870. }
  8871. oldValue, err := m.oldValue(ctx)
  8872. if err != nil {
  8873. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8874. }
  8875. return oldValue.BotID, nil
  8876. }
  8877. // AddBotID adds u to the "bot_id" field.
  8878. func (m *ChatSessionMutation) AddBotID(u int64) {
  8879. if m.addbot_id != nil {
  8880. *m.addbot_id += u
  8881. } else {
  8882. m.addbot_id = &u
  8883. }
  8884. }
  8885. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8886. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8887. v := m.addbot_id
  8888. if v == nil {
  8889. return
  8890. }
  8891. return *v, true
  8892. }
  8893. // ResetBotID resets all changes to the "bot_id" field.
  8894. func (m *ChatSessionMutation) ResetBotID() {
  8895. m.bot_id = nil
  8896. m.addbot_id = nil
  8897. }
  8898. // SetBotType sets the "bot_type" field.
  8899. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8900. m.bot_type = &u
  8901. m.addbot_type = nil
  8902. }
  8903. // BotType returns the value of the "bot_type" field in the mutation.
  8904. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8905. v := m.bot_type
  8906. if v == nil {
  8907. return
  8908. }
  8909. return *v, true
  8910. }
  8911. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8912. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8914. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8915. if !m.op.Is(OpUpdateOne) {
  8916. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8917. }
  8918. if m.id == nil || m.oldValue == nil {
  8919. return v, errors.New("OldBotType requires an ID field in the mutation")
  8920. }
  8921. oldValue, err := m.oldValue(ctx)
  8922. if err != nil {
  8923. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8924. }
  8925. return oldValue.BotType, nil
  8926. }
  8927. // AddBotType adds u to the "bot_type" field.
  8928. func (m *ChatSessionMutation) AddBotType(u int8) {
  8929. if m.addbot_type != nil {
  8930. *m.addbot_type += u
  8931. } else {
  8932. m.addbot_type = &u
  8933. }
  8934. }
  8935. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8936. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8937. v := m.addbot_type
  8938. if v == nil {
  8939. return
  8940. }
  8941. return *v, true
  8942. }
  8943. // ResetBotType resets all changes to the "bot_type" field.
  8944. func (m *ChatSessionMutation) ResetBotType() {
  8945. m.bot_type = nil
  8946. m.addbot_type = nil
  8947. }
  8948. // Where appends a list predicates to the ChatSessionMutation builder.
  8949. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8950. m.predicates = append(m.predicates, ps...)
  8951. }
  8952. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8953. // users can use type-assertion to append predicates that do not depend on any generated package.
  8954. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8955. p := make([]predicate.ChatSession, len(ps))
  8956. for i := range ps {
  8957. p[i] = ps[i]
  8958. }
  8959. m.Where(p...)
  8960. }
  8961. // Op returns the operation name.
  8962. func (m *ChatSessionMutation) Op() Op {
  8963. return m.op
  8964. }
  8965. // SetOp allows setting the mutation operation.
  8966. func (m *ChatSessionMutation) SetOp(op Op) {
  8967. m.op = op
  8968. }
  8969. // Type returns the node type of this mutation (ChatSession).
  8970. func (m *ChatSessionMutation) Type() string {
  8971. return m.typ
  8972. }
  8973. // Fields returns all fields that were changed during this mutation. Note that in
  8974. // order to get all numeric fields that were incremented/decremented, call
  8975. // AddedFields().
  8976. func (m *ChatSessionMutation) Fields() []string {
  8977. fields := make([]string, 0, 7)
  8978. if m.created_at != nil {
  8979. fields = append(fields, chatsession.FieldCreatedAt)
  8980. }
  8981. if m.updated_at != nil {
  8982. fields = append(fields, chatsession.FieldUpdatedAt)
  8983. }
  8984. if m.deleted_at != nil {
  8985. fields = append(fields, chatsession.FieldDeletedAt)
  8986. }
  8987. if m.name != nil {
  8988. fields = append(fields, chatsession.FieldName)
  8989. }
  8990. if m.user_id != nil {
  8991. fields = append(fields, chatsession.FieldUserID)
  8992. }
  8993. if m.bot_id != nil {
  8994. fields = append(fields, chatsession.FieldBotID)
  8995. }
  8996. if m.bot_type != nil {
  8997. fields = append(fields, chatsession.FieldBotType)
  8998. }
  8999. return fields
  9000. }
  9001. // Field returns the value of a field with the given name. The second boolean
  9002. // return value indicates that this field was not set, or was not defined in the
  9003. // schema.
  9004. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9005. switch name {
  9006. case chatsession.FieldCreatedAt:
  9007. return m.CreatedAt()
  9008. case chatsession.FieldUpdatedAt:
  9009. return m.UpdatedAt()
  9010. case chatsession.FieldDeletedAt:
  9011. return m.DeletedAt()
  9012. case chatsession.FieldName:
  9013. return m.Name()
  9014. case chatsession.FieldUserID:
  9015. return m.UserID()
  9016. case chatsession.FieldBotID:
  9017. return m.BotID()
  9018. case chatsession.FieldBotType:
  9019. return m.BotType()
  9020. }
  9021. return nil, false
  9022. }
  9023. // OldField returns the old value of the field from the database. An error is
  9024. // returned if the mutation operation is not UpdateOne, or the query to the
  9025. // database failed.
  9026. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9027. switch name {
  9028. case chatsession.FieldCreatedAt:
  9029. return m.OldCreatedAt(ctx)
  9030. case chatsession.FieldUpdatedAt:
  9031. return m.OldUpdatedAt(ctx)
  9032. case chatsession.FieldDeletedAt:
  9033. return m.OldDeletedAt(ctx)
  9034. case chatsession.FieldName:
  9035. return m.OldName(ctx)
  9036. case chatsession.FieldUserID:
  9037. return m.OldUserID(ctx)
  9038. case chatsession.FieldBotID:
  9039. return m.OldBotID(ctx)
  9040. case chatsession.FieldBotType:
  9041. return m.OldBotType(ctx)
  9042. }
  9043. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9044. }
  9045. // SetField sets the value of a field with the given name. It returns an error if
  9046. // the field is not defined in the schema, or if the type mismatched the field
  9047. // type.
  9048. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9049. switch name {
  9050. case chatsession.FieldCreatedAt:
  9051. v, ok := value.(time.Time)
  9052. if !ok {
  9053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9054. }
  9055. m.SetCreatedAt(v)
  9056. return nil
  9057. case chatsession.FieldUpdatedAt:
  9058. v, ok := value.(time.Time)
  9059. if !ok {
  9060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9061. }
  9062. m.SetUpdatedAt(v)
  9063. return nil
  9064. case chatsession.FieldDeletedAt:
  9065. v, ok := value.(time.Time)
  9066. if !ok {
  9067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9068. }
  9069. m.SetDeletedAt(v)
  9070. return nil
  9071. case chatsession.FieldName:
  9072. v, ok := value.(string)
  9073. if !ok {
  9074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9075. }
  9076. m.SetName(v)
  9077. return nil
  9078. case chatsession.FieldUserID:
  9079. v, ok := value.(uint64)
  9080. if !ok {
  9081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9082. }
  9083. m.SetUserID(v)
  9084. return nil
  9085. case chatsession.FieldBotID:
  9086. v, ok := value.(uint64)
  9087. if !ok {
  9088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9089. }
  9090. m.SetBotID(v)
  9091. return nil
  9092. case chatsession.FieldBotType:
  9093. v, ok := value.(uint8)
  9094. if !ok {
  9095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9096. }
  9097. m.SetBotType(v)
  9098. return nil
  9099. }
  9100. return fmt.Errorf("unknown ChatSession field %s", name)
  9101. }
  9102. // AddedFields returns all numeric fields that were incremented/decremented during
  9103. // this mutation.
  9104. func (m *ChatSessionMutation) AddedFields() []string {
  9105. var fields []string
  9106. if m.adduser_id != nil {
  9107. fields = append(fields, chatsession.FieldUserID)
  9108. }
  9109. if m.addbot_id != nil {
  9110. fields = append(fields, chatsession.FieldBotID)
  9111. }
  9112. if m.addbot_type != nil {
  9113. fields = append(fields, chatsession.FieldBotType)
  9114. }
  9115. return fields
  9116. }
  9117. // AddedField returns the numeric value that was incremented/decremented on a field
  9118. // with the given name. The second boolean return value indicates that this field
  9119. // was not set, or was not defined in the schema.
  9120. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9121. switch name {
  9122. case chatsession.FieldUserID:
  9123. return m.AddedUserID()
  9124. case chatsession.FieldBotID:
  9125. return m.AddedBotID()
  9126. case chatsession.FieldBotType:
  9127. return m.AddedBotType()
  9128. }
  9129. return nil, false
  9130. }
  9131. // AddField adds the value to the field with the given name. It returns an error if
  9132. // the field is not defined in the schema, or if the type mismatched the field
  9133. // type.
  9134. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9135. switch name {
  9136. case chatsession.FieldUserID:
  9137. v, ok := value.(int64)
  9138. if !ok {
  9139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9140. }
  9141. m.AddUserID(v)
  9142. return nil
  9143. case chatsession.FieldBotID:
  9144. v, ok := value.(int64)
  9145. if !ok {
  9146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9147. }
  9148. m.AddBotID(v)
  9149. return nil
  9150. case chatsession.FieldBotType:
  9151. v, ok := value.(int8)
  9152. if !ok {
  9153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9154. }
  9155. m.AddBotType(v)
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9159. }
  9160. // ClearedFields returns all nullable fields that were cleared during this
  9161. // mutation.
  9162. func (m *ChatSessionMutation) ClearedFields() []string {
  9163. var fields []string
  9164. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9165. fields = append(fields, chatsession.FieldDeletedAt)
  9166. }
  9167. return fields
  9168. }
  9169. // FieldCleared returns a boolean indicating if a field with the given name was
  9170. // cleared in this mutation.
  9171. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9172. _, ok := m.clearedFields[name]
  9173. return ok
  9174. }
  9175. // ClearField clears the value of the field with the given name. It returns an
  9176. // error if the field is not defined in the schema.
  9177. func (m *ChatSessionMutation) ClearField(name string) error {
  9178. switch name {
  9179. case chatsession.FieldDeletedAt:
  9180. m.ClearDeletedAt()
  9181. return nil
  9182. }
  9183. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9184. }
  9185. // ResetField resets all changes in the mutation for the field with the given name.
  9186. // It returns an error if the field is not defined in the schema.
  9187. func (m *ChatSessionMutation) ResetField(name string) error {
  9188. switch name {
  9189. case chatsession.FieldCreatedAt:
  9190. m.ResetCreatedAt()
  9191. return nil
  9192. case chatsession.FieldUpdatedAt:
  9193. m.ResetUpdatedAt()
  9194. return nil
  9195. case chatsession.FieldDeletedAt:
  9196. m.ResetDeletedAt()
  9197. return nil
  9198. case chatsession.FieldName:
  9199. m.ResetName()
  9200. return nil
  9201. case chatsession.FieldUserID:
  9202. m.ResetUserID()
  9203. return nil
  9204. case chatsession.FieldBotID:
  9205. m.ResetBotID()
  9206. return nil
  9207. case chatsession.FieldBotType:
  9208. m.ResetBotType()
  9209. return nil
  9210. }
  9211. return fmt.Errorf("unknown ChatSession field %s", name)
  9212. }
  9213. // AddedEdges returns all edge names that were set/added in this mutation.
  9214. func (m *ChatSessionMutation) AddedEdges() []string {
  9215. edges := make([]string, 0, 0)
  9216. return edges
  9217. }
  9218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9219. // name in this mutation.
  9220. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9221. return nil
  9222. }
  9223. // RemovedEdges returns all edge names that were removed in this mutation.
  9224. func (m *ChatSessionMutation) RemovedEdges() []string {
  9225. edges := make([]string, 0, 0)
  9226. return edges
  9227. }
  9228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9229. // the given name in this mutation.
  9230. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9231. return nil
  9232. }
  9233. // ClearedEdges returns all edge names that were cleared in this mutation.
  9234. func (m *ChatSessionMutation) ClearedEdges() []string {
  9235. edges := make([]string, 0, 0)
  9236. return edges
  9237. }
  9238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9239. // was cleared in this mutation.
  9240. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9241. return false
  9242. }
  9243. // ClearEdge clears the value of the edge with the given name. It returns an error
  9244. // if that edge is not defined in the schema.
  9245. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9246. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9247. }
  9248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9249. // It returns an error if the edge is not defined in the schema.
  9250. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9251. return fmt.Errorf("unknown ChatSession edge %s", name)
  9252. }
  9253. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9254. type ContactMutation struct {
  9255. config
  9256. op Op
  9257. typ string
  9258. id *uint64
  9259. created_at *time.Time
  9260. updated_at *time.Time
  9261. status *uint8
  9262. addstatus *int8
  9263. deleted_at *time.Time
  9264. wx_wxid *string
  9265. _type *int
  9266. add_type *int
  9267. wxid *string
  9268. account *string
  9269. nickname *string
  9270. markname *string
  9271. headimg *string
  9272. sex *int
  9273. addsex *int
  9274. starrole *string
  9275. dontseeit *int
  9276. adddontseeit *int
  9277. dontseeme *int
  9278. adddontseeme *int
  9279. lag *string
  9280. gid *string
  9281. gname *string
  9282. v3 *string
  9283. organization_id *uint64
  9284. addorganization_id *int64
  9285. ctype *uint64
  9286. addctype *int64
  9287. cage *int
  9288. addcage *int
  9289. cname *string
  9290. carea *string
  9291. cbirthday *string
  9292. cbirtharea *string
  9293. cidcard_no *string
  9294. ctitle *string
  9295. cc *string
  9296. phone *string
  9297. clearedFields map[string]struct{}
  9298. contact_relationships map[uint64]struct{}
  9299. removedcontact_relationships map[uint64]struct{}
  9300. clearedcontact_relationships bool
  9301. contact_messages map[uint64]struct{}
  9302. removedcontact_messages map[uint64]struct{}
  9303. clearedcontact_messages bool
  9304. done bool
  9305. oldValue func(context.Context) (*Contact, error)
  9306. predicates []predicate.Contact
  9307. }
  9308. var _ ent.Mutation = (*ContactMutation)(nil)
  9309. // contactOption allows management of the mutation configuration using functional options.
  9310. type contactOption func(*ContactMutation)
  9311. // newContactMutation creates new mutation for the Contact entity.
  9312. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9313. m := &ContactMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeContact,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withContactID sets the ID field of the mutation.
  9325. func withContactID(id uint64) contactOption {
  9326. return func(m *ContactMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Contact
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Contact.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withContact sets the old Contact of the mutation.
  9346. func withContact(node *Contact) contactOption {
  9347. return func(m *ContactMutation) {
  9348. m.oldValue = func(context.Context) (*Contact, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m ContactMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m ContactMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Contact entities.
  9373. func (m *ContactMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *ContactMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9447. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *ContactMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetStatus sets the "status" field.
  9467. func (m *ContactMutation) SetStatus(u uint8) {
  9468. m.status = &u
  9469. m.addstatus = nil
  9470. }
  9471. // Status returns the value of the "status" field in the mutation.
  9472. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9473. v := m.status
  9474. if v == nil {
  9475. return
  9476. }
  9477. return *v, true
  9478. }
  9479. // OldStatus returns the old "status" field's value of the Contact entity.
  9480. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9482. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9483. if !m.op.Is(OpUpdateOne) {
  9484. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9485. }
  9486. if m.id == nil || m.oldValue == nil {
  9487. return v, errors.New("OldStatus requires an ID field in the mutation")
  9488. }
  9489. oldValue, err := m.oldValue(ctx)
  9490. if err != nil {
  9491. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9492. }
  9493. return oldValue.Status, nil
  9494. }
  9495. // AddStatus adds u to the "status" field.
  9496. func (m *ContactMutation) AddStatus(u int8) {
  9497. if m.addstatus != nil {
  9498. *m.addstatus += u
  9499. } else {
  9500. m.addstatus = &u
  9501. }
  9502. }
  9503. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9504. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9505. v := m.addstatus
  9506. if v == nil {
  9507. return
  9508. }
  9509. return *v, true
  9510. }
  9511. // ClearStatus clears the value of the "status" field.
  9512. func (m *ContactMutation) ClearStatus() {
  9513. m.status = nil
  9514. m.addstatus = nil
  9515. m.clearedFields[contact.FieldStatus] = struct{}{}
  9516. }
  9517. // StatusCleared returns if the "status" field was cleared in this mutation.
  9518. func (m *ContactMutation) StatusCleared() bool {
  9519. _, ok := m.clearedFields[contact.FieldStatus]
  9520. return ok
  9521. }
  9522. // ResetStatus resets all changes to the "status" field.
  9523. func (m *ContactMutation) ResetStatus() {
  9524. m.status = nil
  9525. m.addstatus = nil
  9526. delete(m.clearedFields, contact.FieldStatus)
  9527. }
  9528. // SetDeletedAt sets the "deleted_at" field.
  9529. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9530. m.deleted_at = &t
  9531. }
  9532. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9533. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9534. v := m.deleted_at
  9535. if v == nil {
  9536. return
  9537. }
  9538. return *v, true
  9539. }
  9540. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9543. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9544. if !m.op.Is(OpUpdateOne) {
  9545. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9546. }
  9547. if m.id == nil || m.oldValue == nil {
  9548. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9549. }
  9550. oldValue, err := m.oldValue(ctx)
  9551. if err != nil {
  9552. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9553. }
  9554. return oldValue.DeletedAt, nil
  9555. }
  9556. // ClearDeletedAt clears the value of the "deleted_at" field.
  9557. func (m *ContactMutation) ClearDeletedAt() {
  9558. m.deleted_at = nil
  9559. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9560. }
  9561. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9562. func (m *ContactMutation) DeletedAtCleared() bool {
  9563. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9564. return ok
  9565. }
  9566. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9567. func (m *ContactMutation) ResetDeletedAt() {
  9568. m.deleted_at = nil
  9569. delete(m.clearedFields, contact.FieldDeletedAt)
  9570. }
  9571. // SetWxWxid sets the "wx_wxid" field.
  9572. func (m *ContactMutation) SetWxWxid(s string) {
  9573. m.wx_wxid = &s
  9574. }
  9575. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9576. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9577. v := m.wx_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9584. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9596. }
  9597. return oldValue.WxWxid, nil
  9598. }
  9599. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9600. func (m *ContactMutation) ResetWxWxid() {
  9601. m.wx_wxid = nil
  9602. }
  9603. // SetType sets the "type" field.
  9604. func (m *ContactMutation) SetType(i int) {
  9605. m._type = &i
  9606. m.add_type = nil
  9607. }
  9608. // GetType returns the value of the "type" field in the mutation.
  9609. func (m *ContactMutation) GetType() (r int, exists bool) {
  9610. v := m._type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldType returns the old "type" field's value of the Contact entity.
  9617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9629. }
  9630. return oldValue.Type, nil
  9631. }
  9632. // AddType adds i to the "type" field.
  9633. func (m *ContactMutation) AddType(i int) {
  9634. if m.add_type != nil {
  9635. *m.add_type += i
  9636. } else {
  9637. m.add_type = &i
  9638. }
  9639. }
  9640. // AddedType returns the value that was added to the "type" field in this mutation.
  9641. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9642. v := m.add_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ClearType clears the value of the "type" field.
  9649. func (m *ContactMutation) ClearType() {
  9650. m._type = nil
  9651. m.add_type = nil
  9652. m.clearedFields[contact.FieldType] = struct{}{}
  9653. }
  9654. // TypeCleared returns if the "type" field was cleared in this mutation.
  9655. func (m *ContactMutation) TypeCleared() bool {
  9656. _, ok := m.clearedFields[contact.FieldType]
  9657. return ok
  9658. }
  9659. // ResetType resets all changes to the "type" field.
  9660. func (m *ContactMutation) ResetType() {
  9661. m._type = nil
  9662. m.add_type = nil
  9663. delete(m.clearedFields, contact.FieldType)
  9664. }
  9665. // SetWxid sets the "wxid" field.
  9666. func (m *ContactMutation) SetWxid(s string) {
  9667. m.wxid = &s
  9668. }
  9669. // Wxid returns the value of the "wxid" field in the mutation.
  9670. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9671. v := m.wxid
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldWxid requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9690. }
  9691. return oldValue.Wxid, nil
  9692. }
  9693. // ResetWxid resets all changes to the "wxid" field.
  9694. func (m *ContactMutation) ResetWxid() {
  9695. m.wxid = nil
  9696. }
  9697. // SetAccount sets the "account" field.
  9698. func (m *ContactMutation) SetAccount(s string) {
  9699. m.account = &s
  9700. }
  9701. // Account returns the value of the "account" field in the mutation.
  9702. func (m *ContactMutation) Account() (r string, exists bool) {
  9703. v := m.account
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // OldAccount returns the old "account" field's value of the Contact entity.
  9710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9712. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9713. if !m.op.Is(OpUpdateOne) {
  9714. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9715. }
  9716. if m.id == nil || m.oldValue == nil {
  9717. return v, errors.New("OldAccount requires an ID field in the mutation")
  9718. }
  9719. oldValue, err := m.oldValue(ctx)
  9720. if err != nil {
  9721. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9722. }
  9723. return oldValue.Account, nil
  9724. }
  9725. // ResetAccount resets all changes to the "account" field.
  9726. func (m *ContactMutation) ResetAccount() {
  9727. m.account = nil
  9728. }
  9729. // SetNickname sets the "nickname" field.
  9730. func (m *ContactMutation) SetNickname(s string) {
  9731. m.nickname = &s
  9732. }
  9733. // Nickname returns the value of the "nickname" field in the mutation.
  9734. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9735. v := m.nickname
  9736. if v == nil {
  9737. return
  9738. }
  9739. return *v, true
  9740. }
  9741. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9744. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9745. if !m.op.Is(OpUpdateOne) {
  9746. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9747. }
  9748. if m.id == nil || m.oldValue == nil {
  9749. return v, errors.New("OldNickname requires an ID field in the mutation")
  9750. }
  9751. oldValue, err := m.oldValue(ctx)
  9752. if err != nil {
  9753. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9754. }
  9755. return oldValue.Nickname, nil
  9756. }
  9757. // ResetNickname resets all changes to the "nickname" field.
  9758. func (m *ContactMutation) ResetNickname() {
  9759. m.nickname = nil
  9760. }
  9761. // SetMarkname sets the "markname" field.
  9762. func (m *ContactMutation) SetMarkname(s string) {
  9763. m.markname = &s
  9764. }
  9765. // Markname returns the value of the "markname" field in the mutation.
  9766. func (m *ContactMutation) Markname() (r string, exists bool) {
  9767. v := m.markname
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9774. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9776. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9782. }
  9783. oldValue, err := m.oldValue(ctx)
  9784. if err != nil {
  9785. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9786. }
  9787. return oldValue.Markname, nil
  9788. }
  9789. // ResetMarkname resets all changes to the "markname" field.
  9790. func (m *ContactMutation) ResetMarkname() {
  9791. m.markname = nil
  9792. }
  9793. // SetHeadimg sets the "headimg" field.
  9794. func (m *ContactMutation) SetHeadimg(s string) {
  9795. m.headimg = &s
  9796. }
  9797. // Headimg returns the value of the "headimg" field in the mutation.
  9798. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9799. v := m.headimg
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9806. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9808. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9809. if !m.op.Is(OpUpdateOne) {
  9810. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9811. }
  9812. if m.id == nil || m.oldValue == nil {
  9813. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9814. }
  9815. oldValue, err := m.oldValue(ctx)
  9816. if err != nil {
  9817. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9818. }
  9819. return oldValue.Headimg, nil
  9820. }
  9821. // ResetHeadimg resets all changes to the "headimg" field.
  9822. func (m *ContactMutation) ResetHeadimg() {
  9823. m.headimg = nil
  9824. }
  9825. // SetSex sets the "sex" field.
  9826. func (m *ContactMutation) SetSex(i int) {
  9827. m.sex = &i
  9828. m.addsex = nil
  9829. }
  9830. // Sex returns the value of the "sex" field in the mutation.
  9831. func (m *ContactMutation) Sex() (r int, exists bool) {
  9832. v := m.sex
  9833. if v == nil {
  9834. return
  9835. }
  9836. return *v, true
  9837. }
  9838. // OldSex returns the old "sex" field's value of the Contact entity.
  9839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9841. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9842. if !m.op.Is(OpUpdateOne) {
  9843. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9844. }
  9845. if m.id == nil || m.oldValue == nil {
  9846. return v, errors.New("OldSex requires an ID field in the mutation")
  9847. }
  9848. oldValue, err := m.oldValue(ctx)
  9849. if err != nil {
  9850. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9851. }
  9852. return oldValue.Sex, nil
  9853. }
  9854. // AddSex adds i to the "sex" field.
  9855. func (m *ContactMutation) AddSex(i int) {
  9856. if m.addsex != nil {
  9857. *m.addsex += i
  9858. } else {
  9859. m.addsex = &i
  9860. }
  9861. }
  9862. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9863. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9864. v := m.addsex
  9865. if v == nil {
  9866. return
  9867. }
  9868. return *v, true
  9869. }
  9870. // ResetSex resets all changes to the "sex" field.
  9871. func (m *ContactMutation) ResetSex() {
  9872. m.sex = nil
  9873. m.addsex = nil
  9874. }
  9875. // SetStarrole sets the "starrole" field.
  9876. func (m *ContactMutation) SetStarrole(s string) {
  9877. m.starrole = &s
  9878. }
  9879. // Starrole returns the value of the "starrole" field in the mutation.
  9880. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9881. v := m.starrole
  9882. if v == nil {
  9883. return
  9884. }
  9885. return *v, true
  9886. }
  9887. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9888. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9890. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9891. if !m.op.Is(OpUpdateOne) {
  9892. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9893. }
  9894. if m.id == nil || m.oldValue == nil {
  9895. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9896. }
  9897. oldValue, err := m.oldValue(ctx)
  9898. if err != nil {
  9899. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9900. }
  9901. return oldValue.Starrole, nil
  9902. }
  9903. // ResetStarrole resets all changes to the "starrole" field.
  9904. func (m *ContactMutation) ResetStarrole() {
  9905. m.starrole = nil
  9906. }
  9907. // SetDontseeit sets the "dontseeit" field.
  9908. func (m *ContactMutation) SetDontseeit(i int) {
  9909. m.dontseeit = &i
  9910. m.adddontseeit = nil
  9911. }
  9912. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9913. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9914. v := m.dontseeit
  9915. if v == nil {
  9916. return
  9917. }
  9918. return *v, true
  9919. }
  9920. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9923. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9924. if !m.op.Is(OpUpdateOne) {
  9925. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9926. }
  9927. if m.id == nil || m.oldValue == nil {
  9928. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9929. }
  9930. oldValue, err := m.oldValue(ctx)
  9931. if err != nil {
  9932. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9933. }
  9934. return oldValue.Dontseeit, nil
  9935. }
  9936. // AddDontseeit adds i to the "dontseeit" field.
  9937. func (m *ContactMutation) AddDontseeit(i int) {
  9938. if m.adddontseeit != nil {
  9939. *m.adddontseeit += i
  9940. } else {
  9941. m.adddontseeit = &i
  9942. }
  9943. }
  9944. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9945. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9946. v := m.adddontseeit
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // ResetDontseeit resets all changes to the "dontseeit" field.
  9953. func (m *ContactMutation) ResetDontseeit() {
  9954. m.dontseeit = nil
  9955. m.adddontseeit = nil
  9956. }
  9957. // SetDontseeme sets the "dontseeme" field.
  9958. func (m *ContactMutation) SetDontseeme(i int) {
  9959. m.dontseeme = &i
  9960. m.adddontseeme = nil
  9961. }
  9962. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9963. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9964. v := m.dontseeme
  9965. if v == nil {
  9966. return
  9967. }
  9968. return *v, true
  9969. }
  9970. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9971. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9973. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9974. if !m.op.Is(OpUpdateOne) {
  9975. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9976. }
  9977. if m.id == nil || m.oldValue == nil {
  9978. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9979. }
  9980. oldValue, err := m.oldValue(ctx)
  9981. if err != nil {
  9982. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9983. }
  9984. return oldValue.Dontseeme, nil
  9985. }
  9986. // AddDontseeme adds i to the "dontseeme" field.
  9987. func (m *ContactMutation) AddDontseeme(i int) {
  9988. if m.adddontseeme != nil {
  9989. *m.adddontseeme += i
  9990. } else {
  9991. m.adddontseeme = &i
  9992. }
  9993. }
  9994. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9995. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9996. v := m.adddontseeme
  9997. if v == nil {
  9998. return
  9999. }
  10000. return *v, true
  10001. }
  10002. // ResetDontseeme resets all changes to the "dontseeme" field.
  10003. func (m *ContactMutation) ResetDontseeme() {
  10004. m.dontseeme = nil
  10005. m.adddontseeme = nil
  10006. }
  10007. // SetLag sets the "lag" field.
  10008. func (m *ContactMutation) SetLag(s string) {
  10009. m.lag = &s
  10010. }
  10011. // Lag returns the value of the "lag" field in the mutation.
  10012. func (m *ContactMutation) Lag() (r string, exists bool) {
  10013. v := m.lag
  10014. if v == nil {
  10015. return
  10016. }
  10017. return *v, true
  10018. }
  10019. // OldLag returns the old "lag" field's value of the Contact entity.
  10020. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10022. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10023. if !m.op.Is(OpUpdateOne) {
  10024. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10025. }
  10026. if m.id == nil || m.oldValue == nil {
  10027. return v, errors.New("OldLag requires an ID field in the mutation")
  10028. }
  10029. oldValue, err := m.oldValue(ctx)
  10030. if err != nil {
  10031. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10032. }
  10033. return oldValue.Lag, nil
  10034. }
  10035. // ResetLag resets all changes to the "lag" field.
  10036. func (m *ContactMutation) ResetLag() {
  10037. m.lag = nil
  10038. }
  10039. // SetGid sets the "gid" field.
  10040. func (m *ContactMutation) SetGid(s string) {
  10041. m.gid = &s
  10042. }
  10043. // Gid returns the value of the "gid" field in the mutation.
  10044. func (m *ContactMutation) Gid() (r string, exists bool) {
  10045. v := m.gid
  10046. if v == nil {
  10047. return
  10048. }
  10049. return *v, true
  10050. }
  10051. // OldGid returns the old "gid" field's value of the Contact entity.
  10052. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10054. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10055. if !m.op.Is(OpUpdateOne) {
  10056. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10057. }
  10058. if m.id == nil || m.oldValue == nil {
  10059. return v, errors.New("OldGid requires an ID field in the mutation")
  10060. }
  10061. oldValue, err := m.oldValue(ctx)
  10062. if err != nil {
  10063. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10064. }
  10065. return oldValue.Gid, nil
  10066. }
  10067. // ResetGid resets all changes to the "gid" field.
  10068. func (m *ContactMutation) ResetGid() {
  10069. m.gid = nil
  10070. }
  10071. // SetGname sets the "gname" field.
  10072. func (m *ContactMutation) SetGname(s string) {
  10073. m.gname = &s
  10074. }
  10075. // Gname returns the value of the "gname" field in the mutation.
  10076. func (m *ContactMutation) Gname() (r string, exists bool) {
  10077. v := m.gname
  10078. if v == nil {
  10079. return
  10080. }
  10081. return *v, true
  10082. }
  10083. // OldGname returns the old "gname" field's value of the Contact entity.
  10084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10086. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10087. if !m.op.Is(OpUpdateOne) {
  10088. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10089. }
  10090. if m.id == nil || m.oldValue == nil {
  10091. return v, errors.New("OldGname requires an ID field in the mutation")
  10092. }
  10093. oldValue, err := m.oldValue(ctx)
  10094. if err != nil {
  10095. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10096. }
  10097. return oldValue.Gname, nil
  10098. }
  10099. // ResetGname resets all changes to the "gname" field.
  10100. func (m *ContactMutation) ResetGname() {
  10101. m.gname = nil
  10102. }
  10103. // SetV3 sets the "v3" field.
  10104. func (m *ContactMutation) SetV3(s string) {
  10105. m.v3 = &s
  10106. }
  10107. // V3 returns the value of the "v3" field in the mutation.
  10108. func (m *ContactMutation) V3() (r string, exists bool) {
  10109. v := m.v3
  10110. if v == nil {
  10111. return
  10112. }
  10113. return *v, true
  10114. }
  10115. // OldV3 returns the old "v3" field's value of the Contact entity.
  10116. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10118. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10119. if !m.op.Is(OpUpdateOne) {
  10120. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10121. }
  10122. if m.id == nil || m.oldValue == nil {
  10123. return v, errors.New("OldV3 requires an ID field in the mutation")
  10124. }
  10125. oldValue, err := m.oldValue(ctx)
  10126. if err != nil {
  10127. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10128. }
  10129. return oldValue.V3, nil
  10130. }
  10131. // ResetV3 resets all changes to the "v3" field.
  10132. func (m *ContactMutation) ResetV3() {
  10133. m.v3 = nil
  10134. }
  10135. // SetOrganizationID sets the "organization_id" field.
  10136. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10137. m.organization_id = &u
  10138. m.addorganization_id = nil
  10139. }
  10140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10141. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10142. v := m.organization_id
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10149. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10151. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10157. }
  10158. oldValue, err := m.oldValue(ctx)
  10159. if err != nil {
  10160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10161. }
  10162. return oldValue.OrganizationID, nil
  10163. }
  10164. // AddOrganizationID adds u to the "organization_id" field.
  10165. func (m *ContactMutation) AddOrganizationID(u int64) {
  10166. if m.addorganization_id != nil {
  10167. *m.addorganization_id += u
  10168. } else {
  10169. m.addorganization_id = &u
  10170. }
  10171. }
  10172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10173. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10174. v := m.addorganization_id
  10175. if v == nil {
  10176. return
  10177. }
  10178. return *v, true
  10179. }
  10180. // ClearOrganizationID clears the value of the "organization_id" field.
  10181. func (m *ContactMutation) ClearOrganizationID() {
  10182. m.organization_id = nil
  10183. m.addorganization_id = nil
  10184. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10185. }
  10186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10187. func (m *ContactMutation) OrganizationIDCleared() bool {
  10188. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10189. return ok
  10190. }
  10191. // ResetOrganizationID resets all changes to the "organization_id" field.
  10192. func (m *ContactMutation) ResetOrganizationID() {
  10193. m.organization_id = nil
  10194. m.addorganization_id = nil
  10195. delete(m.clearedFields, contact.FieldOrganizationID)
  10196. }
  10197. // SetCtype sets the "ctype" field.
  10198. func (m *ContactMutation) SetCtype(u uint64) {
  10199. m.ctype = &u
  10200. m.addctype = nil
  10201. }
  10202. // Ctype returns the value of the "ctype" field in the mutation.
  10203. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10204. v := m.ctype
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10211. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldCtype requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10223. }
  10224. return oldValue.Ctype, nil
  10225. }
  10226. // AddCtype adds u to the "ctype" field.
  10227. func (m *ContactMutation) AddCtype(u int64) {
  10228. if m.addctype != nil {
  10229. *m.addctype += u
  10230. } else {
  10231. m.addctype = &u
  10232. }
  10233. }
  10234. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10235. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10236. v := m.addctype
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetCtype resets all changes to the "ctype" field.
  10243. func (m *ContactMutation) ResetCtype() {
  10244. m.ctype = nil
  10245. m.addctype = nil
  10246. }
  10247. // SetCage sets the "cage" field.
  10248. func (m *ContactMutation) SetCage(i int) {
  10249. m.cage = &i
  10250. m.addcage = nil
  10251. }
  10252. // Cage returns the value of the "cage" field in the mutation.
  10253. func (m *ContactMutation) Cage() (r int, exists bool) {
  10254. v := m.cage
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldCage returns the old "cage" field's value of the Contact entity.
  10261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldCage requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10273. }
  10274. return oldValue.Cage, nil
  10275. }
  10276. // AddCage adds i to the "cage" field.
  10277. func (m *ContactMutation) AddCage(i int) {
  10278. if m.addcage != nil {
  10279. *m.addcage += i
  10280. } else {
  10281. m.addcage = &i
  10282. }
  10283. }
  10284. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10285. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10286. v := m.addcage
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetCage resets all changes to the "cage" field.
  10293. func (m *ContactMutation) ResetCage() {
  10294. m.cage = nil
  10295. m.addcage = nil
  10296. }
  10297. // SetCname sets the "cname" field.
  10298. func (m *ContactMutation) SetCname(s string) {
  10299. m.cname = &s
  10300. }
  10301. // Cname returns the value of the "cname" field in the mutation.
  10302. func (m *ContactMutation) Cname() (r string, exists bool) {
  10303. v := m.cname
  10304. if v == nil {
  10305. return
  10306. }
  10307. return *v, true
  10308. }
  10309. // OldCname returns the old "cname" field's value of the Contact entity.
  10310. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10312. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10313. if !m.op.Is(OpUpdateOne) {
  10314. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10315. }
  10316. if m.id == nil || m.oldValue == nil {
  10317. return v, errors.New("OldCname requires an ID field in the mutation")
  10318. }
  10319. oldValue, err := m.oldValue(ctx)
  10320. if err != nil {
  10321. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10322. }
  10323. return oldValue.Cname, nil
  10324. }
  10325. // ResetCname resets all changes to the "cname" field.
  10326. func (m *ContactMutation) ResetCname() {
  10327. m.cname = nil
  10328. }
  10329. // SetCarea sets the "carea" field.
  10330. func (m *ContactMutation) SetCarea(s string) {
  10331. m.carea = &s
  10332. }
  10333. // Carea returns the value of the "carea" field in the mutation.
  10334. func (m *ContactMutation) Carea() (r string, exists bool) {
  10335. v := m.carea
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldCarea returns the old "carea" field's value of the Contact entity.
  10342. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldCarea requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10354. }
  10355. return oldValue.Carea, nil
  10356. }
  10357. // ResetCarea resets all changes to the "carea" field.
  10358. func (m *ContactMutation) ResetCarea() {
  10359. m.carea = nil
  10360. }
  10361. // SetCbirthday sets the "cbirthday" field.
  10362. func (m *ContactMutation) SetCbirthday(s string) {
  10363. m.cbirthday = &s
  10364. }
  10365. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10366. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10367. v := m.cbirthday
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10374. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10376. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10377. if !m.op.Is(OpUpdateOne) {
  10378. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10379. }
  10380. if m.id == nil || m.oldValue == nil {
  10381. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10382. }
  10383. oldValue, err := m.oldValue(ctx)
  10384. if err != nil {
  10385. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10386. }
  10387. return oldValue.Cbirthday, nil
  10388. }
  10389. // ResetCbirthday resets all changes to the "cbirthday" field.
  10390. func (m *ContactMutation) ResetCbirthday() {
  10391. m.cbirthday = nil
  10392. }
  10393. // SetCbirtharea sets the "cbirtharea" field.
  10394. func (m *ContactMutation) SetCbirtharea(s string) {
  10395. m.cbirtharea = &s
  10396. }
  10397. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10398. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10399. v := m.cbirtharea
  10400. if v == nil {
  10401. return
  10402. }
  10403. return *v, true
  10404. }
  10405. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10406. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10408. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10409. if !m.op.Is(OpUpdateOne) {
  10410. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10411. }
  10412. if m.id == nil || m.oldValue == nil {
  10413. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10414. }
  10415. oldValue, err := m.oldValue(ctx)
  10416. if err != nil {
  10417. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10418. }
  10419. return oldValue.Cbirtharea, nil
  10420. }
  10421. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10422. func (m *ContactMutation) ResetCbirtharea() {
  10423. m.cbirtharea = nil
  10424. }
  10425. // SetCidcardNo sets the "cidcard_no" field.
  10426. func (m *ContactMutation) SetCidcardNo(s string) {
  10427. m.cidcard_no = &s
  10428. }
  10429. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10430. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10431. v := m.cidcard_no
  10432. if v == nil {
  10433. return
  10434. }
  10435. return *v, true
  10436. }
  10437. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10438. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10440. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10441. if !m.op.Is(OpUpdateOne) {
  10442. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10443. }
  10444. if m.id == nil || m.oldValue == nil {
  10445. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10446. }
  10447. oldValue, err := m.oldValue(ctx)
  10448. if err != nil {
  10449. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10450. }
  10451. return oldValue.CidcardNo, nil
  10452. }
  10453. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10454. func (m *ContactMutation) ResetCidcardNo() {
  10455. m.cidcard_no = nil
  10456. }
  10457. // SetCtitle sets the "ctitle" field.
  10458. func (m *ContactMutation) SetCtitle(s string) {
  10459. m.ctitle = &s
  10460. }
  10461. // Ctitle returns the value of the "ctitle" field in the mutation.
  10462. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10463. v := m.ctitle
  10464. if v == nil {
  10465. return
  10466. }
  10467. return *v, true
  10468. }
  10469. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10472. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10473. if !m.op.Is(OpUpdateOne) {
  10474. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10475. }
  10476. if m.id == nil || m.oldValue == nil {
  10477. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10478. }
  10479. oldValue, err := m.oldValue(ctx)
  10480. if err != nil {
  10481. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10482. }
  10483. return oldValue.Ctitle, nil
  10484. }
  10485. // ResetCtitle resets all changes to the "ctitle" field.
  10486. func (m *ContactMutation) ResetCtitle() {
  10487. m.ctitle = nil
  10488. }
  10489. // SetCc sets the "cc" field.
  10490. func (m *ContactMutation) SetCc(s string) {
  10491. m.cc = &s
  10492. }
  10493. // Cc returns the value of the "cc" field in the mutation.
  10494. func (m *ContactMutation) Cc() (r string, exists bool) {
  10495. v := m.cc
  10496. if v == nil {
  10497. return
  10498. }
  10499. return *v, true
  10500. }
  10501. // OldCc returns the old "cc" field's value of the Contact entity.
  10502. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10504. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10505. if !m.op.Is(OpUpdateOne) {
  10506. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10507. }
  10508. if m.id == nil || m.oldValue == nil {
  10509. return v, errors.New("OldCc requires an ID field in the mutation")
  10510. }
  10511. oldValue, err := m.oldValue(ctx)
  10512. if err != nil {
  10513. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10514. }
  10515. return oldValue.Cc, nil
  10516. }
  10517. // ResetCc resets all changes to the "cc" field.
  10518. func (m *ContactMutation) ResetCc() {
  10519. m.cc = nil
  10520. }
  10521. // SetPhone sets the "phone" field.
  10522. func (m *ContactMutation) SetPhone(s string) {
  10523. m.phone = &s
  10524. }
  10525. // Phone returns the value of the "phone" field in the mutation.
  10526. func (m *ContactMutation) Phone() (r string, exists bool) {
  10527. v := m.phone
  10528. if v == nil {
  10529. return
  10530. }
  10531. return *v, true
  10532. }
  10533. // OldPhone returns the old "phone" field's value of the Contact entity.
  10534. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10536. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10537. if !m.op.Is(OpUpdateOne) {
  10538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10539. }
  10540. if m.id == nil || m.oldValue == nil {
  10541. return v, errors.New("OldPhone requires an ID field in the mutation")
  10542. }
  10543. oldValue, err := m.oldValue(ctx)
  10544. if err != nil {
  10545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10546. }
  10547. return oldValue.Phone, nil
  10548. }
  10549. // ResetPhone resets all changes to the "phone" field.
  10550. func (m *ContactMutation) ResetPhone() {
  10551. m.phone = nil
  10552. }
  10553. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10554. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10555. if m.contact_relationships == nil {
  10556. m.contact_relationships = make(map[uint64]struct{})
  10557. }
  10558. for i := range ids {
  10559. m.contact_relationships[ids[i]] = struct{}{}
  10560. }
  10561. }
  10562. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10563. func (m *ContactMutation) ClearContactRelationships() {
  10564. m.clearedcontact_relationships = true
  10565. }
  10566. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10567. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10568. return m.clearedcontact_relationships
  10569. }
  10570. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10571. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10572. if m.removedcontact_relationships == nil {
  10573. m.removedcontact_relationships = make(map[uint64]struct{})
  10574. }
  10575. for i := range ids {
  10576. delete(m.contact_relationships, ids[i])
  10577. m.removedcontact_relationships[ids[i]] = struct{}{}
  10578. }
  10579. }
  10580. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10581. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10582. for id := range m.removedcontact_relationships {
  10583. ids = append(ids, id)
  10584. }
  10585. return
  10586. }
  10587. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10588. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10589. for id := range m.contact_relationships {
  10590. ids = append(ids, id)
  10591. }
  10592. return
  10593. }
  10594. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10595. func (m *ContactMutation) ResetContactRelationships() {
  10596. m.contact_relationships = nil
  10597. m.clearedcontact_relationships = false
  10598. m.removedcontact_relationships = nil
  10599. }
  10600. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10601. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10602. if m.contact_messages == nil {
  10603. m.contact_messages = make(map[uint64]struct{})
  10604. }
  10605. for i := range ids {
  10606. m.contact_messages[ids[i]] = struct{}{}
  10607. }
  10608. }
  10609. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10610. func (m *ContactMutation) ClearContactMessages() {
  10611. m.clearedcontact_messages = true
  10612. }
  10613. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10614. func (m *ContactMutation) ContactMessagesCleared() bool {
  10615. return m.clearedcontact_messages
  10616. }
  10617. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10618. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10619. if m.removedcontact_messages == nil {
  10620. m.removedcontact_messages = make(map[uint64]struct{})
  10621. }
  10622. for i := range ids {
  10623. delete(m.contact_messages, ids[i])
  10624. m.removedcontact_messages[ids[i]] = struct{}{}
  10625. }
  10626. }
  10627. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10628. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10629. for id := range m.removedcontact_messages {
  10630. ids = append(ids, id)
  10631. }
  10632. return
  10633. }
  10634. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10635. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10636. for id := range m.contact_messages {
  10637. ids = append(ids, id)
  10638. }
  10639. return
  10640. }
  10641. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10642. func (m *ContactMutation) ResetContactMessages() {
  10643. m.contact_messages = nil
  10644. m.clearedcontact_messages = false
  10645. m.removedcontact_messages = nil
  10646. }
  10647. // Where appends a list predicates to the ContactMutation builder.
  10648. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10649. m.predicates = append(m.predicates, ps...)
  10650. }
  10651. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10652. // users can use type-assertion to append predicates that do not depend on any generated package.
  10653. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10654. p := make([]predicate.Contact, len(ps))
  10655. for i := range ps {
  10656. p[i] = ps[i]
  10657. }
  10658. m.Where(p...)
  10659. }
  10660. // Op returns the operation name.
  10661. func (m *ContactMutation) Op() Op {
  10662. return m.op
  10663. }
  10664. // SetOp allows setting the mutation operation.
  10665. func (m *ContactMutation) SetOp(op Op) {
  10666. m.op = op
  10667. }
  10668. // Type returns the node type of this mutation (Contact).
  10669. func (m *ContactMutation) Type() string {
  10670. return m.typ
  10671. }
  10672. // Fields returns all fields that were changed during this mutation. Note that in
  10673. // order to get all numeric fields that were incremented/decremented, call
  10674. // AddedFields().
  10675. func (m *ContactMutation) Fields() []string {
  10676. fields := make([]string, 0, 30)
  10677. if m.created_at != nil {
  10678. fields = append(fields, contact.FieldCreatedAt)
  10679. }
  10680. if m.updated_at != nil {
  10681. fields = append(fields, contact.FieldUpdatedAt)
  10682. }
  10683. if m.status != nil {
  10684. fields = append(fields, contact.FieldStatus)
  10685. }
  10686. if m.deleted_at != nil {
  10687. fields = append(fields, contact.FieldDeletedAt)
  10688. }
  10689. if m.wx_wxid != nil {
  10690. fields = append(fields, contact.FieldWxWxid)
  10691. }
  10692. if m._type != nil {
  10693. fields = append(fields, contact.FieldType)
  10694. }
  10695. if m.wxid != nil {
  10696. fields = append(fields, contact.FieldWxid)
  10697. }
  10698. if m.account != nil {
  10699. fields = append(fields, contact.FieldAccount)
  10700. }
  10701. if m.nickname != nil {
  10702. fields = append(fields, contact.FieldNickname)
  10703. }
  10704. if m.markname != nil {
  10705. fields = append(fields, contact.FieldMarkname)
  10706. }
  10707. if m.headimg != nil {
  10708. fields = append(fields, contact.FieldHeadimg)
  10709. }
  10710. if m.sex != nil {
  10711. fields = append(fields, contact.FieldSex)
  10712. }
  10713. if m.starrole != nil {
  10714. fields = append(fields, contact.FieldStarrole)
  10715. }
  10716. if m.dontseeit != nil {
  10717. fields = append(fields, contact.FieldDontseeit)
  10718. }
  10719. if m.dontseeme != nil {
  10720. fields = append(fields, contact.FieldDontseeme)
  10721. }
  10722. if m.lag != nil {
  10723. fields = append(fields, contact.FieldLag)
  10724. }
  10725. if m.gid != nil {
  10726. fields = append(fields, contact.FieldGid)
  10727. }
  10728. if m.gname != nil {
  10729. fields = append(fields, contact.FieldGname)
  10730. }
  10731. if m.v3 != nil {
  10732. fields = append(fields, contact.FieldV3)
  10733. }
  10734. if m.organization_id != nil {
  10735. fields = append(fields, contact.FieldOrganizationID)
  10736. }
  10737. if m.ctype != nil {
  10738. fields = append(fields, contact.FieldCtype)
  10739. }
  10740. if m.cage != nil {
  10741. fields = append(fields, contact.FieldCage)
  10742. }
  10743. if m.cname != nil {
  10744. fields = append(fields, contact.FieldCname)
  10745. }
  10746. if m.carea != nil {
  10747. fields = append(fields, contact.FieldCarea)
  10748. }
  10749. if m.cbirthday != nil {
  10750. fields = append(fields, contact.FieldCbirthday)
  10751. }
  10752. if m.cbirtharea != nil {
  10753. fields = append(fields, contact.FieldCbirtharea)
  10754. }
  10755. if m.cidcard_no != nil {
  10756. fields = append(fields, contact.FieldCidcardNo)
  10757. }
  10758. if m.ctitle != nil {
  10759. fields = append(fields, contact.FieldCtitle)
  10760. }
  10761. if m.cc != nil {
  10762. fields = append(fields, contact.FieldCc)
  10763. }
  10764. if m.phone != nil {
  10765. fields = append(fields, contact.FieldPhone)
  10766. }
  10767. return fields
  10768. }
  10769. // Field returns the value of a field with the given name. The second boolean
  10770. // return value indicates that this field was not set, or was not defined in the
  10771. // schema.
  10772. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10773. switch name {
  10774. case contact.FieldCreatedAt:
  10775. return m.CreatedAt()
  10776. case contact.FieldUpdatedAt:
  10777. return m.UpdatedAt()
  10778. case contact.FieldStatus:
  10779. return m.Status()
  10780. case contact.FieldDeletedAt:
  10781. return m.DeletedAt()
  10782. case contact.FieldWxWxid:
  10783. return m.WxWxid()
  10784. case contact.FieldType:
  10785. return m.GetType()
  10786. case contact.FieldWxid:
  10787. return m.Wxid()
  10788. case contact.FieldAccount:
  10789. return m.Account()
  10790. case contact.FieldNickname:
  10791. return m.Nickname()
  10792. case contact.FieldMarkname:
  10793. return m.Markname()
  10794. case contact.FieldHeadimg:
  10795. return m.Headimg()
  10796. case contact.FieldSex:
  10797. return m.Sex()
  10798. case contact.FieldStarrole:
  10799. return m.Starrole()
  10800. case contact.FieldDontseeit:
  10801. return m.Dontseeit()
  10802. case contact.FieldDontseeme:
  10803. return m.Dontseeme()
  10804. case contact.FieldLag:
  10805. return m.Lag()
  10806. case contact.FieldGid:
  10807. return m.Gid()
  10808. case contact.FieldGname:
  10809. return m.Gname()
  10810. case contact.FieldV3:
  10811. return m.V3()
  10812. case contact.FieldOrganizationID:
  10813. return m.OrganizationID()
  10814. case contact.FieldCtype:
  10815. return m.Ctype()
  10816. case contact.FieldCage:
  10817. return m.Cage()
  10818. case contact.FieldCname:
  10819. return m.Cname()
  10820. case contact.FieldCarea:
  10821. return m.Carea()
  10822. case contact.FieldCbirthday:
  10823. return m.Cbirthday()
  10824. case contact.FieldCbirtharea:
  10825. return m.Cbirtharea()
  10826. case contact.FieldCidcardNo:
  10827. return m.CidcardNo()
  10828. case contact.FieldCtitle:
  10829. return m.Ctitle()
  10830. case contact.FieldCc:
  10831. return m.Cc()
  10832. case contact.FieldPhone:
  10833. return m.Phone()
  10834. }
  10835. return nil, false
  10836. }
  10837. // OldField returns the old value of the field from the database. An error is
  10838. // returned if the mutation operation is not UpdateOne, or the query to the
  10839. // database failed.
  10840. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10841. switch name {
  10842. case contact.FieldCreatedAt:
  10843. return m.OldCreatedAt(ctx)
  10844. case contact.FieldUpdatedAt:
  10845. return m.OldUpdatedAt(ctx)
  10846. case contact.FieldStatus:
  10847. return m.OldStatus(ctx)
  10848. case contact.FieldDeletedAt:
  10849. return m.OldDeletedAt(ctx)
  10850. case contact.FieldWxWxid:
  10851. return m.OldWxWxid(ctx)
  10852. case contact.FieldType:
  10853. return m.OldType(ctx)
  10854. case contact.FieldWxid:
  10855. return m.OldWxid(ctx)
  10856. case contact.FieldAccount:
  10857. return m.OldAccount(ctx)
  10858. case contact.FieldNickname:
  10859. return m.OldNickname(ctx)
  10860. case contact.FieldMarkname:
  10861. return m.OldMarkname(ctx)
  10862. case contact.FieldHeadimg:
  10863. return m.OldHeadimg(ctx)
  10864. case contact.FieldSex:
  10865. return m.OldSex(ctx)
  10866. case contact.FieldStarrole:
  10867. return m.OldStarrole(ctx)
  10868. case contact.FieldDontseeit:
  10869. return m.OldDontseeit(ctx)
  10870. case contact.FieldDontseeme:
  10871. return m.OldDontseeme(ctx)
  10872. case contact.FieldLag:
  10873. return m.OldLag(ctx)
  10874. case contact.FieldGid:
  10875. return m.OldGid(ctx)
  10876. case contact.FieldGname:
  10877. return m.OldGname(ctx)
  10878. case contact.FieldV3:
  10879. return m.OldV3(ctx)
  10880. case contact.FieldOrganizationID:
  10881. return m.OldOrganizationID(ctx)
  10882. case contact.FieldCtype:
  10883. return m.OldCtype(ctx)
  10884. case contact.FieldCage:
  10885. return m.OldCage(ctx)
  10886. case contact.FieldCname:
  10887. return m.OldCname(ctx)
  10888. case contact.FieldCarea:
  10889. return m.OldCarea(ctx)
  10890. case contact.FieldCbirthday:
  10891. return m.OldCbirthday(ctx)
  10892. case contact.FieldCbirtharea:
  10893. return m.OldCbirtharea(ctx)
  10894. case contact.FieldCidcardNo:
  10895. return m.OldCidcardNo(ctx)
  10896. case contact.FieldCtitle:
  10897. return m.OldCtitle(ctx)
  10898. case contact.FieldCc:
  10899. return m.OldCc(ctx)
  10900. case contact.FieldPhone:
  10901. return m.OldPhone(ctx)
  10902. }
  10903. return nil, fmt.Errorf("unknown Contact field %s", name)
  10904. }
  10905. // SetField sets the value of a field with the given name. It returns an error if
  10906. // the field is not defined in the schema, or if the type mismatched the field
  10907. // type.
  10908. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10909. switch name {
  10910. case contact.FieldCreatedAt:
  10911. v, ok := value.(time.Time)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.SetCreatedAt(v)
  10916. return nil
  10917. case contact.FieldUpdatedAt:
  10918. v, ok := value.(time.Time)
  10919. if !ok {
  10920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10921. }
  10922. m.SetUpdatedAt(v)
  10923. return nil
  10924. case contact.FieldStatus:
  10925. v, ok := value.(uint8)
  10926. if !ok {
  10927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10928. }
  10929. m.SetStatus(v)
  10930. return nil
  10931. case contact.FieldDeletedAt:
  10932. v, ok := value.(time.Time)
  10933. if !ok {
  10934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10935. }
  10936. m.SetDeletedAt(v)
  10937. return nil
  10938. case contact.FieldWxWxid:
  10939. v, ok := value.(string)
  10940. if !ok {
  10941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10942. }
  10943. m.SetWxWxid(v)
  10944. return nil
  10945. case contact.FieldType:
  10946. v, ok := value.(int)
  10947. if !ok {
  10948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10949. }
  10950. m.SetType(v)
  10951. return nil
  10952. case contact.FieldWxid:
  10953. v, ok := value.(string)
  10954. if !ok {
  10955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10956. }
  10957. m.SetWxid(v)
  10958. return nil
  10959. case contact.FieldAccount:
  10960. v, ok := value.(string)
  10961. if !ok {
  10962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10963. }
  10964. m.SetAccount(v)
  10965. return nil
  10966. case contact.FieldNickname:
  10967. v, ok := value.(string)
  10968. if !ok {
  10969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10970. }
  10971. m.SetNickname(v)
  10972. return nil
  10973. case contact.FieldMarkname:
  10974. v, ok := value.(string)
  10975. if !ok {
  10976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10977. }
  10978. m.SetMarkname(v)
  10979. return nil
  10980. case contact.FieldHeadimg:
  10981. v, ok := value.(string)
  10982. if !ok {
  10983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10984. }
  10985. m.SetHeadimg(v)
  10986. return nil
  10987. case contact.FieldSex:
  10988. v, ok := value.(int)
  10989. if !ok {
  10990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10991. }
  10992. m.SetSex(v)
  10993. return nil
  10994. case contact.FieldStarrole:
  10995. v, ok := value.(string)
  10996. if !ok {
  10997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10998. }
  10999. m.SetStarrole(v)
  11000. return nil
  11001. case contact.FieldDontseeit:
  11002. v, ok := value.(int)
  11003. if !ok {
  11004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11005. }
  11006. m.SetDontseeit(v)
  11007. return nil
  11008. case contact.FieldDontseeme:
  11009. v, ok := value.(int)
  11010. if !ok {
  11011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11012. }
  11013. m.SetDontseeme(v)
  11014. return nil
  11015. case contact.FieldLag:
  11016. v, ok := value.(string)
  11017. if !ok {
  11018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11019. }
  11020. m.SetLag(v)
  11021. return nil
  11022. case contact.FieldGid:
  11023. v, ok := value.(string)
  11024. if !ok {
  11025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11026. }
  11027. m.SetGid(v)
  11028. return nil
  11029. case contact.FieldGname:
  11030. v, ok := value.(string)
  11031. if !ok {
  11032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11033. }
  11034. m.SetGname(v)
  11035. return nil
  11036. case contact.FieldV3:
  11037. v, ok := value.(string)
  11038. if !ok {
  11039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11040. }
  11041. m.SetV3(v)
  11042. return nil
  11043. case contact.FieldOrganizationID:
  11044. v, ok := value.(uint64)
  11045. if !ok {
  11046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11047. }
  11048. m.SetOrganizationID(v)
  11049. return nil
  11050. case contact.FieldCtype:
  11051. v, ok := value.(uint64)
  11052. if !ok {
  11053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11054. }
  11055. m.SetCtype(v)
  11056. return nil
  11057. case contact.FieldCage:
  11058. v, ok := value.(int)
  11059. if !ok {
  11060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11061. }
  11062. m.SetCage(v)
  11063. return nil
  11064. case contact.FieldCname:
  11065. v, ok := value.(string)
  11066. if !ok {
  11067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11068. }
  11069. m.SetCname(v)
  11070. return nil
  11071. case contact.FieldCarea:
  11072. v, ok := value.(string)
  11073. if !ok {
  11074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11075. }
  11076. m.SetCarea(v)
  11077. return nil
  11078. case contact.FieldCbirthday:
  11079. v, ok := value.(string)
  11080. if !ok {
  11081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11082. }
  11083. m.SetCbirthday(v)
  11084. return nil
  11085. case contact.FieldCbirtharea:
  11086. v, ok := value.(string)
  11087. if !ok {
  11088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11089. }
  11090. m.SetCbirtharea(v)
  11091. return nil
  11092. case contact.FieldCidcardNo:
  11093. v, ok := value.(string)
  11094. if !ok {
  11095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11096. }
  11097. m.SetCidcardNo(v)
  11098. return nil
  11099. case contact.FieldCtitle:
  11100. v, ok := value.(string)
  11101. if !ok {
  11102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11103. }
  11104. m.SetCtitle(v)
  11105. return nil
  11106. case contact.FieldCc:
  11107. v, ok := value.(string)
  11108. if !ok {
  11109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11110. }
  11111. m.SetCc(v)
  11112. return nil
  11113. case contact.FieldPhone:
  11114. v, ok := value.(string)
  11115. if !ok {
  11116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11117. }
  11118. m.SetPhone(v)
  11119. return nil
  11120. }
  11121. return fmt.Errorf("unknown Contact field %s", name)
  11122. }
  11123. // AddedFields returns all numeric fields that were incremented/decremented during
  11124. // this mutation.
  11125. func (m *ContactMutation) AddedFields() []string {
  11126. var fields []string
  11127. if m.addstatus != nil {
  11128. fields = append(fields, contact.FieldStatus)
  11129. }
  11130. if m.add_type != nil {
  11131. fields = append(fields, contact.FieldType)
  11132. }
  11133. if m.addsex != nil {
  11134. fields = append(fields, contact.FieldSex)
  11135. }
  11136. if m.adddontseeit != nil {
  11137. fields = append(fields, contact.FieldDontseeit)
  11138. }
  11139. if m.adddontseeme != nil {
  11140. fields = append(fields, contact.FieldDontseeme)
  11141. }
  11142. if m.addorganization_id != nil {
  11143. fields = append(fields, contact.FieldOrganizationID)
  11144. }
  11145. if m.addctype != nil {
  11146. fields = append(fields, contact.FieldCtype)
  11147. }
  11148. if m.addcage != nil {
  11149. fields = append(fields, contact.FieldCage)
  11150. }
  11151. return fields
  11152. }
  11153. // AddedField returns the numeric value that was incremented/decremented on a field
  11154. // with the given name. The second boolean return value indicates that this field
  11155. // was not set, or was not defined in the schema.
  11156. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11157. switch name {
  11158. case contact.FieldStatus:
  11159. return m.AddedStatus()
  11160. case contact.FieldType:
  11161. return m.AddedType()
  11162. case contact.FieldSex:
  11163. return m.AddedSex()
  11164. case contact.FieldDontseeit:
  11165. return m.AddedDontseeit()
  11166. case contact.FieldDontseeme:
  11167. return m.AddedDontseeme()
  11168. case contact.FieldOrganizationID:
  11169. return m.AddedOrganizationID()
  11170. case contact.FieldCtype:
  11171. return m.AddedCtype()
  11172. case contact.FieldCage:
  11173. return m.AddedCage()
  11174. }
  11175. return nil, false
  11176. }
  11177. // AddField adds the value to the field with the given name. It returns an error if
  11178. // the field is not defined in the schema, or if the type mismatched the field
  11179. // type.
  11180. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11181. switch name {
  11182. case contact.FieldStatus:
  11183. v, ok := value.(int8)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.AddStatus(v)
  11188. return nil
  11189. case contact.FieldType:
  11190. v, ok := value.(int)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.AddType(v)
  11195. return nil
  11196. case contact.FieldSex:
  11197. v, ok := value.(int)
  11198. if !ok {
  11199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11200. }
  11201. m.AddSex(v)
  11202. return nil
  11203. case contact.FieldDontseeit:
  11204. v, ok := value.(int)
  11205. if !ok {
  11206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11207. }
  11208. m.AddDontseeit(v)
  11209. return nil
  11210. case contact.FieldDontseeme:
  11211. v, ok := value.(int)
  11212. if !ok {
  11213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11214. }
  11215. m.AddDontseeme(v)
  11216. return nil
  11217. case contact.FieldOrganizationID:
  11218. v, ok := value.(int64)
  11219. if !ok {
  11220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11221. }
  11222. m.AddOrganizationID(v)
  11223. return nil
  11224. case contact.FieldCtype:
  11225. v, ok := value.(int64)
  11226. if !ok {
  11227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11228. }
  11229. m.AddCtype(v)
  11230. return nil
  11231. case contact.FieldCage:
  11232. v, ok := value.(int)
  11233. if !ok {
  11234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11235. }
  11236. m.AddCage(v)
  11237. return nil
  11238. }
  11239. return fmt.Errorf("unknown Contact numeric field %s", name)
  11240. }
  11241. // ClearedFields returns all nullable fields that were cleared during this
  11242. // mutation.
  11243. func (m *ContactMutation) ClearedFields() []string {
  11244. var fields []string
  11245. if m.FieldCleared(contact.FieldStatus) {
  11246. fields = append(fields, contact.FieldStatus)
  11247. }
  11248. if m.FieldCleared(contact.FieldDeletedAt) {
  11249. fields = append(fields, contact.FieldDeletedAt)
  11250. }
  11251. if m.FieldCleared(contact.FieldType) {
  11252. fields = append(fields, contact.FieldType)
  11253. }
  11254. if m.FieldCleared(contact.FieldOrganizationID) {
  11255. fields = append(fields, contact.FieldOrganizationID)
  11256. }
  11257. return fields
  11258. }
  11259. // FieldCleared returns a boolean indicating if a field with the given name was
  11260. // cleared in this mutation.
  11261. func (m *ContactMutation) FieldCleared(name string) bool {
  11262. _, ok := m.clearedFields[name]
  11263. return ok
  11264. }
  11265. // ClearField clears the value of the field with the given name. It returns an
  11266. // error if the field is not defined in the schema.
  11267. func (m *ContactMutation) ClearField(name string) error {
  11268. switch name {
  11269. case contact.FieldStatus:
  11270. m.ClearStatus()
  11271. return nil
  11272. case contact.FieldDeletedAt:
  11273. m.ClearDeletedAt()
  11274. return nil
  11275. case contact.FieldType:
  11276. m.ClearType()
  11277. return nil
  11278. case contact.FieldOrganizationID:
  11279. m.ClearOrganizationID()
  11280. return nil
  11281. }
  11282. return fmt.Errorf("unknown Contact nullable field %s", name)
  11283. }
  11284. // ResetField resets all changes in the mutation for the field with the given name.
  11285. // It returns an error if the field is not defined in the schema.
  11286. func (m *ContactMutation) ResetField(name string) error {
  11287. switch name {
  11288. case contact.FieldCreatedAt:
  11289. m.ResetCreatedAt()
  11290. return nil
  11291. case contact.FieldUpdatedAt:
  11292. m.ResetUpdatedAt()
  11293. return nil
  11294. case contact.FieldStatus:
  11295. m.ResetStatus()
  11296. return nil
  11297. case contact.FieldDeletedAt:
  11298. m.ResetDeletedAt()
  11299. return nil
  11300. case contact.FieldWxWxid:
  11301. m.ResetWxWxid()
  11302. return nil
  11303. case contact.FieldType:
  11304. m.ResetType()
  11305. return nil
  11306. case contact.FieldWxid:
  11307. m.ResetWxid()
  11308. return nil
  11309. case contact.FieldAccount:
  11310. m.ResetAccount()
  11311. return nil
  11312. case contact.FieldNickname:
  11313. m.ResetNickname()
  11314. return nil
  11315. case contact.FieldMarkname:
  11316. m.ResetMarkname()
  11317. return nil
  11318. case contact.FieldHeadimg:
  11319. m.ResetHeadimg()
  11320. return nil
  11321. case contact.FieldSex:
  11322. m.ResetSex()
  11323. return nil
  11324. case contact.FieldStarrole:
  11325. m.ResetStarrole()
  11326. return nil
  11327. case contact.FieldDontseeit:
  11328. m.ResetDontseeit()
  11329. return nil
  11330. case contact.FieldDontseeme:
  11331. m.ResetDontseeme()
  11332. return nil
  11333. case contact.FieldLag:
  11334. m.ResetLag()
  11335. return nil
  11336. case contact.FieldGid:
  11337. m.ResetGid()
  11338. return nil
  11339. case contact.FieldGname:
  11340. m.ResetGname()
  11341. return nil
  11342. case contact.FieldV3:
  11343. m.ResetV3()
  11344. return nil
  11345. case contact.FieldOrganizationID:
  11346. m.ResetOrganizationID()
  11347. return nil
  11348. case contact.FieldCtype:
  11349. m.ResetCtype()
  11350. return nil
  11351. case contact.FieldCage:
  11352. m.ResetCage()
  11353. return nil
  11354. case contact.FieldCname:
  11355. m.ResetCname()
  11356. return nil
  11357. case contact.FieldCarea:
  11358. m.ResetCarea()
  11359. return nil
  11360. case contact.FieldCbirthday:
  11361. m.ResetCbirthday()
  11362. return nil
  11363. case contact.FieldCbirtharea:
  11364. m.ResetCbirtharea()
  11365. return nil
  11366. case contact.FieldCidcardNo:
  11367. m.ResetCidcardNo()
  11368. return nil
  11369. case contact.FieldCtitle:
  11370. m.ResetCtitle()
  11371. return nil
  11372. case contact.FieldCc:
  11373. m.ResetCc()
  11374. return nil
  11375. case contact.FieldPhone:
  11376. m.ResetPhone()
  11377. return nil
  11378. }
  11379. return fmt.Errorf("unknown Contact field %s", name)
  11380. }
  11381. // AddedEdges returns all edge names that were set/added in this mutation.
  11382. func (m *ContactMutation) AddedEdges() []string {
  11383. edges := make([]string, 0, 2)
  11384. if m.contact_relationships != nil {
  11385. edges = append(edges, contact.EdgeContactRelationships)
  11386. }
  11387. if m.contact_messages != nil {
  11388. edges = append(edges, contact.EdgeContactMessages)
  11389. }
  11390. return edges
  11391. }
  11392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11393. // name in this mutation.
  11394. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11395. switch name {
  11396. case contact.EdgeContactRelationships:
  11397. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11398. for id := range m.contact_relationships {
  11399. ids = append(ids, id)
  11400. }
  11401. return ids
  11402. case contact.EdgeContactMessages:
  11403. ids := make([]ent.Value, 0, len(m.contact_messages))
  11404. for id := range m.contact_messages {
  11405. ids = append(ids, id)
  11406. }
  11407. return ids
  11408. }
  11409. return nil
  11410. }
  11411. // RemovedEdges returns all edge names that were removed in this mutation.
  11412. func (m *ContactMutation) RemovedEdges() []string {
  11413. edges := make([]string, 0, 2)
  11414. if m.removedcontact_relationships != nil {
  11415. edges = append(edges, contact.EdgeContactRelationships)
  11416. }
  11417. if m.removedcontact_messages != nil {
  11418. edges = append(edges, contact.EdgeContactMessages)
  11419. }
  11420. return edges
  11421. }
  11422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11423. // the given name in this mutation.
  11424. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11425. switch name {
  11426. case contact.EdgeContactRelationships:
  11427. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11428. for id := range m.removedcontact_relationships {
  11429. ids = append(ids, id)
  11430. }
  11431. return ids
  11432. case contact.EdgeContactMessages:
  11433. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11434. for id := range m.removedcontact_messages {
  11435. ids = append(ids, id)
  11436. }
  11437. return ids
  11438. }
  11439. return nil
  11440. }
  11441. // ClearedEdges returns all edge names that were cleared in this mutation.
  11442. func (m *ContactMutation) ClearedEdges() []string {
  11443. edges := make([]string, 0, 2)
  11444. if m.clearedcontact_relationships {
  11445. edges = append(edges, contact.EdgeContactRelationships)
  11446. }
  11447. if m.clearedcontact_messages {
  11448. edges = append(edges, contact.EdgeContactMessages)
  11449. }
  11450. return edges
  11451. }
  11452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11453. // was cleared in this mutation.
  11454. func (m *ContactMutation) EdgeCleared(name string) bool {
  11455. switch name {
  11456. case contact.EdgeContactRelationships:
  11457. return m.clearedcontact_relationships
  11458. case contact.EdgeContactMessages:
  11459. return m.clearedcontact_messages
  11460. }
  11461. return false
  11462. }
  11463. // ClearEdge clears the value of the edge with the given name. It returns an error
  11464. // if that edge is not defined in the schema.
  11465. func (m *ContactMutation) ClearEdge(name string) error {
  11466. switch name {
  11467. }
  11468. return fmt.Errorf("unknown Contact unique edge %s", name)
  11469. }
  11470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11471. // It returns an error if the edge is not defined in the schema.
  11472. func (m *ContactMutation) ResetEdge(name string) error {
  11473. switch name {
  11474. case contact.EdgeContactRelationships:
  11475. m.ResetContactRelationships()
  11476. return nil
  11477. case contact.EdgeContactMessages:
  11478. m.ResetContactMessages()
  11479. return nil
  11480. }
  11481. return fmt.Errorf("unknown Contact edge %s", name)
  11482. }
  11483. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11484. type CreditBalanceMutation struct {
  11485. config
  11486. op Op
  11487. typ string
  11488. id *uint64
  11489. created_at *time.Time
  11490. updated_at *time.Time
  11491. deleted_at *time.Time
  11492. user_id *string
  11493. balance *float32
  11494. addbalance *float32
  11495. status *int
  11496. addstatus *int
  11497. organization_id *uint64
  11498. addorganization_id *int64
  11499. clearedFields map[string]struct{}
  11500. done bool
  11501. oldValue func(context.Context) (*CreditBalance, error)
  11502. predicates []predicate.CreditBalance
  11503. }
  11504. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11505. // creditbalanceOption allows management of the mutation configuration using functional options.
  11506. type creditbalanceOption func(*CreditBalanceMutation)
  11507. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11508. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11509. m := &CreditBalanceMutation{
  11510. config: c,
  11511. op: op,
  11512. typ: TypeCreditBalance,
  11513. clearedFields: make(map[string]struct{}),
  11514. }
  11515. for _, opt := range opts {
  11516. opt(m)
  11517. }
  11518. return m
  11519. }
  11520. // withCreditBalanceID sets the ID field of the mutation.
  11521. func withCreditBalanceID(id uint64) creditbalanceOption {
  11522. return func(m *CreditBalanceMutation) {
  11523. var (
  11524. err error
  11525. once sync.Once
  11526. value *CreditBalance
  11527. )
  11528. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11529. once.Do(func() {
  11530. if m.done {
  11531. err = errors.New("querying old values post mutation is not allowed")
  11532. } else {
  11533. value, err = m.Client().CreditBalance.Get(ctx, id)
  11534. }
  11535. })
  11536. return value, err
  11537. }
  11538. m.id = &id
  11539. }
  11540. }
  11541. // withCreditBalance sets the old CreditBalance of the mutation.
  11542. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11543. return func(m *CreditBalanceMutation) {
  11544. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11545. return node, nil
  11546. }
  11547. m.id = &node.ID
  11548. }
  11549. }
  11550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11551. // executed in a transaction (ent.Tx), a transactional client is returned.
  11552. func (m CreditBalanceMutation) Client() *Client {
  11553. client := &Client{config: m.config}
  11554. client.init()
  11555. return client
  11556. }
  11557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11558. // it returns an error otherwise.
  11559. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11560. if _, ok := m.driver.(*txDriver); !ok {
  11561. return nil, errors.New("ent: mutation is not running in a transaction")
  11562. }
  11563. tx := &Tx{config: m.config}
  11564. tx.init()
  11565. return tx, nil
  11566. }
  11567. // SetID sets the value of the id field. Note that this
  11568. // operation is only accepted on creation of CreditBalance entities.
  11569. func (m *CreditBalanceMutation) SetID(id uint64) {
  11570. m.id = &id
  11571. }
  11572. // ID returns the ID value in the mutation. Note that the ID is only available
  11573. // if it was provided to the builder or after it was returned from the database.
  11574. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11575. if m.id == nil {
  11576. return
  11577. }
  11578. return *m.id, true
  11579. }
  11580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11581. // That means, if the mutation is applied within a transaction with an isolation level such
  11582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11583. // or updated by the mutation.
  11584. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11585. switch {
  11586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11587. id, exists := m.ID()
  11588. if exists {
  11589. return []uint64{id}, nil
  11590. }
  11591. fallthrough
  11592. case m.op.Is(OpUpdate | OpDelete):
  11593. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11594. default:
  11595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11596. }
  11597. }
  11598. // SetCreatedAt sets the "created_at" field.
  11599. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11600. m.created_at = &t
  11601. }
  11602. // CreatedAt returns the value of the "created_at" field in the mutation.
  11603. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11604. v := m.created_at
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11611. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11613. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11614. if !m.op.Is(OpUpdateOne) {
  11615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11616. }
  11617. if m.id == nil || m.oldValue == nil {
  11618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11619. }
  11620. oldValue, err := m.oldValue(ctx)
  11621. if err != nil {
  11622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11623. }
  11624. return oldValue.CreatedAt, nil
  11625. }
  11626. // ResetCreatedAt resets all changes to the "created_at" field.
  11627. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11628. m.created_at = nil
  11629. }
  11630. // SetUpdatedAt sets the "updated_at" field.
  11631. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11632. m.updated_at = &t
  11633. }
  11634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11635. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11636. v := m.updated_at
  11637. if v == nil {
  11638. return
  11639. }
  11640. return *v, true
  11641. }
  11642. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11643. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11645. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11646. if !m.op.Is(OpUpdateOne) {
  11647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11648. }
  11649. if m.id == nil || m.oldValue == nil {
  11650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11651. }
  11652. oldValue, err := m.oldValue(ctx)
  11653. if err != nil {
  11654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11655. }
  11656. return oldValue.UpdatedAt, nil
  11657. }
  11658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11659. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11660. m.updated_at = nil
  11661. }
  11662. // SetDeletedAt sets the "deleted_at" field.
  11663. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11664. m.deleted_at = &t
  11665. }
  11666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11667. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11668. v := m.deleted_at
  11669. if v == nil {
  11670. return
  11671. }
  11672. return *v, true
  11673. }
  11674. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11675. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11677. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11678. if !m.op.Is(OpUpdateOne) {
  11679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11680. }
  11681. if m.id == nil || m.oldValue == nil {
  11682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11683. }
  11684. oldValue, err := m.oldValue(ctx)
  11685. if err != nil {
  11686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11687. }
  11688. return oldValue.DeletedAt, nil
  11689. }
  11690. // ClearDeletedAt clears the value of the "deleted_at" field.
  11691. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11692. m.deleted_at = nil
  11693. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11694. }
  11695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11696. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11697. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11698. return ok
  11699. }
  11700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11701. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11702. m.deleted_at = nil
  11703. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11704. }
  11705. // SetUserID sets the "user_id" field.
  11706. func (m *CreditBalanceMutation) SetUserID(s string) {
  11707. m.user_id = &s
  11708. }
  11709. // UserID returns the value of the "user_id" field in the mutation.
  11710. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11711. v := m.user_id
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11718. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldUserID requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11730. }
  11731. return oldValue.UserID, nil
  11732. }
  11733. // ClearUserID clears the value of the "user_id" field.
  11734. func (m *CreditBalanceMutation) ClearUserID() {
  11735. m.user_id = nil
  11736. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11737. }
  11738. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11739. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11740. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11741. return ok
  11742. }
  11743. // ResetUserID resets all changes to the "user_id" field.
  11744. func (m *CreditBalanceMutation) ResetUserID() {
  11745. m.user_id = nil
  11746. delete(m.clearedFields, creditbalance.FieldUserID)
  11747. }
  11748. // SetBalance sets the "balance" field.
  11749. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11750. m.balance = &f
  11751. m.addbalance = nil
  11752. }
  11753. // Balance returns the value of the "balance" field in the mutation.
  11754. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11755. v := m.balance
  11756. if v == nil {
  11757. return
  11758. }
  11759. return *v, true
  11760. }
  11761. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11762. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11764. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11765. if !m.op.Is(OpUpdateOne) {
  11766. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11767. }
  11768. if m.id == nil || m.oldValue == nil {
  11769. return v, errors.New("OldBalance requires an ID field in the mutation")
  11770. }
  11771. oldValue, err := m.oldValue(ctx)
  11772. if err != nil {
  11773. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11774. }
  11775. return oldValue.Balance, nil
  11776. }
  11777. // AddBalance adds f to the "balance" field.
  11778. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11779. if m.addbalance != nil {
  11780. *m.addbalance += f
  11781. } else {
  11782. m.addbalance = &f
  11783. }
  11784. }
  11785. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11786. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11787. v := m.addbalance
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // ResetBalance resets all changes to the "balance" field.
  11794. func (m *CreditBalanceMutation) ResetBalance() {
  11795. m.balance = nil
  11796. m.addbalance = nil
  11797. }
  11798. // SetStatus sets the "status" field.
  11799. func (m *CreditBalanceMutation) SetStatus(i int) {
  11800. m.status = &i
  11801. m.addstatus = nil
  11802. }
  11803. // Status returns the value of the "status" field in the mutation.
  11804. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11805. v := m.status
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11812. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11814. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11815. if !m.op.Is(OpUpdateOne) {
  11816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11817. }
  11818. if m.id == nil || m.oldValue == nil {
  11819. return v, errors.New("OldStatus requires an ID field in the mutation")
  11820. }
  11821. oldValue, err := m.oldValue(ctx)
  11822. if err != nil {
  11823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11824. }
  11825. return oldValue.Status, nil
  11826. }
  11827. // AddStatus adds i to the "status" field.
  11828. func (m *CreditBalanceMutation) AddStatus(i int) {
  11829. if m.addstatus != nil {
  11830. *m.addstatus += i
  11831. } else {
  11832. m.addstatus = &i
  11833. }
  11834. }
  11835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11836. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11837. v := m.addstatus
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // ClearStatus clears the value of the "status" field.
  11844. func (m *CreditBalanceMutation) ClearStatus() {
  11845. m.status = nil
  11846. m.addstatus = nil
  11847. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11848. }
  11849. // StatusCleared returns if the "status" field was cleared in this mutation.
  11850. func (m *CreditBalanceMutation) StatusCleared() bool {
  11851. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11852. return ok
  11853. }
  11854. // ResetStatus resets all changes to the "status" field.
  11855. func (m *CreditBalanceMutation) ResetStatus() {
  11856. m.status = nil
  11857. m.addstatus = nil
  11858. delete(m.clearedFields, creditbalance.FieldStatus)
  11859. }
  11860. // SetOrganizationID sets the "organization_id" field.
  11861. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11862. m.organization_id = &u
  11863. m.addorganization_id = nil
  11864. }
  11865. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11866. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11867. v := m.organization_id
  11868. if v == nil {
  11869. return
  11870. }
  11871. return *v, true
  11872. }
  11873. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11874. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11876. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11877. if !m.op.Is(OpUpdateOne) {
  11878. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11879. }
  11880. if m.id == nil || m.oldValue == nil {
  11881. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11882. }
  11883. oldValue, err := m.oldValue(ctx)
  11884. if err != nil {
  11885. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11886. }
  11887. return oldValue.OrganizationID, nil
  11888. }
  11889. // AddOrganizationID adds u to the "organization_id" field.
  11890. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11891. if m.addorganization_id != nil {
  11892. *m.addorganization_id += u
  11893. } else {
  11894. m.addorganization_id = &u
  11895. }
  11896. }
  11897. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11898. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11899. v := m.addorganization_id
  11900. if v == nil {
  11901. return
  11902. }
  11903. return *v, true
  11904. }
  11905. // ClearOrganizationID clears the value of the "organization_id" field.
  11906. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11907. m.organization_id = nil
  11908. m.addorganization_id = nil
  11909. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11910. }
  11911. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11912. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11913. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11914. return ok
  11915. }
  11916. // ResetOrganizationID resets all changes to the "organization_id" field.
  11917. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11918. m.organization_id = nil
  11919. m.addorganization_id = nil
  11920. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11921. }
  11922. // Where appends a list predicates to the CreditBalanceMutation builder.
  11923. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11924. m.predicates = append(m.predicates, ps...)
  11925. }
  11926. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11927. // users can use type-assertion to append predicates that do not depend on any generated package.
  11928. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11929. p := make([]predicate.CreditBalance, len(ps))
  11930. for i := range ps {
  11931. p[i] = ps[i]
  11932. }
  11933. m.Where(p...)
  11934. }
  11935. // Op returns the operation name.
  11936. func (m *CreditBalanceMutation) Op() Op {
  11937. return m.op
  11938. }
  11939. // SetOp allows setting the mutation operation.
  11940. func (m *CreditBalanceMutation) SetOp(op Op) {
  11941. m.op = op
  11942. }
  11943. // Type returns the node type of this mutation (CreditBalance).
  11944. func (m *CreditBalanceMutation) Type() string {
  11945. return m.typ
  11946. }
  11947. // Fields returns all fields that were changed during this mutation. Note that in
  11948. // order to get all numeric fields that were incremented/decremented, call
  11949. // AddedFields().
  11950. func (m *CreditBalanceMutation) Fields() []string {
  11951. fields := make([]string, 0, 7)
  11952. if m.created_at != nil {
  11953. fields = append(fields, creditbalance.FieldCreatedAt)
  11954. }
  11955. if m.updated_at != nil {
  11956. fields = append(fields, creditbalance.FieldUpdatedAt)
  11957. }
  11958. if m.deleted_at != nil {
  11959. fields = append(fields, creditbalance.FieldDeletedAt)
  11960. }
  11961. if m.user_id != nil {
  11962. fields = append(fields, creditbalance.FieldUserID)
  11963. }
  11964. if m.balance != nil {
  11965. fields = append(fields, creditbalance.FieldBalance)
  11966. }
  11967. if m.status != nil {
  11968. fields = append(fields, creditbalance.FieldStatus)
  11969. }
  11970. if m.organization_id != nil {
  11971. fields = append(fields, creditbalance.FieldOrganizationID)
  11972. }
  11973. return fields
  11974. }
  11975. // Field returns the value of a field with the given name. The second boolean
  11976. // return value indicates that this field was not set, or was not defined in the
  11977. // schema.
  11978. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditbalance.FieldCreatedAt:
  11981. return m.CreatedAt()
  11982. case creditbalance.FieldUpdatedAt:
  11983. return m.UpdatedAt()
  11984. case creditbalance.FieldDeletedAt:
  11985. return m.DeletedAt()
  11986. case creditbalance.FieldUserID:
  11987. return m.UserID()
  11988. case creditbalance.FieldBalance:
  11989. return m.Balance()
  11990. case creditbalance.FieldStatus:
  11991. return m.Status()
  11992. case creditbalance.FieldOrganizationID:
  11993. return m.OrganizationID()
  11994. }
  11995. return nil, false
  11996. }
  11997. // OldField returns the old value of the field from the database. An error is
  11998. // returned if the mutation operation is not UpdateOne, or the query to the
  11999. // database failed.
  12000. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12001. switch name {
  12002. case creditbalance.FieldCreatedAt:
  12003. return m.OldCreatedAt(ctx)
  12004. case creditbalance.FieldUpdatedAt:
  12005. return m.OldUpdatedAt(ctx)
  12006. case creditbalance.FieldDeletedAt:
  12007. return m.OldDeletedAt(ctx)
  12008. case creditbalance.FieldUserID:
  12009. return m.OldUserID(ctx)
  12010. case creditbalance.FieldBalance:
  12011. return m.OldBalance(ctx)
  12012. case creditbalance.FieldStatus:
  12013. return m.OldStatus(ctx)
  12014. case creditbalance.FieldOrganizationID:
  12015. return m.OldOrganizationID(ctx)
  12016. }
  12017. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12018. }
  12019. // SetField sets the value of a field with the given name. It returns an error if
  12020. // the field is not defined in the schema, or if the type mismatched the field
  12021. // type.
  12022. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12023. switch name {
  12024. case creditbalance.FieldCreatedAt:
  12025. v, ok := value.(time.Time)
  12026. if !ok {
  12027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12028. }
  12029. m.SetCreatedAt(v)
  12030. return nil
  12031. case creditbalance.FieldUpdatedAt:
  12032. v, ok := value.(time.Time)
  12033. if !ok {
  12034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12035. }
  12036. m.SetUpdatedAt(v)
  12037. return nil
  12038. case creditbalance.FieldDeletedAt:
  12039. v, ok := value.(time.Time)
  12040. if !ok {
  12041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12042. }
  12043. m.SetDeletedAt(v)
  12044. return nil
  12045. case creditbalance.FieldUserID:
  12046. v, ok := value.(string)
  12047. if !ok {
  12048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12049. }
  12050. m.SetUserID(v)
  12051. return nil
  12052. case creditbalance.FieldBalance:
  12053. v, ok := value.(float32)
  12054. if !ok {
  12055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12056. }
  12057. m.SetBalance(v)
  12058. return nil
  12059. case creditbalance.FieldStatus:
  12060. v, ok := value.(int)
  12061. if !ok {
  12062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12063. }
  12064. m.SetStatus(v)
  12065. return nil
  12066. case creditbalance.FieldOrganizationID:
  12067. v, ok := value.(uint64)
  12068. if !ok {
  12069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12070. }
  12071. m.SetOrganizationID(v)
  12072. return nil
  12073. }
  12074. return fmt.Errorf("unknown CreditBalance field %s", name)
  12075. }
  12076. // AddedFields returns all numeric fields that were incremented/decremented during
  12077. // this mutation.
  12078. func (m *CreditBalanceMutation) AddedFields() []string {
  12079. var fields []string
  12080. if m.addbalance != nil {
  12081. fields = append(fields, creditbalance.FieldBalance)
  12082. }
  12083. if m.addstatus != nil {
  12084. fields = append(fields, creditbalance.FieldStatus)
  12085. }
  12086. if m.addorganization_id != nil {
  12087. fields = append(fields, creditbalance.FieldOrganizationID)
  12088. }
  12089. return fields
  12090. }
  12091. // AddedField returns the numeric value that was incremented/decremented on a field
  12092. // with the given name. The second boolean return value indicates that this field
  12093. // was not set, or was not defined in the schema.
  12094. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12095. switch name {
  12096. case creditbalance.FieldBalance:
  12097. return m.AddedBalance()
  12098. case creditbalance.FieldStatus:
  12099. return m.AddedStatus()
  12100. case creditbalance.FieldOrganizationID:
  12101. return m.AddedOrganizationID()
  12102. }
  12103. return nil, false
  12104. }
  12105. // AddField adds the value to the field with the given name. It returns an error if
  12106. // the field is not defined in the schema, or if the type mismatched the field
  12107. // type.
  12108. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12109. switch name {
  12110. case creditbalance.FieldBalance:
  12111. v, ok := value.(float32)
  12112. if !ok {
  12113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12114. }
  12115. m.AddBalance(v)
  12116. return nil
  12117. case creditbalance.FieldStatus:
  12118. v, ok := value.(int)
  12119. if !ok {
  12120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12121. }
  12122. m.AddStatus(v)
  12123. return nil
  12124. case creditbalance.FieldOrganizationID:
  12125. v, ok := value.(int64)
  12126. if !ok {
  12127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12128. }
  12129. m.AddOrganizationID(v)
  12130. return nil
  12131. }
  12132. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12133. }
  12134. // ClearedFields returns all nullable fields that were cleared during this
  12135. // mutation.
  12136. func (m *CreditBalanceMutation) ClearedFields() []string {
  12137. var fields []string
  12138. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12139. fields = append(fields, creditbalance.FieldDeletedAt)
  12140. }
  12141. if m.FieldCleared(creditbalance.FieldUserID) {
  12142. fields = append(fields, creditbalance.FieldUserID)
  12143. }
  12144. if m.FieldCleared(creditbalance.FieldStatus) {
  12145. fields = append(fields, creditbalance.FieldStatus)
  12146. }
  12147. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12148. fields = append(fields, creditbalance.FieldOrganizationID)
  12149. }
  12150. return fields
  12151. }
  12152. // FieldCleared returns a boolean indicating if a field with the given name was
  12153. // cleared in this mutation.
  12154. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12155. _, ok := m.clearedFields[name]
  12156. return ok
  12157. }
  12158. // ClearField clears the value of the field with the given name. It returns an
  12159. // error if the field is not defined in the schema.
  12160. func (m *CreditBalanceMutation) ClearField(name string) error {
  12161. switch name {
  12162. case creditbalance.FieldDeletedAt:
  12163. m.ClearDeletedAt()
  12164. return nil
  12165. case creditbalance.FieldUserID:
  12166. m.ClearUserID()
  12167. return nil
  12168. case creditbalance.FieldStatus:
  12169. m.ClearStatus()
  12170. return nil
  12171. case creditbalance.FieldOrganizationID:
  12172. m.ClearOrganizationID()
  12173. return nil
  12174. }
  12175. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12176. }
  12177. // ResetField resets all changes in the mutation for the field with the given name.
  12178. // It returns an error if the field is not defined in the schema.
  12179. func (m *CreditBalanceMutation) ResetField(name string) error {
  12180. switch name {
  12181. case creditbalance.FieldCreatedAt:
  12182. m.ResetCreatedAt()
  12183. return nil
  12184. case creditbalance.FieldUpdatedAt:
  12185. m.ResetUpdatedAt()
  12186. return nil
  12187. case creditbalance.FieldDeletedAt:
  12188. m.ResetDeletedAt()
  12189. return nil
  12190. case creditbalance.FieldUserID:
  12191. m.ResetUserID()
  12192. return nil
  12193. case creditbalance.FieldBalance:
  12194. m.ResetBalance()
  12195. return nil
  12196. case creditbalance.FieldStatus:
  12197. m.ResetStatus()
  12198. return nil
  12199. case creditbalance.FieldOrganizationID:
  12200. m.ResetOrganizationID()
  12201. return nil
  12202. }
  12203. return fmt.Errorf("unknown CreditBalance field %s", name)
  12204. }
  12205. // AddedEdges returns all edge names that were set/added in this mutation.
  12206. func (m *CreditBalanceMutation) AddedEdges() []string {
  12207. edges := make([]string, 0, 0)
  12208. return edges
  12209. }
  12210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12211. // name in this mutation.
  12212. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12213. return nil
  12214. }
  12215. // RemovedEdges returns all edge names that were removed in this mutation.
  12216. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12217. edges := make([]string, 0, 0)
  12218. return edges
  12219. }
  12220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12221. // the given name in this mutation.
  12222. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12223. return nil
  12224. }
  12225. // ClearedEdges returns all edge names that were cleared in this mutation.
  12226. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12227. edges := make([]string, 0, 0)
  12228. return edges
  12229. }
  12230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12231. // was cleared in this mutation.
  12232. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12233. return false
  12234. }
  12235. // ClearEdge clears the value of the edge with the given name. It returns an error
  12236. // if that edge is not defined in the schema.
  12237. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12238. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12239. }
  12240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12241. // It returns an error if the edge is not defined in the schema.
  12242. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12243. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12244. }
  12245. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12246. type CreditUsageMutation struct {
  12247. config
  12248. op Op
  12249. typ string
  12250. id *uint64
  12251. created_at *time.Time
  12252. updated_at *time.Time
  12253. deleted_at *time.Time
  12254. user_id *string
  12255. number *float32
  12256. addnumber *float32
  12257. pay_number *float32
  12258. addpay_number *float32
  12259. before_number *float32
  12260. addbefore_number *float32
  12261. after_number *float32
  12262. addafter_number *float32
  12263. pay_method *string
  12264. status *int
  12265. addstatus *int
  12266. ntype *int
  12267. addntype *int
  12268. table *string
  12269. organization_id *uint64
  12270. addorganization_id *int64
  12271. nid *uint64
  12272. addnid *int64
  12273. reason *string
  12274. operator *string
  12275. clearedFields map[string]struct{}
  12276. done bool
  12277. oldValue func(context.Context) (*CreditUsage, error)
  12278. predicates []predicate.CreditUsage
  12279. }
  12280. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12281. // creditusageOption allows management of the mutation configuration using functional options.
  12282. type creditusageOption func(*CreditUsageMutation)
  12283. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12284. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12285. m := &CreditUsageMutation{
  12286. config: c,
  12287. op: op,
  12288. typ: TypeCreditUsage,
  12289. clearedFields: make(map[string]struct{}),
  12290. }
  12291. for _, opt := range opts {
  12292. opt(m)
  12293. }
  12294. return m
  12295. }
  12296. // withCreditUsageID sets the ID field of the mutation.
  12297. func withCreditUsageID(id uint64) creditusageOption {
  12298. return func(m *CreditUsageMutation) {
  12299. var (
  12300. err error
  12301. once sync.Once
  12302. value *CreditUsage
  12303. )
  12304. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12305. once.Do(func() {
  12306. if m.done {
  12307. err = errors.New("querying old values post mutation is not allowed")
  12308. } else {
  12309. value, err = m.Client().CreditUsage.Get(ctx, id)
  12310. }
  12311. })
  12312. return value, err
  12313. }
  12314. m.id = &id
  12315. }
  12316. }
  12317. // withCreditUsage sets the old CreditUsage of the mutation.
  12318. func withCreditUsage(node *CreditUsage) creditusageOption {
  12319. return func(m *CreditUsageMutation) {
  12320. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12321. return node, nil
  12322. }
  12323. m.id = &node.ID
  12324. }
  12325. }
  12326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12327. // executed in a transaction (ent.Tx), a transactional client is returned.
  12328. func (m CreditUsageMutation) Client() *Client {
  12329. client := &Client{config: m.config}
  12330. client.init()
  12331. return client
  12332. }
  12333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12334. // it returns an error otherwise.
  12335. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12336. if _, ok := m.driver.(*txDriver); !ok {
  12337. return nil, errors.New("ent: mutation is not running in a transaction")
  12338. }
  12339. tx := &Tx{config: m.config}
  12340. tx.init()
  12341. return tx, nil
  12342. }
  12343. // SetID sets the value of the id field. Note that this
  12344. // operation is only accepted on creation of CreditUsage entities.
  12345. func (m *CreditUsageMutation) SetID(id uint64) {
  12346. m.id = &id
  12347. }
  12348. // ID returns the ID value in the mutation. Note that the ID is only available
  12349. // if it was provided to the builder or after it was returned from the database.
  12350. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12351. if m.id == nil {
  12352. return
  12353. }
  12354. return *m.id, true
  12355. }
  12356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12357. // That means, if the mutation is applied within a transaction with an isolation level such
  12358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12359. // or updated by the mutation.
  12360. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12361. switch {
  12362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12363. id, exists := m.ID()
  12364. if exists {
  12365. return []uint64{id}, nil
  12366. }
  12367. fallthrough
  12368. case m.op.Is(OpUpdate | OpDelete):
  12369. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12370. default:
  12371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12372. }
  12373. }
  12374. // SetCreatedAt sets the "created_at" field.
  12375. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12376. m.created_at = &t
  12377. }
  12378. // CreatedAt returns the value of the "created_at" field in the mutation.
  12379. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12380. v := m.created_at
  12381. if v == nil {
  12382. return
  12383. }
  12384. return *v, true
  12385. }
  12386. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12387. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12389. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12390. if !m.op.Is(OpUpdateOne) {
  12391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12392. }
  12393. if m.id == nil || m.oldValue == nil {
  12394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12395. }
  12396. oldValue, err := m.oldValue(ctx)
  12397. if err != nil {
  12398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12399. }
  12400. return oldValue.CreatedAt, nil
  12401. }
  12402. // ResetCreatedAt resets all changes to the "created_at" field.
  12403. func (m *CreditUsageMutation) ResetCreatedAt() {
  12404. m.created_at = nil
  12405. }
  12406. // SetUpdatedAt sets the "updated_at" field.
  12407. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12408. m.updated_at = &t
  12409. }
  12410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12411. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12412. v := m.updated_at
  12413. if v == nil {
  12414. return
  12415. }
  12416. return *v, true
  12417. }
  12418. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12419. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12421. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12422. if !m.op.Is(OpUpdateOne) {
  12423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12424. }
  12425. if m.id == nil || m.oldValue == nil {
  12426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12427. }
  12428. oldValue, err := m.oldValue(ctx)
  12429. if err != nil {
  12430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12431. }
  12432. return oldValue.UpdatedAt, nil
  12433. }
  12434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12435. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12436. m.updated_at = nil
  12437. }
  12438. // SetDeletedAt sets the "deleted_at" field.
  12439. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12440. m.deleted_at = &t
  12441. }
  12442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12443. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12444. v := m.deleted_at
  12445. if v == nil {
  12446. return
  12447. }
  12448. return *v, true
  12449. }
  12450. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12451. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12453. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12454. if !m.op.Is(OpUpdateOne) {
  12455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12456. }
  12457. if m.id == nil || m.oldValue == nil {
  12458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12459. }
  12460. oldValue, err := m.oldValue(ctx)
  12461. if err != nil {
  12462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12463. }
  12464. return oldValue.DeletedAt, nil
  12465. }
  12466. // ClearDeletedAt clears the value of the "deleted_at" field.
  12467. func (m *CreditUsageMutation) ClearDeletedAt() {
  12468. m.deleted_at = nil
  12469. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12470. }
  12471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12472. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12473. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12474. return ok
  12475. }
  12476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12477. func (m *CreditUsageMutation) ResetDeletedAt() {
  12478. m.deleted_at = nil
  12479. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12480. }
  12481. // SetUserID sets the "user_id" field.
  12482. func (m *CreditUsageMutation) SetUserID(s string) {
  12483. m.user_id = &s
  12484. }
  12485. // UserID returns the value of the "user_id" field in the mutation.
  12486. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12487. v := m.user_id
  12488. if v == nil {
  12489. return
  12490. }
  12491. return *v, true
  12492. }
  12493. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12494. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12496. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12497. if !m.op.Is(OpUpdateOne) {
  12498. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12499. }
  12500. if m.id == nil || m.oldValue == nil {
  12501. return v, errors.New("OldUserID requires an ID field in the mutation")
  12502. }
  12503. oldValue, err := m.oldValue(ctx)
  12504. if err != nil {
  12505. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12506. }
  12507. return oldValue.UserID, nil
  12508. }
  12509. // ClearUserID clears the value of the "user_id" field.
  12510. func (m *CreditUsageMutation) ClearUserID() {
  12511. m.user_id = nil
  12512. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12513. }
  12514. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12515. func (m *CreditUsageMutation) UserIDCleared() bool {
  12516. _, ok := m.clearedFields[creditusage.FieldUserID]
  12517. return ok
  12518. }
  12519. // ResetUserID resets all changes to the "user_id" field.
  12520. func (m *CreditUsageMutation) ResetUserID() {
  12521. m.user_id = nil
  12522. delete(m.clearedFields, creditusage.FieldUserID)
  12523. }
  12524. // SetNumber sets the "number" field.
  12525. func (m *CreditUsageMutation) SetNumber(f float32) {
  12526. m.number = &f
  12527. m.addnumber = nil
  12528. }
  12529. // Number returns the value of the "number" field in the mutation.
  12530. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12531. v := m.number
  12532. if v == nil {
  12533. return
  12534. }
  12535. return *v, true
  12536. }
  12537. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12538. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12540. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12541. if !m.op.Is(OpUpdateOne) {
  12542. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12543. }
  12544. if m.id == nil || m.oldValue == nil {
  12545. return v, errors.New("OldNumber requires an ID field in the mutation")
  12546. }
  12547. oldValue, err := m.oldValue(ctx)
  12548. if err != nil {
  12549. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12550. }
  12551. return oldValue.Number, nil
  12552. }
  12553. // AddNumber adds f to the "number" field.
  12554. func (m *CreditUsageMutation) AddNumber(f float32) {
  12555. if m.addnumber != nil {
  12556. *m.addnumber += f
  12557. } else {
  12558. m.addnumber = &f
  12559. }
  12560. }
  12561. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12562. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12563. v := m.addnumber
  12564. if v == nil {
  12565. return
  12566. }
  12567. return *v, true
  12568. }
  12569. // ResetNumber resets all changes to the "number" field.
  12570. func (m *CreditUsageMutation) ResetNumber() {
  12571. m.number = nil
  12572. m.addnumber = nil
  12573. }
  12574. // SetPayNumber sets the "pay_number" field.
  12575. func (m *CreditUsageMutation) SetPayNumber(f float32) {
  12576. m.pay_number = &f
  12577. m.addpay_number = nil
  12578. }
  12579. // PayNumber returns the value of the "pay_number" field in the mutation.
  12580. func (m *CreditUsageMutation) PayNumber() (r float32, exists bool) {
  12581. v := m.pay_number
  12582. if v == nil {
  12583. return
  12584. }
  12585. return *v, true
  12586. }
  12587. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  12588. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12590. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float32, err error) {
  12591. if !m.op.Is(OpUpdateOne) {
  12592. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  12593. }
  12594. if m.id == nil || m.oldValue == nil {
  12595. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  12596. }
  12597. oldValue, err := m.oldValue(ctx)
  12598. if err != nil {
  12599. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  12600. }
  12601. return oldValue.PayNumber, nil
  12602. }
  12603. // AddPayNumber adds f to the "pay_number" field.
  12604. func (m *CreditUsageMutation) AddPayNumber(f float32) {
  12605. if m.addpay_number != nil {
  12606. *m.addpay_number += f
  12607. } else {
  12608. m.addpay_number = &f
  12609. }
  12610. }
  12611. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  12612. func (m *CreditUsageMutation) AddedPayNumber() (r float32, exists bool) {
  12613. v := m.addpay_number
  12614. if v == nil {
  12615. return
  12616. }
  12617. return *v, true
  12618. }
  12619. // ClearPayNumber clears the value of the "pay_number" field.
  12620. func (m *CreditUsageMutation) ClearPayNumber() {
  12621. m.pay_number = nil
  12622. m.addpay_number = nil
  12623. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  12624. }
  12625. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  12626. func (m *CreditUsageMutation) PayNumberCleared() bool {
  12627. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  12628. return ok
  12629. }
  12630. // ResetPayNumber resets all changes to the "pay_number" field.
  12631. func (m *CreditUsageMutation) ResetPayNumber() {
  12632. m.pay_number = nil
  12633. m.addpay_number = nil
  12634. delete(m.clearedFields, creditusage.FieldPayNumber)
  12635. }
  12636. // SetBeforeNumber sets the "before_number" field.
  12637. func (m *CreditUsageMutation) SetBeforeNumber(f float32) {
  12638. m.before_number = &f
  12639. m.addbefore_number = nil
  12640. }
  12641. // BeforeNumber returns the value of the "before_number" field in the mutation.
  12642. func (m *CreditUsageMutation) BeforeNumber() (r float32, exists bool) {
  12643. v := m.before_number
  12644. if v == nil {
  12645. return
  12646. }
  12647. return *v, true
  12648. }
  12649. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  12650. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12652. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float32, err error) {
  12653. if !m.op.Is(OpUpdateOne) {
  12654. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  12655. }
  12656. if m.id == nil || m.oldValue == nil {
  12657. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  12658. }
  12659. oldValue, err := m.oldValue(ctx)
  12660. if err != nil {
  12661. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  12662. }
  12663. return oldValue.BeforeNumber, nil
  12664. }
  12665. // AddBeforeNumber adds f to the "before_number" field.
  12666. func (m *CreditUsageMutation) AddBeforeNumber(f float32) {
  12667. if m.addbefore_number != nil {
  12668. *m.addbefore_number += f
  12669. } else {
  12670. m.addbefore_number = &f
  12671. }
  12672. }
  12673. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  12674. func (m *CreditUsageMutation) AddedBeforeNumber() (r float32, exists bool) {
  12675. v := m.addbefore_number
  12676. if v == nil {
  12677. return
  12678. }
  12679. return *v, true
  12680. }
  12681. // ClearBeforeNumber clears the value of the "before_number" field.
  12682. func (m *CreditUsageMutation) ClearBeforeNumber() {
  12683. m.before_number = nil
  12684. m.addbefore_number = nil
  12685. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  12686. }
  12687. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  12688. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  12689. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  12690. return ok
  12691. }
  12692. // ResetBeforeNumber resets all changes to the "before_number" field.
  12693. func (m *CreditUsageMutation) ResetBeforeNumber() {
  12694. m.before_number = nil
  12695. m.addbefore_number = nil
  12696. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  12697. }
  12698. // SetAfterNumber sets the "after_number" field.
  12699. func (m *CreditUsageMutation) SetAfterNumber(f float32) {
  12700. m.after_number = &f
  12701. m.addafter_number = nil
  12702. }
  12703. // AfterNumber returns the value of the "after_number" field in the mutation.
  12704. func (m *CreditUsageMutation) AfterNumber() (r float32, exists bool) {
  12705. v := m.after_number
  12706. if v == nil {
  12707. return
  12708. }
  12709. return *v, true
  12710. }
  12711. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  12712. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12714. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float32, err error) {
  12715. if !m.op.Is(OpUpdateOne) {
  12716. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  12717. }
  12718. if m.id == nil || m.oldValue == nil {
  12719. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  12720. }
  12721. oldValue, err := m.oldValue(ctx)
  12722. if err != nil {
  12723. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  12724. }
  12725. return oldValue.AfterNumber, nil
  12726. }
  12727. // AddAfterNumber adds f to the "after_number" field.
  12728. func (m *CreditUsageMutation) AddAfterNumber(f float32) {
  12729. if m.addafter_number != nil {
  12730. *m.addafter_number += f
  12731. } else {
  12732. m.addafter_number = &f
  12733. }
  12734. }
  12735. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  12736. func (m *CreditUsageMutation) AddedAfterNumber() (r float32, exists bool) {
  12737. v := m.addafter_number
  12738. if v == nil {
  12739. return
  12740. }
  12741. return *v, true
  12742. }
  12743. // ClearAfterNumber clears the value of the "after_number" field.
  12744. func (m *CreditUsageMutation) ClearAfterNumber() {
  12745. m.after_number = nil
  12746. m.addafter_number = nil
  12747. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  12748. }
  12749. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  12750. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  12751. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  12752. return ok
  12753. }
  12754. // ResetAfterNumber resets all changes to the "after_number" field.
  12755. func (m *CreditUsageMutation) ResetAfterNumber() {
  12756. m.after_number = nil
  12757. m.addafter_number = nil
  12758. delete(m.clearedFields, creditusage.FieldAfterNumber)
  12759. }
  12760. // SetPayMethod sets the "pay_method" field.
  12761. func (m *CreditUsageMutation) SetPayMethod(s string) {
  12762. m.pay_method = &s
  12763. }
  12764. // PayMethod returns the value of the "pay_method" field in the mutation.
  12765. func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
  12766. v := m.pay_method
  12767. if v == nil {
  12768. return
  12769. }
  12770. return *v, true
  12771. }
  12772. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  12773. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12775. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err error) {
  12776. if !m.op.Is(OpUpdateOne) {
  12777. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  12778. }
  12779. if m.id == nil || m.oldValue == nil {
  12780. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  12781. }
  12782. oldValue, err := m.oldValue(ctx)
  12783. if err != nil {
  12784. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  12785. }
  12786. return oldValue.PayMethod, nil
  12787. }
  12788. // ClearPayMethod clears the value of the "pay_method" field.
  12789. func (m *CreditUsageMutation) ClearPayMethod() {
  12790. m.pay_method = nil
  12791. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  12792. }
  12793. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  12794. func (m *CreditUsageMutation) PayMethodCleared() bool {
  12795. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  12796. return ok
  12797. }
  12798. // ResetPayMethod resets all changes to the "pay_method" field.
  12799. func (m *CreditUsageMutation) ResetPayMethod() {
  12800. m.pay_method = nil
  12801. delete(m.clearedFields, creditusage.FieldPayMethod)
  12802. }
  12803. // SetStatus sets the "status" field.
  12804. func (m *CreditUsageMutation) SetStatus(i int) {
  12805. m.status = &i
  12806. m.addstatus = nil
  12807. }
  12808. // Status returns the value of the "status" field in the mutation.
  12809. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12810. v := m.status
  12811. if v == nil {
  12812. return
  12813. }
  12814. return *v, true
  12815. }
  12816. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12817. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12819. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12820. if !m.op.Is(OpUpdateOne) {
  12821. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12822. }
  12823. if m.id == nil || m.oldValue == nil {
  12824. return v, errors.New("OldStatus requires an ID field in the mutation")
  12825. }
  12826. oldValue, err := m.oldValue(ctx)
  12827. if err != nil {
  12828. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12829. }
  12830. return oldValue.Status, nil
  12831. }
  12832. // AddStatus adds i to the "status" field.
  12833. func (m *CreditUsageMutation) AddStatus(i int) {
  12834. if m.addstatus != nil {
  12835. *m.addstatus += i
  12836. } else {
  12837. m.addstatus = &i
  12838. }
  12839. }
  12840. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12841. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12842. v := m.addstatus
  12843. if v == nil {
  12844. return
  12845. }
  12846. return *v, true
  12847. }
  12848. // ClearStatus clears the value of the "status" field.
  12849. func (m *CreditUsageMutation) ClearStatus() {
  12850. m.status = nil
  12851. m.addstatus = nil
  12852. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12853. }
  12854. // StatusCleared returns if the "status" field was cleared in this mutation.
  12855. func (m *CreditUsageMutation) StatusCleared() bool {
  12856. _, ok := m.clearedFields[creditusage.FieldStatus]
  12857. return ok
  12858. }
  12859. // ResetStatus resets all changes to the "status" field.
  12860. func (m *CreditUsageMutation) ResetStatus() {
  12861. m.status = nil
  12862. m.addstatus = nil
  12863. delete(m.clearedFields, creditusage.FieldStatus)
  12864. }
  12865. // SetNtype sets the "ntype" field.
  12866. func (m *CreditUsageMutation) SetNtype(i int) {
  12867. m.ntype = &i
  12868. m.addntype = nil
  12869. }
  12870. // Ntype returns the value of the "ntype" field in the mutation.
  12871. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12872. v := m.ntype
  12873. if v == nil {
  12874. return
  12875. }
  12876. return *v, true
  12877. }
  12878. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12879. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12881. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12882. if !m.op.Is(OpUpdateOne) {
  12883. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12884. }
  12885. if m.id == nil || m.oldValue == nil {
  12886. return v, errors.New("OldNtype requires an ID field in the mutation")
  12887. }
  12888. oldValue, err := m.oldValue(ctx)
  12889. if err != nil {
  12890. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12891. }
  12892. return oldValue.Ntype, nil
  12893. }
  12894. // AddNtype adds i to the "ntype" field.
  12895. func (m *CreditUsageMutation) AddNtype(i int) {
  12896. if m.addntype != nil {
  12897. *m.addntype += i
  12898. } else {
  12899. m.addntype = &i
  12900. }
  12901. }
  12902. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12903. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12904. v := m.addntype
  12905. if v == nil {
  12906. return
  12907. }
  12908. return *v, true
  12909. }
  12910. // ResetNtype resets all changes to the "ntype" field.
  12911. func (m *CreditUsageMutation) ResetNtype() {
  12912. m.ntype = nil
  12913. m.addntype = nil
  12914. }
  12915. // SetTable sets the "table" field.
  12916. func (m *CreditUsageMutation) SetTable(s string) {
  12917. m.table = &s
  12918. }
  12919. // Table returns the value of the "table" field in the mutation.
  12920. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12921. v := m.table
  12922. if v == nil {
  12923. return
  12924. }
  12925. return *v, true
  12926. }
  12927. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12928. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12930. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12931. if !m.op.Is(OpUpdateOne) {
  12932. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12933. }
  12934. if m.id == nil || m.oldValue == nil {
  12935. return v, errors.New("OldTable requires an ID field in the mutation")
  12936. }
  12937. oldValue, err := m.oldValue(ctx)
  12938. if err != nil {
  12939. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12940. }
  12941. return oldValue.Table, nil
  12942. }
  12943. // ResetTable resets all changes to the "table" field.
  12944. func (m *CreditUsageMutation) ResetTable() {
  12945. m.table = nil
  12946. }
  12947. // SetOrganizationID sets the "organization_id" field.
  12948. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12949. m.organization_id = &u
  12950. m.addorganization_id = nil
  12951. }
  12952. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12953. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12954. v := m.organization_id
  12955. if v == nil {
  12956. return
  12957. }
  12958. return *v, true
  12959. }
  12960. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12961. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12963. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12964. if !m.op.Is(OpUpdateOne) {
  12965. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12966. }
  12967. if m.id == nil || m.oldValue == nil {
  12968. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12969. }
  12970. oldValue, err := m.oldValue(ctx)
  12971. if err != nil {
  12972. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12973. }
  12974. return oldValue.OrganizationID, nil
  12975. }
  12976. // AddOrganizationID adds u to the "organization_id" field.
  12977. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12978. if m.addorganization_id != nil {
  12979. *m.addorganization_id += u
  12980. } else {
  12981. m.addorganization_id = &u
  12982. }
  12983. }
  12984. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12985. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12986. v := m.addorganization_id
  12987. if v == nil {
  12988. return
  12989. }
  12990. return *v, true
  12991. }
  12992. // ClearOrganizationID clears the value of the "organization_id" field.
  12993. func (m *CreditUsageMutation) ClearOrganizationID() {
  12994. m.organization_id = nil
  12995. m.addorganization_id = nil
  12996. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12997. }
  12998. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12999. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  13000. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  13001. return ok
  13002. }
  13003. // ResetOrganizationID resets all changes to the "organization_id" field.
  13004. func (m *CreditUsageMutation) ResetOrganizationID() {
  13005. m.organization_id = nil
  13006. m.addorganization_id = nil
  13007. delete(m.clearedFields, creditusage.FieldOrganizationID)
  13008. }
  13009. // SetNid sets the "nid" field.
  13010. func (m *CreditUsageMutation) SetNid(u uint64) {
  13011. m.nid = &u
  13012. m.addnid = nil
  13013. }
  13014. // Nid returns the value of the "nid" field in the mutation.
  13015. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  13016. v := m.nid
  13017. if v == nil {
  13018. return
  13019. }
  13020. return *v, true
  13021. }
  13022. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  13023. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13025. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  13026. if !m.op.Is(OpUpdateOne) {
  13027. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  13028. }
  13029. if m.id == nil || m.oldValue == nil {
  13030. return v, errors.New("OldNid requires an ID field in the mutation")
  13031. }
  13032. oldValue, err := m.oldValue(ctx)
  13033. if err != nil {
  13034. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  13035. }
  13036. return oldValue.Nid, nil
  13037. }
  13038. // AddNid adds u to the "nid" field.
  13039. func (m *CreditUsageMutation) AddNid(u int64) {
  13040. if m.addnid != nil {
  13041. *m.addnid += u
  13042. } else {
  13043. m.addnid = &u
  13044. }
  13045. }
  13046. // AddedNid returns the value that was added to the "nid" field in this mutation.
  13047. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  13048. v := m.addnid
  13049. if v == nil {
  13050. return
  13051. }
  13052. return *v, true
  13053. }
  13054. // ResetNid resets all changes to the "nid" field.
  13055. func (m *CreditUsageMutation) ResetNid() {
  13056. m.nid = nil
  13057. m.addnid = nil
  13058. }
  13059. // SetReason sets the "reason" field.
  13060. func (m *CreditUsageMutation) SetReason(s string) {
  13061. m.reason = &s
  13062. }
  13063. // Reason returns the value of the "reason" field in the mutation.
  13064. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  13065. v := m.reason
  13066. if v == nil {
  13067. return
  13068. }
  13069. return *v, true
  13070. }
  13071. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  13072. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13074. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  13075. if !m.op.Is(OpUpdateOne) {
  13076. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  13077. }
  13078. if m.id == nil || m.oldValue == nil {
  13079. return v, errors.New("OldReason requires an ID field in the mutation")
  13080. }
  13081. oldValue, err := m.oldValue(ctx)
  13082. if err != nil {
  13083. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  13084. }
  13085. return oldValue.Reason, nil
  13086. }
  13087. // ResetReason resets all changes to the "reason" field.
  13088. func (m *CreditUsageMutation) ResetReason() {
  13089. m.reason = nil
  13090. }
  13091. // SetOperator sets the "operator" field.
  13092. func (m *CreditUsageMutation) SetOperator(s string) {
  13093. m.operator = &s
  13094. }
  13095. // Operator returns the value of the "operator" field in the mutation.
  13096. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  13097. v := m.operator
  13098. if v == nil {
  13099. return
  13100. }
  13101. return *v, true
  13102. }
  13103. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  13104. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13106. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  13107. if !m.op.Is(OpUpdateOne) {
  13108. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  13109. }
  13110. if m.id == nil || m.oldValue == nil {
  13111. return v, errors.New("OldOperator requires an ID field in the mutation")
  13112. }
  13113. oldValue, err := m.oldValue(ctx)
  13114. if err != nil {
  13115. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  13116. }
  13117. return oldValue.Operator, nil
  13118. }
  13119. // ResetOperator resets all changes to the "operator" field.
  13120. func (m *CreditUsageMutation) ResetOperator() {
  13121. m.operator = nil
  13122. }
  13123. // Where appends a list predicates to the CreditUsageMutation builder.
  13124. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  13125. m.predicates = append(m.predicates, ps...)
  13126. }
  13127. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  13128. // users can use type-assertion to append predicates that do not depend on any generated package.
  13129. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  13130. p := make([]predicate.CreditUsage, len(ps))
  13131. for i := range ps {
  13132. p[i] = ps[i]
  13133. }
  13134. m.Where(p...)
  13135. }
  13136. // Op returns the operation name.
  13137. func (m *CreditUsageMutation) Op() Op {
  13138. return m.op
  13139. }
  13140. // SetOp allows setting the mutation operation.
  13141. func (m *CreditUsageMutation) SetOp(op Op) {
  13142. m.op = op
  13143. }
  13144. // Type returns the node type of this mutation (CreditUsage).
  13145. func (m *CreditUsageMutation) Type() string {
  13146. return m.typ
  13147. }
  13148. // Fields returns all fields that were changed during this mutation. Note that in
  13149. // order to get all numeric fields that were incremented/decremented, call
  13150. // AddedFields().
  13151. func (m *CreditUsageMutation) Fields() []string {
  13152. fields := make([]string, 0, 16)
  13153. if m.created_at != nil {
  13154. fields = append(fields, creditusage.FieldCreatedAt)
  13155. }
  13156. if m.updated_at != nil {
  13157. fields = append(fields, creditusage.FieldUpdatedAt)
  13158. }
  13159. if m.deleted_at != nil {
  13160. fields = append(fields, creditusage.FieldDeletedAt)
  13161. }
  13162. if m.user_id != nil {
  13163. fields = append(fields, creditusage.FieldUserID)
  13164. }
  13165. if m.number != nil {
  13166. fields = append(fields, creditusage.FieldNumber)
  13167. }
  13168. if m.pay_number != nil {
  13169. fields = append(fields, creditusage.FieldPayNumber)
  13170. }
  13171. if m.before_number != nil {
  13172. fields = append(fields, creditusage.FieldBeforeNumber)
  13173. }
  13174. if m.after_number != nil {
  13175. fields = append(fields, creditusage.FieldAfterNumber)
  13176. }
  13177. if m.pay_method != nil {
  13178. fields = append(fields, creditusage.FieldPayMethod)
  13179. }
  13180. if m.status != nil {
  13181. fields = append(fields, creditusage.FieldStatus)
  13182. }
  13183. if m.ntype != nil {
  13184. fields = append(fields, creditusage.FieldNtype)
  13185. }
  13186. if m.table != nil {
  13187. fields = append(fields, creditusage.FieldTable)
  13188. }
  13189. if m.organization_id != nil {
  13190. fields = append(fields, creditusage.FieldOrganizationID)
  13191. }
  13192. if m.nid != nil {
  13193. fields = append(fields, creditusage.FieldNid)
  13194. }
  13195. if m.reason != nil {
  13196. fields = append(fields, creditusage.FieldReason)
  13197. }
  13198. if m.operator != nil {
  13199. fields = append(fields, creditusage.FieldOperator)
  13200. }
  13201. return fields
  13202. }
  13203. // Field returns the value of a field with the given name. The second boolean
  13204. // return value indicates that this field was not set, or was not defined in the
  13205. // schema.
  13206. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  13207. switch name {
  13208. case creditusage.FieldCreatedAt:
  13209. return m.CreatedAt()
  13210. case creditusage.FieldUpdatedAt:
  13211. return m.UpdatedAt()
  13212. case creditusage.FieldDeletedAt:
  13213. return m.DeletedAt()
  13214. case creditusage.FieldUserID:
  13215. return m.UserID()
  13216. case creditusage.FieldNumber:
  13217. return m.Number()
  13218. case creditusage.FieldPayNumber:
  13219. return m.PayNumber()
  13220. case creditusage.FieldBeforeNumber:
  13221. return m.BeforeNumber()
  13222. case creditusage.FieldAfterNumber:
  13223. return m.AfterNumber()
  13224. case creditusage.FieldPayMethod:
  13225. return m.PayMethod()
  13226. case creditusage.FieldStatus:
  13227. return m.Status()
  13228. case creditusage.FieldNtype:
  13229. return m.Ntype()
  13230. case creditusage.FieldTable:
  13231. return m.Table()
  13232. case creditusage.FieldOrganizationID:
  13233. return m.OrganizationID()
  13234. case creditusage.FieldNid:
  13235. return m.Nid()
  13236. case creditusage.FieldReason:
  13237. return m.Reason()
  13238. case creditusage.FieldOperator:
  13239. return m.Operator()
  13240. }
  13241. return nil, false
  13242. }
  13243. // OldField returns the old value of the field from the database. An error is
  13244. // returned if the mutation operation is not UpdateOne, or the query to the
  13245. // database failed.
  13246. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13247. switch name {
  13248. case creditusage.FieldCreatedAt:
  13249. return m.OldCreatedAt(ctx)
  13250. case creditusage.FieldUpdatedAt:
  13251. return m.OldUpdatedAt(ctx)
  13252. case creditusage.FieldDeletedAt:
  13253. return m.OldDeletedAt(ctx)
  13254. case creditusage.FieldUserID:
  13255. return m.OldUserID(ctx)
  13256. case creditusage.FieldNumber:
  13257. return m.OldNumber(ctx)
  13258. case creditusage.FieldPayNumber:
  13259. return m.OldPayNumber(ctx)
  13260. case creditusage.FieldBeforeNumber:
  13261. return m.OldBeforeNumber(ctx)
  13262. case creditusage.FieldAfterNumber:
  13263. return m.OldAfterNumber(ctx)
  13264. case creditusage.FieldPayMethod:
  13265. return m.OldPayMethod(ctx)
  13266. case creditusage.FieldStatus:
  13267. return m.OldStatus(ctx)
  13268. case creditusage.FieldNtype:
  13269. return m.OldNtype(ctx)
  13270. case creditusage.FieldTable:
  13271. return m.OldTable(ctx)
  13272. case creditusage.FieldOrganizationID:
  13273. return m.OldOrganizationID(ctx)
  13274. case creditusage.FieldNid:
  13275. return m.OldNid(ctx)
  13276. case creditusage.FieldReason:
  13277. return m.OldReason(ctx)
  13278. case creditusage.FieldOperator:
  13279. return m.OldOperator(ctx)
  13280. }
  13281. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13282. }
  13283. // SetField sets the value of a field with the given name. It returns an error if
  13284. // the field is not defined in the schema, or if the type mismatched the field
  13285. // type.
  13286. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13287. switch name {
  13288. case creditusage.FieldCreatedAt:
  13289. v, ok := value.(time.Time)
  13290. if !ok {
  13291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13292. }
  13293. m.SetCreatedAt(v)
  13294. return nil
  13295. case creditusage.FieldUpdatedAt:
  13296. v, ok := value.(time.Time)
  13297. if !ok {
  13298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13299. }
  13300. m.SetUpdatedAt(v)
  13301. return nil
  13302. case creditusage.FieldDeletedAt:
  13303. v, ok := value.(time.Time)
  13304. if !ok {
  13305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13306. }
  13307. m.SetDeletedAt(v)
  13308. return nil
  13309. case creditusage.FieldUserID:
  13310. v, ok := value.(string)
  13311. if !ok {
  13312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13313. }
  13314. m.SetUserID(v)
  13315. return nil
  13316. case creditusage.FieldNumber:
  13317. v, ok := value.(float32)
  13318. if !ok {
  13319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13320. }
  13321. m.SetNumber(v)
  13322. return nil
  13323. case creditusage.FieldPayNumber:
  13324. v, ok := value.(float32)
  13325. if !ok {
  13326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13327. }
  13328. m.SetPayNumber(v)
  13329. return nil
  13330. case creditusage.FieldBeforeNumber:
  13331. v, ok := value.(float32)
  13332. if !ok {
  13333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13334. }
  13335. m.SetBeforeNumber(v)
  13336. return nil
  13337. case creditusage.FieldAfterNumber:
  13338. v, ok := value.(float32)
  13339. if !ok {
  13340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13341. }
  13342. m.SetAfterNumber(v)
  13343. return nil
  13344. case creditusage.FieldPayMethod:
  13345. v, ok := value.(string)
  13346. if !ok {
  13347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13348. }
  13349. m.SetPayMethod(v)
  13350. return nil
  13351. case creditusage.FieldStatus:
  13352. v, ok := value.(int)
  13353. if !ok {
  13354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13355. }
  13356. m.SetStatus(v)
  13357. return nil
  13358. case creditusage.FieldNtype:
  13359. v, ok := value.(int)
  13360. if !ok {
  13361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13362. }
  13363. m.SetNtype(v)
  13364. return nil
  13365. case creditusage.FieldTable:
  13366. v, ok := value.(string)
  13367. if !ok {
  13368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13369. }
  13370. m.SetTable(v)
  13371. return nil
  13372. case creditusage.FieldOrganizationID:
  13373. v, ok := value.(uint64)
  13374. if !ok {
  13375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13376. }
  13377. m.SetOrganizationID(v)
  13378. return nil
  13379. case creditusage.FieldNid:
  13380. v, ok := value.(uint64)
  13381. if !ok {
  13382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13383. }
  13384. m.SetNid(v)
  13385. return nil
  13386. case creditusage.FieldReason:
  13387. v, ok := value.(string)
  13388. if !ok {
  13389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13390. }
  13391. m.SetReason(v)
  13392. return nil
  13393. case creditusage.FieldOperator:
  13394. v, ok := value.(string)
  13395. if !ok {
  13396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13397. }
  13398. m.SetOperator(v)
  13399. return nil
  13400. }
  13401. return fmt.Errorf("unknown CreditUsage field %s", name)
  13402. }
  13403. // AddedFields returns all numeric fields that were incremented/decremented during
  13404. // this mutation.
  13405. func (m *CreditUsageMutation) AddedFields() []string {
  13406. var fields []string
  13407. if m.addnumber != nil {
  13408. fields = append(fields, creditusage.FieldNumber)
  13409. }
  13410. if m.addpay_number != nil {
  13411. fields = append(fields, creditusage.FieldPayNumber)
  13412. }
  13413. if m.addbefore_number != nil {
  13414. fields = append(fields, creditusage.FieldBeforeNumber)
  13415. }
  13416. if m.addafter_number != nil {
  13417. fields = append(fields, creditusage.FieldAfterNumber)
  13418. }
  13419. if m.addstatus != nil {
  13420. fields = append(fields, creditusage.FieldStatus)
  13421. }
  13422. if m.addntype != nil {
  13423. fields = append(fields, creditusage.FieldNtype)
  13424. }
  13425. if m.addorganization_id != nil {
  13426. fields = append(fields, creditusage.FieldOrganizationID)
  13427. }
  13428. if m.addnid != nil {
  13429. fields = append(fields, creditusage.FieldNid)
  13430. }
  13431. return fields
  13432. }
  13433. // AddedField returns the numeric value that was incremented/decremented on a field
  13434. // with the given name. The second boolean return value indicates that this field
  13435. // was not set, or was not defined in the schema.
  13436. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13437. switch name {
  13438. case creditusage.FieldNumber:
  13439. return m.AddedNumber()
  13440. case creditusage.FieldPayNumber:
  13441. return m.AddedPayNumber()
  13442. case creditusage.FieldBeforeNumber:
  13443. return m.AddedBeforeNumber()
  13444. case creditusage.FieldAfterNumber:
  13445. return m.AddedAfterNumber()
  13446. case creditusage.FieldStatus:
  13447. return m.AddedStatus()
  13448. case creditusage.FieldNtype:
  13449. return m.AddedNtype()
  13450. case creditusage.FieldOrganizationID:
  13451. return m.AddedOrganizationID()
  13452. case creditusage.FieldNid:
  13453. return m.AddedNid()
  13454. }
  13455. return nil, false
  13456. }
  13457. // AddField adds the value to the field with the given name. It returns an error if
  13458. // the field is not defined in the schema, or if the type mismatched the field
  13459. // type.
  13460. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13461. switch name {
  13462. case creditusage.FieldNumber:
  13463. v, ok := value.(float32)
  13464. if !ok {
  13465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13466. }
  13467. m.AddNumber(v)
  13468. return nil
  13469. case creditusage.FieldPayNumber:
  13470. v, ok := value.(float32)
  13471. if !ok {
  13472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13473. }
  13474. m.AddPayNumber(v)
  13475. return nil
  13476. case creditusage.FieldBeforeNumber:
  13477. v, ok := value.(float32)
  13478. if !ok {
  13479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13480. }
  13481. m.AddBeforeNumber(v)
  13482. return nil
  13483. case creditusage.FieldAfterNumber:
  13484. v, ok := value.(float32)
  13485. if !ok {
  13486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13487. }
  13488. m.AddAfterNumber(v)
  13489. return nil
  13490. case creditusage.FieldStatus:
  13491. v, ok := value.(int)
  13492. if !ok {
  13493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13494. }
  13495. m.AddStatus(v)
  13496. return nil
  13497. case creditusage.FieldNtype:
  13498. v, ok := value.(int)
  13499. if !ok {
  13500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13501. }
  13502. m.AddNtype(v)
  13503. return nil
  13504. case creditusage.FieldOrganizationID:
  13505. v, ok := value.(int64)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.AddOrganizationID(v)
  13510. return nil
  13511. case creditusage.FieldNid:
  13512. v, ok := value.(int64)
  13513. if !ok {
  13514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13515. }
  13516. m.AddNid(v)
  13517. return nil
  13518. }
  13519. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13520. }
  13521. // ClearedFields returns all nullable fields that were cleared during this
  13522. // mutation.
  13523. func (m *CreditUsageMutation) ClearedFields() []string {
  13524. var fields []string
  13525. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13526. fields = append(fields, creditusage.FieldDeletedAt)
  13527. }
  13528. if m.FieldCleared(creditusage.FieldUserID) {
  13529. fields = append(fields, creditusage.FieldUserID)
  13530. }
  13531. if m.FieldCleared(creditusage.FieldPayNumber) {
  13532. fields = append(fields, creditusage.FieldPayNumber)
  13533. }
  13534. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  13535. fields = append(fields, creditusage.FieldBeforeNumber)
  13536. }
  13537. if m.FieldCleared(creditusage.FieldAfterNumber) {
  13538. fields = append(fields, creditusage.FieldAfterNumber)
  13539. }
  13540. if m.FieldCleared(creditusage.FieldPayMethod) {
  13541. fields = append(fields, creditusage.FieldPayMethod)
  13542. }
  13543. if m.FieldCleared(creditusage.FieldStatus) {
  13544. fields = append(fields, creditusage.FieldStatus)
  13545. }
  13546. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13547. fields = append(fields, creditusage.FieldOrganizationID)
  13548. }
  13549. return fields
  13550. }
  13551. // FieldCleared returns a boolean indicating if a field with the given name was
  13552. // cleared in this mutation.
  13553. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13554. _, ok := m.clearedFields[name]
  13555. return ok
  13556. }
  13557. // ClearField clears the value of the field with the given name. It returns an
  13558. // error if the field is not defined in the schema.
  13559. func (m *CreditUsageMutation) ClearField(name string) error {
  13560. switch name {
  13561. case creditusage.FieldDeletedAt:
  13562. m.ClearDeletedAt()
  13563. return nil
  13564. case creditusage.FieldUserID:
  13565. m.ClearUserID()
  13566. return nil
  13567. case creditusage.FieldPayNumber:
  13568. m.ClearPayNumber()
  13569. return nil
  13570. case creditusage.FieldBeforeNumber:
  13571. m.ClearBeforeNumber()
  13572. return nil
  13573. case creditusage.FieldAfterNumber:
  13574. m.ClearAfterNumber()
  13575. return nil
  13576. case creditusage.FieldPayMethod:
  13577. m.ClearPayMethod()
  13578. return nil
  13579. case creditusage.FieldStatus:
  13580. m.ClearStatus()
  13581. return nil
  13582. case creditusage.FieldOrganizationID:
  13583. m.ClearOrganizationID()
  13584. return nil
  13585. }
  13586. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13587. }
  13588. // ResetField resets all changes in the mutation for the field with the given name.
  13589. // It returns an error if the field is not defined in the schema.
  13590. func (m *CreditUsageMutation) ResetField(name string) error {
  13591. switch name {
  13592. case creditusage.FieldCreatedAt:
  13593. m.ResetCreatedAt()
  13594. return nil
  13595. case creditusage.FieldUpdatedAt:
  13596. m.ResetUpdatedAt()
  13597. return nil
  13598. case creditusage.FieldDeletedAt:
  13599. m.ResetDeletedAt()
  13600. return nil
  13601. case creditusage.FieldUserID:
  13602. m.ResetUserID()
  13603. return nil
  13604. case creditusage.FieldNumber:
  13605. m.ResetNumber()
  13606. return nil
  13607. case creditusage.FieldPayNumber:
  13608. m.ResetPayNumber()
  13609. return nil
  13610. case creditusage.FieldBeforeNumber:
  13611. m.ResetBeforeNumber()
  13612. return nil
  13613. case creditusage.FieldAfterNumber:
  13614. m.ResetAfterNumber()
  13615. return nil
  13616. case creditusage.FieldPayMethod:
  13617. m.ResetPayMethod()
  13618. return nil
  13619. case creditusage.FieldStatus:
  13620. m.ResetStatus()
  13621. return nil
  13622. case creditusage.FieldNtype:
  13623. m.ResetNtype()
  13624. return nil
  13625. case creditusage.FieldTable:
  13626. m.ResetTable()
  13627. return nil
  13628. case creditusage.FieldOrganizationID:
  13629. m.ResetOrganizationID()
  13630. return nil
  13631. case creditusage.FieldNid:
  13632. m.ResetNid()
  13633. return nil
  13634. case creditusage.FieldReason:
  13635. m.ResetReason()
  13636. return nil
  13637. case creditusage.FieldOperator:
  13638. m.ResetOperator()
  13639. return nil
  13640. }
  13641. return fmt.Errorf("unknown CreditUsage field %s", name)
  13642. }
  13643. // AddedEdges returns all edge names that were set/added in this mutation.
  13644. func (m *CreditUsageMutation) AddedEdges() []string {
  13645. edges := make([]string, 0, 0)
  13646. return edges
  13647. }
  13648. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13649. // name in this mutation.
  13650. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13651. return nil
  13652. }
  13653. // RemovedEdges returns all edge names that were removed in this mutation.
  13654. func (m *CreditUsageMutation) RemovedEdges() []string {
  13655. edges := make([]string, 0, 0)
  13656. return edges
  13657. }
  13658. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13659. // the given name in this mutation.
  13660. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13661. return nil
  13662. }
  13663. // ClearedEdges returns all edge names that were cleared in this mutation.
  13664. func (m *CreditUsageMutation) ClearedEdges() []string {
  13665. edges := make([]string, 0, 0)
  13666. return edges
  13667. }
  13668. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13669. // was cleared in this mutation.
  13670. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13671. return false
  13672. }
  13673. // ClearEdge clears the value of the edge with the given name. It returns an error
  13674. // if that edge is not defined in the schema.
  13675. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13676. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13677. }
  13678. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13679. // It returns an error if the edge is not defined in the schema.
  13680. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13681. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13682. }
  13683. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13684. type EmployeeMutation struct {
  13685. config
  13686. op Op
  13687. typ string
  13688. id *uint64
  13689. created_at *time.Time
  13690. updated_at *time.Time
  13691. deleted_at *time.Time
  13692. title *string
  13693. avatar *string
  13694. tags *string
  13695. hire_count *int
  13696. addhire_count *int
  13697. service_count *int
  13698. addservice_count *int
  13699. achievement_count *int
  13700. addachievement_count *int
  13701. intro *string
  13702. estimate *string
  13703. skill *string
  13704. ability_type *string
  13705. scene *string
  13706. switch_in *string
  13707. video_url *string
  13708. organization_id *uint64
  13709. addorganization_id *int64
  13710. category_id *uint64
  13711. addcategory_id *int64
  13712. api_base *string
  13713. api_key *string
  13714. ai_info *string
  13715. is_vip *int
  13716. addis_vip *int
  13717. chat_url *string
  13718. clearedFields map[string]struct{}
  13719. em_work_experiences map[uint64]struct{}
  13720. removedem_work_experiences map[uint64]struct{}
  13721. clearedem_work_experiences bool
  13722. em_tutorial map[uint64]struct{}
  13723. removedem_tutorial map[uint64]struct{}
  13724. clearedem_tutorial bool
  13725. done bool
  13726. oldValue func(context.Context) (*Employee, error)
  13727. predicates []predicate.Employee
  13728. }
  13729. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13730. // employeeOption allows management of the mutation configuration using functional options.
  13731. type employeeOption func(*EmployeeMutation)
  13732. // newEmployeeMutation creates new mutation for the Employee entity.
  13733. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13734. m := &EmployeeMutation{
  13735. config: c,
  13736. op: op,
  13737. typ: TypeEmployee,
  13738. clearedFields: make(map[string]struct{}),
  13739. }
  13740. for _, opt := range opts {
  13741. opt(m)
  13742. }
  13743. return m
  13744. }
  13745. // withEmployeeID sets the ID field of the mutation.
  13746. func withEmployeeID(id uint64) employeeOption {
  13747. return func(m *EmployeeMutation) {
  13748. var (
  13749. err error
  13750. once sync.Once
  13751. value *Employee
  13752. )
  13753. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13754. once.Do(func() {
  13755. if m.done {
  13756. err = errors.New("querying old values post mutation is not allowed")
  13757. } else {
  13758. value, err = m.Client().Employee.Get(ctx, id)
  13759. }
  13760. })
  13761. return value, err
  13762. }
  13763. m.id = &id
  13764. }
  13765. }
  13766. // withEmployee sets the old Employee of the mutation.
  13767. func withEmployee(node *Employee) employeeOption {
  13768. return func(m *EmployeeMutation) {
  13769. m.oldValue = func(context.Context) (*Employee, error) {
  13770. return node, nil
  13771. }
  13772. m.id = &node.ID
  13773. }
  13774. }
  13775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13776. // executed in a transaction (ent.Tx), a transactional client is returned.
  13777. func (m EmployeeMutation) Client() *Client {
  13778. client := &Client{config: m.config}
  13779. client.init()
  13780. return client
  13781. }
  13782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13783. // it returns an error otherwise.
  13784. func (m EmployeeMutation) Tx() (*Tx, error) {
  13785. if _, ok := m.driver.(*txDriver); !ok {
  13786. return nil, errors.New("ent: mutation is not running in a transaction")
  13787. }
  13788. tx := &Tx{config: m.config}
  13789. tx.init()
  13790. return tx, nil
  13791. }
  13792. // SetID sets the value of the id field. Note that this
  13793. // operation is only accepted on creation of Employee entities.
  13794. func (m *EmployeeMutation) SetID(id uint64) {
  13795. m.id = &id
  13796. }
  13797. // ID returns the ID value in the mutation. Note that the ID is only available
  13798. // if it was provided to the builder or after it was returned from the database.
  13799. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13800. if m.id == nil {
  13801. return
  13802. }
  13803. return *m.id, true
  13804. }
  13805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13806. // That means, if the mutation is applied within a transaction with an isolation level such
  13807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13808. // or updated by the mutation.
  13809. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13810. switch {
  13811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13812. id, exists := m.ID()
  13813. if exists {
  13814. return []uint64{id}, nil
  13815. }
  13816. fallthrough
  13817. case m.op.Is(OpUpdate | OpDelete):
  13818. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13819. default:
  13820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13821. }
  13822. }
  13823. // SetCreatedAt sets the "created_at" field.
  13824. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13825. m.created_at = &t
  13826. }
  13827. // CreatedAt returns the value of the "created_at" field in the mutation.
  13828. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13829. v := m.created_at
  13830. if v == nil {
  13831. return
  13832. }
  13833. return *v, true
  13834. }
  13835. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13836. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13838. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13839. if !m.op.Is(OpUpdateOne) {
  13840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13841. }
  13842. if m.id == nil || m.oldValue == nil {
  13843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13844. }
  13845. oldValue, err := m.oldValue(ctx)
  13846. if err != nil {
  13847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13848. }
  13849. return oldValue.CreatedAt, nil
  13850. }
  13851. // ResetCreatedAt resets all changes to the "created_at" field.
  13852. func (m *EmployeeMutation) ResetCreatedAt() {
  13853. m.created_at = nil
  13854. }
  13855. // SetUpdatedAt sets the "updated_at" field.
  13856. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13857. m.updated_at = &t
  13858. }
  13859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13860. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13861. v := m.updated_at
  13862. if v == nil {
  13863. return
  13864. }
  13865. return *v, true
  13866. }
  13867. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13868. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13870. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13871. if !m.op.Is(OpUpdateOne) {
  13872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13873. }
  13874. if m.id == nil || m.oldValue == nil {
  13875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13876. }
  13877. oldValue, err := m.oldValue(ctx)
  13878. if err != nil {
  13879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13880. }
  13881. return oldValue.UpdatedAt, nil
  13882. }
  13883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13884. func (m *EmployeeMutation) ResetUpdatedAt() {
  13885. m.updated_at = nil
  13886. }
  13887. // SetDeletedAt sets the "deleted_at" field.
  13888. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13889. m.deleted_at = &t
  13890. }
  13891. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13892. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13893. v := m.deleted_at
  13894. if v == nil {
  13895. return
  13896. }
  13897. return *v, true
  13898. }
  13899. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13900. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13902. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13903. if !m.op.Is(OpUpdateOne) {
  13904. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13905. }
  13906. if m.id == nil || m.oldValue == nil {
  13907. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13908. }
  13909. oldValue, err := m.oldValue(ctx)
  13910. if err != nil {
  13911. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13912. }
  13913. return oldValue.DeletedAt, nil
  13914. }
  13915. // ClearDeletedAt clears the value of the "deleted_at" field.
  13916. func (m *EmployeeMutation) ClearDeletedAt() {
  13917. m.deleted_at = nil
  13918. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13919. }
  13920. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13921. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13922. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13923. return ok
  13924. }
  13925. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13926. func (m *EmployeeMutation) ResetDeletedAt() {
  13927. m.deleted_at = nil
  13928. delete(m.clearedFields, employee.FieldDeletedAt)
  13929. }
  13930. // SetTitle sets the "title" field.
  13931. func (m *EmployeeMutation) SetTitle(s string) {
  13932. m.title = &s
  13933. }
  13934. // Title returns the value of the "title" field in the mutation.
  13935. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13936. v := m.title
  13937. if v == nil {
  13938. return
  13939. }
  13940. return *v, true
  13941. }
  13942. // OldTitle returns the old "title" field's value of the Employee entity.
  13943. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13945. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13946. if !m.op.Is(OpUpdateOne) {
  13947. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13948. }
  13949. if m.id == nil || m.oldValue == nil {
  13950. return v, errors.New("OldTitle requires an ID field in the mutation")
  13951. }
  13952. oldValue, err := m.oldValue(ctx)
  13953. if err != nil {
  13954. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13955. }
  13956. return oldValue.Title, nil
  13957. }
  13958. // ResetTitle resets all changes to the "title" field.
  13959. func (m *EmployeeMutation) ResetTitle() {
  13960. m.title = nil
  13961. }
  13962. // SetAvatar sets the "avatar" field.
  13963. func (m *EmployeeMutation) SetAvatar(s string) {
  13964. m.avatar = &s
  13965. }
  13966. // Avatar returns the value of the "avatar" field in the mutation.
  13967. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13968. v := m.avatar
  13969. if v == nil {
  13970. return
  13971. }
  13972. return *v, true
  13973. }
  13974. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13975. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13977. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13978. if !m.op.Is(OpUpdateOne) {
  13979. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13980. }
  13981. if m.id == nil || m.oldValue == nil {
  13982. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13983. }
  13984. oldValue, err := m.oldValue(ctx)
  13985. if err != nil {
  13986. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13987. }
  13988. return oldValue.Avatar, nil
  13989. }
  13990. // ResetAvatar resets all changes to the "avatar" field.
  13991. func (m *EmployeeMutation) ResetAvatar() {
  13992. m.avatar = nil
  13993. }
  13994. // SetTags sets the "tags" field.
  13995. func (m *EmployeeMutation) SetTags(s string) {
  13996. m.tags = &s
  13997. }
  13998. // Tags returns the value of the "tags" field in the mutation.
  13999. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  14000. v := m.tags
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // OldTags returns the old "tags" field's value of the Employee entity.
  14007. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14009. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  14010. if !m.op.Is(OpUpdateOne) {
  14011. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  14012. }
  14013. if m.id == nil || m.oldValue == nil {
  14014. return v, errors.New("OldTags requires an ID field in the mutation")
  14015. }
  14016. oldValue, err := m.oldValue(ctx)
  14017. if err != nil {
  14018. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  14019. }
  14020. return oldValue.Tags, nil
  14021. }
  14022. // ResetTags resets all changes to the "tags" field.
  14023. func (m *EmployeeMutation) ResetTags() {
  14024. m.tags = nil
  14025. }
  14026. // SetHireCount sets the "hire_count" field.
  14027. func (m *EmployeeMutation) SetHireCount(i int) {
  14028. m.hire_count = &i
  14029. m.addhire_count = nil
  14030. }
  14031. // HireCount returns the value of the "hire_count" field in the mutation.
  14032. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  14033. v := m.hire_count
  14034. if v == nil {
  14035. return
  14036. }
  14037. return *v, true
  14038. }
  14039. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  14040. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14042. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  14043. if !m.op.Is(OpUpdateOne) {
  14044. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  14045. }
  14046. if m.id == nil || m.oldValue == nil {
  14047. return v, errors.New("OldHireCount requires an ID field in the mutation")
  14048. }
  14049. oldValue, err := m.oldValue(ctx)
  14050. if err != nil {
  14051. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  14052. }
  14053. return oldValue.HireCount, nil
  14054. }
  14055. // AddHireCount adds i to the "hire_count" field.
  14056. func (m *EmployeeMutation) AddHireCount(i int) {
  14057. if m.addhire_count != nil {
  14058. *m.addhire_count += i
  14059. } else {
  14060. m.addhire_count = &i
  14061. }
  14062. }
  14063. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  14064. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  14065. v := m.addhire_count
  14066. if v == nil {
  14067. return
  14068. }
  14069. return *v, true
  14070. }
  14071. // ResetHireCount resets all changes to the "hire_count" field.
  14072. func (m *EmployeeMutation) ResetHireCount() {
  14073. m.hire_count = nil
  14074. m.addhire_count = nil
  14075. }
  14076. // SetServiceCount sets the "service_count" field.
  14077. func (m *EmployeeMutation) SetServiceCount(i int) {
  14078. m.service_count = &i
  14079. m.addservice_count = nil
  14080. }
  14081. // ServiceCount returns the value of the "service_count" field in the mutation.
  14082. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  14083. v := m.service_count
  14084. if v == nil {
  14085. return
  14086. }
  14087. return *v, true
  14088. }
  14089. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  14090. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14092. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  14093. if !m.op.Is(OpUpdateOne) {
  14094. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  14095. }
  14096. if m.id == nil || m.oldValue == nil {
  14097. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  14098. }
  14099. oldValue, err := m.oldValue(ctx)
  14100. if err != nil {
  14101. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  14102. }
  14103. return oldValue.ServiceCount, nil
  14104. }
  14105. // AddServiceCount adds i to the "service_count" field.
  14106. func (m *EmployeeMutation) AddServiceCount(i int) {
  14107. if m.addservice_count != nil {
  14108. *m.addservice_count += i
  14109. } else {
  14110. m.addservice_count = &i
  14111. }
  14112. }
  14113. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  14114. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  14115. v := m.addservice_count
  14116. if v == nil {
  14117. return
  14118. }
  14119. return *v, true
  14120. }
  14121. // ResetServiceCount resets all changes to the "service_count" field.
  14122. func (m *EmployeeMutation) ResetServiceCount() {
  14123. m.service_count = nil
  14124. m.addservice_count = nil
  14125. }
  14126. // SetAchievementCount sets the "achievement_count" field.
  14127. func (m *EmployeeMutation) SetAchievementCount(i int) {
  14128. m.achievement_count = &i
  14129. m.addachievement_count = nil
  14130. }
  14131. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  14132. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  14133. v := m.achievement_count
  14134. if v == nil {
  14135. return
  14136. }
  14137. return *v, true
  14138. }
  14139. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  14140. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14142. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  14143. if !m.op.Is(OpUpdateOne) {
  14144. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  14145. }
  14146. if m.id == nil || m.oldValue == nil {
  14147. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  14148. }
  14149. oldValue, err := m.oldValue(ctx)
  14150. if err != nil {
  14151. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  14152. }
  14153. return oldValue.AchievementCount, nil
  14154. }
  14155. // AddAchievementCount adds i to the "achievement_count" field.
  14156. func (m *EmployeeMutation) AddAchievementCount(i int) {
  14157. if m.addachievement_count != nil {
  14158. *m.addachievement_count += i
  14159. } else {
  14160. m.addachievement_count = &i
  14161. }
  14162. }
  14163. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  14164. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  14165. v := m.addachievement_count
  14166. if v == nil {
  14167. return
  14168. }
  14169. return *v, true
  14170. }
  14171. // ResetAchievementCount resets all changes to the "achievement_count" field.
  14172. func (m *EmployeeMutation) ResetAchievementCount() {
  14173. m.achievement_count = nil
  14174. m.addachievement_count = nil
  14175. }
  14176. // SetIntro sets the "intro" field.
  14177. func (m *EmployeeMutation) SetIntro(s string) {
  14178. m.intro = &s
  14179. }
  14180. // Intro returns the value of the "intro" field in the mutation.
  14181. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  14182. v := m.intro
  14183. if v == nil {
  14184. return
  14185. }
  14186. return *v, true
  14187. }
  14188. // OldIntro returns the old "intro" field's value of the Employee entity.
  14189. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14191. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  14192. if !m.op.Is(OpUpdateOne) {
  14193. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  14194. }
  14195. if m.id == nil || m.oldValue == nil {
  14196. return v, errors.New("OldIntro requires an ID field in the mutation")
  14197. }
  14198. oldValue, err := m.oldValue(ctx)
  14199. if err != nil {
  14200. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  14201. }
  14202. return oldValue.Intro, nil
  14203. }
  14204. // ResetIntro resets all changes to the "intro" field.
  14205. func (m *EmployeeMutation) ResetIntro() {
  14206. m.intro = nil
  14207. }
  14208. // SetEstimate sets the "estimate" field.
  14209. func (m *EmployeeMutation) SetEstimate(s string) {
  14210. m.estimate = &s
  14211. }
  14212. // Estimate returns the value of the "estimate" field in the mutation.
  14213. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  14214. v := m.estimate
  14215. if v == nil {
  14216. return
  14217. }
  14218. return *v, true
  14219. }
  14220. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  14221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14223. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  14224. if !m.op.Is(OpUpdateOne) {
  14225. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  14226. }
  14227. if m.id == nil || m.oldValue == nil {
  14228. return v, errors.New("OldEstimate requires an ID field in the mutation")
  14229. }
  14230. oldValue, err := m.oldValue(ctx)
  14231. if err != nil {
  14232. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  14233. }
  14234. return oldValue.Estimate, nil
  14235. }
  14236. // ResetEstimate resets all changes to the "estimate" field.
  14237. func (m *EmployeeMutation) ResetEstimate() {
  14238. m.estimate = nil
  14239. }
  14240. // SetSkill sets the "skill" field.
  14241. func (m *EmployeeMutation) SetSkill(s string) {
  14242. m.skill = &s
  14243. }
  14244. // Skill returns the value of the "skill" field in the mutation.
  14245. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  14246. v := m.skill
  14247. if v == nil {
  14248. return
  14249. }
  14250. return *v, true
  14251. }
  14252. // OldSkill returns the old "skill" field's value of the Employee entity.
  14253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14255. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  14256. if !m.op.Is(OpUpdateOne) {
  14257. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  14258. }
  14259. if m.id == nil || m.oldValue == nil {
  14260. return v, errors.New("OldSkill requires an ID field in the mutation")
  14261. }
  14262. oldValue, err := m.oldValue(ctx)
  14263. if err != nil {
  14264. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  14265. }
  14266. return oldValue.Skill, nil
  14267. }
  14268. // ResetSkill resets all changes to the "skill" field.
  14269. func (m *EmployeeMutation) ResetSkill() {
  14270. m.skill = nil
  14271. }
  14272. // SetAbilityType sets the "ability_type" field.
  14273. func (m *EmployeeMutation) SetAbilityType(s string) {
  14274. m.ability_type = &s
  14275. }
  14276. // AbilityType returns the value of the "ability_type" field in the mutation.
  14277. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  14278. v := m.ability_type
  14279. if v == nil {
  14280. return
  14281. }
  14282. return *v, true
  14283. }
  14284. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  14285. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14287. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14288. if !m.op.Is(OpUpdateOne) {
  14289. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14290. }
  14291. if m.id == nil || m.oldValue == nil {
  14292. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14293. }
  14294. oldValue, err := m.oldValue(ctx)
  14295. if err != nil {
  14296. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  14297. }
  14298. return oldValue.AbilityType, nil
  14299. }
  14300. // ResetAbilityType resets all changes to the "ability_type" field.
  14301. func (m *EmployeeMutation) ResetAbilityType() {
  14302. m.ability_type = nil
  14303. }
  14304. // SetScene sets the "scene" field.
  14305. func (m *EmployeeMutation) SetScene(s string) {
  14306. m.scene = &s
  14307. }
  14308. // Scene returns the value of the "scene" field in the mutation.
  14309. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  14310. v := m.scene
  14311. if v == nil {
  14312. return
  14313. }
  14314. return *v, true
  14315. }
  14316. // OldScene returns the old "scene" field's value of the Employee entity.
  14317. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14319. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  14320. if !m.op.Is(OpUpdateOne) {
  14321. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  14322. }
  14323. if m.id == nil || m.oldValue == nil {
  14324. return v, errors.New("OldScene requires an ID field in the mutation")
  14325. }
  14326. oldValue, err := m.oldValue(ctx)
  14327. if err != nil {
  14328. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  14329. }
  14330. return oldValue.Scene, nil
  14331. }
  14332. // ResetScene resets all changes to the "scene" field.
  14333. func (m *EmployeeMutation) ResetScene() {
  14334. m.scene = nil
  14335. }
  14336. // SetSwitchIn sets the "switch_in" field.
  14337. func (m *EmployeeMutation) SetSwitchIn(s string) {
  14338. m.switch_in = &s
  14339. }
  14340. // SwitchIn returns the value of the "switch_in" field in the mutation.
  14341. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  14342. v := m.switch_in
  14343. if v == nil {
  14344. return
  14345. }
  14346. return *v, true
  14347. }
  14348. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  14349. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14351. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  14352. if !m.op.Is(OpUpdateOne) {
  14353. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  14354. }
  14355. if m.id == nil || m.oldValue == nil {
  14356. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  14357. }
  14358. oldValue, err := m.oldValue(ctx)
  14359. if err != nil {
  14360. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  14361. }
  14362. return oldValue.SwitchIn, nil
  14363. }
  14364. // ResetSwitchIn resets all changes to the "switch_in" field.
  14365. func (m *EmployeeMutation) ResetSwitchIn() {
  14366. m.switch_in = nil
  14367. }
  14368. // SetVideoURL sets the "video_url" field.
  14369. func (m *EmployeeMutation) SetVideoURL(s string) {
  14370. m.video_url = &s
  14371. }
  14372. // VideoURL returns the value of the "video_url" field in the mutation.
  14373. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14374. v := m.video_url
  14375. if v == nil {
  14376. return
  14377. }
  14378. return *v, true
  14379. }
  14380. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14381. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14383. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14384. if !m.op.Is(OpUpdateOne) {
  14385. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14386. }
  14387. if m.id == nil || m.oldValue == nil {
  14388. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14389. }
  14390. oldValue, err := m.oldValue(ctx)
  14391. if err != nil {
  14392. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14393. }
  14394. return oldValue.VideoURL, nil
  14395. }
  14396. // ResetVideoURL resets all changes to the "video_url" field.
  14397. func (m *EmployeeMutation) ResetVideoURL() {
  14398. m.video_url = nil
  14399. }
  14400. // SetOrganizationID sets the "organization_id" field.
  14401. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14402. m.organization_id = &u
  14403. m.addorganization_id = nil
  14404. }
  14405. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14406. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14407. v := m.organization_id
  14408. if v == nil {
  14409. return
  14410. }
  14411. return *v, true
  14412. }
  14413. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14414. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14416. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14417. if !m.op.Is(OpUpdateOne) {
  14418. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14419. }
  14420. if m.id == nil || m.oldValue == nil {
  14421. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14422. }
  14423. oldValue, err := m.oldValue(ctx)
  14424. if err != nil {
  14425. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14426. }
  14427. return oldValue.OrganizationID, nil
  14428. }
  14429. // AddOrganizationID adds u to the "organization_id" field.
  14430. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14431. if m.addorganization_id != nil {
  14432. *m.addorganization_id += u
  14433. } else {
  14434. m.addorganization_id = &u
  14435. }
  14436. }
  14437. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14438. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14439. v := m.addorganization_id
  14440. if v == nil {
  14441. return
  14442. }
  14443. return *v, true
  14444. }
  14445. // ResetOrganizationID resets all changes to the "organization_id" field.
  14446. func (m *EmployeeMutation) ResetOrganizationID() {
  14447. m.organization_id = nil
  14448. m.addorganization_id = nil
  14449. }
  14450. // SetCategoryID sets the "category_id" field.
  14451. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14452. m.category_id = &u
  14453. m.addcategory_id = nil
  14454. }
  14455. // CategoryID returns the value of the "category_id" field in the mutation.
  14456. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14457. v := m.category_id
  14458. if v == nil {
  14459. return
  14460. }
  14461. return *v, true
  14462. }
  14463. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14464. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14466. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14467. if !m.op.Is(OpUpdateOne) {
  14468. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14469. }
  14470. if m.id == nil || m.oldValue == nil {
  14471. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14472. }
  14473. oldValue, err := m.oldValue(ctx)
  14474. if err != nil {
  14475. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14476. }
  14477. return oldValue.CategoryID, nil
  14478. }
  14479. // AddCategoryID adds u to the "category_id" field.
  14480. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14481. if m.addcategory_id != nil {
  14482. *m.addcategory_id += u
  14483. } else {
  14484. m.addcategory_id = &u
  14485. }
  14486. }
  14487. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14488. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14489. v := m.addcategory_id
  14490. if v == nil {
  14491. return
  14492. }
  14493. return *v, true
  14494. }
  14495. // ResetCategoryID resets all changes to the "category_id" field.
  14496. func (m *EmployeeMutation) ResetCategoryID() {
  14497. m.category_id = nil
  14498. m.addcategory_id = nil
  14499. }
  14500. // SetAPIBase sets the "api_base" field.
  14501. func (m *EmployeeMutation) SetAPIBase(s string) {
  14502. m.api_base = &s
  14503. }
  14504. // APIBase returns the value of the "api_base" field in the mutation.
  14505. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14506. v := m.api_base
  14507. if v == nil {
  14508. return
  14509. }
  14510. return *v, true
  14511. }
  14512. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14513. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14515. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14516. if !m.op.Is(OpUpdateOne) {
  14517. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14518. }
  14519. if m.id == nil || m.oldValue == nil {
  14520. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14521. }
  14522. oldValue, err := m.oldValue(ctx)
  14523. if err != nil {
  14524. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14525. }
  14526. return oldValue.APIBase, nil
  14527. }
  14528. // ResetAPIBase resets all changes to the "api_base" field.
  14529. func (m *EmployeeMutation) ResetAPIBase() {
  14530. m.api_base = nil
  14531. }
  14532. // SetAPIKey sets the "api_key" field.
  14533. func (m *EmployeeMutation) SetAPIKey(s string) {
  14534. m.api_key = &s
  14535. }
  14536. // APIKey returns the value of the "api_key" field in the mutation.
  14537. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14538. v := m.api_key
  14539. if v == nil {
  14540. return
  14541. }
  14542. return *v, true
  14543. }
  14544. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14545. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14547. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14548. if !m.op.Is(OpUpdateOne) {
  14549. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14550. }
  14551. if m.id == nil || m.oldValue == nil {
  14552. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14553. }
  14554. oldValue, err := m.oldValue(ctx)
  14555. if err != nil {
  14556. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14557. }
  14558. return oldValue.APIKey, nil
  14559. }
  14560. // ResetAPIKey resets all changes to the "api_key" field.
  14561. func (m *EmployeeMutation) ResetAPIKey() {
  14562. m.api_key = nil
  14563. }
  14564. // SetAiInfo sets the "ai_info" field.
  14565. func (m *EmployeeMutation) SetAiInfo(s string) {
  14566. m.ai_info = &s
  14567. }
  14568. // AiInfo returns the value of the "ai_info" field in the mutation.
  14569. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14570. v := m.ai_info
  14571. if v == nil {
  14572. return
  14573. }
  14574. return *v, true
  14575. }
  14576. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14577. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14579. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14580. if !m.op.Is(OpUpdateOne) {
  14581. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14582. }
  14583. if m.id == nil || m.oldValue == nil {
  14584. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14585. }
  14586. oldValue, err := m.oldValue(ctx)
  14587. if err != nil {
  14588. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14589. }
  14590. return oldValue.AiInfo, nil
  14591. }
  14592. // ClearAiInfo clears the value of the "ai_info" field.
  14593. func (m *EmployeeMutation) ClearAiInfo() {
  14594. m.ai_info = nil
  14595. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14596. }
  14597. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14598. func (m *EmployeeMutation) AiInfoCleared() bool {
  14599. _, ok := m.clearedFields[employee.FieldAiInfo]
  14600. return ok
  14601. }
  14602. // ResetAiInfo resets all changes to the "ai_info" field.
  14603. func (m *EmployeeMutation) ResetAiInfo() {
  14604. m.ai_info = nil
  14605. delete(m.clearedFields, employee.FieldAiInfo)
  14606. }
  14607. // SetIsVip sets the "is_vip" field.
  14608. func (m *EmployeeMutation) SetIsVip(i int) {
  14609. m.is_vip = &i
  14610. m.addis_vip = nil
  14611. }
  14612. // IsVip returns the value of the "is_vip" field in the mutation.
  14613. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14614. v := m.is_vip
  14615. if v == nil {
  14616. return
  14617. }
  14618. return *v, true
  14619. }
  14620. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14621. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14623. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14624. if !m.op.Is(OpUpdateOne) {
  14625. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14626. }
  14627. if m.id == nil || m.oldValue == nil {
  14628. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14629. }
  14630. oldValue, err := m.oldValue(ctx)
  14631. if err != nil {
  14632. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14633. }
  14634. return oldValue.IsVip, nil
  14635. }
  14636. // AddIsVip adds i to the "is_vip" field.
  14637. func (m *EmployeeMutation) AddIsVip(i int) {
  14638. if m.addis_vip != nil {
  14639. *m.addis_vip += i
  14640. } else {
  14641. m.addis_vip = &i
  14642. }
  14643. }
  14644. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14645. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14646. v := m.addis_vip
  14647. if v == nil {
  14648. return
  14649. }
  14650. return *v, true
  14651. }
  14652. // ResetIsVip resets all changes to the "is_vip" field.
  14653. func (m *EmployeeMutation) ResetIsVip() {
  14654. m.is_vip = nil
  14655. m.addis_vip = nil
  14656. }
  14657. // SetChatURL sets the "chat_url" field.
  14658. func (m *EmployeeMutation) SetChatURL(s string) {
  14659. m.chat_url = &s
  14660. }
  14661. // ChatURL returns the value of the "chat_url" field in the mutation.
  14662. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14663. v := m.chat_url
  14664. if v == nil {
  14665. return
  14666. }
  14667. return *v, true
  14668. }
  14669. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14670. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14672. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14673. if !m.op.Is(OpUpdateOne) {
  14674. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14675. }
  14676. if m.id == nil || m.oldValue == nil {
  14677. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14678. }
  14679. oldValue, err := m.oldValue(ctx)
  14680. if err != nil {
  14681. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14682. }
  14683. return oldValue.ChatURL, nil
  14684. }
  14685. // ResetChatURL resets all changes to the "chat_url" field.
  14686. func (m *EmployeeMutation) ResetChatURL() {
  14687. m.chat_url = nil
  14688. }
  14689. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14690. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14691. if m.em_work_experiences == nil {
  14692. m.em_work_experiences = make(map[uint64]struct{})
  14693. }
  14694. for i := range ids {
  14695. m.em_work_experiences[ids[i]] = struct{}{}
  14696. }
  14697. }
  14698. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14699. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14700. m.clearedem_work_experiences = true
  14701. }
  14702. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14703. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14704. return m.clearedem_work_experiences
  14705. }
  14706. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14707. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14708. if m.removedem_work_experiences == nil {
  14709. m.removedem_work_experiences = make(map[uint64]struct{})
  14710. }
  14711. for i := range ids {
  14712. delete(m.em_work_experiences, ids[i])
  14713. m.removedem_work_experiences[ids[i]] = struct{}{}
  14714. }
  14715. }
  14716. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14717. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14718. for id := range m.removedem_work_experiences {
  14719. ids = append(ids, id)
  14720. }
  14721. return
  14722. }
  14723. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14724. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14725. for id := range m.em_work_experiences {
  14726. ids = append(ids, id)
  14727. }
  14728. return
  14729. }
  14730. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14731. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14732. m.em_work_experiences = nil
  14733. m.clearedem_work_experiences = false
  14734. m.removedem_work_experiences = nil
  14735. }
  14736. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14737. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14738. if m.em_tutorial == nil {
  14739. m.em_tutorial = make(map[uint64]struct{})
  14740. }
  14741. for i := range ids {
  14742. m.em_tutorial[ids[i]] = struct{}{}
  14743. }
  14744. }
  14745. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14746. func (m *EmployeeMutation) ClearEmTutorial() {
  14747. m.clearedem_tutorial = true
  14748. }
  14749. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14750. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14751. return m.clearedem_tutorial
  14752. }
  14753. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14754. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14755. if m.removedem_tutorial == nil {
  14756. m.removedem_tutorial = make(map[uint64]struct{})
  14757. }
  14758. for i := range ids {
  14759. delete(m.em_tutorial, ids[i])
  14760. m.removedem_tutorial[ids[i]] = struct{}{}
  14761. }
  14762. }
  14763. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14764. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14765. for id := range m.removedem_tutorial {
  14766. ids = append(ids, id)
  14767. }
  14768. return
  14769. }
  14770. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14771. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14772. for id := range m.em_tutorial {
  14773. ids = append(ids, id)
  14774. }
  14775. return
  14776. }
  14777. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14778. func (m *EmployeeMutation) ResetEmTutorial() {
  14779. m.em_tutorial = nil
  14780. m.clearedem_tutorial = false
  14781. m.removedem_tutorial = nil
  14782. }
  14783. // Where appends a list predicates to the EmployeeMutation builder.
  14784. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14785. m.predicates = append(m.predicates, ps...)
  14786. }
  14787. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14788. // users can use type-assertion to append predicates that do not depend on any generated package.
  14789. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14790. p := make([]predicate.Employee, len(ps))
  14791. for i := range ps {
  14792. p[i] = ps[i]
  14793. }
  14794. m.Where(p...)
  14795. }
  14796. // Op returns the operation name.
  14797. func (m *EmployeeMutation) Op() Op {
  14798. return m.op
  14799. }
  14800. // SetOp allows setting the mutation operation.
  14801. func (m *EmployeeMutation) SetOp(op Op) {
  14802. m.op = op
  14803. }
  14804. // Type returns the node type of this mutation (Employee).
  14805. func (m *EmployeeMutation) Type() string {
  14806. return m.typ
  14807. }
  14808. // Fields returns all fields that were changed during this mutation. Note that in
  14809. // order to get all numeric fields that were incremented/decremented, call
  14810. // AddedFields().
  14811. func (m *EmployeeMutation) Fields() []string {
  14812. fields := make([]string, 0, 23)
  14813. if m.created_at != nil {
  14814. fields = append(fields, employee.FieldCreatedAt)
  14815. }
  14816. if m.updated_at != nil {
  14817. fields = append(fields, employee.FieldUpdatedAt)
  14818. }
  14819. if m.deleted_at != nil {
  14820. fields = append(fields, employee.FieldDeletedAt)
  14821. }
  14822. if m.title != nil {
  14823. fields = append(fields, employee.FieldTitle)
  14824. }
  14825. if m.avatar != nil {
  14826. fields = append(fields, employee.FieldAvatar)
  14827. }
  14828. if m.tags != nil {
  14829. fields = append(fields, employee.FieldTags)
  14830. }
  14831. if m.hire_count != nil {
  14832. fields = append(fields, employee.FieldHireCount)
  14833. }
  14834. if m.service_count != nil {
  14835. fields = append(fields, employee.FieldServiceCount)
  14836. }
  14837. if m.achievement_count != nil {
  14838. fields = append(fields, employee.FieldAchievementCount)
  14839. }
  14840. if m.intro != nil {
  14841. fields = append(fields, employee.FieldIntro)
  14842. }
  14843. if m.estimate != nil {
  14844. fields = append(fields, employee.FieldEstimate)
  14845. }
  14846. if m.skill != nil {
  14847. fields = append(fields, employee.FieldSkill)
  14848. }
  14849. if m.ability_type != nil {
  14850. fields = append(fields, employee.FieldAbilityType)
  14851. }
  14852. if m.scene != nil {
  14853. fields = append(fields, employee.FieldScene)
  14854. }
  14855. if m.switch_in != nil {
  14856. fields = append(fields, employee.FieldSwitchIn)
  14857. }
  14858. if m.video_url != nil {
  14859. fields = append(fields, employee.FieldVideoURL)
  14860. }
  14861. if m.organization_id != nil {
  14862. fields = append(fields, employee.FieldOrganizationID)
  14863. }
  14864. if m.category_id != nil {
  14865. fields = append(fields, employee.FieldCategoryID)
  14866. }
  14867. if m.api_base != nil {
  14868. fields = append(fields, employee.FieldAPIBase)
  14869. }
  14870. if m.api_key != nil {
  14871. fields = append(fields, employee.FieldAPIKey)
  14872. }
  14873. if m.ai_info != nil {
  14874. fields = append(fields, employee.FieldAiInfo)
  14875. }
  14876. if m.is_vip != nil {
  14877. fields = append(fields, employee.FieldIsVip)
  14878. }
  14879. if m.chat_url != nil {
  14880. fields = append(fields, employee.FieldChatURL)
  14881. }
  14882. return fields
  14883. }
  14884. // Field returns the value of a field with the given name. The second boolean
  14885. // return value indicates that this field was not set, or was not defined in the
  14886. // schema.
  14887. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14888. switch name {
  14889. case employee.FieldCreatedAt:
  14890. return m.CreatedAt()
  14891. case employee.FieldUpdatedAt:
  14892. return m.UpdatedAt()
  14893. case employee.FieldDeletedAt:
  14894. return m.DeletedAt()
  14895. case employee.FieldTitle:
  14896. return m.Title()
  14897. case employee.FieldAvatar:
  14898. return m.Avatar()
  14899. case employee.FieldTags:
  14900. return m.Tags()
  14901. case employee.FieldHireCount:
  14902. return m.HireCount()
  14903. case employee.FieldServiceCount:
  14904. return m.ServiceCount()
  14905. case employee.FieldAchievementCount:
  14906. return m.AchievementCount()
  14907. case employee.FieldIntro:
  14908. return m.Intro()
  14909. case employee.FieldEstimate:
  14910. return m.Estimate()
  14911. case employee.FieldSkill:
  14912. return m.Skill()
  14913. case employee.FieldAbilityType:
  14914. return m.AbilityType()
  14915. case employee.FieldScene:
  14916. return m.Scene()
  14917. case employee.FieldSwitchIn:
  14918. return m.SwitchIn()
  14919. case employee.FieldVideoURL:
  14920. return m.VideoURL()
  14921. case employee.FieldOrganizationID:
  14922. return m.OrganizationID()
  14923. case employee.FieldCategoryID:
  14924. return m.CategoryID()
  14925. case employee.FieldAPIBase:
  14926. return m.APIBase()
  14927. case employee.FieldAPIKey:
  14928. return m.APIKey()
  14929. case employee.FieldAiInfo:
  14930. return m.AiInfo()
  14931. case employee.FieldIsVip:
  14932. return m.IsVip()
  14933. case employee.FieldChatURL:
  14934. return m.ChatURL()
  14935. }
  14936. return nil, false
  14937. }
  14938. // OldField returns the old value of the field from the database. An error is
  14939. // returned if the mutation operation is not UpdateOne, or the query to the
  14940. // database failed.
  14941. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14942. switch name {
  14943. case employee.FieldCreatedAt:
  14944. return m.OldCreatedAt(ctx)
  14945. case employee.FieldUpdatedAt:
  14946. return m.OldUpdatedAt(ctx)
  14947. case employee.FieldDeletedAt:
  14948. return m.OldDeletedAt(ctx)
  14949. case employee.FieldTitle:
  14950. return m.OldTitle(ctx)
  14951. case employee.FieldAvatar:
  14952. return m.OldAvatar(ctx)
  14953. case employee.FieldTags:
  14954. return m.OldTags(ctx)
  14955. case employee.FieldHireCount:
  14956. return m.OldHireCount(ctx)
  14957. case employee.FieldServiceCount:
  14958. return m.OldServiceCount(ctx)
  14959. case employee.FieldAchievementCount:
  14960. return m.OldAchievementCount(ctx)
  14961. case employee.FieldIntro:
  14962. return m.OldIntro(ctx)
  14963. case employee.FieldEstimate:
  14964. return m.OldEstimate(ctx)
  14965. case employee.FieldSkill:
  14966. return m.OldSkill(ctx)
  14967. case employee.FieldAbilityType:
  14968. return m.OldAbilityType(ctx)
  14969. case employee.FieldScene:
  14970. return m.OldScene(ctx)
  14971. case employee.FieldSwitchIn:
  14972. return m.OldSwitchIn(ctx)
  14973. case employee.FieldVideoURL:
  14974. return m.OldVideoURL(ctx)
  14975. case employee.FieldOrganizationID:
  14976. return m.OldOrganizationID(ctx)
  14977. case employee.FieldCategoryID:
  14978. return m.OldCategoryID(ctx)
  14979. case employee.FieldAPIBase:
  14980. return m.OldAPIBase(ctx)
  14981. case employee.FieldAPIKey:
  14982. return m.OldAPIKey(ctx)
  14983. case employee.FieldAiInfo:
  14984. return m.OldAiInfo(ctx)
  14985. case employee.FieldIsVip:
  14986. return m.OldIsVip(ctx)
  14987. case employee.FieldChatURL:
  14988. return m.OldChatURL(ctx)
  14989. }
  14990. return nil, fmt.Errorf("unknown Employee field %s", name)
  14991. }
  14992. // SetField sets the value of a field with the given name. It returns an error if
  14993. // the field is not defined in the schema, or if the type mismatched the field
  14994. // type.
  14995. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14996. switch name {
  14997. case employee.FieldCreatedAt:
  14998. v, ok := value.(time.Time)
  14999. if !ok {
  15000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15001. }
  15002. m.SetCreatedAt(v)
  15003. return nil
  15004. case employee.FieldUpdatedAt:
  15005. v, ok := value.(time.Time)
  15006. if !ok {
  15007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15008. }
  15009. m.SetUpdatedAt(v)
  15010. return nil
  15011. case employee.FieldDeletedAt:
  15012. v, ok := value.(time.Time)
  15013. if !ok {
  15014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15015. }
  15016. m.SetDeletedAt(v)
  15017. return nil
  15018. case employee.FieldTitle:
  15019. v, ok := value.(string)
  15020. if !ok {
  15021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15022. }
  15023. m.SetTitle(v)
  15024. return nil
  15025. case employee.FieldAvatar:
  15026. v, ok := value.(string)
  15027. if !ok {
  15028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15029. }
  15030. m.SetAvatar(v)
  15031. return nil
  15032. case employee.FieldTags:
  15033. v, ok := value.(string)
  15034. if !ok {
  15035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15036. }
  15037. m.SetTags(v)
  15038. return nil
  15039. case employee.FieldHireCount:
  15040. v, ok := value.(int)
  15041. if !ok {
  15042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15043. }
  15044. m.SetHireCount(v)
  15045. return nil
  15046. case employee.FieldServiceCount:
  15047. v, ok := value.(int)
  15048. if !ok {
  15049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15050. }
  15051. m.SetServiceCount(v)
  15052. return nil
  15053. case employee.FieldAchievementCount:
  15054. v, ok := value.(int)
  15055. if !ok {
  15056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15057. }
  15058. m.SetAchievementCount(v)
  15059. return nil
  15060. case employee.FieldIntro:
  15061. v, ok := value.(string)
  15062. if !ok {
  15063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15064. }
  15065. m.SetIntro(v)
  15066. return nil
  15067. case employee.FieldEstimate:
  15068. v, ok := value.(string)
  15069. if !ok {
  15070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15071. }
  15072. m.SetEstimate(v)
  15073. return nil
  15074. case employee.FieldSkill:
  15075. v, ok := value.(string)
  15076. if !ok {
  15077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15078. }
  15079. m.SetSkill(v)
  15080. return nil
  15081. case employee.FieldAbilityType:
  15082. v, ok := value.(string)
  15083. if !ok {
  15084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15085. }
  15086. m.SetAbilityType(v)
  15087. return nil
  15088. case employee.FieldScene:
  15089. v, ok := value.(string)
  15090. if !ok {
  15091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15092. }
  15093. m.SetScene(v)
  15094. return nil
  15095. case employee.FieldSwitchIn:
  15096. v, ok := value.(string)
  15097. if !ok {
  15098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15099. }
  15100. m.SetSwitchIn(v)
  15101. return nil
  15102. case employee.FieldVideoURL:
  15103. v, ok := value.(string)
  15104. if !ok {
  15105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15106. }
  15107. m.SetVideoURL(v)
  15108. return nil
  15109. case employee.FieldOrganizationID:
  15110. v, ok := value.(uint64)
  15111. if !ok {
  15112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15113. }
  15114. m.SetOrganizationID(v)
  15115. return nil
  15116. case employee.FieldCategoryID:
  15117. v, ok := value.(uint64)
  15118. if !ok {
  15119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15120. }
  15121. m.SetCategoryID(v)
  15122. return nil
  15123. case employee.FieldAPIBase:
  15124. v, ok := value.(string)
  15125. if !ok {
  15126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15127. }
  15128. m.SetAPIBase(v)
  15129. return nil
  15130. case employee.FieldAPIKey:
  15131. v, ok := value.(string)
  15132. if !ok {
  15133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15134. }
  15135. m.SetAPIKey(v)
  15136. return nil
  15137. case employee.FieldAiInfo:
  15138. v, ok := value.(string)
  15139. if !ok {
  15140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15141. }
  15142. m.SetAiInfo(v)
  15143. return nil
  15144. case employee.FieldIsVip:
  15145. v, ok := value.(int)
  15146. if !ok {
  15147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15148. }
  15149. m.SetIsVip(v)
  15150. return nil
  15151. case employee.FieldChatURL:
  15152. v, ok := value.(string)
  15153. if !ok {
  15154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15155. }
  15156. m.SetChatURL(v)
  15157. return nil
  15158. }
  15159. return fmt.Errorf("unknown Employee field %s", name)
  15160. }
  15161. // AddedFields returns all numeric fields that were incremented/decremented during
  15162. // this mutation.
  15163. func (m *EmployeeMutation) AddedFields() []string {
  15164. var fields []string
  15165. if m.addhire_count != nil {
  15166. fields = append(fields, employee.FieldHireCount)
  15167. }
  15168. if m.addservice_count != nil {
  15169. fields = append(fields, employee.FieldServiceCount)
  15170. }
  15171. if m.addachievement_count != nil {
  15172. fields = append(fields, employee.FieldAchievementCount)
  15173. }
  15174. if m.addorganization_id != nil {
  15175. fields = append(fields, employee.FieldOrganizationID)
  15176. }
  15177. if m.addcategory_id != nil {
  15178. fields = append(fields, employee.FieldCategoryID)
  15179. }
  15180. if m.addis_vip != nil {
  15181. fields = append(fields, employee.FieldIsVip)
  15182. }
  15183. return fields
  15184. }
  15185. // AddedField returns the numeric value that was incremented/decremented on a field
  15186. // with the given name. The second boolean return value indicates that this field
  15187. // was not set, or was not defined in the schema.
  15188. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  15189. switch name {
  15190. case employee.FieldHireCount:
  15191. return m.AddedHireCount()
  15192. case employee.FieldServiceCount:
  15193. return m.AddedServiceCount()
  15194. case employee.FieldAchievementCount:
  15195. return m.AddedAchievementCount()
  15196. case employee.FieldOrganizationID:
  15197. return m.AddedOrganizationID()
  15198. case employee.FieldCategoryID:
  15199. return m.AddedCategoryID()
  15200. case employee.FieldIsVip:
  15201. return m.AddedIsVip()
  15202. }
  15203. return nil, false
  15204. }
  15205. // AddField adds the value to the field with the given name. It returns an error if
  15206. // the field is not defined in the schema, or if the type mismatched the field
  15207. // type.
  15208. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  15209. switch name {
  15210. case employee.FieldHireCount:
  15211. v, ok := value.(int)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.AddHireCount(v)
  15216. return nil
  15217. case employee.FieldServiceCount:
  15218. v, ok := value.(int)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.AddServiceCount(v)
  15223. return nil
  15224. case employee.FieldAchievementCount:
  15225. v, ok := value.(int)
  15226. if !ok {
  15227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15228. }
  15229. m.AddAchievementCount(v)
  15230. return nil
  15231. case employee.FieldOrganizationID:
  15232. v, ok := value.(int64)
  15233. if !ok {
  15234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15235. }
  15236. m.AddOrganizationID(v)
  15237. return nil
  15238. case employee.FieldCategoryID:
  15239. v, ok := value.(int64)
  15240. if !ok {
  15241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15242. }
  15243. m.AddCategoryID(v)
  15244. return nil
  15245. case employee.FieldIsVip:
  15246. v, ok := value.(int)
  15247. if !ok {
  15248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15249. }
  15250. m.AddIsVip(v)
  15251. return nil
  15252. }
  15253. return fmt.Errorf("unknown Employee numeric field %s", name)
  15254. }
  15255. // ClearedFields returns all nullable fields that were cleared during this
  15256. // mutation.
  15257. func (m *EmployeeMutation) ClearedFields() []string {
  15258. var fields []string
  15259. if m.FieldCleared(employee.FieldDeletedAt) {
  15260. fields = append(fields, employee.FieldDeletedAt)
  15261. }
  15262. if m.FieldCleared(employee.FieldAiInfo) {
  15263. fields = append(fields, employee.FieldAiInfo)
  15264. }
  15265. return fields
  15266. }
  15267. // FieldCleared returns a boolean indicating if a field with the given name was
  15268. // cleared in this mutation.
  15269. func (m *EmployeeMutation) FieldCleared(name string) bool {
  15270. _, ok := m.clearedFields[name]
  15271. return ok
  15272. }
  15273. // ClearField clears the value of the field with the given name. It returns an
  15274. // error if the field is not defined in the schema.
  15275. func (m *EmployeeMutation) ClearField(name string) error {
  15276. switch name {
  15277. case employee.FieldDeletedAt:
  15278. m.ClearDeletedAt()
  15279. return nil
  15280. case employee.FieldAiInfo:
  15281. m.ClearAiInfo()
  15282. return nil
  15283. }
  15284. return fmt.Errorf("unknown Employee nullable field %s", name)
  15285. }
  15286. // ResetField resets all changes in the mutation for the field with the given name.
  15287. // It returns an error if the field is not defined in the schema.
  15288. func (m *EmployeeMutation) ResetField(name string) error {
  15289. switch name {
  15290. case employee.FieldCreatedAt:
  15291. m.ResetCreatedAt()
  15292. return nil
  15293. case employee.FieldUpdatedAt:
  15294. m.ResetUpdatedAt()
  15295. return nil
  15296. case employee.FieldDeletedAt:
  15297. m.ResetDeletedAt()
  15298. return nil
  15299. case employee.FieldTitle:
  15300. m.ResetTitle()
  15301. return nil
  15302. case employee.FieldAvatar:
  15303. m.ResetAvatar()
  15304. return nil
  15305. case employee.FieldTags:
  15306. m.ResetTags()
  15307. return nil
  15308. case employee.FieldHireCount:
  15309. m.ResetHireCount()
  15310. return nil
  15311. case employee.FieldServiceCount:
  15312. m.ResetServiceCount()
  15313. return nil
  15314. case employee.FieldAchievementCount:
  15315. m.ResetAchievementCount()
  15316. return nil
  15317. case employee.FieldIntro:
  15318. m.ResetIntro()
  15319. return nil
  15320. case employee.FieldEstimate:
  15321. m.ResetEstimate()
  15322. return nil
  15323. case employee.FieldSkill:
  15324. m.ResetSkill()
  15325. return nil
  15326. case employee.FieldAbilityType:
  15327. m.ResetAbilityType()
  15328. return nil
  15329. case employee.FieldScene:
  15330. m.ResetScene()
  15331. return nil
  15332. case employee.FieldSwitchIn:
  15333. m.ResetSwitchIn()
  15334. return nil
  15335. case employee.FieldVideoURL:
  15336. m.ResetVideoURL()
  15337. return nil
  15338. case employee.FieldOrganizationID:
  15339. m.ResetOrganizationID()
  15340. return nil
  15341. case employee.FieldCategoryID:
  15342. m.ResetCategoryID()
  15343. return nil
  15344. case employee.FieldAPIBase:
  15345. m.ResetAPIBase()
  15346. return nil
  15347. case employee.FieldAPIKey:
  15348. m.ResetAPIKey()
  15349. return nil
  15350. case employee.FieldAiInfo:
  15351. m.ResetAiInfo()
  15352. return nil
  15353. case employee.FieldIsVip:
  15354. m.ResetIsVip()
  15355. return nil
  15356. case employee.FieldChatURL:
  15357. m.ResetChatURL()
  15358. return nil
  15359. }
  15360. return fmt.Errorf("unknown Employee field %s", name)
  15361. }
  15362. // AddedEdges returns all edge names that were set/added in this mutation.
  15363. func (m *EmployeeMutation) AddedEdges() []string {
  15364. edges := make([]string, 0, 2)
  15365. if m.em_work_experiences != nil {
  15366. edges = append(edges, employee.EdgeEmWorkExperiences)
  15367. }
  15368. if m.em_tutorial != nil {
  15369. edges = append(edges, employee.EdgeEmTutorial)
  15370. }
  15371. return edges
  15372. }
  15373. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15374. // name in this mutation.
  15375. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15376. switch name {
  15377. case employee.EdgeEmWorkExperiences:
  15378. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15379. for id := range m.em_work_experiences {
  15380. ids = append(ids, id)
  15381. }
  15382. return ids
  15383. case employee.EdgeEmTutorial:
  15384. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15385. for id := range m.em_tutorial {
  15386. ids = append(ids, id)
  15387. }
  15388. return ids
  15389. }
  15390. return nil
  15391. }
  15392. // RemovedEdges returns all edge names that were removed in this mutation.
  15393. func (m *EmployeeMutation) RemovedEdges() []string {
  15394. edges := make([]string, 0, 2)
  15395. if m.removedem_work_experiences != nil {
  15396. edges = append(edges, employee.EdgeEmWorkExperiences)
  15397. }
  15398. if m.removedem_tutorial != nil {
  15399. edges = append(edges, employee.EdgeEmTutorial)
  15400. }
  15401. return edges
  15402. }
  15403. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15404. // the given name in this mutation.
  15405. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15406. switch name {
  15407. case employee.EdgeEmWorkExperiences:
  15408. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15409. for id := range m.removedem_work_experiences {
  15410. ids = append(ids, id)
  15411. }
  15412. return ids
  15413. case employee.EdgeEmTutorial:
  15414. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15415. for id := range m.removedem_tutorial {
  15416. ids = append(ids, id)
  15417. }
  15418. return ids
  15419. }
  15420. return nil
  15421. }
  15422. // ClearedEdges returns all edge names that were cleared in this mutation.
  15423. func (m *EmployeeMutation) ClearedEdges() []string {
  15424. edges := make([]string, 0, 2)
  15425. if m.clearedem_work_experiences {
  15426. edges = append(edges, employee.EdgeEmWorkExperiences)
  15427. }
  15428. if m.clearedem_tutorial {
  15429. edges = append(edges, employee.EdgeEmTutorial)
  15430. }
  15431. return edges
  15432. }
  15433. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15434. // was cleared in this mutation.
  15435. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15436. switch name {
  15437. case employee.EdgeEmWorkExperiences:
  15438. return m.clearedem_work_experiences
  15439. case employee.EdgeEmTutorial:
  15440. return m.clearedem_tutorial
  15441. }
  15442. return false
  15443. }
  15444. // ClearEdge clears the value of the edge with the given name. It returns an error
  15445. // if that edge is not defined in the schema.
  15446. func (m *EmployeeMutation) ClearEdge(name string) error {
  15447. switch name {
  15448. }
  15449. return fmt.Errorf("unknown Employee unique edge %s", name)
  15450. }
  15451. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15452. // It returns an error if the edge is not defined in the schema.
  15453. func (m *EmployeeMutation) ResetEdge(name string) error {
  15454. switch name {
  15455. case employee.EdgeEmWorkExperiences:
  15456. m.ResetEmWorkExperiences()
  15457. return nil
  15458. case employee.EdgeEmTutorial:
  15459. m.ResetEmTutorial()
  15460. return nil
  15461. }
  15462. return fmt.Errorf("unknown Employee edge %s", name)
  15463. }
  15464. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15465. type EmployeeConfigMutation struct {
  15466. config
  15467. op Op
  15468. typ string
  15469. id *uint64
  15470. created_at *time.Time
  15471. updated_at *time.Time
  15472. deleted_at *time.Time
  15473. stype *string
  15474. title *string
  15475. photo *string
  15476. organization_id *uint64
  15477. addorganization_id *int64
  15478. clearedFields map[string]struct{}
  15479. done bool
  15480. oldValue func(context.Context) (*EmployeeConfig, error)
  15481. predicates []predicate.EmployeeConfig
  15482. }
  15483. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15484. // employeeconfigOption allows management of the mutation configuration using functional options.
  15485. type employeeconfigOption func(*EmployeeConfigMutation)
  15486. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15487. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15488. m := &EmployeeConfigMutation{
  15489. config: c,
  15490. op: op,
  15491. typ: TypeEmployeeConfig,
  15492. clearedFields: make(map[string]struct{}),
  15493. }
  15494. for _, opt := range opts {
  15495. opt(m)
  15496. }
  15497. return m
  15498. }
  15499. // withEmployeeConfigID sets the ID field of the mutation.
  15500. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15501. return func(m *EmployeeConfigMutation) {
  15502. var (
  15503. err error
  15504. once sync.Once
  15505. value *EmployeeConfig
  15506. )
  15507. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15508. once.Do(func() {
  15509. if m.done {
  15510. err = errors.New("querying old values post mutation is not allowed")
  15511. } else {
  15512. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15513. }
  15514. })
  15515. return value, err
  15516. }
  15517. m.id = &id
  15518. }
  15519. }
  15520. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15521. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15522. return func(m *EmployeeConfigMutation) {
  15523. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15524. return node, nil
  15525. }
  15526. m.id = &node.ID
  15527. }
  15528. }
  15529. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15530. // executed in a transaction (ent.Tx), a transactional client is returned.
  15531. func (m EmployeeConfigMutation) Client() *Client {
  15532. client := &Client{config: m.config}
  15533. client.init()
  15534. return client
  15535. }
  15536. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15537. // it returns an error otherwise.
  15538. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15539. if _, ok := m.driver.(*txDriver); !ok {
  15540. return nil, errors.New("ent: mutation is not running in a transaction")
  15541. }
  15542. tx := &Tx{config: m.config}
  15543. tx.init()
  15544. return tx, nil
  15545. }
  15546. // SetID sets the value of the id field. Note that this
  15547. // operation is only accepted on creation of EmployeeConfig entities.
  15548. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15549. m.id = &id
  15550. }
  15551. // ID returns the ID value in the mutation. Note that the ID is only available
  15552. // if it was provided to the builder or after it was returned from the database.
  15553. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15554. if m.id == nil {
  15555. return
  15556. }
  15557. return *m.id, true
  15558. }
  15559. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15560. // That means, if the mutation is applied within a transaction with an isolation level such
  15561. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15562. // or updated by the mutation.
  15563. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15564. switch {
  15565. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15566. id, exists := m.ID()
  15567. if exists {
  15568. return []uint64{id}, nil
  15569. }
  15570. fallthrough
  15571. case m.op.Is(OpUpdate | OpDelete):
  15572. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15573. default:
  15574. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15575. }
  15576. }
  15577. // SetCreatedAt sets the "created_at" field.
  15578. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15579. m.created_at = &t
  15580. }
  15581. // CreatedAt returns the value of the "created_at" field in the mutation.
  15582. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15583. v := m.created_at
  15584. if v == nil {
  15585. return
  15586. }
  15587. return *v, true
  15588. }
  15589. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15590. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15592. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15593. if !m.op.Is(OpUpdateOne) {
  15594. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15595. }
  15596. if m.id == nil || m.oldValue == nil {
  15597. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15598. }
  15599. oldValue, err := m.oldValue(ctx)
  15600. if err != nil {
  15601. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15602. }
  15603. return oldValue.CreatedAt, nil
  15604. }
  15605. // ResetCreatedAt resets all changes to the "created_at" field.
  15606. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15607. m.created_at = nil
  15608. }
  15609. // SetUpdatedAt sets the "updated_at" field.
  15610. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15611. m.updated_at = &t
  15612. }
  15613. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15614. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15615. v := m.updated_at
  15616. if v == nil {
  15617. return
  15618. }
  15619. return *v, true
  15620. }
  15621. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15622. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15624. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15625. if !m.op.Is(OpUpdateOne) {
  15626. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15627. }
  15628. if m.id == nil || m.oldValue == nil {
  15629. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15630. }
  15631. oldValue, err := m.oldValue(ctx)
  15632. if err != nil {
  15633. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15634. }
  15635. return oldValue.UpdatedAt, nil
  15636. }
  15637. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15638. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15639. m.updated_at = nil
  15640. }
  15641. // SetDeletedAt sets the "deleted_at" field.
  15642. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15643. m.deleted_at = &t
  15644. }
  15645. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15646. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15647. v := m.deleted_at
  15648. if v == nil {
  15649. return
  15650. }
  15651. return *v, true
  15652. }
  15653. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15654. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15656. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15657. if !m.op.Is(OpUpdateOne) {
  15658. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15659. }
  15660. if m.id == nil || m.oldValue == nil {
  15661. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15662. }
  15663. oldValue, err := m.oldValue(ctx)
  15664. if err != nil {
  15665. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15666. }
  15667. return oldValue.DeletedAt, nil
  15668. }
  15669. // ClearDeletedAt clears the value of the "deleted_at" field.
  15670. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15671. m.deleted_at = nil
  15672. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15673. }
  15674. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15675. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15676. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15677. return ok
  15678. }
  15679. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15680. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15681. m.deleted_at = nil
  15682. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15683. }
  15684. // SetStype sets the "stype" field.
  15685. func (m *EmployeeConfigMutation) SetStype(s string) {
  15686. m.stype = &s
  15687. }
  15688. // Stype returns the value of the "stype" field in the mutation.
  15689. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15690. v := m.stype
  15691. if v == nil {
  15692. return
  15693. }
  15694. return *v, true
  15695. }
  15696. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15697. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15699. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15700. if !m.op.Is(OpUpdateOne) {
  15701. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15702. }
  15703. if m.id == nil || m.oldValue == nil {
  15704. return v, errors.New("OldStype requires an ID field in the mutation")
  15705. }
  15706. oldValue, err := m.oldValue(ctx)
  15707. if err != nil {
  15708. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15709. }
  15710. return oldValue.Stype, nil
  15711. }
  15712. // ResetStype resets all changes to the "stype" field.
  15713. func (m *EmployeeConfigMutation) ResetStype() {
  15714. m.stype = nil
  15715. }
  15716. // SetTitle sets the "title" field.
  15717. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15718. m.title = &s
  15719. }
  15720. // Title returns the value of the "title" field in the mutation.
  15721. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15722. v := m.title
  15723. if v == nil {
  15724. return
  15725. }
  15726. return *v, true
  15727. }
  15728. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15729. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15731. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15732. if !m.op.Is(OpUpdateOne) {
  15733. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15734. }
  15735. if m.id == nil || m.oldValue == nil {
  15736. return v, errors.New("OldTitle requires an ID field in the mutation")
  15737. }
  15738. oldValue, err := m.oldValue(ctx)
  15739. if err != nil {
  15740. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15741. }
  15742. return oldValue.Title, nil
  15743. }
  15744. // ResetTitle resets all changes to the "title" field.
  15745. func (m *EmployeeConfigMutation) ResetTitle() {
  15746. m.title = nil
  15747. }
  15748. // SetPhoto sets the "photo" field.
  15749. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15750. m.photo = &s
  15751. }
  15752. // Photo returns the value of the "photo" field in the mutation.
  15753. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15754. v := m.photo
  15755. if v == nil {
  15756. return
  15757. }
  15758. return *v, true
  15759. }
  15760. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15761. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15763. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15764. if !m.op.Is(OpUpdateOne) {
  15765. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15766. }
  15767. if m.id == nil || m.oldValue == nil {
  15768. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15769. }
  15770. oldValue, err := m.oldValue(ctx)
  15771. if err != nil {
  15772. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15773. }
  15774. return oldValue.Photo, nil
  15775. }
  15776. // ResetPhoto resets all changes to the "photo" field.
  15777. func (m *EmployeeConfigMutation) ResetPhoto() {
  15778. m.photo = nil
  15779. }
  15780. // SetOrganizationID sets the "organization_id" field.
  15781. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15782. m.organization_id = &u
  15783. m.addorganization_id = nil
  15784. }
  15785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15786. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15787. v := m.organization_id
  15788. if v == nil {
  15789. return
  15790. }
  15791. return *v, true
  15792. }
  15793. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15794. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15796. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15797. if !m.op.Is(OpUpdateOne) {
  15798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15799. }
  15800. if m.id == nil || m.oldValue == nil {
  15801. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15802. }
  15803. oldValue, err := m.oldValue(ctx)
  15804. if err != nil {
  15805. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15806. }
  15807. return oldValue.OrganizationID, nil
  15808. }
  15809. // AddOrganizationID adds u to the "organization_id" field.
  15810. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15811. if m.addorganization_id != nil {
  15812. *m.addorganization_id += u
  15813. } else {
  15814. m.addorganization_id = &u
  15815. }
  15816. }
  15817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15818. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15819. v := m.addorganization_id
  15820. if v == nil {
  15821. return
  15822. }
  15823. return *v, true
  15824. }
  15825. // ClearOrganizationID clears the value of the "organization_id" field.
  15826. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15827. m.organization_id = nil
  15828. m.addorganization_id = nil
  15829. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15830. }
  15831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15832. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15833. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15834. return ok
  15835. }
  15836. // ResetOrganizationID resets all changes to the "organization_id" field.
  15837. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15838. m.organization_id = nil
  15839. m.addorganization_id = nil
  15840. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15841. }
  15842. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15843. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15844. m.predicates = append(m.predicates, ps...)
  15845. }
  15846. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15847. // users can use type-assertion to append predicates that do not depend on any generated package.
  15848. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15849. p := make([]predicate.EmployeeConfig, len(ps))
  15850. for i := range ps {
  15851. p[i] = ps[i]
  15852. }
  15853. m.Where(p...)
  15854. }
  15855. // Op returns the operation name.
  15856. func (m *EmployeeConfigMutation) Op() Op {
  15857. return m.op
  15858. }
  15859. // SetOp allows setting the mutation operation.
  15860. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15861. m.op = op
  15862. }
  15863. // Type returns the node type of this mutation (EmployeeConfig).
  15864. func (m *EmployeeConfigMutation) Type() string {
  15865. return m.typ
  15866. }
  15867. // Fields returns all fields that were changed during this mutation. Note that in
  15868. // order to get all numeric fields that were incremented/decremented, call
  15869. // AddedFields().
  15870. func (m *EmployeeConfigMutation) Fields() []string {
  15871. fields := make([]string, 0, 7)
  15872. if m.created_at != nil {
  15873. fields = append(fields, employeeconfig.FieldCreatedAt)
  15874. }
  15875. if m.updated_at != nil {
  15876. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15877. }
  15878. if m.deleted_at != nil {
  15879. fields = append(fields, employeeconfig.FieldDeletedAt)
  15880. }
  15881. if m.stype != nil {
  15882. fields = append(fields, employeeconfig.FieldStype)
  15883. }
  15884. if m.title != nil {
  15885. fields = append(fields, employeeconfig.FieldTitle)
  15886. }
  15887. if m.photo != nil {
  15888. fields = append(fields, employeeconfig.FieldPhoto)
  15889. }
  15890. if m.organization_id != nil {
  15891. fields = append(fields, employeeconfig.FieldOrganizationID)
  15892. }
  15893. return fields
  15894. }
  15895. // Field returns the value of a field with the given name. The second boolean
  15896. // return value indicates that this field was not set, or was not defined in the
  15897. // schema.
  15898. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15899. switch name {
  15900. case employeeconfig.FieldCreatedAt:
  15901. return m.CreatedAt()
  15902. case employeeconfig.FieldUpdatedAt:
  15903. return m.UpdatedAt()
  15904. case employeeconfig.FieldDeletedAt:
  15905. return m.DeletedAt()
  15906. case employeeconfig.FieldStype:
  15907. return m.Stype()
  15908. case employeeconfig.FieldTitle:
  15909. return m.Title()
  15910. case employeeconfig.FieldPhoto:
  15911. return m.Photo()
  15912. case employeeconfig.FieldOrganizationID:
  15913. return m.OrganizationID()
  15914. }
  15915. return nil, false
  15916. }
  15917. // OldField returns the old value of the field from the database. An error is
  15918. // returned if the mutation operation is not UpdateOne, or the query to the
  15919. // database failed.
  15920. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15921. switch name {
  15922. case employeeconfig.FieldCreatedAt:
  15923. return m.OldCreatedAt(ctx)
  15924. case employeeconfig.FieldUpdatedAt:
  15925. return m.OldUpdatedAt(ctx)
  15926. case employeeconfig.FieldDeletedAt:
  15927. return m.OldDeletedAt(ctx)
  15928. case employeeconfig.FieldStype:
  15929. return m.OldStype(ctx)
  15930. case employeeconfig.FieldTitle:
  15931. return m.OldTitle(ctx)
  15932. case employeeconfig.FieldPhoto:
  15933. return m.OldPhoto(ctx)
  15934. case employeeconfig.FieldOrganizationID:
  15935. return m.OldOrganizationID(ctx)
  15936. }
  15937. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15938. }
  15939. // SetField sets the value of a field with the given name. It returns an error if
  15940. // the field is not defined in the schema, or if the type mismatched the field
  15941. // type.
  15942. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15943. switch name {
  15944. case employeeconfig.FieldCreatedAt:
  15945. v, ok := value.(time.Time)
  15946. if !ok {
  15947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15948. }
  15949. m.SetCreatedAt(v)
  15950. return nil
  15951. case employeeconfig.FieldUpdatedAt:
  15952. v, ok := value.(time.Time)
  15953. if !ok {
  15954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15955. }
  15956. m.SetUpdatedAt(v)
  15957. return nil
  15958. case employeeconfig.FieldDeletedAt:
  15959. v, ok := value.(time.Time)
  15960. if !ok {
  15961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15962. }
  15963. m.SetDeletedAt(v)
  15964. return nil
  15965. case employeeconfig.FieldStype:
  15966. v, ok := value.(string)
  15967. if !ok {
  15968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15969. }
  15970. m.SetStype(v)
  15971. return nil
  15972. case employeeconfig.FieldTitle:
  15973. v, ok := value.(string)
  15974. if !ok {
  15975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15976. }
  15977. m.SetTitle(v)
  15978. return nil
  15979. case employeeconfig.FieldPhoto:
  15980. v, ok := value.(string)
  15981. if !ok {
  15982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15983. }
  15984. m.SetPhoto(v)
  15985. return nil
  15986. case employeeconfig.FieldOrganizationID:
  15987. v, ok := value.(uint64)
  15988. if !ok {
  15989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15990. }
  15991. m.SetOrganizationID(v)
  15992. return nil
  15993. }
  15994. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15995. }
  15996. // AddedFields returns all numeric fields that were incremented/decremented during
  15997. // this mutation.
  15998. func (m *EmployeeConfigMutation) AddedFields() []string {
  15999. var fields []string
  16000. if m.addorganization_id != nil {
  16001. fields = append(fields, employeeconfig.FieldOrganizationID)
  16002. }
  16003. return fields
  16004. }
  16005. // AddedField returns the numeric value that was incremented/decremented on a field
  16006. // with the given name. The second boolean return value indicates that this field
  16007. // was not set, or was not defined in the schema.
  16008. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  16009. switch name {
  16010. case employeeconfig.FieldOrganizationID:
  16011. return m.AddedOrganizationID()
  16012. }
  16013. return nil, false
  16014. }
  16015. // AddField adds the value to the field with the given name. It returns an error if
  16016. // the field is not defined in the schema, or if the type mismatched the field
  16017. // type.
  16018. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  16019. switch name {
  16020. case employeeconfig.FieldOrganizationID:
  16021. v, ok := value.(int64)
  16022. if !ok {
  16023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16024. }
  16025. m.AddOrganizationID(v)
  16026. return nil
  16027. }
  16028. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  16029. }
  16030. // ClearedFields returns all nullable fields that were cleared during this
  16031. // mutation.
  16032. func (m *EmployeeConfigMutation) ClearedFields() []string {
  16033. var fields []string
  16034. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  16035. fields = append(fields, employeeconfig.FieldDeletedAt)
  16036. }
  16037. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  16038. fields = append(fields, employeeconfig.FieldOrganizationID)
  16039. }
  16040. return fields
  16041. }
  16042. // FieldCleared returns a boolean indicating if a field with the given name was
  16043. // cleared in this mutation.
  16044. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  16045. _, ok := m.clearedFields[name]
  16046. return ok
  16047. }
  16048. // ClearField clears the value of the field with the given name. It returns an
  16049. // error if the field is not defined in the schema.
  16050. func (m *EmployeeConfigMutation) ClearField(name string) error {
  16051. switch name {
  16052. case employeeconfig.FieldDeletedAt:
  16053. m.ClearDeletedAt()
  16054. return nil
  16055. case employeeconfig.FieldOrganizationID:
  16056. m.ClearOrganizationID()
  16057. return nil
  16058. }
  16059. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  16060. }
  16061. // ResetField resets all changes in the mutation for the field with the given name.
  16062. // It returns an error if the field is not defined in the schema.
  16063. func (m *EmployeeConfigMutation) ResetField(name string) error {
  16064. switch name {
  16065. case employeeconfig.FieldCreatedAt:
  16066. m.ResetCreatedAt()
  16067. return nil
  16068. case employeeconfig.FieldUpdatedAt:
  16069. m.ResetUpdatedAt()
  16070. return nil
  16071. case employeeconfig.FieldDeletedAt:
  16072. m.ResetDeletedAt()
  16073. return nil
  16074. case employeeconfig.FieldStype:
  16075. m.ResetStype()
  16076. return nil
  16077. case employeeconfig.FieldTitle:
  16078. m.ResetTitle()
  16079. return nil
  16080. case employeeconfig.FieldPhoto:
  16081. m.ResetPhoto()
  16082. return nil
  16083. case employeeconfig.FieldOrganizationID:
  16084. m.ResetOrganizationID()
  16085. return nil
  16086. }
  16087. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16088. }
  16089. // AddedEdges returns all edge names that were set/added in this mutation.
  16090. func (m *EmployeeConfigMutation) AddedEdges() []string {
  16091. edges := make([]string, 0, 0)
  16092. return edges
  16093. }
  16094. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16095. // name in this mutation.
  16096. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  16097. return nil
  16098. }
  16099. // RemovedEdges returns all edge names that were removed in this mutation.
  16100. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  16101. edges := make([]string, 0, 0)
  16102. return edges
  16103. }
  16104. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16105. // the given name in this mutation.
  16106. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  16107. return nil
  16108. }
  16109. // ClearedEdges returns all edge names that were cleared in this mutation.
  16110. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  16111. edges := make([]string, 0, 0)
  16112. return edges
  16113. }
  16114. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16115. // was cleared in this mutation.
  16116. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  16117. return false
  16118. }
  16119. // ClearEdge clears the value of the edge with the given name. It returns an error
  16120. // if that edge is not defined in the schema.
  16121. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  16122. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  16123. }
  16124. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16125. // It returns an error if the edge is not defined in the schema.
  16126. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  16127. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  16128. }
  16129. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  16130. type LabelMutation struct {
  16131. config
  16132. op Op
  16133. typ string
  16134. id *uint64
  16135. created_at *time.Time
  16136. updated_at *time.Time
  16137. status *uint8
  16138. addstatus *int8
  16139. _type *int
  16140. add_type *int
  16141. name *string
  16142. from *int
  16143. addfrom *int
  16144. mode *int
  16145. addmode *int
  16146. conditions *string
  16147. organization_id *uint64
  16148. addorganization_id *int64
  16149. clearedFields map[string]struct{}
  16150. label_relationships map[uint64]struct{}
  16151. removedlabel_relationships map[uint64]struct{}
  16152. clearedlabel_relationships bool
  16153. done bool
  16154. oldValue func(context.Context) (*Label, error)
  16155. predicates []predicate.Label
  16156. }
  16157. var _ ent.Mutation = (*LabelMutation)(nil)
  16158. // labelOption allows management of the mutation configuration using functional options.
  16159. type labelOption func(*LabelMutation)
  16160. // newLabelMutation creates new mutation for the Label entity.
  16161. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  16162. m := &LabelMutation{
  16163. config: c,
  16164. op: op,
  16165. typ: TypeLabel,
  16166. clearedFields: make(map[string]struct{}),
  16167. }
  16168. for _, opt := range opts {
  16169. opt(m)
  16170. }
  16171. return m
  16172. }
  16173. // withLabelID sets the ID field of the mutation.
  16174. func withLabelID(id uint64) labelOption {
  16175. return func(m *LabelMutation) {
  16176. var (
  16177. err error
  16178. once sync.Once
  16179. value *Label
  16180. )
  16181. m.oldValue = func(ctx context.Context) (*Label, error) {
  16182. once.Do(func() {
  16183. if m.done {
  16184. err = errors.New("querying old values post mutation is not allowed")
  16185. } else {
  16186. value, err = m.Client().Label.Get(ctx, id)
  16187. }
  16188. })
  16189. return value, err
  16190. }
  16191. m.id = &id
  16192. }
  16193. }
  16194. // withLabel sets the old Label of the mutation.
  16195. func withLabel(node *Label) labelOption {
  16196. return func(m *LabelMutation) {
  16197. m.oldValue = func(context.Context) (*Label, error) {
  16198. return node, nil
  16199. }
  16200. m.id = &node.ID
  16201. }
  16202. }
  16203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16204. // executed in a transaction (ent.Tx), a transactional client is returned.
  16205. func (m LabelMutation) Client() *Client {
  16206. client := &Client{config: m.config}
  16207. client.init()
  16208. return client
  16209. }
  16210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16211. // it returns an error otherwise.
  16212. func (m LabelMutation) Tx() (*Tx, error) {
  16213. if _, ok := m.driver.(*txDriver); !ok {
  16214. return nil, errors.New("ent: mutation is not running in a transaction")
  16215. }
  16216. tx := &Tx{config: m.config}
  16217. tx.init()
  16218. return tx, nil
  16219. }
  16220. // SetID sets the value of the id field. Note that this
  16221. // operation is only accepted on creation of Label entities.
  16222. func (m *LabelMutation) SetID(id uint64) {
  16223. m.id = &id
  16224. }
  16225. // ID returns the ID value in the mutation. Note that the ID is only available
  16226. // if it was provided to the builder or after it was returned from the database.
  16227. func (m *LabelMutation) ID() (id uint64, exists bool) {
  16228. if m.id == nil {
  16229. return
  16230. }
  16231. return *m.id, true
  16232. }
  16233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16234. // That means, if the mutation is applied within a transaction with an isolation level such
  16235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16236. // or updated by the mutation.
  16237. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  16238. switch {
  16239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16240. id, exists := m.ID()
  16241. if exists {
  16242. return []uint64{id}, nil
  16243. }
  16244. fallthrough
  16245. case m.op.Is(OpUpdate | OpDelete):
  16246. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  16247. default:
  16248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16249. }
  16250. }
  16251. // SetCreatedAt sets the "created_at" field.
  16252. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  16253. m.created_at = &t
  16254. }
  16255. // CreatedAt returns the value of the "created_at" field in the mutation.
  16256. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  16257. v := m.created_at
  16258. if v == nil {
  16259. return
  16260. }
  16261. return *v, true
  16262. }
  16263. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  16264. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16266. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16267. if !m.op.Is(OpUpdateOne) {
  16268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16269. }
  16270. if m.id == nil || m.oldValue == nil {
  16271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16272. }
  16273. oldValue, err := m.oldValue(ctx)
  16274. if err != nil {
  16275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16276. }
  16277. return oldValue.CreatedAt, nil
  16278. }
  16279. // ResetCreatedAt resets all changes to the "created_at" field.
  16280. func (m *LabelMutation) ResetCreatedAt() {
  16281. m.created_at = nil
  16282. }
  16283. // SetUpdatedAt sets the "updated_at" field.
  16284. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  16285. m.updated_at = &t
  16286. }
  16287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16288. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16289. v := m.updated_at
  16290. if v == nil {
  16291. return
  16292. }
  16293. return *v, true
  16294. }
  16295. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  16296. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16298. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16299. if !m.op.Is(OpUpdateOne) {
  16300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16301. }
  16302. if m.id == nil || m.oldValue == nil {
  16303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16304. }
  16305. oldValue, err := m.oldValue(ctx)
  16306. if err != nil {
  16307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16308. }
  16309. return oldValue.UpdatedAt, nil
  16310. }
  16311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16312. func (m *LabelMutation) ResetUpdatedAt() {
  16313. m.updated_at = nil
  16314. }
  16315. // SetStatus sets the "status" field.
  16316. func (m *LabelMutation) SetStatus(u uint8) {
  16317. m.status = &u
  16318. m.addstatus = nil
  16319. }
  16320. // Status returns the value of the "status" field in the mutation.
  16321. func (m *LabelMutation) Status() (r uint8, exists bool) {
  16322. v := m.status
  16323. if v == nil {
  16324. return
  16325. }
  16326. return *v, true
  16327. }
  16328. // OldStatus returns the old "status" field's value of the Label entity.
  16329. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16331. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16332. if !m.op.Is(OpUpdateOne) {
  16333. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16334. }
  16335. if m.id == nil || m.oldValue == nil {
  16336. return v, errors.New("OldStatus requires an ID field in the mutation")
  16337. }
  16338. oldValue, err := m.oldValue(ctx)
  16339. if err != nil {
  16340. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16341. }
  16342. return oldValue.Status, nil
  16343. }
  16344. // AddStatus adds u to the "status" field.
  16345. func (m *LabelMutation) AddStatus(u int8) {
  16346. if m.addstatus != nil {
  16347. *m.addstatus += u
  16348. } else {
  16349. m.addstatus = &u
  16350. }
  16351. }
  16352. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16353. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  16354. v := m.addstatus
  16355. if v == nil {
  16356. return
  16357. }
  16358. return *v, true
  16359. }
  16360. // ClearStatus clears the value of the "status" field.
  16361. func (m *LabelMutation) ClearStatus() {
  16362. m.status = nil
  16363. m.addstatus = nil
  16364. m.clearedFields[label.FieldStatus] = struct{}{}
  16365. }
  16366. // StatusCleared returns if the "status" field was cleared in this mutation.
  16367. func (m *LabelMutation) StatusCleared() bool {
  16368. _, ok := m.clearedFields[label.FieldStatus]
  16369. return ok
  16370. }
  16371. // ResetStatus resets all changes to the "status" field.
  16372. func (m *LabelMutation) ResetStatus() {
  16373. m.status = nil
  16374. m.addstatus = nil
  16375. delete(m.clearedFields, label.FieldStatus)
  16376. }
  16377. // SetType sets the "type" field.
  16378. func (m *LabelMutation) SetType(i int) {
  16379. m._type = &i
  16380. m.add_type = nil
  16381. }
  16382. // GetType returns the value of the "type" field in the mutation.
  16383. func (m *LabelMutation) GetType() (r int, exists bool) {
  16384. v := m._type
  16385. if v == nil {
  16386. return
  16387. }
  16388. return *v, true
  16389. }
  16390. // OldType returns the old "type" field's value of the Label entity.
  16391. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16393. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16394. if !m.op.Is(OpUpdateOne) {
  16395. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16396. }
  16397. if m.id == nil || m.oldValue == nil {
  16398. return v, errors.New("OldType requires an ID field in the mutation")
  16399. }
  16400. oldValue, err := m.oldValue(ctx)
  16401. if err != nil {
  16402. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16403. }
  16404. return oldValue.Type, nil
  16405. }
  16406. // AddType adds i to the "type" field.
  16407. func (m *LabelMutation) AddType(i int) {
  16408. if m.add_type != nil {
  16409. *m.add_type += i
  16410. } else {
  16411. m.add_type = &i
  16412. }
  16413. }
  16414. // AddedType returns the value that was added to the "type" field in this mutation.
  16415. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16416. v := m.add_type
  16417. if v == nil {
  16418. return
  16419. }
  16420. return *v, true
  16421. }
  16422. // ResetType resets all changes to the "type" field.
  16423. func (m *LabelMutation) ResetType() {
  16424. m._type = nil
  16425. m.add_type = nil
  16426. }
  16427. // SetName sets the "name" field.
  16428. func (m *LabelMutation) SetName(s string) {
  16429. m.name = &s
  16430. }
  16431. // Name returns the value of the "name" field in the mutation.
  16432. func (m *LabelMutation) Name() (r string, exists bool) {
  16433. v := m.name
  16434. if v == nil {
  16435. return
  16436. }
  16437. return *v, true
  16438. }
  16439. // OldName returns the old "name" field's value of the Label entity.
  16440. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16442. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16443. if !m.op.Is(OpUpdateOne) {
  16444. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16445. }
  16446. if m.id == nil || m.oldValue == nil {
  16447. return v, errors.New("OldName requires an ID field in the mutation")
  16448. }
  16449. oldValue, err := m.oldValue(ctx)
  16450. if err != nil {
  16451. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16452. }
  16453. return oldValue.Name, nil
  16454. }
  16455. // ResetName resets all changes to the "name" field.
  16456. func (m *LabelMutation) ResetName() {
  16457. m.name = nil
  16458. }
  16459. // SetFrom sets the "from" field.
  16460. func (m *LabelMutation) SetFrom(i int) {
  16461. m.from = &i
  16462. m.addfrom = nil
  16463. }
  16464. // From returns the value of the "from" field in the mutation.
  16465. func (m *LabelMutation) From() (r int, exists bool) {
  16466. v := m.from
  16467. if v == nil {
  16468. return
  16469. }
  16470. return *v, true
  16471. }
  16472. // OldFrom returns the old "from" field's value of the Label entity.
  16473. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16475. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16476. if !m.op.Is(OpUpdateOne) {
  16477. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16478. }
  16479. if m.id == nil || m.oldValue == nil {
  16480. return v, errors.New("OldFrom requires an ID field in the mutation")
  16481. }
  16482. oldValue, err := m.oldValue(ctx)
  16483. if err != nil {
  16484. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16485. }
  16486. return oldValue.From, nil
  16487. }
  16488. // AddFrom adds i to the "from" field.
  16489. func (m *LabelMutation) AddFrom(i int) {
  16490. if m.addfrom != nil {
  16491. *m.addfrom += i
  16492. } else {
  16493. m.addfrom = &i
  16494. }
  16495. }
  16496. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16497. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16498. v := m.addfrom
  16499. if v == nil {
  16500. return
  16501. }
  16502. return *v, true
  16503. }
  16504. // ResetFrom resets all changes to the "from" field.
  16505. func (m *LabelMutation) ResetFrom() {
  16506. m.from = nil
  16507. m.addfrom = nil
  16508. }
  16509. // SetMode sets the "mode" field.
  16510. func (m *LabelMutation) SetMode(i int) {
  16511. m.mode = &i
  16512. m.addmode = nil
  16513. }
  16514. // Mode returns the value of the "mode" field in the mutation.
  16515. func (m *LabelMutation) Mode() (r int, exists bool) {
  16516. v := m.mode
  16517. if v == nil {
  16518. return
  16519. }
  16520. return *v, true
  16521. }
  16522. // OldMode returns the old "mode" field's value of the Label entity.
  16523. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16525. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16526. if !m.op.Is(OpUpdateOne) {
  16527. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16528. }
  16529. if m.id == nil || m.oldValue == nil {
  16530. return v, errors.New("OldMode requires an ID field in the mutation")
  16531. }
  16532. oldValue, err := m.oldValue(ctx)
  16533. if err != nil {
  16534. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16535. }
  16536. return oldValue.Mode, nil
  16537. }
  16538. // AddMode adds i to the "mode" field.
  16539. func (m *LabelMutation) AddMode(i int) {
  16540. if m.addmode != nil {
  16541. *m.addmode += i
  16542. } else {
  16543. m.addmode = &i
  16544. }
  16545. }
  16546. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16547. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16548. v := m.addmode
  16549. if v == nil {
  16550. return
  16551. }
  16552. return *v, true
  16553. }
  16554. // ResetMode resets all changes to the "mode" field.
  16555. func (m *LabelMutation) ResetMode() {
  16556. m.mode = nil
  16557. m.addmode = nil
  16558. }
  16559. // SetConditions sets the "conditions" field.
  16560. func (m *LabelMutation) SetConditions(s string) {
  16561. m.conditions = &s
  16562. }
  16563. // Conditions returns the value of the "conditions" field in the mutation.
  16564. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16565. v := m.conditions
  16566. if v == nil {
  16567. return
  16568. }
  16569. return *v, true
  16570. }
  16571. // OldConditions returns the old "conditions" field's value of the Label entity.
  16572. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16574. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16575. if !m.op.Is(OpUpdateOne) {
  16576. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16577. }
  16578. if m.id == nil || m.oldValue == nil {
  16579. return v, errors.New("OldConditions requires an ID field in the mutation")
  16580. }
  16581. oldValue, err := m.oldValue(ctx)
  16582. if err != nil {
  16583. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16584. }
  16585. return oldValue.Conditions, nil
  16586. }
  16587. // ClearConditions clears the value of the "conditions" field.
  16588. func (m *LabelMutation) ClearConditions() {
  16589. m.conditions = nil
  16590. m.clearedFields[label.FieldConditions] = struct{}{}
  16591. }
  16592. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16593. func (m *LabelMutation) ConditionsCleared() bool {
  16594. _, ok := m.clearedFields[label.FieldConditions]
  16595. return ok
  16596. }
  16597. // ResetConditions resets all changes to the "conditions" field.
  16598. func (m *LabelMutation) ResetConditions() {
  16599. m.conditions = nil
  16600. delete(m.clearedFields, label.FieldConditions)
  16601. }
  16602. // SetOrganizationID sets the "organization_id" field.
  16603. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16604. m.organization_id = &u
  16605. m.addorganization_id = nil
  16606. }
  16607. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16608. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16609. v := m.organization_id
  16610. if v == nil {
  16611. return
  16612. }
  16613. return *v, true
  16614. }
  16615. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16616. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16618. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16619. if !m.op.Is(OpUpdateOne) {
  16620. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16621. }
  16622. if m.id == nil || m.oldValue == nil {
  16623. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16624. }
  16625. oldValue, err := m.oldValue(ctx)
  16626. if err != nil {
  16627. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16628. }
  16629. return oldValue.OrganizationID, nil
  16630. }
  16631. // AddOrganizationID adds u to the "organization_id" field.
  16632. func (m *LabelMutation) AddOrganizationID(u int64) {
  16633. if m.addorganization_id != nil {
  16634. *m.addorganization_id += u
  16635. } else {
  16636. m.addorganization_id = &u
  16637. }
  16638. }
  16639. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16640. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16641. v := m.addorganization_id
  16642. if v == nil {
  16643. return
  16644. }
  16645. return *v, true
  16646. }
  16647. // ClearOrganizationID clears the value of the "organization_id" field.
  16648. func (m *LabelMutation) ClearOrganizationID() {
  16649. m.organization_id = nil
  16650. m.addorganization_id = nil
  16651. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16652. }
  16653. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16654. func (m *LabelMutation) OrganizationIDCleared() bool {
  16655. _, ok := m.clearedFields[label.FieldOrganizationID]
  16656. return ok
  16657. }
  16658. // ResetOrganizationID resets all changes to the "organization_id" field.
  16659. func (m *LabelMutation) ResetOrganizationID() {
  16660. m.organization_id = nil
  16661. m.addorganization_id = nil
  16662. delete(m.clearedFields, label.FieldOrganizationID)
  16663. }
  16664. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16665. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16666. if m.label_relationships == nil {
  16667. m.label_relationships = make(map[uint64]struct{})
  16668. }
  16669. for i := range ids {
  16670. m.label_relationships[ids[i]] = struct{}{}
  16671. }
  16672. }
  16673. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16674. func (m *LabelMutation) ClearLabelRelationships() {
  16675. m.clearedlabel_relationships = true
  16676. }
  16677. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16678. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16679. return m.clearedlabel_relationships
  16680. }
  16681. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16682. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16683. if m.removedlabel_relationships == nil {
  16684. m.removedlabel_relationships = make(map[uint64]struct{})
  16685. }
  16686. for i := range ids {
  16687. delete(m.label_relationships, ids[i])
  16688. m.removedlabel_relationships[ids[i]] = struct{}{}
  16689. }
  16690. }
  16691. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16692. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16693. for id := range m.removedlabel_relationships {
  16694. ids = append(ids, id)
  16695. }
  16696. return
  16697. }
  16698. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16699. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16700. for id := range m.label_relationships {
  16701. ids = append(ids, id)
  16702. }
  16703. return
  16704. }
  16705. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16706. func (m *LabelMutation) ResetLabelRelationships() {
  16707. m.label_relationships = nil
  16708. m.clearedlabel_relationships = false
  16709. m.removedlabel_relationships = nil
  16710. }
  16711. // Where appends a list predicates to the LabelMutation builder.
  16712. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16713. m.predicates = append(m.predicates, ps...)
  16714. }
  16715. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16716. // users can use type-assertion to append predicates that do not depend on any generated package.
  16717. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16718. p := make([]predicate.Label, len(ps))
  16719. for i := range ps {
  16720. p[i] = ps[i]
  16721. }
  16722. m.Where(p...)
  16723. }
  16724. // Op returns the operation name.
  16725. func (m *LabelMutation) Op() Op {
  16726. return m.op
  16727. }
  16728. // SetOp allows setting the mutation operation.
  16729. func (m *LabelMutation) SetOp(op Op) {
  16730. m.op = op
  16731. }
  16732. // Type returns the node type of this mutation (Label).
  16733. func (m *LabelMutation) Type() string {
  16734. return m.typ
  16735. }
  16736. // Fields returns all fields that were changed during this mutation. Note that in
  16737. // order to get all numeric fields that were incremented/decremented, call
  16738. // AddedFields().
  16739. func (m *LabelMutation) Fields() []string {
  16740. fields := make([]string, 0, 9)
  16741. if m.created_at != nil {
  16742. fields = append(fields, label.FieldCreatedAt)
  16743. }
  16744. if m.updated_at != nil {
  16745. fields = append(fields, label.FieldUpdatedAt)
  16746. }
  16747. if m.status != nil {
  16748. fields = append(fields, label.FieldStatus)
  16749. }
  16750. if m._type != nil {
  16751. fields = append(fields, label.FieldType)
  16752. }
  16753. if m.name != nil {
  16754. fields = append(fields, label.FieldName)
  16755. }
  16756. if m.from != nil {
  16757. fields = append(fields, label.FieldFrom)
  16758. }
  16759. if m.mode != nil {
  16760. fields = append(fields, label.FieldMode)
  16761. }
  16762. if m.conditions != nil {
  16763. fields = append(fields, label.FieldConditions)
  16764. }
  16765. if m.organization_id != nil {
  16766. fields = append(fields, label.FieldOrganizationID)
  16767. }
  16768. return fields
  16769. }
  16770. // Field returns the value of a field with the given name. The second boolean
  16771. // return value indicates that this field was not set, or was not defined in the
  16772. // schema.
  16773. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16774. switch name {
  16775. case label.FieldCreatedAt:
  16776. return m.CreatedAt()
  16777. case label.FieldUpdatedAt:
  16778. return m.UpdatedAt()
  16779. case label.FieldStatus:
  16780. return m.Status()
  16781. case label.FieldType:
  16782. return m.GetType()
  16783. case label.FieldName:
  16784. return m.Name()
  16785. case label.FieldFrom:
  16786. return m.From()
  16787. case label.FieldMode:
  16788. return m.Mode()
  16789. case label.FieldConditions:
  16790. return m.Conditions()
  16791. case label.FieldOrganizationID:
  16792. return m.OrganizationID()
  16793. }
  16794. return nil, false
  16795. }
  16796. // OldField returns the old value of the field from the database. An error is
  16797. // returned if the mutation operation is not UpdateOne, or the query to the
  16798. // database failed.
  16799. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16800. switch name {
  16801. case label.FieldCreatedAt:
  16802. return m.OldCreatedAt(ctx)
  16803. case label.FieldUpdatedAt:
  16804. return m.OldUpdatedAt(ctx)
  16805. case label.FieldStatus:
  16806. return m.OldStatus(ctx)
  16807. case label.FieldType:
  16808. return m.OldType(ctx)
  16809. case label.FieldName:
  16810. return m.OldName(ctx)
  16811. case label.FieldFrom:
  16812. return m.OldFrom(ctx)
  16813. case label.FieldMode:
  16814. return m.OldMode(ctx)
  16815. case label.FieldConditions:
  16816. return m.OldConditions(ctx)
  16817. case label.FieldOrganizationID:
  16818. return m.OldOrganizationID(ctx)
  16819. }
  16820. return nil, fmt.Errorf("unknown Label field %s", name)
  16821. }
  16822. // SetField sets the value of a field with the given name. It returns an error if
  16823. // the field is not defined in the schema, or if the type mismatched the field
  16824. // type.
  16825. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16826. switch name {
  16827. case label.FieldCreatedAt:
  16828. v, ok := value.(time.Time)
  16829. if !ok {
  16830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16831. }
  16832. m.SetCreatedAt(v)
  16833. return nil
  16834. case label.FieldUpdatedAt:
  16835. v, ok := value.(time.Time)
  16836. if !ok {
  16837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16838. }
  16839. m.SetUpdatedAt(v)
  16840. return nil
  16841. case label.FieldStatus:
  16842. v, ok := value.(uint8)
  16843. if !ok {
  16844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16845. }
  16846. m.SetStatus(v)
  16847. return nil
  16848. case label.FieldType:
  16849. v, ok := value.(int)
  16850. if !ok {
  16851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16852. }
  16853. m.SetType(v)
  16854. return nil
  16855. case label.FieldName:
  16856. v, ok := value.(string)
  16857. if !ok {
  16858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16859. }
  16860. m.SetName(v)
  16861. return nil
  16862. case label.FieldFrom:
  16863. v, ok := value.(int)
  16864. if !ok {
  16865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16866. }
  16867. m.SetFrom(v)
  16868. return nil
  16869. case label.FieldMode:
  16870. v, ok := value.(int)
  16871. if !ok {
  16872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16873. }
  16874. m.SetMode(v)
  16875. return nil
  16876. case label.FieldConditions:
  16877. v, ok := value.(string)
  16878. if !ok {
  16879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16880. }
  16881. m.SetConditions(v)
  16882. return nil
  16883. case label.FieldOrganizationID:
  16884. v, ok := value.(uint64)
  16885. if !ok {
  16886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16887. }
  16888. m.SetOrganizationID(v)
  16889. return nil
  16890. }
  16891. return fmt.Errorf("unknown Label field %s", name)
  16892. }
  16893. // AddedFields returns all numeric fields that were incremented/decremented during
  16894. // this mutation.
  16895. func (m *LabelMutation) AddedFields() []string {
  16896. var fields []string
  16897. if m.addstatus != nil {
  16898. fields = append(fields, label.FieldStatus)
  16899. }
  16900. if m.add_type != nil {
  16901. fields = append(fields, label.FieldType)
  16902. }
  16903. if m.addfrom != nil {
  16904. fields = append(fields, label.FieldFrom)
  16905. }
  16906. if m.addmode != nil {
  16907. fields = append(fields, label.FieldMode)
  16908. }
  16909. if m.addorganization_id != nil {
  16910. fields = append(fields, label.FieldOrganizationID)
  16911. }
  16912. return fields
  16913. }
  16914. // AddedField returns the numeric value that was incremented/decremented on a field
  16915. // with the given name. The second boolean return value indicates that this field
  16916. // was not set, or was not defined in the schema.
  16917. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16918. switch name {
  16919. case label.FieldStatus:
  16920. return m.AddedStatus()
  16921. case label.FieldType:
  16922. return m.AddedType()
  16923. case label.FieldFrom:
  16924. return m.AddedFrom()
  16925. case label.FieldMode:
  16926. return m.AddedMode()
  16927. case label.FieldOrganizationID:
  16928. return m.AddedOrganizationID()
  16929. }
  16930. return nil, false
  16931. }
  16932. // AddField adds the value to the field with the given name. It returns an error if
  16933. // the field is not defined in the schema, or if the type mismatched the field
  16934. // type.
  16935. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16936. switch name {
  16937. case label.FieldStatus:
  16938. v, ok := value.(int8)
  16939. if !ok {
  16940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16941. }
  16942. m.AddStatus(v)
  16943. return nil
  16944. case label.FieldType:
  16945. v, ok := value.(int)
  16946. if !ok {
  16947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16948. }
  16949. m.AddType(v)
  16950. return nil
  16951. case label.FieldFrom:
  16952. v, ok := value.(int)
  16953. if !ok {
  16954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16955. }
  16956. m.AddFrom(v)
  16957. return nil
  16958. case label.FieldMode:
  16959. v, ok := value.(int)
  16960. if !ok {
  16961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16962. }
  16963. m.AddMode(v)
  16964. return nil
  16965. case label.FieldOrganizationID:
  16966. v, ok := value.(int64)
  16967. if !ok {
  16968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16969. }
  16970. m.AddOrganizationID(v)
  16971. return nil
  16972. }
  16973. return fmt.Errorf("unknown Label numeric field %s", name)
  16974. }
  16975. // ClearedFields returns all nullable fields that were cleared during this
  16976. // mutation.
  16977. func (m *LabelMutation) ClearedFields() []string {
  16978. var fields []string
  16979. if m.FieldCleared(label.FieldStatus) {
  16980. fields = append(fields, label.FieldStatus)
  16981. }
  16982. if m.FieldCleared(label.FieldConditions) {
  16983. fields = append(fields, label.FieldConditions)
  16984. }
  16985. if m.FieldCleared(label.FieldOrganizationID) {
  16986. fields = append(fields, label.FieldOrganizationID)
  16987. }
  16988. return fields
  16989. }
  16990. // FieldCleared returns a boolean indicating if a field with the given name was
  16991. // cleared in this mutation.
  16992. func (m *LabelMutation) FieldCleared(name string) bool {
  16993. _, ok := m.clearedFields[name]
  16994. return ok
  16995. }
  16996. // ClearField clears the value of the field with the given name. It returns an
  16997. // error if the field is not defined in the schema.
  16998. func (m *LabelMutation) ClearField(name string) error {
  16999. switch name {
  17000. case label.FieldStatus:
  17001. m.ClearStatus()
  17002. return nil
  17003. case label.FieldConditions:
  17004. m.ClearConditions()
  17005. return nil
  17006. case label.FieldOrganizationID:
  17007. m.ClearOrganizationID()
  17008. return nil
  17009. }
  17010. return fmt.Errorf("unknown Label nullable field %s", name)
  17011. }
  17012. // ResetField resets all changes in the mutation for the field with the given name.
  17013. // It returns an error if the field is not defined in the schema.
  17014. func (m *LabelMutation) ResetField(name string) error {
  17015. switch name {
  17016. case label.FieldCreatedAt:
  17017. m.ResetCreatedAt()
  17018. return nil
  17019. case label.FieldUpdatedAt:
  17020. m.ResetUpdatedAt()
  17021. return nil
  17022. case label.FieldStatus:
  17023. m.ResetStatus()
  17024. return nil
  17025. case label.FieldType:
  17026. m.ResetType()
  17027. return nil
  17028. case label.FieldName:
  17029. m.ResetName()
  17030. return nil
  17031. case label.FieldFrom:
  17032. m.ResetFrom()
  17033. return nil
  17034. case label.FieldMode:
  17035. m.ResetMode()
  17036. return nil
  17037. case label.FieldConditions:
  17038. m.ResetConditions()
  17039. return nil
  17040. case label.FieldOrganizationID:
  17041. m.ResetOrganizationID()
  17042. return nil
  17043. }
  17044. return fmt.Errorf("unknown Label field %s", name)
  17045. }
  17046. // AddedEdges returns all edge names that were set/added in this mutation.
  17047. func (m *LabelMutation) AddedEdges() []string {
  17048. edges := make([]string, 0, 1)
  17049. if m.label_relationships != nil {
  17050. edges = append(edges, label.EdgeLabelRelationships)
  17051. }
  17052. return edges
  17053. }
  17054. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17055. // name in this mutation.
  17056. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  17057. switch name {
  17058. case label.EdgeLabelRelationships:
  17059. ids := make([]ent.Value, 0, len(m.label_relationships))
  17060. for id := range m.label_relationships {
  17061. ids = append(ids, id)
  17062. }
  17063. return ids
  17064. }
  17065. return nil
  17066. }
  17067. // RemovedEdges returns all edge names that were removed in this mutation.
  17068. func (m *LabelMutation) RemovedEdges() []string {
  17069. edges := make([]string, 0, 1)
  17070. if m.removedlabel_relationships != nil {
  17071. edges = append(edges, label.EdgeLabelRelationships)
  17072. }
  17073. return edges
  17074. }
  17075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17076. // the given name in this mutation.
  17077. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  17078. switch name {
  17079. case label.EdgeLabelRelationships:
  17080. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  17081. for id := range m.removedlabel_relationships {
  17082. ids = append(ids, id)
  17083. }
  17084. return ids
  17085. }
  17086. return nil
  17087. }
  17088. // ClearedEdges returns all edge names that were cleared in this mutation.
  17089. func (m *LabelMutation) ClearedEdges() []string {
  17090. edges := make([]string, 0, 1)
  17091. if m.clearedlabel_relationships {
  17092. edges = append(edges, label.EdgeLabelRelationships)
  17093. }
  17094. return edges
  17095. }
  17096. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17097. // was cleared in this mutation.
  17098. func (m *LabelMutation) EdgeCleared(name string) bool {
  17099. switch name {
  17100. case label.EdgeLabelRelationships:
  17101. return m.clearedlabel_relationships
  17102. }
  17103. return false
  17104. }
  17105. // ClearEdge clears the value of the edge with the given name. It returns an error
  17106. // if that edge is not defined in the schema.
  17107. func (m *LabelMutation) ClearEdge(name string) error {
  17108. switch name {
  17109. }
  17110. return fmt.Errorf("unknown Label unique edge %s", name)
  17111. }
  17112. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17113. // It returns an error if the edge is not defined in the schema.
  17114. func (m *LabelMutation) ResetEdge(name string) error {
  17115. switch name {
  17116. case label.EdgeLabelRelationships:
  17117. m.ResetLabelRelationships()
  17118. return nil
  17119. }
  17120. return fmt.Errorf("unknown Label edge %s", name)
  17121. }
  17122. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  17123. type LabelRelationshipMutation struct {
  17124. config
  17125. op Op
  17126. typ string
  17127. id *uint64
  17128. created_at *time.Time
  17129. updated_at *time.Time
  17130. status *uint8
  17131. addstatus *int8
  17132. organization_id *uint64
  17133. addorganization_id *int64
  17134. clearedFields map[string]struct{}
  17135. contacts *uint64
  17136. clearedcontacts bool
  17137. labels *uint64
  17138. clearedlabels bool
  17139. done bool
  17140. oldValue func(context.Context) (*LabelRelationship, error)
  17141. predicates []predicate.LabelRelationship
  17142. }
  17143. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  17144. // labelrelationshipOption allows management of the mutation configuration using functional options.
  17145. type labelrelationshipOption func(*LabelRelationshipMutation)
  17146. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  17147. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  17148. m := &LabelRelationshipMutation{
  17149. config: c,
  17150. op: op,
  17151. typ: TypeLabelRelationship,
  17152. clearedFields: make(map[string]struct{}),
  17153. }
  17154. for _, opt := range opts {
  17155. opt(m)
  17156. }
  17157. return m
  17158. }
  17159. // withLabelRelationshipID sets the ID field of the mutation.
  17160. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  17161. return func(m *LabelRelationshipMutation) {
  17162. var (
  17163. err error
  17164. once sync.Once
  17165. value *LabelRelationship
  17166. )
  17167. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  17168. once.Do(func() {
  17169. if m.done {
  17170. err = errors.New("querying old values post mutation is not allowed")
  17171. } else {
  17172. value, err = m.Client().LabelRelationship.Get(ctx, id)
  17173. }
  17174. })
  17175. return value, err
  17176. }
  17177. m.id = &id
  17178. }
  17179. }
  17180. // withLabelRelationship sets the old LabelRelationship of the mutation.
  17181. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  17182. return func(m *LabelRelationshipMutation) {
  17183. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  17184. return node, nil
  17185. }
  17186. m.id = &node.ID
  17187. }
  17188. }
  17189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17190. // executed in a transaction (ent.Tx), a transactional client is returned.
  17191. func (m LabelRelationshipMutation) Client() *Client {
  17192. client := &Client{config: m.config}
  17193. client.init()
  17194. return client
  17195. }
  17196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17197. // it returns an error otherwise.
  17198. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  17199. if _, ok := m.driver.(*txDriver); !ok {
  17200. return nil, errors.New("ent: mutation is not running in a transaction")
  17201. }
  17202. tx := &Tx{config: m.config}
  17203. tx.init()
  17204. return tx, nil
  17205. }
  17206. // SetID sets the value of the id field. Note that this
  17207. // operation is only accepted on creation of LabelRelationship entities.
  17208. func (m *LabelRelationshipMutation) SetID(id uint64) {
  17209. m.id = &id
  17210. }
  17211. // ID returns the ID value in the mutation. Note that the ID is only available
  17212. // if it was provided to the builder or after it was returned from the database.
  17213. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  17214. if m.id == nil {
  17215. return
  17216. }
  17217. return *m.id, true
  17218. }
  17219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17220. // That means, if the mutation is applied within a transaction with an isolation level such
  17221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17222. // or updated by the mutation.
  17223. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  17224. switch {
  17225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17226. id, exists := m.ID()
  17227. if exists {
  17228. return []uint64{id}, nil
  17229. }
  17230. fallthrough
  17231. case m.op.Is(OpUpdate | OpDelete):
  17232. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  17233. default:
  17234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17235. }
  17236. }
  17237. // SetCreatedAt sets the "created_at" field.
  17238. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  17239. m.created_at = &t
  17240. }
  17241. // CreatedAt returns the value of the "created_at" field in the mutation.
  17242. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  17243. v := m.created_at
  17244. if v == nil {
  17245. return
  17246. }
  17247. return *v, true
  17248. }
  17249. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  17250. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17252. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17253. if !m.op.Is(OpUpdateOne) {
  17254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17255. }
  17256. if m.id == nil || m.oldValue == nil {
  17257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17258. }
  17259. oldValue, err := m.oldValue(ctx)
  17260. if err != nil {
  17261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17262. }
  17263. return oldValue.CreatedAt, nil
  17264. }
  17265. // ResetCreatedAt resets all changes to the "created_at" field.
  17266. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  17267. m.created_at = nil
  17268. }
  17269. // SetUpdatedAt sets the "updated_at" field.
  17270. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  17271. m.updated_at = &t
  17272. }
  17273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17274. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  17275. v := m.updated_at
  17276. if v == nil {
  17277. return
  17278. }
  17279. return *v, true
  17280. }
  17281. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  17282. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17284. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17285. if !m.op.Is(OpUpdateOne) {
  17286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17287. }
  17288. if m.id == nil || m.oldValue == nil {
  17289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17290. }
  17291. oldValue, err := m.oldValue(ctx)
  17292. if err != nil {
  17293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17294. }
  17295. return oldValue.UpdatedAt, nil
  17296. }
  17297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17298. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  17299. m.updated_at = nil
  17300. }
  17301. // SetStatus sets the "status" field.
  17302. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  17303. m.status = &u
  17304. m.addstatus = nil
  17305. }
  17306. // Status returns the value of the "status" field in the mutation.
  17307. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  17308. v := m.status
  17309. if v == nil {
  17310. return
  17311. }
  17312. return *v, true
  17313. }
  17314. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  17315. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17317. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17318. if !m.op.Is(OpUpdateOne) {
  17319. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17320. }
  17321. if m.id == nil || m.oldValue == nil {
  17322. return v, errors.New("OldStatus requires an ID field in the mutation")
  17323. }
  17324. oldValue, err := m.oldValue(ctx)
  17325. if err != nil {
  17326. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17327. }
  17328. return oldValue.Status, nil
  17329. }
  17330. // AddStatus adds u to the "status" field.
  17331. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  17332. if m.addstatus != nil {
  17333. *m.addstatus += u
  17334. } else {
  17335. m.addstatus = &u
  17336. }
  17337. }
  17338. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17339. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  17340. v := m.addstatus
  17341. if v == nil {
  17342. return
  17343. }
  17344. return *v, true
  17345. }
  17346. // ClearStatus clears the value of the "status" field.
  17347. func (m *LabelRelationshipMutation) ClearStatus() {
  17348. m.status = nil
  17349. m.addstatus = nil
  17350. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  17351. }
  17352. // StatusCleared returns if the "status" field was cleared in this mutation.
  17353. func (m *LabelRelationshipMutation) StatusCleared() bool {
  17354. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  17355. return ok
  17356. }
  17357. // ResetStatus resets all changes to the "status" field.
  17358. func (m *LabelRelationshipMutation) ResetStatus() {
  17359. m.status = nil
  17360. m.addstatus = nil
  17361. delete(m.clearedFields, labelrelationship.FieldStatus)
  17362. }
  17363. // SetLabelID sets the "label_id" field.
  17364. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17365. m.labels = &u
  17366. }
  17367. // LabelID returns the value of the "label_id" field in the mutation.
  17368. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17369. v := m.labels
  17370. if v == nil {
  17371. return
  17372. }
  17373. return *v, true
  17374. }
  17375. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17376. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17378. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17379. if !m.op.Is(OpUpdateOne) {
  17380. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17381. }
  17382. if m.id == nil || m.oldValue == nil {
  17383. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17384. }
  17385. oldValue, err := m.oldValue(ctx)
  17386. if err != nil {
  17387. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17388. }
  17389. return oldValue.LabelID, nil
  17390. }
  17391. // ResetLabelID resets all changes to the "label_id" field.
  17392. func (m *LabelRelationshipMutation) ResetLabelID() {
  17393. m.labels = nil
  17394. }
  17395. // SetContactID sets the "contact_id" field.
  17396. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17397. m.contacts = &u
  17398. }
  17399. // ContactID returns the value of the "contact_id" field in the mutation.
  17400. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17401. v := m.contacts
  17402. if v == nil {
  17403. return
  17404. }
  17405. return *v, true
  17406. }
  17407. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17408. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17410. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17411. if !m.op.Is(OpUpdateOne) {
  17412. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17413. }
  17414. if m.id == nil || m.oldValue == nil {
  17415. return v, errors.New("OldContactID requires an ID field in the mutation")
  17416. }
  17417. oldValue, err := m.oldValue(ctx)
  17418. if err != nil {
  17419. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17420. }
  17421. return oldValue.ContactID, nil
  17422. }
  17423. // ResetContactID resets all changes to the "contact_id" field.
  17424. func (m *LabelRelationshipMutation) ResetContactID() {
  17425. m.contacts = nil
  17426. }
  17427. // SetOrganizationID sets the "organization_id" field.
  17428. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17429. m.organization_id = &u
  17430. m.addorganization_id = nil
  17431. }
  17432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17433. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17434. v := m.organization_id
  17435. if v == nil {
  17436. return
  17437. }
  17438. return *v, true
  17439. }
  17440. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17441. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17443. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17444. if !m.op.Is(OpUpdateOne) {
  17445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17446. }
  17447. if m.id == nil || m.oldValue == nil {
  17448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17449. }
  17450. oldValue, err := m.oldValue(ctx)
  17451. if err != nil {
  17452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17453. }
  17454. return oldValue.OrganizationID, nil
  17455. }
  17456. // AddOrganizationID adds u to the "organization_id" field.
  17457. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17458. if m.addorganization_id != nil {
  17459. *m.addorganization_id += u
  17460. } else {
  17461. m.addorganization_id = &u
  17462. }
  17463. }
  17464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17465. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17466. v := m.addorganization_id
  17467. if v == nil {
  17468. return
  17469. }
  17470. return *v, true
  17471. }
  17472. // ClearOrganizationID clears the value of the "organization_id" field.
  17473. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17474. m.organization_id = nil
  17475. m.addorganization_id = nil
  17476. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17477. }
  17478. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17479. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17480. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17481. return ok
  17482. }
  17483. // ResetOrganizationID resets all changes to the "organization_id" field.
  17484. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17485. m.organization_id = nil
  17486. m.addorganization_id = nil
  17487. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17488. }
  17489. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17490. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17491. m.contacts = &id
  17492. }
  17493. // ClearContacts clears the "contacts" edge to the Contact entity.
  17494. func (m *LabelRelationshipMutation) ClearContacts() {
  17495. m.clearedcontacts = true
  17496. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17497. }
  17498. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17499. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17500. return m.clearedcontacts
  17501. }
  17502. // ContactsID returns the "contacts" edge ID in the mutation.
  17503. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17504. if m.contacts != nil {
  17505. return *m.contacts, true
  17506. }
  17507. return
  17508. }
  17509. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17510. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17511. // ContactsID instead. It exists only for internal usage by the builders.
  17512. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17513. if id := m.contacts; id != nil {
  17514. ids = append(ids, *id)
  17515. }
  17516. return
  17517. }
  17518. // ResetContacts resets all changes to the "contacts" edge.
  17519. func (m *LabelRelationshipMutation) ResetContacts() {
  17520. m.contacts = nil
  17521. m.clearedcontacts = false
  17522. }
  17523. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17524. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17525. m.labels = &id
  17526. }
  17527. // ClearLabels clears the "labels" edge to the Label entity.
  17528. func (m *LabelRelationshipMutation) ClearLabels() {
  17529. m.clearedlabels = true
  17530. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17531. }
  17532. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17533. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17534. return m.clearedlabels
  17535. }
  17536. // LabelsID returns the "labels" edge ID in the mutation.
  17537. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17538. if m.labels != nil {
  17539. return *m.labels, true
  17540. }
  17541. return
  17542. }
  17543. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17544. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17545. // LabelsID instead. It exists only for internal usage by the builders.
  17546. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17547. if id := m.labels; id != nil {
  17548. ids = append(ids, *id)
  17549. }
  17550. return
  17551. }
  17552. // ResetLabels resets all changes to the "labels" edge.
  17553. func (m *LabelRelationshipMutation) ResetLabels() {
  17554. m.labels = nil
  17555. m.clearedlabels = false
  17556. }
  17557. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17558. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17559. m.predicates = append(m.predicates, ps...)
  17560. }
  17561. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17562. // users can use type-assertion to append predicates that do not depend on any generated package.
  17563. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17564. p := make([]predicate.LabelRelationship, len(ps))
  17565. for i := range ps {
  17566. p[i] = ps[i]
  17567. }
  17568. m.Where(p...)
  17569. }
  17570. // Op returns the operation name.
  17571. func (m *LabelRelationshipMutation) Op() Op {
  17572. return m.op
  17573. }
  17574. // SetOp allows setting the mutation operation.
  17575. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17576. m.op = op
  17577. }
  17578. // Type returns the node type of this mutation (LabelRelationship).
  17579. func (m *LabelRelationshipMutation) Type() string {
  17580. return m.typ
  17581. }
  17582. // Fields returns all fields that were changed during this mutation. Note that in
  17583. // order to get all numeric fields that were incremented/decremented, call
  17584. // AddedFields().
  17585. func (m *LabelRelationshipMutation) Fields() []string {
  17586. fields := make([]string, 0, 6)
  17587. if m.created_at != nil {
  17588. fields = append(fields, labelrelationship.FieldCreatedAt)
  17589. }
  17590. if m.updated_at != nil {
  17591. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17592. }
  17593. if m.status != nil {
  17594. fields = append(fields, labelrelationship.FieldStatus)
  17595. }
  17596. if m.labels != nil {
  17597. fields = append(fields, labelrelationship.FieldLabelID)
  17598. }
  17599. if m.contacts != nil {
  17600. fields = append(fields, labelrelationship.FieldContactID)
  17601. }
  17602. if m.organization_id != nil {
  17603. fields = append(fields, labelrelationship.FieldOrganizationID)
  17604. }
  17605. return fields
  17606. }
  17607. // Field returns the value of a field with the given name. The second boolean
  17608. // return value indicates that this field was not set, or was not defined in the
  17609. // schema.
  17610. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17611. switch name {
  17612. case labelrelationship.FieldCreatedAt:
  17613. return m.CreatedAt()
  17614. case labelrelationship.FieldUpdatedAt:
  17615. return m.UpdatedAt()
  17616. case labelrelationship.FieldStatus:
  17617. return m.Status()
  17618. case labelrelationship.FieldLabelID:
  17619. return m.LabelID()
  17620. case labelrelationship.FieldContactID:
  17621. return m.ContactID()
  17622. case labelrelationship.FieldOrganizationID:
  17623. return m.OrganizationID()
  17624. }
  17625. return nil, false
  17626. }
  17627. // OldField returns the old value of the field from the database. An error is
  17628. // returned if the mutation operation is not UpdateOne, or the query to the
  17629. // database failed.
  17630. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17631. switch name {
  17632. case labelrelationship.FieldCreatedAt:
  17633. return m.OldCreatedAt(ctx)
  17634. case labelrelationship.FieldUpdatedAt:
  17635. return m.OldUpdatedAt(ctx)
  17636. case labelrelationship.FieldStatus:
  17637. return m.OldStatus(ctx)
  17638. case labelrelationship.FieldLabelID:
  17639. return m.OldLabelID(ctx)
  17640. case labelrelationship.FieldContactID:
  17641. return m.OldContactID(ctx)
  17642. case labelrelationship.FieldOrganizationID:
  17643. return m.OldOrganizationID(ctx)
  17644. }
  17645. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17646. }
  17647. // SetField sets the value of a field with the given name. It returns an error if
  17648. // the field is not defined in the schema, or if the type mismatched the field
  17649. // type.
  17650. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17651. switch name {
  17652. case labelrelationship.FieldCreatedAt:
  17653. v, ok := value.(time.Time)
  17654. if !ok {
  17655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17656. }
  17657. m.SetCreatedAt(v)
  17658. return nil
  17659. case labelrelationship.FieldUpdatedAt:
  17660. v, ok := value.(time.Time)
  17661. if !ok {
  17662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17663. }
  17664. m.SetUpdatedAt(v)
  17665. return nil
  17666. case labelrelationship.FieldStatus:
  17667. v, ok := value.(uint8)
  17668. if !ok {
  17669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17670. }
  17671. m.SetStatus(v)
  17672. return nil
  17673. case labelrelationship.FieldLabelID:
  17674. v, ok := value.(uint64)
  17675. if !ok {
  17676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17677. }
  17678. m.SetLabelID(v)
  17679. return nil
  17680. case labelrelationship.FieldContactID:
  17681. v, ok := value.(uint64)
  17682. if !ok {
  17683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17684. }
  17685. m.SetContactID(v)
  17686. return nil
  17687. case labelrelationship.FieldOrganizationID:
  17688. v, ok := value.(uint64)
  17689. if !ok {
  17690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17691. }
  17692. m.SetOrganizationID(v)
  17693. return nil
  17694. }
  17695. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17696. }
  17697. // AddedFields returns all numeric fields that were incremented/decremented during
  17698. // this mutation.
  17699. func (m *LabelRelationshipMutation) AddedFields() []string {
  17700. var fields []string
  17701. if m.addstatus != nil {
  17702. fields = append(fields, labelrelationship.FieldStatus)
  17703. }
  17704. if m.addorganization_id != nil {
  17705. fields = append(fields, labelrelationship.FieldOrganizationID)
  17706. }
  17707. return fields
  17708. }
  17709. // AddedField returns the numeric value that was incremented/decremented on a field
  17710. // with the given name. The second boolean return value indicates that this field
  17711. // was not set, or was not defined in the schema.
  17712. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17713. switch name {
  17714. case labelrelationship.FieldStatus:
  17715. return m.AddedStatus()
  17716. case labelrelationship.FieldOrganizationID:
  17717. return m.AddedOrganizationID()
  17718. }
  17719. return nil, false
  17720. }
  17721. // AddField adds the value to the field with the given name. It returns an error if
  17722. // the field is not defined in the schema, or if the type mismatched the field
  17723. // type.
  17724. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17725. switch name {
  17726. case labelrelationship.FieldStatus:
  17727. v, ok := value.(int8)
  17728. if !ok {
  17729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17730. }
  17731. m.AddStatus(v)
  17732. return nil
  17733. case labelrelationship.FieldOrganizationID:
  17734. v, ok := value.(int64)
  17735. if !ok {
  17736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17737. }
  17738. m.AddOrganizationID(v)
  17739. return nil
  17740. }
  17741. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17742. }
  17743. // ClearedFields returns all nullable fields that were cleared during this
  17744. // mutation.
  17745. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17746. var fields []string
  17747. if m.FieldCleared(labelrelationship.FieldStatus) {
  17748. fields = append(fields, labelrelationship.FieldStatus)
  17749. }
  17750. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17751. fields = append(fields, labelrelationship.FieldOrganizationID)
  17752. }
  17753. return fields
  17754. }
  17755. // FieldCleared returns a boolean indicating if a field with the given name was
  17756. // cleared in this mutation.
  17757. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17758. _, ok := m.clearedFields[name]
  17759. return ok
  17760. }
  17761. // ClearField clears the value of the field with the given name. It returns an
  17762. // error if the field is not defined in the schema.
  17763. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17764. switch name {
  17765. case labelrelationship.FieldStatus:
  17766. m.ClearStatus()
  17767. return nil
  17768. case labelrelationship.FieldOrganizationID:
  17769. m.ClearOrganizationID()
  17770. return nil
  17771. }
  17772. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17773. }
  17774. // ResetField resets all changes in the mutation for the field with the given name.
  17775. // It returns an error if the field is not defined in the schema.
  17776. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17777. switch name {
  17778. case labelrelationship.FieldCreatedAt:
  17779. m.ResetCreatedAt()
  17780. return nil
  17781. case labelrelationship.FieldUpdatedAt:
  17782. m.ResetUpdatedAt()
  17783. return nil
  17784. case labelrelationship.FieldStatus:
  17785. m.ResetStatus()
  17786. return nil
  17787. case labelrelationship.FieldLabelID:
  17788. m.ResetLabelID()
  17789. return nil
  17790. case labelrelationship.FieldContactID:
  17791. m.ResetContactID()
  17792. return nil
  17793. case labelrelationship.FieldOrganizationID:
  17794. m.ResetOrganizationID()
  17795. return nil
  17796. }
  17797. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17798. }
  17799. // AddedEdges returns all edge names that were set/added in this mutation.
  17800. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17801. edges := make([]string, 0, 2)
  17802. if m.contacts != nil {
  17803. edges = append(edges, labelrelationship.EdgeContacts)
  17804. }
  17805. if m.labels != nil {
  17806. edges = append(edges, labelrelationship.EdgeLabels)
  17807. }
  17808. return edges
  17809. }
  17810. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17811. // name in this mutation.
  17812. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17813. switch name {
  17814. case labelrelationship.EdgeContacts:
  17815. if id := m.contacts; id != nil {
  17816. return []ent.Value{*id}
  17817. }
  17818. case labelrelationship.EdgeLabels:
  17819. if id := m.labels; id != nil {
  17820. return []ent.Value{*id}
  17821. }
  17822. }
  17823. return nil
  17824. }
  17825. // RemovedEdges returns all edge names that were removed in this mutation.
  17826. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17827. edges := make([]string, 0, 2)
  17828. return edges
  17829. }
  17830. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17831. // the given name in this mutation.
  17832. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17833. return nil
  17834. }
  17835. // ClearedEdges returns all edge names that were cleared in this mutation.
  17836. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17837. edges := make([]string, 0, 2)
  17838. if m.clearedcontacts {
  17839. edges = append(edges, labelrelationship.EdgeContacts)
  17840. }
  17841. if m.clearedlabels {
  17842. edges = append(edges, labelrelationship.EdgeLabels)
  17843. }
  17844. return edges
  17845. }
  17846. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17847. // was cleared in this mutation.
  17848. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17849. switch name {
  17850. case labelrelationship.EdgeContacts:
  17851. return m.clearedcontacts
  17852. case labelrelationship.EdgeLabels:
  17853. return m.clearedlabels
  17854. }
  17855. return false
  17856. }
  17857. // ClearEdge clears the value of the edge with the given name. It returns an error
  17858. // if that edge is not defined in the schema.
  17859. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17860. switch name {
  17861. case labelrelationship.EdgeContacts:
  17862. m.ClearContacts()
  17863. return nil
  17864. case labelrelationship.EdgeLabels:
  17865. m.ClearLabels()
  17866. return nil
  17867. }
  17868. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17869. }
  17870. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17871. // It returns an error if the edge is not defined in the schema.
  17872. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17873. switch name {
  17874. case labelrelationship.EdgeContacts:
  17875. m.ResetContacts()
  17876. return nil
  17877. case labelrelationship.EdgeLabels:
  17878. m.ResetLabels()
  17879. return nil
  17880. }
  17881. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17882. }
  17883. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17884. type LabelTaggingMutation struct {
  17885. config
  17886. op Op
  17887. typ string
  17888. id *uint64
  17889. created_at *time.Time
  17890. updated_at *time.Time
  17891. status *uint8
  17892. addstatus *int8
  17893. deleted_at *time.Time
  17894. organization_id *uint64
  17895. addorganization_id *int64
  17896. _type *int
  17897. add_type *int
  17898. conditions *string
  17899. action_label_add *[]uint64
  17900. appendaction_label_add []uint64
  17901. action_label_del *[]uint64
  17902. appendaction_label_del []uint64
  17903. clearedFields map[string]struct{}
  17904. done bool
  17905. oldValue func(context.Context) (*LabelTagging, error)
  17906. predicates []predicate.LabelTagging
  17907. }
  17908. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17909. // labeltaggingOption allows management of the mutation configuration using functional options.
  17910. type labeltaggingOption func(*LabelTaggingMutation)
  17911. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17912. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17913. m := &LabelTaggingMutation{
  17914. config: c,
  17915. op: op,
  17916. typ: TypeLabelTagging,
  17917. clearedFields: make(map[string]struct{}),
  17918. }
  17919. for _, opt := range opts {
  17920. opt(m)
  17921. }
  17922. return m
  17923. }
  17924. // withLabelTaggingID sets the ID field of the mutation.
  17925. func withLabelTaggingID(id uint64) labeltaggingOption {
  17926. return func(m *LabelTaggingMutation) {
  17927. var (
  17928. err error
  17929. once sync.Once
  17930. value *LabelTagging
  17931. )
  17932. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17933. once.Do(func() {
  17934. if m.done {
  17935. err = errors.New("querying old values post mutation is not allowed")
  17936. } else {
  17937. value, err = m.Client().LabelTagging.Get(ctx, id)
  17938. }
  17939. })
  17940. return value, err
  17941. }
  17942. m.id = &id
  17943. }
  17944. }
  17945. // withLabelTagging sets the old LabelTagging of the mutation.
  17946. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17947. return func(m *LabelTaggingMutation) {
  17948. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17949. return node, nil
  17950. }
  17951. m.id = &node.ID
  17952. }
  17953. }
  17954. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17955. // executed in a transaction (ent.Tx), a transactional client is returned.
  17956. func (m LabelTaggingMutation) Client() *Client {
  17957. client := &Client{config: m.config}
  17958. client.init()
  17959. return client
  17960. }
  17961. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17962. // it returns an error otherwise.
  17963. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17964. if _, ok := m.driver.(*txDriver); !ok {
  17965. return nil, errors.New("ent: mutation is not running in a transaction")
  17966. }
  17967. tx := &Tx{config: m.config}
  17968. tx.init()
  17969. return tx, nil
  17970. }
  17971. // SetID sets the value of the id field. Note that this
  17972. // operation is only accepted on creation of LabelTagging entities.
  17973. func (m *LabelTaggingMutation) SetID(id uint64) {
  17974. m.id = &id
  17975. }
  17976. // ID returns the ID value in the mutation. Note that the ID is only available
  17977. // if it was provided to the builder or after it was returned from the database.
  17978. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17979. if m.id == nil {
  17980. return
  17981. }
  17982. return *m.id, true
  17983. }
  17984. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17985. // That means, if the mutation is applied within a transaction with an isolation level such
  17986. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17987. // or updated by the mutation.
  17988. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17989. switch {
  17990. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17991. id, exists := m.ID()
  17992. if exists {
  17993. return []uint64{id}, nil
  17994. }
  17995. fallthrough
  17996. case m.op.Is(OpUpdate | OpDelete):
  17997. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17998. default:
  17999. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18000. }
  18001. }
  18002. // SetCreatedAt sets the "created_at" field.
  18003. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  18004. m.created_at = &t
  18005. }
  18006. // CreatedAt returns the value of the "created_at" field in the mutation.
  18007. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  18008. v := m.created_at
  18009. if v == nil {
  18010. return
  18011. }
  18012. return *v, true
  18013. }
  18014. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  18015. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18017. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18018. if !m.op.Is(OpUpdateOne) {
  18019. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18020. }
  18021. if m.id == nil || m.oldValue == nil {
  18022. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18023. }
  18024. oldValue, err := m.oldValue(ctx)
  18025. if err != nil {
  18026. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18027. }
  18028. return oldValue.CreatedAt, nil
  18029. }
  18030. // ResetCreatedAt resets all changes to the "created_at" field.
  18031. func (m *LabelTaggingMutation) ResetCreatedAt() {
  18032. m.created_at = nil
  18033. }
  18034. // SetUpdatedAt sets the "updated_at" field.
  18035. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  18036. m.updated_at = &t
  18037. }
  18038. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18039. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  18040. v := m.updated_at
  18041. if v == nil {
  18042. return
  18043. }
  18044. return *v, true
  18045. }
  18046. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  18047. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18049. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18050. if !m.op.Is(OpUpdateOne) {
  18051. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18052. }
  18053. if m.id == nil || m.oldValue == nil {
  18054. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18055. }
  18056. oldValue, err := m.oldValue(ctx)
  18057. if err != nil {
  18058. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18059. }
  18060. return oldValue.UpdatedAt, nil
  18061. }
  18062. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18063. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  18064. m.updated_at = nil
  18065. }
  18066. // SetStatus sets the "status" field.
  18067. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  18068. m.status = &u
  18069. m.addstatus = nil
  18070. }
  18071. // Status returns the value of the "status" field in the mutation.
  18072. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  18073. v := m.status
  18074. if v == nil {
  18075. return
  18076. }
  18077. return *v, true
  18078. }
  18079. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  18080. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18082. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18083. if !m.op.Is(OpUpdateOne) {
  18084. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18085. }
  18086. if m.id == nil || m.oldValue == nil {
  18087. return v, errors.New("OldStatus requires an ID field in the mutation")
  18088. }
  18089. oldValue, err := m.oldValue(ctx)
  18090. if err != nil {
  18091. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18092. }
  18093. return oldValue.Status, nil
  18094. }
  18095. // AddStatus adds u to the "status" field.
  18096. func (m *LabelTaggingMutation) AddStatus(u int8) {
  18097. if m.addstatus != nil {
  18098. *m.addstatus += u
  18099. } else {
  18100. m.addstatus = &u
  18101. }
  18102. }
  18103. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18104. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  18105. v := m.addstatus
  18106. if v == nil {
  18107. return
  18108. }
  18109. return *v, true
  18110. }
  18111. // ClearStatus clears the value of the "status" field.
  18112. func (m *LabelTaggingMutation) ClearStatus() {
  18113. m.status = nil
  18114. m.addstatus = nil
  18115. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  18116. }
  18117. // StatusCleared returns if the "status" field was cleared in this mutation.
  18118. func (m *LabelTaggingMutation) StatusCleared() bool {
  18119. _, ok := m.clearedFields[labeltagging.FieldStatus]
  18120. return ok
  18121. }
  18122. // ResetStatus resets all changes to the "status" field.
  18123. func (m *LabelTaggingMutation) ResetStatus() {
  18124. m.status = nil
  18125. m.addstatus = nil
  18126. delete(m.clearedFields, labeltagging.FieldStatus)
  18127. }
  18128. // SetDeletedAt sets the "deleted_at" field.
  18129. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  18130. m.deleted_at = &t
  18131. }
  18132. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18133. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  18134. v := m.deleted_at
  18135. if v == nil {
  18136. return
  18137. }
  18138. return *v, true
  18139. }
  18140. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  18141. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18143. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18144. if !m.op.Is(OpUpdateOne) {
  18145. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18146. }
  18147. if m.id == nil || m.oldValue == nil {
  18148. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18149. }
  18150. oldValue, err := m.oldValue(ctx)
  18151. if err != nil {
  18152. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18153. }
  18154. return oldValue.DeletedAt, nil
  18155. }
  18156. // ClearDeletedAt clears the value of the "deleted_at" field.
  18157. func (m *LabelTaggingMutation) ClearDeletedAt() {
  18158. m.deleted_at = nil
  18159. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  18160. }
  18161. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18162. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  18163. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  18164. return ok
  18165. }
  18166. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18167. func (m *LabelTaggingMutation) ResetDeletedAt() {
  18168. m.deleted_at = nil
  18169. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  18170. }
  18171. // SetOrganizationID sets the "organization_id" field.
  18172. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  18173. m.organization_id = &u
  18174. m.addorganization_id = nil
  18175. }
  18176. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18177. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  18178. v := m.organization_id
  18179. if v == nil {
  18180. return
  18181. }
  18182. return *v, true
  18183. }
  18184. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  18185. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18187. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18188. if !m.op.Is(OpUpdateOne) {
  18189. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18190. }
  18191. if m.id == nil || m.oldValue == nil {
  18192. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18193. }
  18194. oldValue, err := m.oldValue(ctx)
  18195. if err != nil {
  18196. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18197. }
  18198. return oldValue.OrganizationID, nil
  18199. }
  18200. // AddOrganizationID adds u to the "organization_id" field.
  18201. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  18202. if m.addorganization_id != nil {
  18203. *m.addorganization_id += u
  18204. } else {
  18205. m.addorganization_id = &u
  18206. }
  18207. }
  18208. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18209. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  18210. v := m.addorganization_id
  18211. if v == nil {
  18212. return
  18213. }
  18214. return *v, true
  18215. }
  18216. // ResetOrganizationID resets all changes to the "organization_id" field.
  18217. func (m *LabelTaggingMutation) ResetOrganizationID() {
  18218. m.organization_id = nil
  18219. m.addorganization_id = nil
  18220. }
  18221. // SetType sets the "type" field.
  18222. func (m *LabelTaggingMutation) SetType(i int) {
  18223. m._type = &i
  18224. m.add_type = nil
  18225. }
  18226. // GetType returns the value of the "type" field in the mutation.
  18227. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  18228. v := m._type
  18229. if v == nil {
  18230. return
  18231. }
  18232. return *v, true
  18233. }
  18234. // OldType returns the old "type" field's value of the LabelTagging entity.
  18235. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18237. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  18238. if !m.op.Is(OpUpdateOne) {
  18239. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18240. }
  18241. if m.id == nil || m.oldValue == nil {
  18242. return v, errors.New("OldType requires an ID field in the mutation")
  18243. }
  18244. oldValue, err := m.oldValue(ctx)
  18245. if err != nil {
  18246. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18247. }
  18248. return oldValue.Type, nil
  18249. }
  18250. // AddType adds i to the "type" field.
  18251. func (m *LabelTaggingMutation) AddType(i int) {
  18252. if m.add_type != nil {
  18253. *m.add_type += i
  18254. } else {
  18255. m.add_type = &i
  18256. }
  18257. }
  18258. // AddedType returns the value that was added to the "type" field in this mutation.
  18259. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  18260. v := m.add_type
  18261. if v == nil {
  18262. return
  18263. }
  18264. return *v, true
  18265. }
  18266. // ResetType resets all changes to the "type" field.
  18267. func (m *LabelTaggingMutation) ResetType() {
  18268. m._type = nil
  18269. m.add_type = nil
  18270. }
  18271. // SetConditions sets the "conditions" field.
  18272. func (m *LabelTaggingMutation) SetConditions(s string) {
  18273. m.conditions = &s
  18274. }
  18275. // Conditions returns the value of the "conditions" field in the mutation.
  18276. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  18277. v := m.conditions
  18278. if v == nil {
  18279. return
  18280. }
  18281. return *v, true
  18282. }
  18283. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  18284. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18286. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  18287. if !m.op.Is(OpUpdateOne) {
  18288. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18289. }
  18290. if m.id == nil || m.oldValue == nil {
  18291. return v, errors.New("OldConditions requires an ID field in the mutation")
  18292. }
  18293. oldValue, err := m.oldValue(ctx)
  18294. if err != nil {
  18295. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18296. }
  18297. return oldValue.Conditions, nil
  18298. }
  18299. // ResetConditions resets all changes to the "conditions" field.
  18300. func (m *LabelTaggingMutation) ResetConditions() {
  18301. m.conditions = nil
  18302. }
  18303. // SetActionLabelAdd sets the "action_label_add" field.
  18304. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  18305. m.action_label_add = &u
  18306. m.appendaction_label_add = nil
  18307. }
  18308. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18309. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18310. v := m.action_label_add
  18311. if v == nil {
  18312. return
  18313. }
  18314. return *v, true
  18315. }
  18316. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  18317. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18319. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18320. if !m.op.Is(OpUpdateOne) {
  18321. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18322. }
  18323. if m.id == nil || m.oldValue == nil {
  18324. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18325. }
  18326. oldValue, err := m.oldValue(ctx)
  18327. if err != nil {
  18328. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18329. }
  18330. return oldValue.ActionLabelAdd, nil
  18331. }
  18332. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18333. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  18334. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18335. }
  18336. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18337. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18338. if len(m.appendaction_label_add) == 0 {
  18339. return nil, false
  18340. }
  18341. return m.appendaction_label_add, true
  18342. }
  18343. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18344. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  18345. m.action_label_add = nil
  18346. m.appendaction_label_add = nil
  18347. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  18348. }
  18349. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18350. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  18351. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  18352. return ok
  18353. }
  18354. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18355. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  18356. m.action_label_add = nil
  18357. m.appendaction_label_add = nil
  18358. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  18359. }
  18360. // SetActionLabelDel sets the "action_label_del" field.
  18361. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  18362. m.action_label_del = &u
  18363. m.appendaction_label_del = nil
  18364. }
  18365. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18366. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18367. v := m.action_label_del
  18368. if v == nil {
  18369. return
  18370. }
  18371. return *v, true
  18372. }
  18373. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18374. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18376. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18377. if !m.op.Is(OpUpdateOne) {
  18378. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18379. }
  18380. if m.id == nil || m.oldValue == nil {
  18381. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18382. }
  18383. oldValue, err := m.oldValue(ctx)
  18384. if err != nil {
  18385. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18386. }
  18387. return oldValue.ActionLabelDel, nil
  18388. }
  18389. // AppendActionLabelDel adds u to the "action_label_del" field.
  18390. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18391. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18392. }
  18393. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18394. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18395. if len(m.appendaction_label_del) == 0 {
  18396. return nil, false
  18397. }
  18398. return m.appendaction_label_del, true
  18399. }
  18400. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18401. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18402. m.action_label_del = nil
  18403. m.appendaction_label_del = nil
  18404. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18405. }
  18406. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18407. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18408. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18409. return ok
  18410. }
  18411. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18412. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18413. m.action_label_del = nil
  18414. m.appendaction_label_del = nil
  18415. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18416. }
  18417. // Where appends a list predicates to the LabelTaggingMutation builder.
  18418. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18419. m.predicates = append(m.predicates, ps...)
  18420. }
  18421. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18422. // users can use type-assertion to append predicates that do not depend on any generated package.
  18423. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18424. p := make([]predicate.LabelTagging, len(ps))
  18425. for i := range ps {
  18426. p[i] = ps[i]
  18427. }
  18428. m.Where(p...)
  18429. }
  18430. // Op returns the operation name.
  18431. func (m *LabelTaggingMutation) Op() Op {
  18432. return m.op
  18433. }
  18434. // SetOp allows setting the mutation operation.
  18435. func (m *LabelTaggingMutation) SetOp(op Op) {
  18436. m.op = op
  18437. }
  18438. // Type returns the node type of this mutation (LabelTagging).
  18439. func (m *LabelTaggingMutation) Type() string {
  18440. return m.typ
  18441. }
  18442. // Fields returns all fields that were changed during this mutation. Note that in
  18443. // order to get all numeric fields that were incremented/decremented, call
  18444. // AddedFields().
  18445. func (m *LabelTaggingMutation) Fields() []string {
  18446. fields := make([]string, 0, 9)
  18447. if m.created_at != nil {
  18448. fields = append(fields, labeltagging.FieldCreatedAt)
  18449. }
  18450. if m.updated_at != nil {
  18451. fields = append(fields, labeltagging.FieldUpdatedAt)
  18452. }
  18453. if m.status != nil {
  18454. fields = append(fields, labeltagging.FieldStatus)
  18455. }
  18456. if m.deleted_at != nil {
  18457. fields = append(fields, labeltagging.FieldDeletedAt)
  18458. }
  18459. if m.organization_id != nil {
  18460. fields = append(fields, labeltagging.FieldOrganizationID)
  18461. }
  18462. if m._type != nil {
  18463. fields = append(fields, labeltagging.FieldType)
  18464. }
  18465. if m.conditions != nil {
  18466. fields = append(fields, labeltagging.FieldConditions)
  18467. }
  18468. if m.action_label_add != nil {
  18469. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18470. }
  18471. if m.action_label_del != nil {
  18472. fields = append(fields, labeltagging.FieldActionLabelDel)
  18473. }
  18474. return fields
  18475. }
  18476. // Field returns the value of a field with the given name. The second boolean
  18477. // return value indicates that this field was not set, or was not defined in the
  18478. // schema.
  18479. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18480. switch name {
  18481. case labeltagging.FieldCreatedAt:
  18482. return m.CreatedAt()
  18483. case labeltagging.FieldUpdatedAt:
  18484. return m.UpdatedAt()
  18485. case labeltagging.FieldStatus:
  18486. return m.Status()
  18487. case labeltagging.FieldDeletedAt:
  18488. return m.DeletedAt()
  18489. case labeltagging.FieldOrganizationID:
  18490. return m.OrganizationID()
  18491. case labeltagging.FieldType:
  18492. return m.GetType()
  18493. case labeltagging.FieldConditions:
  18494. return m.Conditions()
  18495. case labeltagging.FieldActionLabelAdd:
  18496. return m.ActionLabelAdd()
  18497. case labeltagging.FieldActionLabelDel:
  18498. return m.ActionLabelDel()
  18499. }
  18500. return nil, false
  18501. }
  18502. // OldField returns the old value of the field from the database. An error is
  18503. // returned if the mutation operation is not UpdateOne, or the query to the
  18504. // database failed.
  18505. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18506. switch name {
  18507. case labeltagging.FieldCreatedAt:
  18508. return m.OldCreatedAt(ctx)
  18509. case labeltagging.FieldUpdatedAt:
  18510. return m.OldUpdatedAt(ctx)
  18511. case labeltagging.FieldStatus:
  18512. return m.OldStatus(ctx)
  18513. case labeltagging.FieldDeletedAt:
  18514. return m.OldDeletedAt(ctx)
  18515. case labeltagging.FieldOrganizationID:
  18516. return m.OldOrganizationID(ctx)
  18517. case labeltagging.FieldType:
  18518. return m.OldType(ctx)
  18519. case labeltagging.FieldConditions:
  18520. return m.OldConditions(ctx)
  18521. case labeltagging.FieldActionLabelAdd:
  18522. return m.OldActionLabelAdd(ctx)
  18523. case labeltagging.FieldActionLabelDel:
  18524. return m.OldActionLabelDel(ctx)
  18525. }
  18526. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18527. }
  18528. // SetField sets the value of a field with the given name. It returns an error if
  18529. // the field is not defined in the schema, or if the type mismatched the field
  18530. // type.
  18531. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18532. switch name {
  18533. case labeltagging.FieldCreatedAt:
  18534. v, ok := value.(time.Time)
  18535. if !ok {
  18536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18537. }
  18538. m.SetCreatedAt(v)
  18539. return nil
  18540. case labeltagging.FieldUpdatedAt:
  18541. v, ok := value.(time.Time)
  18542. if !ok {
  18543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18544. }
  18545. m.SetUpdatedAt(v)
  18546. return nil
  18547. case labeltagging.FieldStatus:
  18548. v, ok := value.(uint8)
  18549. if !ok {
  18550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18551. }
  18552. m.SetStatus(v)
  18553. return nil
  18554. case labeltagging.FieldDeletedAt:
  18555. v, ok := value.(time.Time)
  18556. if !ok {
  18557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18558. }
  18559. m.SetDeletedAt(v)
  18560. return nil
  18561. case labeltagging.FieldOrganizationID:
  18562. v, ok := value.(uint64)
  18563. if !ok {
  18564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18565. }
  18566. m.SetOrganizationID(v)
  18567. return nil
  18568. case labeltagging.FieldType:
  18569. v, ok := value.(int)
  18570. if !ok {
  18571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18572. }
  18573. m.SetType(v)
  18574. return nil
  18575. case labeltagging.FieldConditions:
  18576. v, ok := value.(string)
  18577. if !ok {
  18578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18579. }
  18580. m.SetConditions(v)
  18581. return nil
  18582. case labeltagging.FieldActionLabelAdd:
  18583. v, ok := value.([]uint64)
  18584. if !ok {
  18585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18586. }
  18587. m.SetActionLabelAdd(v)
  18588. return nil
  18589. case labeltagging.FieldActionLabelDel:
  18590. v, ok := value.([]uint64)
  18591. if !ok {
  18592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18593. }
  18594. m.SetActionLabelDel(v)
  18595. return nil
  18596. }
  18597. return fmt.Errorf("unknown LabelTagging field %s", name)
  18598. }
  18599. // AddedFields returns all numeric fields that were incremented/decremented during
  18600. // this mutation.
  18601. func (m *LabelTaggingMutation) AddedFields() []string {
  18602. var fields []string
  18603. if m.addstatus != nil {
  18604. fields = append(fields, labeltagging.FieldStatus)
  18605. }
  18606. if m.addorganization_id != nil {
  18607. fields = append(fields, labeltagging.FieldOrganizationID)
  18608. }
  18609. if m.add_type != nil {
  18610. fields = append(fields, labeltagging.FieldType)
  18611. }
  18612. return fields
  18613. }
  18614. // AddedField returns the numeric value that was incremented/decremented on a field
  18615. // with the given name. The second boolean return value indicates that this field
  18616. // was not set, or was not defined in the schema.
  18617. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18618. switch name {
  18619. case labeltagging.FieldStatus:
  18620. return m.AddedStatus()
  18621. case labeltagging.FieldOrganizationID:
  18622. return m.AddedOrganizationID()
  18623. case labeltagging.FieldType:
  18624. return m.AddedType()
  18625. }
  18626. return nil, false
  18627. }
  18628. // AddField adds the value to the field with the given name. It returns an error if
  18629. // the field is not defined in the schema, or if the type mismatched the field
  18630. // type.
  18631. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18632. switch name {
  18633. case labeltagging.FieldStatus:
  18634. v, ok := value.(int8)
  18635. if !ok {
  18636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18637. }
  18638. m.AddStatus(v)
  18639. return nil
  18640. case labeltagging.FieldOrganizationID:
  18641. v, ok := value.(int64)
  18642. if !ok {
  18643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18644. }
  18645. m.AddOrganizationID(v)
  18646. return nil
  18647. case labeltagging.FieldType:
  18648. v, ok := value.(int)
  18649. if !ok {
  18650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18651. }
  18652. m.AddType(v)
  18653. return nil
  18654. }
  18655. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18656. }
  18657. // ClearedFields returns all nullable fields that were cleared during this
  18658. // mutation.
  18659. func (m *LabelTaggingMutation) ClearedFields() []string {
  18660. var fields []string
  18661. if m.FieldCleared(labeltagging.FieldStatus) {
  18662. fields = append(fields, labeltagging.FieldStatus)
  18663. }
  18664. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18665. fields = append(fields, labeltagging.FieldDeletedAt)
  18666. }
  18667. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18668. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18669. }
  18670. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18671. fields = append(fields, labeltagging.FieldActionLabelDel)
  18672. }
  18673. return fields
  18674. }
  18675. // FieldCleared returns a boolean indicating if a field with the given name was
  18676. // cleared in this mutation.
  18677. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18678. _, ok := m.clearedFields[name]
  18679. return ok
  18680. }
  18681. // ClearField clears the value of the field with the given name. It returns an
  18682. // error if the field is not defined in the schema.
  18683. func (m *LabelTaggingMutation) ClearField(name string) error {
  18684. switch name {
  18685. case labeltagging.FieldStatus:
  18686. m.ClearStatus()
  18687. return nil
  18688. case labeltagging.FieldDeletedAt:
  18689. m.ClearDeletedAt()
  18690. return nil
  18691. case labeltagging.FieldActionLabelAdd:
  18692. m.ClearActionLabelAdd()
  18693. return nil
  18694. case labeltagging.FieldActionLabelDel:
  18695. m.ClearActionLabelDel()
  18696. return nil
  18697. }
  18698. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18699. }
  18700. // ResetField resets all changes in the mutation for the field with the given name.
  18701. // It returns an error if the field is not defined in the schema.
  18702. func (m *LabelTaggingMutation) ResetField(name string) error {
  18703. switch name {
  18704. case labeltagging.FieldCreatedAt:
  18705. m.ResetCreatedAt()
  18706. return nil
  18707. case labeltagging.FieldUpdatedAt:
  18708. m.ResetUpdatedAt()
  18709. return nil
  18710. case labeltagging.FieldStatus:
  18711. m.ResetStatus()
  18712. return nil
  18713. case labeltagging.FieldDeletedAt:
  18714. m.ResetDeletedAt()
  18715. return nil
  18716. case labeltagging.FieldOrganizationID:
  18717. m.ResetOrganizationID()
  18718. return nil
  18719. case labeltagging.FieldType:
  18720. m.ResetType()
  18721. return nil
  18722. case labeltagging.FieldConditions:
  18723. m.ResetConditions()
  18724. return nil
  18725. case labeltagging.FieldActionLabelAdd:
  18726. m.ResetActionLabelAdd()
  18727. return nil
  18728. case labeltagging.FieldActionLabelDel:
  18729. m.ResetActionLabelDel()
  18730. return nil
  18731. }
  18732. return fmt.Errorf("unknown LabelTagging field %s", name)
  18733. }
  18734. // AddedEdges returns all edge names that were set/added in this mutation.
  18735. func (m *LabelTaggingMutation) AddedEdges() []string {
  18736. edges := make([]string, 0, 0)
  18737. return edges
  18738. }
  18739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18740. // name in this mutation.
  18741. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18742. return nil
  18743. }
  18744. // RemovedEdges returns all edge names that were removed in this mutation.
  18745. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18746. edges := make([]string, 0, 0)
  18747. return edges
  18748. }
  18749. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18750. // the given name in this mutation.
  18751. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18752. return nil
  18753. }
  18754. // ClearedEdges returns all edge names that were cleared in this mutation.
  18755. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18756. edges := make([]string, 0, 0)
  18757. return edges
  18758. }
  18759. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18760. // was cleared in this mutation.
  18761. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18762. return false
  18763. }
  18764. // ClearEdge clears the value of the edge with the given name. It returns an error
  18765. // if that edge is not defined in the schema.
  18766. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18767. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18768. }
  18769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18770. // It returns an error if the edge is not defined in the schema.
  18771. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18772. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18773. }
  18774. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18775. type MessageMutation struct {
  18776. config
  18777. op Op
  18778. typ string
  18779. id *int
  18780. wx_wxid *string
  18781. wxid *string
  18782. content *string
  18783. clearedFields map[string]struct{}
  18784. done bool
  18785. oldValue func(context.Context) (*Message, error)
  18786. predicates []predicate.Message
  18787. }
  18788. var _ ent.Mutation = (*MessageMutation)(nil)
  18789. // messageOption allows management of the mutation configuration using functional options.
  18790. type messageOption func(*MessageMutation)
  18791. // newMessageMutation creates new mutation for the Message entity.
  18792. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18793. m := &MessageMutation{
  18794. config: c,
  18795. op: op,
  18796. typ: TypeMessage,
  18797. clearedFields: make(map[string]struct{}),
  18798. }
  18799. for _, opt := range opts {
  18800. opt(m)
  18801. }
  18802. return m
  18803. }
  18804. // withMessageID sets the ID field of the mutation.
  18805. func withMessageID(id int) messageOption {
  18806. return func(m *MessageMutation) {
  18807. var (
  18808. err error
  18809. once sync.Once
  18810. value *Message
  18811. )
  18812. m.oldValue = func(ctx context.Context) (*Message, error) {
  18813. once.Do(func() {
  18814. if m.done {
  18815. err = errors.New("querying old values post mutation is not allowed")
  18816. } else {
  18817. value, err = m.Client().Message.Get(ctx, id)
  18818. }
  18819. })
  18820. return value, err
  18821. }
  18822. m.id = &id
  18823. }
  18824. }
  18825. // withMessage sets the old Message of the mutation.
  18826. func withMessage(node *Message) messageOption {
  18827. return func(m *MessageMutation) {
  18828. m.oldValue = func(context.Context) (*Message, error) {
  18829. return node, nil
  18830. }
  18831. m.id = &node.ID
  18832. }
  18833. }
  18834. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18835. // executed in a transaction (ent.Tx), a transactional client is returned.
  18836. func (m MessageMutation) Client() *Client {
  18837. client := &Client{config: m.config}
  18838. client.init()
  18839. return client
  18840. }
  18841. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18842. // it returns an error otherwise.
  18843. func (m MessageMutation) Tx() (*Tx, error) {
  18844. if _, ok := m.driver.(*txDriver); !ok {
  18845. return nil, errors.New("ent: mutation is not running in a transaction")
  18846. }
  18847. tx := &Tx{config: m.config}
  18848. tx.init()
  18849. return tx, nil
  18850. }
  18851. // ID returns the ID value in the mutation. Note that the ID is only available
  18852. // if it was provided to the builder or after it was returned from the database.
  18853. func (m *MessageMutation) ID() (id int, exists bool) {
  18854. if m.id == nil {
  18855. return
  18856. }
  18857. return *m.id, true
  18858. }
  18859. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18860. // That means, if the mutation is applied within a transaction with an isolation level such
  18861. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18862. // or updated by the mutation.
  18863. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18864. switch {
  18865. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18866. id, exists := m.ID()
  18867. if exists {
  18868. return []int{id}, nil
  18869. }
  18870. fallthrough
  18871. case m.op.Is(OpUpdate | OpDelete):
  18872. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18873. default:
  18874. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18875. }
  18876. }
  18877. // SetWxWxid sets the "wx_wxid" field.
  18878. func (m *MessageMutation) SetWxWxid(s string) {
  18879. m.wx_wxid = &s
  18880. }
  18881. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18882. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18883. v := m.wx_wxid
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18890. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18892. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18893. if !m.op.Is(OpUpdateOne) {
  18894. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18895. }
  18896. if m.id == nil || m.oldValue == nil {
  18897. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18898. }
  18899. oldValue, err := m.oldValue(ctx)
  18900. if err != nil {
  18901. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18902. }
  18903. return oldValue.WxWxid, nil
  18904. }
  18905. // ClearWxWxid clears the value of the "wx_wxid" field.
  18906. func (m *MessageMutation) ClearWxWxid() {
  18907. m.wx_wxid = nil
  18908. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18909. }
  18910. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18911. func (m *MessageMutation) WxWxidCleared() bool {
  18912. _, ok := m.clearedFields[message.FieldWxWxid]
  18913. return ok
  18914. }
  18915. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18916. func (m *MessageMutation) ResetWxWxid() {
  18917. m.wx_wxid = nil
  18918. delete(m.clearedFields, message.FieldWxWxid)
  18919. }
  18920. // SetWxid sets the "wxid" field.
  18921. func (m *MessageMutation) SetWxid(s string) {
  18922. m.wxid = &s
  18923. }
  18924. // Wxid returns the value of the "wxid" field in the mutation.
  18925. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18926. v := m.wxid
  18927. if v == nil {
  18928. return
  18929. }
  18930. return *v, true
  18931. }
  18932. // OldWxid returns the old "wxid" field's value of the Message entity.
  18933. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18935. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18936. if !m.op.Is(OpUpdateOne) {
  18937. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18938. }
  18939. if m.id == nil || m.oldValue == nil {
  18940. return v, errors.New("OldWxid requires an ID field in the mutation")
  18941. }
  18942. oldValue, err := m.oldValue(ctx)
  18943. if err != nil {
  18944. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18945. }
  18946. return oldValue.Wxid, nil
  18947. }
  18948. // ResetWxid resets all changes to the "wxid" field.
  18949. func (m *MessageMutation) ResetWxid() {
  18950. m.wxid = nil
  18951. }
  18952. // SetContent sets the "content" field.
  18953. func (m *MessageMutation) SetContent(s string) {
  18954. m.content = &s
  18955. }
  18956. // Content returns the value of the "content" field in the mutation.
  18957. func (m *MessageMutation) Content() (r string, exists bool) {
  18958. v := m.content
  18959. if v == nil {
  18960. return
  18961. }
  18962. return *v, true
  18963. }
  18964. // OldContent returns the old "content" field's value of the Message entity.
  18965. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18967. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18968. if !m.op.Is(OpUpdateOne) {
  18969. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18970. }
  18971. if m.id == nil || m.oldValue == nil {
  18972. return v, errors.New("OldContent requires an ID field in the mutation")
  18973. }
  18974. oldValue, err := m.oldValue(ctx)
  18975. if err != nil {
  18976. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18977. }
  18978. return oldValue.Content, nil
  18979. }
  18980. // ResetContent resets all changes to the "content" field.
  18981. func (m *MessageMutation) ResetContent() {
  18982. m.content = nil
  18983. }
  18984. // Where appends a list predicates to the MessageMutation builder.
  18985. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18986. m.predicates = append(m.predicates, ps...)
  18987. }
  18988. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18989. // users can use type-assertion to append predicates that do not depend on any generated package.
  18990. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18991. p := make([]predicate.Message, len(ps))
  18992. for i := range ps {
  18993. p[i] = ps[i]
  18994. }
  18995. m.Where(p...)
  18996. }
  18997. // Op returns the operation name.
  18998. func (m *MessageMutation) Op() Op {
  18999. return m.op
  19000. }
  19001. // SetOp allows setting the mutation operation.
  19002. func (m *MessageMutation) SetOp(op Op) {
  19003. m.op = op
  19004. }
  19005. // Type returns the node type of this mutation (Message).
  19006. func (m *MessageMutation) Type() string {
  19007. return m.typ
  19008. }
  19009. // Fields returns all fields that were changed during this mutation. Note that in
  19010. // order to get all numeric fields that were incremented/decremented, call
  19011. // AddedFields().
  19012. func (m *MessageMutation) Fields() []string {
  19013. fields := make([]string, 0, 3)
  19014. if m.wx_wxid != nil {
  19015. fields = append(fields, message.FieldWxWxid)
  19016. }
  19017. if m.wxid != nil {
  19018. fields = append(fields, message.FieldWxid)
  19019. }
  19020. if m.content != nil {
  19021. fields = append(fields, message.FieldContent)
  19022. }
  19023. return fields
  19024. }
  19025. // Field returns the value of a field with the given name. The second boolean
  19026. // return value indicates that this field was not set, or was not defined in the
  19027. // schema.
  19028. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  19029. switch name {
  19030. case message.FieldWxWxid:
  19031. return m.WxWxid()
  19032. case message.FieldWxid:
  19033. return m.Wxid()
  19034. case message.FieldContent:
  19035. return m.Content()
  19036. }
  19037. return nil, false
  19038. }
  19039. // OldField returns the old value of the field from the database. An error is
  19040. // returned if the mutation operation is not UpdateOne, or the query to the
  19041. // database failed.
  19042. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19043. switch name {
  19044. case message.FieldWxWxid:
  19045. return m.OldWxWxid(ctx)
  19046. case message.FieldWxid:
  19047. return m.OldWxid(ctx)
  19048. case message.FieldContent:
  19049. return m.OldContent(ctx)
  19050. }
  19051. return nil, fmt.Errorf("unknown Message field %s", name)
  19052. }
  19053. // SetField sets the value of a field with the given name. It returns an error if
  19054. // the field is not defined in the schema, or if the type mismatched the field
  19055. // type.
  19056. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  19057. switch name {
  19058. case message.FieldWxWxid:
  19059. v, ok := value.(string)
  19060. if !ok {
  19061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19062. }
  19063. m.SetWxWxid(v)
  19064. return nil
  19065. case message.FieldWxid:
  19066. v, ok := value.(string)
  19067. if !ok {
  19068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19069. }
  19070. m.SetWxid(v)
  19071. return nil
  19072. case message.FieldContent:
  19073. v, ok := value.(string)
  19074. if !ok {
  19075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19076. }
  19077. m.SetContent(v)
  19078. return nil
  19079. }
  19080. return fmt.Errorf("unknown Message field %s", name)
  19081. }
  19082. // AddedFields returns all numeric fields that were incremented/decremented during
  19083. // this mutation.
  19084. func (m *MessageMutation) AddedFields() []string {
  19085. return nil
  19086. }
  19087. // AddedField returns the numeric value that was incremented/decremented on a field
  19088. // with the given name. The second boolean return value indicates that this field
  19089. // was not set, or was not defined in the schema.
  19090. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  19091. return nil, false
  19092. }
  19093. // AddField adds the value to the field with the given name. It returns an error if
  19094. // the field is not defined in the schema, or if the type mismatched the field
  19095. // type.
  19096. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  19097. switch name {
  19098. }
  19099. return fmt.Errorf("unknown Message numeric field %s", name)
  19100. }
  19101. // ClearedFields returns all nullable fields that were cleared during this
  19102. // mutation.
  19103. func (m *MessageMutation) ClearedFields() []string {
  19104. var fields []string
  19105. if m.FieldCleared(message.FieldWxWxid) {
  19106. fields = append(fields, message.FieldWxWxid)
  19107. }
  19108. return fields
  19109. }
  19110. // FieldCleared returns a boolean indicating if a field with the given name was
  19111. // cleared in this mutation.
  19112. func (m *MessageMutation) FieldCleared(name string) bool {
  19113. _, ok := m.clearedFields[name]
  19114. return ok
  19115. }
  19116. // ClearField clears the value of the field with the given name. It returns an
  19117. // error if the field is not defined in the schema.
  19118. func (m *MessageMutation) ClearField(name string) error {
  19119. switch name {
  19120. case message.FieldWxWxid:
  19121. m.ClearWxWxid()
  19122. return nil
  19123. }
  19124. return fmt.Errorf("unknown Message nullable field %s", name)
  19125. }
  19126. // ResetField resets all changes in the mutation for the field with the given name.
  19127. // It returns an error if the field is not defined in the schema.
  19128. func (m *MessageMutation) ResetField(name string) error {
  19129. switch name {
  19130. case message.FieldWxWxid:
  19131. m.ResetWxWxid()
  19132. return nil
  19133. case message.FieldWxid:
  19134. m.ResetWxid()
  19135. return nil
  19136. case message.FieldContent:
  19137. m.ResetContent()
  19138. return nil
  19139. }
  19140. return fmt.Errorf("unknown Message field %s", name)
  19141. }
  19142. // AddedEdges returns all edge names that were set/added in this mutation.
  19143. func (m *MessageMutation) AddedEdges() []string {
  19144. edges := make([]string, 0, 0)
  19145. return edges
  19146. }
  19147. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19148. // name in this mutation.
  19149. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  19150. return nil
  19151. }
  19152. // RemovedEdges returns all edge names that were removed in this mutation.
  19153. func (m *MessageMutation) RemovedEdges() []string {
  19154. edges := make([]string, 0, 0)
  19155. return edges
  19156. }
  19157. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19158. // the given name in this mutation.
  19159. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  19160. return nil
  19161. }
  19162. // ClearedEdges returns all edge names that were cleared in this mutation.
  19163. func (m *MessageMutation) ClearedEdges() []string {
  19164. edges := make([]string, 0, 0)
  19165. return edges
  19166. }
  19167. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19168. // was cleared in this mutation.
  19169. func (m *MessageMutation) EdgeCleared(name string) bool {
  19170. return false
  19171. }
  19172. // ClearEdge clears the value of the edge with the given name. It returns an error
  19173. // if that edge is not defined in the schema.
  19174. func (m *MessageMutation) ClearEdge(name string) error {
  19175. return fmt.Errorf("unknown Message unique edge %s", name)
  19176. }
  19177. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19178. // It returns an error if the edge is not defined in the schema.
  19179. func (m *MessageMutation) ResetEdge(name string) error {
  19180. return fmt.Errorf("unknown Message edge %s", name)
  19181. }
  19182. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  19183. type MessageRecordsMutation struct {
  19184. config
  19185. op Op
  19186. typ string
  19187. id *uint64
  19188. created_at *time.Time
  19189. updated_at *time.Time
  19190. status *uint8
  19191. addstatus *int8
  19192. bot_wxid *string
  19193. contact_type *int
  19194. addcontact_type *int
  19195. contact_wxid *string
  19196. content_type *int
  19197. addcontent_type *int
  19198. content *string
  19199. meta *custom_types.Meta
  19200. error_detail *string
  19201. send_time *time.Time
  19202. source_type *int
  19203. addsource_type *int
  19204. organization_id *uint64
  19205. addorganization_id *int64
  19206. clearedFields map[string]struct{}
  19207. sop_stage *uint64
  19208. clearedsop_stage bool
  19209. sop_node *uint64
  19210. clearedsop_node bool
  19211. message_contact *uint64
  19212. clearedmessage_contact bool
  19213. done bool
  19214. oldValue func(context.Context) (*MessageRecords, error)
  19215. predicates []predicate.MessageRecords
  19216. }
  19217. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  19218. // messagerecordsOption allows management of the mutation configuration using functional options.
  19219. type messagerecordsOption func(*MessageRecordsMutation)
  19220. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  19221. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  19222. m := &MessageRecordsMutation{
  19223. config: c,
  19224. op: op,
  19225. typ: TypeMessageRecords,
  19226. clearedFields: make(map[string]struct{}),
  19227. }
  19228. for _, opt := range opts {
  19229. opt(m)
  19230. }
  19231. return m
  19232. }
  19233. // withMessageRecordsID sets the ID field of the mutation.
  19234. func withMessageRecordsID(id uint64) messagerecordsOption {
  19235. return func(m *MessageRecordsMutation) {
  19236. var (
  19237. err error
  19238. once sync.Once
  19239. value *MessageRecords
  19240. )
  19241. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  19242. once.Do(func() {
  19243. if m.done {
  19244. err = errors.New("querying old values post mutation is not allowed")
  19245. } else {
  19246. value, err = m.Client().MessageRecords.Get(ctx, id)
  19247. }
  19248. })
  19249. return value, err
  19250. }
  19251. m.id = &id
  19252. }
  19253. }
  19254. // withMessageRecords sets the old MessageRecords of the mutation.
  19255. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  19256. return func(m *MessageRecordsMutation) {
  19257. m.oldValue = func(context.Context) (*MessageRecords, error) {
  19258. return node, nil
  19259. }
  19260. m.id = &node.ID
  19261. }
  19262. }
  19263. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19264. // executed in a transaction (ent.Tx), a transactional client is returned.
  19265. func (m MessageRecordsMutation) Client() *Client {
  19266. client := &Client{config: m.config}
  19267. client.init()
  19268. return client
  19269. }
  19270. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19271. // it returns an error otherwise.
  19272. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  19273. if _, ok := m.driver.(*txDriver); !ok {
  19274. return nil, errors.New("ent: mutation is not running in a transaction")
  19275. }
  19276. tx := &Tx{config: m.config}
  19277. tx.init()
  19278. return tx, nil
  19279. }
  19280. // SetID sets the value of the id field. Note that this
  19281. // operation is only accepted on creation of MessageRecords entities.
  19282. func (m *MessageRecordsMutation) SetID(id uint64) {
  19283. m.id = &id
  19284. }
  19285. // ID returns the ID value in the mutation. Note that the ID is only available
  19286. // if it was provided to the builder or after it was returned from the database.
  19287. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19288. if m.id == nil {
  19289. return
  19290. }
  19291. return *m.id, true
  19292. }
  19293. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19294. // That means, if the mutation is applied within a transaction with an isolation level such
  19295. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19296. // or updated by the mutation.
  19297. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  19298. switch {
  19299. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19300. id, exists := m.ID()
  19301. if exists {
  19302. return []uint64{id}, nil
  19303. }
  19304. fallthrough
  19305. case m.op.Is(OpUpdate | OpDelete):
  19306. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  19307. default:
  19308. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19309. }
  19310. }
  19311. // SetCreatedAt sets the "created_at" field.
  19312. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  19313. m.created_at = &t
  19314. }
  19315. // CreatedAt returns the value of the "created_at" field in the mutation.
  19316. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  19317. v := m.created_at
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  19324. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19326. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19327. if !m.op.Is(OpUpdateOne) {
  19328. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19329. }
  19330. if m.id == nil || m.oldValue == nil {
  19331. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19332. }
  19333. oldValue, err := m.oldValue(ctx)
  19334. if err != nil {
  19335. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19336. }
  19337. return oldValue.CreatedAt, nil
  19338. }
  19339. // ResetCreatedAt resets all changes to the "created_at" field.
  19340. func (m *MessageRecordsMutation) ResetCreatedAt() {
  19341. m.created_at = nil
  19342. }
  19343. // SetUpdatedAt sets the "updated_at" field.
  19344. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  19345. m.updated_at = &t
  19346. }
  19347. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19348. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  19349. v := m.updated_at
  19350. if v == nil {
  19351. return
  19352. }
  19353. return *v, true
  19354. }
  19355. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  19356. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19358. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19359. if !m.op.Is(OpUpdateOne) {
  19360. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19361. }
  19362. if m.id == nil || m.oldValue == nil {
  19363. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19364. }
  19365. oldValue, err := m.oldValue(ctx)
  19366. if err != nil {
  19367. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19368. }
  19369. return oldValue.UpdatedAt, nil
  19370. }
  19371. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19372. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19373. m.updated_at = nil
  19374. }
  19375. // SetStatus sets the "status" field.
  19376. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19377. m.status = &u
  19378. m.addstatus = nil
  19379. }
  19380. // Status returns the value of the "status" field in the mutation.
  19381. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19382. v := m.status
  19383. if v == nil {
  19384. return
  19385. }
  19386. return *v, true
  19387. }
  19388. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19389. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19391. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19392. if !m.op.Is(OpUpdateOne) {
  19393. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19394. }
  19395. if m.id == nil || m.oldValue == nil {
  19396. return v, errors.New("OldStatus requires an ID field in the mutation")
  19397. }
  19398. oldValue, err := m.oldValue(ctx)
  19399. if err != nil {
  19400. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19401. }
  19402. return oldValue.Status, nil
  19403. }
  19404. // AddStatus adds u to the "status" field.
  19405. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19406. if m.addstatus != nil {
  19407. *m.addstatus += u
  19408. } else {
  19409. m.addstatus = &u
  19410. }
  19411. }
  19412. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19413. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19414. v := m.addstatus
  19415. if v == nil {
  19416. return
  19417. }
  19418. return *v, true
  19419. }
  19420. // ClearStatus clears the value of the "status" field.
  19421. func (m *MessageRecordsMutation) ClearStatus() {
  19422. m.status = nil
  19423. m.addstatus = nil
  19424. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19425. }
  19426. // StatusCleared returns if the "status" field was cleared in this mutation.
  19427. func (m *MessageRecordsMutation) StatusCleared() bool {
  19428. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19429. return ok
  19430. }
  19431. // ResetStatus resets all changes to the "status" field.
  19432. func (m *MessageRecordsMutation) ResetStatus() {
  19433. m.status = nil
  19434. m.addstatus = nil
  19435. delete(m.clearedFields, messagerecords.FieldStatus)
  19436. }
  19437. // SetBotWxid sets the "bot_wxid" field.
  19438. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19439. m.bot_wxid = &s
  19440. }
  19441. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19442. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19443. v := m.bot_wxid
  19444. if v == nil {
  19445. return
  19446. }
  19447. return *v, true
  19448. }
  19449. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19450. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19452. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19453. if !m.op.Is(OpUpdateOne) {
  19454. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19455. }
  19456. if m.id == nil || m.oldValue == nil {
  19457. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19458. }
  19459. oldValue, err := m.oldValue(ctx)
  19460. if err != nil {
  19461. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19462. }
  19463. return oldValue.BotWxid, nil
  19464. }
  19465. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19466. func (m *MessageRecordsMutation) ResetBotWxid() {
  19467. m.bot_wxid = nil
  19468. }
  19469. // SetContactID sets the "contact_id" field.
  19470. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19471. m.message_contact = &u
  19472. }
  19473. // ContactID returns the value of the "contact_id" field in the mutation.
  19474. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19475. v := m.message_contact
  19476. if v == nil {
  19477. return
  19478. }
  19479. return *v, true
  19480. }
  19481. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19482. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19484. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19485. if !m.op.Is(OpUpdateOne) {
  19486. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19487. }
  19488. if m.id == nil || m.oldValue == nil {
  19489. return v, errors.New("OldContactID requires an ID field in the mutation")
  19490. }
  19491. oldValue, err := m.oldValue(ctx)
  19492. if err != nil {
  19493. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19494. }
  19495. return oldValue.ContactID, nil
  19496. }
  19497. // ClearContactID clears the value of the "contact_id" field.
  19498. func (m *MessageRecordsMutation) ClearContactID() {
  19499. m.message_contact = nil
  19500. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19501. }
  19502. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19503. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19504. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19505. return ok
  19506. }
  19507. // ResetContactID resets all changes to the "contact_id" field.
  19508. func (m *MessageRecordsMutation) ResetContactID() {
  19509. m.message_contact = nil
  19510. delete(m.clearedFields, messagerecords.FieldContactID)
  19511. }
  19512. // SetContactType sets the "contact_type" field.
  19513. func (m *MessageRecordsMutation) SetContactType(i int) {
  19514. m.contact_type = &i
  19515. m.addcontact_type = nil
  19516. }
  19517. // ContactType returns the value of the "contact_type" field in the mutation.
  19518. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19519. v := m.contact_type
  19520. if v == nil {
  19521. return
  19522. }
  19523. return *v, true
  19524. }
  19525. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19526. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19528. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19529. if !m.op.Is(OpUpdateOne) {
  19530. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19531. }
  19532. if m.id == nil || m.oldValue == nil {
  19533. return v, errors.New("OldContactType requires an ID field in the mutation")
  19534. }
  19535. oldValue, err := m.oldValue(ctx)
  19536. if err != nil {
  19537. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19538. }
  19539. return oldValue.ContactType, nil
  19540. }
  19541. // AddContactType adds i to the "contact_type" field.
  19542. func (m *MessageRecordsMutation) AddContactType(i int) {
  19543. if m.addcontact_type != nil {
  19544. *m.addcontact_type += i
  19545. } else {
  19546. m.addcontact_type = &i
  19547. }
  19548. }
  19549. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19550. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19551. v := m.addcontact_type
  19552. if v == nil {
  19553. return
  19554. }
  19555. return *v, true
  19556. }
  19557. // ResetContactType resets all changes to the "contact_type" field.
  19558. func (m *MessageRecordsMutation) ResetContactType() {
  19559. m.contact_type = nil
  19560. m.addcontact_type = nil
  19561. }
  19562. // SetContactWxid sets the "contact_wxid" field.
  19563. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19564. m.contact_wxid = &s
  19565. }
  19566. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19567. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19568. v := m.contact_wxid
  19569. if v == nil {
  19570. return
  19571. }
  19572. return *v, true
  19573. }
  19574. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19575. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19577. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19578. if !m.op.Is(OpUpdateOne) {
  19579. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19580. }
  19581. if m.id == nil || m.oldValue == nil {
  19582. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19583. }
  19584. oldValue, err := m.oldValue(ctx)
  19585. if err != nil {
  19586. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19587. }
  19588. return oldValue.ContactWxid, nil
  19589. }
  19590. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19591. func (m *MessageRecordsMutation) ResetContactWxid() {
  19592. m.contact_wxid = nil
  19593. }
  19594. // SetContentType sets the "content_type" field.
  19595. func (m *MessageRecordsMutation) SetContentType(i int) {
  19596. m.content_type = &i
  19597. m.addcontent_type = nil
  19598. }
  19599. // ContentType returns the value of the "content_type" field in the mutation.
  19600. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19601. v := m.content_type
  19602. if v == nil {
  19603. return
  19604. }
  19605. return *v, true
  19606. }
  19607. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19608. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19610. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19611. if !m.op.Is(OpUpdateOne) {
  19612. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19613. }
  19614. if m.id == nil || m.oldValue == nil {
  19615. return v, errors.New("OldContentType requires an ID field in the mutation")
  19616. }
  19617. oldValue, err := m.oldValue(ctx)
  19618. if err != nil {
  19619. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19620. }
  19621. return oldValue.ContentType, nil
  19622. }
  19623. // AddContentType adds i to the "content_type" field.
  19624. func (m *MessageRecordsMutation) AddContentType(i int) {
  19625. if m.addcontent_type != nil {
  19626. *m.addcontent_type += i
  19627. } else {
  19628. m.addcontent_type = &i
  19629. }
  19630. }
  19631. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19632. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19633. v := m.addcontent_type
  19634. if v == nil {
  19635. return
  19636. }
  19637. return *v, true
  19638. }
  19639. // ResetContentType resets all changes to the "content_type" field.
  19640. func (m *MessageRecordsMutation) ResetContentType() {
  19641. m.content_type = nil
  19642. m.addcontent_type = nil
  19643. }
  19644. // SetContent sets the "content" field.
  19645. func (m *MessageRecordsMutation) SetContent(s string) {
  19646. m.content = &s
  19647. }
  19648. // Content returns the value of the "content" field in the mutation.
  19649. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19650. v := m.content
  19651. if v == nil {
  19652. return
  19653. }
  19654. return *v, true
  19655. }
  19656. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19657. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19659. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19660. if !m.op.Is(OpUpdateOne) {
  19661. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19662. }
  19663. if m.id == nil || m.oldValue == nil {
  19664. return v, errors.New("OldContent requires an ID field in the mutation")
  19665. }
  19666. oldValue, err := m.oldValue(ctx)
  19667. if err != nil {
  19668. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19669. }
  19670. return oldValue.Content, nil
  19671. }
  19672. // ResetContent resets all changes to the "content" field.
  19673. func (m *MessageRecordsMutation) ResetContent() {
  19674. m.content = nil
  19675. }
  19676. // SetMeta sets the "meta" field.
  19677. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19678. m.meta = &ct
  19679. }
  19680. // Meta returns the value of the "meta" field in the mutation.
  19681. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19682. v := m.meta
  19683. if v == nil {
  19684. return
  19685. }
  19686. return *v, true
  19687. }
  19688. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19689. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19691. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19692. if !m.op.Is(OpUpdateOne) {
  19693. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19694. }
  19695. if m.id == nil || m.oldValue == nil {
  19696. return v, errors.New("OldMeta requires an ID field in the mutation")
  19697. }
  19698. oldValue, err := m.oldValue(ctx)
  19699. if err != nil {
  19700. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19701. }
  19702. return oldValue.Meta, nil
  19703. }
  19704. // ClearMeta clears the value of the "meta" field.
  19705. func (m *MessageRecordsMutation) ClearMeta() {
  19706. m.meta = nil
  19707. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19708. }
  19709. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19710. func (m *MessageRecordsMutation) MetaCleared() bool {
  19711. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19712. return ok
  19713. }
  19714. // ResetMeta resets all changes to the "meta" field.
  19715. func (m *MessageRecordsMutation) ResetMeta() {
  19716. m.meta = nil
  19717. delete(m.clearedFields, messagerecords.FieldMeta)
  19718. }
  19719. // SetErrorDetail sets the "error_detail" field.
  19720. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19721. m.error_detail = &s
  19722. }
  19723. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19724. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19725. v := m.error_detail
  19726. if v == nil {
  19727. return
  19728. }
  19729. return *v, true
  19730. }
  19731. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19732. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19734. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19735. if !m.op.Is(OpUpdateOne) {
  19736. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19737. }
  19738. if m.id == nil || m.oldValue == nil {
  19739. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19740. }
  19741. oldValue, err := m.oldValue(ctx)
  19742. if err != nil {
  19743. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19744. }
  19745. return oldValue.ErrorDetail, nil
  19746. }
  19747. // ResetErrorDetail resets all changes to the "error_detail" field.
  19748. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19749. m.error_detail = nil
  19750. }
  19751. // SetSendTime sets the "send_time" field.
  19752. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19753. m.send_time = &t
  19754. }
  19755. // SendTime returns the value of the "send_time" field in the mutation.
  19756. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19757. v := m.send_time
  19758. if v == nil {
  19759. return
  19760. }
  19761. return *v, true
  19762. }
  19763. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19764. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19766. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19767. if !m.op.Is(OpUpdateOne) {
  19768. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19769. }
  19770. if m.id == nil || m.oldValue == nil {
  19771. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19772. }
  19773. oldValue, err := m.oldValue(ctx)
  19774. if err != nil {
  19775. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19776. }
  19777. return oldValue.SendTime, nil
  19778. }
  19779. // ClearSendTime clears the value of the "send_time" field.
  19780. func (m *MessageRecordsMutation) ClearSendTime() {
  19781. m.send_time = nil
  19782. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19783. }
  19784. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19785. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19786. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19787. return ok
  19788. }
  19789. // ResetSendTime resets all changes to the "send_time" field.
  19790. func (m *MessageRecordsMutation) ResetSendTime() {
  19791. m.send_time = nil
  19792. delete(m.clearedFields, messagerecords.FieldSendTime)
  19793. }
  19794. // SetSourceType sets the "source_type" field.
  19795. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19796. m.source_type = &i
  19797. m.addsource_type = nil
  19798. }
  19799. // SourceType returns the value of the "source_type" field in the mutation.
  19800. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19801. v := m.source_type
  19802. if v == nil {
  19803. return
  19804. }
  19805. return *v, true
  19806. }
  19807. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19808. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19810. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19811. if !m.op.Is(OpUpdateOne) {
  19812. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19813. }
  19814. if m.id == nil || m.oldValue == nil {
  19815. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19816. }
  19817. oldValue, err := m.oldValue(ctx)
  19818. if err != nil {
  19819. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19820. }
  19821. return oldValue.SourceType, nil
  19822. }
  19823. // AddSourceType adds i to the "source_type" field.
  19824. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19825. if m.addsource_type != nil {
  19826. *m.addsource_type += i
  19827. } else {
  19828. m.addsource_type = &i
  19829. }
  19830. }
  19831. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19832. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19833. v := m.addsource_type
  19834. if v == nil {
  19835. return
  19836. }
  19837. return *v, true
  19838. }
  19839. // ResetSourceType resets all changes to the "source_type" field.
  19840. func (m *MessageRecordsMutation) ResetSourceType() {
  19841. m.source_type = nil
  19842. m.addsource_type = nil
  19843. }
  19844. // SetSourceID sets the "source_id" field.
  19845. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19846. m.sop_stage = &u
  19847. }
  19848. // SourceID returns the value of the "source_id" field in the mutation.
  19849. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19850. v := m.sop_stage
  19851. if v == nil {
  19852. return
  19853. }
  19854. return *v, true
  19855. }
  19856. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19857. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19859. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19860. if !m.op.Is(OpUpdateOne) {
  19861. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19862. }
  19863. if m.id == nil || m.oldValue == nil {
  19864. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19865. }
  19866. oldValue, err := m.oldValue(ctx)
  19867. if err != nil {
  19868. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19869. }
  19870. return oldValue.SourceID, nil
  19871. }
  19872. // ClearSourceID clears the value of the "source_id" field.
  19873. func (m *MessageRecordsMutation) ClearSourceID() {
  19874. m.sop_stage = nil
  19875. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19876. }
  19877. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19878. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19879. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19880. return ok
  19881. }
  19882. // ResetSourceID resets all changes to the "source_id" field.
  19883. func (m *MessageRecordsMutation) ResetSourceID() {
  19884. m.sop_stage = nil
  19885. delete(m.clearedFields, messagerecords.FieldSourceID)
  19886. }
  19887. // SetSubSourceID sets the "sub_source_id" field.
  19888. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19889. m.sop_node = &u
  19890. }
  19891. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19892. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19893. v := m.sop_node
  19894. if v == nil {
  19895. return
  19896. }
  19897. return *v, true
  19898. }
  19899. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19900. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19902. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19903. if !m.op.Is(OpUpdateOne) {
  19904. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19905. }
  19906. if m.id == nil || m.oldValue == nil {
  19907. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19908. }
  19909. oldValue, err := m.oldValue(ctx)
  19910. if err != nil {
  19911. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19912. }
  19913. return oldValue.SubSourceID, nil
  19914. }
  19915. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19916. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19917. m.sop_node = nil
  19918. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19919. }
  19920. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19921. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19922. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19923. return ok
  19924. }
  19925. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19926. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19927. m.sop_node = nil
  19928. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19929. }
  19930. // SetOrganizationID sets the "organization_id" field.
  19931. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19932. m.organization_id = &u
  19933. m.addorganization_id = nil
  19934. }
  19935. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19936. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19937. v := m.organization_id
  19938. if v == nil {
  19939. return
  19940. }
  19941. return *v, true
  19942. }
  19943. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19944. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19946. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19947. if !m.op.Is(OpUpdateOne) {
  19948. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19949. }
  19950. if m.id == nil || m.oldValue == nil {
  19951. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19952. }
  19953. oldValue, err := m.oldValue(ctx)
  19954. if err != nil {
  19955. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19956. }
  19957. return oldValue.OrganizationID, nil
  19958. }
  19959. // AddOrganizationID adds u to the "organization_id" field.
  19960. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19961. if m.addorganization_id != nil {
  19962. *m.addorganization_id += u
  19963. } else {
  19964. m.addorganization_id = &u
  19965. }
  19966. }
  19967. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19968. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19969. v := m.addorganization_id
  19970. if v == nil {
  19971. return
  19972. }
  19973. return *v, true
  19974. }
  19975. // ClearOrganizationID clears the value of the "organization_id" field.
  19976. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19977. m.organization_id = nil
  19978. m.addorganization_id = nil
  19979. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19980. }
  19981. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19982. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19983. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19984. return ok
  19985. }
  19986. // ResetOrganizationID resets all changes to the "organization_id" field.
  19987. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19988. m.organization_id = nil
  19989. m.addorganization_id = nil
  19990. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19991. }
  19992. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19993. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19994. m.sop_stage = &id
  19995. }
  19996. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19997. func (m *MessageRecordsMutation) ClearSopStage() {
  19998. m.clearedsop_stage = true
  19999. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20000. }
  20001. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  20002. func (m *MessageRecordsMutation) SopStageCleared() bool {
  20003. return m.SourceIDCleared() || m.clearedsop_stage
  20004. }
  20005. // SopStageID returns the "sop_stage" edge ID in the mutation.
  20006. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  20007. if m.sop_stage != nil {
  20008. return *m.sop_stage, true
  20009. }
  20010. return
  20011. }
  20012. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  20013. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20014. // SopStageID instead. It exists only for internal usage by the builders.
  20015. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  20016. if id := m.sop_stage; id != nil {
  20017. ids = append(ids, *id)
  20018. }
  20019. return
  20020. }
  20021. // ResetSopStage resets all changes to the "sop_stage" edge.
  20022. func (m *MessageRecordsMutation) ResetSopStage() {
  20023. m.sop_stage = nil
  20024. m.clearedsop_stage = false
  20025. }
  20026. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  20027. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  20028. m.sop_node = &id
  20029. }
  20030. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  20031. func (m *MessageRecordsMutation) ClearSopNode() {
  20032. m.clearedsop_node = true
  20033. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20034. }
  20035. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  20036. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  20037. return m.SubSourceIDCleared() || m.clearedsop_node
  20038. }
  20039. // SopNodeID returns the "sop_node" edge ID in the mutation.
  20040. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  20041. if m.sop_node != nil {
  20042. return *m.sop_node, true
  20043. }
  20044. return
  20045. }
  20046. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  20047. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20048. // SopNodeID instead. It exists only for internal usage by the builders.
  20049. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  20050. if id := m.sop_node; id != nil {
  20051. ids = append(ids, *id)
  20052. }
  20053. return
  20054. }
  20055. // ResetSopNode resets all changes to the "sop_node" edge.
  20056. func (m *MessageRecordsMutation) ResetSopNode() {
  20057. m.sop_node = nil
  20058. m.clearedsop_node = false
  20059. }
  20060. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  20061. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  20062. m.message_contact = &id
  20063. }
  20064. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  20065. func (m *MessageRecordsMutation) ClearMessageContact() {
  20066. m.clearedmessage_contact = true
  20067. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20068. }
  20069. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  20070. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  20071. return m.ContactIDCleared() || m.clearedmessage_contact
  20072. }
  20073. // MessageContactID returns the "message_contact" edge ID in the mutation.
  20074. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  20075. if m.message_contact != nil {
  20076. return *m.message_contact, true
  20077. }
  20078. return
  20079. }
  20080. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  20081. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20082. // MessageContactID instead. It exists only for internal usage by the builders.
  20083. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  20084. if id := m.message_contact; id != nil {
  20085. ids = append(ids, *id)
  20086. }
  20087. return
  20088. }
  20089. // ResetMessageContact resets all changes to the "message_contact" edge.
  20090. func (m *MessageRecordsMutation) ResetMessageContact() {
  20091. m.message_contact = nil
  20092. m.clearedmessage_contact = false
  20093. }
  20094. // Where appends a list predicates to the MessageRecordsMutation builder.
  20095. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  20096. m.predicates = append(m.predicates, ps...)
  20097. }
  20098. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  20099. // users can use type-assertion to append predicates that do not depend on any generated package.
  20100. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  20101. p := make([]predicate.MessageRecords, len(ps))
  20102. for i := range ps {
  20103. p[i] = ps[i]
  20104. }
  20105. m.Where(p...)
  20106. }
  20107. // Op returns the operation name.
  20108. func (m *MessageRecordsMutation) Op() Op {
  20109. return m.op
  20110. }
  20111. // SetOp allows setting the mutation operation.
  20112. func (m *MessageRecordsMutation) SetOp(op Op) {
  20113. m.op = op
  20114. }
  20115. // Type returns the node type of this mutation (MessageRecords).
  20116. func (m *MessageRecordsMutation) Type() string {
  20117. return m.typ
  20118. }
  20119. // Fields returns all fields that were changed during this mutation. Note that in
  20120. // order to get all numeric fields that were incremented/decremented, call
  20121. // AddedFields().
  20122. func (m *MessageRecordsMutation) Fields() []string {
  20123. fields := make([]string, 0, 16)
  20124. if m.created_at != nil {
  20125. fields = append(fields, messagerecords.FieldCreatedAt)
  20126. }
  20127. if m.updated_at != nil {
  20128. fields = append(fields, messagerecords.FieldUpdatedAt)
  20129. }
  20130. if m.status != nil {
  20131. fields = append(fields, messagerecords.FieldStatus)
  20132. }
  20133. if m.bot_wxid != nil {
  20134. fields = append(fields, messagerecords.FieldBotWxid)
  20135. }
  20136. if m.message_contact != nil {
  20137. fields = append(fields, messagerecords.FieldContactID)
  20138. }
  20139. if m.contact_type != nil {
  20140. fields = append(fields, messagerecords.FieldContactType)
  20141. }
  20142. if m.contact_wxid != nil {
  20143. fields = append(fields, messagerecords.FieldContactWxid)
  20144. }
  20145. if m.content_type != nil {
  20146. fields = append(fields, messagerecords.FieldContentType)
  20147. }
  20148. if m.content != nil {
  20149. fields = append(fields, messagerecords.FieldContent)
  20150. }
  20151. if m.meta != nil {
  20152. fields = append(fields, messagerecords.FieldMeta)
  20153. }
  20154. if m.error_detail != nil {
  20155. fields = append(fields, messagerecords.FieldErrorDetail)
  20156. }
  20157. if m.send_time != nil {
  20158. fields = append(fields, messagerecords.FieldSendTime)
  20159. }
  20160. if m.source_type != nil {
  20161. fields = append(fields, messagerecords.FieldSourceType)
  20162. }
  20163. if m.sop_stage != nil {
  20164. fields = append(fields, messagerecords.FieldSourceID)
  20165. }
  20166. if m.sop_node != nil {
  20167. fields = append(fields, messagerecords.FieldSubSourceID)
  20168. }
  20169. if m.organization_id != nil {
  20170. fields = append(fields, messagerecords.FieldOrganizationID)
  20171. }
  20172. return fields
  20173. }
  20174. // Field returns the value of a field with the given name. The second boolean
  20175. // return value indicates that this field was not set, or was not defined in the
  20176. // schema.
  20177. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  20178. switch name {
  20179. case messagerecords.FieldCreatedAt:
  20180. return m.CreatedAt()
  20181. case messagerecords.FieldUpdatedAt:
  20182. return m.UpdatedAt()
  20183. case messagerecords.FieldStatus:
  20184. return m.Status()
  20185. case messagerecords.FieldBotWxid:
  20186. return m.BotWxid()
  20187. case messagerecords.FieldContactID:
  20188. return m.ContactID()
  20189. case messagerecords.FieldContactType:
  20190. return m.ContactType()
  20191. case messagerecords.FieldContactWxid:
  20192. return m.ContactWxid()
  20193. case messagerecords.FieldContentType:
  20194. return m.ContentType()
  20195. case messagerecords.FieldContent:
  20196. return m.Content()
  20197. case messagerecords.FieldMeta:
  20198. return m.Meta()
  20199. case messagerecords.FieldErrorDetail:
  20200. return m.ErrorDetail()
  20201. case messagerecords.FieldSendTime:
  20202. return m.SendTime()
  20203. case messagerecords.FieldSourceType:
  20204. return m.SourceType()
  20205. case messagerecords.FieldSourceID:
  20206. return m.SourceID()
  20207. case messagerecords.FieldSubSourceID:
  20208. return m.SubSourceID()
  20209. case messagerecords.FieldOrganizationID:
  20210. return m.OrganizationID()
  20211. }
  20212. return nil, false
  20213. }
  20214. // OldField returns the old value of the field from the database. An error is
  20215. // returned if the mutation operation is not UpdateOne, or the query to the
  20216. // database failed.
  20217. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20218. switch name {
  20219. case messagerecords.FieldCreatedAt:
  20220. return m.OldCreatedAt(ctx)
  20221. case messagerecords.FieldUpdatedAt:
  20222. return m.OldUpdatedAt(ctx)
  20223. case messagerecords.FieldStatus:
  20224. return m.OldStatus(ctx)
  20225. case messagerecords.FieldBotWxid:
  20226. return m.OldBotWxid(ctx)
  20227. case messagerecords.FieldContactID:
  20228. return m.OldContactID(ctx)
  20229. case messagerecords.FieldContactType:
  20230. return m.OldContactType(ctx)
  20231. case messagerecords.FieldContactWxid:
  20232. return m.OldContactWxid(ctx)
  20233. case messagerecords.FieldContentType:
  20234. return m.OldContentType(ctx)
  20235. case messagerecords.FieldContent:
  20236. return m.OldContent(ctx)
  20237. case messagerecords.FieldMeta:
  20238. return m.OldMeta(ctx)
  20239. case messagerecords.FieldErrorDetail:
  20240. return m.OldErrorDetail(ctx)
  20241. case messagerecords.FieldSendTime:
  20242. return m.OldSendTime(ctx)
  20243. case messagerecords.FieldSourceType:
  20244. return m.OldSourceType(ctx)
  20245. case messagerecords.FieldSourceID:
  20246. return m.OldSourceID(ctx)
  20247. case messagerecords.FieldSubSourceID:
  20248. return m.OldSubSourceID(ctx)
  20249. case messagerecords.FieldOrganizationID:
  20250. return m.OldOrganizationID(ctx)
  20251. }
  20252. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  20253. }
  20254. // SetField sets the value of a field with the given name. It returns an error if
  20255. // the field is not defined in the schema, or if the type mismatched the field
  20256. // type.
  20257. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  20258. switch name {
  20259. case messagerecords.FieldCreatedAt:
  20260. v, ok := value.(time.Time)
  20261. if !ok {
  20262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20263. }
  20264. m.SetCreatedAt(v)
  20265. return nil
  20266. case messagerecords.FieldUpdatedAt:
  20267. v, ok := value.(time.Time)
  20268. if !ok {
  20269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20270. }
  20271. m.SetUpdatedAt(v)
  20272. return nil
  20273. case messagerecords.FieldStatus:
  20274. v, ok := value.(uint8)
  20275. if !ok {
  20276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20277. }
  20278. m.SetStatus(v)
  20279. return nil
  20280. case messagerecords.FieldBotWxid:
  20281. v, ok := value.(string)
  20282. if !ok {
  20283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20284. }
  20285. m.SetBotWxid(v)
  20286. return nil
  20287. case messagerecords.FieldContactID:
  20288. v, ok := value.(uint64)
  20289. if !ok {
  20290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20291. }
  20292. m.SetContactID(v)
  20293. return nil
  20294. case messagerecords.FieldContactType:
  20295. v, ok := value.(int)
  20296. if !ok {
  20297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20298. }
  20299. m.SetContactType(v)
  20300. return nil
  20301. case messagerecords.FieldContactWxid:
  20302. v, ok := value.(string)
  20303. if !ok {
  20304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20305. }
  20306. m.SetContactWxid(v)
  20307. return nil
  20308. case messagerecords.FieldContentType:
  20309. v, ok := value.(int)
  20310. if !ok {
  20311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20312. }
  20313. m.SetContentType(v)
  20314. return nil
  20315. case messagerecords.FieldContent:
  20316. v, ok := value.(string)
  20317. if !ok {
  20318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20319. }
  20320. m.SetContent(v)
  20321. return nil
  20322. case messagerecords.FieldMeta:
  20323. v, ok := value.(custom_types.Meta)
  20324. if !ok {
  20325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20326. }
  20327. m.SetMeta(v)
  20328. return nil
  20329. case messagerecords.FieldErrorDetail:
  20330. v, ok := value.(string)
  20331. if !ok {
  20332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20333. }
  20334. m.SetErrorDetail(v)
  20335. return nil
  20336. case messagerecords.FieldSendTime:
  20337. v, ok := value.(time.Time)
  20338. if !ok {
  20339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20340. }
  20341. m.SetSendTime(v)
  20342. return nil
  20343. case messagerecords.FieldSourceType:
  20344. v, ok := value.(int)
  20345. if !ok {
  20346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20347. }
  20348. m.SetSourceType(v)
  20349. return nil
  20350. case messagerecords.FieldSourceID:
  20351. v, ok := value.(uint64)
  20352. if !ok {
  20353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20354. }
  20355. m.SetSourceID(v)
  20356. return nil
  20357. case messagerecords.FieldSubSourceID:
  20358. v, ok := value.(uint64)
  20359. if !ok {
  20360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20361. }
  20362. m.SetSubSourceID(v)
  20363. return nil
  20364. case messagerecords.FieldOrganizationID:
  20365. v, ok := value.(uint64)
  20366. if !ok {
  20367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20368. }
  20369. m.SetOrganizationID(v)
  20370. return nil
  20371. }
  20372. return fmt.Errorf("unknown MessageRecords field %s", name)
  20373. }
  20374. // AddedFields returns all numeric fields that were incremented/decremented during
  20375. // this mutation.
  20376. func (m *MessageRecordsMutation) AddedFields() []string {
  20377. var fields []string
  20378. if m.addstatus != nil {
  20379. fields = append(fields, messagerecords.FieldStatus)
  20380. }
  20381. if m.addcontact_type != nil {
  20382. fields = append(fields, messagerecords.FieldContactType)
  20383. }
  20384. if m.addcontent_type != nil {
  20385. fields = append(fields, messagerecords.FieldContentType)
  20386. }
  20387. if m.addsource_type != nil {
  20388. fields = append(fields, messagerecords.FieldSourceType)
  20389. }
  20390. if m.addorganization_id != nil {
  20391. fields = append(fields, messagerecords.FieldOrganizationID)
  20392. }
  20393. return fields
  20394. }
  20395. // AddedField returns the numeric value that was incremented/decremented on a field
  20396. // with the given name. The second boolean return value indicates that this field
  20397. // was not set, or was not defined in the schema.
  20398. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20399. switch name {
  20400. case messagerecords.FieldStatus:
  20401. return m.AddedStatus()
  20402. case messagerecords.FieldContactType:
  20403. return m.AddedContactType()
  20404. case messagerecords.FieldContentType:
  20405. return m.AddedContentType()
  20406. case messagerecords.FieldSourceType:
  20407. return m.AddedSourceType()
  20408. case messagerecords.FieldOrganizationID:
  20409. return m.AddedOrganizationID()
  20410. }
  20411. return nil, false
  20412. }
  20413. // AddField adds the value to the field with the given name. It returns an error if
  20414. // the field is not defined in the schema, or if the type mismatched the field
  20415. // type.
  20416. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20417. switch name {
  20418. case messagerecords.FieldStatus:
  20419. v, ok := value.(int8)
  20420. if !ok {
  20421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20422. }
  20423. m.AddStatus(v)
  20424. return nil
  20425. case messagerecords.FieldContactType:
  20426. v, ok := value.(int)
  20427. if !ok {
  20428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20429. }
  20430. m.AddContactType(v)
  20431. return nil
  20432. case messagerecords.FieldContentType:
  20433. v, ok := value.(int)
  20434. if !ok {
  20435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20436. }
  20437. m.AddContentType(v)
  20438. return nil
  20439. case messagerecords.FieldSourceType:
  20440. v, ok := value.(int)
  20441. if !ok {
  20442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20443. }
  20444. m.AddSourceType(v)
  20445. return nil
  20446. case messagerecords.FieldOrganizationID:
  20447. v, ok := value.(int64)
  20448. if !ok {
  20449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20450. }
  20451. m.AddOrganizationID(v)
  20452. return nil
  20453. }
  20454. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20455. }
  20456. // ClearedFields returns all nullable fields that were cleared during this
  20457. // mutation.
  20458. func (m *MessageRecordsMutation) ClearedFields() []string {
  20459. var fields []string
  20460. if m.FieldCleared(messagerecords.FieldStatus) {
  20461. fields = append(fields, messagerecords.FieldStatus)
  20462. }
  20463. if m.FieldCleared(messagerecords.FieldContactID) {
  20464. fields = append(fields, messagerecords.FieldContactID)
  20465. }
  20466. if m.FieldCleared(messagerecords.FieldMeta) {
  20467. fields = append(fields, messagerecords.FieldMeta)
  20468. }
  20469. if m.FieldCleared(messagerecords.FieldSendTime) {
  20470. fields = append(fields, messagerecords.FieldSendTime)
  20471. }
  20472. if m.FieldCleared(messagerecords.FieldSourceID) {
  20473. fields = append(fields, messagerecords.FieldSourceID)
  20474. }
  20475. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20476. fields = append(fields, messagerecords.FieldSubSourceID)
  20477. }
  20478. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20479. fields = append(fields, messagerecords.FieldOrganizationID)
  20480. }
  20481. return fields
  20482. }
  20483. // FieldCleared returns a boolean indicating if a field with the given name was
  20484. // cleared in this mutation.
  20485. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20486. _, ok := m.clearedFields[name]
  20487. return ok
  20488. }
  20489. // ClearField clears the value of the field with the given name. It returns an
  20490. // error if the field is not defined in the schema.
  20491. func (m *MessageRecordsMutation) ClearField(name string) error {
  20492. switch name {
  20493. case messagerecords.FieldStatus:
  20494. m.ClearStatus()
  20495. return nil
  20496. case messagerecords.FieldContactID:
  20497. m.ClearContactID()
  20498. return nil
  20499. case messagerecords.FieldMeta:
  20500. m.ClearMeta()
  20501. return nil
  20502. case messagerecords.FieldSendTime:
  20503. m.ClearSendTime()
  20504. return nil
  20505. case messagerecords.FieldSourceID:
  20506. m.ClearSourceID()
  20507. return nil
  20508. case messagerecords.FieldSubSourceID:
  20509. m.ClearSubSourceID()
  20510. return nil
  20511. case messagerecords.FieldOrganizationID:
  20512. m.ClearOrganizationID()
  20513. return nil
  20514. }
  20515. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20516. }
  20517. // ResetField resets all changes in the mutation for the field with the given name.
  20518. // It returns an error if the field is not defined in the schema.
  20519. func (m *MessageRecordsMutation) ResetField(name string) error {
  20520. switch name {
  20521. case messagerecords.FieldCreatedAt:
  20522. m.ResetCreatedAt()
  20523. return nil
  20524. case messagerecords.FieldUpdatedAt:
  20525. m.ResetUpdatedAt()
  20526. return nil
  20527. case messagerecords.FieldStatus:
  20528. m.ResetStatus()
  20529. return nil
  20530. case messagerecords.FieldBotWxid:
  20531. m.ResetBotWxid()
  20532. return nil
  20533. case messagerecords.FieldContactID:
  20534. m.ResetContactID()
  20535. return nil
  20536. case messagerecords.FieldContactType:
  20537. m.ResetContactType()
  20538. return nil
  20539. case messagerecords.FieldContactWxid:
  20540. m.ResetContactWxid()
  20541. return nil
  20542. case messagerecords.FieldContentType:
  20543. m.ResetContentType()
  20544. return nil
  20545. case messagerecords.FieldContent:
  20546. m.ResetContent()
  20547. return nil
  20548. case messagerecords.FieldMeta:
  20549. m.ResetMeta()
  20550. return nil
  20551. case messagerecords.FieldErrorDetail:
  20552. m.ResetErrorDetail()
  20553. return nil
  20554. case messagerecords.FieldSendTime:
  20555. m.ResetSendTime()
  20556. return nil
  20557. case messagerecords.FieldSourceType:
  20558. m.ResetSourceType()
  20559. return nil
  20560. case messagerecords.FieldSourceID:
  20561. m.ResetSourceID()
  20562. return nil
  20563. case messagerecords.FieldSubSourceID:
  20564. m.ResetSubSourceID()
  20565. return nil
  20566. case messagerecords.FieldOrganizationID:
  20567. m.ResetOrganizationID()
  20568. return nil
  20569. }
  20570. return fmt.Errorf("unknown MessageRecords field %s", name)
  20571. }
  20572. // AddedEdges returns all edge names that were set/added in this mutation.
  20573. func (m *MessageRecordsMutation) AddedEdges() []string {
  20574. edges := make([]string, 0, 3)
  20575. if m.sop_stage != nil {
  20576. edges = append(edges, messagerecords.EdgeSopStage)
  20577. }
  20578. if m.sop_node != nil {
  20579. edges = append(edges, messagerecords.EdgeSopNode)
  20580. }
  20581. if m.message_contact != nil {
  20582. edges = append(edges, messagerecords.EdgeMessageContact)
  20583. }
  20584. return edges
  20585. }
  20586. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20587. // name in this mutation.
  20588. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20589. switch name {
  20590. case messagerecords.EdgeSopStage:
  20591. if id := m.sop_stage; id != nil {
  20592. return []ent.Value{*id}
  20593. }
  20594. case messagerecords.EdgeSopNode:
  20595. if id := m.sop_node; id != nil {
  20596. return []ent.Value{*id}
  20597. }
  20598. case messagerecords.EdgeMessageContact:
  20599. if id := m.message_contact; id != nil {
  20600. return []ent.Value{*id}
  20601. }
  20602. }
  20603. return nil
  20604. }
  20605. // RemovedEdges returns all edge names that were removed in this mutation.
  20606. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20607. edges := make([]string, 0, 3)
  20608. return edges
  20609. }
  20610. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20611. // the given name in this mutation.
  20612. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20613. return nil
  20614. }
  20615. // ClearedEdges returns all edge names that were cleared in this mutation.
  20616. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20617. edges := make([]string, 0, 3)
  20618. if m.clearedsop_stage {
  20619. edges = append(edges, messagerecords.EdgeSopStage)
  20620. }
  20621. if m.clearedsop_node {
  20622. edges = append(edges, messagerecords.EdgeSopNode)
  20623. }
  20624. if m.clearedmessage_contact {
  20625. edges = append(edges, messagerecords.EdgeMessageContact)
  20626. }
  20627. return edges
  20628. }
  20629. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20630. // was cleared in this mutation.
  20631. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20632. switch name {
  20633. case messagerecords.EdgeSopStage:
  20634. return m.clearedsop_stage
  20635. case messagerecords.EdgeSopNode:
  20636. return m.clearedsop_node
  20637. case messagerecords.EdgeMessageContact:
  20638. return m.clearedmessage_contact
  20639. }
  20640. return false
  20641. }
  20642. // ClearEdge clears the value of the edge with the given name. It returns an error
  20643. // if that edge is not defined in the schema.
  20644. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20645. switch name {
  20646. case messagerecords.EdgeSopStage:
  20647. m.ClearSopStage()
  20648. return nil
  20649. case messagerecords.EdgeSopNode:
  20650. m.ClearSopNode()
  20651. return nil
  20652. case messagerecords.EdgeMessageContact:
  20653. m.ClearMessageContact()
  20654. return nil
  20655. }
  20656. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20657. }
  20658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20659. // It returns an error if the edge is not defined in the schema.
  20660. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20661. switch name {
  20662. case messagerecords.EdgeSopStage:
  20663. m.ResetSopStage()
  20664. return nil
  20665. case messagerecords.EdgeSopNode:
  20666. m.ResetSopNode()
  20667. return nil
  20668. case messagerecords.EdgeMessageContact:
  20669. m.ResetMessageContact()
  20670. return nil
  20671. }
  20672. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20673. }
  20674. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20675. type MsgMutation struct {
  20676. config
  20677. op Op
  20678. typ string
  20679. id *uint64
  20680. created_at *time.Time
  20681. updated_at *time.Time
  20682. deleted_at *time.Time
  20683. status *uint8
  20684. addstatus *int8
  20685. fromwxid *string
  20686. toid *string
  20687. msgtype *int32
  20688. addmsgtype *int32
  20689. msg *string
  20690. batch_no *string
  20691. cc *string
  20692. phone *string
  20693. clearedFields map[string]struct{}
  20694. done bool
  20695. oldValue func(context.Context) (*Msg, error)
  20696. predicates []predicate.Msg
  20697. }
  20698. var _ ent.Mutation = (*MsgMutation)(nil)
  20699. // msgOption allows management of the mutation configuration using functional options.
  20700. type msgOption func(*MsgMutation)
  20701. // newMsgMutation creates new mutation for the Msg entity.
  20702. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20703. m := &MsgMutation{
  20704. config: c,
  20705. op: op,
  20706. typ: TypeMsg,
  20707. clearedFields: make(map[string]struct{}),
  20708. }
  20709. for _, opt := range opts {
  20710. opt(m)
  20711. }
  20712. return m
  20713. }
  20714. // withMsgID sets the ID field of the mutation.
  20715. func withMsgID(id uint64) msgOption {
  20716. return func(m *MsgMutation) {
  20717. var (
  20718. err error
  20719. once sync.Once
  20720. value *Msg
  20721. )
  20722. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20723. once.Do(func() {
  20724. if m.done {
  20725. err = errors.New("querying old values post mutation is not allowed")
  20726. } else {
  20727. value, err = m.Client().Msg.Get(ctx, id)
  20728. }
  20729. })
  20730. return value, err
  20731. }
  20732. m.id = &id
  20733. }
  20734. }
  20735. // withMsg sets the old Msg of the mutation.
  20736. func withMsg(node *Msg) msgOption {
  20737. return func(m *MsgMutation) {
  20738. m.oldValue = func(context.Context) (*Msg, error) {
  20739. return node, nil
  20740. }
  20741. m.id = &node.ID
  20742. }
  20743. }
  20744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20745. // executed in a transaction (ent.Tx), a transactional client is returned.
  20746. func (m MsgMutation) Client() *Client {
  20747. client := &Client{config: m.config}
  20748. client.init()
  20749. return client
  20750. }
  20751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20752. // it returns an error otherwise.
  20753. func (m MsgMutation) Tx() (*Tx, error) {
  20754. if _, ok := m.driver.(*txDriver); !ok {
  20755. return nil, errors.New("ent: mutation is not running in a transaction")
  20756. }
  20757. tx := &Tx{config: m.config}
  20758. tx.init()
  20759. return tx, nil
  20760. }
  20761. // SetID sets the value of the id field. Note that this
  20762. // operation is only accepted on creation of Msg entities.
  20763. func (m *MsgMutation) SetID(id uint64) {
  20764. m.id = &id
  20765. }
  20766. // ID returns the ID value in the mutation. Note that the ID is only available
  20767. // if it was provided to the builder or after it was returned from the database.
  20768. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20769. if m.id == nil {
  20770. return
  20771. }
  20772. return *m.id, true
  20773. }
  20774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20775. // That means, if the mutation is applied within a transaction with an isolation level such
  20776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20777. // or updated by the mutation.
  20778. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20779. switch {
  20780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20781. id, exists := m.ID()
  20782. if exists {
  20783. return []uint64{id}, nil
  20784. }
  20785. fallthrough
  20786. case m.op.Is(OpUpdate | OpDelete):
  20787. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20788. default:
  20789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20790. }
  20791. }
  20792. // SetCreatedAt sets the "created_at" field.
  20793. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20794. m.created_at = &t
  20795. }
  20796. // CreatedAt returns the value of the "created_at" field in the mutation.
  20797. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20798. v := m.created_at
  20799. if v == nil {
  20800. return
  20801. }
  20802. return *v, true
  20803. }
  20804. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20805. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20807. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20808. if !m.op.Is(OpUpdateOne) {
  20809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20810. }
  20811. if m.id == nil || m.oldValue == nil {
  20812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20813. }
  20814. oldValue, err := m.oldValue(ctx)
  20815. if err != nil {
  20816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20817. }
  20818. return oldValue.CreatedAt, nil
  20819. }
  20820. // ResetCreatedAt resets all changes to the "created_at" field.
  20821. func (m *MsgMutation) ResetCreatedAt() {
  20822. m.created_at = nil
  20823. }
  20824. // SetUpdatedAt sets the "updated_at" field.
  20825. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20826. m.updated_at = &t
  20827. }
  20828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20829. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20830. v := m.updated_at
  20831. if v == nil {
  20832. return
  20833. }
  20834. return *v, true
  20835. }
  20836. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20837. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20839. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20840. if !m.op.Is(OpUpdateOne) {
  20841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20842. }
  20843. if m.id == nil || m.oldValue == nil {
  20844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20845. }
  20846. oldValue, err := m.oldValue(ctx)
  20847. if err != nil {
  20848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20849. }
  20850. return oldValue.UpdatedAt, nil
  20851. }
  20852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20853. func (m *MsgMutation) ResetUpdatedAt() {
  20854. m.updated_at = nil
  20855. }
  20856. // SetDeletedAt sets the "deleted_at" field.
  20857. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20858. m.deleted_at = &t
  20859. }
  20860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20861. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20862. v := m.deleted_at
  20863. if v == nil {
  20864. return
  20865. }
  20866. return *v, true
  20867. }
  20868. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20869. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20871. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20872. if !m.op.Is(OpUpdateOne) {
  20873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20874. }
  20875. if m.id == nil || m.oldValue == nil {
  20876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20877. }
  20878. oldValue, err := m.oldValue(ctx)
  20879. if err != nil {
  20880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20881. }
  20882. return oldValue.DeletedAt, nil
  20883. }
  20884. // ClearDeletedAt clears the value of the "deleted_at" field.
  20885. func (m *MsgMutation) ClearDeletedAt() {
  20886. m.deleted_at = nil
  20887. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20888. }
  20889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20890. func (m *MsgMutation) DeletedAtCleared() bool {
  20891. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20892. return ok
  20893. }
  20894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20895. func (m *MsgMutation) ResetDeletedAt() {
  20896. m.deleted_at = nil
  20897. delete(m.clearedFields, msg.FieldDeletedAt)
  20898. }
  20899. // SetStatus sets the "status" field.
  20900. func (m *MsgMutation) SetStatus(u uint8) {
  20901. m.status = &u
  20902. m.addstatus = nil
  20903. }
  20904. // Status returns the value of the "status" field in the mutation.
  20905. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20906. v := m.status
  20907. if v == nil {
  20908. return
  20909. }
  20910. return *v, true
  20911. }
  20912. // OldStatus returns the old "status" field's value of the Msg entity.
  20913. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20915. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20916. if !m.op.Is(OpUpdateOne) {
  20917. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20918. }
  20919. if m.id == nil || m.oldValue == nil {
  20920. return v, errors.New("OldStatus requires an ID field in the mutation")
  20921. }
  20922. oldValue, err := m.oldValue(ctx)
  20923. if err != nil {
  20924. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20925. }
  20926. return oldValue.Status, nil
  20927. }
  20928. // AddStatus adds u to the "status" field.
  20929. func (m *MsgMutation) AddStatus(u int8) {
  20930. if m.addstatus != nil {
  20931. *m.addstatus += u
  20932. } else {
  20933. m.addstatus = &u
  20934. }
  20935. }
  20936. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20937. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20938. v := m.addstatus
  20939. if v == nil {
  20940. return
  20941. }
  20942. return *v, true
  20943. }
  20944. // ClearStatus clears the value of the "status" field.
  20945. func (m *MsgMutation) ClearStatus() {
  20946. m.status = nil
  20947. m.addstatus = nil
  20948. m.clearedFields[msg.FieldStatus] = struct{}{}
  20949. }
  20950. // StatusCleared returns if the "status" field was cleared in this mutation.
  20951. func (m *MsgMutation) StatusCleared() bool {
  20952. _, ok := m.clearedFields[msg.FieldStatus]
  20953. return ok
  20954. }
  20955. // ResetStatus resets all changes to the "status" field.
  20956. func (m *MsgMutation) ResetStatus() {
  20957. m.status = nil
  20958. m.addstatus = nil
  20959. delete(m.clearedFields, msg.FieldStatus)
  20960. }
  20961. // SetFromwxid sets the "fromwxid" field.
  20962. func (m *MsgMutation) SetFromwxid(s string) {
  20963. m.fromwxid = &s
  20964. }
  20965. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20966. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20967. v := m.fromwxid
  20968. if v == nil {
  20969. return
  20970. }
  20971. return *v, true
  20972. }
  20973. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20974. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20976. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20977. if !m.op.Is(OpUpdateOne) {
  20978. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20979. }
  20980. if m.id == nil || m.oldValue == nil {
  20981. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20982. }
  20983. oldValue, err := m.oldValue(ctx)
  20984. if err != nil {
  20985. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20986. }
  20987. return oldValue.Fromwxid, nil
  20988. }
  20989. // ClearFromwxid clears the value of the "fromwxid" field.
  20990. func (m *MsgMutation) ClearFromwxid() {
  20991. m.fromwxid = nil
  20992. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20993. }
  20994. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20995. func (m *MsgMutation) FromwxidCleared() bool {
  20996. _, ok := m.clearedFields[msg.FieldFromwxid]
  20997. return ok
  20998. }
  20999. // ResetFromwxid resets all changes to the "fromwxid" field.
  21000. func (m *MsgMutation) ResetFromwxid() {
  21001. m.fromwxid = nil
  21002. delete(m.clearedFields, msg.FieldFromwxid)
  21003. }
  21004. // SetToid sets the "toid" field.
  21005. func (m *MsgMutation) SetToid(s string) {
  21006. m.toid = &s
  21007. }
  21008. // Toid returns the value of the "toid" field in the mutation.
  21009. func (m *MsgMutation) Toid() (r string, exists bool) {
  21010. v := m.toid
  21011. if v == nil {
  21012. return
  21013. }
  21014. return *v, true
  21015. }
  21016. // OldToid returns the old "toid" field's value of the Msg entity.
  21017. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21019. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  21020. if !m.op.Is(OpUpdateOne) {
  21021. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  21022. }
  21023. if m.id == nil || m.oldValue == nil {
  21024. return v, errors.New("OldToid requires an ID field in the mutation")
  21025. }
  21026. oldValue, err := m.oldValue(ctx)
  21027. if err != nil {
  21028. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  21029. }
  21030. return oldValue.Toid, nil
  21031. }
  21032. // ClearToid clears the value of the "toid" field.
  21033. func (m *MsgMutation) ClearToid() {
  21034. m.toid = nil
  21035. m.clearedFields[msg.FieldToid] = struct{}{}
  21036. }
  21037. // ToidCleared returns if the "toid" field was cleared in this mutation.
  21038. func (m *MsgMutation) ToidCleared() bool {
  21039. _, ok := m.clearedFields[msg.FieldToid]
  21040. return ok
  21041. }
  21042. // ResetToid resets all changes to the "toid" field.
  21043. func (m *MsgMutation) ResetToid() {
  21044. m.toid = nil
  21045. delete(m.clearedFields, msg.FieldToid)
  21046. }
  21047. // SetMsgtype sets the "msgtype" field.
  21048. func (m *MsgMutation) SetMsgtype(i int32) {
  21049. m.msgtype = &i
  21050. m.addmsgtype = nil
  21051. }
  21052. // Msgtype returns the value of the "msgtype" field in the mutation.
  21053. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  21054. v := m.msgtype
  21055. if v == nil {
  21056. return
  21057. }
  21058. return *v, true
  21059. }
  21060. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  21061. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21063. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  21064. if !m.op.Is(OpUpdateOne) {
  21065. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  21066. }
  21067. if m.id == nil || m.oldValue == nil {
  21068. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  21069. }
  21070. oldValue, err := m.oldValue(ctx)
  21071. if err != nil {
  21072. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  21073. }
  21074. return oldValue.Msgtype, nil
  21075. }
  21076. // AddMsgtype adds i to the "msgtype" field.
  21077. func (m *MsgMutation) AddMsgtype(i int32) {
  21078. if m.addmsgtype != nil {
  21079. *m.addmsgtype += i
  21080. } else {
  21081. m.addmsgtype = &i
  21082. }
  21083. }
  21084. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  21085. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  21086. v := m.addmsgtype
  21087. if v == nil {
  21088. return
  21089. }
  21090. return *v, true
  21091. }
  21092. // ClearMsgtype clears the value of the "msgtype" field.
  21093. func (m *MsgMutation) ClearMsgtype() {
  21094. m.msgtype = nil
  21095. m.addmsgtype = nil
  21096. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  21097. }
  21098. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  21099. func (m *MsgMutation) MsgtypeCleared() bool {
  21100. _, ok := m.clearedFields[msg.FieldMsgtype]
  21101. return ok
  21102. }
  21103. // ResetMsgtype resets all changes to the "msgtype" field.
  21104. func (m *MsgMutation) ResetMsgtype() {
  21105. m.msgtype = nil
  21106. m.addmsgtype = nil
  21107. delete(m.clearedFields, msg.FieldMsgtype)
  21108. }
  21109. // SetMsg sets the "msg" field.
  21110. func (m *MsgMutation) SetMsg(s string) {
  21111. m.msg = &s
  21112. }
  21113. // Msg returns the value of the "msg" field in the mutation.
  21114. func (m *MsgMutation) Msg() (r string, exists bool) {
  21115. v := m.msg
  21116. if v == nil {
  21117. return
  21118. }
  21119. return *v, true
  21120. }
  21121. // OldMsg returns the old "msg" field's value of the Msg entity.
  21122. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21124. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  21125. if !m.op.Is(OpUpdateOne) {
  21126. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  21127. }
  21128. if m.id == nil || m.oldValue == nil {
  21129. return v, errors.New("OldMsg requires an ID field in the mutation")
  21130. }
  21131. oldValue, err := m.oldValue(ctx)
  21132. if err != nil {
  21133. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  21134. }
  21135. return oldValue.Msg, nil
  21136. }
  21137. // ClearMsg clears the value of the "msg" field.
  21138. func (m *MsgMutation) ClearMsg() {
  21139. m.msg = nil
  21140. m.clearedFields[msg.FieldMsg] = struct{}{}
  21141. }
  21142. // MsgCleared returns if the "msg" field was cleared in this mutation.
  21143. func (m *MsgMutation) MsgCleared() bool {
  21144. _, ok := m.clearedFields[msg.FieldMsg]
  21145. return ok
  21146. }
  21147. // ResetMsg resets all changes to the "msg" field.
  21148. func (m *MsgMutation) ResetMsg() {
  21149. m.msg = nil
  21150. delete(m.clearedFields, msg.FieldMsg)
  21151. }
  21152. // SetBatchNo sets the "batch_no" field.
  21153. func (m *MsgMutation) SetBatchNo(s string) {
  21154. m.batch_no = &s
  21155. }
  21156. // BatchNo returns the value of the "batch_no" field in the mutation.
  21157. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  21158. v := m.batch_no
  21159. if v == nil {
  21160. return
  21161. }
  21162. return *v, true
  21163. }
  21164. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  21165. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21167. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  21168. if !m.op.Is(OpUpdateOne) {
  21169. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  21170. }
  21171. if m.id == nil || m.oldValue == nil {
  21172. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  21173. }
  21174. oldValue, err := m.oldValue(ctx)
  21175. if err != nil {
  21176. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  21177. }
  21178. return oldValue.BatchNo, nil
  21179. }
  21180. // ClearBatchNo clears the value of the "batch_no" field.
  21181. func (m *MsgMutation) ClearBatchNo() {
  21182. m.batch_no = nil
  21183. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  21184. }
  21185. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  21186. func (m *MsgMutation) BatchNoCleared() bool {
  21187. _, ok := m.clearedFields[msg.FieldBatchNo]
  21188. return ok
  21189. }
  21190. // ResetBatchNo resets all changes to the "batch_no" field.
  21191. func (m *MsgMutation) ResetBatchNo() {
  21192. m.batch_no = nil
  21193. delete(m.clearedFields, msg.FieldBatchNo)
  21194. }
  21195. // SetCc sets the "cc" field.
  21196. func (m *MsgMutation) SetCc(s string) {
  21197. m.cc = &s
  21198. }
  21199. // Cc returns the value of the "cc" field in the mutation.
  21200. func (m *MsgMutation) Cc() (r string, exists bool) {
  21201. v := m.cc
  21202. if v == nil {
  21203. return
  21204. }
  21205. return *v, true
  21206. }
  21207. // OldCc returns the old "cc" field's value of the Msg entity.
  21208. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21210. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  21211. if !m.op.Is(OpUpdateOne) {
  21212. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  21213. }
  21214. if m.id == nil || m.oldValue == nil {
  21215. return v, errors.New("OldCc requires an ID field in the mutation")
  21216. }
  21217. oldValue, err := m.oldValue(ctx)
  21218. if err != nil {
  21219. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  21220. }
  21221. return oldValue.Cc, nil
  21222. }
  21223. // ResetCc resets all changes to the "cc" field.
  21224. func (m *MsgMutation) ResetCc() {
  21225. m.cc = nil
  21226. }
  21227. // SetPhone sets the "phone" field.
  21228. func (m *MsgMutation) SetPhone(s string) {
  21229. m.phone = &s
  21230. }
  21231. // Phone returns the value of the "phone" field in the mutation.
  21232. func (m *MsgMutation) Phone() (r string, exists bool) {
  21233. v := m.phone
  21234. if v == nil {
  21235. return
  21236. }
  21237. return *v, true
  21238. }
  21239. // OldPhone returns the old "phone" field's value of the Msg entity.
  21240. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21242. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  21243. if !m.op.Is(OpUpdateOne) {
  21244. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  21245. }
  21246. if m.id == nil || m.oldValue == nil {
  21247. return v, errors.New("OldPhone requires an ID field in the mutation")
  21248. }
  21249. oldValue, err := m.oldValue(ctx)
  21250. if err != nil {
  21251. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  21252. }
  21253. return oldValue.Phone, nil
  21254. }
  21255. // ResetPhone resets all changes to the "phone" field.
  21256. func (m *MsgMutation) ResetPhone() {
  21257. m.phone = nil
  21258. }
  21259. // Where appends a list predicates to the MsgMutation builder.
  21260. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  21261. m.predicates = append(m.predicates, ps...)
  21262. }
  21263. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  21264. // users can use type-assertion to append predicates that do not depend on any generated package.
  21265. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  21266. p := make([]predicate.Msg, len(ps))
  21267. for i := range ps {
  21268. p[i] = ps[i]
  21269. }
  21270. m.Where(p...)
  21271. }
  21272. // Op returns the operation name.
  21273. func (m *MsgMutation) Op() Op {
  21274. return m.op
  21275. }
  21276. // SetOp allows setting the mutation operation.
  21277. func (m *MsgMutation) SetOp(op Op) {
  21278. m.op = op
  21279. }
  21280. // Type returns the node type of this mutation (Msg).
  21281. func (m *MsgMutation) Type() string {
  21282. return m.typ
  21283. }
  21284. // Fields returns all fields that were changed during this mutation. Note that in
  21285. // order to get all numeric fields that were incremented/decremented, call
  21286. // AddedFields().
  21287. func (m *MsgMutation) Fields() []string {
  21288. fields := make([]string, 0, 11)
  21289. if m.created_at != nil {
  21290. fields = append(fields, msg.FieldCreatedAt)
  21291. }
  21292. if m.updated_at != nil {
  21293. fields = append(fields, msg.FieldUpdatedAt)
  21294. }
  21295. if m.deleted_at != nil {
  21296. fields = append(fields, msg.FieldDeletedAt)
  21297. }
  21298. if m.status != nil {
  21299. fields = append(fields, msg.FieldStatus)
  21300. }
  21301. if m.fromwxid != nil {
  21302. fields = append(fields, msg.FieldFromwxid)
  21303. }
  21304. if m.toid != nil {
  21305. fields = append(fields, msg.FieldToid)
  21306. }
  21307. if m.msgtype != nil {
  21308. fields = append(fields, msg.FieldMsgtype)
  21309. }
  21310. if m.msg != nil {
  21311. fields = append(fields, msg.FieldMsg)
  21312. }
  21313. if m.batch_no != nil {
  21314. fields = append(fields, msg.FieldBatchNo)
  21315. }
  21316. if m.cc != nil {
  21317. fields = append(fields, msg.FieldCc)
  21318. }
  21319. if m.phone != nil {
  21320. fields = append(fields, msg.FieldPhone)
  21321. }
  21322. return fields
  21323. }
  21324. // Field returns the value of a field with the given name. The second boolean
  21325. // return value indicates that this field was not set, or was not defined in the
  21326. // schema.
  21327. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  21328. switch name {
  21329. case msg.FieldCreatedAt:
  21330. return m.CreatedAt()
  21331. case msg.FieldUpdatedAt:
  21332. return m.UpdatedAt()
  21333. case msg.FieldDeletedAt:
  21334. return m.DeletedAt()
  21335. case msg.FieldStatus:
  21336. return m.Status()
  21337. case msg.FieldFromwxid:
  21338. return m.Fromwxid()
  21339. case msg.FieldToid:
  21340. return m.Toid()
  21341. case msg.FieldMsgtype:
  21342. return m.Msgtype()
  21343. case msg.FieldMsg:
  21344. return m.Msg()
  21345. case msg.FieldBatchNo:
  21346. return m.BatchNo()
  21347. case msg.FieldCc:
  21348. return m.Cc()
  21349. case msg.FieldPhone:
  21350. return m.Phone()
  21351. }
  21352. return nil, false
  21353. }
  21354. // OldField returns the old value of the field from the database. An error is
  21355. // returned if the mutation operation is not UpdateOne, or the query to the
  21356. // database failed.
  21357. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21358. switch name {
  21359. case msg.FieldCreatedAt:
  21360. return m.OldCreatedAt(ctx)
  21361. case msg.FieldUpdatedAt:
  21362. return m.OldUpdatedAt(ctx)
  21363. case msg.FieldDeletedAt:
  21364. return m.OldDeletedAt(ctx)
  21365. case msg.FieldStatus:
  21366. return m.OldStatus(ctx)
  21367. case msg.FieldFromwxid:
  21368. return m.OldFromwxid(ctx)
  21369. case msg.FieldToid:
  21370. return m.OldToid(ctx)
  21371. case msg.FieldMsgtype:
  21372. return m.OldMsgtype(ctx)
  21373. case msg.FieldMsg:
  21374. return m.OldMsg(ctx)
  21375. case msg.FieldBatchNo:
  21376. return m.OldBatchNo(ctx)
  21377. case msg.FieldCc:
  21378. return m.OldCc(ctx)
  21379. case msg.FieldPhone:
  21380. return m.OldPhone(ctx)
  21381. }
  21382. return nil, fmt.Errorf("unknown Msg field %s", name)
  21383. }
  21384. // SetField sets the value of a field with the given name. It returns an error if
  21385. // the field is not defined in the schema, or if the type mismatched the field
  21386. // type.
  21387. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21388. switch name {
  21389. case msg.FieldCreatedAt:
  21390. v, ok := value.(time.Time)
  21391. if !ok {
  21392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21393. }
  21394. m.SetCreatedAt(v)
  21395. return nil
  21396. case msg.FieldUpdatedAt:
  21397. v, ok := value.(time.Time)
  21398. if !ok {
  21399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21400. }
  21401. m.SetUpdatedAt(v)
  21402. return nil
  21403. case msg.FieldDeletedAt:
  21404. v, ok := value.(time.Time)
  21405. if !ok {
  21406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21407. }
  21408. m.SetDeletedAt(v)
  21409. return nil
  21410. case msg.FieldStatus:
  21411. v, ok := value.(uint8)
  21412. if !ok {
  21413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21414. }
  21415. m.SetStatus(v)
  21416. return nil
  21417. case msg.FieldFromwxid:
  21418. v, ok := value.(string)
  21419. if !ok {
  21420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21421. }
  21422. m.SetFromwxid(v)
  21423. return nil
  21424. case msg.FieldToid:
  21425. v, ok := value.(string)
  21426. if !ok {
  21427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21428. }
  21429. m.SetToid(v)
  21430. return nil
  21431. case msg.FieldMsgtype:
  21432. v, ok := value.(int32)
  21433. if !ok {
  21434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21435. }
  21436. m.SetMsgtype(v)
  21437. return nil
  21438. case msg.FieldMsg:
  21439. v, ok := value.(string)
  21440. if !ok {
  21441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21442. }
  21443. m.SetMsg(v)
  21444. return nil
  21445. case msg.FieldBatchNo:
  21446. v, ok := value.(string)
  21447. if !ok {
  21448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21449. }
  21450. m.SetBatchNo(v)
  21451. return nil
  21452. case msg.FieldCc:
  21453. v, ok := value.(string)
  21454. if !ok {
  21455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21456. }
  21457. m.SetCc(v)
  21458. return nil
  21459. case msg.FieldPhone:
  21460. v, ok := value.(string)
  21461. if !ok {
  21462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21463. }
  21464. m.SetPhone(v)
  21465. return nil
  21466. }
  21467. return fmt.Errorf("unknown Msg field %s", name)
  21468. }
  21469. // AddedFields returns all numeric fields that were incremented/decremented during
  21470. // this mutation.
  21471. func (m *MsgMutation) AddedFields() []string {
  21472. var fields []string
  21473. if m.addstatus != nil {
  21474. fields = append(fields, msg.FieldStatus)
  21475. }
  21476. if m.addmsgtype != nil {
  21477. fields = append(fields, msg.FieldMsgtype)
  21478. }
  21479. return fields
  21480. }
  21481. // AddedField returns the numeric value that was incremented/decremented on a field
  21482. // with the given name. The second boolean return value indicates that this field
  21483. // was not set, or was not defined in the schema.
  21484. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21485. switch name {
  21486. case msg.FieldStatus:
  21487. return m.AddedStatus()
  21488. case msg.FieldMsgtype:
  21489. return m.AddedMsgtype()
  21490. }
  21491. return nil, false
  21492. }
  21493. // AddField adds the value to the field with the given name. It returns an error if
  21494. // the field is not defined in the schema, or if the type mismatched the field
  21495. // type.
  21496. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21497. switch name {
  21498. case msg.FieldStatus:
  21499. v, ok := value.(int8)
  21500. if !ok {
  21501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21502. }
  21503. m.AddStatus(v)
  21504. return nil
  21505. case msg.FieldMsgtype:
  21506. v, ok := value.(int32)
  21507. if !ok {
  21508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21509. }
  21510. m.AddMsgtype(v)
  21511. return nil
  21512. }
  21513. return fmt.Errorf("unknown Msg numeric field %s", name)
  21514. }
  21515. // ClearedFields returns all nullable fields that were cleared during this
  21516. // mutation.
  21517. func (m *MsgMutation) ClearedFields() []string {
  21518. var fields []string
  21519. if m.FieldCleared(msg.FieldDeletedAt) {
  21520. fields = append(fields, msg.FieldDeletedAt)
  21521. }
  21522. if m.FieldCleared(msg.FieldStatus) {
  21523. fields = append(fields, msg.FieldStatus)
  21524. }
  21525. if m.FieldCleared(msg.FieldFromwxid) {
  21526. fields = append(fields, msg.FieldFromwxid)
  21527. }
  21528. if m.FieldCleared(msg.FieldToid) {
  21529. fields = append(fields, msg.FieldToid)
  21530. }
  21531. if m.FieldCleared(msg.FieldMsgtype) {
  21532. fields = append(fields, msg.FieldMsgtype)
  21533. }
  21534. if m.FieldCleared(msg.FieldMsg) {
  21535. fields = append(fields, msg.FieldMsg)
  21536. }
  21537. if m.FieldCleared(msg.FieldBatchNo) {
  21538. fields = append(fields, msg.FieldBatchNo)
  21539. }
  21540. return fields
  21541. }
  21542. // FieldCleared returns a boolean indicating if a field with the given name was
  21543. // cleared in this mutation.
  21544. func (m *MsgMutation) FieldCleared(name string) bool {
  21545. _, ok := m.clearedFields[name]
  21546. return ok
  21547. }
  21548. // ClearField clears the value of the field with the given name. It returns an
  21549. // error if the field is not defined in the schema.
  21550. func (m *MsgMutation) ClearField(name string) error {
  21551. switch name {
  21552. case msg.FieldDeletedAt:
  21553. m.ClearDeletedAt()
  21554. return nil
  21555. case msg.FieldStatus:
  21556. m.ClearStatus()
  21557. return nil
  21558. case msg.FieldFromwxid:
  21559. m.ClearFromwxid()
  21560. return nil
  21561. case msg.FieldToid:
  21562. m.ClearToid()
  21563. return nil
  21564. case msg.FieldMsgtype:
  21565. m.ClearMsgtype()
  21566. return nil
  21567. case msg.FieldMsg:
  21568. m.ClearMsg()
  21569. return nil
  21570. case msg.FieldBatchNo:
  21571. m.ClearBatchNo()
  21572. return nil
  21573. }
  21574. return fmt.Errorf("unknown Msg nullable field %s", name)
  21575. }
  21576. // ResetField resets all changes in the mutation for the field with the given name.
  21577. // It returns an error if the field is not defined in the schema.
  21578. func (m *MsgMutation) ResetField(name string) error {
  21579. switch name {
  21580. case msg.FieldCreatedAt:
  21581. m.ResetCreatedAt()
  21582. return nil
  21583. case msg.FieldUpdatedAt:
  21584. m.ResetUpdatedAt()
  21585. return nil
  21586. case msg.FieldDeletedAt:
  21587. m.ResetDeletedAt()
  21588. return nil
  21589. case msg.FieldStatus:
  21590. m.ResetStatus()
  21591. return nil
  21592. case msg.FieldFromwxid:
  21593. m.ResetFromwxid()
  21594. return nil
  21595. case msg.FieldToid:
  21596. m.ResetToid()
  21597. return nil
  21598. case msg.FieldMsgtype:
  21599. m.ResetMsgtype()
  21600. return nil
  21601. case msg.FieldMsg:
  21602. m.ResetMsg()
  21603. return nil
  21604. case msg.FieldBatchNo:
  21605. m.ResetBatchNo()
  21606. return nil
  21607. case msg.FieldCc:
  21608. m.ResetCc()
  21609. return nil
  21610. case msg.FieldPhone:
  21611. m.ResetPhone()
  21612. return nil
  21613. }
  21614. return fmt.Errorf("unknown Msg field %s", name)
  21615. }
  21616. // AddedEdges returns all edge names that were set/added in this mutation.
  21617. func (m *MsgMutation) AddedEdges() []string {
  21618. edges := make([]string, 0, 0)
  21619. return edges
  21620. }
  21621. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21622. // name in this mutation.
  21623. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21624. return nil
  21625. }
  21626. // RemovedEdges returns all edge names that were removed in this mutation.
  21627. func (m *MsgMutation) RemovedEdges() []string {
  21628. edges := make([]string, 0, 0)
  21629. return edges
  21630. }
  21631. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21632. // the given name in this mutation.
  21633. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21634. return nil
  21635. }
  21636. // ClearedEdges returns all edge names that were cleared in this mutation.
  21637. func (m *MsgMutation) ClearedEdges() []string {
  21638. edges := make([]string, 0, 0)
  21639. return edges
  21640. }
  21641. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21642. // was cleared in this mutation.
  21643. func (m *MsgMutation) EdgeCleared(name string) bool {
  21644. return false
  21645. }
  21646. // ClearEdge clears the value of the edge with the given name. It returns an error
  21647. // if that edge is not defined in the schema.
  21648. func (m *MsgMutation) ClearEdge(name string) error {
  21649. return fmt.Errorf("unknown Msg unique edge %s", name)
  21650. }
  21651. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21652. // It returns an error if the edge is not defined in the schema.
  21653. func (m *MsgMutation) ResetEdge(name string) error {
  21654. return fmt.Errorf("unknown Msg edge %s", name)
  21655. }
  21656. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21657. type PayRechargeMutation struct {
  21658. config
  21659. op Op
  21660. typ string
  21661. id *uint64
  21662. created_at *time.Time
  21663. updated_at *time.Time
  21664. deleted_at *time.Time
  21665. user_id *string
  21666. number *float32
  21667. addnumber *float32
  21668. status *int
  21669. addstatus *int
  21670. money *float32
  21671. addmoney *float32
  21672. out_trade_no *string
  21673. organization_id *uint64
  21674. addorganization_id *int64
  21675. clearedFields map[string]struct{}
  21676. done bool
  21677. oldValue func(context.Context) (*PayRecharge, error)
  21678. predicates []predicate.PayRecharge
  21679. }
  21680. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21681. // payrechargeOption allows management of the mutation configuration using functional options.
  21682. type payrechargeOption func(*PayRechargeMutation)
  21683. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21684. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21685. m := &PayRechargeMutation{
  21686. config: c,
  21687. op: op,
  21688. typ: TypePayRecharge,
  21689. clearedFields: make(map[string]struct{}),
  21690. }
  21691. for _, opt := range opts {
  21692. opt(m)
  21693. }
  21694. return m
  21695. }
  21696. // withPayRechargeID sets the ID field of the mutation.
  21697. func withPayRechargeID(id uint64) payrechargeOption {
  21698. return func(m *PayRechargeMutation) {
  21699. var (
  21700. err error
  21701. once sync.Once
  21702. value *PayRecharge
  21703. )
  21704. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21705. once.Do(func() {
  21706. if m.done {
  21707. err = errors.New("querying old values post mutation is not allowed")
  21708. } else {
  21709. value, err = m.Client().PayRecharge.Get(ctx, id)
  21710. }
  21711. })
  21712. return value, err
  21713. }
  21714. m.id = &id
  21715. }
  21716. }
  21717. // withPayRecharge sets the old PayRecharge of the mutation.
  21718. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21719. return func(m *PayRechargeMutation) {
  21720. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21721. return node, nil
  21722. }
  21723. m.id = &node.ID
  21724. }
  21725. }
  21726. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21727. // executed in a transaction (ent.Tx), a transactional client is returned.
  21728. func (m PayRechargeMutation) Client() *Client {
  21729. client := &Client{config: m.config}
  21730. client.init()
  21731. return client
  21732. }
  21733. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21734. // it returns an error otherwise.
  21735. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21736. if _, ok := m.driver.(*txDriver); !ok {
  21737. return nil, errors.New("ent: mutation is not running in a transaction")
  21738. }
  21739. tx := &Tx{config: m.config}
  21740. tx.init()
  21741. return tx, nil
  21742. }
  21743. // SetID sets the value of the id field. Note that this
  21744. // operation is only accepted on creation of PayRecharge entities.
  21745. func (m *PayRechargeMutation) SetID(id uint64) {
  21746. m.id = &id
  21747. }
  21748. // ID returns the ID value in the mutation. Note that the ID is only available
  21749. // if it was provided to the builder or after it was returned from the database.
  21750. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21751. if m.id == nil {
  21752. return
  21753. }
  21754. return *m.id, true
  21755. }
  21756. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21757. // That means, if the mutation is applied within a transaction with an isolation level such
  21758. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21759. // or updated by the mutation.
  21760. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21761. switch {
  21762. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21763. id, exists := m.ID()
  21764. if exists {
  21765. return []uint64{id}, nil
  21766. }
  21767. fallthrough
  21768. case m.op.Is(OpUpdate | OpDelete):
  21769. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21770. default:
  21771. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21772. }
  21773. }
  21774. // SetCreatedAt sets the "created_at" field.
  21775. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21776. m.created_at = &t
  21777. }
  21778. // CreatedAt returns the value of the "created_at" field in the mutation.
  21779. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21780. v := m.created_at
  21781. if v == nil {
  21782. return
  21783. }
  21784. return *v, true
  21785. }
  21786. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21787. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21789. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21790. if !m.op.Is(OpUpdateOne) {
  21791. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21792. }
  21793. if m.id == nil || m.oldValue == nil {
  21794. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21795. }
  21796. oldValue, err := m.oldValue(ctx)
  21797. if err != nil {
  21798. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21799. }
  21800. return oldValue.CreatedAt, nil
  21801. }
  21802. // ResetCreatedAt resets all changes to the "created_at" field.
  21803. func (m *PayRechargeMutation) ResetCreatedAt() {
  21804. m.created_at = nil
  21805. }
  21806. // SetUpdatedAt sets the "updated_at" field.
  21807. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21808. m.updated_at = &t
  21809. }
  21810. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21811. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21812. v := m.updated_at
  21813. if v == nil {
  21814. return
  21815. }
  21816. return *v, true
  21817. }
  21818. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21819. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21821. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21822. if !m.op.Is(OpUpdateOne) {
  21823. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21824. }
  21825. if m.id == nil || m.oldValue == nil {
  21826. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21827. }
  21828. oldValue, err := m.oldValue(ctx)
  21829. if err != nil {
  21830. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21831. }
  21832. return oldValue.UpdatedAt, nil
  21833. }
  21834. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21835. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21836. m.updated_at = nil
  21837. }
  21838. // SetDeletedAt sets the "deleted_at" field.
  21839. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21840. m.deleted_at = &t
  21841. }
  21842. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21843. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21844. v := m.deleted_at
  21845. if v == nil {
  21846. return
  21847. }
  21848. return *v, true
  21849. }
  21850. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21851. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21853. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21854. if !m.op.Is(OpUpdateOne) {
  21855. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21856. }
  21857. if m.id == nil || m.oldValue == nil {
  21858. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21859. }
  21860. oldValue, err := m.oldValue(ctx)
  21861. if err != nil {
  21862. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21863. }
  21864. return oldValue.DeletedAt, nil
  21865. }
  21866. // ClearDeletedAt clears the value of the "deleted_at" field.
  21867. func (m *PayRechargeMutation) ClearDeletedAt() {
  21868. m.deleted_at = nil
  21869. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21870. }
  21871. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21872. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21873. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21874. return ok
  21875. }
  21876. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21877. func (m *PayRechargeMutation) ResetDeletedAt() {
  21878. m.deleted_at = nil
  21879. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21880. }
  21881. // SetUserID sets the "user_id" field.
  21882. func (m *PayRechargeMutation) SetUserID(s string) {
  21883. m.user_id = &s
  21884. }
  21885. // UserID returns the value of the "user_id" field in the mutation.
  21886. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21887. v := m.user_id
  21888. if v == nil {
  21889. return
  21890. }
  21891. return *v, true
  21892. }
  21893. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21894. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21896. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21897. if !m.op.Is(OpUpdateOne) {
  21898. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21899. }
  21900. if m.id == nil || m.oldValue == nil {
  21901. return v, errors.New("OldUserID requires an ID field in the mutation")
  21902. }
  21903. oldValue, err := m.oldValue(ctx)
  21904. if err != nil {
  21905. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21906. }
  21907. return oldValue.UserID, nil
  21908. }
  21909. // ResetUserID resets all changes to the "user_id" field.
  21910. func (m *PayRechargeMutation) ResetUserID() {
  21911. m.user_id = nil
  21912. }
  21913. // SetNumber sets the "number" field.
  21914. func (m *PayRechargeMutation) SetNumber(f float32) {
  21915. m.number = &f
  21916. m.addnumber = nil
  21917. }
  21918. // Number returns the value of the "number" field in the mutation.
  21919. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21920. v := m.number
  21921. if v == nil {
  21922. return
  21923. }
  21924. return *v, true
  21925. }
  21926. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21927. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21929. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21930. if !m.op.Is(OpUpdateOne) {
  21931. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21932. }
  21933. if m.id == nil || m.oldValue == nil {
  21934. return v, errors.New("OldNumber requires an ID field in the mutation")
  21935. }
  21936. oldValue, err := m.oldValue(ctx)
  21937. if err != nil {
  21938. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21939. }
  21940. return oldValue.Number, nil
  21941. }
  21942. // AddNumber adds f to the "number" field.
  21943. func (m *PayRechargeMutation) AddNumber(f float32) {
  21944. if m.addnumber != nil {
  21945. *m.addnumber += f
  21946. } else {
  21947. m.addnumber = &f
  21948. }
  21949. }
  21950. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21951. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21952. v := m.addnumber
  21953. if v == nil {
  21954. return
  21955. }
  21956. return *v, true
  21957. }
  21958. // ResetNumber resets all changes to the "number" field.
  21959. func (m *PayRechargeMutation) ResetNumber() {
  21960. m.number = nil
  21961. m.addnumber = nil
  21962. }
  21963. // SetStatus sets the "status" field.
  21964. func (m *PayRechargeMutation) SetStatus(i int) {
  21965. m.status = &i
  21966. m.addstatus = nil
  21967. }
  21968. // Status returns the value of the "status" field in the mutation.
  21969. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21970. v := m.status
  21971. if v == nil {
  21972. return
  21973. }
  21974. return *v, true
  21975. }
  21976. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21977. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21979. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21980. if !m.op.Is(OpUpdateOne) {
  21981. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21982. }
  21983. if m.id == nil || m.oldValue == nil {
  21984. return v, errors.New("OldStatus requires an ID field in the mutation")
  21985. }
  21986. oldValue, err := m.oldValue(ctx)
  21987. if err != nil {
  21988. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21989. }
  21990. return oldValue.Status, nil
  21991. }
  21992. // AddStatus adds i to the "status" field.
  21993. func (m *PayRechargeMutation) AddStatus(i int) {
  21994. if m.addstatus != nil {
  21995. *m.addstatus += i
  21996. } else {
  21997. m.addstatus = &i
  21998. }
  21999. }
  22000. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22001. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  22002. v := m.addstatus
  22003. if v == nil {
  22004. return
  22005. }
  22006. return *v, true
  22007. }
  22008. // ClearStatus clears the value of the "status" field.
  22009. func (m *PayRechargeMutation) ClearStatus() {
  22010. m.status = nil
  22011. m.addstatus = nil
  22012. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  22013. }
  22014. // StatusCleared returns if the "status" field was cleared in this mutation.
  22015. func (m *PayRechargeMutation) StatusCleared() bool {
  22016. _, ok := m.clearedFields[payrecharge.FieldStatus]
  22017. return ok
  22018. }
  22019. // ResetStatus resets all changes to the "status" field.
  22020. func (m *PayRechargeMutation) ResetStatus() {
  22021. m.status = nil
  22022. m.addstatus = nil
  22023. delete(m.clearedFields, payrecharge.FieldStatus)
  22024. }
  22025. // SetMoney sets the "money" field.
  22026. func (m *PayRechargeMutation) SetMoney(f float32) {
  22027. m.money = &f
  22028. m.addmoney = nil
  22029. }
  22030. // Money returns the value of the "money" field in the mutation.
  22031. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  22032. v := m.money
  22033. if v == nil {
  22034. return
  22035. }
  22036. return *v, true
  22037. }
  22038. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  22039. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22041. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  22042. if !m.op.Is(OpUpdateOne) {
  22043. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  22044. }
  22045. if m.id == nil || m.oldValue == nil {
  22046. return v, errors.New("OldMoney requires an ID field in the mutation")
  22047. }
  22048. oldValue, err := m.oldValue(ctx)
  22049. if err != nil {
  22050. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  22051. }
  22052. return oldValue.Money, nil
  22053. }
  22054. // AddMoney adds f to the "money" field.
  22055. func (m *PayRechargeMutation) AddMoney(f float32) {
  22056. if m.addmoney != nil {
  22057. *m.addmoney += f
  22058. } else {
  22059. m.addmoney = &f
  22060. }
  22061. }
  22062. // AddedMoney returns the value that was added to the "money" field in this mutation.
  22063. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  22064. v := m.addmoney
  22065. if v == nil {
  22066. return
  22067. }
  22068. return *v, true
  22069. }
  22070. // ClearMoney clears the value of the "money" field.
  22071. func (m *PayRechargeMutation) ClearMoney() {
  22072. m.money = nil
  22073. m.addmoney = nil
  22074. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  22075. }
  22076. // MoneyCleared returns if the "money" field was cleared in this mutation.
  22077. func (m *PayRechargeMutation) MoneyCleared() bool {
  22078. _, ok := m.clearedFields[payrecharge.FieldMoney]
  22079. return ok
  22080. }
  22081. // ResetMoney resets all changes to the "money" field.
  22082. func (m *PayRechargeMutation) ResetMoney() {
  22083. m.money = nil
  22084. m.addmoney = nil
  22085. delete(m.clearedFields, payrecharge.FieldMoney)
  22086. }
  22087. // SetOutTradeNo sets the "out_trade_no" field.
  22088. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  22089. m.out_trade_no = &s
  22090. }
  22091. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  22092. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  22093. v := m.out_trade_no
  22094. if v == nil {
  22095. return
  22096. }
  22097. return *v, true
  22098. }
  22099. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  22100. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22102. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  22103. if !m.op.Is(OpUpdateOne) {
  22104. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  22105. }
  22106. if m.id == nil || m.oldValue == nil {
  22107. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  22108. }
  22109. oldValue, err := m.oldValue(ctx)
  22110. if err != nil {
  22111. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  22112. }
  22113. return oldValue.OutTradeNo, nil
  22114. }
  22115. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  22116. func (m *PayRechargeMutation) ClearOutTradeNo() {
  22117. m.out_trade_no = nil
  22118. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  22119. }
  22120. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  22121. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  22122. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  22123. return ok
  22124. }
  22125. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  22126. func (m *PayRechargeMutation) ResetOutTradeNo() {
  22127. m.out_trade_no = nil
  22128. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  22129. }
  22130. // SetOrganizationID sets the "organization_id" field.
  22131. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  22132. m.organization_id = &u
  22133. m.addorganization_id = nil
  22134. }
  22135. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22136. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  22137. v := m.organization_id
  22138. if v == nil {
  22139. return
  22140. }
  22141. return *v, true
  22142. }
  22143. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  22144. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22146. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22147. if !m.op.Is(OpUpdateOne) {
  22148. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22149. }
  22150. if m.id == nil || m.oldValue == nil {
  22151. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22152. }
  22153. oldValue, err := m.oldValue(ctx)
  22154. if err != nil {
  22155. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22156. }
  22157. return oldValue.OrganizationID, nil
  22158. }
  22159. // AddOrganizationID adds u to the "organization_id" field.
  22160. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  22161. if m.addorganization_id != nil {
  22162. *m.addorganization_id += u
  22163. } else {
  22164. m.addorganization_id = &u
  22165. }
  22166. }
  22167. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22168. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  22169. v := m.addorganization_id
  22170. if v == nil {
  22171. return
  22172. }
  22173. return *v, true
  22174. }
  22175. // ResetOrganizationID resets all changes to the "organization_id" field.
  22176. func (m *PayRechargeMutation) ResetOrganizationID() {
  22177. m.organization_id = nil
  22178. m.addorganization_id = nil
  22179. }
  22180. // Where appends a list predicates to the PayRechargeMutation builder.
  22181. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  22182. m.predicates = append(m.predicates, ps...)
  22183. }
  22184. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  22185. // users can use type-assertion to append predicates that do not depend on any generated package.
  22186. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  22187. p := make([]predicate.PayRecharge, len(ps))
  22188. for i := range ps {
  22189. p[i] = ps[i]
  22190. }
  22191. m.Where(p...)
  22192. }
  22193. // Op returns the operation name.
  22194. func (m *PayRechargeMutation) Op() Op {
  22195. return m.op
  22196. }
  22197. // SetOp allows setting the mutation operation.
  22198. func (m *PayRechargeMutation) SetOp(op Op) {
  22199. m.op = op
  22200. }
  22201. // Type returns the node type of this mutation (PayRecharge).
  22202. func (m *PayRechargeMutation) Type() string {
  22203. return m.typ
  22204. }
  22205. // Fields returns all fields that were changed during this mutation. Note that in
  22206. // order to get all numeric fields that were incremented/decremented, call
  22207. // AddedFields().
  22208. func (m *PayRechargeMutation) Fields() []string {
  22209. fields := make([]string, 0, 9)
  22210. if m.created_at != nil {
  22211. fields = append(fields, payrecharge.FieldCreatedAt)
  22212. }
  22213. if m.updated_at != nil {
  22214. fields = append(fields, payrecharge.FieldUpdatedAt)
  22215. }
  22216. if m.deleted_at != nil {
  22217. fields = append(fields, payrecharge.FieldDeletedAt)
  22218. }
  22219. if m.user_id != nil {
  22220. fields = append(fields, payrecharge.FieldUserID)
  22221. }
  22222. if m.number != nil {
  22223. fields = append(fields, payrecharge.FieldNumber)
  22224. }
  22225. if m.status != nil {
  22226. fields = append(fields, payrecharge.FieldStatus)
  22227. }
  22228. if m.money != nil {
  22229. fields = append(fields, payrecharge.FieldMoney)
  22230. }
  22231. if m.out_trade_no != nil {
  22232. fields = append(fields, payrecharge.FieldOutTradeNo)
  22233. }
  22234. if m.organization_id != nil {
  22235. fields = append(fields, payrecharge.FieldOrganizationID)
  22236. }
  22237. return fields
  22238. }
  22239. // Field returns the value of a field with the given name. The second boolean
  22240. // return value indicates that this field was not set, or was not defined in the
  22241. // schema.
  22242. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  22243. switch name {
  22244. case payrecharge.FieldCreatedAt:
  22245. return m.CreatedAt()
  22246. case payrecharge.FieldUpdatedAt:
  22247. return m.UpdatedAt()
  22248. case payrecharge.FieldDeletedAt:
  22249. return m.DeletedAt()
  22250. case payrecharge.FieldUserID:
  22251. return m.UserID()
  22252. case payrecharge.FieldNumber:
  22253. return m.Number()
  22254. case payrecharge.FieldStatus:
  22255. return m.Status()
  22256. case payrecharge.FieldMoney:
  22257. return m.Money()
  22258. case payrecharge.FieldOutTradeNo:
  22259. return m.OutTradeNo()
  22260. case payrecharge.FieldOrganizationID:
  22261. return m.OrganizationID()
  22262. }
  22263. return nil, false
  22264. }
  22265. // OldField returns the old value of the field from the database. An error is
  22266. // returned if the mutation operation is not UpdateOne, or the query to the
  22267. // database failed.
  22268. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22269. switch name {
  22270. case payrecharge.FieldCreatedAt:
  22271. return m.OldCreatedAt(ctx)
  22272. case payrecharge.FieldUpdatedAt:
  22273. return m.OldUpdatedAt(ctx)
  22274. case payrecharge.FieldDeletedAt:
  22275. return m.OldDeletedAt(ctx)
  22276. case payrecharge.FieldUserID:
  22277. return m.OldUserID(ctx)
  22278. case payrecharge.FieldNumber:
  22279. return m.OldNumber(ctx)
  22280. case payrecharge.FieldStatus:
  22281. return m.OldStatus(ctx)
  22282. case payrecharge.FieldMoney:
  22283. return m.OldMoney(ctx)
  22284. case payrecharge.FieldOutTradeNo:
  22285. return m.OldOutTradeNo(ctx)
  22286. case payrecharge.FieldOrganizationID:
  22287. return m.OldOrganizationID(ctx)
  22288. }
  22289. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22290. }
  22291. // SetField sets the value of a field with the given name. It returns an error if
  22292. // the field is not defined in the schema, or if the type mismatched the field
  22293. // type.
  22294. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  22295. switch name {
  22296. case payrecharge.FieldCreatedAt:
  22297. v, ok := value.(time.Time)
  22298. if !ok {
  22299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22300. }
  22301. m.SetCreatedAt(v)
  22302. return nil
  22303. case payrecharge.FieldUpdatedAt:
  22304. v, ok := value.(time.Time)
  22305. if !ok {
  22306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22307. }
  22308. m.SetUpdatedAt(v)
  22309. return nil
  22310. case payrecharge.FieldDeletedAt:
  22311. v, ok := value.(time.Time)
  22312. if !ok {
  22313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22314. }
  22315. m.SetDeletedAt(v)
  22316. return nil
  22317. case payrecharge.FieldUserID:
  22318. v, ok := value.(string)
  22319. if !ok {
  22320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22321. }
  22322. m.SetUserID(v)
  22323. return nil
  22324. case payrecharge.FieldNumber:
  22325. v, ok := value.(float32)
  22326. if !ok {
  22327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22328. }
  22329. m.SetNumber(v)
  22330. return nil
  22331. case payrecharge.FieldStatus:
  22332. v, ok := value.(int)
  22333. if !ok {
  22334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22335. }
  22336. m.SetStatus(v)
  22337. return nil
  22338. case payrecharge.FieldMoney:
  22339. v, ok := value.(float32)
  22340. if !ok {
  22341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22342. }
  22343. m.SetMoney(v)
  22344. return nil
  22345. case payrecharge.FieldOutTradeNo:
  22346. v, ok := value.(string)
  22347. if !ok {
  22348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22349. }
  22350. m.SetOutTradeNo(v)
  22351. return nil
  22352. case payrecharge.FieldOrganizationID:
  22353. v, ok := value.(uint64)
  22354. if !ok {
  22355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22356. }
  22357. m.SetOrganizationID(v)
  22358. return nil
  22359. }
  22360. return fmt.Errorf("unknown PayRecharge field %s", name)
  22361. }
  22362. // AddedFields returns all numeric fields that were incremented/decremented during
  22363. // this mutation.
  22364. func (m *PayRechargeMutation) AddedFields() []string {
  22365. var fields []string
  22366. if m.addnumber != nil {
  22367. fields = append(fields, payrecharge.FieldNumber)
  22368. }
  22369. if m.addstatus != nil {
  22370. fields = append(fields, payrecharge.FieldStatus)
  22371. }
  22372. if m.addmoney != nil {
  22373. fields = append(fields, payrecharge.FieldMoney)
  22374. }
  22375. if m.addorganization_id != nil {
  22376. fields = append(fields, payrecharge.FieldOrganizationID)
  22377. }
  22378. return fields
  22379. }
  22380. // AddedField returns the numeric value that was incremented/decremented on a field
  22381. // with the given name. The second boolean return value indicates that this field
  22382. // was not set, or was not defined in the schema.
  22383. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22384. switch name {
  22385. case payrecharge.FieldNumber:
  22386. return m.AddedNumber()
  22387. case payrecharge.FieldStatus:
  22388. return m.AddedStatus()
  22389. case payrecharge.FieldMoney:
  22390. return m.AddedMoney()
  22391. case payrecharge.FieldOrganizationID:
  22392. return m.AddedOrganizationID()
  22393. }
  22394. return nil, false
  22395. }
  22396. // AddField adds the value to the field with the given name. It returns an error if
  22397. // the field is not defined in the schema, or if the type mismatched the field
  22398. // type.
  22399. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22400. switch name {
  22401. case payrecharge.FieldNumber:
  22402. v, ok := value.(float32)
  22403. if !ok {
  22404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22405. }
  22406. m.AddNumber(v)
  22407. return nil
  22408. case payrecharge.FieldStatus:
  22409. v, ok := value.(int)
  22410. if !ok {
  22411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22412. }
  22413. m.AddStatus(v)
  22414. return nil
  22415. case payrecharge.FieldMoney:
  22416. v, ok := value.(float32)
  22417. if !ok {
  22418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22419. }
  22420. m.AddMoney(v)
  22421. return nil
  22422. case payrecharge.FieldOrganizationID:
  22423. v, ok := value.(int64)
  22424. if !ok {
  22425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22426. }
  22427. m.AddOrganizationID(v)
  22428. return nil
  22429. }
  22430. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22431. }
  22432. // ClearedFields returns all nullable fields that were cleared during this
  22433. // mutation.
  22434. func (m *PayRechargeMutation) ClearedFields() []string {
  22435. var fields []string
  22436. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22437. fields = append(fields, payrecharge.FieldDeletedAt)
  22438. }
  22439. if m.FieldCleared(payrecharge.FieldStatus) {
  22440. fields = append(fields, payrecharge.FieldStatus)
  22441. }
  22442. if m.FieldCleared(payrecharge.FieldMoney) {
  22443. fields = append(fields, payrecharge.FieldMoney)
  22444. }
  22445. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22446. fields = append(fields, payrecharge.FieldOutTradeNo)
  22447. }
  22448. return fields
  22449. }
  22450. // FieldCleared returns a boolean indicating if a field with the given name was
  22451. // cleared in this mutation.
  22452. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22453. _, ok := m.clearedFields[name]
  22454. return ok
  22455. }
  22456. // ClearField clears the value of the field with the given name. It returns an
  22457. // error if the field is not defined in the schema.
  22458. func (m *PayRechargeMutation) ClearField(name string) error {
  22459. switch name {
  22460. case payrecharge.FieldDeletedAt:
  22461. m.ClearDeletedAt()
  22462. return nil
  22463. case payrecharge.FieldStatus:
  22464. m.ClearStatus()
  22465. return nil
  22466. case payrecharge.FieldMoney:
  22467. m.ClearMoney()
  22468. return nil
  22469. case payrecharge.FieldOutTradeNo:
  22470. m.ClearOutTradeNo()
  22471. return nil
  22472. }
  22473. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22474. }
  22475. // ResetField resets all changes in the mutation for the field with the given name.
  22476. // It returns an error if the field is not defined in the schema.
  22477. func (m *PayRechargeMutation) ResetField(name string) error {
  22478. switch name {
  22479. case payrecharge.FieldCreatedAt:
  22480. m.ResetCreatedAt()
  22481. return nil
  22482. case payrecharge.FieldUpdatedAt:
  22483. m.ResetUpdatedAt()
  22484. return nil
  22485. case payrecharge.FieldDeletedAt:
  22486. m.ResetDeletedAt()
  22487. return nil
  22488. case payrecharge.FieldUserID:
  22489. m.ResetUserID()
  22490. return nil
  22491. case payrecharge.FieldNumber:
  22492. m.ResetNumber()
  22493. return nil
  22494. case payrecharge.FieldStatus:
  22495. m.ResetStatus()
  22496. return nil
  22497. case payrecharge.FieldMoney:
  22498. m.ResetMoney()
  22499. return nil
  22500. case payrecharge.FieldOutTradeNo:
  22501. m.ResetOutTradeNo()
  22502. return nil
  22503. case payrecharge.FieldOrganizationID:
  22504. m.ResetOrganizationID()
  22505. return nil
  22506. }
  22507. return fmt.Errorf("unknown PayRecharge field %s", name)
  22508. }
  22509. // AddedEdges returns all edge names that were set/added in this mutation.
  22510. func (m *PayRechargeMutation) AddedEdges() []string {
  22511. edges := make([]string, 0, 0)
  22512. return edges
  22513. }
  22514. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22515. // name in this mutation.
  22516. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22517. return nil
  22518. }
  22519. // RemovedEdges returns all edge names that were removed in this mutation.
  22520. func (m *PayRechargeMutation) RemovedEdges() []string {
  22521. edges := make([]string, 0, 0)
  22522. return edges
  22523. }
  22524. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22525. // the given name in this mutation.
  22526. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22527. return nil
  22528. }
  22529. // ClearedEdges returns all edge names that were cleared in this mutation.
  22530. func (m *PayRechargeMutation) ClearedEdges() []string {
  22531. edges := make([]string, 0, 0)
  22532. return edges
  22533. }
  22534. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22535. // was cleared in this mutation.
  22536. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22537. return false
  22538. }
  22539. // ClearEdge clears the value of the edge with the given name. It returns an error
  22540. // if that edge is not defined in the schema.
  22541. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22542. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22543. }
  22544. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22545. // It returns an error if the edge is not defined in the schema.
  22546. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22547. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22548. }
  22549. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22550. type ServerMutation struct {
  22551. config
  22552. op Op
  22553. typ string
  22554. id *uint64
  22555. created_at *time.Time
  22556. updated_at *time.Time
  22557. status *uint8
  22558. addstatus *int8
  22559. deleted_at *time.Time
  22560. name *string
  22561. public_ip *string
  22562. private_ip *string
  22563. admin_port *string
  22564. clearedFields map[string]struct{}
  22565. wxs map[uint64]struct{}
  22566. removedwxs map[uint64]struct{}
  22567. clearedwxs bool
  22568. done bool
  22569. oldValue func(context.Context) (*Server, error)
  22570. predicates []predicate.Server
  22571. }
  22572. var _ ent.Mutation = (*ServerMutation)(nil)
  22573. // serverOption allows management of the mutation configuration using functional options.
  22574. type serverOption func(*ServerMutation)
  22575. // newServerMutation creates new mutation for the Server entity.
  22576. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22577. m := &ServerMutation{
  22578. config: c,
  22579. op: op,
  22580. typ: TypeServer,
  22581. clearedFields: make(map[string]struct{}),
  22582. }
  22583. for _, opt := range opts {
  22584. opt(m)
  22585. }
  22586. return m
  22587. }
  22588. // withServerID sets the ID field of the mutation.
  22589. func withServerID(id uint64) serverOption {
  22590. return func(m *ServerMutation) {
  22591. var (
  22592. err error
  22593. once sync.Once
  22594. value *Server
  22595. )
  22596. m.oldValue = func(ctx context.Context) (*Server, error) {
  22597. once.Do(func() {
  22598. if m.done {
  22599. err = errors.New("querying old values post mutation is not allowed")
  22600. } else {
  22601. value, err = m.Client().Server.Get(ctx, id)
  22602. }
  22603. })
  22604. return value, err
  22605. }
  22606. m.id = &id
  22607. }
  22608. }
  22609. // withServer sets the old Server of the mutation.
  22610. func withServer(node *Server) serverOption {
  22611. return func(m *ServerMutation) {
  22612. m.oldValue = func(context.Context) (*Server, error) {
  22613. return node, nil
  22614. }
  22615. m.id = &node.ID
  22616. }
  22617. }
  22618. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22619. // executed in a transaction (ent.Tx), a transactional client is returned.
  22620. func (m ServerMutation) Client() *Client {
  22621. client := &Client{config: m.config}
  22622. client.init()
  22623. return client
  22624. }
  22625. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22626. // it returns an error otherwise.
  22627. func (m ServerMutation) Tx() (*Tx, error) {
  22628. if _, ok := m.driver.(*txDriver); !ok {
  22629. return nil, errors.New("ent: mutation is not running in a transaction")
  22630. }
  22631. tx := &Tx{config: m.config}
  22632. tx.init()
  22633. return tx, nil
  22634. }
  22635. // SetID sets the value of the id field. Note that this
  22636. // operation is only accepted on creation of Server entities.
  22637. func (m *ServerMutation) SetID(id uint64) {
  22638. m.id = &id
  22639. }
  22640. // ID returns the ID value in the mutation. Note that the ID is only available
  22641. // if it was provided to the builder or after it was returned from the database.
  22642. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22643. if m.id == nil {
  22644. return
  22645. }
  22646. return *m.id, true
  22647. }
  22648. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22649. // That means, if the mutation is applied within a transaction with an isolation level such
  22650. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22651. // or updated by the mutation.
  22652. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22653. switch {
  22654. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22655. id, exists := m.ID()
  22656. if exists {
  22657. return []uint64{id}, nil
  22658. }
  22659. fallthrough
  22660. case m.op.Is(OpUpdate | OpDelete):
  22661. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22662. default:
  22663. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22664. }
  22665. }
  22666. // SetCreatedAt sets the "created_at" field.
  22667. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22668. m.created_at = &t
  22669. }
  22670. // CreatedAt returns the value of the "created_at" field in the mutation.
  22671. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22672. v := m.created_at
  22673. if v == nil {
  22674. return
  22675. }
  22676. return *v, true
  22677. }
  22678. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22679. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22681. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22682. if !m.op.Is(OpUpdateOne) {
  22683. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22684. }
  22685. if m.id == nil || m.oldValue == nil {
  22686. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22687. }
  22688. oldValue, err := m.oldValue(ctx)
  22689. if err != nil {
  22690. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22691. }
  22692. return oldValue.CreatedAt, nil
  22693. }
  22694. // ResetCreatedAt resets all changes to the "created_at" field.
  22695. func (m *ServerMutation) ResetCreatedAt() {
  22696. m.created_at = nil
  22697. }
  22698. // SetUpdatedAt sets the "updated_at" field.
  22699. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22700. m.updated_at = &t
  22701. }
  22702. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22703. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22704. v := m.updated_at
  22705. if v == nil {
  22706. return
  22707. }
  22708. return *v, true
  22709. }
  22710. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22711. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22713. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22714. if !m.op.Is(OpUpdateOne) {
  22715. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22716. }
  22717. if m.id == nil || m.oldValue == nil {
  22718. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22719. }
  22720. oldValue, err := m.oldValue(ctx)
  22721. if err != nil {
  22722. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22723. }
  22724. return oldValue.UpdatedAt, nil
  22725. }
  22726. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22727. func (m *ServerMutation) ResetUpdatedAt() {
  22728. m.updated_at = nil
  22729. }
  22730. // SetStatus sets the "status" field.
  22731. func (m *ServerMutation) SetStatus(u uint8) {
  22732. m.status = &u
  22733. m.addstatus = nil
  22734. }
  22735. // Status returns the value of the "status" field in the mutation.
  22736. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22737. v := m.status
  22738. if v == nil {
  22739. return
  22740. }
  22741. return *v, true
  22742. }
  22743. // OldStatus returns the old "status" field's value of the Server entity.
  22744. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22746. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22747. if !m.op.Is(OpUpdateOne) {
  22748. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22749. }
  22750. if m.id == nil || m.oldValue == nil {
  22751. return v, errors.New("OldStatus requires an ID field in the mutation")
  22752. }
  22753. oldValue, err := m.oldValue(ctx)
  22754. if err != nil {
  22755. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22756. }
  22757. return oldValue.Status, nil
  22758. }
  22759. // AddStatus adds u to the "status" field.
  22760. func (m *ServerMutation) AddStatus(u int8) {
  22761. if m.addstatus != nil {
  22762. *m.addstatus += u
  22763. } else {
  22764. m.addstatus = &u
  22765. }
  22766. }
  22767. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22768. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22769. v := m.addstatus
  22770. if v == nil {
  22771. return
  22772. }
  22773. return *v, true
  22774. }
  22775. // ClearStatus clears the value of the "status" field.
  22776. func (m *ServerMutation) ClearStatus() {
  22777. m.status = nil
  22778. m.addstatus = nil
  22779. m.clearedFields[server.FieldStatus] = struct{}{}
  22780. }
  22781. // StatusCleared returns if the "status" field was cleared in this mutation.
  22782. func (m *ServerMutation) StatusCleared() bool {
  22783. _, ok := m.clearedFields[server.FieldStatus]
  22784. return ok
  22785. }
  22786. // ResetStatus resets all changes to the "status" field.
  22787. func (m *ServerMutation) ResetStatus() {
  22788. m.status = nil
  22789. m.addstatus = nil
  22790. delete(m.clearedFields, server.FieldStatus)
  22791. }
  22792. // SetDeletedAt sets the "deleted_at" field.
  22793. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22794. m.deleted_at = &t
  22795. }
  22796. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22797. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22798. v := m.deleted_at
  22799. if v == nil {
  22800. return
  22801. }
  22802. return *v, true
  22803. }
  22804. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22805. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22807. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22808. if !m.op.Is(OpUpdateOne) {
  22809. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22810. }
  22811. if m.id == nil || m.oldValue == nil {
  22812. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22813. }
  22814. oldValue, err := m.oldValue(ctx)
  22815. if err != nil {
  22816. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22817. }
  22818. return oldValue.DeletedAt, nil
  22819. }
  22820. // ClearDeletedAt clears the value of the "deleted_at" field.
  22821. func (m *ServerMutation) ClearDeletedAt() {
  22822. m.deleted_at = nil
  22823. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22824. }
  22825. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22826. func (m *ServerMutation) DeletedAtCleared() bool {
  22827. _, ok := m.clearedFields[server.FieldDeletedAt]
  22828. return ok
  22829. }
  22830. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22831. func (m *ServerMutation) ResetDeletedAt() {
  22832. m.deleted_at = nil
  22833. delete(m.clearedFields, server.FieldDeletedAt)
  22834. }
  22835. // SetName sets the "name" field.
  22836. func (m *ServerMutation) SetName(s string) {
  22837. m.name = &s
  22838. }
  22839. // Name returns the value of the "name" field in the mutation.
  22840. func (m *ServerMutation) Name() (r string, exists bool) {
  22841. v := m.name
  22842. if v == nil {
  22843. return
  22844. }
  22845. return *v, true
  22846. }
  22847. // OldName returns the old "name" field's value of the Server entity.
  22848. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22850. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22851. if !m.op.Is(OpUpdateOne) {
  22852. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22853. }
  22854. if m.id == nil || m.oldValue == nil {
  22855. return v, errors.New("OldName requires an ID field in the mutation")
  22856. }
  22857. oldValue, err := m.oldValue(ctx)
  22858. if err != nil {
  22859. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22860. }
  22861. return oldValue.Name, nil
  22862. }
  22863. // ResetName resets all changes to the "name" field.
  22864. func (m *ServerMutation) ResetName() {
  22865. m.name = nil
  22866. }
  22867. // SetPublicIP sets the "public_ip" field.
  22868. func (m *ServerMutation) SetPublicIP(s string) {
  22869. m.public_ip = &s
  22870. }
  22871. // PublicIP returns the value of the "public_ip" field in the mutation.
  22872. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22873. v := m.public_ip
  22874. if v == nil {
  22875. return
  22876. }
  22877. return *v, true
  22878. }
  22879. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22880. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22882. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22883. if !m.op.Is(OpUpdateOne) {
  22884. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22885. }
  22886. if m.id == nil || m.oldValue == nil {
  22887. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22888. }
  22889. oldValue, err := m.oldValue(ctx)
  22890. if err != nil {
  22891. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22892. }
  22893. return oldValue.PublicIP, nil
  22894. }
  22895. // ResetPublicIP resets all changes to the "public_ip" field.
  22896. func (m *ServerMutation) ResetPublicIP() {
  22897. m.public_ip = nil
  22898. }
  22899. // SetPrivateIP sets the "private_ip" field.
  22900. func (m *ServerMutation) SetPrivateIP(s string) {
  22901. m.private_ip = &s
  22902. }
  22903. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22904. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22905. v := m.private_ip
  22906. if v == nil {
  22907. return
  22908. }
  22909. return *v, true
  22910. }
  22911. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22912. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22914. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22915. if !m.op.Is(OpUpdateOne) {
  22916. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22917. }
  22918. if m.id == nil || m.oldValue == nil {
  22919. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22920. }
  22921. oldValue, err := m.oldValue(ctx)
  22922. if err != nil {
  22923. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22924. }
  22925. return oldValue.PrivateIP, nil
  22926. }
  22927. // ResetPrivateIP resets all changes to the "private_ip" field.
  22928. func (m *ServerMutation) ResetPrivateIP() {
  22929. m.private_ip = nil
  22930. }
  22931. // SetAdminPort sets the "admin_port" field.
  22932. func (m *ServerMutation) SetAdminPort(s string) {
  22933. m.admin_port = &s
  22934. }
  22935. // AdminPort returns the value of the "admin_port" field in the mutation.
  22936. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22937. v := m.admin_port
  22938. if v == nil {
  22939. return
  22940. }
  22941. return *v, true
  22942. }
  22943. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22944. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22946. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22947. if !m.op.Is(OpUpdateOne) {
  22948. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22949. }
  22950. if m.id == nil || m.oldValue == nil {
  22951. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22952. }
  22953. oldValue, err := m.oldValue(ctx)
  22954. if err != nil {
  22955. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22956. }
  22957. return oldValue.AdminPort, nil
  22958. }
  22959. // ResetAdminPort resets all changes to the "admin_port" field.
  22960. func (m *ServerMutation) ResetAdminPort() {
  22961. m.admin_port = nil
  22962. }
  22963. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22964. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22965. if m.wxs == nil {
  22966. m.wxs = make(map[uint64]struct{})
  22967. }
  22968. for i := range ids {
  22969. m.wxs[ids[i]] = struct{}{}
  22970. }
  22971. }
  22972. // ClearWxs clears the "wxs" edge to the Wx entity.
  22973. func (m *ServerMutation) ClearWxs() {
  22974. m.clearedwxs = true
  22975. }
  22976. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22977. func (m *ServerMutation) WxsCleared() bool {
  22978. return m.clearedwxs
  22979. }
  22980. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22981. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22982. if m.removedwxs == nil {
  22983. m.removedwxs = make(map[uint64]struct{})
  22984. }
  22985. for i := range ids {
  22986. delete(m.wxs, ids[i])
  22987. m.removedwxs[ids[i]] = struct{}{}
  22988. }
  22989. }
  22990. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22991. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22992. for id := range m.removedwxs {
  22993. ids = append(ids, id)
  22994. }
  22995. return
  22996. }
  22997. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22998. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22999. for id := range m.wxs {
  23000. ids = append(ids, id)
  23001. }
  23002. return
  23003. }
  23004. // ResetWxs resets all changes to the "wxs" edge.
  23005. func (m *ServerMutation) ResetWxs() {
  23006. m.wxs = nil
  23007. m.clearedwxs = false
  23008. m.removedwxs = nil
  23009. }
  23010. // Where appends a list predicates to the ServerMutation builder.
  23011. func (m *ServerMutation) Where(ps ...predicate.Server) {
  23012. m.predicates = append(m.predicates, ps...)
  23013. }
  23014. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  23015. // users can use type-assertion to append predicates that do not depend on any generated package.
  23016. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  23017. p := make([]predicate.Server, len(ps))
  23018. for i := range ps {
  23019. p[i] = ps[i]
  23020. }
  23021. m.Where(p...)
  23022. }
  23023. // Op returns the operation name.
  23024. func (m *ServerMutation) Op() Op {
  23025. return m.op
  23026. }
  23027. // SetOp allows setting the mutation operation.
  23028. func (m *ServerMutation) SetOp(op Op) {
  23029. m.op = op
  23030. }
  23031. // Type returns the node type of this mutation (Server).
  23032. func (m *ServerMutation) Type() string {
  23033. return m.typ
  23034. }
  23035. // Fields returns all fields that were changed during this mutation. Note that in
  23036. // order to get all numeric fields that were incremented/decremented, call
  23037. // AddedFields().
  23038. func (m *ServerMutation) Fields() []string {
  23039. fields := make([]string, 0, 8)
  23040. if m.created_at != nil {
  23041. fields = append(fields, server.FieldCreatedAt)
  23042. }
  23043. if m.updated_at != nil {
  23044. fields = append(fields, server.FieldUpdatedAt)
  23045. }
  23046. if m.status != nil {
  23047. fields = append(fields, server.FieldStatus)
  23048. }
  23049. if m.deleted_at != nil {
  23050. fields = append(fields, server.FieldDeletedAt)
  23051. }
  23052. if m.name != nil {
  23053. fields = append(fields, server.FieldName)
  23054. }
  23055. if m.public_ip != nil {
  23056. fields = append(fields, server.FieldPublicIP)
  23057. }
  23058. if m.private_ip != nil {
  23059. fields = append(fields, server.FieldPrivateIP)
  23060. }
  23061. if m.admin_port != nil {
  23062. fields = append(fields, server.FieldAdminPort)
  23063. }
  23064. return fields
  23065. }
  23066. // Field returns the value of a field with the given name. The second boolean
  23067. // return value indicates that this field was not set, or was not defined in the
  23068. // schema.
  23069. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  23070. switch name {
  23071. case server.FieldCreatedAt:
  23072. return m.CreatedAt()
  23073. case server.FieldUpdatedAt:
  23074. return m.UpdatedAt()
  23075. case server.FieldStatus:
  23076. return m.Status()
  23077. case server.FieldDeletedAt:
  23078. return m.DeletedAt()
  23079. case server.FieldName:
  23080. return m.Name()
  23081. case server.FieldPublicIP:
  23082. return m.PublicIP()
  23083. case server.FieldPrivateIP:
  23084. return m.PrivateIP()
  23085. case server.FieldAdminPort:
  23086. return m.AdminPort()
  23087. }
  23088. return nil, false
  23089. }
  23090. // OldField returns the old value of the field from the database. An error is
  23091. // returned if the mutation operation is not UpdateOne, or the query to the
  23092. // database failed.
  23093. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23094. switch name {
  23095. case server.FieldCreatedAt:
  23096. return m.OldCreatedAt(ctx)
  23097. case server.FieldUpdatedAt:
  23098. return m.OldUpdatedAt(ctx)
  23099. case server.FieldStatus:
  23100. return m.OldStatus(ctx)
  23101. case server.FieldDeletedAt:
  23102. return m.OldDeletedAt(ctx)
  23103. case server.FieldName:
  23104. return m.OldName(ctx)
  23105. case server.FieldPublicIP:
  23106. return m.OldPublicIP(ctx)
  23107. case server.FieldPrivateIP:
  23108. return m.OldPrivateIP(ctx)
  23109. case server.FieldAdminPort:
  23110. return m.OldAdminPort(ctx)
  23111. }
  23112. return nil, fmt.Errorf("unknown Server field %s", name)
  23113. }
  23114. // SetField sets the value of a field with the given name. It returns an error if
  23115. // the field is not defined in the schema, or if the type mismatched the field
  23116. // type.
  23117. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  23118. switch name {
  23119. case server.FieldCreatedAt:
  23120. v, ok := value.(time.Time)
  23121. if !ok {
  23122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23123. }
  23124. m.SetCreatedAt(v)
  23125. return nil
  23126. case server.FieldUpdatedAt:
  23127. v, ok := value.(time.Time)
  23128. if !ok {
  23129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23130. }
  23131. m.SetUpdatedAt(v)
  23132. return nil
  23133. case server.FieldStatus:
  23134. v, ok := value.(uint8)
  23135. if !ok {
  23136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23137. }
  23138. m.SetStatus(v)
  23139. return nil
  23140. case server.FieldDeletedAt:
  23141. v, ok := value.(time.Time)
  23142. if !ok {
  23143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23144. }
  23145. m.SetDeletedAt(v)
  23146. return nil
  23147. case server.FieldName:
  23148. v, ok := value.(string)
  23149. if !ok {
  23150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23151. }
  23152. m.SetName(v)
  23153. return nil
  23154. case server.FieldPublicIP:
  23155. v, ok := value.(string)
  23156. if !ok {
  23157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23158. }
  23159. m.SetPublicIP(v)
  23160. return nil
  23161. case server.FieldPrivateIP:
  23162. v, ok := value.(string)
  23163. if !ok {
  23164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23165. }
  23166. m.SetPrivateIP(v)
  23167. return nil
  23168. case server.FieldAdminPort:
  23169. v, ok := value.(string)
  23170. if !ok {
  23171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23172. }
  23173. m.SetAdminPort(v)
  23174. return nil
  23175. }
  23176. return fmt.Errorf("unknown Server field %s", name)
  23177. }
  23178. // AddedFields returns all numeric fields that were incremented/decremented during
  23179. // this mutation.
  23180. func (m *ServerMutation) AddedFields() []string {
  23181. var fields []string
  23182. if m.addstatus != nil {
  23183. fields = append(fields, server.FieldStatus)
  23184. }
  23185. return fields
  23186. }
  23187. // AddedField returns the numeric value that was incremented/decremented on a field
  23188. // with the given name. The second boolean return value indicates that this field
  23189. // was not set, or was not defined in the schema.
  23190. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  23191. switch name {
  23192. case server.FieldStatus:
  23193. return m.AddedStatus()
  23194. }
  23195. return nil, false
  23196. }
  23197. // AddField adds the value to the field with the given name. It returns an error if
  23198. // the field is not defined in the schema, or if the type mismatched the field
  23199. // type.
  23200. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  23201. switch name {
  23202. case server.FieldStatus:
  23203. v, ok := value.(int8)
  23204. if !ok {
  23205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23206. }
  23207. m.AddStatus(v)
  23208. return nil
  23209. }
  23210. return fmt.Errorf("unknown Server numeric field %s", name)
  23211. }
  23212. // ClearedFields returns all nullable fields that were cleared during this
  23213. // mutation.
  23214. func (m *ServerMutation) ClearedFields() []string {
  23215. var fields []string
  23216. if m.FieldCleared(server.FieldStatus) {
  23217. fields = append(fields, server.FieldStatus)
  23218. }
  23219. if m.FieldCleared(server.FieldDeletedAt) {
  23220. fields = append(fields, server.FieldDeletedAt)
  23221. }
  23222. return fields
  23223. }
  23224. // FieldCleared returns a boolean indicating if a field with the given name was
  23225. // cleared in this mutation.
  23226. func (m *ServerMutation) FieldCleared(name string) bool {
  23227. _, ok := m.clearedFields[name]
  23228. return ok
  23229. }
  23230. // ClearField clears the value of the field with the given name. It returns an
  23231. // error if the field is not defined in the schema.
  23232. func (m *ServerMutation) ClearField(name string) error {
  23233. switch name {
  23234. case server.FieldStatus:
  23235. m.ClearStatus()
  23236. return nil
  23237. case server.FieldDeletedAt:
  23238. m.ClearDeletedAt()
  23239. return nil
  23240. }
  23241. return fmt.Errorf("unknown Server nullable field %s", name)
  23242. }
  23243. // ResetField resets all changes in the mutation for the field with the given name.
  23244. // It returns an error if the field is not defined in the schema.
  23245. func (m *ServerMutation) ResetField(name string) error {
  23246. switch name {
  23247. case server.FieldCreatedAt:
  23248. m.ResetCreatedAt()
  23249. return nil
  23250. case server.FieldUpdatedAt:
  23251. m.ResetUpdatedAt()
  23252. return nil
  23253. case server.FieldStatus:
  23254. m.ResetStatus()
  23255. return nil
  23256. case server.FieldDeletedAt:
  23257. m.ResetDeletedAt()
  23258. return nil
  23259. case server.FieldName:
  23260. m.ResetName()
  23261. return nil
  23262. case server.FieldPublicIP:
  23263. m.ResetPublicIP()
  23264. return nil
  23265. case server.FieldPrivateIP:
  23266. m.ResetPrivateIP()
  23267. return nil
  23268. case server.FieldAdminPort:
  23269. m.ResetAdminPort()
  23270. return nil
  23271. }
  23272. return fmt.Errorf("unknown Server field %s", name)
  23273. }
  23274. // AddedEdges returns all edge names that were set/added in this mutation.
  23275. func (m *ServerMutation) AddedEdges() []string {
  23276. edges := make([]string, 0, 1)
  23277. if m.wxs != nil {
  23278. edges = append(edges, server.EdgeWxs)
  23279. }
  23280. return edges
  23281. }
  23282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23283. // name in this mutation.
  23284. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  23285. switch name {
  23286. case server.EdgeWxs:
  23287. ids := make([]ent.Value, 0, len(m.wxs))
  23288. for id := range m.wxs {
  23289. ids = append(ids, id)
  23290. }
  23291. return ids
  23292. }
  23293. return nil
  23294. }
  23295. // RemovedEdges returns all edge names that were removed in this mutation.
  23296. func (m *ServerMutation) RemovedEdges() []string {
  23297. edges := make([]string, 0, 1)
  23298. if m.removedwxs != nil {
  23299. edges = append(edges, server.EdgeWxs)
  23300. }
  23301. return edges
  23302. }
  23303. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23304. // the given name in this mutation.
  23305. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  23306. switch name {
  23307. case server.EdgeWxs:
  23308. ids := make([]ent.Value, 0, len(m.removedwxs))
  23309. for id := range m.removedwxs {
  23310. ids = append(ids, id)
  23311. }
  23312. return ids
  23313. }
  23314. return nil
  23315. }
  23316. // ClearedEdges returns all edge names that were cleared in this mutation.
  23317. func (m *ServerMutation) ClearedEdges() []string {
  23318. edges := make([]string, 0, 1)
  23319. if m.clearedwxs {
  23320. edges = append(edges, server.EdgeWxs)
  23321. }
  23322. return edges
  23323. }
  23324. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23325. // was cleared in this mutation.
  23326. func (m *ServerMutation) EdgeCleared(name string) bool {
  23327. switch name {
  23328. case server.EdgeWxs:
  23329. return m.clearedwxs
  23330. }
  23331. return false
  23332. }
  23333. // ClearEdge clears the value of the edge with the given name. It returns an error
  23334. // if that edge is not defined in the schema.
  23335. func (m *ServerMutation) ClearEdge(name string) error {
  23336. switch name {
  23337. }
  23338. return fmt.Errorf("unknown Server unique edge %s", name)
  23339. }
  23340. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23341. // It returns an error if the edge is not defined in the schema.
  23342. func (m *ServerMutation) ResetEdge(name string) error {
  23343. switch name {
  23344. case server.EdgeWxs:
  23345. m.ResetWxs()
  23346. return nil
  23347. }
  23348. return fmt.Errorf("unknown Server edge %s", name)
  23349. }
  23350. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  23351. type SopNodeMutation struct {
  23352. config
  23353. op Op
  23354. typ string
  23355. id *uint64
  23356. created_at *time.Time
  23357. updated_at *time.Time
  23358. status *uint8
  23359. addstatus *int8
  23360. deleted_at *time.Time
  23361. parent_id *uint64
  23362. addparent_id *int64
  23363. name *string
  23364. condition_type *int
  23365. addcondition_type *int
  23366. condition_list *[]string
  23367. appendcondition_list []string
  23368. no_reply_condition *uint64
  23369. addno_reply_condition *int64
  23370. no_reply_unit *string
  23371. action_message *[]custom_types.Action
  23372. appendaction_message []custom_types.Action
  23373. action_label_add *[]uint64
  23374. appendaction_label_add []uint64
  23375. action_label_del *[]uint64
  23376. appendaction_label_del []uint64
  23377. action_forward **custom_types.ActionForward
  23378. clearedFields map[string]struct{}
  23379. sop_stage *uint64
  23380. clearedsop_stage bool
  23381. node_messages map[uint64]struct{}
  23382. removednode_messages map[uint64]struct{}
  23383. clearednode_messages bool
  23384. done bool
  23385. oldValue func(context.Context) (*SopNode, error)
  23386. predicates []predicate.SopNode
  23387. }
  23388. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23389. // sopnodeOption allows management of the mutation configuration using functional options.
  23390. type sopnodeOption func(*SopNodeMutation)
  23391. // newSopNodeMutation creates new mutation for the SopNode entity.
  23392. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23393. m := &SopNodeMutation{
  23394. config: c,
  23395. op: op,
  23396. typ: TypeSopNode,
  23397. clearedFields: make(map[string]struct{}),
  23398. }
  23399. for _, opt := range opts {
  23400. opt(m)
  23401. }
  23402. return m
  23403. }
  23404. // withSopNodeID sets the ID field of the mutation.
  23405. func withSopNodeID(id uint64) sopnodeOption {
  23406. return func(m *SopNodeMutation) {
  23407. var (
  23408. err error
  23409. once sync.Once
  23410. value *SopNode
  23411. )
  23412. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23413. once.Do(func() {
  23414. if m.done {
  23415. err = errors.New("querying old values post mutation is not allowed")
  23416. } else {
  23417. value, err = m.Client().SopNode.Get(ctx, id)
  23418. }
  23419. })
  23420. return value, err
  23421. }
  23422. m.id = &id
  23423. }
  23424. }
  23425. // withSopNode sets the old SopNode of the mutation.
  23426. func withSopNode(node *SopNode) sopnodeOption {
  23427. return func(m *SopNodeMutation) {
  23428. m.oldValue = func(context.Context) (*SopNode, error) {
  23429. return node, nil
  23430. }
  23431. m.id = &node.ID
  23432. }
  23433. }
  23434. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23435. // executed in a transaction (ent.Tx), a transactional client is returned.
  23436. func (m SopNodeMutation) Client() *Client {
  23437. client := &Client{config: m.config}
  23438. client.init()
  23439. return client
  23440. }
  23441. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23442. // it returns an error otherwise.
  23443. func (m SopNodeMutation) Tx() (*Tx, error) {
  23444. if _, ok := m.driver.(*txDriver); !ok {
  23445. return nil, errors.New("ent: mutation is not running in a transaction")
  23446. }
  23447. tx := &Tx{config: m.config}
  23448. tx.init()
  23449. return tx, nil
  23450. }
  23451. // SetID sets the value of the id field. Note that this
  23452. // operation is only accepted on creation of SopNode entities.
  23453. func (m *SopNodeMutation) SetID(id uint64) {
  23454. m.id = &id
  23455. }
  23456. // ID returns the ID value in the mutation. Note that the ID is only available
  23457. // if it was provided to the builder or after it was returned from the database.
  23458. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23459. if m.id == nil {
  23460. return
  23461. }
  23462. return *m.id, true
  23463. }
  23464. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23465. // That means, if the mutation is applied within a transaction with an isolation level such
  23466. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23467. // or updated by the mutation.
  23468. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23469. switch {
  23470. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23471. id, exists := m.ID()
  23472. if exists {
  23473. return []uint64{id}, nil
  23474. }
  23475. fallthrough
  23476. case m.op.Is(OpUpdate | OpDelete):
  23477. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23478. default:
  23479. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23480. }
  23481. }
  23482. // SetCreatedAt sets the "created_at" field.
  23483. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23484. m.created_at = &t
  23485. }
  23486. // CreatedAt returns the value of the "created_at" field in the mutation.
  23487. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23488. v := m.created_at
  23489. if v == nil {
  23490. return
  23491. }
  23492. return *v, true
  23493. }
  23494. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23495. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23497. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23498. if !m.op.Is(OpUpdateOne) {
  23499. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23500. }
  23501. if m.id == nil || m.oldValue == nil {
  23502. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23503. }
  23504. oldValue, err := m.oldValue(ctx)
  23505. if err != nil {
  23506. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23507. }
  23508. return oldValue.CreatedAt, nil
  23509. }
  23510. // ResetCreatedAt resets all changes to the "created_at" field.
  23511. func (m *SopNodeMutation) ResetCreatedAt() {
  23512. m.created_at = nil
  23513. }
  23514. // SetUpdatedAt sets the "updated_at" field.
  23515. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23516. m.updated_at = &t
  23517. }
  23518. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23519. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23520. v := m.updated_at
  23521. if v == nil {
  23522. return
  23523. }
  23524. return *v, true
  23525. }
  23526. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23527. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23529. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23530. if !m.op.Is(OpUpdateOne) {
  23531. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23532. }
  23533. if m.id == nil || m.oldValue == nil {
  23534. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23535. }
  23536. oldValue, err := m.oldValue(ctx)
  23537. if err != nil {
  23538. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23539. }
  23540. return oldValue.UpdatedAt, nil
  23541. }
  23542. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23543. func (m *SopNodeMutation) ResetUpdatedAt() {
  23544. m.updated_at = nil
  23545. }
  23546. // SetStatus sets the "status" field.
  23547. func (m *SopNodeMutation) SetStatus(u uint8) {
  23548. m.status = &u
  23549. m.addstatus = nil
  23550. }
  23551. // Status returns the value of the "status" field in the mutation.
  23552. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23553. v := m.status
  23554. if v == nil {
  23555. return
  23556. }
  23557. return *v, true
  23558. }
  23559. // OldStatus returns the old "status" field's value of the SopNode entity.
  23560. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23562. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23563. if !m.op.Is(OpUpdateOne) {
  23564. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23565. }
  23566. if m.id == nil || m.oldValue == nil {
  23567. return v, errors.New("OldStatus requires an ID field in the mutation")
  23568. }
  23569. oldValue, err := m.oldValue(ctx)
  23570. if err != nil {
  23571. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23572. }
  23573. return oldValue.Status, nil
  23574. }
  23575. // AddStatus adds u to the "status" field.
  23576. func (m *SopNodeMutation) AddStatus(u int8) {
  23577. if m.addstatus != nil {
  23578. *m.addstatus += u
  23579. } else {
  23580. m.addstatus = &u
  23581. }
  23582. }
  23583. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23584. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23585. v := m.addstatus
  23586. if v == nil {
  23587. return
  23588. }
  23589. return *v, true
  23590. }
  23591. // ClearStatus clears the value of the "status" field.
  23592. func (m *SopNodeMutation) ClearStatus() {
  23593. m.status = nil
  23594. m.addstatus = nil
  23595. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23596. }
  23597. // StatusCleared returns if the "status" field was cleared in this mutation.
  23598. func (m *SopNodeMutation) StatusCleared() bool {
  23599. _, ok := m.clearedFields[sopnode.FieldStatus]
  23600. return ok
  23601. }
  23602. // ResetStatus resets all changes to the "status" field.
  23603. func (m *SopNodeMutation) ResetStatus() {
  23604. m.status = nil
  23605. m.addstatus = nil
  23606. delete(m.clearedFields, sopnode.FieldStatus)
  23607. }
  23608. // SetDeletedAt sets the "deleted_at" field.
  23609. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23610. m.deleted_at = &t
  23611. }
  23612. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23613. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23614. v := m.deleted_at
  23615. if v == nil {
  23616. return
  23617. }
  23618. return *v, true
  23619. }
  23620. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23621. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23623. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23624. if !m.op.Is(OpUpdateOne) {
  23625. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23626. }
  23627. if m.id == nil || m.oldValue == nil {
  23628. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23629. }
  23630. oldValue, err := m.oldValue(ctx)
  23631. if err != nil {
  23632. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23633. }
  23634. return oldValue.DeletedAt, nil
  23635. }
  23636. // ClearDeletedAt clears the value of the "deleted_at" field.
  23637. func (m *SopNodeMutation) ClearDeletedAt() {
  23638. m.deleted_at = nil
  23639. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23640. }
  23641. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23642. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23643. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23644. return ok
  23645. }
  23646. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23647. func (m *SopNodeMutation) ResetDeletedAt() {
  23648. m.deleted_at = nil
  23649. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23650. }
  23651. // SetStageID sets the "stage_id" field.
  23652. func (m *SopNodeMutation) SetStageID(u uint64) {
  23653. m.sop_stage = &u
  23654. }
  23655. // StageID returns the value of the "stage_id" field in the mutation.
  23656. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23657. v := m.sop_stage
  23658. if v == nil {
  23659. return
  23660. }
  23661. return *v, true
  23662. }
  23663. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23664. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23666. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23667. if !m.op.Is(OpUpdateOne) {
  23668. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23669. }
  23670. if m.id == nil || m.oldValue == nil {
  23671. return v, errors.New("OldStageID requires an ID field in the mutation")
  23672. }
  23673. oldValue, err := m.oldValue(ctx)
  23674. if err != nil {
  23675. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23676. }
  23677. return oldValue.StageID, nil
  23678. }
  23679. // ResetStageID resets all changes to the "stage_id" field.
  23680. func (m *SopNodeMutation) ResetStageID() {
  23681. m.sop_stage = nil
  23682. }
  23683. // SetParentID sets the "parent_id" field.
  23684. func (m *SopNodeMutation) SetParentID(u uint64) {
  23685. m.parent_id = &u
  23686. m.addparent_id = nil
  23687. }
  23688. // ParentID returns the value of the "parent_id" field in the mutation.
  23689. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23690. v := m.parent_id
  23691. if v == nil {
  23692. return
  23693. }
  23694. return *v, true
  23695. }
  23696. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23697. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23699. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23700. if !m.op.Is(OpUpdateOne) {
  23701. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23702. }
  23703. if m.id == nil || m.oldValue == nil {
  23704. return v, errors.New("OldParentID requires an ID field in the mutation")
  23705. }
  23706. oldValue, err := m.oldValue(ctx)
  23707. if err != nil {
  23708. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23709. }
  23710. return oldValue.ParentID, nil
  23711. }
  23712. // AddParentID adds u to the "parent_id" field.
  23713. func (m *SopNodeMutation) AddParentID(u int64) {
  23714. if m.addparent_id != nil {
  23715. *m.addparent_id += u
  23716. } else {
  23717. m.addparent_id = &u
  23718. }
  23719. }
  23720. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23721. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23722. v := m.addparent_id
  23723. if v == nil {
  23724. return
  23725. }
  23726. return *v, true
  23727. }
  23728. // ResetParentID resets all changes to the "parent_id" field.
  23729. func (m *SopNodeMutation) ResetParentID() {
  23730. m.parent_id = nil
  23731. m.addparent_id = nil
  23732. }
  23733. // SetName sets the "name" field.
  23734. func (m *SopNodeMutation) SetName(s string) {
  23735. m.name = &s
  23736. }
  23737. // Name returns the value of the "name" field in the mutation.
  23738. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23739. v := m.name
  23740. if v == nil {
  23741. return
  23742. }
  23743. return *v, true
  23744. }
  23745. // OldName returns the old "name" field's value of the SopNode entity.
  23746. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23748. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23749. if !m.op.Is(OpUpdateOne) {
  23750. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23751. }
  23752. if m.id == nil || m.oldValue == nil {
  23753. return v, errors.New("OldName requires an ID field in the mutation")
  23754. }
  23755. oldValue, err := m.oldValue(ctx)
  23756. if err != nil {
  23757. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23758. }
  23759. return oldValue.Name, nil
  23760. }
  23761. // ResetName resets all changes to the "name" field.
  23762. func (m *SopNodeMutation) ResetName() {
  23763. m.name = nil
  23764. }
  23765. // SetConditionType sets the "condition_type" field.
  23766. func (m *SopNodeMutation) SetConditionType(i int) {
  23767. m.condition_type = &i
  23768. m.addcondition_type = nil
  23769. }
  23770. // ConditionType returns the value of the "condition_type" field in the mutation.
  23771. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23772. v := m.condition_type
  23773. if v == nil {
  23774. return
  23775. }
  23776. return *v, true
  23777. }
  23778. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23779. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23781. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23782. if !m.op.Is(OpUpdateOne) {
  23783. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23784. }
  23785. if m.id == nil || m.oldValue == nil {
  23786. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23787. }
  23788. oldValue, err := m.oldValue(ctx)
  23789. if err != nil {
  23790. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23791. }
  23792. return oldValue.ConditionType, nil
  23793. }
  23794. // AddConditionType adds i to the "condition_type" field.
  23795. func (m *SopNodeMutation) AddConditionType(i int) {
  23796. if m.addcondition_type != nil {
  23797. *m.addcondition_type += i
  23798. } else {
  23799. m.addcondition_type = &i
  23800. }
  23801. }
  23802. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23803. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23804. v := m.addcondition_type
  23805. if v == nil {
  23806. return
  23807. }
  23808. return *v, true
  23809. }
  23810. // ResetConditionType resets all changes to the "condition_type" field.
  23811. func (m *SopNodeMutation) ResetConditionType() {
  23812. m.condition_type = nil
  23813. m.addcondition_type = nil
  23814. }
  23815. // SetConditionList sets the "condition_list" field.
  23816. func (m *SopNodeMutation) SetConditionList(s []string) {
  23817. m.condition_list = &s
  23818. m.appendcondition_list = nil
  23819. }
  23820. // ConditionList returns the value of the "condition_list" field in the mutation.
  23821. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23822. v := m.condition_list
  23823. if v == nil {
  23824. return
  23825. }
  23826. return *v, true
  23827. }
  23828. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23829. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23831. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23832. if !m.op.Is(OpUpdateOne) {
  23833. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23834. }
  23835. if m.id == nil || m.oldValue == nil {
  23836. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23837. }
  23838. oldValue, err := m.oldValue(ctx)
  23839. if err != nil {
  23840. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23841. }
  23842. return oldValue.ConditionList, nil
  23843. }
  23844. // AppendConditionList adds s to the "condition_list" field.
  23845. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23846. m.appendcondition_list = append(m.appendcondition_list, s...)
  23847. }
  23848. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23849. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23850. if len(m.appendcondition_list) == 0 {
  23851. return nil, false
  23852. }
  23853. return m.appendcondition_list, true
  23854. }
  23855. // ClearConditionList clears the value of the "condition_list" field.
  23856. func (m *SopNodeMutation) ClearConditionList() {
  23857. m.condition_list = nil
  23858. m.appendcondition_list = nil
  23859. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23860. }
  23861. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23862. func (m *SopNodeMutation) ConditionListCleared() bool {
  23863. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23864. return ok
  23865. }
  23866. // ResetConditionList resets all changes to the "condition_list" field.
  23867. func (m *SopNodeMutation) ResetConditionList() {
  23868. m.condition_list = nil
  23869. m.appendcondition_list = nil
  23870. delete(m.clearedFields, sopnode.FieldConditionList)
  23871. }
  23872. // SetNoReplyCondition sets the "no_reply_condition" field.
  23873. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23874. m.no_reply_condition = &u
  23875. m.addno_reply_condition = nil
  23876. }
  23877. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23878. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23879. v := m.no_reply_condition
  23880. if v == nil {
  23881. return
  23882. }
  23883. return *v, true
  23884. }
  23885. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23886. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23888. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23889. if !m.op.Is(OpUpdateOne) {
  23890. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23891. }
  23892. if m.id == nil || m.oldValue == nil {
  23893. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23894. }
  23895. oldValue, err := m.oldValue(ctx)
  23896. if err != nil {
  23897. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23898. }
  23899. return oldValue.NoReplyCondition, nil
  23900. }
  23901. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23902. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23903. if m.addno_reply_condition != nil {
  23904. *m.addno_reply_condition += u
  23905. } else {
  23906. m.addno_reply_condition = &u
  23907. }
  23908. }
  23909. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23910. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23911. v := m.addno_reply_condition
  23912. if v == nil {
  23913. return
  23914. }
  23915. return *v, true
  23916. }
  23917. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23918. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23919. m.no_reply_condition = nil
  23920. m.addno_reply_condition = nil
  23921. }
  23922. // SetNoReplyUnit sets the "no_reply_unit" field.
  23923. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23924. m.no_reply_unit = &s
  23925. }
  23926. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23927. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23928. v := m.no_reply_unit
  23929. if v == nil {
  23930. return
  23931. }
  23932. return *v, true
  23933. }
  23934. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23935. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23937. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23938. if !m.op.Is(OpUpdateOne) {
  23939. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23940. }
  23941. if m.id == nil || m.oldValue == nil {
  23942. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23943. }
  23944. oldValue, err := m.oldValue(ctx)
  23945. if err != nil {
  23946. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23947. }
  23948. return oldValue.NoReplyUnit, nil
  23949. }
  23950. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23951. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23952. m.no_reply_unit = nil
  23953. }
  23954. // SetActionMessage sets the "action_message" field.
  23955. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23956. m.action_message = &ct
  23957. m.appendaction_message = nil
  23958. }
  23959. // ActionMessage returns the value of the "action_message" field in the mutation.
  23960. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23961. v := m.action_message
  23962. if v == nil {
  23963. return
  23964. }
  23965. return *v, true
  23966. }
  23967. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23968. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23970. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23971. if !m.op.Is(OpUpdateOne) {
  23972. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23973. }
  23974. if m.id == nil || m.oldValue == nil {
  23975. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23976. }
  23977. oldValue, err := m.oldValue(ctx)
  23978. if err != nil {
  23979. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23980. }
  23981. return oldValue.ActionMessage, nil
  23982. }
  23983. // AppendActionMessage adds ct to the "action_message" field.
  23984. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23985. m.appendaction_message = append(m.appendaction_message, ct...)
  23986. }
  23987. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23988. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23989. if len(m.appendaction_message) == 0 {
  23990. return nil, false
  23991. }
  23992. return m.appendaction_message, true
  23993. }
  23994. // ClearActionMessage clears the value of the "action_message" field.
  23995. func (m *SopNodeMutation) ClearActionMessage() {
  23996. m.action_message = nil
  23997. m.appendaction_message = nil
  23998. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23999. }
  24000. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24001. func (m *SopNodeMutation) ActionMessageCleared() bool {
  24002. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  24003. return ok
  24004. }
  24005. // ResetActionMessage resets all changes to the "action_message" field.
  24006. func (m *SopNodeMutation) ResetActionMessage() {
  24007. m.action_message = nil
  24008. m.appendaction_message = nil
  24009. delete(m.clearedFields, sopnode.FieldActionMessage)
  24010. }
  24011. // SetActionLabelAdd sets the "action_label_add" field.
  24012. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  24013. m.action_label_add = &u
  24014. m.appendaction_label_add = nil
  24015. }
  24016. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24017. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24018. v := m.action_label_add
  24019. if v == nil {
  24020. return
  24021. }
  24022. return *v, true
  24023. }
  24024. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  24025. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24027. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24028. if !m.op.Is(OpUpdateOne) {
  24029. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24030. }
  24031. if m.id == nil || m.oldValue == nil {
  24032. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24033. }
  24034. oldValue, err := m.oldValue(ctx)
  24035. if err != nil {
  24036. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24037. }
  24038. return oldValue.ActionLabelAdd, nil
  24039. }
  24040. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24041. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  24042. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24043. }
  24044. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24045. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24046. if len(m.appendaction_label_add) == 0 {
  24047. return nil, false
  24048. }
  24049. return m.appendaction_label_add, true
  24050. }
  24051. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24052. func (m *SopNodeMutation) ClearActionLabelAdd() {
  24053. m.action_label_add = nil
  24054. m.appendaction_label_add = nil
  24055. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  24056. }
  24057. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24058. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  24059. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  24060. return ok
  24061. }
  24062. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24063. func (m *SopNodeMutation) ResetActionLabelAdd() {
  24064. m.action_label_add = nil
  24065. m.appendaction_label_add = nil
  24066. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  24067. }
  24068. // SetActionLabelDel sets the "action_label_del" field.
  24069. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  24070. m.action_label_del = &u
  24071. m.appendaction_label_del = nil
  24072. }
  24073. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24074. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  24075. v := m.action_label_del
  24076. if v == nil {
  24077. return
  24078. }
  24079. return *v, true
  24080. }
  24081. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  24082. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24084. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24085. if !m.op.Is(OpUpdateOne) {
  24086. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24087. }
  24088. if m.id == nil || m.oldValue == nil {
  24089. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24090. }
  24091. oldValue, err := m.oldValue(ctx)
  24092. if err != nil {
  24093. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24094. }
  24095. return oldValue.ActionLabelDel, nil
  24096. }
  24097. // AppendActionLabelDel adds u to the "action_label_del" field.
  24098. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  24099. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24100. }
  24101. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24102. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24103. if len(m.appendaction_label_del) == 0 {
  24104. return nil, false
  24105. }
  24106. return m.appendaction_label_del, true
  24107. }
  24108. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24109. func (m *SopNodeMutation) ClearActionLabelDel() {
  24110. m.action_label_del = nil
  24111. m.appendaction_label_del = nil
  24112. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  24113. }
  24114. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24115. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  24116. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  24117. return ok
  24118. }
  24119. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24120. func (m *SopNodeMutation) ResetActionLabelDel() {
  24121. m.action_label_del = nil
  24122. m.appendaction_label_del = nil
  24123. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  24124. }
  24125. // SetActionForward sets the "action_forward" field.
  24126. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24127. m.action_forward = &ctf
  24128. }
  24129. // ActionForward returns the value of the "action_forward" field in the mutation.
  24130. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24131. v := m.action_forward
  24132. if v == nil {
  24133. return
  24134. }
  24135. return *v, true
  24136. }
  24137. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  24138. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24140. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24141. if !m.op.Is(OpUpdateOne) {
  24142. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24143. }
  24144. if m.id == nil || m.oldValue == nil {
  24145. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24146. }
  24147. oldValue, err := m.oldValue(ctx)
  24148. if err != nil {
  24149. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24150. }
  24151. return oldValue.ActionForward, nil
  24152. }
  24153. // ClearActionForward clears the value of the "action_forward" field.
  24154. func (m *SopNodeMutation) ClearActionForward() {
  24155. m.action_forward = nil
  24156. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  24157. }
  24158. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24159. func (m *SopNodeMutation) ActionForwardCleared() bool {
  24160. _, ok := m.clearedFields[sopnode.FieldActionForward]
  24161. return ok
  24162. }
  24163. // ResetActionForward resets all changes to the "action_forward" field.
  24164. func (m *SopNodeMutation) ResetActionForward() {
  24165. m.action_forward = nil
  24166. delete(m.clearedFields, sopnode.FieldActionForward)
  24167. }
  24168. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24169. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  24170. m.sop_stage = &id
  24171. }
  24172. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24173. func (m *SopNodeMutation) ClearSopStage() {
  24174. m.clearedsop_stage = true
  24175. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  24176. }
  24177. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24178. func (m *SopNodeMutation) SopStageCleared() bool {
  24179. return m.clearedsop_stage
  24180. }
  24181. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24182. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  24183. if m.sop_stage != nil {
  24184. return *m.sop_stage, true
  24185. }
  24186. return
  24187. }
  24188. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24189. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24190. // SopStageID instead. It exists only for internal usage by the builders.
  24191. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  24192. if id := m.sop_stage; id != nil {
  24193. ids = append(ids, *id)
  24194. }
  24195. return
  24196. }
  24197. // ResetSopStage resets all changes to the "sop_stage" edge.
  24198. func (m *SopNodeMutation) ResetSopStage() {
  24199. m.sop_stage = nil
  24200. m.clearedsop_stage = false
  24201. }
  24202. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  24203. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  24204. if m.node_messages == nil {
  24205. m.node_messages = make(map[uint64]struct{})
  24206. }
  24207. for i := range ids {
  24208. m.node_messages[ids[i]] = struct{}{}
  24209. }
  24210. }
  24211. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  24212. func (m *SopNodeMutation) ClearNodeMessages() {
  24213. m.clearednode_messages = true
  24214. }
  24215. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  24216. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  24217. return m.clearednode_messages
  24218. }
  24219. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  24220. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  24221. if m.removednode_messages == nil {
  24222. m.removednode_messages = make(map[uint64]struct{})
  24223. }
  24224. for i := range ids {
  24225. delete(m.node_messages, ids[i])
  24226. m.removednode_messages[ids[i]] = struct{}{}
  24227. }
  24228. }
  24229. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  24230. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  24231. for id := range m.removednode_messages {
  24232. ids = append(ids, id)
  24233. }
  24234. return
  24235. }
  24236. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  24237. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  24238. for id := range m.node_messages {
  24239. ids = append(ids, id)
  24240. }
  24241. return
  24242. }
  24243. // ResetNodeMessages resets all changes to the "node_messages" edge.
  24244. func (m *SopNodeMutation) ResetNodeMessages() {
  24245. m.node_messages = nil
  24246. m.clearednode_messages = false
  24247. m.removednode_messages = nil
  24248. }
  24249. // Where appends a list predicates to the SopNodeMutation builder.
  24250. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  24251. m.predicates = append(m.predicates, ps...)
  24252. }
  24253. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  24254. // users can use type-assertion to append predicates that do not depend on any generated package.
  24255. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  24256. p := make([]predicate.SopNode, len(ps))
  24257. for i := range ps {
  24258. p[i] = ps[i]
  24259. }
  24260. m.Where(p...)
  24261. }
  24262. // Op returns the operation name.
  24263. func (m *SopNodeMutation) Op() Op {
  24264. return m.op
  24265. }
  24266. // SetOp allows setting the mutation operation.
  24267. func (m *SopNodeMutation) SetOp(op Op) {
  24268. m.op = op
  24269. }
  24270. // Type returns the node type of this mutation (SopNode).
  24271. func (m *SopNodeMutation) Type() string {
  24272. return m.typ
  24273. }
  24274. // Fields returns all fields that were changed during this mutation. Note that in
  24275. // order to get all numeric fields that were incremented/decremented, call
  24276. // AddedFields().
  24277. func (m *SopNodeMutation) Fields() []string {
  24278. fields := make([]string, 0, 15)
  24279. if m.created_at != nil {
  24280. fields = append(fields, sopnode.FieldCreatedAt)
  24281. }
  24282. if m.updated_at != nil {
  24283. fields = append(fields, sopnode.FieldUpdatedAt)
  24284. }
  24285. if m.status != nil {
  24286. fields = append(fields, sopnode.FieldStatus)
  24287. }
  24288. if m.deleted_at != nil {
  24289. fields = append(fields, sopnode.FieldDeletedAt)
  24290. }
  24291. if m.sop_stage != nil {
  24292. fields = append(fields, sopnode.FieldStageID)
  24293. }
  24294. if m.parent_id != nil {
  24295. fields = append(fields, sopnode.FieldParentID)
  24296. }
  24297. if m.name != nil {
  24298. fields = append(fields, sopnode.FieldName)
  24299. }
  24300. if m.condition_type != nil {
  24301. fields = append(fields, sopnode.FieldConditionType)
  24302. }
  24303. if m.condition_list != nil {
  24304. fields = append(fields, sopnode.FieldConditionList)
  24305. }
  24306. if m.no_reply_condition != nil {
  24307. fields = append(fields, sopnode.FieldNoReplyCondition)
  24308. }
  24309. if m.no_reply_unit != nil {
  24310. fields = append(fields, sopnode.FieldNoReplyUnit)
  24311. }
  24312. if m.action_message != nil {
  24313. fields = append(fields, sopnode.FieldActionMessage)
  24314. }
  24315. if m.action_label_add != nil {
  24316. fields = append(fields, sopnode.FieldActionLabelAdd)
  24317. }
  24318. if m.action_label_del != nil {
  24319. fields = append(fields, sopnode.FieldActionLabelDel)
  24320. }
  24321. if m.action_forward != nil {
  24322. fields = append(fields, sopnode.FieldActionForward)
  24323. }
  24324. return fields
  24325. }
  24326. // Field returns the value of a field with the given name. The second boolean
  24327. // return value indicates that this field was not set, or was not defined in the
  24328. // schema.
  24329. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  24330. switch name {
  24331. case sopnode.FieldCreatedAt:
  24332. return m.CreatedAt()
  24333. case sopnode.FieldUpdatedAt:
  24334. return m.UpdatedAt()
  24335. case sopnode.FieldStatus:
  24336. return m.Status()
  24337. case sopnode.FieldDeletedAt:
  24338. return m.DeletedAt()
  24339. case sopnode.FieldStageID:
  24340. return m.StageID()
  24341. case sopnode.FieldParentID:
  24342. return m.ParentID()
  24343. case sopnode.FieldName:
  24344. return m.Name()
  24345. case sopnode.FieldConditionType:
  24346. return m.ConditionType()
  24347. case sopnode.FieldConditionList:
  24348. return m.ConditionList()
  24349. case sopnode.FieldNoReplyCondition:
  24350. return m.NoReplyCondition()
  24351. case sopnode.FieldNoReplyUnit:
  24352. return m.NoReplyUnit()
  24353. case sopnode.FieldActionMessage:
  24354. return m.ActionMessage()
  24355. case sopnode.FieldActionLabelAdd:
  24356. return m.ActionLabelAdd()
  24357. case sopnode.FieldActionLabelDel:
  24358. return m.ActionLabelDel()
  24359. case sopnode.FieldActionForward:
  24360. return m.ActionForward()
  24361. }
  24362. return nil, false
  24363. }
  24364. // OldField returns the old value of the field from the database. An error is
  24365. // returned if the mutation operation is not UpdateOne, or the query to the
  24366. // database failed.
  24367. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24368. switch name {
  24369. case sopnode.FieldCreatedAt:
  24370. return m.OldCreatedAt(ctx)
  24371. case sopnode.FieldUpdatedAt:
  24372. return m.OldUpdatedAt(ctx)
  24373. case sopnode.FieldStatus:
  24374. return m.OldStatus(ctx)
  24375. case sopnode.FieldDeletedAt:
  24376. return m.OldDeletedAt(ctx)
  24377. case sopnode.FieldStageID:
  24378. return m.OldStageID(ctx)
  24379. case sopnode.FieldParentID:
  24380. return m.OldParentID(ctx)
  24381. case sopnode.FieldName:
  24382. return m.OldName(ctx)
  24383. case sopnode.FieldConditionType:
  24384. return m.OldConditionType(ctx)
  24385. case sopnode.FieldConditionList:
  24386. return m.OldConditionList(ctx)
  24387. case sopnode.FieldNoReplyCondition:
  24388. return m.OldNoReplyCondition(ctx)
  24389. case sopnode.FieldNoReplyUnit:
  24390. return m.OldNoReplyUnit(ctx)
  24391. case sopnode.FieldActionMessage:
  24392. return m.OldActionMessage(ctx)
  24393. case sopnode.FieldActionLabelAdd:
  24394. return m.OldActionLabelAdd(ctx)
  24395. case sopnode.FieldActionLabelDel:
  24396. return m.OldActionLabelDel(ctx)
  24397. case sopnode.FieldActionForward:
  24398. return m.OldActionForward(ctx)
  24399. }
  24400. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24401. }
  24402. // SetField sets the value of a field with the given name. It returns an error if
  24403. // the field is not defined in the schema, or if the type mismatched the field
  24404. // type.
  24405. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24406. switch name {
  24407. case sopnode.FieldCreatedAt:
  24408. v, ok := value.(time.Time)
  24409. if !ok {
  24410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24411. }
  24412. m.SetCreatedAt(v)
  24413. return nil
  24414. case sopnode.FieldUpdatedAt:
  24415. v, ok := value.(time.Time)
  24416. if !ok {
  24417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24418. }
  24419. m.SetUpdatedAt(v)
  24420. return nil
  24421. case sopnode.FieldStatus:
  24422. v, ok := value.(uint8)
  24423. if !ok {
  24424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24425. }
  24426. m.SetStatus(v)
  24427. return nil
  24428. case sopnode.FieldDeletedAt:
  24429. v, ok := value.(time.Time)
  24430. if !ok {
  24431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24432. }
  24433. m.SetDeletedAt(v)
  24434. return nil
  24435. case sopnode.FieldStageID:
  24436. v, ok := value.(uint64)
  24437. if !ok {
  24438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24439. }
  24440. m.SetStageID(v)
  24441. return nil
  24442. case sopnode.FieldParentID:
  24443. v, ok := value.(uint64)
  24444. if !ok {
  24445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24446. }
  24447. m.SetParentID(v)
  24448. return nil
  24449. case sopnode.FieldName:
  24450. v, ok := value.(string)
  24451. if !ok {
  24452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24453. }
  24454. m.SetName(v)
  24455. return nil
  24456. case sopnode.FieldConditionType:
  24457. v, ok := value.(int)
  24458. if !ok {
  24459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24460. }
  24461. m.SetConditionType(v)
  24462. return nil
  24463. case sopnode.FieldConditionList:
  24464. v, ok := value.([]string)
  24465. if !ok {
  24466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24467. }
  24468. m.SetConditionList(v)
  24469. return nil
  24470. case sopnode.FieldNoReplyCondition:
  24471. v, ok := value.(uint64)
  24472. if !ok {
  24473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24474. }
  24475. m.SetNoReplyCondition(v)
  24476. return nil
  24477. case sopnode.FieldNoReplyUnit:
  24478. v, ok := value.(string)
  24479. if !ok {
  24480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24481. }
  24482. m.SetNoReplyUnit(v)
  24483. return nil
  24484. case sopnode.FieldActionMessage:
  24485. v, ok := value.([]custom_types.Action)
  24486. if !ok {
  24487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24488. }
  24489. m.SetActionMessage(v)
  24490. return nil
  24491. case sopnode.FieldActionLabelAdd:
  24492. v, ok := value.([]uint64)
  24493. if !ok {
  24494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24495. }
  24496. m.SetActionLabelAdd(v)
  24497. return nil
  24498. case sopnode.FieldActionLabelDel:
  24499. v, ok := value.([]uint64)
  24500. if !ok {
  24501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24502. }
  24503. m.SetActionLabelDel(v)
  24504. return nil
  24505. case sopnode.FieldActionForward:
  24506. v, ok := value.(*custom_types.ActionForward)
  24507. if !ok {
  24508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24509. }
  24510. m.SetActionForward(v)
  24511. return nil
  24512. }
  24513. return fmt.Errorf("unknown SopNode field %s", name)
  24514. }
  24515. // AddedFields returns all numeric fields that were incremented/decremented during
  24516. // this mutation.
  24517. func (m *SopNodeMutation) AddedFields() []string {
  24518. var fields []string
  24519. if m.addstatus != nil {
  24520. fields = append(fields, sopnode.FieldStatus)
  24521. }
  24522. if m.addparent_id != nil {
  24523. fields = append(fields, sopnode.FieldParentID)
  24524. }
  24525. if m.addcondition_type != nil {
  24526. fields = append(fields, sopnode.FieldConditionType)
  24527. }
  24528. if m.addno_reply_condition != nil {
  24529. fields = append(fields, sopnode.FieldNoReplyCondition)
  24530. }
  24531. return fields
  24532. }
  24533. // AddedField returns the numeric value that was incremented/decremented on a field
  24534. // with the given name. The second boolean return value indicates that this field
  24535. // was not set, or was not defined in the schema.
  24536. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24537. switch name {
  24538. case sopnode.FieldStatus:
  24539. return m.AddedStatus()
  24540. case sopnode.FieldParentID:
  24541. return m.AddedParentID()
  24542. case sopnode.FieldConditionType:
  24543. return m.AddedConditionType()
  24544. case sopnode.FieldNoReplyCondition:
  24545. return m.AddedNoReplyCondition()
  24546. }
  24547. return nil, false
  24548. }
  24549. // AddField adds the value to the field with the given name. It returns an error if
  24550. // the field is not defined in the schema, or if the type mismatched the field
  24551. // type.
  24552. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24553. switch name {
  24554. case sopnode.FieldStatus:
  24555. v, ok := value.(int8)
  24556. if !ok {
  24557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24558. }
  24559. m.AddStatus(v)
  24560. return nil
  24561. case sopnode.FieldParentID:
  24562. v, ok := value.(int64)
  24563. if !ok {
  24564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24565. }
  24566. m.AddParentID(v)
  24567. return nil
  24568. case sopnode.FieldConditionType:
  24569. v, ok := value.(int)
  24570. if !ok {
  24571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24572. }
  24573. m.AddConditionType(v)
  24574. return nil
  24575. case sopnode.FieldNoReplyCondition:
  24576. v, ok := value.(int64)
  24577. if !ok {
  24578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24579. }
  24580. m.AddNoReplyCondition(v)
  24581. return nil
  24582. }
  24583. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24584. }
  24585. // ClearedFields returns all nullable fields that were cleared during this
  24586. // mutation.
  24587. func (m *SopNodeMutation) ClearedFields() []string {
  24588. var fields []string
  24589. if m.FieldCleared(sopnode.FieldStatus) {
  24590. fields = append(fields, sopnode.FieldStatus)
  24591. }
  24592. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24593. fields = append(fields, sopnode.FieldDeletedAt)
  24594. }
  24595. if m.FieldCleared(sopnode.FieldConditionList) {
  24596. fields = append(fields, sopnode.FieldConditionList)
  24597. }
  24598. if m.FieldCleared(sopnode.FieldActionMessage) {
  24599. fields = append(fields, sopnode.FieldActionMessage)
  24600. }
  24601. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24602. fields = append(fields, sopnode.FieldActionLabelAdd)
  24603. }
  24604. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24605. fields = append(fields, sopnode.FieldActionLabelDel)
  24606. }
  24607. if m.FieldCleared(sopnode.FieldActionForward) {
  24608. fields = append(fields, sopnode.FieldActionForward)
  24609. }
  24610. return fields
  24611. }
  24612. // FieldCleared returns a boolean indicating if a field with the given name was
  24613. // cleared in this mutation.
  24614. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24615. _, ok := m.clearedFields[name]
  24616. return ok
  24617. }
  24618. // ClearField clears the value of the field with the given name. It returns an
  24619. // error if the field is not defined in the schema.
  24620. func (m *SopNodeMutation) ClearField(name string) error {
  24621. switch name {
  24622. case sopnode.FieldStatus:
  24623. m.ClearStatus()
  24624. return nil
  24625. case sopnode.FieldDeletedAt:
  24626. m.ClearDeletedAt()
  24627. return nil
  24628. case sopnode.FieldConditionList:
  24629. m.ClearConditionList()
  24630. return nil
  24631. case sopnode.FieldActionMessage:
  24632. m.ClearActionMessage()
  24633. return nil
  24634. case sopnode.FieldActionLabelAdd:
  24635. m.ClearActionLabelAdd()
  24636. return nil
  24637. case sopnode.FieldActionLabelDel:
  24638. m.ClearActionLabelDel()
  24639. return nil
  24640. case sopnode.FieldActionForward:
  24641. m.ClearActionForward()
  24642. return nil
  24643. }
  24644. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24645. }
  24646. // ResetField resets all changes in the mutation for the field with the given name.
  24647. // It returns an error if the field is not defined in the schema.
  24648. func (m *SopNodeMutation) ResetField(name string) error {
  24649. switch name {
  24650. case sopnode.FieldCreatedAt:
  24651. m.ResetCreatedAt()
  24652. return nil
  24653. case sopnode.FieldUpdatedAt:
  24654. m.ResetUpdatedAt()
  24655. return nil
  24656. case sopnode.FieldStatus:
  24657. m.ResetStatus()
  24658. return nil
  24659. case sopnode.FieldDeletedAt:
  24660. m.ResetDeletedAt()
  24661. return nil
  24662. case sopnode.FieldStageID:
  24663. m.ResetStageID()
  24664. return nil
  24665. case sopnode.FieldParentID:
  24666. m.ResetParentID()
  24667. return nil
  24668. case sopnode.FieldName:
  24669. m.ResetName()
  24670. return nil
  24671. case sopnode.FieldConditionType:
  24672. m.ResetConditionType()
  24673. return nil
  24674. case sopnode.FieldConditionList:
  24675. m.ResetConditionList()
  24676. return nil
  24677. case sopnode.FieldNoReplyCondition:
  24678. m.ResetNoReplyCondition()
  24679. return nil
  24680. case sopnode.FieldNoReplyUnit:
  24681. m.ResetNoReplyUnit()
  24682. return nil
  24683. case sopnode.FieldActionMessage:
  24684. m.ResetActionMessage()
  24685. return nil
  24686. case sopnode.FieldActionLabelAdd:
  24687. m.ResetActionLabelAdd()
  24688. return nil
  24689. case sopnode.FieldActionLabelDel:
  24690. m.ResetActionLabelDel()
  24691. return nil
  24692. case sopnode.FieldActionForward:
  24693. m.ResetActionForward()
  24694. return nil
  24695. }
  24696. return fmt.Errorf("unknown SopNode field %s", name)
  24697. }
  24698. // AddedEdges returns all edge names that were set/added in this mutation.
  24699. func (m *SopNodeMutation) AddedEdges() []string {
  24700. edges := make([]string, 0, 2)
  24701. if m.sop_stage != nil {
  24702. edges = append(edges, sopnode.EdgeSopStage)
  24703. }
  24704. if m.node_messages != nil {
  24705. edges = append(edges, sopnode.EdgeNodeMessages)
  24706. }
  24707. return edges
  24708. }
  24709. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24710. // name in this mutation.
  24711. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24712. switch name {
  24713. case sopnode.EdgeSopStage:
  24714. if id := m.sop_stage; id != nil {
  24715. return []ent.Value{*id}
  24716. }
  24717. case sopnode.EdgeNodeMessages:
  24718. ids := make([]ent.Value, 0, len(m.node_messages))
  24719. for id := range m.node_messages {
  24720. ids = append(ids, id)
  24721. }
  24722. return ids
  24723. }
  24724. return nil
  24725. }
  24726. // RemovedEdges returns all edge names that were removed in this mutation.
  24727. func (m *SopNodeMutation) RemovedEdges() []string {
  24728. edges := make([]string, 0, 2)
  24729. if m.removednode_messages != nil {
  24730. edges = append(edges, sopnode.EdgeNodeMessages)
  24731. }
  24732. return edges
  24733. }
  24734. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24735. // the given name in this mutation.
  24736. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24737. switch name {
  24738. case sopnode.EdgeNodeMessages:
  24739. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24740. for id := range m.removednode_messages {
  24741. ids = append(ids, id)
  24742. }
  24743. return ids
  24744. }
  24745. return nil
  24746. }
  24747. // ClearedEdges returns all edge names that were cleared in this mutation.
  24748. func (m *SopNodeMutation) ClearedEdges() []string {
  24749. edges := make([]string, 0, 2)
  24750. if m.clearedsop_stage {
  24751. edges = append(edges, sopnode.EdgeSopStage)
  24752. }
  24753. if m.clearednode_messages {
  24754. edges = append(edges, sopnode.EdgeNodeMessages)
  24755. }
  24756. return edges
  24757. }
  24758. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24759. // was cleared in this mutation.
  24760. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24761. switch name {
  24762. case sopnode.EdgeSopStage:
  24763. return m.clearedsop_stage
  24764. case sopnode.EdgeNodeMessages:
  24765. return m.clearednode_messages
  24766. }
  24767. return false
  24768. }
  24769. // ClearEdge clears the value of the edge with the given name. It returns an error
  24770. // if that edge is not defined in the schema.
  24771. func (m *SopNodeMutation) ClearEdge(name string) error {
  24772. switch name {
  24773. case sopnode.EdgeSopStage:
  24774. m.ClearSopStage()
  24775. return nil
  24776. }
  24777. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24778. }
  24779. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24780. // It returns an error if the edge is not defined in the schema.
  24781. func (m *SopNodeMutation) ResetEdge(name string) error {
  24782. switch name {
  24783. case sopnode.EdgeSopStage:
  24784. m.ResetSopStage()
  24785. return nil
  24786. case sopnode.EdgeNodeMessages:
  24787. m.ResetNodeMessages()
  24788. return nil
  24789. }
  24790. return fmt.Errorf("unknown SopNode edge %s", name)
  24791. }
  24792. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24793. type SopStageMutation struct {
  24794. config
  24795. op Op
  24796. typ string
  24797. id *uint64
  24798. created_at *time.Time
  24799. updated_at *time.Time
  24800. status *uint8
  24801. addstatus *int8
  24802. deleted_at *time.Time
  24803. name *string
  24804. condition_type *int
  24805. addcondition_type *int
  24806. condition_operator *int
  24807. addcondition_operator *int
  24808. condition_list *[]custom_types.Condition
  24809. appendcondition_list []custom_types.Condition
  24810. action_message *[]custom_types.Action
  24811. appendaction_message []custom_types.Action
  24812. action_label_add *[]uint64
  24813. appendaction_label_add []uint64
  24814. action_label_del *[]uint64
  24815. appendaction_label_del []uint64
  24816. action_forward **custom_types.ActionForward
  24817. index_sort *int
  24818. addindex_sort *int
  24819. clearedFields map[string]struct{}
  24820. sop_task *uint64
  24821. clearedsop_task bool
  24822. stage_nodes map[uint64]struct{}
  24823. removedstage_nodes map[uint64]struct{}
  24824. clearedstage_nodes bool
  24825. stage_messages map[uint64]struct{}
  24826. removedstage_messages map[uint64]struct{}
  24827. clearedstage_messages bool
  24828. done bool
  24829. oldValue func(context.Context) (*SopStage, error)
  24830. predicates []predicate.SopStage
  24831. }
  24832. var _ ent.Mutation = (*SopStageMutation)(nil)
  24833. // sopstageOption allows management of the mutation configuration using functional options.
  24834. type sopstageOption func(*SopStageMutation)
  24835. // newSopStageMutation creates new mutation for the SopStage entity.
  24836. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24837. m := &SopStageMutation{
  24838. config: c,
  24839. op: op,
  24840. typ: TypeSopStage,
  24841. clearedFields: make(map[string]struct{}),
  24842. }
  24843. for _, opt := range opts {
  24844. opt(m)
  24845. }
  24846. return m
  24847. }
  24848. // withSopStageID sets the ID field of the mutation.
  24849. func withSopStageID(id uint64) sopstageOption {
  24850. return func(m *SopStageMutation) {
  24851. var (
  24852. err error
  24853. once sync.Once
  24854. value *SopStage
  24855. )
  24856. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24857. once.Do(func() {
  24858. if m.done {
  24859. err = errors.New("querying old values post mutation is not allowed")
  24860. } else {
  24861. value, err = m.Client().SopStage.Get(ctx, id)
  24862. }
  24863. })
  24864. return value, err
  24865. }
  24866. m.id = &id
  24867. }
  24868. }
  24869. // withSopStage sets the old SopStage of the mutation.
  24870. func withSopStage(node *SopStage) sopstageOption {
  24871. return func(m *SopStageMutation) {
  24872. m.oldValue = func(context.Context) (*SopStage, error) {
  24873. return node, nil
  24874. }
  24875. m.id = &node.ID
  24876. }
  24877. }
  24878. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24879. // executed in a transaction (ent.Tx), a transactional client is returned.
  24880. func (m SopStageMutation) Client() *Client {
  24881. client := &Client{config: m.config}
  24882. client.init()
  24883. return client
  24884. }
  24885. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24886. // it returns an error otherwise.
  24887. func (m SopStageMutation) Tx() (*Tx, error) {
  24888. if _, ok := m.driver.(*txDriver); !ok {
  24889. return nil, errors.New("ent: mutation is not running in a transaction")
  24890. }
  24891. tx := &Tx{config: m.config}
  24892. tx.init()
  24893. return tx, nil
  24894. }
  24895. // SetID sets the value of the id field. Note that this
  24896. // operation is only accepted on creation of SopStage entities.
  24897. func (m *SopStageMutation) SetID(id uint64) {
  24898. m.id = &id
  24899. }
  24900. // ID returns the ID value in the mutation. Note that the ID is only available
  24901. // if it was provided to the builder or after it was returned from the database.
  24902. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24903. if m.id == nil {
  24904. return
  24905. }
  24906. return *m.id, true
  24907. }
  24908. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24909. // That means, if the mutation is applied within a transaction with an isolation level such
  24910. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24911. // or updated by the mutation.
  24912. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24913. switch {
  24914. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24915. id, exists := m.ID()
  24916. if exists {
  24917. return []uint64{id}, nil
  24918. }
  24919. fallthrough
  24920. case m.op.Is(OpUpdate | OpDelete):
  24921. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24922. default:
  24923. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24924. }
  24925. }
  24926. // SetCreatedAt sets the "created_at" field.
  24927. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24928. m.created_at = &t
  24929. }
  24930. // CreatedAt returns the value of the "created_at" field in the mutation.
  24931. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24932. v := m.created_at
  24933. if v == nil {
  24934. return
  24935. }
  24936. return *v, true
  24937. }
  24938. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24939. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24941. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24942. if !m.op.Is(OpUpdateOne) {
  24943. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24944. }
  24945. if m.id == nil || m.oldValue == nil {
  24946. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24947. }
  24948. oldValue, err := m.oldValue(ctx)
  24949. if err != nil {
  24950. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24951. }
  24952. return oldValue.CreatedAt, nil
  24953. }
  24954. // ResetCreatedAt resets all changes to the "created_at" field.
  24955. func (m *SopStageMutation) ResetCreatedAt() {
  24956. m.created_at = nil
  24957. }
  24958. // SetUpdatedAt sets the "updated_at" field.
  24959. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24960. m.updated_at = &t
  24961. }
  24962. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24963. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24964. v := m.updated_at
  24965. if v == nil {
  24966. return
  24967. }
  24968. return *v, true
  24969. }
  24970. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24971. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24973. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24974. if !m.op.Is(OpUpdateOne) {
  24975. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24976. }
  24977. if m.id == nil || m.oldValue == nil {
  24978. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24979. }
  24980. oldValue, err := m.oldValue(ctx)
  24981. if err != nil {
  24982. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24983. }
  24984. return oldValue.UpdatedAt, nil
  24985. }
  24986. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24987. func (m *SopStageMutation) ResetUpdatedAt() {
  24988. m.updated_at = nil
  24989. }
  24990. // SetStatus sets the "status" field.
  24991. func (m *SopStageMutation) SetStatus(u uint8) {
  24992. m.status = &u
  24993. m.addstatus = nil
  24994. }
  24995. // Status returns the value of the "status" field in the mutation.
  24996. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24997. v := m.status
  24998. if v == nil {
  24999. return
  25000. }
  25001. return *v, true
  25002. }
  25003. // OldStatus returns the old "status" field's value of the SopStage entity.
  25004. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25006. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25007. if !m.op.Is(OpUpdateOne) {
  25008. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25009. }
  25010. if m.id == nil || m.oldValue == nil {
  25011. return v, errors.New("OldStatus requires an ID field in the mutation")
  25012. }
  25013. oldValue, err := m.oldValue(ctx)
  25014. if err != nil {
  25015. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25016. }
  25017. return oldValue.Status, nil
  25018. }
  25019. // AddStatus adds u to the "status" field.
  25020. func (m *SopStageMutation) AddStatus(u int8) {
  25021. if m.addstatus != nil {
  25022. *m.addstatus += u
  25023. } else {
  25024. m.addstatus = &u
  25025. }
  25026. }
  25027. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25028. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  25029. v := m.addstatus
  25030. if v == nil {
  25031. return
  25032. }
  25033. return *v, true
  25034. }
  25035. // ClearStatus clears the value of the "status" field.
  25036. func (m *SopStageMutation) ClearStatus() {
  25037. m.status = nil
  25038. m.addstatus = nil
  25039. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  25040. }
  25041. // StatusCleared returns if the "status" field was cleared in this mutation.
  25042. func (m *SopStageMutation) StatusCleared() bool {
  25043. _, ok := m.clearedFields[sopstage.FieldStatus]
  25044. return ok
  25045. }
  25046. // ResetStatus resets all changes to the "status" field.
  25047. func (m *SopStageMutation) ResetStatus() {
  25048. m.status = nil
  25049. m.addstatus = nil
  25050. delete(m.clearedFields, sopstage.FieldStatus)
  25051. }
  25052. // SetDeletedAt sets the "deleted_at" field.
  25053. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  25054. m.deleted_at = &t
  25055. }
  25056. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25057. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  25058. v := m.deleted_at
  25059. if v == nil {
  25060. return
  25061. }
  25062. return *v, true
  25063. }
  25064. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  25065. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25067. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25068. if !m.op.Is(OpUpdateOne) {
  25069. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25070. }
  25071. if m.id == nil || m.oldValue == nil {
  25072. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25073. }
  25074. oldValue, err := m.oldValue(ctx)
  25075. if err != nil {
  25076. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25077. }
  25078. return oldValue.DeletedAt, nil
  25079. }
  25080. // ClearDeletedAt clears the value of the "deleted_at" field.
  25081. func (m *SopStageMutation) ClearDeletedAt() {
  25082. m.deleted_at = nil
  25083. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  25084. }
  25085. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25086. func (m *SopStageMutation) DeletedAtCleared() bool {
  25087. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  25088. return ok
  25089. }
  25090. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25091. func (m *SopStageMutation) ResetDeletedAt() {
  25092. m.deleted_at = nil
  25093. delete(m.clearedFields, sopstage.FieldDeletedAt)
  25094. }
  25095. // SetTaskID sets the "task_id" field.
  25096. func (m *SopStageMutation) SetTaskID(u uint64) {
  25097. m.sop_task = &u
  25098. }
  25099. // TaskID returns the value of the "task_id" field in the mutation.
  25100. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  25101. v := m.sop_task
  25102. if v == nil {
  25103. return
  25104. }
  25105. return *v, true
  25106. }
  25107. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  25108. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25110. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  25111. if !m.op.Is(OpUpdateOne) {
  25112. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  25113. }
  25114. if m.id == nil || m.oldValue == nil {
  25115. return v, errors.New("OldTaskID requires an ID field in the mutation")
  25116. }
  25117. oldValue, err := m.oldValue(ctx)
  25118. if err != nil {
  25119. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  25120. }
  25121. return oldValue.TaskID, nil
  25122. }
  25123. // ResetTaskID resets all changes to the "task_id" field.
  25124. func (m *SopStageMutation) ResetTaskID() {
  25125. m.sop_task = nil
  25126. }
  25127. // SetName sets the "name" field.
  25128. func (m *SopStageMutation) SetName(s string) {
  25129. m.name = &s
  25130. }
  25131. // Name returns the value of the "name" field in the mutation.
  25132. func (m *SopStageMutation) Name() (r string, exists bool) {
  25133. v := m.name
  25134. if v == nil {
  25135. return
  25136. }
  25137. return *v, true
  25138. }
  25139. // OldName returns the old "name" field's value of the SopStage entity.
  25140. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25142. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  25143. if !m.op.Is(OpUpdateOne) {
  25144. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25145. }
  25146. if m.id == nil || m.oldValue == nil {
  25147. return v, errors.New("OldName requires an ID field in the mutation")
  25148. }
  25149. oldValue, err := m.oldValue(ctx)
  25150. if err != nil {
  25151. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25152. }
  25153. return oldValue.Name, nil
  25154. }
  25155. // ResetName resets all changes to the "name" field.
  25156. func (m *SopStageMutation) ResetName() {
  25157. m.name = nil
  25158. }
  25159. // SetConditionType sets the "condition_type" field.
  25160. func (m *SopStageMutation) SetConditionType(i int) {
  25161. m.condition_type = &i
  25162. m.addcondition_type = nil
  25163. }
  25164. // ConditionType returns the value of the "condition_type" field in the mutation.
  25165. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  25166. v := m.condition_type
  25167. if v == nil {
  25168. return
  25169. }
  25170. return *v, true
  25171. }
  25172. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  25173. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25175. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25176. if !m.op.Is(OpUpdateOne) {
  25177. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25178. }
  25179. if m.id == nil || m.oldValue == nil {
  25180. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25181. }
  25182. oldValue, err := m.oldValue(ctx)
  25183. if err != nil {
  25184. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25185. }
  25186. return oldValue.ConditionType, nil
  25187. }
  25188. // AddConditionType adds i to the "condition_type" field.
  25189. func (m *SopStageMutation) AddConditionType(i int) {
  25190. if m.addcondition_type != nil {
  25191. *m.addcondition_type += i
  25192. } else {
  25193. m.addcondition_type = &i
  25194. }
  25195. }
  25196. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25197. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  25198. v := m.addcondition_type
  25199. if v == nil {
  25200. return
  25201. }
  25202. return *v, true
  25203. }
  25204. // ResetConditionType resets all changes to the "condition_type" field.
  25205. func (m *SopStageMutation) ResetConditionType() {
  25206. m.condition_type = nil
  25207. m.addcondition_type = nil
  25208. }
  25209. // SetConditionOperator sets the "condition_operator" field.
  25210. func (m *SopStageMutation) SetConditionOperator(i int) {
  25211. m.condition_operator = &i
  25212. m.addcondition_operator = nil
  25213. }
  25214. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  25215. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  25216. v := m.condition_operator
  25217. if v == nil {
  25218. return
  25219. }
  25220. return *v, true
  25221. }
  25222. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  25223. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25225. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  25226. if !m.op.Is(OpUpdateOne) {
  25227. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  25228. }
  25229. if m.id == nil || m.oldValue == nil {
  25230. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  25231. }
  25232. oldValue, err := m.oldValue(ctx)
  25233. if err != nil {
  25234. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  25235. }
  25236. return oldValue.ConditionOperator, nil
  25237. }
  25238. // AddConditionOperator adds i to the "condition_operator" field.
  25239. func (m *SopStageMutation) AddConditionOperator(i int) {
  25240. if m.addcondition_operator != nil {
  25241. *m.addcondition_operator += i
  25242. } else {
  25243. m.addcondition_operator = &i
  25244. }
  25245. }
  25246. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  25247. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  25248. v := m.addcondition_operator
  25249. if v == nil {
  25250. return
  25251. }
  25252. return *v, true
  25253. }
  25254. // ResetConditionOperator resets all changes to the "condition_operator" field.
  25255. func (m *SopStageMutation) ResetConditionOperator() {
  25256. m.condition_operator = nil
  25257. m.addcondition_operator = nil
  25258. }
  25259. // SetConditionList sets the "condition_list" field.
  25260. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  25261. m.condition_list = &ct
  25262. m.appendcondition_list = nil
  25263. }
  25264. // ConditionList returns the value of the "condition_list" field in the mutation.
  25265. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  25266. v := m.condition_list
  25267. if v == nil {
  25268. return
  25269. }
  25270. return *v, true
  25271. }
  25272. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  25273. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25275. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  25276. if !m.op.Is(OpUpdateOne) {
  25277. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25278. }
  25279. if m.id == nil || m.oldValue == nil {
  25280. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25281. }
  25282. oldValue, err := m.oldValue(ctx)
  25283. if err != nil {
  25284. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25285. }
  25286. return oldValue.ConditionList, nil
  25287. }
  25288. // AppendConditionList adds ct to the "condition_list" field.
  25289. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25290. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25291. }
  25292. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25293. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25294. if len(m.appendcondition_list) == 0 {
  25295. return nil, false
  25296. }
  25297. return m.appendcondition_list, true
  25298. }
  25299. // ResetConditionList resets all changes to the "condition_list" field.
  25300. func (m *SopStageMutation) ResetConditionList() {
  25301. m.condition_list = nil
  25302. m.appendcondition_list = nil
  25303. }
  25304. // SetActionMessage sets the "action_message" field.
  25305. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  25306. m.action_message = &ct
  25307. m.appendaction_message = nil
  25308. }
  25309. // ActionMessage returns the value of the "action_message" field in the mutation.
  25310. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25311. v := m.action_message
  25312. if v == nil {
  25313. return
  25314. }
  25315. return *v, true
  25316. }
  25317. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  25318. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25320. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25321. if !m.op.Is(OpUpdateOne) {
  25322. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25323. }
  25324. if m.id == nil || m.oldValue == nil {
  25325. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25326. }
  25327. oldValue, err := m.oldValue(ctx)
  25328. if err != nil {
  25329. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25330. }
  25331. return oldValue.ActionMessage, nil
  25332. }
  25333. // AppendActionMessage adds ct to the "action_message" field.
  25334. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  25335. m.appendaction_message = append(m.appendaction_message, ct...)
  25336. }
  25337. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25338. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25339. if len(m.appendaction_message) == 0 {
  25340. return nil, false
  25341. }
  25342. return m.appendaction_message, true
  25343. }
  25344. // ClearActionMessage clears the value of the "action_message" field.
  25345. func (m *SopStageMutation) ClearActionMessage() {
  25346. m.action_message = nil
  25347. m.appendaction_message = nil
  25348. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  25349. }
  25350. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25351. func (m *SopStageMutation) ActionMessageCleared() bool {
  25352. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  25353. return ok
  25354. }
  25355. // ResetActionMessage resets all changes to the "action_message" field.
  25356. func (m *SopStageMutation) ResetActionMessage() {
  25357. m.action_message = nil
  25358. m.appendaction_message = nil
  25359. delete(m.clearedFields, sopstage.FieldActionMessage)
  25360. }
  25361. // SetActionLabelAdd sets the "action_label_add" field.
  25362. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  25363. m.action_label_add = &u
  25364. m.appendaction_label_add = nil
  25365. }
  25366. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25367. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25368. v := m.action_label_add
  25369. if v == nil {
  25370. return
  25371. }
  25372. return *v, true
  25373. }
  25374. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25375. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25377. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25378. if !m.op.Is(OpUpdateOne) {
  25379. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25380. }
  25381. if m.id == nil || m.oldValue == nil {
  25382. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25383. }
  25384. oldValue, err := m.oldValue(ctx)
  25385. if err != nil {
  25386. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25387. }
  25388. return oldValue.ActionLabelAdd, nil
  25389. }
  25390. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25391. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25392. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25393. }
  25394. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25395. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25396. if len(m.appendaction_label_add) == 0 {
  25397. return nil, false
  25398. }
  25399. return m.appendaction_label_add, true
  25400. }
  25401. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25402. func (m *SopStageMutation) ClearActionLabelAdd() {
  25403. m.action_label_add = nil
  25404. m.appendaction_label_add = nil
  25405. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25406. }
  25407. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25408. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25409. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25410. return ok
  25411. }
  25412. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25413. func (m *SopStageMutation) ResetActionLabelAdd() {
  25414. m.action_label_add = nil
  25415. m.appendaction_label_add = nil
  25416. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25417. }
  25418. // SetActionLabelDel sets the "action_label_del" field.
  25419. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25420. m.action_label_del = &u
  25421. m.appendaction_label_del = nil
  25422. }
  25423. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25424. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25425. v := m.action_label_del
  25426. if v == nil {
  25427. return
  25428. }
  25429. return *v, true
  25430. }
  25431. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25432. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25434. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25435. if !m.op.Is(OpUpdateOne) {
  25436. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25437. }
  25438. if m.id == nil || m.oldValue == nil {
  25439. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25440. }
  25441. oldValue, err := m.oldValue(ctx)
  25442. if err != nil {
  25443. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25444. }
  25445. return oldValue.ActionLabelDel, nil
  25446. }
  25447. // AppendActionLabelDel adds u to the "action_label_del" field.
  25448. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25449. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25450. }
  25451. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25452. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25453. if len(m.appendaction_label_del) == 0 {
  25454. return nil, false
  25455. }
  25456. return m.appendaction_label_del, true
  25457. }
  25458. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25459. func (m *SopStageMutation) ClearActionLabelDel() {
  25460. m.action_label_del = nil
  25461. m.appendaction_label_del = nil
  25462. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25463. }
  25464. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25465. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25466. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25467. return ok
  25468. }
  25469. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25470. func (m *SopStageMutation) ResetActionLabelDel() {
  25471. m.action_label_del = nil
  25472. m.appendaction_label_del = nil
  25473. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25474. }
  25475. // SetActionForward sets the "action_forward" field.
  25476. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25477. m.action_forward = &ctf
  25478. }
  25479. // ActionForward returns the value of the "action_forward" field in the mutation.
  25480. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25481. v := m.action_forward
  25482. if v == nil {
  25483. return
  25484. }
  25485. return *v, true
  25486. }
  25487. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25488. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25490. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25491. if !m.op.Is(OpUpdateOne) {
  25492. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25493. }
  25494. if m.id == nil || m.oldValue == nil {
  25495. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25496. }
  25497. oldValue, err := m.oldValue(ctx)
  25498. if err != nil {
  25499. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25500. }
  25501. return oldValue.ActionForward, nil
  25502. }
  25503. // ClearActionForward clears the value of the "action_forward" field.
  25504. func (m *SopStageMutation) ClearActionForward() {
  25505. m.action_forward = nil
  25506. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25507. }
  25508. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25509. func (m *SopStageMutation) ActionForwardCleared() bool {
  25510. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25511. return ok
  25512. }
  25513. // ResetActionForward resets all changes to the "action_forward" field.
  25514. func (m *SopStageMutation) ResetActionForward() {
  25515. m.action_forward = nil
  25516. delete(m.clearedFields, sopstage.FieldActionForward)
  25517. }
  25518. // SetIndexSort sets the "index_sort" field.
  25519. func (m *SopStageMutation) SetIndexSort(i int) {
  25520. m.index_sort = &i
  25521. m.addindex_sort = nil
  25522. }
  25523. // IndexSort returns the value of the "index_sort" field in the mutation.
  25524. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25525. v := m.index_sort
  25526. if v == nil {
  25527. return
  25528. }
  25529. return *v, true
  25530. }
  25531. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25532. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25534. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25535. if !m.op.Is(OpUpdateOne) {
  25536. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25537. }
  25538. if m.id == nil || m.oldValue == nil {
  25539. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25540. }
  25541. oldValue, err := m.oldValue(ctx)
  25542. if err != nil {
  25543. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25544. }
  25545. return oldValue.IndexSort, nil
  25546. }
  25547. // AddIndexSort adds i to the "index_sort" field.
  25548. func (m *SopStageMutation) AddIndexSort(i int) {
  25549. if m.addindex_sort != nil {
  25550. *m.addindex_sort += i
  25551. } else {
  25552. m.addindex_sort = &i
  25553. }
  25554. }
  25555. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25556. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25557. v := m.addindex_sort
  25558. if v == nil {
  25559. return
  25560. }
  25561. return *v, true
  25562. }
  25563. // ClearIndexSort clears the value of the "index_sort" field.
  25564. func (m *SopStageMutation) ClearIndexSort() {
  25565. m.index_sort = nil
  25566. m.addindex_sort = nil
  25567. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25568. }
  25569. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25570. func (m *SopStageMutation) IndexSortCleared() bool {
  25571. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25572. return ok
  25573. }
  25574. // ResetIndexSort resets all changes to the "index_sort" field.
  25575. func (m *SopStageMutation) ResetIndexSort() {
  25576. m.index_sort = nil
  25577. m.addindex_sort = nil
  25578. delete(m.clearedFields, sopstage.FieldIndexSort)
  25579. }
  25580. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25581. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25582. m.sop_task = &id
  25583. }
  25584. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25585. func (m *SopStageMutation) ClearSopTask() {
  25586. m.clearedsop_task = true
  25587. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25588. }
  25589. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25590. func (m *SopStageMutation) SopTaskCleared() bool {
  25591. return m.clearedsop_task
  25592. }
  25593. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25594. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25595. if m.sop_task != nil {
  25596. return *m.sop_task, true
  25597. }
  25598. return
  25599. }
  25600. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25601. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25602. // SopTaskID instead. It exists only for internal usage by the builders.
  25603. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25604. if id := m.sop_task; id != nil {
  25605. ids = append(ids, *id)
  25606. }
  25607. return
  25608. }
  25609. // ResetSopTask resets all changes to the "sop_task" edge.
  25610. func (m *SopStageMutation) ResetSopTask() {
  25611. m.sop_task = nil
  25612. m.clearedsop_task = false
  25613. }
  25614. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25615. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25616. if m.stage_nodes == nil {
  25617. m.stage_nodes = make(map[uint64]struct{})
  25618. }
  25619. for i := range ids {
  25620. m.stage_nodes[ids[i]] = struct{}{}
  25621. }
  25622. }
  25623. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25624. func (m *SopStageMutation) ClearStageNodes() {
  25625. m.clearedstage_nodes = true
  25626. }
  25627. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25628. func (m *SopStageMutation) StageNodesCleared() bool {
  25629. return m.clearedstage_nodes
  25630. }
  25631. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25632. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25633. if m.removedstage_nodes == nil {
  25634. m.removedstage_nodes = make(map[uint64]struct{})
  25635. }
  25636. for i := range ids {
  25637. delete(m.stage_nodes, ids[i])
  25638. m.removedstage_nodes[ids[i]] = struct{}{}
  25639. }
  25640. }
  25641. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25642. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25643. for id := range m.removedstage_nodes {
  25644. ids = append(ids, id)
  25645. }
  25646. return
  25647. }
  25648. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25649. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25650. for id := range m.stage_nodes {
  25651. ids = append(ids, id)
  25652. }
  25653. return
  25654. }
  25655. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25656. func (m *SopStageMutation) ResetStageNodes() {
  25657. m.stage_nodes = nil
  25658. m.clearedstage_nodes = false
  25659. m.removedstage_nodes = nil
  25660. }
  25661. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25662. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25663. if m.stage_messages == nil {
  25664. m.stage_messages = make(map[uint64]struct{})
  25665. }
  25666. for i := range ids {
  25667. m.stage_messages[ids[i]] = struct{}{}
  25668. }
  25669. }
  25670. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25671. func (m *SopStageMutation) ClearStageMessages() {
  25672. m.clearedstage_messages = true
  25673. }
  25674. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25675. func (m *SopStageMutation) StageMessagesCleared() bool {
  25676. return m.clearedstage_messages
  25677. }
  25678. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25679. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25680. if m.removedstage_messages == nil {
  25681. m.removedstage_messages = make(map[uint64]struct{})
  25682. }
  25683. for i := range ids {
  25684. delete(m.stage_messages, ids[i])
  25685. m.removedstage_messages[ids[i]] = struct{}{}
  25686. }
  25687. }
  25688. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25689. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25690. for id := range m.removedstage_messages {
  25691. ids = append(ids, id)
  25692. }
  25693. return
  25694. }
  25695. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25696. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25697. for id := range m.stage_messages {
  25698. ids = append(ids, id)
  25699. }
  25700. return
  25701. }
  25702. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25703. func (m *SopStageMutation) ResetStageMessages() {
  25704. m.stage_messages = nil
  25705. m.clearedstage_messages = false
  25706. m.removedstage_messages = nil
  25707. }
  25708. // Where appends a list predicates to the SopStageMutation builder.
  25709. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25710. m.predicates = append(m.predicates, ps...)
  25711. }
  25712. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25713. // users can use type-assertion to append predicates that do not depend on any generated package.
  25714. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25715. p := make([]predicate.SopStage, len(ps))
  25716. for i := range ps {
  25717. p[i] = ps[i]
  25718. }
  25719. m.Where(p...)
  25720. }
  25721. // Op returns the operation name.
  25722. func (m *SopStageMutation) Op() Op {
  25723. return m.op
  25724. }
  25725. // SetOp allows setting the mutation operation.
  25726. func (m *SopStageMutation) SetOp(op Op) {
  25727. m.op = op
  25728. }
  25729. // Type returns the node type of this mutation (SopStage).
  25730. func (m *SopStageMutation) Type() string {
  25731. return m.typ
  25732. }
  25733. // Fields returns all fields that were changed during this mutation. Note that in
  25734. // order to get all numeric fields that were incremented/decremented, call
  25735. // AddedFields().
  25736. func (m *SopStageMutation) Fields() []string {
  25737. fields := make([]string, 0, 14)
  25738. if m.created_at != nil {
  25739. fields = append(fields, sopstage.FieldCreatedAt)
  25740. }
  25741. if m.updated_at != nil {
  25742. fields = append(fields, sopstage.FieldUpdatedAt)
  25743. }
  25744. if m.status != nil {
  25745. fields = append(fields, sopstage.FieldStatus)
  25746. }
  25747. if m.deleted_at != nil {
  25748. fields = append(fields, sopstage.FieldDeletedAt)
  25749. }
  25750. if m.sop_task != nil {
  25751. fields = append(fields, sopstage.FieldTaskID)
  25752. }
  25753. if m.name != nil {
  25754. fields = append(fields, sopstage.FieldName)
  25755. }
  25756. if m.condition_type != nil {
  25757. fields = append(fields, sopstage.FieldConditionType)
  25758. }
  25759. if m.condition_operator != nil {
  25760. fields = append(fields, sopstage.FieldConditionOperator)
  25761. }
  25762. if m.condition_list != nil {
  25763. fields = append(fields, sopstage.FieldConditionList)
  25764. }
  25765. if m.action_message != nil {
  25766. fields = append(fields, sopstage.FieldActionMessage)
  25767. }
  25768. if m.action_label_add != nil {
  25769. fields = append(fields, sopstage.FieldActionLabelAdd)
  25770. }
  25771. if m.action_label_del != nil {
  25772. fields = append(fields, sopstage.FieldActionLabelDel)
  25773. }
  25774. if m.action_forward != nil {
  25775. fields = append(fields, sopstage.FieldActionForward)
  25776. }
  25777. if m.index_sort != nil {
  25778. fields = append(fields, sopstage.FieldIndexSort)
  25779. }
  25780. return fields
  25781. }
  25782. // Field returns the value of a field with the given name. The second boolean
  25783. // return value indicates that this field was not set, or was not defined in the
  25784. // schema.
  25785. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25786. switch name {
  25787. case sopstage.FieldCreatedAt:
  25788. return m.CreatedAt()
  25789. case sopstage.FieldUpdatedAt:
  25790. return m.UpdatedAt()
  25791. case sopstage.FieldStatus:
  25792. return m.Status()
  25793. case sopstage.FieldDeletedAt:
  25794. return m.DeletedAt()
  25795. case sopstage.FieldTaskID:
  25796. return m.TaskID()
  25797. case sopstage.FieldName:
  25798. return m.Name()
  25799. case sopstage.FieldConditionType:
  25800. return m.ConditionType()
  25801. case sopstage.FieldConditionOperator:
  25802. return m.ConditionOperator()
  25803. case sopstage.FieldConditionList:
  25804. return m.ConditionList()
  25805. case sopstage.FieldActionMessage:
  25806. return m.ActionMessage()
  25807. case sopstage.FieldActionLabelAdd:
  25808. return m.ActionLabelAdd()
  25809. case sopstage.FieldActionLabelDel:
  25810. return m.ActionLabelDel()
  25811. case sopstage.FieldActionForward:
  25812. return m.ActionForward()
  25813. case sopstage.FieldIndexSort:
  25814. return m.IndexSort()
  25815. }
  25816. return nil, false
  25817. }
  25818. // OldField returns the old value of the field from the database. An error is
  25819. // returned if the mutation operation is not UpdateOne, or the query to the
  25820. // database failed.
  25821. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25822. switch name {
  25823. case sopstage.FieldCreatedAt:
  25824. return m.OldCreatedAt(ctx)
  25825. case sopstage.FieldUpdatedAt:
  25826. return m.OldUpdatedAt(ctx)
  25827. case sopstage.FieldStatus:
  25828. return m.OldStatus(ctx)
  25829. case sopstage.FieldDeletedAt:
  25830. return m.OldDeletedAt(ctx)
  25831. case sopstage.FieldTaskID:
  25832. return m.OldTaskID(ctx)
  25833. case sopstage.FieldName:
  25834. return m.OldName(ctx)
  25835. case sopstage.FieldConditionType:
  25836. return m.OldConditionType(ctx)
  25837. case sopstage.FieldConditionOperator:
  25838. return m.OldConditionOperator(ctx)
  25839. case sopstage.FieldConditionList:
  25840. return m.OldConditionList(ctx)
  25841. case sopstage.FieldActionMessage:
  25842. return m.OldActionMessage(ctx)
  25843. case sopstage.FieldActionLabelAdd:
  25844. return m.OldActionLabelAdd(ctx)
  25845. case sopstage.FieldActionLabelDel:
  25846. return m.OldActionLabelDel(ctx)
  25847. case sopstage.FieldActionForward:
  25848. return m.OldActionForward(ctx)
  25849. case sopstage.FieldIndexSort:
  25850. return m.OldIndexSort(ctx)
  25851. }
  25852. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25853. }
  25854. // SetField sets the value of a field with the given name. It returns an error if
  25855. // the field is not defined in the schema, or if the type mismatched the field
  25856. // type.
  25857. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25858. switch name {
  25859. case sopstage.FieldCreatedAt:
  25860. v, ok := value.(time.Time)
  25861. if !ok {
  25862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25863. }
  25864. m.SetCreatedAt(v)
  25865. return nil
  25866. case sopstage.FieldUpdatedAt:
  25867. v, ok := value.(time.Time)
  25868. if !ok {
  25869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25870. }
  25871. m.SetUpdatedAt(v)
  25872. return nil
  25873. case sopstage.FieldStatus:
  25874. v, ok := value.(uint8)
  25875. if !ok {
  25876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25877. }
  25878. m.SetStatus(v)
  25879. return nil
  25880. case sopstage.FieldDeletedAt:
  25881. v, ok := value.(time.Time)
  25882. if !ok {
  25883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25884. }
  25885. m.SetDeletedAt(v)
  25886. return nil
  25887. case sopstage.FieldTaskID:
  25888. v, ok := value.(uint64)
  25889. if !ok {
  25890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25891. }
  25892. m.SetTaskID(v)
  25893. return nil
  25894. case sopstage.FieldName:
  25895. v, ok := value.(string)
  25896. if !ok {
  25897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25898. }
  25899. m.SetName(v)
  25900. return nil
  25901. case sopstage.FieldConditionType:
  25902. v, ok := value.(int)
  25903. if !ok {
  25904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25905. }
  25906. m.SetConditionType(v)
  25907. return nil
  25908. case sopstage.FieldConditionOperator:
  25909. v, ok := value.(int)
  25910. if !ok {
  25911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25912. }
  25913. m.SetConditionOperator(v)
  25914. return nil
  25915. case sopstage.FieldConditionList:
  25916. v, ok := value.([]custom_types.Condition)
  25917. if !ok {
  25918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25919. }
  25920. m.SetConditionList(v)
  25921. return nil
  25922. case sopstage.FieldActionMessage:
  25923. v, ok := value.([]custom_types.Action)
  25924. if !ok {
  25925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25926. }
  25927. m.SetActionMessage(v)
  25928. return nil
  25929. case sopstage.FieldActionLabelAdd:
  25930. v, ok := value.([]uint64)
  25931. if !ok {
  25932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25933. }
  25934. m.SetActionLabelAdd(v)
  25935. return nil
  25936. case sopstage.FieldActionLabelDel:
  25937. v, ok := value.([]uint64)
  25938. if !ok {
  25939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25940. }
  25941. m.SetActionLabelDel(v)
  25942. return nil
  25943. case sopstage.FieldActionForward:
  25944. v, ok := value.(*custom_types.ActionForward)
  25945. if !ok {
  25946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25947. }
  25948. m.SetActionForward(v)
  25949. return nil
  25950. case sopstage.FieldIndexSort:
  25951. v, ok := value.(int)
  25952. if !ok {
  25953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25954. }
  25955. m.SetIndexSort(v)
  25956. return nil
  25957. }
  25958. return fmt.Errorf("unknown SopStage field %s", name)
  25959. }
  25960. // AddedFields returns all numeric fields that were incremented/decremented during
  25961. // this mutation.
  25962. func (m *SopStageMutation) AddedFields() []string {
  25963. var fields []string
  25964. if m.addstatus != nil {
  25965. fields = append(fields, sopstage.FieldStatus)
  25966. }
  25967. if m.addcondition_type != nil {
  25968. fields = append(fields, sopstage.FieldConditionType)
  25969. }
  25970. if m.addcondition_operator != nil {
  25971. fields = append(fields, sopstage.FieldConditionOperator)
  25972. }
  25973. if m.addindex_sort != nil {
  25974. fields = append(fields, sopstage.FieldIndexSort)
  25975. }
  25976. return fields
  25977. }
  25978. // AddedField returns the numeric value that was incremented/decremented on a field
  25979. // with the given name. The second boolean return value indicates that this field
  25980. // was not set, or was not defined in the schema.
  25981. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25982. switch name {
  25983. case sopstage.FieldStatus:
  25984. return m.AddedStatus()
  25985. case sopstage.FieldConditionType:
  25986. return m.AddedConditionType()
  25987. case sopstage.FieldConditionOperator:
  25988. return m.AddedConditionOperator()
  25989. case sopstage.FieldIndexSort:
  25990. return m.AddedIndexSort()
  25991. }
  25992. return nil, false
  25993. }
  25994. // AddField adds the value to the field with the given name. It returns an error if
  25995. // the field is not defined in the schema, or if the type mismatched the field
  25996. // type.
  25997. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25998. switch name {
  25999. case sopstage.FieldStatus:
  26000. v, ok := value.(int8)
  26001. if !ok {
  26002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26003. }
  26004. m.AddStatus(v)
  26005. return nil
  26006. case sopstage.FieldConditionType:
  26007. v, ok := value.(int)
  26008. if !ok {
  26009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26010. }
  26011. m.AddConditionType(v)
  26012. return nil
  26013. case sopstage.FieldConditionOperator:
  26014. v, ok := value.(int)
  26015. if !ok {
  26016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26017. }
  26018. m.AddConditionOperator(v)
  26019. return nil
  26020. case sopstage.FieldIndexSort:
  26021. v, ok := value.(int)
  26022. if !ok {
  26023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26024. }
  26025. m.AddIndexSort(v)
  26026. return nil
  26027. }
  26028. return fmt.Errorf("unknown SopStage numeric field %s", name)
  26029. }
  26030. // ClearedFields returns all nullable fields that were cleared during this
  26031. // mutation.
  26032. func (m *SopStageMutation) ClearedFields() []string {
  26033. var fields []string
  26034. if m.FieldCleared(sopstage.FieldStatus) {
  26035. fields = append(fields, sopstage.FieldStatus)
  26036. }
  26037. if m.FieldCleared(sopstage.FieldDeletedAt) {
  26038. fields = append(fields, sopstage.FieldDeletedAt)
  26039. }
  26040. if m.FieldCleared(sopstage.FieldActionMessage) {
  26041. fields = append(fields, sopstage.FieldActionMessage)
  26042. }
  26043. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  26044. fields = append(fields, sopstage.FieldActionLabelAdd)
  26045. }
  26046. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  26047. fields = append(fields, sopstage.FieldActionLabelDel)
  26048. }
  26049. if m.FieldCleared(sopstage.FieldActionForward) {
  26050. fields = append(fields, sopstage.FieldActionForward)
  26051. }
  26052. if m.FieldCleared(sopstage.FieldIndexSort) {
  26053. fields = append(fields, sopstage.FieldIndexSort)
  26054. }
  26055. return fields
  26056. }
  26057. // FieldCleared returns a boolean indicating if a field with the given name was
  26058. // cleared in this mutation.
  26059. func (m *SopStageMutation) FieldCleared(name string) bool {
  26060. _, ok := m.clearedFields[name]
  26061. return ok
  26062. }
  26063. // ClearField clears the value of the field with the given name. It returns an
  26064. // error if the field is not defined in the schema.
  26065. func (m *SopStageMutation) ClearField(name string) error {
  26066. switch name {
  26067. case sopstage.FieldStatus:
  26068. m.ClearStatus()
  26069. return nil
  26070. case sopstage.FieldDeletedAt:
  26071. m.ClearDeletedAt()
  26072. return nil
  26073. case sopstage.FieldActionMessage:
  26074. m.ClearActionMessage()
  26075. return nil
  26076. case sopstage.FieldActionLabelAdd:
  26077. m.ClearActionLabelAdd()
  26078. return nil
  26079. case sopstage.FieldActionLabelDel:
  26080. m.ClearActionLabelDel()
  26081. return nil
  26082. case sopstage.FieldActionForward:
  26083. m.ClearActionForward()
  26084. return nil
  26085. case sopstage.FieldIndexSort:
  26086. m.ClearIndexSort()
  26087. return nil
  26088. }
  26089. return fmt.Errorf("unknown SopStage nullable field %s", name)
  26090. }
  26091. // ResetField resets all changes in the mutation for the field with the given name.
  26092. // It returns an error if the field is not defined in the schema.
  26093. func (m *SopStageMutation) ResetField(name string) error {
  26094. switch name {
  26095. case sopstage.FieldCreatedAt:
  26096. m.ResetCreatedAt()
  26097. return nil
  26098. case sopstage.FieldUpdatedAt:
  26099. m.ResetUpdatedAt()
  26100. return nil
  26101. case sopstage.FieldStatus:
  26102. m.ResetStatus()
  26103. return nil
  26104. case sopstage.FieldDeletedAt:
  26105. m.ResetDeletedAt()
  26106. return nil
  26107. case sopstage.FieldTaskID:
  26108. m.ResetTaskID()
  26109. return nil
  26110. case sopstage.FieldName:
  26111. m.ResetName()
  26112. return nil
  26113. case sopstage.FieldConditionType:
  26114. m.ResetConditionType()
  26115. return nil
  26116. case sopstage.FieldConditionOperator:
  26117. m.ResetConditionOperator()
  26118. return nil
  26119. case sopstage.FieldConditionList:
  26120. m.ResetConditionList()
  26121. return nil
  26122. case sopstage.FieldActionMessage:
  26123. m.ResetActionMessage()
  26124. return nil
  26125. case sopstage.FieldActionLabelAdd:
  26126. m.ResetActionLabelAdd()
  26127. return nil
  26128. case sopstage.FieldActionLabelDel:
  26129. m.ResetActionLabelDel()
  26130. return nil
  26131. case sopstage.FieldActionForward:
  26132. m.ResetActionForward()
  26133. return nil
  26134. case sopstage.FieldIndexSort:
  26135. m.ResetIndexSort()
  26136. return nil
  26137. }
  26138. return fmt.Errorf("unknown SopStage field %s", name)
  26139. }
  26140. // AddedEdges returns all edge names that were set/added in this mutation.
  26141. func (m *SopStageMutation) AddedEdges() []string {
  26142. edges := make([]string, 0, 3)
  26143. if m.sop_task != nil {
  26144. edges = append(edges, sopstage.EdgeSopTask)
  26145. }
  26146. if m.stage_nodes != nil {
  26147. edges = append(edges, sopstage.EdgeStageNodes)
  26148. }
  26149. if m.stage_messages != nil {
  26150. edges = append(edges, sopstage.EdgeStageMessages)
  26151. }
  26152. return edges
  26153. }
  26154. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26155. // name in this mutation.
  26156. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  26157. switch name {
  26158. case sopstage.EdgeSopTask:
  26159. if id := m.sop_task; id != nil {
  26160. return []ent.Value{*id}
  26161. }
  26162. case sopstage.EdgeStageNodes:
  26163. ids := make([]ent.Value, 0, len(m.stage_nodes))
  26164. for id := range m.stage_nodes {
  26165. ids = append(ids, id)
  26166. }
  26167. return ids
  26168. case sopstage.EdgeStageMessages:
  26169. ids := make([]ent.Value, 0, len(m.stage_messages))
  26170. for id := range m.stage_messages {
  26171. ids = append(ids, id)
  26172. }
  26173. return ids
  26174. }
  26175. return nil
  26176. }
  26177. // RemovedEdges returns all edge names that were removed in this mutation.
  26178. func (m *SopStageMutation) RemovedEdges() []string {
  26179. edges := make([]string, 0, 3)
  26180. if m.removedstage_nodes != nil {
  26181. edges = append(edges, sopstage.EdgeStageNodes)
  26182. }
  26183. if m.removedstage_messages != nil {
  26184. edges = append(edges, sopstage.EdgeStageMessages)
  26185. }
  26186. return edges
  26187. }
  26188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26189. // the given name in this mutation.
  26190. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  26191. switch name {
  26192. case sopstage.EdgeStageNodes:
  26193. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  26194. for id := range m.removedstage_nodes {
  26195. ids = append(ids, id)
  26196. }
  26197. return ids
  26198. case sopstage.EdgeStageMessages:
  26199. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  26200. for id := range m.removedstage_messages {
  26201. ids = append(ids, id)
  26202. }
  26203. return ids
  26204. }
  26205. return nil
  26206. }
  26207. // ClearedEdges returns all edge names that were cleared in this mutation.
  26208. func (m *SopStageMutation) ClearedEdges() []string {
  26209. edges := make([]string, 0, 3)
  26210. if m.clearedsop_task {
  26211. edges = append(edges, sopstage.EdgeSopTask)
  26212. }
  26213. if m.clearedstage_nodes {
  26214. edges = append(edges, sopstage.EdgeStageNodes)
  26215. }
  26216. if m.clearedstage_messages {
  26217. edges = append(edges, sopstage.EdgeStageMessages)
  26218. }
  26219. return edges
  26220. }
  26221. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26222. // was cleared in this mutation.
  26223. func (m *SopStageMutation) EdgeCleared(name string) bool {
  26224. switch name {
  26225. case sopstage.EdgeSopTask:
  26226. return m.clearedsop_task
  26227. case sopstage.EdgeStageNodes:
  26228. return m.clearedstage_nodes
  26229. case sopstage.EdgeStageMessages:
  26230. return m.clearedstage_messages
  26231. }
  26232. return false
  26233. }
  26234. // ClearEdge clears the value of the edge with the given name. It returns an error
  26235. // if that edge is not defined in the schema.
  26236. func (m *SopStageMutation) ClearEdge(name string) error {
  26237. switch name {
  26238. case sopstage.EdgeSopTask:
  26239. m.ClearSopTask()
  26240. return nil
  26241. }
  26242. return fmt.Errorf("unknown SopStage unique edge %s", name)
  26243. }
  26244. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26245. // It returns an error if the edge is not defined in the schema.
  26246. func (m *SopStageMutation) ResetEdge(name string) error {
  26247. switch name {
  26248. case sopstage.EdgeSopTask:
  26249. m.ResetSopTask()
  26250. return nil
  26251. case sopstage.EdgeStageNodes:
  26252. m.ResetStageNodes()
  26253. return nil
  26254. case sopstage.EdgeStageMessages:
  26255. m.ResetStageMessages()
  26256. return nil
  26257. }
  26258. return fmt.Errorf("unknown SopStage edge %s", name)
  26259. }
  26260. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  26261. type SopTaskMutation struct {
  26262. config
  26263. op Op
  26264. typ string
  26265. id *uint64
  26266. created_at *time.Time
  26267. updated_at *time.Time
  26268. status *uint8
  26269. addstatus *int8
  26270. deleted_at *time.Time
  26271. name *string
  26272. bot_wxid_list *[]string
  26273. appendbot_wxid_list []string
  26274. _type *int
  26275. add_type *int
  26276. plan_start_time *time.Time
  26277. plan_end_time *time.Time
  26278. creator_id *string
  26279. organization_id *uint64
  26280. addorganization_id *int64
  26281. token *[]string
  26282. appendtoken []string
  26283. clearedFields map[string]struct{}
  26284. task_stages map[uint64]struct{}
  26285. removedtask_stages map[uint64]struct{}
  26286. clearedtask_stages bool
  26287. done bool
  26288. oldValue func(context.Context) (*SopTask, error)
  26289. predicates []predicate.SopTask
  26290. }
  26291. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26292. // soptaskOption allows management of the mutation configuration using functional options.
  26293. type soptaskOption func(*SopTaskMutation)
  26294. // newSopTaskMutation creates new mutation for the SopTask entity.
  26295. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  26296. m := &SopTaskMutation{
  26297. config: c,
  26298. op: op,
  26299. typ: TypeSopTask,
  26300. clearedFields: make(map[string]struct{}),
  26301. }
  26302. for _, opt := range opts {
  26303. opt(m)
  26304. }
  26305. return m
  26306. }
  26307. // withSopTaskID sets the ID field of the mutation.
  26308. func withSopTaskID(id uint64) soptaskOption {
  26309. return func(m *SopTaskMutation) {
  26310. var (
  26311. err error
  26312. once sync.Once
  26313. value *SopTask
  26314. )
  26315. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  26316. once.Do(func() {
  26317. if m.done {
  26318. err = errors.New("querying old values post mutation is not allowed")
  26319. } else {
  26320. value, err = m.Client().SopTask.Get(ctx, id)
  26321. }
  26322. })
  26323. return value, err
  26324. }
  26325. m.id = &id
  26326. }
  26327. }
  26328. // withSopTask sets the old SopTask of the mutation.
  26329. func withSopTask(node *SopTask) soptaskOption {
  26330. return func(m *SopTaskMutation) {
  26331. m.oldValue = func(context.Context) (*SopTask, error) {
  26332. return node, nil
  26333. }
  26334. m.id = &node.ID
  26335. }
  26336. }
  26337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26338. // executed in a transaction (ent.Tx), a transactional client is returned.
  26339. func (m SopTaskMutation) Client() *Client {
  26340. client := &Client{config: m.config}
  26341. client.init()
  26342. return client
  26343. }
  26344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26345. // it returns an error otherwise.
  26346. func (m SopTaskMutation) Tx() (*Tx, error) {
  26347. if _, ok := m.driver.(*txDriver); !ok {
  26348. return nil, errors.New("ent: mutation is not running in a transaction")
  26349. }
  26350. tx := &Tx{config: m.config}
  26351. tx.init()
  26352. return tx, nil
  26353. }
  26354. // SetID sets the value of the id field. Note that this
  26355. // operation is only accepted on creation of SopTask entities.
  26356. func (m *SopTaskMutation) SetID(id uint64) {
  26357. m.id = &id
  26358. }
  26359. // ID returns the ID value in the mutation. Note that the ID is only available
  26360. // if it was provided to the builder or after it was returned from the database.
  26361. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  26362. if m.id == nil {
  26363. return
  26364. }
  26365. return *m.id, true
  26366. }
  26367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26368. // That means, if the mutation is applied within a transaction with an isolation level such
  26369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26370. // or updated by the mutation.
  26371. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26372. switch {
  26373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26374. id, exists := m.ID()
  26375. if exists {
  26376. return []uint64{id}, nil
  26377. }
  26378. fallthrough
  26379. case m.op.Is(OpUpdate | OpDelete):
  26380. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26381. default:
  26382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26383. }
  26384. }
  26385. // SetCreatedAt sets the "created_at" field.
  26386. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26387. m.created_at = &t
  26388. }
  26389. // CreatedAt returns the value of the "created_at" field in the mutation.
  26390. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26391. v := m.created_at
  26392. if v == nil {
  26393. return
  26394. }
  26395. return *v, true
  26396. }
  26397. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26398. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26400. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26401. if !m.op.Is(OpUpdateOne) {
  26402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26403. }
  26404. if m.id == nil || m.oldValue == nil {
  26405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26406. }
  26407. oldValue, err := m.oldValue(ctx)
  26408. if err != nil {
  26409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26410. }
  26411. return oldValue.CreatedAt, nil
  26412. }
  26413. // ResetCreatedAt resets all changes to the "created_at" field.
  26414. func (m *SopTaskMutation) ResetCreatedAt() {
  26415. m.created_at = nil
  26416. }
  26417. // SetUpdatedAt sets the "updated_at" field.
  26418. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26419. m.updated_at = &t
  26420. }
  26421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26422. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26423. v := m.updated_at
  26424. if v == nil {
  26425. return
  26426. }
  26427. return *v, true
  26428. }
  26429. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26430. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26432. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26433. if !m.op.Is(OpUpdateOne) {
  26434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26435. }
  26436. if m.id == nil || m.oldValue == nil {
  26437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26438. }
  26439. oldValue, err := m.oldValue(ctx)
  26440. if err != nil {
  26441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26442. }
  26443. return oldValue.UpdatedAt, nil
  26444. }
  26445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26446. func (m *SopTaskMutation) ResetUpdatedAt() {
  26447. m.updated_at = nil
  26448. }
  26449. // SetStatus sets the "status" field.
  26450. func (m *SopTaskMutation) SetStatus(u uint8) {
  26451. m.status = &u
  26452. m.addstatus = nil
  26453. }
  26454. // Status returns the value of the "status" field in the mutation.
  26455. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26456. v := m.status
  26457. if v == nil {
  26458. return
  26459. }
  26460. return *v, true
  26461. }
  26462. // OldStatus returns the old "status" field's value of the SopTask entity.
  26463. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26465. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26466. if !m.op.Is(OpUpdateOne) {
  26467. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26468. }
  26469. if m.id == nil || m.oldValue == nil {
  26470. return v, errors.New("OldStatus requires an ID field in the mutation")
  26471. }
  26472. oldValue, err := m.oldValue(ctx)
  26473. if err != nil {
  26474. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26475. }
  26476. return oldValue.Status, nil
  26477. }
  26478. // AddStatus adds u to the "status" field.
  26479. func (m *SopTaskMutation) AddStatus(u int8) {
  26480. if m.addstatus != nil {
  26481. *m.addstatus += u
  26482. } else {
  26483. m.addstatus = &u
  26484. }
  26485. }
  26486. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26487. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26488. v := m.addstatus
  26489. if v == nil {
  26490. return
  26491. }
  26492. return *v, true
  26493. }
  26494. // ClearStatus clears the value of the "status" field.
  26495. func (m *SopTaskMutation) ClearStatus() {
  26496. m.status = nil
  26497. m.addstatus = nil
  26498. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26499. }
  26500. // StatusCleared returns if the "status" field was cleared in this mutation.
  26501. func (m *SopTaskMutation) StatusCleared() bool {
  26502. _, ok := m.clearedFields[soptask.FieldStatus]
  26503. return ok
  26504. }
  26505. // ResetStatus resets all changes to the "status" field.
  26506. func (m *SopTaskMutation) ResetStatus() {
  26507. m.status = nil
  26508. m.addstatus = nil
  26509. delete(m.clearedFields, soptask.FieldStatus)
  26510. }
  26511. // SetDeletedAt sets the "deleted_at" field.
  26512. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26513. m.deleted_at = &t
  26514. }
  26515. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26516. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26517. v := m.deleted_at
  26518. if v == nil {
  26519. return
  26520. }
  26521. return *v, true
  26522. }
  26523. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26524. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26526. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26527. if !m.op.Is(OpUpdateOne) {
  26528. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26529. }
  26530. if m.id == nil || m.oldValue == nil {
  26531. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26532. }
  26533. oldValue, err := m.oldValue(ctx)
  26534. if err != nil {
  26535. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26536. }
  26537. return oldValue.DeletedAt, nil
  26538. }
  26539. // ClearDeletedAt clears the value of the "deleted_at" field.
  26540. func (m *SopTaskMutation) ClearDeletedAt() {
  26541. m.deleted_at = nil
  26542. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26543. }
  26544. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26545. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26546. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26547. return ok
  26548. }
  26549. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26550. func (m *SopTaskMutation) ResetDeletedAt() {
  26551. m.deleted_at = nil
  26552. delete(m.clearedFields, soptask.FieldDeletedAt)
  26553. }
  26554. // SetName sets the "name" field.
  26555. func (m *SopTaskMutation) SetName(s string) {
  26556. m.name = &s
  26557. }
  26558. // Name returns the value of the "name" field in the mutation.
  26559. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26560. v := m.name
  26561. if v == nil {
  26562. return
  26563. }
  26564. return *v, true
  26565. }
  26566. // OldName returns the old "name" field's value of the SopTask entity.
  26567. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26569. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26570. if !m.op.Is(OpUpdateOne) {
  26571. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26572. }
  26573. if m.id == nil || m.oldValue == nil {
  26574. return v, errors.New("OldName requires an ID field in the mutation")
  26575. }
  26576. oldValue, err := m.oldValue(ctx)
  26577. if err != nil {
  26578. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26579. }
  26580. return oldValue.Name, nil
  26581. }
  26582. // ResetName resets all changes to the "name" field.
  26583. func (m *SopTaskMutation) ResetName() {
  26584. m.name = nil
  26585. }
  26586. // SetBotWxidList sets the "bot_wxid_list" field.
  26587. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26588. m.bot_wxid_list = &s
  26589. m.appendbot_wxid_list = nil
  26590. }
  26591. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26592. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26593. v := m.bot_wxid_list
  26594. if v == nil {
  26595. return
  26596. }
  26597. return *v, true
  26598. }
  26599. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26600. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26602. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26603. if !m.op.Is(OpUpdateOne) {
  26604. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26605. }
  26606. if m.id == nil || m.oldValue == nil {
  26607. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26608. }
  26609. oldValue, err := m.oldValue(ctx)
  26610. if err != nil {
  26611. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26612. }
  26613. return oldValue.BotWxidList, nil
  26614. }
  26615. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26616. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26617. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26618. }
  26619. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26620. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26621. if len(m.appendbot_wxid_list) == 0 {
  26622. return nil, false
  26623. }
  26624. return m.appendbot_wxid_list, true
  26625. }
  26626. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26627. func (m *SopTaskMutation) ClearBotWxidList() {
  26628. m.bot_wxid_list = nil
  26629. m.appendbot_wxid_list = nil
  26630. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26631. }
  26632. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26633. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26634. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26635. return ok
  26636. }
  26637. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26638. func (m *SopTaskMutation) ResetBotWxidList() {
  26639. m.bot_wxid_list = nil
  26640. m.appendbot_wxid_list = nil
  26641. delete(m.clearedFields, soptask.FieldBotWxidList)
  26642. }
  26643. // SetType sets the "type" field.
  26644. func (m *SopTaskMutation) SetType(i int) {
  26645. m._type = &i
  26646. m.add_type = nil
  26647. }
  26648. // GetType returns the value of the "type" field in the mutation.
  26649. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26650. v := m._type
  26651. if v == nil {
  26652. return
  26653. }
  26654. return *v, true
  26655. }
  26656. // OldType returns the old "type" field's value of the SopTask entity.
  26657. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26659. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26660. if !m.op.Is(OpUpdateOne) {
  26661. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26662. }
  26663. if m.id == nil || m.oldValue == nil {
  26664. return v, errors.New("OldType requires an ID field in the mutation")
  26665. }
  26666. oldValue, err := m.oldValue(ctx)
  26667. if err != nil {
  26668. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26669. }
  26670. return oldValue.Type, nil
  26671. }
  26672. // AddType adds i to the "type" field.
  26673. func (m *SopTaskMutation) AddType(i int) {
  26674. if m.add_type != nil {
  26675. *m.add_type += i
  26676. } else {
  26677. m.add_type = &i
  26678. }
  26679. }
  26680. // AddedType returns the value that was added to the "type" field in this mutation.
  26681. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26682. v := m.add_type
  26683. if v == nil {
  26684. return
  26685. }
  26686. return *v, true
  26687. }
  26688. // ResetType resets all changes to the "type" field.
  26689. func (m *SopTaskMutation) ResetType() {
  26690. m._type = nil
  26691. m.add_type = nil
  26692. }
  26693. // SetPlanStartTime sets the "plan_start_time" field.
  26694. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26695. m.plan_start_time = &t
  26696. }
  26697. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26698. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26699. v := m.plan_start_time
  26700. if v == nil {
  26701. return
  26702. }
  26703. return *v, true
  26704. }
  26705. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26706. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26708. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26709. if !m.op.Is(OpUpdateOne) {
  26710. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26711. }
  26712. if m.id == nil || m.oldValue == nil {
  26713. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26714. }
  26715. oldValue, err := m.oldValue(ctx)
  26716. if err != nil {
  26717. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26718. }
  26719. return oldValue.PlanStartTime, nil
  26720. }
  26721. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26722. func (m *SopTaskMutation) ClearPlanStartTime() {
  26723. m.plan_start_time = nil
  26724. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26725. }
  26726. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26727. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26728. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26729. return ok
  26730. }
  26731. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26732. func (m *SopTaskMutation) ResetPlanStartTime() {
  26733. m.plan_start_time = nil
  26734. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26735. }
  26736. // SetPlanEndTime sets the "plan_end_time" field.
  26737. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26738. m.plan_end_time = &t
  26739. }
  26740. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26741. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26742. v := m.plan_end_time
  26743. if v == nil {
  26744. return
  26745. }
  26746. return *v, true
  26747. }
  26748. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26749. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26751. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26752. if !m.op.Is(OpUpdateOne) {
  26753. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26754. }
  26755. if m.id == nil || m.oldValue == nil {
  26756. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26757. }
  26758. oldValue, err := m.oldValue(ctx)
  26759. if err != nil {
  26760. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26761. }
  26762. return oldValue.PlanEndTime, nil
  26763. }
  26764. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26765. func (m *SopTaskMutation) ClearPlanEndTime() {
  26766. m.plan_end_time = nil
  26767. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26768. }
  26769. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26770. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26771. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26772. return ok
  26773. }
  26774. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26775. func (m *SopTaskMutation) ResetPlanEndTime() {
  26776. m.plan_end_time = nil
  26777. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26778. }
  26779. // SetCreatorID sets the "creator_id" field.
  26780. func (m *SopTaskMutation) SetCreatorID(s string) {
  26781. m.creator_id = &s
  26782. }
  26783. // CreatorID returns the value of the "creator_id" field in the mutation.
  26784. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26785. v := m.creator_id
  26786. if v == nil {
  26787. return
  26788. }
  26789. return *v, true
  26790. }
  26791. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26792. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26794. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26795. if !m.op.Is(OpUpdateOne) {
  26796. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26797. }
  26798. if m.id == nil || m.oldValue == nil {
  26799. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26800. }
  26801. oldValue, err := m.oldValue(ctx)
  26802. if err != nil {
  26803. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26804. }
  26805. return oldValue.CreatorID, nil
  26806. }
  26807. // ClearCreatorID clears the value of the "creator_id" field.
  26808. func (m *SopTaskMutation) ClearCreatorID() {
  26809. m.creator_id = nil
  26810. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26811. }
  26812. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26813. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26814. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26815. return ok
  26816. }
  26817. // ResetCreatorID resets all changes to the "creator_id" field.
  26818. func (m *SopTaskMutation) ResetCreatorID() {
  26819. m.creator_id = nil
  26820. delete(m.clearedFields, soptask.FieldCreatorID)
  26821. }
  26822. // SetOrganizationID sets the "organization_id" field.
  26823. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26824. m.organization_id = &u
  26825. m.addorganization_id = nil
  26826. }
  26827. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26828. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26829. v := m.organization_id
  26830. if v == nil {
  26831. return
  26832. }
  26833. return *v, true
  26834. }
  26835. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26836. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26838. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26839. if !m.op.Is(OpUpdateOne) {
  26840. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26841. }
  26842. if m.id == nil || m.oldValue == nil {
  26843. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26844. }
  26845. oldValue, err := m.oldValue(ctx)
  26846. if err != nil {
  26847. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26848. }
  26849. return oldValue.OrganizationID, nil
  26850. }
  26851. // AddOrganizationID adds u to the "organization_id" field.
  26852. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26853. if m.addorganization_id != nil {
  26854. *m.addorganization_id += u
  26855. } else {
  26856. m.addorganization_id = &u
  26857. }
  26858. }
  26859. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26860. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26861. v := m.addorganization_id
  26862. if v == nil {
  26863. return
  26864. }
  26865. return *v, true
  26866. }
  26867. // ClearOrganizationID clears the value of the "organization_id" field.
  26868. func (m *SopTaskMutation) ClearOrganizationID() {
  26869. m.organization_id = nil
  26870. m.addorganization_id = nil
  26871. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26872. }
  26873. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26874. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26875. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26876. return ok
  26877. }
  26878. // ResetOrganizationID resets all changes to the "organization_id" field.
  26879. func (m *SopTaskMutation) ResetOrganizationID() {
  26880. m.organization_id = nil
  26881. m.addorganization_id = nil
  26882. delete(m.clearedFields, soptask.FieldOrganizationID)
  26883. }
  26884. // SetToken sets the "token" field.
  26885. func (m *SopTaskMutation) SetToken(s []string) {
  26886. m.token = &s
  26887. m.appendtoken = nil
  26888. }
  26889. // Token returns the value of the "token" field in the mutation.
  26890. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26891. v := m.token
  26892. if v == nil {
  26893. return
  26894. }
  26895. return *v, true
  26896. }
  26897. // OldToken returns the old "token" field's value of the SopTask entity.
  26898. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26900. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26901. if !m.op.Is(OpUpdateOne) {
  26902. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26903. }
  26904. if m.id == nil || m.oldValue == nil {
  26905. return v, errors.New("OldToken requires an ID field in the mutation")
  26906. }
  26907. oldValue, err := m.oldValue(ctx)
  26908. if err != nil {
  26909. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26910. }
  26911. return oldValue.Token, nil
  26912. }
  26913. // AppendToken adds s to the "token" field.
  26914. func (m *SopTaskMutation) AppendToken(s []string) {
  26915. m.appendtoken = append(m.appendtoken, s...)
  26916. }
  26917. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26918. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26919. if len(m.appendtoken) == 0 {
  26920. return nil, false
  26921. }
  26922. return m.appendtoken, true
  26923. }
  26924. // ClearToken clears the value of the "token" field.
  26925. func (m *SopTaskMutation) ClearToken() {
  26926. m.token = nil
  26927. m.appendtoken = nil
  26928. m.clearedFields[soptask.FieldToken] = struct{}{}
  26929. }
  26930. // TokenCleared returns if the "token" field was cleared in this mutation.
  26931. func (m *SopTaskMutation) TokenCleared() bool {
  26932. _, ok := m.clearedFields[soptask.FieldToken]
  26933. return ok
  26934. }
  26935. // ResetToken resets all changes to the "token" field.
  26936. func (m *SopTaskMutation) ResetToken() {
  26937. m.token = nil
  26938. m.appendtoken = nil
  26939. delete(m.clearedFields, soptask.FieldToken)
  26940. }
  26941. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26942. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26943. if m.task_stages == nil {
  26944. m.task_stages = make(map[uint64]struct{})
  26945. }
  26946. for i := range ids {
  26947. m.task_stages[ids[i]] = struct{}{}
  26948. }
  26949. }
  26950. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26951. func (m *SopTaskMutation) ClearTaskStages() {
  26952. m.clearedtask_stages = true
  26953. }
  26954. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26955. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26956. return m.clearedtask_stages
  26957. }
  26958. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26959. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26960. if m.removedtask_stages == nil {
  26961. m.removedtask_stages = make(map[uint64]struct{})
  26962. }
  26963. for i := range ids {
  26964. delete(m.task_stages, ids[i])
  26965. m.removedtask_stages[ids[i]] = struct{}{}
  26966. }
  26967. }
  26968. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26969. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26970. for id := range m.removedtask_stages {
  26971. ids = append(ids, id)
  26972. }
  26973. return
  26974. }
  26975. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26976. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26977. for id := range m.task_stages {
  26978. ids = append(ids, id)
  26979. }
  26980. return
  26981. }
  26982. // ResetTaskStages resets all changes to the "task_stages" edge.
  26983. func (m *SopTaskMutation) ResetTaskStages() {
  26984. m.task_stages = nil
  26985. m.clearedtask_stages = false
  26986. m.removedtask_stages = nil
  26987. }
  26988. // Where appends a list predicates to the SopTaskMutation builder.
  26989. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26990. m.predicates = append(m.predicates, ps...)
  26991. }
  26992. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26993. // users can use type-assertion to append predicates that do not depend on any generated package.
  26994. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26995. p := make([]predicate.SopTask, len(ps))
  26996. for i := range ps {
  26997. p[i] = ps[i]
  26998. }
  26999. m.Where(p...)
  27000. }
  27001. // Op returns the operation name.
  27002. func (m *SopTaskMutation) Op() Op {
  27003. return m.op
  27004. }
  27005. // SetOp allows setting the mutation operation.
  27006. func (m *SopTaskMutation) SetOp(op Op) {
  27007. m.op = op
  27008. }
  27009. // Type returns the node type of this mutation (SopTask).
  27010. func (m *SopTaskMutation) Type() string {
  27011. return m.typ
  27012. }
  27013. // Fields returns all fields that were changed during this mutation. Note that in
  27014. // order to get all numeric fields that were incremented/decremented, call
  27015. // AddedFields().
  27016. func (m *SopTaskMutation) Fields() []string {
  27017. fields := make([]string, 0, 12)
  27018. if m.created_at != nil {
  27019. fields = append(fields, soptask.FieldCreatedAt)
  27020. }
  27021. if m.updated_at != nil {
  27022. fields = append(fields, soptask.FieldUpdatedAt)
  27023. }
  27024. if m.status != nil {
  27025. fields = append(fields, soptask.FieldStatus)
  27026. }
  27027. if m.deleted_at != nil {
  27028. fields = append(fields, soptask.FieldDeletedAt)
  27029. }
  27030. if m.name != nil {
  27031. fields = append(fields, soptask.FieldName)
  27032. }
  27033. if m.bot_wxid_list != nil {
  27034. fields = append(fields, soptask.FieldBotWxidList)
  27035. }
  27036. if m._type != nil {
  27037. fields = append(fields, soptask.FieldType)
  27038. }
  27039. if m.plan_start_time != nil {
  27040. fields = append(fields, soptask.FieldPlanStartTime)
  27041. }
  27042. if m.plan_end_time != nil {
  27043. fields = append(fields, soptask.FieldPlanEndTime)
  27044. }
  27045. if m.creator_id != nil {
  27046. fields = append(fields, soptask.FieldCreatorID)
  27047. }
  27048. if m.organization_id != nil {
  27049. fields = append(fields, soptask.FieldOrganizationID)
  27050. }
  27051. if m.token != nil {
  27052. fields = append(fields, soptask.FieldToken)
  27053. }
  27054. return fields
  27055. }
  27056. // Field returns the value of a field with the given name. The second boolean
  27057. // return value indicates that this field was not set, or was not defined in the
  27058. // schema.
  27059. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  27060. switch name {
  27061. case soptask.FieldCreatedAt:
  27062. return m.CreatedAt()
  27063. case soptask.FieldUpdatedAt:
  27064. return m.UpdatedAt()
  27065. case soptask.FieldStatus:
  27066. return m.Status()
  27067. case soptask.FieldDeletedAt:
  27068. return m.DeletedAt()
  27069. case soptask.FieldName:
  27070. return m.Name()
  27071. case soptask.FieldBotWxidList:
  27072. return m.BotWxidList()
  27073. case soptask.FieldType:
  27074. return m.GetType()
  27075. case soptask.FieldPlanStartTime:
  27076. return m.PlanStartTime()
  27077. case soptask.FieldPlanEndTime:
  27078. return m.PlanEndTime()
  27079. case soptask.FieldCreatorID:
  27080. return m.CreatorID()
  27081. case soptask.FieldOrganizationID:
  27082. return m.OrganizationID()
  27083. case soptask.FieldToken:
  27084. return m.Token()
  27085. }
  27086. return nil, false
  27087. }
  27088. // OldField returns the old value of the field from the database. An error is
  27089. // returned if the mutation operation is not UpdateOne, or the query to the
  27090. // database failed.
  27091. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27092. switch name {
  27093. case soptask.FieldCreatedAt:
  27094. return m.OldCreatedAt(ctx)
  27095. case soptask.FieldUpdatedAt:
  27096. return m.OldUpdatedAt(ctx)
  27097. case soptask.FieldStatus:
  27098. return m.OldStatus(ctx)
  27099. case soptask.FieldDeletedAt:
  27100. return m.OldDeletedAt(ctx)
  27101. case soptask.FieldName:
  27102. return m.OldName(ctx)
  27103. case soptask.FieldBotWxidList:
  27104. return m.OldBotWxidList(ctx)
  27105. case soptask.FieldType:
  27106. return m.OldType(ctx)
  27107. case soptask.FieldPlanStartTime:
  27108. return m.OldPlanStartTime(ctx)
  27109. case soptask.FieldPlanEndTime:
  27110. return m.OldPlanEndTime(ctx)
  27111. case soptask.FieldCreatorID:
  27112. return m.OldCreatorID(ctx)
  27113. case soptask.FieldOrganizationID:
  27114. return m.OldOrganizationID(ctx)
  27115. case soptask.FieldToken:
  27116. return m.OldToken(ctx)
  27117. }
  27118. return nil, fmt.Errorf("unknown SopTask field %s", name)
  27119. }
  27120. // SetField sets the value of a field with the given name. It returns an error if
  27121. // the field is not defined in the schema, or if the type mismatched the field
  27122. // type.
  27123. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  27124. switch name {
  27125. case soptask.FieldCreatedAt:
  27126. v, ok := value.(time.Time)
  27127. if !ok {
  27128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27129. }
  27130. m.SetCreatedAt(v)
  27131. return nil
  27132. case soptask.FieldUpdatedAt:
  27133. v, ok := value.(time.Time)
  27134. if !ok {
  27135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27136. }
  27137. m.SetUpdatedAt(v)
  27138. return nil
  27139. case soptask.FieldStatus:
  27140. v, ok := value.(uint8)
  27141. if !ok {
  27142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27143. }
  27144. m.SetStatus(v)
  27145. return nil
  27146. case soptask.FieldDeletedAt:
  27147. v, ok := value.(time.Time)
  27148. if !ok {
  27149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27150. }
  27151. m.SetDeletedAt(v)
  27152. return nil
  27153. case soptask.FieldName:
  27154. v, ok := value.(string)
  27155. if !ok {
  27156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27157. }
  27158. m.SetName(v)
  27159. return nil
  27160. case soptask.FieldBotWxidList:
  27161. v, ok := value.([]string)
  27162. if !ok {
  27163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27164. }
  27165. m.SetBotWxidList(v)
  27166. return nil
  27167. case soptask.FieldType:
  27168. v, ok := value.(int)
  27169. if !ok {
  27170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27171. }
  27172. m.SetType(v)
  27173. return nil
  27174. case soptask.FieldPlanStartTime:
  27175. v, ok := value.(time.Time)
  27176. if !ok {
  27177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27178. }
  27179. m.SetPlanStartTime(v)
  27180. return nil
  27181. case soptask.FieldPlanEndTime:
  27182. v, ok := value.(time.Time)
  27183. if !ok {
  27184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27185. }
  27186. m.SetPlanEndTime(v)
  27187. return nil
  27188. case soptask.FieldCreatorID:
  27189. v, ok := value.(string)
  27190. if !ok {
  27191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27192. }
  27193. m.SetCreatorID(v)
  27194. return nil
  27195. case soptask.FieldOrganizationID:
  27196. v, ok := value.(uint64)
  27197. if !ok {
  27198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27199. }
  27200. m.SetOrganizationID(v)
  27201. return nil
  27202. case soptask.FieldToken:
  27203. v, ok := value.([]string)
  27204. if !ok {
  27205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27206. }
  27207. m.SetToken(v)
  27208. return nil
  27209. }
  27210. return fmt.Errorf("unknown SopTask field %s", name)
  27211. }
  27212. // AddedFields returns all numeric fields that were incremented/decremented during
  27213. // this mutation.
  27214. func (m *SopTaskMutation) AddedFields() []string {
  27215. var fields []string
  27216. if m.addstatus != nil {
  27217. fields = append(fields, soptask.FieldStatus)
  27218. }
  27219. if m.add_type != nil {
  27220. fields = append(fields, soptask.FieldType)
  27221. }
  27222. if m.addorganization_id != nil {
  27223. fields = append(fields, soptask.FieldOrganizationID)
  27224. }
  27225. return fields
  27226. }
  27227. // AddedField returns the numeric value that was incremented/decremented on a field
  27228. // with the given name. The second boolean return value indicates that this field
  27229. // was not set, or was not defined in the schema.
  27230. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  27231. switch name {
  27232. case soptask.FieldStatus:
  27233. return m.AddedStatus()
  27234. case soptask.FieldType:
  27235. return m.AddedType()
  27236. case soptask.FieldOrganizationID:
  27237. return m.AddedOrganizationID()
  27238. }
  27239. return nil, false
  27240. }
  27241. // AddField adds the value to the field with the given name. It returns an error if
  27242. // the field is not defined in the schema, or if the type mismatched the field
  27243. // type.
  27244. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  27245. switch name {
  27246. case soptask.FieldStatus:
  27247. v, ok := value.(int8)
  27248. if !ok {
  27249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27250. }
  27251. m.AddStatus(v)
  27252. return nil
  27253. case soptask.FieldType:
  27254. v, ok := value.(int)
  27255. if !ok {
  27256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27257. }
  27258. m.AddType(v)
  27259. return nil
  27260. case soptask.FieldOrganizationID:
  27261. v, ok := value.(int64)
  27262. if !ok {
  27263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27264. }
  27265. m.AddOrganizationID(v)
  27266. return nil
  27267. }
  27268. return fmt.Errorf("unknown SopTask numeric field %s", name)
  27269. }
  27270. // ClearedFields returns all nullable fields that were cleared during this
  27271. // mutation.
  27272. func (m *SopTaskMutation) ClearedFields() []string {
  27273. var fields []string
  27274. if m.FieldCleared(soptask.FieldStatus) {
  27275. fields = append(fields, soptask.FieldStatus)
  27276. }
  27277. if m.FieldCleared(soptask.FieldDeletedAt) {
  27278. fields = append(fields, soptask.FieldDeletedAt)
  27279. }
  27280. if m.FieldCleared(soptask.FieldBotWxidList) {
  27281. fields = append(fields, soptask.FieldBotWxidList)
  27282. }
  27283. if m.FieldCleared(soptask.FieldPlanStartTime) {
  27284. fields = append(fields, soptask.FieldPlanStartTime)
  27285. }
  27286. if m.FieldCleared(soptask.FieldPlanEndTime) {
  27287. fields = append(fields, soptask.FieldPlanEndTime)
  27288. }
  27289. if m.FieldCleared(soptask.FieldCreatorID) {
  27290. fields = append(fields, soptask.FieldCreatorID)
  27291. }
  27292. if m.FieldCleared(soptask.FieldOrganizationID) {
  27293. fields = append(fields, soptask.FieldOrganizationID)
  27294. }
  27295. if m.FieldCleared(soptask.FieldToken) {
  27296. fields = append(fields, soptask.FieldToken)
  27297. }
  27298. return fields
  27299. }
  27300. // FieldCleared returns a boolean indicating if a field with the given name was
  27301. // cleared in this mutation.
  27302. func (m *SopTaskMutation) FieldCleared(name string) bool {
  27303. _, ok := m.clearedFields[name]
  27304. return ok
  27305. }
  27306. // ClearField clears the value of the field with the given name. It returns an
  27307. // error if the field is not defined in the schema.
  27308. func (m *SopTaskMutation) ClearField(name string) error {
  27309. switch name {
  27310. case soptask.FieldStatus:
  27311. m.ClearStatus()
  27312. return nil
  27313. case soptask.FieldDeletedAt:
  27314. m.ClearDeletedAt()
  27315. return nil
  27316. case soptask.FieldBotWxidList:
  27317. m.ClearBotWxidList()
  27318. return nil
  27319. case soptask.FieldPlanStartTime:
  27320. m.ClearPlanStartTime()
  27321. return nil
  27322. case soptask.FieldPlanEndTime:
  27323. m.ClearPlanEndTime()
  27324. return nil
  27325. case soptask.FieldCreatorID:
  27326. m.ClearCreatorID()
  27327. return nil
  27328. case soptask.FieldOrganizationID:
  27329. m.ClearOrganizationID()
  27330. return nil
  27331. case soptask.FieldToken:
  27332. m.ClearToken()
  27333. return nil
  27334. }
  27335. return fmt.Errorf("unknown SopTask nullable field %s", name)
  27336. }
  27337. // ResetField resets all changes in the mutation for the field with the given name.
  27338. // It returns an error if the field is not defined in the schema.
  27339. func (m *SopTaskMutation) ResetField(name string) error {
  27340. switch name {
  27341. case soptask.FieldCreatedAt:
  27342. m.ResetCreatedAt()
  27343. return nil
  27344. case soptask.FieldUpdatedAt:
  27345. m.ResetUpdatedAt()
  27346. return nil
  27347. case soptask.FieldStatus:
  27348. m.ResetStatus()
  27349. return nil
  27350. case soptask.FieldDeletedAt:
  27351. m.ResetDeletedAt()
  27352. return nil
  27353. case soptask.FieldName:
  27354. m.ResetName()
  27355. return nil
  27356. case soptask.FieldBotWxidList:
  27357. m.ResetBotWxidList()
  27358. return nil
  27359. case soptask.FieldType:
  27360. m.ResetType()
  27361. return nil
  27362. case soptask.FieldPlanStartTime:
  27363. m.ResetPlanStartTime()
  27364. return nil
  27365. case soptask.FieldPlanEndTime:
  27366. m.ResetPlanEndTime()
  27367. return nil
  27368. case soptask.FieldCreatorID:
  27369. m.ResetCreatorID()
  27370. return nil
  27371. case soptask.FieldOrganizationID:
  27372. m.ResetOrganizationID()
  27373. return nil
  27374. case soptask.FieldToken:
  27375. m.ResetToken()
  27376. return nil
  27377. }
  27378. return fmt.Errorf("unknown SopTask field %s", name)
  27379. }
  27380. // AddedEdges returns all edge names that were set/added in this mutation.
  27381. func (m *SopTaskMutation) AddedEdges() []string {
  27382. edges := make([]string, 0, 1)
  27383. if m.task_stages != nil {
  27384. edges = append(edges, soptask.EdgeTaskStages)
  27385. }
  27386. return edges
  27387. }
  27388. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27389. // name in this mutation.
  27390. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27391. switch name {
  27392. case soptask.EdgeTaskStages:
  27393. ids := make([]ent.Value, 0, len(m.task_stages))
  27394. for id := range m.task_stages {
  27395. ids = append(ids, id)
  27396. }
  27397. return ids
  27398. }
  27399. return nil
  27400. }
  27401. // RemovedEdges returns all edge names that were removed in this mutation.
  27402. func (m *SopTaskMutation) RemovedEdges() []string {
  27403. edges := make([]string, 0, 1)
  27404. if m.removedtask_stages != nil {
  27405. edges = append(edges, soptask.EdgeTaskStages)
  27406. }
  27407. return edges
  27408. }
  27409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27410. // the given name in this mutation.
  27411. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27412. switch name {
  27413. case soptask.EdgeTaskStages:
  27414. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27415. for id := range m.removedtask_stages {
  27416. ids = append(ids, id)
  27417. }
  27418. return ids
  27419. }
  27420. return nil
  27421. }
  27422. // ClearedEdges returns all edge names that were cleared in this mutation.
  27423. func (m *SopTaskMutation) ClearedEdges() []string {
  27424. edges := make([]string, 0, 1)
  27425. if m.clearedtask_stages {
  27426. edges = append(edges, soptask.EdgeTaskStages)
  27427. }
  27428. return edges
  27429. }
  27430. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27431. // was cleared in this mutation.
  27432. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27433. switch name {
  27434. case soptask.EdgeTaskStages:
  27435. return m.clearedtask_stages
  27436. }
  27437. return false
  27438. }
  27439. // ClearEdge clears the value of the edge with the given name. It returns an error
  27440. // if that edge is not defined in the schema.
  27441. func (m *SopTaskMutation) ClearEdge(name string) error {
  27442. switch name {
  27443. }
  27444. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27445. }
  27446. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27447. // It returns an error if the edge is not defined in the schema.
  27448. func (m *SopTaskMutation) ResetEdge(name string) error {
  27449. switch name {
  27450. case soptask.EdgeTaskStages:
  27451. m.ResetTaskStages()
  27452. return nil
  27453. }
  27454. return fmt.Errorf("unknown SopTask edge %s", name)
  27455. }
  27456. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27457. type TokenMutation struct {
  27458. config
  27459. op Op
  27460. typ string
  27461. id *uint64
  27462. created_at *time.Time
  27463. updated_at *time.Time
  27464. deleted_at *time.Time
  27465. expire_at *time.Time
  27466. token *string
  27467. mac *string
  27468. organization_id *uint64
  27469. addorganization_id *int64
  27470. custom_agent_base *string
  27471. custom_agent_key *string
  27472. openai_base *string
  27473. openai_key *string
  27474. clearedFields map[string]struct{}
  27475. agent *uint64
  27476. clearedagent bool
  27477. done bool
  27478. oldValue func(context.Context) (*Token, error)
  27479. predicates []predicate.Token
  27480. }
  27481. var _ ent.Mutation = (*TokenMutation)(nil)
  27482. // tokenOption allows management of the mutation configuration using functional options.
  27483. type tokenOption func(*TokenMutation)
  27484. // newTokenMutation creates new mutation for the Token entity.
  27485. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27486. m := &TokenMutation{
  27487. config: c,
  27488. op: op,
  27489. typ: TypeToken,
  27490. clearedFields: make(map[string]struct{}),
  27491. }
  27492. for _, opt := range opts {
  27493. opt(m)
  27494. }
  27495. return m
  27496. }
  27497. // withTokenID sets the ID field of the mutation.
  27498. func withTokenID(id uint64) tokenOption {
  27499. return func(m *TokenMutation) {
  27500. var (
  27501. err error
  27502. once sync.Once
  27503. value *Token
  27504. )
  27505. m.oldValue = func(ctx context.Context) (*Token, error) {
  27506. once.Do(func() {
  27507. if m.done {
  27508. err = errors.New("querying old values post mutation is not allowed")
  27509. } else {
  27510. value, err = m.Client().Token.Get(ctx, id)
  27511. }
  27512. })
  27513. return value, err
  27514. }
  27515. m.id = &id
  27516. }
  27517. }
  27518. // withToken sets the old Token of the mutation.
  27519. func withToken(node *Token) tokenOption {
  27520. return func(m *TokenMutation) {
  27521. m.oldValue = func(context.Context) (*Token, error) {
  27522. return node, nil
  27523. }
  27524. m.id = &node.ID
  27525. }
  27526. }
  27527. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27528. // executed in a transaction (ent.Tx), a transactional client is returned.
  27529. func (m TokenMutation) Client() *Client {
  27530. client := &Client{config: m.config}
  27531. client.init()
  27532. return client
  27533. }
  27534. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27535. // it returns an error otherwise.
  27536. func (m TokenMutation) Tx() (*Tx, error) {
  27537. if _, ok := m.driver.(*txDriver); !ok {
  27538. return nil, errors.New("ent: mutation is not running in a transaction")
  27539. }
  27540. tx := &Tx{config: m.config}
  27541. tx.init()
  27542. return tx, nil
  27543. }
  27544. // SetID sets the value of the id field. Note that this
  27545. // operation is only accepted on creation of Token entities.
  27546. func (m *TokenMutation) SetID(id uint64) {
  27547. m.id = &id
  27548. }
  27549. // ID returns the ID value in the mutation. Note that the ID is only available
  27550. // if it was provided to the builder or after it was returned from the database.
  27551. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27552. if m.id == nil {
  27553. return
  27554. }
  27555. return *m.id, true
  27556. }
  27557. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27558. // That means, if the mutation is applied within a transaction with an isolation level such
  27559. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27560. // or updated by the mutation.
  27561. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27562. switch {
  27563. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27564. id, exists := m.ID()
  27565. if exists {
  27566. return []uint64{id}, nil
  27567. }
  27568. fallthrough
  27569. case m.op.Is(OpUpdate | OpDelete):
  27570. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27571. default:
  27572. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27573. }
  27574. }
  27575. // SetCreatedAt sets the "created_at" field.
  27576. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27577. m.created_at = &t
  27578. }
  27579. // CreatedAt returns the value of the "created_at" field in the mutation.
  27580. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27581. v := m.created_at
  27582. if v == nil {
  27583. return
  27584. }
  27585. return *v, true
  27586. }
  27587. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27588. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27590. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27591. if !m.op.Is(OpUpdateOne) {
  27592. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27593. }
  27594. if m.id == nil || m.oldValue == nil {
  27595. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27596. }
  27597. oldValue, err := m.oldValue(ctx)
  27598. if err != nil {
  27599. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27600. }
  27601. return oldValue.CreatedAt, nil
  27602. }
  27603. // ResetCreatedAt resets all changes to the "created_at" field.
  27604. func (m *TokenMutation) ResetCreatedAt() {
  27605. m.created_at = nil
  27606. }
  27607. // SetUpdatedAt sets the "updated_at" field.
  27608. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27609. m.updated_at = &t
  27610. }
  27611. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27612. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27613. v := m.updated_at
  27614. if v == nil {
  27615. return
  27616. }
  27617. return *v, true
  27618. }
  27619. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27620. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27622. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27623. if !m.op.Is(OpUpdateOne) {
  27624. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27625. }
  27626. if m.id == nil || m.oldValue == nil {
  27627. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27628. }
  27629. oldValue, err := m.oldValue(ctx)
  27630. if err != nil {
  27631. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27632. }
  27633. return oldValue.UpdatedAt, nil
  27634. }
  27635. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27636. func (m *TokenMutation) ResetUpdatedAt() {
  27637. m.updated_at = nil
  27638. }
  27639. // SetDeletedAt sets the "deleted_at" field.
  27640. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27641. m.deleted_at = &t
  27642. }
  27643. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27644. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27645. v := m.deleted_at
  27646. if v == nil {
  27647. return
  27648. }
  27649. return *v, true
  27650. }
  27651. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27652. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27654. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27655. if !m.op.Is(OpUpdateOne) {
  27656. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27657. }
  27658. if m.id == nil || m.oldValue == nil {
  27659. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27660. }
  27661. oldValue, err := m.oldValue(ctx)
  27662. if err != nil {
  27663. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27664. }
  27665. return oldValue.DeletedAt, nil
  27666. }
  27667. // ClearDeletedAt clears the value of the "deleted_at" field.
  27668. func (m *TokenMutation) ClearDeletedAt() {
  27669. m.deleted_at = nil
  27670. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27671. }
  27672. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27673. func (m *TokenMutation) DeletedAtCleared() bool {
  27674. _, ok := m.clearedFields[token.FieldDeletedAt]
  27675. return ok
  27676. }
  27677. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27678. func (m *TokenMutation) ResetDeletedAt() {
  27679. m.deleted_at = nil
  27680. delete(m.clearedFields, token.FieldDeletedAt)
  27681. }
  27682. // SetExpireAt sets the "expire_at" field.
  27683. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27684. m.expire_at = &t
  27685. }
  27686. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27687. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27688. v := m.expire_at
  27689. if v == nil {
  27690. return
  27691. }
  27692. return *v, true
  27693. }
  27694. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27695. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27697. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27698. if !m.op.Is(OpUpdateOne) {
  27699. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27700. }
  27701. if m.id == nil || m.oldValue == nil {
  27702. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27703. }
  27704. oldValue, err := m.oldValue(ctx)
  27705. if err != nil {
  27706. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27707. }
  27708. return oldValue.ExpireAt, nil
  27709. }
  27710. // ClearExpireAt clears the value of the "expire_at" field.
  27711. func (m *TokenMutation) ClearExpireAt() {
  27712. m.expire_at = nil
  27713. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27714. }
  27715. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27716. func (m *TokenMutation) ExpireAtCleared() bool {
  27717. _, ok := m.clearedFields[token.FieldExpireAt]
  27718. return ok
  27719. }
  27720. // ResetExpireAt resets all changes to the "expire_at" field.
  27721. func (m *TokenMutation) ResetExpireAt() {
  27722. m.expire_at = nil
  27723. delete(m.clearedFields, token.FieldExpireAt)
  27724. }
  27725. // SetToken sets the "token" field.
  27726. func (m *TokenMutation) SetToken(s string) {
  27727. m.token = &s
  27728. }
  27729. // Token returns the value of the "token" field in the mutation.
  27730. func (m *TokenMutation) Token() (r string, exists bool) {
  27731. v := m.token
  27732. if v == nil {
  27733. return
  27734. }
  27735. return *v, true
  27736. }
  27737. // OldToken returns the old "token" field's value of the Token entity.
  27738. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27740. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27741. if !m.op.Is(OpUpdateOne) {
  27742. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27743. }
  27744. if m.id == nil || m.oldValue == nil {
  27745. return v, errors.New("OldToken requires an ID field in the mutation")
  27746. }
  27747. oldValue, err := m.oldValue(ctx)
  27748. if err != nil {
  27749. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27750. }
  27751. return oldValue.Token, nil
  27752. }
  27753. // ClearToken clears the value of the "token" field.
  27754. func (m *TokenMutation) ClearToken() {
  27755. m.token = nil
  27756. m.clearedFields[token.FieldToken] = struct{}{}
  27757. }
  27758. // TokenCleared returns if the "token" field was cleared in this mutation.
  27759. func (m *TokenMutation) TokenCleared() bool {
  27760. _, ok := m.clearedFields[token.FieldToken]
  27761. return ok
  27762. }
  27763. // ResetToken resets all changes to the "token" field.
  27764. func (m *TokenMutation) ResetToken() {
  27765. m.token = nil
  27766. delete(m.clearedFields, token.FieldToken)
  27767. }
  27768. // SetMAC sets the "mac" field.
  27769. func (m *TokenMutation) SetMAC(s string) {
  27770. m.mac = &s
  27771. }
  27772. // MAC returns the value of the "mac" field in the mutation.
  27773. func (m *TokenMutation) MAC() (r string, exists bool) {
  27774. v := m.mac
  27775. if v == nil {
  27776. return
  27777. }
  27778. return *v, true
  27779. }
  27780. // OldMAC returns the old "mac" field's value of the Token entity.
  27781. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27783. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27784. if !m.op.Is(OpUpdateOne) {
  27785. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27786. }
  27787. if m.id == nil || m.oldValue == nil {
  27788. return v, errors.New("OldMAC requires an ID field in the mutation")
  27789. }
  27790. oldValue, err := m.oldValue(ctx)
  27791. if err != nil {
  27792. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27793. }
  27794. return oldValue.MAC, nil
  27795. }
  27796. // ClearMAC clears the value of the "mac" field.
  27797. func (m *TokenMutation) ClearMAC() {
  27798. m.mac = nil
  27799. m.clearedFields[token.FieldMAC] = struct{}{}
  27800. }
  27801. // MACCleared returns if the "mac" field was cleared in this mutation.
  27802. func (m *TokenMutation) MACCleared() bool {
  27803. _, ok := m.clearedFields[token.FieldMAC]
  27804. return ok
  27805. }
  27806. // ResetMAC resets all changes to the "mac" field.
  27807. func (m *TokenMutation) ResetMAC() {
  27808. m.mac = nil
  27809. delete(m.clearedFields, token.FieldMAC)
  27810. }
  27811. // SetOrganizationID sets the "organization_id" field.
  27812. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27813. m.organization_id = &u
  27814. m.addorganization_id = nil
  27815. }
  27816. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27817. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27818. v := m.organization_id
  27819. if v == nil {
  27820. return
  27821. }
  27822. return *v, true
  27823. }
  27824. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27825. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27827. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27828. if !m.op.Is(OpUpdateOne) {
  27829. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27830. }
  27831. if m.id == nil || m.oldValue == nil {
  27832. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27833. }
  27834. oldValue, err := m.oldValue(ctx)
  27835. if err != nil {
  27836. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27837. }
  27838. return oldValue.OrganizationID, nil
  27839. }
  27840. // AddOrganizationID adds u to the "organization_id" field.
  27841. func (m *TokenMutation) AddOrganizationID(u int64) {
  27842. if m.addorganization_id != nil {
  27843. *m.addorganization_id += u
  27844. } else {
  27845. m.addorganization_id = &u
  27846. }
  27847. }
  27848. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27849. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27850. v := m.addorganization_id
  27851. if v == nil {
  27852. return
  27853. }
  27854. return *v, true
  27855. }
  27856. // ResetOrganizationID resets all changes to the "organization_id" field.
  27857. func (m *TokenMutation) ResetOrganizationID() {
  27858. m.organization_id = nil
  27859. m.addorganization_id = nil
  27860. }
  27861. // SetAgentID sets the "agent_id" field.
  27862. func (m *TokenMutation) SetAgentID(u uint64) {
  27863. m.agent = &u
  27864. }
  27865. // AgentID returns the value of the "agent_id" field in the mutation.
  27866. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27867. v := m.agent
  27868. if v == nil {
  27869. return
  27870. }
  27871. return *v, true
  27872. }
  27873. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27874. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27876. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27877. if !m.op.Is(OpUpdateOne) {
  27878. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27879. }
  27880. if m.id == nil || m.oldValue == nil {
  27881. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27882. }
  27883. oldValue, err := m.oldValue(ctx)
  27884. if err != nil {
  27885. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27886. }
  27887. return oldValue.AgentID, nil
  27888. }
  27889. // ResetAgentID resets all changes to the "agent_id" field.
  27890. func (m *TokenMutation) ResetAgentID() {
  27891. m.agent = nil
  27892. }
  27893. // SetCustomAgentBase sets the "custom_agent_base" field.
  27894. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27895. m.custom_agent_base = &s
  27896. }
  27897. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27898. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27899. v := m.custom_agent_base
  27900. if v == nil {
  27901. return
  27902. }
  27903. return *v, true
  27904. }
  27905. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27906. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27908. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27909. if !m.op.Is(OpUpdateOne) {
  27910. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27911. }
  27912. if m.id == nil || m.oldValue == nil {
  27913. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27914. }
  27915. oldValue, err := m.oldValue(ctx)
  27916. if err != nil {
  27917. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27918. }
  27919. return oldValue.CustomAgentBase, nil
  27920. }
  27921. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27922. func (m *TokenMutation) ClearCustomAgentBase() {
  27923. m.custom_agent_base = nil
  27924. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27925. }
  27926. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27927. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27928. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27929. return ok
  27930. }
  27931. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27932. func (m *TokenMutation) ResetCustomAgentBase() {
  27933. m.custom_agent_base = nil
  27934. delete(m.clearedFields, token.FieldCustomAgentBase)
  27935. }
  27936. // SetCustomAgentKey sets the "custom_agent_key" field.
  27937. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27938. m.custom_agent_key = &s
  27939. }
  27940. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27941. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27942. v := m.custom_agent_key
  27943. if v == nil {
  27944. return
  27945. }
  27946. return *v, true
  27947. }
  27948. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27949. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27951. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27952. if !m.op.Is(OpUpdateOne) {
  27953. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27954. }
  27955. if m.id == nil || m.oldValue == nil {
  27956. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27957. }
  27958. oldValue, err := m.oldValue(ctx)
  27959. if err != nil {
  27960. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27961. }
  27962. return oldValue.CustomAgentKey, nil
  27963. }
  27964. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27965. func (m *TokenMutation) ClearCustomAgentKey() {
  27966. m.custom_agent_key = nil
  27967. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27968. }
  27969. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27970. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27971. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27972. return ok
  27973. }
  27974. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27975. func (m *TokenMutation) ResetCustomAgentKey() {
  27976. m.custom_agent_key = nil
  27977. delete(m.clearedFields, token.FieldCustomAgentKey)
  27978. }
  27979. // SetOpenaiBase sets the "openai_base" field.
  27980. func (m *TokenMutation) SetOpenaiBase(s string) {
  27981. m.openai_base = &s
  27982. }
  27983. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27984. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27985. v := m.openai_base
  27986. if v == nil {
  27987. return
  27988. }
  27989. return *v, true
  27990. }
  27991. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27992. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27994. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27995. if !m.op.Is(OpUpdateOne) {
  27996. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27997. }
  27998. if m.id == nil || m.oldValue == nil {
  27999. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  28000. }
  28001. oldValue, err := m.oldValue(ctx)
  28002. if err != nil {
  28003. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  28004. }
  28005. return oldValue.OpenaiBase, nil
  28006. }
  28007. // ClearOpenaiBase clears the value of the "openai_base" field.
  28008. func (m *TokenMutation) ClearOpenaiBase() {
  28009. m.openai_base = nil
  28010. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  28011. }
  28012. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  28013. func (m *TokenMutation) OpenaiBaseCleared() bool {
  28014. _, ok := m.clearedFields[token.FieldOpenaiBase]
  28015. return ok
  28016. }
  28017. // ResetOpenaiBase resets all changes to the "openai_base" field.
  28018. func (m *TokenMutation) ResetOpenaiBase() {
  28019. m.openai_base = nil
  28020. delete(m.clearedFields, token.FieldOpenaiBase)
  28021. }
  28022. // SetOpenaiKey sets the "openai_key" field.
  28023. func (m *TokenMutation) SetOpenaiKey(s string) {
  28024. m.openai_key = &s
  28025. }
  28026. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  28027. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  28028. v := m.openai_key
  28029. if v == nil {
  28030. return
  28031. }
  28032. return *v, true
  28033. }
  28034. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  28035. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28037. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  28038. if !m.op.Is(OpUpdateOne) {
  28039. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  28040. }
  28041. if m.id == nil || m.oldValue == nil {
  28042. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  28043. }
  28044. oldValue, err := m.oldValue(ctx)
  28045. if err != nil {
  28046. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  28047. }
  28048. return oldValue.OpenaiKey, nil
  28049. }
  28050. // ClearOpenaiKey clears the value of the "openai_key" field.
  28051. func (m *TokenMutation) ClearOpenaiKey() {
  28052. m.openai_key = nil
  28053. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  28054. }
  28055. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  28056. func (m *TokenMutation) OpenaiKeyCleared() bool {
  28057. _, ok := m.clearedFields[token.FieldOpenaiKey]
  28058. return ok
  28059. }
  28060. // ResetOpenaiKey resets all changes to the "openai_key" field.
  28061. func (m *TokenMutation) ResetOpenaiKey() {
  28062. m.openai_key = nil
  28063. delete(m.clearedFields, token.FieldOpenaiKey)
  28064. }
  28065. // ClearAgent clears the "agent" edge to the Agent entity.
  28066. func (m *TokenMutation) ClearAgent() {
  28067. m.clearedagent = true
  28068. m.clearedFields[token.FieldAgentID] = struct{}{}
  28069. }
  28070. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28071. func (m *TokenMutation) AgentCleared() bool {
  28072. return m.clearedagent
  28073. }
  28074. // AgentIDs returns the "agent" edge IDs in the mutation.
  28075. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28076. // AgentID instead. It exists only for internal usage by the builders.
  28077. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  28078. if id := m.agent; id != nil {
  28079. ids = append(ids, *id)
  28080. }
  28081. return
  28082. }
  28083. // ResetAgent resets all changes to the "agent" edge.
  28084. func (m *TokenMutation) ResetAgent() {
  28085. m.agent = nil
  28086. m.clearedagent = false
  28087. }
  28088. // Where appends a list predicates to the TokenMutation builder.
  28089. func (m *TokenMutation) Where(ps ...predicate.Token) {
  28090. m.predicates = append(m.predicates, ps...)
  28091. }
  28092. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  28093. // users can use type-assertion to append predicates that do not depend on any generated package.
  28094. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  28095. p := make([]predicate.Token, len(ps))
  28096. for i := range ps {
  28097. p[i] = ps[i]
  28098. }
  28099. m.Where(p...)
  28100. }
  28101. // Op returns the operation name.
  28102. func (m *TokenMutation) Op() Op {
  28103. return m.op
  28104. }
  28105. // SetOp allows setting the mutation operation.
  28106. func (m *TokenMutation) SetOp(op Op) {
  28107. m.op = op
  28108. }
  28109. // Type returns the node type of this mutation (Token).
  28110. func (m *TokenMutation) Type() string {
  28111. return m.typ
  28112. }
  28113. // Fields returns all fields that were changed during this mutation. Note that in
  28114. // order to get all numeric fields that were incremented/decremented, call
  28115. // AddedFields().
  28116. func (m *TokenMutation) Fields() []string {
  28117. fields := make([]string, 0, 12)
  28118. if m.created_at != nil {
  28119. fields = append(fields, token.FieldCreatedAt)
  28120. }
  28121. if m.updated_at != nil {
  28122. fields = append(fields, token.FieldUpdatedAt)
  28123. }
  28124. if m.deleted_at != nil {
  28125. fields = append(fields, token.FieldDeletedAt)
  28126. }
  28127. if m.expire_at != nil {
  28128. fields = append(fields, token.FieldExpireAt)
  28129. }
  28130. if m.token != nil {
  28131. fields = append(fields, token.FieldToken)
  28132. }
  28133. if m.mac != nil {
  28134. fields = append(fields, token.FieldMAC)
  28135. }
  28136. if m.organization_id != nil {
  28137. fields = append(fields, token.FieldOrganizationID)
  28138. }
  28139. if m.agent != nil {
  28140. fields = append(fields, token.FieldAgentID)
  28141. }
  28142. if m.custom_agent_base != nil {
  28143. fields = append(fields, token.FieldCustomAgentBase)
  28144. }
  28145. if m.custom_agent_key != nil {
  28146. fields = append(fields, token.FieldCustomAgentKey)
  28147. }
  28148. if m.openai_base != nil {
  28149. fields = append(fields, token.FieldOpenaiBase)
  28150. }
  28151. if m.openai_key != nil {
  28152. fields = append(fields, token.FieldOpenaiKey)
  28153. }
  28154. return fields
  28155. }
  28156. // Field returns the value of a field with the given name. The second boolean
  28157. // return value indicates that this field was not set, or was not defined in the
  28158. // schema.
  28159. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  28160. switch name {
  28161. case token.FieldCreatedAt:
  28162. return m.CreatedAt()
  28163. case token.FieldUpdatedAt:
  28164. return m.UpdatedAt()
  28165. case token.FieldDeletedAt:
  28166. return m.DeletedAt()
  28167. case token.FieldExpireAt:
  28168. return m.ExpireAt()
  28169. case token.FieldToken:
  28170. return m.Token()
  28171. case token.FieldMAC:
  28172. return m.MAC()
  28173. case token.FieldOrganizationID:
  28174. return m.OrganizationID()
  28175. case token.FieldAgentID:
  28176. return m.AgentID()
  28177. case token.FieldCustomAgentBase:
  28178. return m.CustomAgentBase()
  28179. case token.FieldCustomAgentKey:
  28180. return m.CustomAgentKey()
  28181. case token.FieldOpenaiBase:
  28182. return m.OpenaiBase()
  28183. case token.FieldOpenaiKey:
  28184. return m.OpenaiKey()
  28185. }
  28186. return nil, false
  28187. }
  28188. // OldField returns the old value of the field from the database. An error is
  28189. // returned if the mutation operation is not UpdateOne, or the query to the
  28190. // database failed.
  28191. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28192. switch name {
  28193. case token.FieldCreatedAt:
  28194. return m.OldCreatedAt(ctx)
  28195. case token.FieldUpdatedAt:
  28196. return m.OldUpdatedAt(ctx)
  28197. case token.FieldDeletedAt:
  28198. return m.OldDeletedAt(ctx)
  28199. case token.FieldExpireAt:
  28200. return m.OldExpireAt(ctx)
  28201. case token.FieldToken:
  28202. return m.OldToken(ctx)
  28203. case token.FieldMAC:
  28204. return m.OldMAC(ctx)
  28205. case token.FieldOrganizationID:
  28206. return m.OldOrganizationID(ctx)
  28207. case token.FieldAgentID:
  28208. return m.OldAgentID(ctx)
  28209. case token.FieldCustomAgentBase:
  28210. return m.OldCustomAgentBase(ctx)
  28211. case token.FieldCustomAgentKey:
  28212. return m.OldCustomAgentKey(ctx)
  28213. case token.FieldOpenaiBase:
  28214. return m.OldOpenaiBase(ctx)
  28215. case token.FieldOpenaiKey:
  28216. return m.OldOpenaiKey(ctx)
  28217. }
  28218. return nil, fmt.Errorf("unknown Token field %s", name)
  28219. }
  28220. // SetField sets the value of a field with the given name. It returns an error if
  28221. // the field is not defined in the schema, or if the type mismatched the field
  28222. // type.
  28223. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  28224. switch name {
  28225. case token.FieldCreatedAt:
  28226. v, ok := value.(time.Time)
  28227. if !ok {
  28228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28229. }
  28230. m.SetCreatedAt(v)
  28231. return nil
  28232. case token.FieldUpdatedAt:
  28233. v, ok := value.(time.Time)
  28234. if !ok {
  28235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28236. }
  28237. m.SetUpdatedAt(v)
  28238. return nil
  28239. case token.FieldDeletedAt:
  28240. v, ok := value.(time.Time)
  28241. if !ok {
  28242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28243. }
  28244. m.SetDeletedAt(v)
  28245. return nil
  28246. case token.FieldExpireAt:
  28247. v, ok := value.(time.Time)
  28248. if !ok {
  28249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28250. }
  28251. m.SetExpireAt(v)
  28252. return nil
  28253. case token.FieldToken:
  28254. v, ok := value.(string)
  28255. if !ok {
  28256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28257. }
  28258. m.SetToken(v)
  28259. return nil
  28260. case token.FieldMAC:
  28261. v, ok := value.(string)
  28262. if !ok {
  28263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28264. }
  28265. m.SetMAC(v)
  28266. return nil
  28267. case token.FieldOrganizationID:
  28268. v, ok := value.(uint64)
  28269. if !ok {
  28270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28271. }
  28272. m.SetOrganizationID(v)
  28273. return nil
  28274. case token.FieldAgentID:
  28275. v, ok := value.(uint64)
  28276. if !ok {
  28277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28278. }
  28279. m.SetAgentID(v)
  28280. return nil
  28281. case token.FieldCustomAgentBase:
  28282. v, ok := value.(string)
  28283. if !ok {
  28284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28285. }
  28286. m.SetCustomAgentBase(v)
  28287. return nil
  28288. case token.FieldCustomAgentKey:
  28289. v, ok := value.(string)
  28290. if !ok {
  28291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28292. }
  28293. m.SetCustomAgentKey(v)
  28294. return nil
  28295. case token.FieldOpenaiBase:
  28296. v, ok := value.(string)
  28297. if !ok {
  28298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28299. }
  28300. m.SetOpenaiBase(v)
  28301. return nil
  28302. case token.FieldOpenaiKey:
  28303. v, ok := value.(string)
  28304. if !ok {
  28305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28306. }
  28307. m.SetOpenaiKey(v)
  28308. return nil
  28309. }
  28310. return fmt.Errorf("unknown Token field %s", name)
  28311. }
  28312. // AddedFields returns all numeric fields that were incremented/decremented during
  28313. // this mutation.
  28314. func (m *TokenMutation) AddedFields() []string {
  28315. var fields []string
  28316. if m.addorganization_id != nil {
  28317. fields = append(fields, token.FieldOrganizationID)
  28318. }
  28319. return fields
  28320. }
  28321. // AddedField returns the numeric value that was incremented/decremented on a field
  28322. // with the given name. The second boolean return value indicates that this field
  28323. // was not set, or was not defined in the schema.
  28324. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  28325. switch name {
  28326. case token.FieldOrganizationID:
  28327. return m.AddedOrganizationID()
  28328. }
  28329. return nil, false
  28330. }
  28331. // AddField adds the value to the field with the given name. It returns an error if
  28332. // the field is not defined in the schema, or if the type mismatched the field
  28333. // type.
  28334. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  28335. switch name {
  28336. case token.FieldOrganizationID:
  28337. v, ok := value.(int64)
  28338. if !ok {
  28339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28340. }
  28341. m.AddOrganizationID(v)
  28342. return nil
  28343. }
  28344. return fmt.Errorf("unknown Token numeric field %s", name)
  28345. }
  28346. // ClearedFields returns all nullable fields that were cleared during this
  28347. // mutation.
  28348. func (m *TokenMutation) ClearedFields() []string {
  28349. var fields []string
  28350. if m.FieldCleared(token.FieldDeletedAt) {
  28351. fields = append(fields, token.FieldDeletedAt)
  28352. }
  28353. if m.FieldCleared(token.FieldExpireAt) {
  28354. fields = append(fields, token.FieldExpireAt)
  28355. }
  28356. if m.FieldCleared(token.FieldToken) {
  28357. fields = append(fields, token.FieldToken)
  28358. }
  28359. if m.FieldCleared(token.FieldMAC) {
  28360. fields = append(fields, token.FieldMAC)
  28361. }
  28362. if m.FieldCleared(token.FieldCustomAgentBase) {
  28363. fields = append(fields, token.FieldCustomAgentBase)
  28364. }
  28365. if m.FieldCleared(token.FieldCustomAgentKey) {
  28366. fields = append(fields, token.FieldCustomAgentKey)
  28367. }
  28368. if m.FieldCleared(token.FieldOpenaiBase) {
  28369. fields = append(fields, token.FieldOpenaiBase)
  28370. }
  28371. if m.FieldCleared(token.FieldOpenaiKey) {
  28372. fields = append(fields, token.FieldOpenaiKey)
  28373. }
  28374. return fields
  28375. }
  28376. // FieldCleared returns a boolean indicating if a field with the given name was
  28377. // cleared in this mutation.
  28378. func (m *TokenMutation) FieldCleared(name string) bool {
  28379. _, ok := m.clearedFields[name]
  28380. return ok
  28381. }
  28382. // ClearField clears the value of the field with the given name. It returns an
  28383. // error if the field is not defined in the schema.
  28384. func (m *TokenMutation) ClearField(name string) error {
  28385. switch name {
  28386. case token.FieldDeletedAt:
  28387. m.ClearDeletedAt()
  28388. return nil
  28389. case token.FieldExpireAt:
  28390. m.ClearExpireAt()
  28391. return nil
  28392. case token.FieldToken:
  28393. m.ClearToken()
  28394. return nil
  28395. case token.FieldMAC:
  28396. m.ClearMAC()
  28397. return nil
  28398. case token.FieldCustomAgentBase:
  28399. m.ClearCustomAgentBase()
  28400. return nil
  28401. case token.FieldCustomAgentKey:
  28402. m.ClearCustomAgentKey()
  28403. return nil
  28404. case token.FieldOpenaiBase:
  28405. m.ClearOpenaiBase()
  28406. return nil
  28407. case token.FieldOpenaiKey:
  28408. m.ClearOpenaiKey()
  28409. return nil
  28410. }
  28411. return fmt.Errorf("unknown Token nullable field %s", name)
  28412. }
  28413. // ResetField resets all changes in the mutation for the field with the given name.
  28414. // It returns an error if the field is not defined in the schema.
  28415. func (m *TokenMutation) ResetField(name string) error {
  28416. switch name {
  28417. case token.FieldCreatedAt:
  28418. m.ResetCreatedAt()
  28419. return nil
  28420. case token.FieldUpdatedAt:
  28421. m.ResetUpdatedAt()
  28422. return nil
  28423. case token.FieldDeletedAt:
  28424. m.ResetDeletedAt()
  28425. return nil
  28426. case token.FieldExpireAt:
  28427. m.ResetExpireAt()
  28428. return nil
  28429. case token.FieldToken:
  28430. m.ResetToken()
  28431. return nil
  28432. case token.FieldMAC:
  28433. m.ResetMAC()
  28434. return nil
  28435. case token.FieldOrganizationID:
  28436. m.ResetOrganizationID()
  28437. return nil
  28438. case token.FieldAgentID:
  28439. m.ResetAgentID()
  28440. return nil
  28441. case token.FieldCustomAgentBase:
  28442. m.ResetCustomAgentBase()
  28443. return nil
  28444. case token.FieldCustomAgentKey:
  28445. m.ResetCustomAgentKey()
  28446. return nil
  28447. case token.FieldOpenaiBase:
  28448. m.ResetOpenaiBase()
  28449. return nil
  28450. case token.FieldOpenaiKey:
  28451. m.ResetOpenaiKey()
  28452. return nil
  28453. }
  28454. return fmt.Errorf("unknown Token field %s", name)
  28455. }
  28456. // AddedEdges returns all edge names that were set/added in this mutation.
  28457. func (m *TokenMutation) AddedEdges() []string {
  28458. edges := make([]string, 0, 1)
  28459. if m.agent != nil {
  28460. edges = append(edges, token.EdgeAgent)
  28461. }
  28462. return edges
  28463. }
  28464. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28465. // name in this mutation.
  28466. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28467. switch name {
  28468. case token.EdgeAgent:
  28469. if id := m.agent; id != nil {
  28470. return []ent.Value{*id}
  28471. }
  28472. }
  28473. return nil
  28474. }
  28475. // RemovedEdges returns all edge names that were removed in this mutation.
  28476. func (m *TokenMutation) RemovedEdges() []string {
  28477. edges := make([]string, 0, 1)
  28478. return edges
  28479. }
  28480. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28481. // the given name in this mutation.
  28482. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28483. return nil
  28484. }
  28485. // ClearedEdges returns all edge names that were cleared in this mutation.
  28486. func (m *TokenMutation) ClearedEdges() []string {
  28487. edges := make([]string, 0, 1)
  28488. if m.clearedagent {
  28489. edges = append(edges, token.EdgeAgent)
  28490. }
  28491. return edges
  28492. }
  28493. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28494. // was cleared in this mutation.
  28495. func (m *TokenMutation) EdgeCleared(name string) bool {
  28496. switch name {
  28497. case token.EdgeAgent:
  28498. return m.clearedagent
  28499. }
  28500. return false
  28501. }
  28502. // ClearEdge clears the value of the edge with the given name. It returns an error
  28503. // if that edge is not defined in the schema.
  28504. func (m *TokenMutation) ClearEdge(name string) error {
  28505. switch name {
  28506. case token.EdgeAgent:
  28507. m.ClearAgent()
  28508. return nil
  28509. }
  28510. return fmt.Errorf("unknown Token unique edge %s", name)
  28511. }
  28512. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28513. // It returns an error if the edge is not defined in the schema.
  28514. func (m *TokenMutation) ResetEdge(name string) error {
  28515. switch name {
  28516. case token.EdgeAgent:
  28517. m.ResetAgent()
  28518. return nil
  28519. }
  28520. return fmt.Errorf("unknown Token edge %s", name)
  28521. }
  28522. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28523. type TutorialMutation struct {
  28524. config
  28525. op Op
  28526. typ string
  28527. id *uint64
  28528. created_at *time.Time
  28529. updated_at *time.Time
  28530. deleted_at *time.Time
  28531. index *int
  28532. addindex *int
  28533. title *string
  28534. content *string
  28535. organization_id *uint64
  28536. addorganization_id *int64
  28537. clearedFields map[string]struct{}
  28538. employee *uint64
  28539. clearedemployee bool
  28540. done bool
  28541. oldValue func(context.Context) (*Tutorial, error)
  28542. predicates []predicate.Tutorial
  28543. }
  28544. var _ ent.Mutation = (*TutorialMutation)(nil)
  28545. // tutorialOption allows management of the mutation configuration using functional options.
  28546. type tutorialOption func(*TutorialMutation)
  28547. // newTutorialMutation creates new mutation for the Tutorial entity.
  28548. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28549. m := &TutorialMutation{
  28550. config: c,
  28551. op: op,
  28552. typ: TypeTutorial,
  28553. clearedFields: make(map[string]struct{}),
  28554. }
  28555. for _, opt := range opts {
  28556. opt(m)
  28557. }
  28558. return m
  28559. }
  28560. // withTutorialID sets the ID field of the mutation.
  28561. func withTutorialID(id uint64) tutorialOption {
  28562. return func(m *TutorialMutation) {
  28563. var (
  28564. err error
  28565. once sync.Once
  28566. value *Tutorial
  28567. )
  28568. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28569. once.Do(func() {
  28570. if m.done {
  28571. err = errors.New("querying old values post mutation is not allowed")
  28572. } else {
  28573. value, err = m.Client().Tutorial.Get(ctx, id)
  28574. }
  28575. })
  28576. return value, err
  28577. }
  28578. m.id = &id
  28579. }
  28580. }
  28581. // withTutorial sets the old Tutorial of the mutation.
  28582. func withTutorial(node *Tutorial) tutorialOption {
  28583. return func(m *TutorialMutation) {
  28584. m.oldValue = func(context.Context) (*Tutorial, error) {
  28585. return node, nil
  28586. }
  28587. m.id = &node.ID
  28588. }
  28589. }
  28590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28591. // executed in a transaction (ent.Tx), a transactional client is returned.
  28592. func (m TutorialMutation) Client() *Client {
  28593. client := &Client{config: m.config}
  28594. client.init()
  28595. return client
  28596. }
  28597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28598. // it returns an error otherwise.
  28599. func (m TutorialMutation) Tx() (*Tx, error) {
  28600. if _, ok := m.driver.(*txDriver); !ok {
  28601. return nil, errors.New("ent: mutation is not running in a transaction")
  28602. }
  28603. tx := &Tx{config: m.config}
  28604. tx.init()
  28605. return tx, nil
  28606. }
  28607. // SetID sets the value of the id field. Note that this
  28608. // operation is only accepted on creation of Tutorial entities.
  28609. func (m *TutorialMutation) SetID(id uint64) {
  28610. m.id = &id
  28611. }
  28612. // ID returns the ID value in the mutation. Note that the ID is only available
  28613. // if it was provided to the builder or after it was returned from the database.
  28614. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28615. if m.id == nil {
  28616. return
  28617. }
  28618. return *m.id, true
  28619. }
  28620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28621. // That means, if the mutation is applied within a transaction with an isolation level such
  28622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28623. // or updated by the mutation.
  28624. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28625. switch {
  28626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28627. id, exists := m.ID()
  28628. if exists {
  28629. return []uint64{id}, nil
  28630. }
  28631. fallthrough
  28632. case m.op.Is(OpUpdate | OpDelete):
  28633. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28634. default:
  28635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28636. }
  28637. }
  28638. // SetCreatedAt sets the "created_at" field.
  28639. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28640. m.created_at = &t
  28641. }
  28642. // CreatedAt returns the value of the "created_at" field in the mutation.
  28643. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28644. v := m.created_at
  28645. if v == nil {
  28646. return
  28647. }
  28648. return *v, true
  28649. }
  28650. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28651. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28653. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28654. if !m.op.Is(OpUpdateOne) {
  28655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28656. }
  28657. if m.id == nil || m.oldValue == nil {
  28658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28659. }
  28660. oldValue, err := m.oldValue(ctx)
  28661. if err != nil {
  28662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28663. }
  28664. return oldValue.CreatedAt, nil
  28665. }
  28666. // ResetCreatedAt resets all changes to the "created_at" field.
  28667. func (m *TutorialMutation) ResetCreatedAt() {
  28668. m.created_at = nil
  28669. }
  28670. // SetUpdatedAt sets the "updated_at" field.
  28671. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28672. m.updated_at = &t
  28673. }
  28674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28675. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28676. v := m.updated_at
  28677. if v == nil {
  28678. return
  28679. }
  28680. return *v, true
  28681. }
  28682. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28683. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28685. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28686. if !m.op.Is(OpUpdateOne) {
  28687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28688. }
  28689. if m.id == nil || m.oldValue == nil {
  28690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28691. }
  28692. oldValue, err := m.oldValue(ctx)
  28693. if err != nil {
  28694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28695. }
  28696. return oldValue.UpdatedAt, nil
  28697. }
  28698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28699. func (m *TutorialMutation) ResetUpdatedAt() {
  28700. m.updated_at = nil
  28701. }
  28702. // SetDeletedAt sets the "deleted_at" field.
  28703. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28704. m.deleted_at = &t
  28705. }
  28706. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28707. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28708. v := m.deleted_at
  28709. if v == nil {
  28710. return
  28711. }
  28712. return *v, true
  28713. }
  28714. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28715. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28717. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28718. if !m.op.Is(OpUpdateOne) {
  28719. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28720. }
  28721. if m.id == nil || m.oldValue == nil {
  28722. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28723. }
  28724. oldValue, err := m.oldValue(ctx)
  28725. if err != nil {
  28726. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28727. }
  28728. return oldValue.DeletedAt, nil
  28729. }
  28730. // ClearDeletedAt clears the value of the "deleted_at" field.
  28731. func (m *TutorialMutation) ClearDeletedAt() {
  28732. m.deleted_at = nil
  28733. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28734. }
  28735. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28736. func (m *TutorialMutation) DeletedAtCleared() bool {
  28737. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28738. return ok
  28739. }
  28740. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28741. func (m *TutorialMutation) ResetDeletedAt() {
  28742. m.deleted_at = nil
  28743. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28744. }
  28745. // SetEmployeeID sets the "employee_id" field.
  28746. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28747. m.employee = &u
  28748. }
  28749. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28750. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28751. v := m.employee
  28752. if v == nil {
  28753. return
  28754. }
  28755. return *v, true
  28756. }
  28757. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28758. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28760. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28761. if !m.op.Is(OpUpdateOne) {
  28762. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28763. }
  28764. if m.id == nil || m.oldValue == nil {
  28765. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28766. }
  28767. oldValue, err := m.oldValue(ctx)
  28768. if err != nil {
  28769. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28770. }
  28771. return oldValue.EmployeeID, nil
  28772. }
  28773. // ResetEmployeeID resets all changes to the "employee_id" field.
  28774. func (m *TutorialMutation) ResetEmployeeID() {
  28775. m.employee = nil
  28776. }
  28777. // SetIndex sets the "index" field.
  28778. func (m *TutorialMutation) SetIndex(i int) {
  28779. m.index = &i
  28780. m.addindex = nil
  28781. }
  28782. // Index returns the value of the "index" field in the mutation.
  28783. func (m *TutorialMutation) Index() (r int, exists bool) {
  28784. v := m.index
  28785. if v == nil {
  28786. return
  28787. }
  28788. return *v, true
  28789. }
  28790. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28791. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28793. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28794. if !m.op.Is(OpUpdateOne) {
  28795. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28796. }
  28797. if m.id == nil || m.oldValue == nil {
  28798. return v, errors.New("OldIndex requires an ID field in the mutation")
  28799. }
  28800. oldValue, err := m.oldValue(ctx)
  28801. if err != nil {
  28802. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28803. }
  28804. return oldValue.Index, nil
  28805. }
  28806. // AddIndex adds i to the "index" field.
  28807. func (m *TutorialMutation) AddIndex(i int) {
  28808. if m.addindex != nil {
  28809. *m.addindex += i
  28810. } else {
  28811. m.addindex = &i
  28812. }
  28813. }
  28814. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28815. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28816. v := m.addindex
  28817. if v == nil {
  28818. return
  28819. }
  28820. return *v, true
  28821. }
  28822. // ResetIndex resets all changes to the "index" field.
  28823. func (m *TutorialMutation) ResetIndex() {
  28824. m.index = nil
  28825. m.addindex = nil
  28826. }
  28827. // SetTitle sets the "title" field.
  28828. func (m *TutorialMutation) SetTitle(s string) {
  28829. m.title = &s
  28830. }
  28831. // Title returns the value of the "title" field in the mutation.
  28832. func (m *TutorialMutation) Title() (r string, exists bool) {
  28833. v := m.title
  28834. if v == nil {
  28835. return
  28836. }
  28837. return *v, true
  28838. }
  28839. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28840. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28842. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28843. if !m.op.Is(OpUpdateOne) {
  28844. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28845. }
  28846. if m.id == nil || m.oldValue == nil {
  28847. return v, errors.New("OldTitle requires an ID field in the mutation")
  28848. }
  28849. oldValue, err := m.oldValue(ctx)
  28850. if err != nil {
  28851. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28852. }
  28853. return oldValue.Title, nil
  28854. }
  28855. // ResetTitle resets all changes to the "title" field.
  28856. func (m *TutorialMutation) ResetTitle() {
  28857. m.title = nil
  28858. }
  28859. // SetContent sets the "content" field.
  28860. func (m *TutorialMutation) SetContent(s string) {
  28861. m.content = &s
  28862. }
  28863. // Content returns the value of the "content" field in the mutation.
  28864. func (m *TutorialMutation) Content() (r string, exists bool) {
  28865. v := m.content
  28866. if v == nil {
  28867. return
  28868. }
  28869. return *v, true
  28870. }
  28871. // OldContent returns the old "content" field's value of the Tutorial entity.
  28872. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28874. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28875. if !m.op.Is(OpUpdateOne) {
  28876. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28877. }
  28878. if m.id == nil || m.oldValue == nil {
  28879. return v, errors.New("OldContent requires an ID field in the mutation")
  28880. }
  28881. oldValue, err := m.oldValue(ctx)
  28882. if err != nil {
  28883. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28884. }
  28885. return oldValue.Content, nil
  28886. }
  28887. // ResetContent resets all changes to the "content" field.
  28888. func (m *TutorialMutation) ResetContent() {
  28889. m.content = nil
  28890. }
  28891. // SetOrganizationID sets the "organization_id" field.
  28892. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28893. m.organization_id = &u
  28894. m.addorganization_id = nil
  28895. }
  28896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28897. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28898. v := m.organization_id
  28899. if v == nil {
  28900. return
  28901. }
  28902. return *v, true
  28903. }
  28904. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28905. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28907. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28908. if !m.op.Is(OpUpdateOne) {
  28909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28910. }
  28911. if m.id == nil || m.oldValue == nil {
  28912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28913. }
  28914. oldValue, err := m.oldValue(ctx)
  28915. if err != nil {
  28916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28917. }
  28918. return oldValue.OrganizationID, nil
  28919. }
  28920. // AddOrganizationID adds u to the "organization_id" field.
  28921. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28922. if m.addorganization_id != nil {
  28923. *m.addorganization_id += u
  28924. } else {
  28925. m.addorganization_id = &u
  28926. }
  28927. }
  28928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28929. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28930. v := m.addorganization_id
  28931. if v == nil {
  28932. return
  28933. }
  28934. return *v, true
  28935. }
  28936. // ResetOrganizationID resets all changes to the "organization_id" field.
  28937. func (m *TutorialMutation) ResetOrganizationID() {
  28938. m.organization_id = nil
  28939. m.addorganization_id = nil
  28940. }
  28941. // ClearEmployee clears the "employee" edge to the Employee entity.
  28942. func (m *TutorialMutation) ClearEmployee() {
  28943. m.clearedemployee = true
  28944. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28945. }
  28946. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28947. func (m *TutorialMutation) EmployeeCleared() bool {
  28948. return m.clearedemployee
  28949. }
  28950. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28951. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28952. // EmployeeID instead. It exists only for internal usage by the builders.
  28953. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28954. if id := m.employee; id != nil {
  28955. ids = append(ids, *id)
  28956. }
  28957. return
  28958. }
  28959. // ResetEmployee resets all changes to the "employee" edge.
  28960. func (m *TutorialMutation) ResetEmployee() {
  28961. m.employee = nil
  28962. m.clearedemployee = false
  28963. }
  28964. // Where appends a list predicates to the TutorialMutation builder.
  28965. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28966. m.predicates = append(m.predicates, ps...)
  28967. }
  28968. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28969. // users can use type-assertion to append predicates that do not depend on any generated package.
  28970. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28971. p := make([]predicate.Tutorial, len(ps))
  28972. for i := range ps {
  28973. p[i] = ps[i]
  28974. }
  28975. m.Where(p...)
  28976. }
  28977. // Op returns the operation name.
  28978. func (m *TutorialMutation) Op() Op {
  28979. return m.op
  28980. }
  28981. // SetOp allows setting the mutation operation.
  28982. func (m *TutorialMutation) SetOp(op Op) {
  28983. m.op = op
  28984. }
  28985. // Type returns the node type of this mutation (Tutorial).
  28986. func (m *TutorialMutation) Type() string {
  28987. return m.typ
  28988. }
  28989. // Fields returns all fields that were changed during this mutation. Note that in
  28990. // order to get all numeric fields that were incremented/decremented, call
  28991. // AddedFields().
  28992. func (m *TutorialMutation) Fields() []string {
  28993. fields := make([]string, 0, 8)
  28994. if m.created_at != nil {
  28995. fields = append(fields, tutorial.FieldCreatedAt)
  28996. }
  28997. if m.updated_at != nil {
  28998. fields = append(fields, tutorial.FieldUpdatedAt)
  28999. }
  29000. if m.deleted_at != nil {
  29001. fields = append(fields, tutorial.FieldDeletedAt)
  29002. }
  29003. if m.employee != nil {
  29004. fields = append(fields, tutorial.FieldEmployeeID)
  29005. }
  29006. if m.index != nil {
  29007. fields = append(fields, tutorial.FieldIndex)
  29008. }
  29009. if m.title != nil {
  29010. fields = append(fields, tutorial.FieldTitle)
  29011. }
  29012. if m.content != nil {
  29013. fields = append(fields, tutorial.FieldContent)
  29014. }
  29015. if m.organization_id != nil {
  29016. fields = append(fields, tutorial.FieldOrganizationID)
  29017. }
  29018. return fields
  29019. }
  29020. // Field returns the value of a field with the given name. The second boolean
  29021. // return value indicates that this field was not set, or was not defined in the
  29022. // schema.
  29023. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  29024. switch name {
  29025. case tutorial.FieldCreatedAt:
  29026. return m.CreatedAt()
  29027. case tutorial.FieldUpdatedAt:
  29028. return m.UpdatedAt()
  29029. case tutorial.FieldDeletedAt:
  29030. return m.DeletedAt()
  29031. case tutorial.FieldEmployeeID:
  29032. return m.EmployeeID()
  29033. case tutorial.FieldIndex:
  29034. return m.Index()
  29035. case tutorial.FieldTitle:
  29036. return m.Title()
  29037. case tutorial.FieldContent:
  29038. return m.Content()
  29039. case tutorial.FieldOrganizationID:
  29040. return m.OrganizationID()
  29041. }
  29042. return nil, false
  29043. }
  29044. // OldField returns the old value of the field from the database. An error is
  29045. // returned if the mutation operation is not UpdateOne, or the query to the
  29046. // database failed.
  29047. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29048. switch name {
  29049. case tutorial.FieldCreatedAt:
  29050. return m.OldCreatedAt(ctx)
  29051. case tutorial.FieldUpdatedAt:
  29052. return m.OldUpdatedAt(ctx)
  29053. case tutorial.FieldDeletedAt:
  29054. return m.OldDeletedAt(ctx)
  29055. case tutorial.FieldEmployeeID:
  29056. return m.OldEmployeeID(ctx)
  29057. case tutorial.FieldIndex:
  29058. return m.OldIndex(ctx)
  29059. case tutorial.FieldTitle:
  29060. return m.OldTitle(ctx)
  29061. case tutorial.FieldContent:
  29062. return m.OldContent(ctx)
  29063. case tutorial.FieldOrganizationID:
  29064. return m.OldOrganizationID(ctx)
  29065. }
  29066. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  29067. }
  29068. // SetField sets the value of a field with the given name. It returns an error if
  29069. // the field is not defined in the schema, or if the type mismatched the field
  29070. // type.
  29071. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  29072. switch name {
  29073. case tutorial.FieldCreatedAt:
  29074. v, ok := value.(time.Time)
  29075. if !ok {
  29076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29077. }
  29078. m.SetCreatedAt(v)
  29079. return nil
  29080. case tutorial.FieldUpdatedAt:
  29081. v, ok := value.(time.Time)
  29082. if !ok {
  29083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29084. }
  29085. m.SetUpdatedAt(v)
  29086. return nil
  29087. case tutorial.FieldDeletedAt:
  29088. v, ok := value.(time.Time)
  29089. if !ok {
  29090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29091. }
  29092. m.SetDeletedAt(v)
  29093. return nil
  29094. case tutorial.FieldEmployeeID:
  29095. v, ok := value.(uint64)
  29096. if !ok {
  29097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29098. }
  29099. m.SetEmployeeID(v)
  29100. return nil
  29101. case tutorial.FieldIndex:
  29102. v, ok := value.(int)
  29103. if !ok {
  29104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29105. }
  29106. m.SetIndex(v)
  29107. return nil
  29108. case tutorial.FieldTitle:
  29109. v, ok := value.(string)
  29110. if !ok {
  29111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29112. }
  29113. m.SetTitle(v)
  29114. return nil
  29115. case tutorial.FieldContent:
  29116. v, ok := value.(string)
  29117. if !ok {
  29118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29119. }
  29120. m.SetContent(v)
  29121. return nil
  29122. case tutorial.FieldOrganizationID:
  29123. v, ok := value.(uint64)
  29124. if !ok {
  29125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29126. }
  29127. m.SetOrganizationID(v)
  29128. return nil
  29129. }
  29130. return fmt.Errorf("unknown Tutorial field %s", name)
  29131. }
  29132. // AddedFields returns all numeric fields that were incremented/decremented during
  29133. // this mutation.
  29134. func (m *TutorialMutation) AddedFields() []string {
  29135. var fields []string
  29136. if m.addindex != nil {
  29137. fields = append(fields, tutorial.FieldIndex)
  29138. }
  29139. if m.addorganization_id != nil {
  29140. fields = append(fields, tutorial.FieldOrganizationID)
  29141. }
  29142. return fields
  29143. }
  29144. // AddedField returns the numeric value that was incremented/decremented on a field
  29145. // with the given name. The second boolean return value indicates that this field
  29146. // was not set, or was not defined in the schema.
  29147. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  29148. switch name {
  29149. case tutorial.FieldIndex:
  29150. return m.AddedIndex()
  29151. case tutorial.FieldOrganizationID:
  29152. return m.AddedOrganizationID()
  29153. }
  29154. return nil, false
  29155. }
  29156. // AddField adds the value to the field with the given name. It returns an error if
  29157. // the field is not defined in the schema, or if the type mismatched the field
  29158. // type.
  29159. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  29160. switch name {
  29161. case tutorial.FieldIndex:
  29162. v, ok := value.(int)
  29163. if !ok {
  29164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29165. }
  29166. m.AddIndex(v)
  29167. return nil
  29168. case tutorial.FieldOrganizationID:
  29169. v, ok := value.(int64)
  29170. if !ok {
  29171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29172. }
  29173. m.AddOrganizationID(v)
  29174. return nil
  29175. }
  29176. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  29177. }
  29178. // ClearedFields returns all nullable fields that were cleared during this
  29179. // mutation.
  29180. func (m *TutorialMutation) ClearedFields() []string {
  29181. var fields []string
  29182. if m.FieldCleared(tutorial.FieldDeletedAt) {
  29183. fields = append(fields, tutorial.FieldDeletedAt)
  29184. }
  29185. return fields
  29186. }
  29187. // FieldCleared returns a boolean indicating if a field with the given name was
  29188. // cleared in this mutation.
  29189. func (m *TutorialMutation) FieldCleared(name string) bool {
  29190. _, ok := m.clearedFields[name]
  29191. return ok
  29192. }
  29193. // ClearField clears the value of the field with the given name. It returns an
  29194. // error if the field is not defined in the schema.
  29195. func (m *TutorialMutation) ClearField(name string) error {
  29196. switch name {
  29197. case tutorial.FieldDeletedAt:
  29198. m.ClearDeletedAt()
  29199. return nil
  29200. }
  29201. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  29202. }
  29203. // ResetField resets all changes in the mutation for the field with the given name.
  29204. // It returns an error if the field is not defined in the schema.
  29205. func (m *TutorialMutation) ResetField(name string) error {
  29206. switch name {
  29207. case tutorial.FieldCreatedAt:
  29208. m.ResetCreatedAt()
  29209. return nil
  29210. case tutorial.FieldUpdatedAt:
  29211. m.ResetUpdatedAt()
  29212. return nil
  29213. case tutorial.FieldDeletedAt:
  29214. m.ResetDeletedAt()
  29215. return nil
  29216. case tutorial.FieldEmployeeID:
  29217. m.ResetEmployeeID()
  29218. return nil
  29219. case tutorial.FieldIndex:
  29220. m.ResetIndex()
  29221. return nil
  29222. case tutorial.FieldTitle:
  29223. m.ResetTitle()
  29224. return nil
  29225. case tutorial.FieldContent:
  29226. m.ResetContent()
  29227. return nil
  29228. case tutorial.FieldOrganizationID:
  29229. m.ResetOrganizationID()
  29230. return nil
  29231. }
  29232. return fmt.Errorf("unknown Tutorial field %s", name)
  29233. }
  29234. // AddedEdges returns all edge names that were set/added in this mutation.
  29235. func (m *TutorialMutation) AddedEdges() []string {
  29236. edges := make([]string, 0, 1)
  29237. if m.employee != nil {
  29238. edges = append(edges, tutorial.EdgeEmployee)
  29239. }
  29240. return edges
  29241. }
  29242. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29243. // name in this mutation.
  29244. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  29245. switch name {
  29246. case tutorial.EdgeEmployee:
  29247. if id := m.employee; id != nil {
  29248. return []ent.Value{*id}
  29249. }
  29250. }
  29251. return nil
  29252. }
  29253. // RemovedEdges returns all edge names that were removed in this mutation.
  29254. func (m *TutorialMutation) RemovedEdges() []string {
  29255. edges := make([]string, 0, 1)
  29256. return edges
  29257. }
  29258. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29259. // the given name in this mutation.
  29260. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  29261. return nil
  29262. }
  29263. // ClearedEdges returns all edge names that were cleared in this mutation.
  29264. func (m *TutorialMutation) ClearedEdges() []string {
  29265. edges := make([]string, 0, 1)
  29266. if m.clearedemployee {
  29267. edges = append(edges, tutorial.EdgeEmployee)
  29268. }
  29269. return edges
  29270. }
  29271. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29272. // was cleared in this mutation.
  29273. func (m *TutorialMutation) EdgeCleared(name string) bool {
  29274. switch name {
  29275. case tutorial.EdgeEmployee:
  29276. return m.clearedemployee
  29277. }
  29278. return false
  29279. }
  29280. // ClearEdge clears the value of the edge with the given name. It returns an error
  29281. // if that edge is not defined in the schema.
  29282. func (m *TutorialMutation) ClearEdge(name string) error {
  29283. switch name {
  29284. case tutorial.EdgeEmployee:
  29285. m.ClearEmployee()
  29286. return nil
  29287. }
  29288. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29289. }
  29290. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29291. // It returns an error if the edge is not defined in the schema.
  29292. func (m *TutorialMutation) ResetEdge(name string) error {
  29293. switch name {
  29294. case tutorial.EdgeEmployee:
  29295. m.ResetEmployee()
  29296. return nil
  29297. }
  29298. return fmt.Errorf("unknown Tutorial edge %s", name)
  29299. }
  29300. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  29301. type UsageDetailMutation struct {
  29302. config
  29303. op Op
  29304. typ string
  29305. id *uint64
  29306. created_at *time.Time
  29307. updated_at *time.Time
  29308. status *uint8
  29309. addstatus *int8
  29310. _type *int
  29311. add_type *int
  29312. bot_id *string
  29313. receiver_id *string
  29314. app *int
  29315. addapp *int
  29316. session_id *uint64
  29317. addsession_id *int64
  29318. request *string
  29319. response *string
  29320. original_data *custom_types.OriginalData
  29321. total_tokens *uint64
  29322. addtotal_tokens *int64
  29323. prompt_tokens *uint64
  29324. addprompt_tokens *int64
  29325. completion_tokens *uint64
  29326. addcompletion_tokens *int64
  29327. organization_id *uint64
  29328. addorganization_id *int64
  29329. clearedFields map[string]struct{}
  29330. done bool
  29331. oldValue func(context.Context) (*UsageDetail, error)
  29332. predicates []predicate.UsageDetail
  29333. }
  29334. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  29335. // usagedetailOption allows management of the mutation configuration using functional options.
  29336. type usagedetailOption func(*UsageDetailMutation)
  29337. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  29338. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  29339. m := &UsageDetailMutation{
  29340. config: c,
  29341. op: op,
  29342. typ: TypeUsageDetail,
  29343. clearedFields: make(map[string]struct{}),
  29344. }
  29345. for _, opt := range opts {
  29346. opt(m)
  29347. }
  29348. return m
  29349. }
  29350. // withUsageDetailID sets the ID field of the mutation.
  29351. func withUsageDetailID(id uint64) usagedetailOption {
  29352. return func(m *UsageDetailMutation) {
  29353. var (
  29354. err error
  29355. once sync.Once
  29356. value *UsageDetail
  29357. )
  29358. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  29359. once.Do(func() {
  29360. if m.done {
  29361. err = errors.New("querying old values post mutation is not allowed")
  29362. } else {
  29363. value, err = m.Client().UsageDetail.Get(ctx, id)
  29364. }
  29365. })
  29366. return value, err
  29367. }
  29368. m.id = &id
  29369. }
  29370. }
  29371. // withUsageDetail sets the old UsageDetail of the mutation.
  29372. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29373. return func(m *UsageDetailMutation) {
  29374. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29375. return node, nil
  29376. }
  29377. m.id = &node.ID
  29378. }
  29379. }
  29380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29381. // executed in a transaction (ent.Tx), a transactional client is returned.
  29382. func (m UsageDetailMutation) Client() *Client {
  29383. client := &Client{config: m.config}
  29384. client.init()
  29385. return client
  29386. }
  29387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29388. // it returns an error otherwise.
  29389. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29390. if _, ok := m.driver.(*txDriver); !ok {
  29391. return nil, errors.New("ent: mutation is not running in a transaction")
  29392. }
  29393. tx := &Tx{config: m.config}
  29394. tx.init()
  29395. return tx, nil
  29396. }
  29397. // SetID sets the value of the id field. Note that this
  29398. // operation is only accepted on creation of UsageDetail entities.
  29399. func (m *UsageDetailMutation) SetID(id uint64) {
  29400. m.id = &id
  29401. }
  29402. // ID returns the ID value in the mutation. Note that the ID is only available
  29403. // if it was provided to the builder or after it was returned from the database.
  29404. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29405. if m.id == nil {
  29406. return
  29407. }
  29408. return *m.id, true
  29409. }
  29410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29411. // That means, if the mutation is applied within a transaction with an isolation level such
  29412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29413. // or updated by the mutation.
  29414. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29415. switch {
  29416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29417. id, exists := m.ID()
  29418. if exists {
  29419. return []uint64{id}, nil
  29420. }
  29421. fallthrough
  29422. case m.op.Is(OpUpdate | OpDelete):
  29423. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29424. default:
  29425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29426. }
  29427. }
  29428. // SetCreatedAt sets the "created_at" field.
  29429. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29430. m.created_at = &t
  29431. }
  29432. // CreatedAt returns the value of the "created_at" field in the mutation.
  29433. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29434. v := m.created_at
  29435. if v == nil {
  29436. return
  29437. }
  29438. return *v, true
  29439. }
  29440. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29441. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29443. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29444. if !m.op.Is(OpUpdateOne) {
  29445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29446. }
  29447. if m.id == nil || m.oldValue == nil {
  29448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29449. }
  29450. oldValue, err := m.oldValue(ctx)
  29451. if err != nil {
  29452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29453. }
  29454. return oldValue.CreatedAt, nil
  29455. }
  29456. // ResetCreatedAt resets all changes to the "created_at" field.
  29457. func (m *UsageDetailMutation) ResetCreatedAt() {
  29458. m.created_at = nil
  29459. }
  29460. // SetUpdatedAt sets the "updated_at" field.
  29461. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29462. m.updated_at = &t
  29463. }
  29464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29465. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29466. v := m.updated_at
  29467. if v == nil {
  29468. return
  29469. }
  29470. return *v, true
  29471. }
  29472. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29473. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29475. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29476. if !m.op.Is(OpUpdateOne) {
  29477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29478. }
  29479. if m.id == nil || m.oldValue == nil {
  29480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29481. }
  29482. oldValue, err := m.oldValue(ctx)
  29483. if err != nil {
  29484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29485. }
  29486. return oldValue.UpdatedAt, nil
  29487. }
  29488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29489. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29490. m.updated_at = nil
  29491. }
  29492. // SetStatus sets the "status" field.
  29493. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29494. m.status = &u
  29495. m.addstatus = nil
  29496. }
  29497. // Status returns the value of the "status" field in the mutation.
  29498. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29499. v := m.status
  29500. if v == nil {
  29501. return
  29502. }
  29503. return *v, true
  29504. }
  29505. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29506. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29508. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29509. if !m.op.Is(OpUpdateOne) {
  29510. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29511. }
  29512. if m.id == nil || m.oldValue == nil {
  29513. return v, errors.New("OldStatus requires an ID field in the mutation")
  29514. }
  29515. oldValue, err := m.oldValue(ctx)
  29516. if err != nil {
  29517. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29518. }
  29519. return oldValue.Status, nil
  29520. }
  29521. // AddStatus adds u to the "status" field.
  29522. func (m *UsageDetailMutation) AddStatus(u int8) {
  29523. if m.addstatus != nil {
  29524. *m.addstatus += u
  29525. } else {
  29526. m.addstatus = &u
  29527. }
  29528. }
  29529. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29530. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29531. v := m.addstatus
  29532. if v == nil {
  29533. return
  29534. }
  29535. return *v, true
  29536. }
  29537. // ClearStatus clears the value of the "status" field.
  29538. func (m *UsageDetailMutation) ClearStatus() {
  29539. m.status = nil
  29540. m.addstatus = nil
  29541. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29542. }
  29543. // StatusCleared returns if the "status" field was cleared in this mutation.
  29544. func (m *UsageDetailMutation) StatusCleared() bool {
  29545. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29546. return ok
  29547. }
  29548. // ResetStatus resets all changes to the "status" field.
  29549. func (m *UsageDetailMutation) ResetStatus() {
  29550. m.status = nil
  29551. m.addstatus = nil
  29552. delete(m.clearedFields, usagedetail.FieldStatus)
  29553. }
  29554. // SetType sets the "type" field.
  29555. func (m *UsageDetailMutation) SetType(i int) {
  29556. m._type = &i
  29557. m.add_type = nil
  29558. }
  29559. // GetType returns the value of the "type" field in the mutation.
  29560. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29561. v := m._type
  29562. if v == nil {
  29563. return
  29564. }
  29565. return *v, true
  29566. }
  29567. // OldType returns the old "type" field's value of the UsageDetail entity.
  29568. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29570. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29571. if !m.op.Is(OpUpdateOne) {
  29572. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29573. }
  29574. if m.id == nil || m.oldValue == nil {
  29575. return v, errors.New("OldType requires an ID field in the mutation")
  29576. }
  29577. oldValue, err := m.oldValue(ctx)
  29578. if err != nil {
  29579. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29580. }
  29581. return oldValue.Type, nil
  29582. }
  29583. // AddType adds i to the "type" field.
  29584. func (m *UsageDetailMutation) AddType(i int) {
  29585. if m.add_type != nil {
  29586. *m.add_type += i
  29587. } else {
  29588. m.add_type = &i
  29589. }
  29590. }
  29591. // AddedType returns the value that was added to the "type" field in this mutation.
  29592. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29593. v := m.add_type
  29594. if v == nil {
  29595. return
  29596. }
  29597. return *v, true
  29598. }
  29599. // ClearType clears the value of the "type" field.
  29600. func (m *UsageDetailMutation) ClearType() {
  29601. m._type = nil
  29602. m.add_type = nil
  29603. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29604. }
  29605. // TypeCleared returns if the "type" field was cleared in this mutation.
  29606. func (m *UsageDetailMutation) TypeCleared() bool {
  29607. _, ok := m.clearedFields[usagedetail.FieldType]
  29608. return ok
  29609. }
  29610. // ResetType resets all changes to the "type" field.
  29611. func (m *UsageDetailMutation) ResetType() {
  29612. m._type = nil
  29613. m.add_type = nil
  29614. delete(m.clearedFields, usagedetail.FieldType)
  29615. }
  29616. // SetBotID sets the "bot_id" field.
  29617. func (m *UsageDetailMutation) SetBotID(s string) {
  29618. m.bot_id = &s
  29619. }
  29620. // BotID returns the value of the "bot_id" field in the mutation.
  29621. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29622. v := m.bot_id
  29623. if v == nil {
  29624. return
  29625. }
  29626. return *v, true
  29627. }
  29628. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29629. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29631. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29632. if !m.op.Is(OpUpdateOne) {
  29633. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29634. }
  29635. if m.id == nil || m.oldValue == nil {
  29636. return v, errors.New("OldBotID requires an ID field in the mutation")
  29637. }
  29638. oldValue, err := m.oldValue(ctx)
  29639. if err != nil {
  29640. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29641. }
  29642. return oldValue.BotID, nil
  29643. }
  29644. // ResetBotID resets all changes to the "bot_id" field.
  29645. func (m *UsageDetailMutation) ResetBotID() {
  29646. m.bot_id = nil
  29647. }
  29648. // SetReceiverID sets the "receiver_id" field.
  29649. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29650. m.receiver_id = &s
  29651. }
  29652. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29653. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29654. v := m.receiver_id
  29655. if v == nil {
  29656. return
  29657. }
  29658. return *v, true
  29659. }
  29660. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29661. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29663. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29664. if !m.op.Is(OpUpdateOne) {
  29665. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29666. }
  29667. if m.id == nil || m.oldValue == nil {
  29668. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29669. }
  29670. oldValue, err := m.oldValue(ctx)
  29671. if err != nil {
  29672. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29673. }
  29674. return oldValue.ReceiverID, nil
  29675. }
  29676. // ResetReceiverID resets all changes to the "receiver_id" field.
  29677. func (m *UsageDetailMutation) ResetReceiverID() {
  29678. m.receiver_id = nil
  29679. }
  29680. // SetApp sets the "app" field.
  29681. func (m *UsageDetailMutation) SetApp(i int) {
  29682. m.app = &i
  29683. m.addapp = nil
  29684. }
  29685. // App returns the value of the "app" field in the mutation.
  29686. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29687. v := m.app
  29688. if v == nil {
  29689. return
  29690. }
  29691. return *v, true
  29692. }
  29693. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29694. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29696. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29697. if !m.op.Is(OpUpdateOne) {
  29698. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29699. }
  29700. if m.id == nil || m.oldValue == nil {
  29701. return v, errors.New("OldApp requires an ID field in the mutation")
  29702. }
  29703. oldValue, err := m.oldValue(ctx)
  29704. if err != nil {
  29705. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29706. }
  29707. return oldValue.App, nil
  29708. }
  29709. // AddApp adds i to the "app" field.
  29710. func (m *UsageDetailMutation) AddApp(i int) {
  29711. if m.addapp != nil {
  29712. *m.addapp += i
  29713. } else {
  29714. m.addapp = &i
  29715. }
  29716. }
  29717. // AddedApp returns the value that was added to the "app" field in this mutation.
  29718. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29719. v := m.addapp
  29720. if v == nil {
  29721. return
  29722. }
  29723. return *v, true
  29724. }
  29725. // ClearApp clears the value of the "app" field.
  29726. func (m *UsageDetailMutation) ClearApp() {
  29727. m.app = nil
  29728. m.addapp = nil
  29729. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29730. }
  29731. // AppCleared returns if the "app" field was cleared in this mutation.
  29732. func (m *UsageDetailMutation) AppCleared() bool {
  29733. _, ok := m.clearedFields[usagedetail.FieldApp]
  29734. return ok
  29735. }
  29736. // ResetApp resets all changes to the "app" field.
  29737. func (m *UsageDetailMutation) ResetApp() {
  29738. m.app = nil
  29739. m.addapp = nil
  29740. delete(m.clearedFields, usagedetail.FieldApp)
  29741. }
  29742. // SetSessionID sets the "session_id" field.
  29743. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29744. m.session_id = &u
  29745. m.addsession_id = nil
  29746. }
  29747. // SessionID returns the value of the "session_id" field in the mutation.
  29748. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29749. v := m.session_id
  29750. if v == nil {
  29751. return
  29752. }
  29753. return *v, true
  29754. }
  29755. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29756. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29758. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29759. if !m.op.Is(OpUpdateOne) {
  29760. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29761. }
  29762. if m.id == nil || m.oldValue == nil {
  29763. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29764. }
  29765. oldValue, err := m.oldValue(ctx)
  29766. if err != nil {
  29767. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29768. }
  29769. return oldValue.SessionID, nil
  29770. }
  29771. // AddSessionID adds u to the "session_id" field.
  29772. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29773. if m.addsession_id != nil {
  29774. *m.addsession_id += u
  29775. } else {
  29776. m.addsession_id = &u
  29777. }
  29778. }
  29779. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29780. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29781. v := m.addsession_id
  29782. if v == nil {
  29783. return
  29784. }
  29785. return *v, true
  29786. }
  29787. // ClearSessionID clears the value of the "session_id" field.
  29788. func (m *UsageDetailMutation) ClearSessionID() {
  29789. m.session_id = nil
  29790. m.addsession_id = nil
  29791. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29792. }
  29793. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29794. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29795. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29796. return ok
  29797. }
  29798. // ResetSessionID resets all changes to the "session_id" field.
  29799. func (m *UsageDetailMutation) ResetSessionID() {
  29800. m.session_id = nil
  29801. m.addsession_id = nil
  29802. delete(m.clearedFields, usagedetail.FieldSessionID)
  29803. }
  29804. // SetRequest sets the "request" field.
  29805. func (m *UsageDetailMutation) SetRequest(s string) {
  29806. m.request = &s
  29807. }
  29808. // Request returns the value of the "request" field in the mutation.
  29809. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29810. v := m.request
  29811. if v == nil {
  29812. return
  29813. }
  29814. return *v, true
  29815. }
  29816. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29817. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29819. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29820. if !m.op.Is(OpUpdateOne) {
  29821. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29822. }
  29823. if m.id == nil || m.oldValue == nil {
  29824. return v, errors.New("OldRequest requires an ID field in the mutation")
  29825. }
  29826. oldValue, err := m.oldValue(ctx)
  29827. if err != nil {
  29828. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29829. }
  29830. return oldValue.Request, nil
  29831. }
  29832. // ResetRequest resets all changes to the "request" field.
  29833. func (m *UsageDetailMutation) ResetRequest() {
  29834. m.request = nil
  29835. }
  29836. // SetResponse sets the "response" field.
  29837. func (m *UsageDetailMutation) SetResponse(s string) {
  29838. m.response = &s
  29839. }
  29840. // Response returns the value of the "response" field in the mutation.
  29841. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29842. v := m.response
  29843. if v == nil {
  29844. return
  29845. }
  29846. return *v, true
  29847. }
  29848. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29849. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29851. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29852. if !m.op.Is(OpUpdateOne) {
  29853. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29854. }
  29855. if m.id == nil || m.oldValue == nil {
  29856. return v, errors.New("OldResponse requires an ID field in the mutation")
  29857. }
  29858. oldValue, err := m.oldValue(ctx)
  29859. if err != nil {
  29860. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29861. }
  29862. return oldValue.Response, nil
  29863. }
  29864. // ResetResponse resets all changes to the "response" field.
  29865. func (m *UsageDetailMutation) ResetResponse() {
  29866. m.response = nil
  29867. }
  29868. // SetOriginalData sets the "original_data" field.
  29869. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29870. m.original_data = &ctd
  29871. }
  29872. // OriginalData returns the value of the "original_data" field in the mutation.
  29873. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29874. v := m.original_data
  29875. if v == nil {
  29876. return
  29877. }
  29878. return *v, true
  29879. }
  29880. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29881. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29883. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29884. if !m.op.Is(OpUpdateOne) {
  29885. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29886. }
  29887. if m.id == nil || m.oldValue == nil {
  29888. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29889. }
  29890. oldValue, err := m.oldValue(ctx)
  29891. if err != nil {
  29892. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29893. }
  29894. return oldValue.OriginalData, nil
  29895. }
  29896. // ResetOriginalData resets all changes to the "original_data" field.
  29897. func (m *UsageDetailMutation) ResetOriginalData() {
  29898. m.original_data = nil
  29899. }
  29900. // SetTotalTokens sets the "total_tokens" field.
  29901. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29902. m.total_tokens = &u
  29903. m.addtotal_tokens = nil
  29904. }
  29905. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29906. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29907. v := m.total_tokens
  29908. if v == nil {
  29909. return
  29910. }
  29911. return *v, true
  29912. }
  29913. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29914. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29916. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29917. if !m.op.Is(OpUpdateOne) {
  29918. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29919. }
  29920. if m.id == nil || m.oldValue == nil {
  29921. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29922. }
  29923. oldValue, err := m.oldValue(ctx)
  29924. if err != nil {
  29925. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29926. }
  29927. return oldValue.TotalTokens, nil
  29928. }
  29929. // AddTotalTokens adds u to the "total_tokens" field.
  29930. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29931. if m.addtotal_tokens != nil {
  29932. *m.addtotal_tokens += u
  29933. } else {
  29934. m.addtotal_tokens = &u
  29935. }
  29936. }
  29937. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29938. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29939. v := m.addtotal_tokens
  29940. if v == nil {
  29941. return
  29942. }
  29943. return *v, true
  29944. }
  29945. // ClearTotalTokens clears the value of the "total_tokens" field.
  29946. func (m *UsageDetailMutation) ClearTotalTokens() {
  29947. m.total_tokens = nil
  29948. m.addtotal_tokens = nil
  29949. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29950. }
  29951. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29952. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29953. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29954. return ok
  29955. }
  29956. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29957. func (m *UsageDetailMutation) ResetTotalTokens() {
  29958. m.total_tokens = nil
  29959. m.addtotal_tokens = nil
  29960. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29961. }
  29962. // SetPromptTokens sets the "prompt_tokens" field.
  29963. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29964. m.prompt_tokens = &u
  29965. m.addprompt_tokens = nil
  29966. }
  29967. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29968. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29969. v := m.prompt_tokens
  29970. if v == nil {
  29971. return
  29972. }
  29973. return *v, true
  29974. }
  29975. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29976. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29978. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29979. if !m.op.Is(OpUpdateOne) {
  29980. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29981. }
  29982. if m.id == nil || m.oldValue == nil {
  29983. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29984. }
  29985. oldValue, err := m.oldValue(ctx)
  29986. if err != nil {
  29987. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29988. }
  29989. return oldValue.PromptTokens, nil
  29990. }
  29991. // AddPromptTokens adds u to the "prompt_tokens" field.
  29992. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29993. if m.addprompt_tokens != nil {
  29994. *m.addprompt_tokens += u
  29995. } else {
  29996. m.addprompt_tokens = &u
  29997. }
  29998. }
  29999. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  30000. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  30001. v := m.addprompt_tokens
  30002. if v == nil {
  30003. return
  30004. }
  30005. return *v, true
  30006. }
  30007. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  30008. func (m *UsageDetailMutation) ClearPromptTokens() {
  30009. m.prompt_tokens = nil
  30010. m.addprompt_tokens = nil
  30011. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  30012. }
  30013. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  30014. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  30015. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  30016. return ok
  30017. }
  30018. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  30019. func (m *UsageDetailMutation) ResetPromptTokens() {
  30020. m.prompt_tokens = nil
  30021. m.addprompt_tokens = nil
  30022. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  30023. }
  30024. // SetCompletionTokens sets the "completion_tokens" field.
  30025. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  30026. m.completion_tokens = &u
  30027. m.addcompletion_tokens = nil
  30028. }
  30029. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  30030. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  30031. v := m.completion_tokens
  30032. if v == nil {
  30033. return
  30034. }
  30035. return *v, true
  30036. }
  30037. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  30038. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30040. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  30041. if !m.op.Is(OpUpdateOne) {
  30042. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  30043. }
  30044. if m.id == nil || m.oldValue == nil {
  30045. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  30046. }
  30047. oldValue, err := m.oldValue(ctx)
  30048. if err != nil {
  30049. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  30050. }
  30051. return oldValue.CompletionTokens, nil
  30052. }
  30053. // AddCompletionTokens adds u to the "completion_tokens" field.
  30054. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  30055. if m.addcompletion_tokens != nil {
  30056. *m.addcompletion_tokens += u
  30057. } else {
  30058. m.addcompletion_tokens = &u
  30059. }
  30060. }
  30061. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  30062. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  30063. v := m.addcompletion_tokens
  30064. if v == nil {
  30065. return
  30066. }
  30067. return *v, true
  30068. }
  30069. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  30070. func (m *UsageDetailMutation) ClearCompletionTokens() {
  30071. m.completion_tokens = nil
  30072. m.addcompletion_tokens = nil
  30073. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  30074. }
  30075. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  30076. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  30077. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  30078. return ok
  30079. }
  30080. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  30081. func (m *UsageDetailMutation) ResetCompletionTokens() {
  30082. m.completion_tokens = nil
  30083. m.addcompletion_tokens = nil
  30084. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  30085. }
  30086. // SetOrganizationID sets the "organization_id" field.
  30087. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  30088. m.organization_id = &u
  30089. m.addorganization_id = nil
  30090. }
  30091. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30092. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  30093. v := m.organization_id
  30094. if v == nil {
  30095. return
  30096. }
  30097. return *v, true
  30098. }
  30099. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  30100. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30102. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30103. if !m.op.Is(OpUpdateOne) {
  30104. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30105. }
  30106. if m.id == nil || m.oldValue == nil {
  30107. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30108. }
  30109. oldValue, err := m.oldValue(ctx)
  30110. if err != nil {
  30111. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30112. }
  30113. return oldValue.OrganizationID, nil
  30114. }
  30115. // AddOrganizationID adds u to the "organization_id" field.
  30116. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  30117. if m.addorganization_id != nil {
  30118. *m.addorganization_id += u
  30119. } else {
  30120. m.addorganization_id = &u
  30121. }
  30122. }
  30123. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30124. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  30125. v := m.addorganization_id
  30126. if v == nil {
  30127. return
  30128. }
  30129. return *v, true
  30130. }
  30131. // ClearOrganizationID clears the value of the "organization_id" field.
  30132. func (m *UsageDetailMutation) ClearOrganizationID() {
  30133. m.organization_id = nil
  30134. m.addorganization_id = nil
  30135. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  30136. }
  30137. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30138. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  30139. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  30140. return ok
  30141. }
  30142. // ResetOrganizationID resets all changes to the "organization_id" field.
  30143. func (m *UsageDetailMutation) ResetOrganizationID() {
  30144. m.organization_id = nil
  30145. m.addorganization_id = nil
  30146. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  30147. }
  30148. // Where appends a list predicates to the UsageDetailMutation builder.
  30149. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  30150. m.predicates = append(m.predicates, ps...)
  30151. }
  30152. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  30153. // users can use type-assertion to append predicates that do not depend on any generated package.
  30154. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  30155. p := make([]predicate.UsageDetail, len(ps))
  30156. for i := range ps {
  30157. p[i] = ps[i]
  30158. }
  30159. m.Where(p...)
  30160. }
  30161. // Op returns the operation name.
  30162. func (m *UsageDetailMutation) Op() Op {
  30163. return m.op
  30164. }
  30165. // SetOp allows setting the mutation operation.
  30166. func (m *UsageDetailMutation) SetOp(op Op) {
  30167. m.op = op
  30168. }
  30169. // Type returns the node type of this mutation (UsageDetail).
  30170. func (m *UsageDetailMutation) Type() string {
  30171. return m.typ
  30172. }
  30173. // Fields returns all fields that were changed during this mutation. Note that in
  30174. // order to get all numeric fields that were incremented/decremented, call
  30175. // AddedFields().
  30176. func (m *UsageDetailMutation) Fields() []string {
  30177. fields := make([]string, 0, 15)
  30178. if m.created_at != nil {
  30179. fields = append(fields, usagedetail.FieldCreatedAt)
  30180. }
  30181. if m.updated_at != nil {
  30182. fields = append(fields, usagedetail.FieldUpdatedAt)
  30183. }
  30184. if m.status != nil {
  30185. fields = append(fields, usagedetail.FieldStatus)
  30186. }
  30187. if m._type != nil {
  30188. fields = append(fields, usagedetail.FieldType)
  30189. }
  30190. if m.bot_id != nil {
  30191. fields = append(fields, usagedetail.FieldBotID)
  30192. }
  30193. if m.receiver_id != nil {
  30194. fields = append(fields, usagedetail.FieldReceiverID)
  30195. }
  30196. if m.app != nil {
  30197. fields = append(fields, usagedetail.FieldApp)
  30198. }
  30199. if m.session_id != nil {
  30200. fields = append(fields, usagedetail.FieldSessionID)
  30201. }
  30202. if m.request != nil {
  30203. fields = append(fields, usagedetail.FieldRequest)
  30204. }
  30205. if m.response != nil {
  30206. fields = append(fields, usagedetail.FieldResponse)
  30207. }
  30208. if m.original_data != nil {
  30209. fields = append(fields, usagedetail.FieldOriginalData)
  30210. }
  30211. if m.total_tokens != nil {
  30212. fields = append(fields, usagedetail.FieldTotalTokens)
  30213. }
  30214. if m.prompt_tokens != nil {
  30215. fields = append(fields, usagedetail.FieldPromptTokens)
  30216. }
  30217. if m.completion_tokens != nil {
  30218. fields = append(fields, usagedetail.FieldCompletionTokens)
  30219. }
  30220. if m.organization_id != nil {
  30221. fields = append(fields, usagedetail.FieldOrganizationID)
  30222. }
  30223. return fields
  30224. }
  30225. // Field returns the value of a field with the given name. The second boolean
  30226. // return value indicates that this field was not set, or was not defined in the
  30227. // schema.
  30228. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  30229. switch name {
  30230. case usagedetail.FieldCreatedAt:
  30231. return m.CreatedAt()
  30232. case usagedetail.FieldUpdatedAt:
  30233. return m.UpdatedAt()
  30234. case usagedetail.FieldStatus:
  30235. return m.Status()
  30236. case usagedetail.FieldType:
  30237. return m.GetType()
  30238. case usagedetail.FieldBotID:
  30239. return m.BotID()
  30240. case usagedetail.FieldReceiverID:
  30241. return m.ReceiverID()
  30242. case usagedetail.FieldApp:
  30243. return m.App()
  30244. case usagedetail.FieldSessionID:
  30245. return m.SessionID()
  30246. case usagedetail.FieldRequest:
  30247. return m.Request()
  30248. case usagedetail.FieldResponse:
  30249. return m.Response()
  30250. case usagedetail.FieldOriginalData:
  30251. return m.OriginalData()
  30252. case usagedetail.FieldTotalTokens:
  30253. return m.TotalTokens()
  30254. case usagedetail.FieldPromptTokens:
  30255. return m.PromptTokens()
  30256. case usagedetail.FieldCompletionTokens:
  30257. return m.CompletionTokens()
  30258. case usagedetail.FieldOrganizationID:
  30259. return m.OrganizationID()
  30260. }
  30261. return nil, false
  30262. }
  30263. // OldField returns the old value of the field from the database. An error is
  30264. // returned if the mutation operation is not UpdateOne, or the query to the
  30265. // database failed.
  30266. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30267. switch name {
  30268. case usagedetail.FieldCreatedAt:
  30269. return m.OldCreatedAt(ctx)
  30270. case usagedetail.FieldUpdatedAt:
  30271. return m.OldUpdatedAt(ctx)
  30272. case usagedetail.FieldStatus:
  30273. return m.OldStatus(ctx)
  30274. case usagedetail.FieldType:
  30275. return m.OldType(ctx)
  30276. case usagedetail.FieldBotID:
  30277. return m.OldBotID(ctx)
  30278. case usagedetail.FieldReceiverID:
  30279. return m.OldReceiverID(ctx)
  30280. case usagedetail.FieldApp:
  30281. return m.OldApp(ctx)
  30282. case usagedetail.FieldSessionID:
  30283. return m.OldSessionID(ctx)
  30284. case usagedetail.FieldRequest:
  30285. return m.OldRequest(ctx)
  30286. case usagedetail.FieldResponse:
  30287. return m.OldResponse(ctx)
  30288. case usagedetail.FieldOriginalData:
  30289. return m.OldOriginalData(ctx)
  30290. case usagedetail.FieldTotalTokens:
  30291. return m.OldTotalTokens(ctx)
  30292. case usagedetail.FieldPromptTokens:
  30293. return m.OldPromptTokens(ctx)
  30294. case usagedetail.FieldCompletionTokens:
  30295. return m.OldCompletionTokens(ctx)
  30296. case usagedetail.FieldOrganizationID:
  30297. return m.OldOrganizationID(ctx)
  30298. }
  30299. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  30300. }
  30301. // SetField sets the value of a field with the given name. It returns an error if
  30302. // the field is not defined in the schema, or if the type mismatched the field
  30303. // type.
  30304. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  30305. switch name {
  30306. case usagedetail.FieldCreatedAt:
  30307. v, ok := value.(time.Time)
  30308. if !ok {
  30309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30310. }
  30311. m.SetCreatedAt(v)
  30312. return nil
  30313. case usagedetail.FieldUpdatedAt:
  30314. v, ok := value.(time.Time)
  30315. if !ok {
  30316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30317. }
  30318. m.SetUpdatedAt(v)
  30319. return nil
  30320. case usagedetail.FieldStatus:
  30321. v, ok := value.(uint8)
  30322. if !ok {
  30323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30324. }
  30325. m.SetStatus(v)
  30326. return nil
  30327. case usagedetail.FieldType:
  30328. v, ok := value.(int)
  30329. if !ok {
  30330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30331. }
  30332. m.SetType(v)
  30333. return nil
  30334. case usagedetail.FieldBotID:
  30335. v, ok := value.(string)
  30336. if !ok {
  30337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30338. }
  30339. m.SetBotID(v)
  30340. return nil
  30341. case usagedetail.FieldReceiverID:
  30342. v, ok := value.(string)
  30343. if !ok {
  30344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30345. }
  30346. m.SetReceiverID(v)
  30347. return nil
  30348. case usagedetail.FieldApp:
  30349. v, ok := value.(int)
  30350. if !ok {
  30351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30352. }
  30353. m.SetApp(v)
  30354. return nil
  30355. case usagedetail.FieldSessionID:
  30356. v, ok := value.(uint64)
  30357. if !ok {
  30358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30359. }
  30360. m.SetSessionID(v)
  30361. return nil
  30362. case usagedetail.FieldRequest:
  30363. v, ok := value.(string)
  30364. if !ok {
  30365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30366. }
  30367. m.SetRequest(v)
  30368. return nil
  30369. case usagedetail.FieldResponse:
  30370. v, ok := value.(string)
  30371. if !ok {
  30372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30373. }
  30374. m.SetResponse(v)
  30375. return nil
  30376. case usagedetail.FieldOriginalData:
  30377. v, ok := value.(custom_types.OriginalData)
  30378. if !ok {
  30379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30380. }
  30381. m.SetOriginalData(v)
  30382. return nil
  30383. case usagedetail.FieldTotalTokens:
  30384. v, ok := value.(uint64)
  30385. if !ok {
  30386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30387. }
  30388. m.SetTotalTokens(v)
  30389. return nil
  30390. case usagedetail.FieldPromptTokens:
  30391. v, ok := value.(uint64)
  30392. if !ok {
  30393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30394. }
  30395. m.SetPromptTokens(v)
  30396. return nil
  30397. case usagedetail.FieldCompletionTokens:
  30398. v, ok := value.(uint64)
  30399. if !ok {
  30400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30401. }
  30402. m.SetCompletionTokens(v)
  30403. return nil
  30404. case usagedetail.FieldOrganizationID:
  30405. v, ok := value.(uint64)
  30406. if !ok {
  30407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30408. }
  30409. m.SetOrganizationID(v)
  30410. return nil
  30411. }
  30412. return fmt.Errorf("unknown UsageDetail field %s", name)
  30413. }
  30414. // AddedFields returns all numeric fields that were incremented/decremented during
  30415. // this mutation.
  30416. func (m *UsageDetailMutation) AddedFields() []string {
  30417. var fields []string
  30418. if m.addstatus != nil {
  30419. fields = append(fields, usagedetail.FieldStatus)
  30420. }
  30421. if m.add_type != nil {
  30422. fields = append(fields, usagedetail.FieldType)
  30423. }
  30424. if m.addapp != nil {
  30425. fields = append(fields, usagedetail.FieldApp)
  30426. }
  30427. if m.addsession_id != nil {
  30428. fields = append(fields, usagedetail.FieldSessionID)
  30429. }
  30430. if m.addtotal_tokens != nil {
  30431. fields = append(fields, usagedetail.FieldTotalTokens)
  30432. }
  30433. if m.addprompt_tokens != nil {
  30434. fields = append(fields, usagedetail.FieldPromptTokens)
  30435. }
  30436. if m.addcompletion_tokens != nil {
  30437. fields = append(fields, usagedetail.FieldCompletionTokens)
  30438. }
  30439. if m.addorganization_id != nil {
  30440. fields = append(fields, usagedetail.FieldOrganizationID)
  30441. }
  30442. return fields
  30443. }
  30444. // AddedField returns the numeric value that was incremented/decremented on a field
  30445. // with the given name. The second boolean return value indicates that this field
  30446. // was not set, or was not defined in the schema.
  30447. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30448. switch name {
  30449. case usagedetail.FieldStatus:
  30450. return m.AddedStatus()
  30451. case usagedetail.FieldType:
  30452. return m.AddedType()
  30453. case usagedetail.FieldApp:
  30454. return m.AddedApp()
  30455. case usagedetail.FieldSessionID:
  30456. return m.AddedSessionID()
  30457. case usagedetail.FieldTotalTokens:
  30458. return m.AddedTotalTokens()
  30459. case usagedetail.FieldPromptTokens:
  30460. return m.AddedPromptTokens()
  30461. case usagedetail.FieldCompletionTokens:
  30462. return m.AddedCompletionTokens()
  30463. case usagedetail.FieldOrganizationID:
  30464. return m.AddedOrganizationID()
  30465. }
  30466. return nil, false
  30467. }
  30468. // AddField adds the value to the field with the given name. It returns an error if
  30469. // the field is not defined in the schema, or if the type mismatched the field
  30470. // type.
  30471. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30472. switch name {
  30473. case usagedetail.FieldStatus:
  30474. v, ok := value.(int8)
  30475. if !ok {
  30476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30477. }
  30478. m.AddStatus(v)
  30479. return nil
  30480. case usagedetail.FieldType:
  30481. v, ok := value.(int)
  30482. if !ok {
  30483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30484. }
  30485. m.AddType(v)
  30486. return nil
  30487. case usagedetail.FieldApp:
  30488. v, ok := value.(int)
  30489. if !ok {
  30490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30491. }
  30492. m.AddApp(v)
  30493. return nil
  30494. case usagedetail.FieldSessionID:
  30495. v, ok := value.(int64)
  30496. if !ok {
  30497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30498. }
  30499. m.AddSessionID(v)
  30500. return nil
  30501. case usagedetail.FieldTotalTokens:
  30502. v, ok := value.(int64)
  30503. if !ok {
  30504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30505. }
  30506. m.AddTotalTokens(v)
  30507. return nil
  30508. case usagedetail.FieldPromptTokens:
  30509. v, ok := value.(int64)
  30510. if !ok {
  30511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30512. }
  30513. m.AddPromptTokens(v)
  30514. return nil
  30515. case usagedetail.FieldCompletionTokens:
  30516. v, ok := value.(int64)
  30517. if !ok {
  30518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30519. }
  30520. m.AddCompletionTokens(v)
  30521. return nil
  30522. case usagedetail.FieldOrganizationID:
  30523. v, ok := value.(int64)
  30524. if !ok {
  30525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30526. }
  30527. m.AddOrganizationID(v)
  30528. return nil
  30529. }
  30530. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30531. }
  30532. // ClearedFields returns all nullable fields that were cleared during this
  30533. // mutation.
  30534. func (m *UsageDetailMutation) ClearedFields() []string {
  30535. var fields []string
  30536. if m.FieldCleared(usagedetail.FieldStatus) {
  30537. fields = append(fields, usagedetail.FieldStatus)
  30538. }
  30539. if m.FieldCleared(usagedetail.FieldType) {
  30540. fields = append(fields, usagedetail.FieldType)
  30541. }
  30542. if m.FieldCleared(usagedetail.FieldApp) {
  30543. fields = append(fields, usagedetail.FieldApp)
  30544. }
  30545. if m.FieldCleared(usagedetail.FieldSessionID) {
  30546. fields = append(fields, usagedetail.FieldSessionID)
  30547. }
  30548. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30549. fields = append(fields, usagedetail.FieldTotalTokens)
  30550. }
  30551. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30552. fields = append(fields, usagedetail.FieldPromptTokens)
  30553. }
  30554. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30555. fields = append(fields, usagedetail.FieldCompletionTokens)
  30556. }
  30557. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30558. fields = append(fields, usagedetail.FieldOrganizationID)
  30559. }
  30560. return fields
  30561. }
  30562. // FieldCleared returns a boolean indicating if a field with the given name was
  30563. // cleared in this mutation.
  30564. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30565. _, ok := m.clearedFields[name]
  30566. return ok
  30567. }
  30568. // ClearField clears the value of the field with the given name. It returns an
  30569. // error if the field is not defined in the schema.
  30570. func (m *UsageDetailMutation) ClearField(name string) error {
  30571. switch name {
  30572. case usagedetail.FieldStatus:
  30573. m.ClearStatus()
  30574. return nil
  30575. case usagedetail.FieldType:
  30576. m.ClearType()
  30577. return nil
  30578. case usagedetail.FieldApp:
  30579. m.ClearApp()
  30580. return nil
  30581. case usagedetail.FieldSessionID:
  30582. m.ClearSessionID()
  30583. return nil
  30584. case usagedetail.FieldTotalTokens:
  30585. m.ClearTotalTokens()
  30586. return nil
  30587. case usagedetail.FieldPromptTokens:
  30588. m.ClearPromptTokens()
  30589. return nil
  30590. case usagedetail.FieldCompletionTokens:
  30591. m.ClearCompletionTokens()
  30592. return nil
  30593. case usagedetail.FieldOrganizationID:
  30594. m.ClearOrganizationID()
  30595. return nil
  30596. }
  30597. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30598. }
  30599. // ResetField resets all changes in the mutation for the field with the given name.
  30600. // It returns an error if the field is not defined in the schema.
  30601. func (m *UsageDetailMutation) ResetField(name string) error {
  30602. switch name {
  30603. case usagedetail.FieldCreatedAt:
  30604. m.ResetCreatedAt()
  30605. return nil
  30606. case usagedetail.FieldUpdatedAt:
  30607. m.ResetUpdatedAt()
  30608. return nil
  30609. case usagedetail.FieldStatus:
  30610. m.ResetStatus()
  30611. return nil
  30612. case usagedetail.FieldType:
  30613. m.ResetType()
  30614. return nil
  30615. case usagedetail.FieldBotID:
  30616. m.ResetBotID()
  30617. return nil
  30618. case usagedetail.FieldReceiverID:
  30619. m.ResetReceiverID()
  30620. return nil
  30621. case usagedetail.FieldApp:
  30622. m.ResetApp()
  30623. return nil
  30624. case usagedetail.FieldSessionID:
  30625. m.ResetSessionID()
  30626. return nil
  30627. case usagedetail.FieldRequest:
  30628. m.ResetRequest()
  30629. return nil
  30630. case usagedetail.FieldResponse:
  30631. m.ResetResponse()
  30632. return nil
  30633. case usagedetail.FieldOriginalData:
  30634. m.ResetOriginalData()
  30635. return nil
  30636. case usagedetail.FieldTotalTokens:
  30637. m.ResetTotalTokens()
  30638. return nil
  30639. case usagedetail.FieldPromptTokens:
  30640. m.ResetPromptTokens()
  30641. return nil
  30642. case usagedetail.FieldCompletionTokens:
  30643. m.ResetCompletionTokens()
  30644. return nil
  30645. case usagedetail.FieldOrganizationID:
  30646. m.ResetOrganizationID()
  30647. return nil
  30648. }
  30649. return fmt.Errorf("unknown UsageDetail field %s", name)
  30650. }
  30651. // AddedEdges returns all edge names that were set/added in this mutation.
  30652. func (m *UsageDetailMutation) AddedEdges() []string {
  30653. edges := make([]string, 0, 0)
  30654. return edges
  30655. }
  30656. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30657. // name in this mutation.
  30658. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30659. return nil
  30660. }
  30661. // RemovedEdges returns all edge names that were removed in this mutation.
  30662. func (m *UsageDetailMutation) RemovedEdges() []string {
  30663. edges := make([]string, 0, 0)
  30664. return edges
  30665. }
  30666. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30667. // the given name in this mutation.
  30668. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30669. return nil
  30670. }
  30671. // ClearedEdges returns all edge names that were cleared in this mutation.
  30672. func (m *UsageDetailMutation) ClearedEdges() []string {
  30673. edges := make([]string, 0, 0)
  30674. return edges
  30675. }
  30676. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30677. // was cleared in this mutation.
  30678. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30679. return false
  30680. }
  30681. // ClearEdge clears the value of the edge with the given name. It returns an error
  30682. // if that edge is not defined in the schema.
  30683. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30684. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30685. }
  30686. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30687. // It returns an error if the edge is not defined in the schema.
  30688. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30689. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30690. }
  30691. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30692. type UsageStatisticDayMutation struct {
  30693. config
  30694. op Op
  30695. typ string
  30696. id *uint64
  30697. created_at *time.Time
  30698. updated_at *time.Time
  30699. status *uint8
  30700. addstatus *int8
  30701. deleted_at *time.Time
  30702. addtime *uint64
  30703. addaddtime *int64
  30704. _type *int
  30705. add_type *int
  30706. bot_id *string
  30707. organization_id *uint64
  30708. addorganization_id *int64
  30709. ai_response *uint64
  30710. addai_response *int64
  30711. sop_run *uint64
  30712. addsop_run *int64
  30713. total_friend *uint64
  30714. addtotal_friend *int64
  30715. total_group *uint64
  30716. addtotal_group *int64
  30717. account_balance *uint64
  30718. addaccount_balance *int64
  30719. consume_token *uint64
  30720. addconsume_token *int64
  30721. active_user *uint64
  30722. addactive_user *int64
  30723. new_user *int64
  30724. addnew_user *int64
  30725. label_dist *[]custom_types.LabelDist
  30726. appendlabel_dist []custom_types.LabelDist
  30727. clearedFields map[string]struct{}
  30728. done bool
  30729. oldValue func(context.Context) (*UsageStatisticDay, error)
  30730. predicates []predicate.UsageStatisticDay
  30731. }
  30732. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30733. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30734. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30735. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30736. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30737. m := &UsageStatisticDayMutation{
  30738. config: c,
  30739. op: op,
  30740. typ: TypeUsageStatisticDay,
  30741. clearedFields: make(map[string]struct{}),
  30742. }
  30743. for _, opt := range opts {
  30744. opt(m)
  30745. }
  30746. return m
  30747. }
  30748. // withUsageStatisticDayID sets the ID field of the mutation.
  30749. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30750. return func(m *UsageStatisticDayMutation) {
  30751. var (
  30752. err error
  30753. once sync.Once
  30754. value *UsageStatisticDay
  30755. )
  30756. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30757. once.Do(func() {
  30758. if m.done {
  30759. err = errors.New("querying old values post mutation is not allowed")
  30760. } else {
  30761. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30762. }
  30763. })
  30764. return value, err
  30765. }
  30766. m.id = &id
  30767. }
  30768. }
  30769. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30770. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30771. return func(m *UsageStatisticDayMutation) {
  30772. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30773. return node, nil
  30774. }
  30775. m.id = &node.ID
  30776. }
  30777. }
  30778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30779. // executed in a transaction (ent.Tx), a transactional client is returned.
  30780. func (m UsageStatisticDayMutation) Client() *Client {
  30781. client := &Client{config: m.config}
  30782. client.init()
  30783. return client
  30784. }
  30785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30786. // it returns an error otherwise.
  30787. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30788. if _, ok := m.driver.(*txDriver); !ok {
  30789. return nil, errors.New("ent: mutation is not running in a transaction")
  30790. }
  30791. tx := &Tx{config: m.config}
  30792. tx.init()
  30793. return tx, nil
  30794. }
  30795. // SetID sets the value of the id field. Note that this
  30796. // operation is only accepted on creation of UsageStatisticDay entities.
  30797. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30798. m.id = &id
  30799. }
  30800. // ID returns the ID value in the mutation. Note that the ID is only available
  30801. // if it was provided to the builder or after it was returned from the database.
  30802. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30803. if m.id == nil {
  30804. return
  30805. }
  30806. return *m.id, true
  30807. }
  30808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30809. // That means, if the mutation is applied within a transaction with an isolation level such
  30810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30811. // or updated by the mutation.
  30812. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30813. switch {
  30814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30815. id, exists := m.ID()
  30816. if exists {
  30817. return []uint64{id}, nil
  30818. }
  30819. fallthrough
  30820. case m.op.Is(OpUpdate | OpDelete):
  30821. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30822. default:
  30823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30824. }
  30825. }
  30826. // SetCreatedAt sets the "created_at" field.
  30827. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30828. m.created_at = &t
  30829. }
  30830. // CreatedAt returns the value of the "created_at" field in the mutation.
  30831. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30832. v := m.created_at
  30833. if v == nil {
  30834. return
  30835. }
  30836. return *v, true
  30837. }
  30838. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30839. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30841. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30842. if !m.op.Is(OpUpdateOne) {
  30843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30844. }
  30845. if m.id == nil || m.oldValue == nil {
  30846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30847. }
  30848. oldValue, err := m.oldValue(ctx)
  30849. if err != nil {
  30850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30851. }
  30852. return oldValue.CreatedAt, nil
  30853. }
  30854. // ResetCreatedAt resets all changes to the "created_at" field.
  30855. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30856. m.created_at = nil
  30857. }
  30858. // SetUpdatedAt sets the "updated_at" field.
  30859. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30860. m.updated_at = &t
  30861. }
  30862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30863. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30864. v := m.updated_at
  30865. if v == nil {
  30866. return
  30867. }
  30868. return *v, true
  30869. }
  30870. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30871. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30873. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30874. if !m.op.Is(OpUpdateOne) {
  30875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30876. }
  30877. if m.id == nil || m.oldValue == nil {
  30878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30879. }
  30880. oldValue, err := m.oldValue(ctx)
  30881. if err != nil {
  30882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30883. }
  30884. return oldValue.UpdatedAt, nil
  30885. }
  30886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30887. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30888. m.updated_at = nil
  30889. }
  30890. // SetStatus sets the "status" field.
  30891. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30892. m.status = &u
  30893. m.addstatus = nil
  30894. }
  30895. // Status returns the value of the "status" field in the mutation.
  30896. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30897. v := m.status
  30898. if v == nil {
  30899. return
  30900. }
  30901. return *v, true
  30902. }
  30903. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30904. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30906. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30907. if !m.op.Is(OpUpdateOne) {
  30908. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30909. }
  30910. if m.id == nil || m.oldValue == nil {
  30911. return v, errors.New("OldStatus requires an ID field in the mutation")
  30912. }
  30913. oldValue, err := m.oldValue(ctx)
  30914. if err != nil {
  30915. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30916. }
  30917. return oldValue.Status, nil
  30918. }
  30919. // AddStatus adds u to the "status" field.
  30920. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30921. if m.addstatus != nil {
  30922. *m.addstatus += u
  30923. } else {
  30924. m.addstatus = &u
  30925. }
  30926. }
  30927. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30928. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30929. v := m.addstatus
  30930. if v == nil {
  30931. return
  30932. }
  30933. return *v, true
  30934. }
  30935. // ClearStatus clears the value of the "status" field.
  30936. func (m *UsageStatisticDayMutation) ClearStatus() {
  30937. m.status = nil
  30938. m.addstatus = nil
  30939. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30940. }
  30941. // StatusCleared returns if the "status" field was cleared in this mutation.
  30942. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30943. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30944. return ok
  30945. }
  30946. // ResetStatus resets all changes to the "status" field.
  30947. func (m *UsageStatisticDayMutation) ResetStatus() {
  30948. m.status = nil
  30949. m.addstatus = nil
  30950. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30951. }
  30952. // SetDeletedAt sets the "deleted_at" field.
  30953. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30954. m.deleted_at = &t
  30955. }
  30956. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30957. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30958. v := m.deleted_at
  30959. if v == nil {
  30960. return
  30961. }
  30962. return *v, true
  30963. }
  30964. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30965. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30967. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30968. if !m.op.Is(OpUpdateOne) {
  30969. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30970. }
  30971. if m.id == nil || m.oldValue == nil {
  30972. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30973. }
  30974. oldValue, err := m.oldValue(ctx)
  30975. if err != nil {
  30976. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30977. }
  30978. return oldValue.DeletedAt, nil
  30979. }
  30980. // ClearDeletedAt clears the value of the "deleted_at" field.
  30981. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30982. m.deleted_at = nil
  30983. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30984. }
  30985. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30986. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30987. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30988. return ok
  30989. }
  30990. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30991. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30992. m.deleted_at = nil
  30993. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30994. }
  30995. // SetAddtime sets the "addtime" field.
  30996. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30997. m.addtime = &u
  30998. m.addaddtime = nil
  30999. }
  31000. // Addtime returns the value of the "addtime" field in the mutation.
  31001. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  31002. v := m.addtime
  31003. if v == nil {
  31004. return
  31005. }
  31006. return *v, true
  31007. }
  31008. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  31009. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31011. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31012. if !m.op.Is(OpUpdateOne) {
  31013. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31014. }
  31015. if m.id == nil || m.oldValue == nil {
  31016. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31017. }
  31018. oldValue, err := m.oldValue(ctx)
  31019. if err != nil {
  31020. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31021. }
  31022. return oldValue.Addtime, nil
  31023. }
  31024. // AddAddtime adds u to the "addtime" field.
  31025. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  31026. if m.addaddtime != nil {
  31027. *m.addaddtime += u
  31028. } else {
  31029. m.addaddtime = &u
  31030. }
  31031. }
  31032. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31033. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  31034. v := m.addaddtime
  31035. if v == nil {
  31036. return
  31037. }
  31038. return *v, true
  31039. }
  31040. // ResetAddtime resets all changes to the "addtime" field.
  31041. func (m *UsageStatisticDayMutation) ResetAddtime() {
  31042. m.addtime = nil
  31043. m.addaddtime = nil
  31044. }
  31045. // SetType sets the "type" field.
  31046. func (m *UsageStatisticDayMutation) SetType(i int) {
  31047. m._type = &i
  31048. m.add_type = nil
  31049. }
  31050. // GetType returns the value of the "type" field in the mutation.
  31051. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  31052. v := m._type
  31053. if v == nil {
  31054. return
  31055. }
  31056. return *v, true
  31057. }
  31058. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  31059. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31061. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  31062. if !m.op.Is(OpUpdateOne) {
  31063. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31064. }
  31065. if m.id == nil || m.oldValue == nil {
  31066. return v, errors.New("OldType requires an ID field in the mutation")
  31067. }
  31068. oldValue, err := m.oldValue(ctx)
  31069. if err != nil {
  31070. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31071. }
  31072. return oldValue.Type, nil
  31073. }
  31074. // AddType adds i to the "type" field.
  31075. func (m *UsageStatisticDayMutation) AddType(i int) {
  31076. if m.add_type != nil {
  31077. *m.add_type += i
  31078. } else {
  31079. m.add_type = &i
  31080. }
  31081. }
  31082. // AddedType returns the value that was added to the "type" field in this mutation.
  31083. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  31084. v := m.add_type
  31085. if v == nil {
  31086. return
  31087. }
  31088. return *v, true
  31089. }
  31090. // ResetType resets all changes to the "type" field.
  31091. func (m *UsageStatisticDayMutation) ResetType() {
  31092. m._type = nil
  31093. m.add_type = nil
  31094. }
  31095. // SetBotID sets the "bot_id" field.
  31096. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  31097. m.bot_id = &s
  31098. }
  31099. // BotID returns the value of the "bot_id" field in the mutation.
  31100. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  31101. v := m.bot_id
  31102. if v == nil {
  31103. return
  31104. }
  31105. return *v, true
  31106. }
  31107. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  31108. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31110. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  31111. if !m.op.Is(OpUpdateOne) {
  31112. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31113. }
  31114. if m.id == nil || m.oldValue == nil {
  31115. return v, errors.New("OldBotID requires an ID field in the mutation")
  31116. }
  31117. oldValue, err := m.oldValue(ctx)
  31118. if err != nil {
  31119. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31120. }
  31121. return oldValue.BotID, nil
  31122. }
  31123. // ClearBotID clears the value of the "bot_id" field.
  31124. func (m *UsageStatisticDayMutation) ClearBotID() {
  31125. m.bot_id = nil
  31126. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  31127. }
  31128. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31129. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  31130. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  31131. return ok
  31132. }
  31133. // ResetBotID resets all changes to the "bot_id" field.
  31134. func (m *UsageStatisticDayMutation) ResetBotID() {
  31135. m.bot_id = nil
  31136. delete(m.clearedFields, usagestatisticday.FieldBotID)
  31137. }
  31138. // SetOrganizationID sets the "organization_id" field.
  31139. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  31140. m.organization_id = &u
  31141. m.addorganization_id = nil
  31142. }
  31143. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31144. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  31145. v := m.organization_id
  31146. if v == nil {
  31147. return
  31148. }
  31149. return *v, true
  31150. }
  31151. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  31152. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31154. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31155. if !m.op.Is(OpUpdateOne) {
  31156. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31157. }
  31158. if m.id == nil || m.oldValue == nil {
  31159. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31160. }
  31161. oldValue, err := m.oldValue(ctx)
  31162. if err != nil {
  31163. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31164. }
  31165. return oldValue.OrganizationID, nil
  31166. }
  31167. // AddOrganizationID adds u to the "organization_id" field.
  31168. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  31169. if m.addorganization_id != nil {
  31170. *m.addorganization_id += u
  31171. } else {
  31172. m.addorganization_id = &u
  31173. }
  31174. }
  31175. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31176. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  31177. v := m.addorganization_id
  31178. if v == nil {
  31179. return
  31180. }
  31181. return *v, true
  31182. }
  31183. // ClearOrganizationID clears the value of the "organization_id" field.
  31184. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  31185. m.organization_id = nil
  31186. m.addorganization_id = nil
  31187. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  31188. }
  31189. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31190. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  31191. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  31192. return ok
  31193. }
  31194. // ResetOrganizationID resets all changes to the "organization_id" field.
  31195. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  31196. m.organization_id = nil
  31197. m.addorganization_id = nil
  31198. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  31199. }
  31200. // SetAiResponse sets the "ai_response" field.
  31201. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  31202. m.ai_response = &u
  31203. m.addai_response = nil
  31204. }
  31205. // AiResponse returns the value of the "ai_response" field in the mutation.
  31206. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  31207. v := m.ai_response
  31208. if v == nil {
  31209. return
  31210. }
  31211. return *v, true
  31212. }
  31213. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  31214. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31216. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31217. if !m.op.Is(OpUpdateOne) {
  31218. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31219. }
  31220. if m.id == nil || m.oldValue == nil {
  31221. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31222. }
  31223. oldValue, err := m.oldValue(ctx)
  31224. if err != nil {
  31225. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31226. }
  31227. return oldValue.AiResponse, nil
  31228. }
  31229. // AddAiResponse adds u to the "ai_response" field.
  31230. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  31231. if m.addai_response != nil {
  31232. *m.addai_response += u
  31233. } else {
  31234. m.addai_response = &u
  31235. }
  31236. }
  31237. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31238. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  31239. v := m.addai_response
  31240. if v == nil {
  31241. return
  31242. }
  31243. return *v, true
  31244. }
  31245. // ResetAiResponse resets all changes to the "ai_response" field.
  31246. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  31247. m.ai_response = nil
  31248. m.addai_response = nil
  31249. }
  31250. // SetSopRun sets the "sop_run" field.
  31251. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  31252. m.sop_run = &u
  31253. m.addsop_run = nil
  31254. }
  31255. // SopRun returns the value of the "sop_run" field in the mutation.
  31256. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  31257. v := m.sop_run
  31258. if v == nil {
  31259. return
  31260. }
  31261. return *v, true
  31262. }
  31263. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  31264. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31266. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31267. if !m.op.Is(OpUpdateOne) {
  31268. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31269. }
  31270. if m.id == nil || m.oldValue == nil {
  31271. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31272. }
  31273. oldValue, err := m.oldValue(ctx)
  31274. if err != nil {
  31275. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31276. }
  31277. return oldValue.SopRun, nil
  31278. }
  31279. // AddSopRun adds u to the "sop_run" field.
  31280. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  31281. if m.addsop_run != nil {
  31282. *m.addsop_run += u
  31283. } else {
  31284. m.addsop_run = &u
  31285. }
  31286. }
  31287. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31288. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31289. v := m.addsop_run
  31290. if v == nil {
  31291. return
  31292. }
  31293. return *v, true
  31294. }
  31295. // ResetSopRun resets all changes to the "sop_run" field.
  31296. func (m *UsageStatisticDayMutation) ResetSopRun() {
  31297. m.sop_run = nil
  31298. m.addsop_run = nil
  31299. }
  31300. // SetTotalFriend sets the "total_friend" field.
  31301. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  31302. m.total_friend = &u
  31303. m.addtotal_friend = nil
  31304. }
  31305. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31306. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  31307. v := m.total_friend
  31308. if v == nil {
  31309. return
  31310. }
  31311. return *v, true
  31312. }
  31313. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  31314. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31316. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31317. if !m.op.Is(OpUpdateOne) {
  31318. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31319. }
  31320. if m.id == nil || m.oldValue == nil {
  31321. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31322. }
  31323. oldValue, err := m.oldValue(ctx)
  31324. if err != nil {
  31325. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31326. }
  31327. return oldValue.TotalFriend, nil
  31328. }
  31329. // AddTotalFriend adds u to the "total_friend" field.
  31330. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  31331. if m.addtotal_friend != nil {
  31332. *m.addtotal_friend += u
  31333. } else {
  31334. m.addtotal_friend = &u
  31335. }
  31336. }
  31337. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31338. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  31339. v := m.addtotal_friend
  31340. if v == nil {
  31341. return
  31342. }
  31343. return *v, true
  31344. }
  31345. // ResetTotalFriend resets all changes to the "total_friend" field.
  31346. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  31347. m.total_friend = nil
  31348. m.addtotal_friend = nil
  31349. }
  31350. // SetTotalGroup sets the "total_group" field.
  31351. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  31352. m.total_group = &u
  31353. m.addtotal_group = nil
  31354. }
  31355. // TotalGroup returns the value of the "total_group" field in the mutation.
  31356. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  31357. v := m.total_group
  31358. if v == nil {
  31359. return
  31360. }
  31361. return *v, true
  31362. }
  31363. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31364. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31366. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31367. if !m.op.Is(OpUpdateOne) {
  31368. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31369. }
  31370. if m.id == nil || m.oldValue == nil {
  31371. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31372. }
  31373. oldValue, err := m.oldValue(ctx)
  31374. if err != nil {
  31375. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31376. }
  31377. return oldValue.TotalGroup, nil
  31378. }
  31379. // AddTotalGroup adds u to the "total_group" field.
  31380. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31381. if m.addtotal_group != nil {
  31382. *m.addtotal_group += u
  31383. } else {
  31384. m.addtotal_group = &u
  31385. }
  31386. }
  31387. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31388. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31389. v := m.addtotal_group
  31390. if v == nil {
  31391. return
  31392. }
  31393. return *v, true
  31394. }
  31395. // ResetTotalGroup resets all changes to the "total_group" field.
  31396. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31397. m.total_group = nil
  31398. m.addtotal_group = nil
  31399. }
  31400. // SetAccountBalance sets the "account_balance" field.
  31401. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31402. m.account_balance = &u
  31403. m.addaccount_balance = nil
  31404. }
  31405. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31406. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31407. v := m.account_balance
  31408. if v == nil {
  31409. return
  31410. }
  31411. return *v, true
  31412. }
  31413. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31414. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31416. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31417. if !m.op.Is(OpUpdateOne) {
  31418. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31419. }
  31420. if m.id == nil || m.oldValue == nil {
  31421. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31422. }
  31423. oldValue, err := m.oldValue(ctx)
  31424. if err != nil {
  31425. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31426. }
  31427. return oldValue.AccountBalance, nil
  31428. }
  31429. // AddAccountBalance adds u to the "account_balance" field.
  31430. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31431. if m.addaccount_balance != nil {
  31432. *m.addaccount_balance += u
  31433. } else {
  31434. m.addaccount_balance = &u
  31435. }
  31436. }
  31437. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31438. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31439. v := m.addaccount_balance
  31440. if v == nil {
  31441. return
  31442. }
  31443. return *v, true
  31444. }
  31445. // ResetAccountBalance resets all changes to the "account_balance" field.
  31446. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31447. m.account_balance = nil
  31448. m.addaccount_balance = nil
  31449. }
  31450. // SetConsumeToken sets the "consume_token" field.
  31451. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31452. m.consume_token = &u
  31453. m.addconsume_token = nil
  31454. }
  31455. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31456. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31457. v := m.consume_token
  31458. if v == nil {
  31459. return
  31460. }
  31461. return *v, true
  31462. }
  31463. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31464. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31466. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31467. if !m.op.Is(OpUpdateOne) {
  31468. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31469. }
  31470. if m.id == nil || m.oldValue == nil {
  31471. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31472. }
  31473. oldValue, err := m.oldValue(ctx)
  31474. if err != nil {
  31475. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31476. }
  31477. return oldValue.ConsumeToken, nil
  31478. }
  31479. // AddConsumeToken adds u to the "consume_token" field.
  31480. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31481. if m.addconsume_token != nil {
  31482. *m.addconsume_token += u
  31483. } else {
  31484. m.addconsume_token = &u
  31485. }
  31486. }
  31487. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31488. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31489. v := m.addconsume_token
  31490. if v == nil {
  31491. return
  31492. }
  31493. return *v, true
  31494. }
  31495. // ResetConsumeToken resets all changes to the "consume_token" field.
  31496. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31497. m.consume_token = nil
  31498. m.addconsume_token = nil
  31499. }
  31500. // SetActiveUser sets the "active_user" field.
  31501. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31502. m.active_user = &u
  31503. m.addactive_user = nil
  31504. }
  31505. // ActiveUser returns the value of the "active_user" field in the mutation.
  31506. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31507. v := m.active_user
  31508. if v == nil {
  31509. return
  31510. }
  31511. return *v, true
  31512. }
  31513. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31514. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31516. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31517. if !m.op.Is(OpUpdateOne) {
  31518. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31519. }
  31520. if m.id == nil || m.oldValue == nil {
  31521. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31522. }
  31523. oldValue, err := m.oldValue(ctx)
  31524. if err != nil {
  31525. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31526. }
  31527. return oldValue.ActiveUser, nil
  31528. }
  31529. // AddActiveUser adds u to the "active_user" field.
  31530. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31531. if m.addactive_user != nil {
  31532. *m.addactive_user += u
  31533. } else {
  31534. m.addactive_user = &u
  31535. }
  31536. }
  31537. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31538. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31539. v := m.addactive_user
  31540. if v == nil {
  31541. return
  31542. }
  31543. return *v, true
  31544. }
  31545. // ResetActiveUser resets all changes to the "active_user" field.
  31546. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31547. m.active_user = nil
  31548. m.addactive_user = nil
  31549. }
  31550. // SetNewUser sets the "new_user" field.
  31551. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31552. m.new_user = &i
  31553. m.addnew_user = nil
  31554. }
  31555. // NewUser returns the value of the "new_user" field in the mutation.
  31556. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31557. v := m.new_user
  31558. if v == nil {
  31559. return
  31560. }
  31561. return *v, true
  31562. }
  31563. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31564. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31566. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31567. if !m.op.Is(OpUpdateOne) {
  31568. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31569. }
  31570. if m.id == nil || m.oldValue == nil {
  31571. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31572. }
  31573. oldValue, err := m.oldValue(ctx)
  31574. if err != nil {
  31575. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31576. }
  31577. return oldValue.NewUser, nil
  31578. }
  31579. // AddNewUser adds i to the "new_user" field.
  31580. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31581. if m.addnew_user != nil {
  31582. *m.addnew_user += i
  31583. } else {
  31584. m.addnew_user = &i
  31585. }
  31586. }
  31587. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31588. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31589. v := m.addnew_user
  31590. if v == nil {
  31591. return
  31592. }
  31593. return *v, true
  31594. }
  31595. // ResetNewUser resets all changes to the "new_user" field.
  31596. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31597. m.new_user = nil
  31598. m.addnew_user = nil
  31599. }
  31600. // SetLabelDist sets the "label_dist" field.
  31601. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31602. m.label_dist = &ctd
  31603. m.appendlabel_dist = nil
  31604. }
  31605. // LabelDist returns the value of the "label_dist" field in the mutation.
  31606. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31607. v := m.label_dist
  31608. if v == nil {
  31609. return
  31610. }
  31611. return *v, true
  31612. }
  31613. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31614. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31616. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31617. if !m.op.Is(OpUpdateOne) {
  31618. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31619. }
  31620. if m.id == nil || m.oldValue == nil {
  31621. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31622. }
  31623. oldValue, err := m.oldValue(ctx)
  31624. if err != nil {
  31625. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31626. }
  31627. return oldValue.LabelDist, nil
  31628. }
  31629. // AppendLabelDist adds ctd to the "label_dist" field.
  31630. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31631. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31632. }
  31633. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31634. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31635. if len(m.appendlabel_dist) == 0 {
  31636. return nil, false
  31637. }
  31638. return m.appendlabel_dist, true
  31639. }
  31640. // ResetLabelDist resets all changes to the "label_dist" field.
  31641. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31642. m.label_dist = nil
  31643. m.appendlabel_dist = nil
  31644. }
  31645. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31646. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31647. m.predicates = append(m.predicates, ps...)
  31648. }
  31649. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31650. // users can use type-assertion to append predicates that do not depend on any generated package.
  31651. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31652. p := make([]predicate.UsageStatisticDay, len(ps))
  31653. for i := range ps {
  31654. p[i] = ps[i]
  31655. }
  31656. m.Where(p...)
  31657. }
  31658. // Op returns the operation name.
  31659. func (m *UsageStatisticDayMutation) Op() Op {
  31660. return m.op
  31661. }
  31662. // SetOp allows setting the mutation operation.
  31663. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31664. m.op = op
  31665. }
  31666. // Type returns the node type of this mutation (UsageStatisticDay).
  31667. func (m *UsageStatisticDayMutation) Type() string {
  31668. return m.typ
  31669. }
  31670. // Fields returns all fields that were changed during this mutation. Note that in
  31671. // order to get all numeric fields that were incremented/decremented, call
  31672. // AddedFields().
  31673. func (m *UsageStatisticDayMutation) Fields() []string {
  31674. fields := make([]string, 0, 17)
  31675. if m.created_at != nil {
  31676. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31677. }
  31678. if m.updated_at != nil {
  31679. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31680. }
  31681. if m.status != nil {
  31682. fields = append(fields, usagestatisticday.FieldStatus)
  31683. }
  31684. if m.deleted_at != nil {
  31685. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31686. }
  31687. if m.addtime != nil {
  31688. fields = append(fields, usagestatisticday.FieldAddtime)
  31689. }
  31690. if m._type != nil {
  31691. fields = append(fields, usagestatisticday.FieldType)
  31692. }
  31693. if m.bot_id != nil {
  31694. fields = append(fields, usagestatisticday.FieldBotID)
  31695. }
  31696. if m.organization_id != nil {
  31697. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31698. }
  31699. if m.ai_response != nil {
  31700. fields = append(fields, usagestatisticday.FieldAiResponse)
  31701. }
  31702. if m.sop_run != nil {
  31703. fields = append(fields, usagestatisticday.FieldSopRun)
  31704. }
  31705. if m.total_friend != nil {
  31706. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31707. }
  31708. if m.total_group != nil {
  31709. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31710. }
  31711. if m.account_balance != nil {
  31712. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31713. }
  31714. if m.consume_token != nil {
  31715. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31716. }
  31717. if m.active_user != nil {
  31718. fields = append(fields, usagestatisticday.FieldActiveUser)
  31719. }
  31720. if m.new_user != nil {
  31721. fields = append(fields, usagestatisticday.FieldNewUser)
  31722. }
  31723. if m.label_dist != nil {
  31724. fields = append(fields, usagestatisticday.FieldLabelDist)
  31725. }
  31726. return fields
  31727. }
  31728. // Field returns the value of a field with the given name. The second boolean
  31729. // return value indicates that this field was not set, or was not defined in the
  31730. // schema.
  31731. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31732. switch name {
  31733. case usagestatisticday.FieldCreatedAt:
  31734. return m.CreatedAt()
  31735. case usagestatisticday.FieldUpdatedAt:
  31736. return m.UpdatedAt()
  31737. case usagestatisticday.FieldStatus:
  31738. return m.Status()
  31739. case usagestatisticday.FieldDeletedAt:
  31740. return m.DeletedAt()
  31741. case usagestatisticday.FieldAddtime:
  31742. return m.Addtime()
  31743. case usagestatisticday.FieldType:
  31744. return m.GetType()
  31745. case usagestatisticday.FieldBotID:
  31746. return m.BotID()
  31747. case usagestatisticday.FieldOrganizationID:
  31748. return m.OrganizationID()
  31749. case usagestatisticday.FieldAiResponse:
  31750. return m.AiResponse()
  31751. case usagestatisticday.FieldSopRun:
  31752. return m.SopRun()
  31753. case usagestatisticday.FieldTotalFriend:
  31754. return m.TotalFriend()
  31755. case usagestatisticday.FieldTotalGroup:
  31756. return m.TotalGroup()
  31757. case usagestatisticday.FieldAccountBalance:
  31758. return m.AccountBalance()
  31759. case usagestatisticday.FieldConsumeToken:
  31760. return m.ConsumeToken()
  31761. case usagestatisticday.FieldActiveUser:
  31762. return m.ActiveUser()
  31763. case usagestatisticday.FieldNewUser:
  31764. return m.NewUser()
  31765. case usagestatisticday.FieldLabelDist:
  31766. return m.LabelDist()
  31767. }
  31768. return nil, false
  31769. }
  31770. // OldField returns the old value of the field from the database. An error is
  31771. // returned if the mutation operation is not UpdateOne, or the query to the
  31772. // database failed.
  31773. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31774. switch name {
  31775. case usagestatisticday.FieldCreatedAt:
  31776. return m.OldCreatedAt(ctx)
  31777. case usagestatisticday.FieldUpdatedAt:
  31778. return m.OldUpdatedAt(ctx)
  31779. case usagestatisticday.FieldStatus:
  31780. return m.OldStatus(ctx)
  31781. case usagestatisticday.FieldDeletedAt:
  31782. return m.OldDeletedAt(ctx)
  31783. case usagestatisticday.FieldAddtime:
  31784. return m.OldAddtime(ctx)
  31785. case usagestatisticday.FieldType:
  31786. return m.OldType(ctx)
  31787. case usagestatisticday.FieldBotID:
  31788. return m.OldBotID(ctx)
  31789. case usagestatisticday.FieldOrganizationID:
  31790. return m.OldOrganizationID(ctx)
  31791. case usagestatisticday.FieldAiResponse:
  31792. return m.OldAiResponse(ctx)
  31793. case usagestatisticday.FieldSopRun:
  31794. return m.OldSopRun(ctx)
  31795. case usagestatisticday.FieldTotalFriend:
  31796. return m.OldTotalFriend(ctx)
  31797. case usagestatisticday.FieldTotalGroup:
  31798. return m.OldTotalGroup(ctx)
  31799. case usagestatisticday.FieldAccountBalance:
  31800. return m.OldAccountBalance(ctx)
  31801. case usagestatisticday.FieldConsumeToken:
  31802. return m.OldConsumeToken(ctx)
  31803. case usagestatisticday.FieldActiveUser:
  31804. return m.OldActiveUser(ctx)
  31805. case usagestatisticday.FieldNewUser:
  31806. return m.OldNewUser(ctx)
  31807. case usagestatisticday.FieldLabelDist:
  31808. return m.OldLabelDist(ctx)
  31809. }
  31810. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31811. }
  31812. // SetField sets the value of a field with the given name. It returns an error if
  31813. // the field is not defined in the schema, or if the type mismatched the field
  31814. // type.
  31815. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31816. switch name {
  31817. case usagestatisticday.FieldCreatedAt:
  31818. v, ok := value.(time.Time)
  31819. if !ok {
  31820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31821. }
  31822. m.SetCreatedAt(v)
  31823. return nil
  31824. case usagestatisticday.FieldUpdatedAt:
  31825. v, ok := value.(time.Time)
  31826. if !ok {
  31827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31828. }
  31829. m.SetUpdatedAt(v)
  31830. return nil
  31831. case usagestatisticday.FieldStatus:
  31832. v, ok := value.(uint8)
  31833. if !ok {
  31834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31835. }
  31836. m.SetStatus(v)
  31837. return nil
  31838. case usagestatisticday.FieldDeletedAt:
  31839. v, ok := value.(time.Time)
  31840. if !ok {
  31841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31842. }
  31843. m.SetDeletedAt(v)
  31844. return nil
  31845. case usagestatisticday.FieldAddtime:
  31846. v, ok := value.(uint64)
  31847. if !ok {
  31848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31849. }
  31850. m.SetAddtime(v)
  31851. return nil
  31852. case usagestatisticday.FieldType:
  31853. v, ok := value.(int)
  31854. if !ok {
  31855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31856. }
  31857. m.SetType(v)
  31858. return nil
  31859. case usagestatisticday.FieldBotID:
  31860. v, ok := value.(string)
  31861. if !ok {
  31862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31863. }
  31864. m.SetBotID(v)
  31865. return nil
  31866. case usagestatisticday.FieldOrganizationID:
  31867. v, ok := value.(uint64)
  31868. if !ok {
  31869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31870. }
  31871. m.SetOrganizationID(v)
  31872. return nil
  31873. case usagestatisticday.FieldAiResponse:
  31874. v, ok := value.(uint64)
  31875. if !ok {
  31876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31877. }
  31878. m.SetAiResponse(v)
  31879. return nil
  31880. case usagestatisticday.FieldSopRun:
  31881. v, ok := value.(uint64)
  31882. if !ok {
  31883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31884. }
  31885. m.SetSopRun(v)
  31886. return nil
  31887. case usagestatisticday.FieldTotalFriend:
  31888. v, ok := value.(uint64)
  31889. if !ok {
  31890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31891. }
  31892. m.SetTotalFriend(v)
  31893. return nil
  31894. case usagestatisticday.FieldTotalGroup:
  31895. v, ok := value.(uint64)
  31896. if !ok {
  31897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31898. }
  31899. m.SetTotalGroup(v)
  31900. return nil
  31901. case usagestatisticday.FieldAccountBalance:
  31902. v, ok := value.(uint64)
  31903. if !ok {
  31904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31905. }
  31906. m.SetAccountBalance(v)
  31907. return nil
  31908. case usagestatisticday.FieldConsumeToken:
  31909. v, ok := value.(uint64)
  31910. if !ok {
  31911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31912. }
  31913. m.SetConsumeToken(v)
  31914. return nil
  31915. case usagestatisticday.FieldActiveUser:
  31916. v, ok := value.(uint64)
  31917. if !ok {
  31918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31919. }
  31920. m.SetActiveUser(v)
  31921. return nil
  31922. case usagestatisticday.FieldNewUser:
  31923. v, ok := value.(int64)
  31924. if !ok {
  31925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31926. }
  31927. m.SetNewUser(v)
  31928. return nil
  31929. case usagestatisticday.FieldLabelDist:
  31930. v, ok := value.([]custom_types.LabelDist)
  31931. if !ok {
  31932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31933. }
  31934. m.SetLabelDist(v)
  31935. return nil
  31936. }
  31937. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31938. }
  31939. // AddedFields returns all numeric fields that were incremented/decremented during
  31940. // this mutation.
  31941. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31942. var fields []string
  31943. if m.addstatus != nil {
  31944. fields = append(fields, usagestatisticday.FieldStatus)
  31945. }
  31946. if m.addaddtime != nil {
  31947. fields = append(fields, usagestatisticday.FieldAddtime)
  31948. }
  31949. if m.add_type != nil {
  31950. fields = append(fields, usagestatisticday.FieldType)
  31951. }
  31952. if m.addorganization_id != nil {
  31953. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31954. }
  31955. if m.addai_response != nil {
  31956. fields = append(fields, usagestatisticday.FieldAiResponse)
  31957. }
  31958. if m.addsop_run != nil {
  31959. fields = append(fields, usagestatisticday.FieldSopRun)
  31960. }
  31961. if m.addtotal_friend != nil {
  31962. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31963. }
  31964. if m.addtotal_group != nil {
  31965. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31966. }
  31967. if m.addaccount_balance != nil {
  31968. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31969. }
  31970. if m.addconsume_token != nil {
  31971. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31972. }
  31973. if m.addactive_user != nil {
  31974. fields = append(fields, usagestatisticday.FieldActiveUser)
  31975. }
  31976. if m.addnew_user != nil {
  31977. fields = append(fields, usagestatisticday.FieldNewUser)
  31978. }
  31979. return fields
  31980. }
  31981. // AddedField returns the numeric value that was incremented/decremented on a field
  31982. // with the given name. The second boolean return value indicates that this field
  31983. // was not set, or was not defined in the schema.
  31984. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31985. switch name {
  31986. case usagestatisticday.FieldStatus:
  31987. return m.AddedStatus()
  31988. case usagestatisticday.FieldAddtime:
  31989. return m.AddedAddtime()
  31990. case usagestatisticday.FieldType:
  31991. return m.AddedType()
  31992. case usagestatisticday.FieldOrganizationID:
  31993. return m.AddedOrganizationID()
  31994. case usagestatisticday.FieldAiResponse:
  31995. return m.AddedAiResponse()
  31996. case usagestatisticday.FieldSopRun:
  31997. return m.AddedSopRun()
  31998. case usagestatisticday.FieldTotalFriend:
  31999. return m.AddedTotalFriend()
  32000. case usagestatisticday.FieldTotalGroup:
  32001. return m.AddedTotalGroup()
  32002. case usagestatisticday.FieldAccountBalance:
  32003. return m.AddedAccountBalance()
  32004. case usagestatisticday.FieldConsumeToken:
  32005. return m.AddedConsumeToken()
  32006. case usagestatisticday.FieldActiveUser:
  32007. return m.AddedActiveUser()
  32008. case usagestatisticday.FieldNewUser:
  32009. return m.AddedNewUser()
  32010. }
  32011. return nil, false
  32012. }
  32013. // AddField adds the value to the field with the given name. It returns an error if
  32014. // the field is not defined in the schema, or if the type mismatched the field
  32015. // type.
  32016. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  32017. switch name {
  32018. case usagestatisticday.FieldStatus:
  32019. v, ok := value.(int8)
  32020. if !ok {
  32021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32022. }
  32023. m.AddStatus(v)
  32024. return nil
  32025. case usagestatisticday.FieldAddtime:
  32026. v, ok := value.(int64)
  32027. if !ok {
  32028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32029. }
  32030. m.AddAddtime(v)
  32031. return nil
  32032. case usagestatisticday.FieldType:
  32033. v, ok := value.(int)
  32034. if !ok {
  32035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32036. }
  32037. m.AddType(v)
  32038. return nil
  32039. case usagestatisticday.FieldOrganizationID:
  32040. v, ok := value.(int64)
  32041. if !ok {
  32042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32043. }
  32044. m.AddOrganizationID(v)
  32045. return nil
  32046. case usagestatisticday.FieldAiResponse:
  32047. v, ok := value.(int64)
  32048. if !ok {
  32049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32050. }
  32051. m.AddAiResponse(v)
  32052. return nil
  32053. case usagestatisticday.FieldSopRun:
  32054. v, ok := value.(int64)
  32055. if !ok {
  32056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32057. }
  32058. m.AddSopRun(v)
  32059. return nil
  32060. case usagestatisticday.FieldTotalFriend:
  32061. v, ok := value.(int64)
  32062. if !ok {
  32063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32064. }
  32065. m.AddTotalFriend(v)
  32066. return nil
  32067. case usagestatisticday.FieldTotalGroup:
  32068. v, ok := value.(int64)
  32069. if !ok {
  32070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32071. }
  32072. m.AddTotalGroup(v)
  32073. return nil
  32074. case usagestatisticday.FieldAccountBalance:
  32075. v, ok := value.(int64)
  32076. if !ok {
  32077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32078. }
  32079. m.AddAccountBalance(v)
  32080. return nil
  32081. case usagestatisticday.FieldConsumeToken:
  32082. v, ok := value.(int64)
  32083. if !ok {
  32084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32085. }
  32086. m.AddConsumeToken(v)
  32087. return nil
  32088. case usagestatisticday.FieldActiveUser:
  32089. v, ok := value.(int64)
  32090. if !ok {
  32091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32092. }
  32093. m.AddActiveUser(v)
  32094. return nil
  32095. case usagestatisticday.FieldNewUser:
  32096. v, ok := value.(int64)
  32097. if !ok {
  32098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32099. }
  32100. m.AddNewUser(v)
  32101. return nil
  32102. }
  32103. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  32104. }
  32105. // ClearedFields returns all nullable fields that were cleared during this
  32106. // mutation.
  32107. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  32108. var fields []string
  32109. if m.FieldCleared(usagestatisticday.FieldStatus) {
  32110. fields = append(fields, usagestatisticday.FieldStatus)
  32111. }
  32112. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  32113. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32114. }
  32115. if m.FieldCleared(usagestatisticday.FieldBotID) {
  32116. fields = append(fields, usagestatisticday.FieldBotID)
  32117. }
  32118. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  32119. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32120. }
  32121. return fields
  32122. }
  32123. // FieldCleared returns a boolean indicating if a field with the given name was
  32124. // cleared in this mutation.
  32125. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  32126. _, ok := m.clearedFields[name]
  32127. return ok
  32128. }
  32129. // ClearField clears the value of the field with the given name. It returns an
  32130. // error if the field is not defined in the schema.
  32131. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  32132. switch name {
  32133. case usagestatisticday.FieldStatus:
  32134. m.ClearStatus()
  32135. return nil
  32136. case usagestatisticday.FieldDeletedAt:
  32137. m.ClearDeletedAt()
  32138. return nil
  32139. case usagestatisticday.FieldBotID:
  32140. m.ClearBotID()
  32141. return nil
  32142. case usagestatisticday.FieldOrganizationID:
  32143. m.ClearOrganizationID()
  32144. return nil
  32145. }
  32146. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  32147. }
  32148. // ResetField resets all changes in the mutation for the field with the given name.
  32149. // It returns an error if the field is not defined in the schema.
  32150. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  32151. switch name {
  32152. case usagestatisticday.FieldCreatedAt:
  32153. m.ResetCreatedAt()
  32154. return nil
  32155. case usagestatisticday.FieldUpdatedAt:
  32156. m.ResetUpdatedAt()
  32157. return nil
  32158. case usagestatisticday.FieldStatus:
  32159. m.ResetStatus()
  32160. return nil
  32161. case usagestatisticday.FieldDeletedAt:
  32162. m.ResetDeletedAt()
  32163. return nil
  32164. case usagestatisticday.FieldAddtime:
  32165. m.ResetAddtime()
  32166. return nil
  32167. case usagestatisticday.FieldType:
  32168. m.ResetType()
  32169. return nil
  32170. case usagestatisticday.FieldBotID:
  32171. m.ResetBotID()
  32172. return nil
  32173. case usagestatisticday.FieldOrganizationID:
  32174. m.ResetOrganizationID()
  32175. return nil
  32176. case usagestatisticday.FieldAiResponse:
  32177. m.ResetAiResponse()
  32178. return nil
  32179. case usagestatisticday.FieldSopRun:
  32180. m.ResetSopRun()
  32181. return nil
  32182. case usagestatisticday.FieldTotalFriend:
  32183. m.ResetTotalFriend()
  32184. return nil
  32185. case usagestatisticday.FieldTotalGroup:
  32186. m.ResetTotalGroup()
  32187. return nil
  32188. case usagestatisticday.FieldAccountBalance:
  32189. m.ResetAccountBalance()
  32190. return nil
  32191. case usagestatisticday.FieldConsumeToken:
  32192. m.ResetConsumeToken()
  32193. return nil
  32194. case usagestatisticday.FieldActiveUser:
  32195. m.ResetActiveUser()
  32196. return nil
  32197. case usagestatisticday.FieldNewUser:
  32198. m.ResetNewUser()
  32199. return nil
  32200. case usagestatisticday.FieldLabelDist:
  32201. m.ResetLabelDist()
  32202. return nil
  32203. }
  32204. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32205. }
  32206. // AddedEdges returns all edge names that were set/added in this mutation.
  32207. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  32208. edges := make([]string, 0, 0)
  32209. return edges
  32210. }
  32211. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32212. // name in this mutation.
  32213. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  32214. return nil
  32215. }
  32216. // RemovedEdges returns all edge names that were removed in this mutation.
  32217. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  32218. edges := make([]string, 0, 0)
  32219. return edges
  32220. }
  32221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32222. // the given name in this mutation.
  32223. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  32224. return nil
  32225. }
  32226. // ClearedEdges returns all edge names that were cleared in this mutation.
  32227. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  32228. edges := make([]string, 0, 0)
  32229. return edges
  32230. }
  32231. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32232. // was cleared in this mutation.
  32233. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  32234. return false
  32235. }
  32236. // ClearEdge clears the value of the edge with the given name. It returns an error
  32237. // if that edge is not defined in the schema.
  32238. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  32239. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  32240. }
  32241. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32242. // It returns an error if the edge is not defined in the schema.
  32243. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  32244. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  32245. }
  32246. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  32247. type UsageStatisticHourMutation struct {
  32248. config
  32249. op Op
  32250. typ string
  32251. id *uint64
  32252. created_at *time.Time
  32253. updated_at *time.Time
  32254. status *uint8
  32255. addstatus *int8
  32256. deleted_at *time.Time
  32257. addtime *uint64
  32258. addaddtime *int64
  32259. _type *int
  32260. add_type *int
  32261. bot_id *string
  32262. organization_id *uint64
  32263. addorganization_id *int64
  32264. ai_response *uint64
  32265. addai_response *int64
  32266. sop_run *uint64
  32267. addsop_run *int64
  32268. total_friend *uint64
  32269. addtotal_friend *int64
  32270. total_group *uint64
  32271. addtotal_group *int64
  32272. account_balance *uint64
  32273. addaccount_balance *int64
  32274. consume_token *uint64
  32275. addconsume_token *int64
  32276. active_user *uint64
  32277. addactive_user *int64
  32278. new_user *int64
  32279. addnew_user *int64
  32280. label_dist *[]custom_types.LabelDist
  32281. appendlabel_dist []custom_types.LabelDist
  32282. clearedFields map[string]struct{}
  32283. done bool
  32284. oldValue func(context.Context) (*UsageStatisticHour, error)
  32285. predicates []predicate.UsageStatisticHour
  32286. }
  32287. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32288. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32289. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32290. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32291. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32292. m := &UsageStatisticHourMutation{
  32293. config: c,
  32294. op: op,
  32295. typ: TypeUsageStatisticHour,
  32296. clearedFields: make(map[string]struct{}),
  32297. }
  32298. for _, opt := range opts {
  32299. opt(m)
  32300. }
  32301. return m
  32302. }
  32303. // withUsageStatisticHourID sets the ID field of the mutation.
  32304. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  32305. return func(m *UsageStatisticHourMutation) {
  32306. var (
  32307. err error
  32308. once sync.Once
  32309. value *UsageStatisticHour
  32310. )
  32311. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  32312. once.Do(func() {
  32313. if m.done {
  32314. err = errors.New("querying old values post mutation is not allowed")
  32315. } else {
  32316. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  32317. }
  32318. })
  32319. return value, err
  32320. }
  32321. m.id = &id
  32322. }
  32323. }
  32324. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  32325. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  32326. return func(m *UsageStatisticHourMutation) {
  32327. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  32328. return node, nil
  32329. }
  32330. m.id = &node.ID
  32331. }
  32332. }
  32333. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32334. // executed in a transaction (ent.Tx), a transactional client is returned.
  32335. func (m UsageStatisticHourMutation) Client() *Client {
  32336. client := &Client{config: m.config}
  32337. client.init()
  32338. return client
  32339. }
  32340. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32341. // it returns an error otherwise.
  32342. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  32343. if _, ok := m.driver.(*txDriver); !ok {
  32344. return nil, errors.New("ent: mutation is not running in a transaction")
  32345. }
  32346. tx := &Tx{config: m.config}
  32347. tx.init()
  32348. return tx, nil
  32349. }
  32350. // SetID sets the value of the id field. Note that this
  32351. // operation is only accepted on creation of UsageStatisticHour entities.
  32352. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  32353. m.id = &id
  32354. }
  32355. // ID returns the ID value in the mutation. Note that the ID is only available
  32356. // if it was provided to the builder or after it was returned from the database.
  32357. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  32358. if m.id == nil {
  32359. return
  32360. }
  32361. return *m.id, true
  32362. }
  32363. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32364. // That means, if the mutation is applied within a transaction with an isolation level such
  32365. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32366. // or updated by the mutation.
  32367. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32368. switch {
  32369. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32370. id, exists := m.ID()
  32371. if exists {
  32372. return []uint64{id}, nil
  32373. }
  32374. fallthrough
  32375. case m.op.Is(OpUpdate | OpDelete):
  32376. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32377. default:
  32378. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32379. }
  32380. }
  32381. // SetCreatedAt sets the "created_at" field.
  32382. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32383. m.created_at = &t
  32384. }
  32385. // CreatedAt returns the value of the "created_at" field in the mutation.
  32386. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32387. v := m.created_at
  32388. if v == nil {
  32389. return
  32390. }
  32391. return *v, true
  32392. }
  32393. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32394. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32396. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32397. if !m.op.Is(OpUpdateOne) {
  32398. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32399. }
  32400. if m.id == nil || m.oldValue == nil {
  32401. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32402. }
  32403. oldValue, err := m.oldValue(ctx)
  32404. if err != nil {
  32405. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32406. }
  32407. return oldValue.CreatedAt, nil
  32408. }
  32409. // ResetCreatedAt resets all changes to the "created_at" field.
  32410. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32411. m.created_at = nil
  32412. }
  32413. // SetUpdatedAt sets the "updated_at" field.
  32414. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32415. m.updated_at = &t
  32416. }
  32417. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32418. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32419. v := m.updated_at
  32420. if v == nil {
  32421. return
  32422. }
  32423. return *v, true
  32424. }
  32425. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32426. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32428. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32429. if !m.op.Is(OpUpdateOne) {
  32430. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32431. }
  32432. if m.id == nil || m.oldValue == nil {
  32433. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32434. }
  32435. oldValue, err := m.oldValue(ctx)
  32436. if err != nil {
  32437. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32438. }
  32439. return oldValue.UpdatedAt, nil
  32440. }
  32441. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32442. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32443. m.updated_at = nil
  32444. }
  32445. // SetStatus sets the "status" field.
  32446. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32447. m.status = &u
  32448. m.addstatus = nil
  32449. }
  32450. // Status returns the value of the "status" field in the mutation.
  32451. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32452. v := m.status
  32453. if v == nil {
  32454. return
  32455. }
  32456. return *v, true
  32457. }
  32458. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32459. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32461. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32462. if !m.op.Is(OpUpdateOne) {
  32463. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32464. }
  32465. if m.id == nil || m.oldValue == nil {
  32466. return v, errors.New("OldStatus requires an ID field in the mutation")
  32467. }
  32468. oldValue, err := m.oldValue(ctx)
  32469. if err != nil {
  32470. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32471. }
  32472. return oldValue.Status, nil
  32473. }
  32474. // AddStatus adds u to the "status" field.
  32475. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32476. if m.addstatus != nil {
  32477. *m.addstatus += u
  32478. } else {
  32479. m.addstatus = &u
  32480. }
  32481. }
  32482. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32483. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32484. v := m.addstatus
  32485. if v == nil {
  32486. return
  32487. }
  32488. return *v, true
  32489. }
  32490. // ClearStatus clears the value of the "status" field.
  32491. func (m *UsageStatisticHourMutation) ClearStatus() {
  32492. m.status = nil
  32493. m.addstatus = nil
  32494. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32495. }
  32496. // StatusCleared returns if the "status" field was cleared in this mutation.
  32497. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32498. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32499. return ok
  32500. }
  32501. // ResetStatus resets all changes to the "status" field.
  32502. func (m *UsageStatisticHourMutation) ResetStatus() {
  32503. m.status = nil
  32504. m.addstatus = nil
  32505. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32506. }
  32507. // SetDeletedAt sets the "deleted_at" field.
  32508. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32509. m.deleted_at = &t
  32510. }
  32511. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32512. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32513. v := m.deleted_at
  32514. if v == nil {
  32515. return
  32516. }
  32517. return *v, true
  32518. }
  32519. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32520. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32522. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32523. if !m.op.Is(OpUpdateOne) {
  32524. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32525. }
  32526. if m.id == nil || m.oldValue == nil {
  32527. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32528. }
  32529. oldValue, err := m.oldValue(ctx)
  32530. if err != nil {
  32531. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32532. }
  32533. return oldValue.DeletedAt, nil
  32534. }
  32535. // ClearDeletedAt clears the value of the "deleted_at" field.
  32536. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32537. m.deleted_at = nil
  32538. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32539. }
  32540. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32541. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32542. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32543. return ok
  32544. }
  32545. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32546. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32547. m.deleted_at = nil
  32548. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32549. }
  32550. // SetAddtime sets the "addtime" field.
  32551. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32552. m.addtime = &u
  32553. m.addaddtime = nil
  32554. }
  32555. // Addtime returns the value of the "addtime" field in the mutation.
  32556. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32557. v := m.addtime
  32558. if v == nil {
  32559. return
  32560. }
  32561. return *v, true
  32562. }
  32563. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32564. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32566. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32567. if !m.op.Is(OpUpdateOne) {
  32568. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32569. }
  32570. if m.id == nil || m.oldValue == nil {
  32571. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32572. }
  32573. oldValue, err := m.oldValue(ctx)
  32574. if err != nil {
  32575. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32576. }
  32577. return oldValue.Addtime, nil
  32578. }
  32579. // AddAddtime adds u to the "addtime" field.
  32580. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32581. if m.addaddtime != nil {
  32582. *m.addaddtime += u
  32583. } else {
  32584. m.addaddtime = &u
  32585. }
  32586. }
  32587. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32588. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32589. v := m.addaddtime
  32590. if v == nil {
  32591. return
  32592. }
  32593. return *v, true
  32594. }
  32595. // ResetAddtime resets all changes to the "addtime" field.
  32596. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32597. m.addtime = nil
  32598. m.addaddtime = nil
  32599. }
  32600. // SetType sets the "type" field.
  32601. func (m *UsageStatisticHourMutation) SetType(i int) {
  32602. m._type = &i
  32603. m.add_type = nil
  32604. }
  32605. // GetType returns the value of the "type" field in the mutation.
  32606. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32607. v := m._type
  32608. if v == nil {
  32609. return
  32610. }
  32611. return *v, true
  32612. }
  32613. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32614. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32616. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32617. if !m.op.Is(OpUpdateOne) {
  32618. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32619. }
  32620. if m.id == nil || m.oldValue == nil {
  32621. return v, errors.New("OldType requires an ID field in the mutation")
  32622. }
  32623. oldValue, err := m.oldValue(ctx)
  32624. if err != nil {
  32625. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32626. }
  32627. return oldValue.Type, nil
  32628. }
  32629. // AddType adds i to the "type" field.
  32630. func (m *UsageStatisticHourMutation) AddType(i int) {
  32631. if m.add_type != nil {
  32632. *m.add_type += i
  32633. } else {
  32634. m.add_type = &i
  32635. }
  32636. }
  32637. // AddedType returns the value that was added to the "type" field in this mutation.
  32638. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32639. v := m.add_type
  32640. if v == nil {
  32641. return
  32642. }
  32643. return *v, true
  32644. }
  32645. // ResetType resets all changes to the "type" field.
  32646. func (m *UsageStatisticHourMutation) ResetType() {
  32647. m._type = nil
  32648. m.add_type = nil
  32649. }
  32650. // SetBotID sets the "bot_id" field.
  32651. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32652. m.bot_id = &s
  32653. }
  32654. // BotID returns the value of the "bot_id" field in the mutation.
  32655. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32656. v := m.bot_id
  32657. if v == nil {
  32658. return
  32659. }
  32660. return *v, true
  32661. }
  32662. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32663. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32665. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32666. if !m.op.Is(OpUpdateOne) {
  32667. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32668. }
  32669. if m.id == nil || m.oldValue == nil {
  32670. return v, errors.New("OldBotID requires an ID field in the mutation")
  32671. }
  32672. oldValue, err := m.oldValue(ctx)
  32673. if err != nil {
  32674. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32675. }
  32676. return oldValue.BotID, nil
  32677. }
  32678. // ClearBotID clears the value of the "bot_id" field.
  32679. func (m *UsageStatisticHourMutation) ClearBotID() {
  32680. m.bot_id = nil
  32681. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32682. }
  32683. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32684. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32685. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32686. return ok
  32687. }
  32688. // ResetBotID resets all changes to the "bot_id" field.
  32689. func (m *UsageStatisticHourMutation) ResetBotID() {
  32690. m.bot_id = nil
  32691. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32692. }
  32693. // SetOrganizationID sets the "organization_id" field.
  32694. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32695. m.organization_id = &u
  32696. m.addorganization_id = nil
  32697. }
  32698. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32699. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32700. v := m.organization_id
  32701. if v == nil {
  32702. return
  32703. }
  32704. return *v, true
  32705. }
  32706. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32707. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32709. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32710. if !m.op.Is(OpUpdateOne) {
  32711. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32712. }
  32713. if m.id == nil || m.oldValue == nil {
  32714. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32715. }
  32716. oldValue, err := m.oldValue(ctx)
  32717. if err != nil {
  32718. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32719. }
  32720. return oldValue.OrganizationID, nil
  32721. }
  32722. // AddOrganizationID adds u to the "organization_id" field.
  32723. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32724. if m.addorganization_id != nil {
  32725. *m.addorganization_id += u
  32726. } else {
  32727. m.addorganization_id = &u
  32728. }
  32729. }
  32730. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32731. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32732. v := m.addorganization_id
  32733. if v == nil {
  32734. return
  32735. }
  32736. return *v, true
  32737. }
  32738. // ClearOrganizationID clears the value of the "organization_id" field.
  32739. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32740. m.organization_id = nil
  32741. m.addorganization_id = nil
  32742. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32743. }
  32744. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32745. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32746. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32747. return ok
  32748. }
  32749. // ResetOrganizationID resets all changes to the "organization_id" field.
  32750. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32751. m.organization_id = nil
  32752. m.addorganization_id = nil
  32753. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32754. }
  32755. // SetAiResponse sets the "ai_response" field.
  32756. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32757. m.ai_response = &u
  32758. m.addai_response = nil
  32759. }
  32760. // AiResponse returns the value of the "ai_response" field in the mutation.
  32761. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32762. v := m.ai_response
  32763. if v == nil {
  32764. return
  32765. }
  32766. return *v, true
  32767. }
  32768. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32769. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32771. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32772. if !m.op.Is(OpUpdateOne) {
  32773. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32774. }
  32775. if m.id == nil || m.oldValue == nil {
  32776. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32777. }
  32778. oldValue, err := m.oldValue(ctx)
  32779. if err != nil {
  32780. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32781. }
  32782. return oldValue.AiResponse, nil
  32783. }
  32784. // AddAiResponse adds u to the "ai_response" field.
  32785. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32786. if m.addai_response != nil {
  32787. *m.addai_response += u
  32788. } else {
  32789. m.addai_response = &u
  32790. }
  32791. }
  32792. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32793. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32794. v := m.addai_response
  32795. if v == nil {
  32796. return
  32797. }
  32798. return *v, true
  32799. }
  32800. // ResetAiResponse resets all changes to the "ai_response" field.
  32801. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32802. m.ai_response = nil
  32803. m.addai_response = nil
  32804. }
  32805. // SetSopRun sets the "sop_run" field.
  32806. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32807. m.sop_run = &u
  32808. m.addsop_run = nil
  32809. }
  32810. // SopRun returns the value of the "sop_run" field in the mutation.
  32811. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32812. v := m.sop_run
  32813. if v == nil {
  32814. return
  32815. }
  32816. return *v, true
  32817. }
  32818. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32819. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32821. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32822. if !m.op.Is(OpUpdateOne) {
  32823. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32824. }
  32825. if m.id == nil || m.oldValue == nil {
  32826. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32827. }
  32828. oldValue, err := m.oldValue(ctx)
  32829. if err != nil {
  32830. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32831. }
  32832. return oldValue.SopRun, nil
  32833. }
  32834. // AddSopRun adds u to the "sop_run" field.
  32835. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32836. if m.addsop_run != nil {
  32837. *m.addsop_run += u
  32838. } else {
  32839. m.addsop_run = &u
  32840. }
  32841. }
  32842. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32843. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32844. v := m.addsop_run
  32845. if v == nil {
  32846. return
  32847. }
  32848. return *v, true
  32849. }
  32850. // ResetSopRun resets all changes to the "sop_run" field.
  32851. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32852. m.sop_run = nil
  32853. m.addsop_run = nil
  32854. }
  32855. // SetTotalFriend sets the "total_friend" field.
  32856. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32857. m.total_friend = &u
  32858. m.addtotal_friend = nil
  32859. }
  32860. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32861. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32862. v := m.total_friend
  32863. if v == nil {
  32864. return
  32865. }
  32866. return *v, true
  32867. }
  32868. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32869. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32871. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32872. if !m.op.Is(OpUpdateOne) {
  32873. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32874. }
  32875. if m.id == nil || m.oldValue == nil {
  32876. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32877. }
  32878. oldValue, err := m.oldValue(ctx)
  32879. if err != nil {
  32880. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32881. }
  32882. return oldValue.TotalFriend, nil
  32883. }
  32884. // AddTotalFriend adds u to the "total_friend" field.
  32885. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32886. if m.addtotal_friend != nil {
  32887. *m.addtotal_friend += u
  32888. } else {
  32889. m.addtotal_friend = &u
  32890. }
  32891. }
  32892. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32893. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32894. v := m.addtotal_friend
  32895. if v == nil {
  32896. return
  32897. }
  32898. return *v, true
  32899. }
  32900. // ResetTotalFriend resets all changes to the "total_friend" field.
  32901. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32902. m.total_friend = nil
  32903. m.addtotal_friend = nil
  32904. }
  32905. // SetTotalGroup sets the "total_group" field.
  32906. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32907. m.total_group = &u
  32908. m.addtotal_group = nil
  32909. }
  32910. // TotalGroup returns the value of the "total_group" field in the mutation.
  32911. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32912. v := m.total_group
  32913. if v == nil {
  32914. return
  32915. }
  32916. return *v, true
  32917. }
  32918. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32919. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32921. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32922. if !m.op.Is(OpUpdateOne) {
  32923. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32924. }
  32925. if m.id == nil || m.oldValue == nil {
  32926. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32927. }
  32928. oldValue, err := m.oldValue(ctx)
  32929. if err != nil {
  32930. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32931. }
  32932. return oldValue.TotalGroup, nil
  32933. }
  32934. // AddTotalGroup adds u to the "total_group" field.
  32935. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32936. if m.addtotal_group != nil {
  32937. *m.addtotal_group += u
  32938. } else {
  32939. m.addtotal_group = &u
  32940. }
  32941. }
  32942. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32943. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32944. v := m.addtotal_group
  32945. if v == nil {
  32946. return
  32947. }
  32948. return *v, true
  32949. }
  32950. // ResetTotalGroup resets all changes to the "total_group" field.
  32951. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32952. m.total_group = nil
  32953. m.addtotal_group = nil
  32954. }
  32955. // SetAccountBalance sets the "account_balance" field.
  32956. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32957. m.account_balance = &u
  32958. m.addaccount_balance = nil
  32959. }
  32960. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32961. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32962. v := m.account_balance
  32963. if v == nil {
  32964. return
  32965. }
  32966. return *v, true
  32967. }
  32968. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32969. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32971. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32972. if !m.op.Is(OpUpdateOne) {
  32973. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32974. }
  32975. if m.id == nil || m.oldValue == nil {
  32976. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32977. }
  32978. oldValue, err := m.oldValue(ctx)
  32979. if err != nil {
  32980. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32981. }
  32982. return oldValue.AccountBalance, nil
  32983. }
  32984. // AddAccountBalance adds u to the "account_balance" field.
  32985. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32986. if m.addaccount_balance != nil {
  32987. *m.addaccount_balance += u
  32988. } else {
  32989. m.addaccount_balance = &u
  32990. }
  32991. }
  32992. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32993. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32994. v := m.addaccount_balance
  32995. if v == nil {
  32996. return
  32997. }
  32998. return *v, true
  32999. }
  33000. // ResetAccountBalance resets all changes to the "account_balance" field.
  33001. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  33002. m.account_balance = nil
  33003. m.addaccount_balance = nil
  33004. }
  33005. // SetConsumeToken sets the "consume_token" field.
  33006. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  33007. m.consume_token = &u
  33008. m.addconsume_token = nil
  33009. }
  33010. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33011. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  33012. v := m.consume_token
  33013. if v == nil {
  33014. return
  33015. }
  33016. return *v, true
  33017. }
  33018. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  33019. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33021. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33022. if !m.op.Is(OpUpdateOne) {
  33023. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33024. }
  33025. if m.id == nil || m.oldValue == nil {
  33026. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33027. }
  33028. oldValue, err := m.oldValue(ctx)
  33029. if err != nil {
  33030. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33031. }
  33032. return oldValue.ConsumeToken, nil
  33033. }
  33034. // AddConsumeToken adds u to the "consume_token" field.
  33035. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  33036. if m.addconsume_token != nil {
  33037. *m.addconsume_token += u
  33038. } else {
  33039. m.addconsume_token = &u
  33040. }
  33041. }
  33042. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33043. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  33044. v := m.addconsume_token
  33045. if v == nil {
  33046. return
  33047. }
  33048. return *v, true
  33049. }
  33050. // ResetConsumeToken resets all changes to the "consume_token" field.
  33051. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  33052. m.consume_token = nil
  33053. m.addconsume_token = nil
  33054. }
  33055. // SetActiveUser sets the "active_user" field.
  33056. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  33057. m.active_user = &u
  33058. m.addactive_user = nil
  33059. }
  33060. // ActiveUser returns the value of the "active_user" field in the mutation.
  33061. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  33062. v := m.active_user
  33063. if v == nil {
  33064. return
  33065. }
  33066. return *v, true
  33067. }
  33068. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  33069. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33071. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33072. if !m.op.Is(OpUpdateOne) {
  33073. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33074. }
  33075. if m.id == nil || m.oldValue == nil {
  33076. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33077. }
  33078. oldValue, err := m.oldValue(ctx)
  33079. if err != nil {
  33080. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33081. }
  33082. return oldValue.ActiveUser, nil
  33083. }
  33084. // AddActiveUser adds u to the "active_user" field.
  33085. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  33086. if m.addactive_user != nil {
  33087. *m.addactive_user += u
  33088. } else {
  33089. m.addactive_user = &u
  33090. }
  33091. }
  33092. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33093. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  33094. v := m.addactive_user
  33095. if v == nil {
  33096. return
  33097. }
  33098. return *v, true
  33099. }
  33100. // ResetActiveUser resets all changes to the "active_user" field.
  33101. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  33102. m.active_user = nil
  33103. m.addactive_user = nil
  33104. }
  33105. // SetNewUser sets the "new_user" field.
  33106. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  33107. m.new_user = &i
  33108. m.addnew_user = nil
  33109. }
  33110. // NewUser returns the value of the "new_user" field in the mutation.
  33111. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  33112. v := m.new_user
  33113. if v == nil {
  33114. return
  33115. }
  33116. return *v, true
  33117. }
  33118. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  33119. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33121. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33122. if !m.op.Is(OpUpdateOne) {
  33123. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33124. }
  33125. if m.id == nil || m.oldValue == nil {
  33126. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33127. }
  33128. oldValue, err := m.oldValue(ctx)
  33129. if err != nil {
  33130. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33131. }
  33132. return oldValue.NewUser, nil
  33133. }
  33134. // AddNewUser adds i to the "new_user" field.
  33135. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  33136. if m.addnew_user != nil {
  33137. *m.addnew_user += i
  33138. } else {
  33139. m.addnew_user = &i
  33140. }
  33141. }
  33142. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33143. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  33144. v := m.addnew_user
  33145. if v == nil {
  33146. return
  33147. }
  33148. return *v, true
  33149. }
  33150. // ResetNewUser resets all changes to the "new_user" field.
  33151. func (m *UsageStatisticHourMutation) ResetNewUser() {
  33152. m.new_user = nil
  33153. m.addnew_user = nil
  33154. }
  33155. // SetLabelDist sets the "label_dist" field.
  33156. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33157. m.label_dist = &ctd
  33158. m.appendlabel_dist = nil
  33159. }
  33160. // LabelDist returns the value of the "label_dist" field in the mutation.
  33161. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33162. v := m.label_dist
  33163. if v == nil {
  33164. return
  33165. }
  33166. return *v, true
  33167. }
  33168. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  33169. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33171. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33172. if !m.op.Is(OpUpdateOne) {
  33173. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33174. }
  33175. if m.id == nil || m.oldValue == nil {
  33176. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33177. }
  33178. oldValue, err := m.oldValue(ctx)
  33179. if err != nil {
  33180. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33181. }
  33182. return oldValue.LabelDist, nil
  33183. }
  33184. // AppendLabelDist adds ctd to the "label_dist" field.
  33185. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33186. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33187. }
  33188. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33189. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33190. if len(m.appendlabel_dist) == 0 {
  33191. return nil, false
  33192. }
  33193. return m.appendlabel_dist, true
  33194. }
  33195. // ResetLabelDist resets all changes to the "label_dist" field.
  33196. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  33197. m.label_dist = nil
  33198. m.appendlabel_dist = nil
  33199. }
  33200. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  33201. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  33202. m.predicates = append(m.predicates, ps...)
  33203. }
  33204. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  33205. // users can use type-assertion to append predicates that do not depend on any generated package.
  33206. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  33207. p := make([]predicate.UsageStatisticHour, len(ps))
  33208. for i := range ps {
  33209. p[i] = ps[i]
  33210. }
  33211. m.Where(p...)
  33212. }
  33213. // Op returns the operation name.
  33214. func (m *UsageStatisticHourMutation) Op() Op {
  33215. return m.op
  33216. }
  33217. // SetOp allows setting the mutation operation.
  33218. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  33219. m.op = op
  33220. }
  33221. // Type returns the node type of this mutation (UsageStatisticHour).
  33222. func (m *UsageStatisticHourMutation) Type() string {
  33223. return m.typ
  33224. }
  33225. // Fields returns all fields that were changed during this mutation. Note that in
  33226. // order to get all numeric fields that were incremented/decremented, call
  33227. // AddedFields().
  33228. func (m *UsageStatisticHourMutation) Fields() []string {
  33229. fields := make([]string, 0, 17)
  33230. if m.created_at != nil {
  33231. fields = append(fields, usagestatistichour.FieldCreatedAt)
  33232. }
  33233. if m.updated_at != nil {
  33234. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  33235. }
  33236. if m.status != nil {
  33237. fields = append(fields, usagestatistichour.FieldStatus)
  33238. }
  33239. if m.deleted_at != nil {
  33240. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33241. }
  33242. if m.addtime != nil {
  33243. fields = append(fields, usagestatistichour.FieldAddtime)
  33244. }
  33245. if m._type != nil {
  33246. fields = append(fields, usagestatistichour.FieldType)
  33247. }
  33248. if m.bot_id != nil {
  33249. fields = append(fields, usagestatistichour.FieldBotID)
  33250. }
  33251. if m.organization_id != nil {
  33252. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33253. }
  33254. if m.ai_response != nil {
  33255. fields = append(fields, usagestatistichour.FieldAiResponse)
  33256. }
  33257. if m.sop_run != nil {
  33258. fields = append(fields, usagestatistichour.FieldSopRun)
  33259. }
  33260. if m.total_friend != nil {
  33261. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33262. }
  33263. if m.total_group != nil {
  33264. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33265. }
  33266. if m.account_balance != nil {
  33267. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33268. }
  33269. if m.consume_token != nil {
  33270. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33271. }
  33272. if m.active_user != nil {
  33273. fields = append(fields, usagestatistichour.FieldActiveUser)
  33274. }
  33275. if m.new_user != nil {
  33276. fields = append(fields, usagestatistichour.FieldNewUser)
  33277. }
  33278. if m.label_dist != nil {
  33279. fields = append(fields, usagestatistichour.FieldLabelDist)
  33280. }
  33281. return fields
  33282. }
  33283. // Field returns the value of a field with the given name. The second boolean
  33284. // return value indicates that this field was not set, or was not defined in the
  33285. // schema.
  33286. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  33287. switch name {
  33288. case usagestatistichour.FieldCreatedAt:
  33289. return m.CreatedAt()
  33290. case usagestatistichour.FieldUpdatedAt:
  33291. return m.UpdatedAt()
  33292. case usagestatistichour.FieldStatus:
  33293. return m.Status()
  33294. case usagestatistichour.FieldDeletedAt:
  33295. return m.DeletedAt()
  33296. case usagestatistichour.FieldAddtime:
  33297. return m.Addtime()
  33298. case usagestatistichour.FieldType:
  33299. return m.GetType()
  33300. case usagestatistichour.FieldBotID:
  33301. return m.BotID()
  33302. case usagestatistichour.FieldOrganizationID:
  33303. return m.OrganizationID()
  33304. case usagestatistichour.FieldAiResponse:
  33305. return m.AiResponse()
  33306. case usagestatistichour.FieldSopRun:
  33307. return m.SopRun()
  33308. case usagestatistichour.FieldTotalFriend:
  33309. return m.TotalFriend()
  33310. case usagestatistichour.FieldTotalGroup:
  33311. return m.TotalGroup()
  33312. case usagestatistichour.FieldAccountBalance:
  33313. return m.AccountBalance()
  33314. case usagestatistichour.FieldConsumeToken:
  33315. return m.ConsumeToken()
  33316. case usagestatistichour.FieldActiveUser:
  33317. return m.ActiveUser()
  33318. case usagestatistichour.FieldNewUser:
  33319. return m.NewUser()
  33320. case usagestatistichour.FieldLabelDist:
  33321. return m.LabelDist()
  33322. }
  33323. return nil, false
  33324. }
  33325. // OldField returns the old value of the field from the database. An error is
  33326. // returned if the mutation operation is not UpdateOne, or the query to the
  33327. // database failed.
  33328. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33329. switch name {
  33330. case usagestatistichour.FieldCreatedAt:
  33331. return m.OldCreatedAt(ctx)
  33332. case usagestatistichour.FieldUpdatedAt:
  33333. return m.OldUpdatedAt(ctx)
  33334. case usagestatistichour.FieldStatus:
  33335. return m.OldStatus(ctx)
  33336. case usagestatistichour.FieldDeletedAt:
  33337. return m.OldDeletedAt(ctx)
  33338. case usagestatistichour.FieldAddtime:
  33339. return m.OldAddtime(ctx)
  33340. case usagestatistichour.FieldType:
  33341. return m.OldType(ctx)
  33342. case usagestatistichour.FieldBotID:
  33343. return m.OldBotID(ctx)
  33344. case usagestatistichour.FieldOrganizationID:
  33345. return m.OldOrganizationID(ctx)
  33346. case usagestatistichour.FieldAiResponse:
  33347. return m.OldAiResponse(ctx)
  33348. case usagestatistichour.FieldSopRun:
  33349. return m.OldSopRun(ctx)
  33350. case usagestatistichour.FieldTotalFriend:
  33351. return m.OldTotalFriend(ctx)
  33352. case usagestatistichour.FieldTotalGroup:
  33353. return m.OldTotalGroup(ctx)
  33354. case usagestatistichour.FieldAccountBalance:
  33355. return m.OldAccountBalance(ctx)
  33356. case usagestatistichour.FieldConsumeToken:
  33357. return m.OldConsumeToken(ctx)
  33358. case usagestatistichour.FieldActiveUser:
  33359. return m.OldActiveUser(ctx)
  33360. case usagestatistichour.FieldNewUser:
  33361. return m.OldNewUser(ctx)
  33362. case usagestatistichour.FieldLabelDist:
  33363. return m.OldLabelDist(ctx)
  33364. }
  33365. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33366. }
  33367. // SetField sets the value of a field with the given name. It returns an error if
  33368. // the field is not defined in the schema, or if the type mismatched the field
  33369. // type.
  33370. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33371. switch name {
  33372. case usagestatistichour.FieldCreatedAt:
  33373. v, ok := value.(time.Time)
  33374. if !ok {
  33375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33376. }
  33377. m.SetCreatedAt(v)
  33378. return nil
  33379. case usagestatistichour.FieldUpdatedAt:
  33380. v, ok := value.(time.Time)
  33381. if !ok {
  33382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33383. }
  33384. m.SetUpdatedAt(v)
  33385. return nil
  33386. case usagestatistichour.FieldStatus:
  33387. v, ok := value.(uint8)
  33388. if !ok {
  33389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33390. }
  33391. m.SetStatus(v)
  33392. return nil
  33393. case usagestatistichour.FieldDeletedAt:
  33394. v, ok := value.(time.Time)
  33395. if !ok {
  33396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33397. }
  33398. m.SetDeletedAt(v)
  33399. return nil
  33400. case usagestatistichour.FieldAddtime:
  33401. v, ok := value.(uint64)
  33402. if !ok {
  33403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33404. }
  33405. m.SetAddtime(v)
  33406. return nil
  33407. case usagestatistichour.FieldType:
  33408. v, ok := value.(int)
  33409. if !ok {
  33410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33411. }
  33412. m.SetType(v)
  33413. return nil
  33414. case usagestatistichour.FieldBotID:
  33415. v, ok := value.(string)
  33416. if !ok {
  33417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33418. }
  33419. m.SetBotID(v)
  33420. return nil
  33421. case usagestatistichour.FieldOrganizationID:
  33422. v, ok := value.(uint64)
  33423. if !ok {
  33424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33425. }
  33426. m.SetOrganizationID(v)
  33427. return nil
  33428. case usagestatistichour.FieldAiResponse:
  33429. v, ok := value.(uint64)
  33430. if !ok {
  33431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33432. }
  33433. m.SetAiResponse(v)
  33434. return nil
  33435. case usagestatistichour.FieldSopRun:
  33436. v, ok := value.(uint64)
  33437. if !ok {
  33438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33439. }
  33440. m.SetSopRun(v)
  33441. return nil
  33442. case usagestatistichour.FieldTotalFriend:
  33443. v, ok := value.(uint64)
  33444. if !ok {
  33445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33446. }
  33447. m.SetTotalFriend(v)
  33448. return nil
  33449. case usagestatistichour.FieldTotalGroup:
  33450. v, ok := value.(uint64)
  33451. if !ok {
  33452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33453. }
  33454. m.SetTotalGroup(v)
  33455. return nil
  33456. case usagestatistichour.FieldAccountBalance:
  33457. v, ok := value.(uint64)
  33458. if !ok {
  33459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33460. }
  33461. m.SetAccountBalance(v)
  33462. return nil
  33463. case usagestatistichour.FieldConsumeToken:
  33464. v, ok := value.(uint64)
  33465. if !ok {
  33466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33467. }
  33468. m.SetConsumeToken(v)
  33469. return nil
  33470. case usagestatistichour.FieldActiveUser:
  33471. v, ok := value.(uint64)
  33472. if !ok {
  33473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33474. }
  33475. m.SetActiveUser(v)
  33476. return nil
  33477. case usagestatistichour.FieldNewUser:
  33478. v, ok := value.(int64)
  33479. if !ok {
  33480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33481. }
  33482. m.SetNewUser(v)
  33483. return nil
  33484. case usagestatistichour.FieldLabelDist:
  33485. v, ok := value.([]custom_types.LabelDist)
  33486. if !ok {
  33487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33488. }
  33489. m.SetLabelDist(v)
  33490. return nil
  33491. }
  33492. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33493. }
  33494. // AddedFields returns all numeric fields that were incremented/decremented during
  33495. // this mutation.
  33496. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33497. var fields []string
  33498. if m.addstatus != nil {
  33499. fields = append(fields, usagestatistichour.FieldStatus)
  33500. }
  33501. if m.addaddtime != nil {
  33502. fields = append(fields, usagestatistichour.FieldAddtime)
  33503. }
  33504. if m.add_type != nil {
  33505. fields = append(fields, usagestatistichour.FieldType)
  33506. }
  33507. if m.addorganization_id != nil {
  33508. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33509. }
  33510. if m.addai_response != nil {
  33511. fields = append(fields, usagestatistichour.FieldAiResponse)
  33512. }
  33513. if m.addsop_run != nil {
  33514. fields = append(fields, usagestatistichour.FieldSopRun)
  33515. }
  33516. if m.addtotal_friend != nil {
  33517. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33518. }
  33519. if m.addtotal_group != nil {
  33520. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33521. }
  33522. if m.addaccount_balance != nil {
  33523. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33524. }
  33525. if m.addconsume_token != nil {
  33526. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33527. }
  33528. if m.addactive_user != nil {
  33529. fields = append(fields, usagestatistichour.FieldActiveUser)
  33530. }
  33531. if m.addnew_user != nil {
  33532. fields = append(fields, usagestatistichour.FieldNewUser)
  33533. }
  33534. return fields
  33535. }
  33536. // AddedField returns the numeric value that was incremented/decremented on a field
  33537. // with the given name. The second boolean return value indicates that this field
  33538. // was not set, or was not defined in the schema.
  33539. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33540. switch name {
  33541. case usagestatistichour.FieldStatus:
  33542. return m.AddedStatus()
  33543. case usagestatistichour.FieldAddtime:
  33544. return m.AddedAddtime()
  33545. case usagestatistichour.FieldType:
  33546. return m.AddedType()
  33547. case usagestatistichour.FieldOrganizationID:
  33548. return m.AddedOrganizationID()
  33549. case usagestatistichour.FieldAiResponse:
  33550. return m.AddedAiResponse()
  33551. case usagestatistichour.FieldSopRun:
  33552. return m.AddedSopRun()
  33553. case usagestatistichour.FieldTotalFriend:
  33554. return m.AddedTotalFriend()
  33555. case usagestatistichour.FieldTotalGroup:
  33556. return m.AddedTotalGroup()
  33557. case usagestatistichour.FieldAccountBalance:
  33558. return m.AddedAccountBalance()
  33559. case usagestatistichour.FieldConsumeToken:
  33560. return m.AddedConsumeToken()
  33561. case usagestatistichour.FieldActiveUser:
  33562. return m.AddedActiveUser()
  33563. case usagestatistichour.FieldNewUser:
  33564. return m.AddedNewUser()
  33565. }
  33566. return nil, false
  33567. }
  33568. // AddField adds the value to the field with the given name. It returns an error if
  33569. // the field is not defined in the schema, or if the type mismatched the field
  33570. // type.
  33571. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33572. switch name {
  33573. case usagestatistichour.FieldStatus:
  33574. v, ok := value.(int8)
  33575. if !ok {
  33576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33577. }
  33578. m.AddStatus(v)
  33579. return nil
  33580. case usagestatistichour.FieldAddtime:
  33581. v, ok := value.(int64)
  33582. if !ok {
  33583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33584. }
  33585. m.AddAddtime(v)
  33586. return nil
  33587. case usagestatistichour.FieldType:
  33588. v, ok := value.(int)
  33589. if !ok {
  33590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33591. }
  33592. m.AddType(v)
  33593. return nil
  33594. case usagestatistichour.FieldOrganizationID:
  33595. v, ok := value.(int64)
  33596. if !ok {
  33597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33598. }
  33599. m.AddOrganizationID(v)
  33600. return nil
  33601. case usagestatistichour.FieldAiResponse:
  33602. v, ok := value.(int64)
  33603. if !ok {
  33604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33605. }
  33606. m.AddAiResponse(v)
  33607. return nil
  33608. case usagestatistichour.FieldSopRun:
  33609. v, ok := value.(int64)
  33610. if !ok {
  33611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33612. }
  33613. m.AddSopRun(v)
  33614. return nil
  33615. case usagestatistichour.FieldTotalFriend:
  33616. v, ok := value.(int64)
  33617. if !ok {
  33618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33619. }
  33620. m.AddTotalFriend(v)
  33621. return nil
  33622. case usagestatistichour.FieldTotalGroup:
  33623. v, ok := value.(int64)
  33624. if !ok {
  33625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33626. }
  33627. m.AddTotalGroup(v)
  33628. return nil
  33629. case usagestatistichour.FieldAccountBalance:
  33630. v, ok := value.(int64)
  33631. if !ok {
  33632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33633. }
  33634. m.AddAccountBalance(v)
  33635. return nil
  33636. case usagestatistichour.FieldConsumeToken:
  33637. v, ok := value.(int64)
  33638. if !ok {
  33639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33640. }
  33641. m.AddConsumeToken(v)
  33642. return nil
  33643. case usagestatistichour.FieldActiveUser:
  33644. v, ok := value.(int64)
  33645. if !ok {
  33646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33647. }
  33648. m.AddActiveUser(v)
  33649. return nil
  33650. case usagestatistichour.FieldNewUser:
  33651. v, ok := value.(int64)
  33652. if !ok {
  33653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33654. }
  33655. m.AddNewUser(v)
  33656. return nil
  33657. }
  33658. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33659. }
  33660. // ClearedFields returns all nullable fields that were cleared during this
  33661. // mutation.
  33662. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33663. var fields []string
  33664. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33665. fields = append(fields, usagestatistichour.FieldStatus)
  33666. }
  33667. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33668. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33669. }
  33670. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33671. fields = append(fields, usagestatistichour.FieldBotID)
  33672. }
  33673. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33674. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33675. }
  33676. return fields
  33677. }
  33678. // FieldCleared returns a boolean indicating if a field with the given name was
  33679. // cleared in this mutation.
  33680. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33681. _, ok := m.clearedFields[name]
  33682. return ok
  33683. }
  33684. // ClearField clears the value of the field with the given name. It returns an
  33685. // error if the field is not defined in the schema.
  33686. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33687. switch name {
  33688. case usagestatistichour.FieldStatus:
  33689. m.ClearStatus()
  33690. return nil
  33691. case usagestatistichour.FieldDeletedAt:
  33692. m.ClearDeletedAt()
  33693. return nil
  33694. case usagestatistichour.FieldBotID:
  33695. m.ClearBotID()
  33696. return nil
  33697. case usagestatistichour.FieldOrganizationID:
  33698. m.ClearOrganizationID()
  33699. return nil
  33700. }
  33701. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33702. }
  33703. // ResetField resets all changes in the mutation for the field with the given name.
  33704. // It returns an error if the field is not defined in the schema.
  33705. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33706. switch name {
  33707. case usagestatistichour.FieldCreatedAt:
  33708. m.ResetCreatedAt()
  33709. return nil
  33710. case usagestatistichour.FieldUpdatedAt:
  33711. m.ResetUpdatedAt()
  33712. return nil
  33713. case usagestatistichour.FieldStatus:
  33714. m.ResetStatus()
  33715. return nil
  33716. case usagestatistichour.FieldDeletedAt:
  33717. m.ResetDeletedAt()
  33718. return nil
  33719. case usagestatistichour.FieldAddtime:
  33720. m.ResetAddtime()
  33721. return nil
  33722. case usagestatistichour.FieldType:
  33723. m.ResetType()
  33724. return nil
  33725. case usagestatistichour.FieldBotID:
  33726. m.ResetBotID()
  33727. return nil
  33728. case usagestatistichour.FieldOrganizationID:
  33729. m.ResetOrganizationID()
  33730. return nil
  33731. case usagestatistichour.FieldAiResponse:
  33732. m.ResetAiResponse()
  33733. return nil
  33734. case usagestatistichour.FieldSopRun:
  33735. m.ResetSopRun()
  33736. return nil
  33737. case usagestatistichour.FieldTotalFriend:
  33738. m.ResetTotalFriend()
  33739. return nil
  33740. case usagestatistichour.FieldTotalGroup:
  33741. m.ResetTotalGroup()
  33742. return nil
  33743. case usagestatistichour.FieldAccountBalance:
  33744. m.ResetAccountBalance()
  33745. return nil
  33746. case usagestatistichour.FieldConsumeToken:
  33747. m.ResetConsumeToken()
  33748. return nil
  33749. case usagestatistichour.FieldActiveUser:
  33750. m.ResetActiveUser()
  33751. return nil
  33752. case usagestatistichour.FieldNewUser:
  33753. m.ResetNewUser()
  33754. return nil
  33755. case usagestatistichour.FieldLabelDist:
  33756. m.ResetLabelDist()
  33757. return nil
  33758. }
  33759. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33760. }
  33761. // AddedEdges returns all edge names that were set/added in this mutation.
  33762. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33763. edges := make([]string, 0, 0)
  33764. return edges
  33765. }
  33766. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33767. // name in this mutation.
  33768. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33769. return nil
  33770. }
  33771. // RemovedEdges returns all edge names that were removed in this mutation.
  33772. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33773. edges := make([]string, 0, 0)
  33774. return edges
  33775. }
  33776. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33777. // the given name in this mutation.
  33778. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33779. return nil
  33780. }
  33781. // ClearedEdges returns all edge names that were cleared in this mutation.
  33782. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33783. edges := make([]string, 0, 0)
  33784. return edges
  33785. }
  33786. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33787. // was cleared in this mutation.
  33788. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33789. return false
  33790. }
  33791. // ClearEdge clears the value of the edge with the given name. It returns an error
  33792. // if that edge is not defined in the schema.
  33793. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33794. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33795. }
  33796. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33797. // It returns an error if the edge is not defined in the schema.
  33798. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33799. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33800. }
  33801. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33802. type UsageStatisticMonthMutation struct {
  33803. config
  33804. op Op
  33805. typ string
  33806. id *uint64
  33807. created_at *time.Time
  33808. updated_at *time.Time
  33809. status *uint8
  33810. addstatus *int8
  33811. deleted_at *time.Time
  33812. addtime *uint64
  33813. addaddtime *int64
  33814. _type *int
  33815. add_type *int
  33816. bot_id *string
  33817. organization_id *uint64
  33818. addorganization_id *int64
  33819. ai_response *uint64
  33820. addai_response *int64
  33821. sop_run *uint64
  33822. addsop_run *int64
  33823. total_friend *uint64
  33824. addtotal_friend *int64
  33825. total_group *uint64
  33826. addtotal_group *int64
  33827. account_balance *uint64
  33828. addaccount_balance *int64
  33829. consume_token *uint64
  33830. addconsume_token *int64
  33831. active_user *uint64
  33832. addactive_user *int64
  33833. new_user *int64
  33834. addnew_user *int64
  33835. label_dist *[]custom_types.LabelDist
  33836. appendlabel_dist []custom_types.LabelDist
  33837. clearedFields map[string]struct{}
  33838. done bool
  33839. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33840. predicates []predicate.UsageStatisticMonth
  33841. }
  33842. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33843. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33844. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33845. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33846. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33847. m := &UsageStatisticMonthMutation{
  33848. config: c,
  33849. op: op,
  33850. typ: TypeUsageStatisticMonth,
  33851. clearedFields: make(map[string]struct{}),
  33852. }
  33853. for _, opt := range opts {
  33854. opt(m)
  33855. }
  33856. return m
  33857. }
  33858. // withUsageStatisticMonthID sets the ID field of the mutation.
  33859. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33860. return func(m *UsageStatisticMonthMutation) {
  33861. var (
  33862. err error
  33863. once sync.Once
  33864. value *UsageStatisticMonth
  33865. )
  33866. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33867. once.Do(func() {
  33868. if m.done {
  33869. err = errors.New("querying old values post mutation is not allowed")
  33870. } else {
  33871. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33872. }
  33873. })
  33874. return value, err
  33875. }
  33876. m.id = &id
  33877. }
  33878. }
  33879. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33880. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33881. return func(m *UsageStatisticMonthMutation) {
  33882. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33883. return node, nil
  33884. }
  33885. m.id = &node.ID
  33886. }
  33887. }
  33888. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33889. // executed in a transaction (ent.Tx), a transactional client is returned.
  33890. func (m UsageStatisticMonthMutation) Client() *Client {
  33891. client := &Client{config: m.config}
  33892. client.init()
  33893. return client
  33894. }
  33895. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33896. // it returns an error otherwise.
  33897. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33898. if _, ok := m.driver.(*txDriver); !ok {
  33899. return nil, errors.New("ent: mutation is not running in a transaction")
  33900. }
  33901. tx := &Tx{config: m.config}
  33902. tx.init()
  33903. return tx, nil
  33904. }
  33905. // SetID sets the value of the id field. Note that this
  33906. // operation is only accepted on creation of UsageStatisticMonth entities.
  33907. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33908. m.id = &id
  33909. }
  33910. // ID returns the ID value in the mutation. Note that the ID is only available
  33911. // if it was provided to the builder or after it was returned from the database.
  33912. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33913. if m.id == nil {
  33914. return
  33915. }
  33916. return *m.id, true
  33917. }
  33918. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33919. // That means, if the mutation is applied within a transaction with an isolation level such
  33920. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33921. // or updated by the mutation.
  33922. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33923. switch {
  33924. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33925. id, exists := m.ID()
  33926. if exists {
  33927. return []uint64{id}, nil
  33928. }
  33929. fallthrough
  33930. case m.op.Is(OpUpdate | OpDelete):
  33931. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33932. default:
  33933. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33934. }
  33935. }
  33936. // SetCreatedAt sets the "created_at" field.
  33937. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33938. m.created_at = &t
  33939. }
  33940. // CreatedAt returns the value of the "created_at" field in the mutation.
  33941. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33942. v := m.created_at
  33943. if v == nil {
  33944. return
  33945. }
  33946. return *v, true
  33947. }
  33948. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33949. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33951. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33952. if !m.op.Is(OpUpdateOne) {
  33953. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33954. }
  33955. if m.id == nil || m.oldValue == nil {
  33956. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33957. }
  33958. oldValue, err := m.oldValue(ctx)
  33959. if err != nil {
  33960. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33961. }
  33962. return oldValue.CreatedAt, nil
  33963. }
  33964. // ResetCreatedAt resets all changes to the "created_at" field.
  33965. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33966. m.created_at = nil
  33967. }
  33968. // SetUpdatedAt sets the "updated_at" field.
  33969. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33970. m.updated_at = &t
  33971. }
  33972. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33973. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33974. v := m.updated_at
  33975. if v == nil {
  33976. return
  33977. }
  33978. return *v, true
  33979. }
  33980. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33981. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33983. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33984. if !m.op.Is(OpUpdateOne) {
  33985. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33986. }
  33987. if m.id == nil || m.oldValue == nil {
  33988. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33989. }
  33990. oldValue, err := m.oldValue(ctx)
  33991. if err != nil {
  33992. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33993. }
  33994. return oldValue.UpdatedAt, nil
  33995. }
  33996. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33997. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33998. m.updated_at = nil
  33999. }
  34000. // SetStatus sets the "status" field.
  34001. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  34002. m.status = &u
  34003. m.addstatus = nil
  34004. }
  34005. // Status returns the value of the "status" field in the mutation.
  34006. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  34007. v := m.status
  34008. if v == nil {
  34009. return
  34010. }
  34011. return *v, true
  34012. }
  34013. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  34014. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34016. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34017. if !m.op.Is(OpUpdateOne) {
  34018. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34019. }
  34020. if m.id == nil || m.oldValue == nil {
  34021. return v, errors.New("OldStatus requires an ID field in the mutation")
  34022. }
  34023. oldValue, err := m.oldValue(ctx)
  34024. if err != nil {
  34025. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34026. }
  34027. return oldValue.Status, nil
  34028. }
  34029. // AddStatus adds u to the "status" field.
  34030. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  34031. if m.addstatus != nil {
  34032. *m.addstatus += u
  34033. } else {
  34034. m.addstatus = &u
  34035. }
  34036. }
  34037. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34038. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  34039. v := m.addstatus
  34040. if v == nil {
  34041. return
  34042. }
  34043. return *v, true
  34044. }
  34045. // ClearStatus clears the value of the "status" field.
  34046. func (m *UsageStatisticMonthMutation) ClearStatus() {
  34047. m.status = nil
  34048. m.addstatus = nil
  34049. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  34050. }
  34051. // StatusCleared returns if the "status" field was cleared in this mutation.
  34052. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  34053. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  34054. return ok
  34055. }
  34056. // ResetStatus resets all changes to the "status" field.
  34057. func (m *UsageStatisticMonthMutation) ResetStatus() {
  34058. m.status = nil
  34059. m.addstatus = nil
  34060. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  34061. }
  34062. // SetDeletedAt sets the "deleted_at" field.
  34063. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  34064. m.deleted_at = &t
  34065. }
  34066. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34067. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  34068. v := m.deleted_at
  34069. if v == nil {
  34070. return
  34071. }
  34072. return *v, true
  34073. }
  34074. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  34075. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34077. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34078. if !m.op.Is(OpUpdateOne) {
  34079. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34080. }
  34081. if m.id == nil || m.oldValue == nil {
  34082. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34083. }
  34084. oldValue, err := m.oldValue(ctx)
  34085. if err != nil {
  34086. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34087. }
  34088. return oldValue.DeletedAt, nil
  34089. }
  34090. // ClearDeletedAt clears the value of the "deleted_at" field.
  34091. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  34092. m.deleted_at = nil
  34093. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  34094. }
  34095. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34096. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  34097. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  34098. return ok
  34099. }
  34100. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34101. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  34102. m.deleted_at = nil
  34103. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  34104. }
  34105. // SetAddtime sets the "addtime" field.
  34106. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  34107. m.addtime = &u
  34108. m.addaddtime = nil
  34109. }
  34110. // Addtime returns the value of the "addtime" field in the mutation.
  34111. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  34112. v := m.addtime
  34113. if v == nil {
  34114. return
  34115. }
  34116. return *v, true
  34117. }
  34118. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  34119. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34121. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34122. if !m.op.Is(OpUpdateOne) {
  34123. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34124. }
  34125. if m.id == nil || m.oldValue == nil {
  34126. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34127. }
  34128. oldValue, err := m.oldValue(ctx)
  34129. if err != nil {
  34130. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34131. }
  34132. return oldValue.Addtime, nil
  34133. }
  34134. // AddAddtime adds u to the "addtime" field.
  34135. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  34136. if m.addaddtime != nil {
  34137. *m.addaddtime += u
  34138. } else {
  34139. m.addaddtime = &u
  34140. }
  34141. }
  34142. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34143. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  34144. v := m.addaddtime
  34145. if v == nil {
  34146. return
  34147. }
  34148. return *v, true
  34149. }
  34150. // ResetAddtime resets all changes to the "addtime" field.
  34151. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  34152. m.addtime = nil
  34153. m.addaddtime = nil
  34154. }
  34155. // SetType sets the "type" field.
  34156. func (m *UsageStatisticMonthMutation) SetType(i int) {
  34157. m._type = &i
  34158. m.add_type = nil
  34159. }
  34160. // GetType returns the value of the "type" field in the mutation.
  34161. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  34162. v := m._type
  34163. if v == nil {
  34164. return
  34165. }
  34166. return *v, true
  34167. }
  34168. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  34169. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34171. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  34172. if !m.op.Is(OpUpdateOne) {
  34173. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34174. }
  34175. if m.id == nil || m.oldValue == nil {
  34176. return v, errors.New("OldType requires an ID field in the mutation")
  34177. }
  34178. oldValue, err := m.oldValue(ctx)
  34179. if err != nil {
  34180. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34181. }
  34182. return oldValue.Type, nil
  34183. }
  34184. // AddType adds i to the "type" field.
  34185. func (m *UsageStatisticMonthMutation) AddType(i int) {
  34186. if m.add_type != nil {
  34187. *m.add_type += i
  34188. } else {
  34189. m.add_type = &i
  34190. }
  34191. }
  34192. // AddedType returns the value that was added to the "type" field in this mutation.
  34193. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  34194. v := m.add_type
  34195. if v == nil {
  34196. return
  34197. }
  34198. return *v, true
  34199. }
  34200. // ResetType resets all changes to the "type" field.
  34201. func (m *UsageStatisticMonthMutation) ResetType() {
  34202. m._type = nil
  34203. m.add_type = nil
  34204. }
  34205. // SetBotID sets the "bot_id" field.
  34206. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  34207. m.bot_id = &s
  34208. }
  34209. // BotID returns the value of the "bot_id" field in the mutation.
  34210. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  34211. v := m.bot_id
  34212. if v == nil {
  34213. return
  34214. }
  34215. return *v, true
  34216. }
  34217. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  34218. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34220. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  34221. if !m.op.Is(OpUpdateOne) {
  34222. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34223. }
  34224. if m.id == nil || m.oldValue == nil {
  34225. return v, errors.New("OldBotID requires an ID field in the mutation")
  34226. }
  34227. oldValue, err := m.oldValue(ctx)
  34228. if err != nil {
  34229. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34230. }
  34231. return oldValue.BotID, nil
  34232. }
  34233. // ClearBotID clears the value of the "bot_id" field.
  34234. func (m *UsageStatisticMonthMutation) ClearBotID() {
  34235. m.bot_id = nil
  34236. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  34237. }
  34238. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34239. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  34240. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  34241. return ok
  34242. }
  34243. // ResetBotID resets all changes to the "bot_id" field.
  34244. func (m *UsageStatisticMonthMutation) ResetBotID() {
  34245. m.bot_id = nil
  34246. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  34247. }
  34248. // SetOrganizationID sets the "organization_id" field.
  34249. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  34250. m.organization_id = &u
  34251. m.addorganization_id = nil
  34252. }
  34253. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34254. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  34255. v := m.organization_id
  34256. if v == nil {
  34257. return
  34258. }
  34259. return *v, true
  34260. }
  34261. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  34262. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34264. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34265. if !m.op.Is(OpUpdateOne) {
  34266. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34267. }
  34268. if m.id == nil || m.oldValue == nil {
  34269. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34270. }
  34271. oldValue, err := m.oldValue(ctx)
  34272. if err != nil {
  34273. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34274. }
  34275. return oldValue.OrganizationID, nil
  34276. }
  34277. // AddOrganizationID adds u to the "organization_id" field.
  34278. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  34279. if m.addorganization_id != nil {
  34280. *m.addorganization_id += u
  34281. } else {
  34282. m.addorganization_id = &u
  34283. }
  34284. }
  34285. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34286. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  34287. v := m.addorganization_id
  34288. if v == nil {
  34289. return
  34290. }
  34291. return *v, true
  34292. }
  34293. // ClearOrganizationID clears the value of the "organization_id" field.
  34294. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  34295. m.organization_id = nil
  34296. m.addorganization_id = nil
  34297. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  34298. }
  34299. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34300. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  34301. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  34302. return ok
  34303. }
  34304. // ResetOrganizationID resets all changes to the "organization_id" field.
  34305. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  34306. m.organization_id = nil
  34307. m.addorganization_id = nil
  34308. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  34309. }
  34310. // SetAiResponse sets the "ai_response" field.
  34311. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  34312. m.ai_response = &u
  34313. m.addai_response = nil
  34314. }
  34315. // AiResponse returns the value of the "ai_response" field in the mutation.
  34316. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  34317. v := m.ai_response
  34318. if v == nil {
  34319. return
  34320. }
  34321. return *v, true
  34322. }
  34323. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  34324. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34326. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34327. if !m.op.Is(OpUpdateOne) {
  34328. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34329. }
  34330. if m.id == nil || m.oldValue == nil {
  34331. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34332. }
  34333. oldValue, err := m.oldValue(ctx)
  34334. if err != nil {
  34335. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34336. }
  34337. return oldValue.AiResponse, nil
  34338. }
  34339. // AddAiResponse adds u to the "ai_response" field.
  34340. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  34341. if m.addai_response != nil {
  34342. *m.addai_response += u
  34343. } else {
  34344. m.addai_response = &u
  34345. }
  34346. }
  34347. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34348. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  34349. v := m.addai_response
  34350. if v == nil {
  34351. return
  34352. }
  34353. return *v, true
  34354. }
  34355. // ResetAiResponse resets all changes to the "ai_response" field.
  34356. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  34357. m.ai_response = nil
  34358. m.addai_response = nil
  34359. }
  34360. // SetSopRun sets the "sop_run" field.
  34361. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  34362. m.sop_run = &u
  34363. m.addsop_run = nil
  34364. }
  34365. // SopRun returns the value of the "sop_run" field in the mutation.
  34366. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34367. v := m.sop_run
  34368. if v == nil {
  34369. return
  34370. }
  34371. return *v, true
  34372. }
  34373. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34374. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34376. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34377. if !m.op.Is(OpUpdateOne) {
  34378. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34379. }
  34380. if m.id == nil || m.oldValue == nil {
  34381. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34382. }
  34383. oldValue, err := m.oldValue(ctx)
  34384. if err != nil {
  34385. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34386. }
  34387. return oldValue.SopRun, nil
  34388. }
  34389. // AddSopRun adds u to the "sop_run" field.
  34390. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34391. if m.addsop_run != nil {
  34392. *m.addsop_run += u
  34393. } else {
  34394. m.addsop_run = &u
  34395. }
  34396. }
  34397. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34398. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34399. v := m.addsop_run
  34400. if v == nil {
  34401. return
  34402. }
  34403. return *v, true
  34404. }
  34405. // ResetSopRun resets all changes to the "sop_run" field.
  34406. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34407. m.sop_run = nil
  34408. m.addsop_run = nil
  34409. }
  34410. // SetTotalFriend sets the "total_friend" field.
  34411. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34412. m.total_friend = &u
  34413. m.addtotal_friend = nil
  34414. }
  34415. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34416. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34417. v := m.total_friend
  34418. if v == nil {
  34419. return
  34420. }
  34421. return *v, true
  34422. }
  34423. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34424. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34426. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34427. if !m.op.Is(OpUpdateOne) {
  34428. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34429. }
  34430. if m.id == nil || m.oldValue == nil {
  34431. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34432. }
  34433. oldValue, err := m.oldValue(ctx)
  34434. if err != nil {
  34435. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34436. }
  34437. return oldValue.TotalFriend, nil
  34438. }
  34439. // AddTotalFriend adds u to the "total_friend" field.
  34440. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34441. if m.addtotal_friend != nil {
  34442. *m.addtotal_friend += u
  34443. } else {
  34444. m.addtotal_friend = &u
  34445. }
  34446. }
  34447. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34448. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34449. v := m.addtotal_friend
  34450. if v == nil {
  34451. return
  34452. }
  34453. return *v, true
  34454. }
  34455. // ResetTotalFriend resets all changes to the "total_friend" field.
  34456. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34457. m.total_friend = nil
  34458. m.addtotal_friend = nil
  34459. }
  34460. // SetTotalGroup sets the "total_group" field.
  34461. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34462. m.total_group = &u
  34463. m.addtotal_group = nil
  34464. }
  34465. // TotalGroup returns the value of the "total_group" field in the mutation.
  34466. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34467. v := m.total_group
  34468. if v == nil {
  34469. return
  34470. }
  34471. return *v, true
  34472. }
  34473. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34474. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34476. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34477. if !m.op.Is(OpUpdateOne) {
  34478. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34479. }
  34480. if m.id == nil || m.oldValue == nil {
  34481. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34482. }
  34483. oldValue, err := m.oldValue(ctx)
  34484. if err != nil {
  34485. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34486. }
  34487. return oldValue.TotalGroup, nil
  34488. }
  34489. // AddTotalGroup adds u to the "total_group" field.
  34490. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34491. if m.addtotal_group != nil {
  34492. *m.addtotal_group += u
  34493. } else {
  34494. m.addtotal_group = &u
  34495. }
  34496. }
  34497. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34498. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34499. v := m.addtotal_group
  34500. if v == nil {
  34501. return
  34502. }
  34503. return *v, true
  34504. }
  34505. // ResetTotalGroup resets all changes to the "total_group" field.
  34506. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34507. m.total_group = nil
  34508. m.addtotal_group = nil
  34509. }
  34510. // SetAccountBalance sets the "account_balance" field.
  34511. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34512. m.account_balance = &u
  34513. m.addaccount_balance = nil
  34514. }
  34515. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34516. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34517. v := m.account_balance
  34518. if v == nil {
  34519. return
  34520. }
  34521. return *v, true
  34522. }
  34523. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34524. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34526. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34527. if !m.op.Is(OpUpdateOne) {
  34528. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34529. }
  34530. if m.id == nil || m.oldValue == nil {
  34531. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34532. }
  34533. oldValue, err := m.oldValue(ctx)
  34534. if err != nil {
  34535. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34536. }
  34537. return oldValue.AccountBalance, nil
  34538. }
  34539. // AddAccountBalance adds u to the "account_balance" field.
  34540. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34541. if m.addaccount_balance != nil {
  34542. *m.addaccount_balance += u
  34543. } else {
  34544. m.addaccount_balance = &u
  34545. }
  34546. }
  34547. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34548. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34549. v := m.addaccount_balance
  34550. if v == nil {
  34551. return
  34552. }
  34553. return *v, true
  34554. }
  34555. // ResetAccountBalance resets all changes to the "account_balance" field.
  34556. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34557. m.account_balance = nil
  34558. m.addaccount_balance = nil
  34559. }
  34560. // SetConsumeToken sets the "consume_token" field.
  34561. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34562. m.consume_token = &u
  34563. m.addconsume_token = nil
  34564. }
  34565. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34566. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34567. v := m.consume_token
  34568. if v == nil {
  34569. return
  34570. }
  34571. return *v, true
  34572. }
  34573. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34574. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34576. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34577. if !m.op.Is(OpUpdateOne) {
  34578. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34579. }
  34580. if m.id == nil || m.oldValue == nil {
  34581. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34582. }
  34583. oldValue, err := m.oldValue(ctx)
  34584. if err != nil {
  34585. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34586. }
  34587. return oldValue.ConsumeToken, nil
  34588. }
  34589. // AddConsumeToken adds u to the "consume_token" field.
  34590. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34591. if m.addconsume_token != nil {
  34592. *m.addconsume_token += u
  34593. } else {
  34594. m.addconsume_token = &u
  34595. }
  34596. }
  34597. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34598. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34599. v := m.addconsume_token
  34600. if v == nil {
  34601. return
  34602. }
  34603. return *v, true
  34604. }
  34605. // ResetConsumeToken resets all changes to the "consume_token" field.
  34606. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34607. m.consume_token = nil
  34608. m.addconsume_token = nil
  34609. }
  34610. // SetActiveUser sets the "active_user" field.
  34611. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34612. m.active_user = &u
  34613. m.addactive_user = nil
  34614. }
  34615. // ActiveUser returns the value of the "active_user" field in the mutation.
  34616. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34617. v := m.active_user
  34618. if v == nil {
  34619. return
  34620. }
  34621. return *v, true
  34622. }
  34623. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34624. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34626. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34627. if !m.op.Is(OpUpdateOne) {
  34628. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34629. }
  34630. if m.id == nil || m.oldValue == nil {
  34631. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34632. }
  34633. oldValue, err := m.oldValue(ctx)
  34634. if err != nil {
  34635. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34636. }
  34637. return oldValue.ActiveUser, nil
  34638. }
  34639. // AddActiveUser adds u to the "active_user" field.
  34640. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34641. if m.addactive_user != nil {
  34642. *m.addactive_user += u
  34643. } else {
  34644. m.addactive_user = &u
  34645. }
  34646. }
  34647. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34648. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34649. v := m.addactive_user
  34650. if v == nil {
  34651. return
  34652. }
  34653. return *v, true
  34654. }
  34655. // ResetActiveUser resets all changes to the "active_user" field.
  34656. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34657. m.active_user = nil
  34658. m.addactive_user = nil
  34659. }
  34660. // SetNewUser sets the "new_user" field.
  34661. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34662. m.new_user = &i
  34663. m.addnew_user = nil
  34664. }
  34665. // NewUser returns the value of the "new_user" field in the mutation.
  34666. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34667. v := m.new_user
  34668. if v == nil {
  34669. return
  34670. }
  34671. return *v, true
  34672. }
  34673. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34674. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34676. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34677. if !m.op.Is(OpUpdateOne) {
  34678. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34679. }
  34680. if m.id == nil || m.oldValue == nil {
  34681. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34682. }
  34683. oldValue, err := m.oldValue(ctx)
  34684. if err != nil {
  34685. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34686. }
  34687. return oldValue.NewUser, nil
  34688. }
  34689. // AddNewUser adds i to the "new_user" field.
  34690. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34691. if m.addnew_user != nil {
  34692. *m.addnew_user += i
  34693. } else {
  34694. m.addnew_user = &i
  34695. }
  34696. }
  34697. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34698. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34699. v := m.addnew_user
  34700. if v == nil {
  34701. return
  34702. }
  34703. return *v, true
  34704. }
  34705. // ResetNewUser resets all changes to the "new_user" field.
  34706. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34707. m.new_user = nil
  34708. m.addnew_user = nil
  34709. }
  34710. // SetLabelDist sets the "label_dist" field.
  34711. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34712. m.label_dist = &ctd
  34713. m.appendlabel_dist = nil
  34714. }
  34715. // LabelDist returns the value of the "label_dist" field in the mutation.
  34716. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34717. v := m.label_dist
  34718. if v == nil {
  34719. return
  34720. }
  34721. return *v, true
  34722. }
  34723. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34724. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34726. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34727. if !m.op.Is(OpUpdateOne) {
  34728. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34729. }
  34730. if m.id == nil || m.oldValue == nil {
  34731. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34732. }
  34733. oldValue, err := m.oldValue(ctx)
  34734. if err != nil {
  34735. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34736. }
  34737. return oldValue.LabelDist, nil
  34738. }
  34739. // AppendLabelDist adds ctd to the "label_dist" field.
  34740. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34741. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34742. }
  34743. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34744. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34745. if len(m.appendlabel_dist) == 0 {
  34746. return nil, false
  34747. }
  34748. return m.appendlabel_dist, true
  34749. }
  34750. // ResetLabelDist resets all changes to the "label_dist" field.
  34751. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34752. m.label_dist = nil
  34753. m.appendlabel_dist = nil
  34754. }
  34755. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34756. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34757. m.predicates = append(m.predicates, ps...)
  34758. }
  34759. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34760. // users can use type-assertion to append predicates that do not depend on any generated package.
  34761. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34762. p := make([]predicate.UsageStatisticMonth, len(ps))
  34763. for i := range ps {
  34764. p[i] = ps[i]
  34765. }
  34766. m.Where(p...)
  34767. }
  34768. // Op returns the operation name.
  34769. func (m *UsageStatisticMonthMutation) Op() Op {
  34770. return m.op
  34771. }
  34772. // SetOp allows setting the mutation operation.
  34773. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34774. m.op = op
  34775. }
  34776. // Type returns the node type of this mutation (UsageStatisticMonth).
  34777. func (m *UsageStatisticMonthMutation) Type() string {
  34778. return m.typ
  34779. }
  34780. // Fields returns all fields that were changed during this mutation. Note that in
  34781. // order to get all numeric fields that were incremented/decremented, call
  34782. // AddedFields().
  34783. func (m *UsageStatisticMonthMutation) Fields() []string {
  34784. fields := make([]string, 0, 17)
  34785. if m.created_at != nil {
  34786. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34787. }
  34788. if m.updated_at != nil {
  34789. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34790. }
  34791. if m.status != nil {
  34792. fields = append(fields, usagestatisticmonth.FieldStatus)
  34793. }
  34794. if m.deleted_at != nil {
  34795. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34796. }
  34797. if m.addtime != nil {
  34798. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34799. }
  34800. if m._type != nil {
  34801. fields = append(fields, usagestatisticmonth.FieldType)
  34802. }
  34803. if m.bot_id != nil {
  34804. fields = append(fields, usagestatisticmonth.FieldBotID)
  34805. }
  34806. if m.organization_id != nil {
  34807. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34808. }
  34809. if m.ai_response != nil {
  34810. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34811. }
  34812. if m.sop_run != nil {
  34813. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34814. }
  34815. if m.total_friend != nil {
  34816. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34817. }
  34818. if m.total_group != nil {
  34819. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34820. }
  34821. if m.account_balance != nil {
  34822. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34823. }
  34824. if m.consume_token != nil {
  34825. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34826. }
  34827. if m.active_user != nil {
  34828. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34829. }
  34830. if m.new_user != nil {
  34831. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34832. }
  34833. if m.label_dist != nil {
  34834. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34835. }
  34836. return fields
  34837. }
  34838. // Field returns the value of a field with the given name. The second boolean
  34839. // return value indicates that this field was not set, or was not defined in the
  34840. // schema.
  34841. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34842. switch name {
  34843. case usagestatisticmonth.FieldCreatedAt:
  34844. return m.CreatedAt()
  34845. case usagestatisticmonth.FieldUpdatedAt:
  34846. return m.UpdatedAt()
  34847. case usagestatisticmonth.FieldStatus:
  34848. return m.Status()
  34849. case usagestatisticmonth.FieldDeletedAt:
  34850. return m.DeletedAt()
  34851. case usagestatisticmonth.FieldAddtime:
  34852. return m.Addtime()
  34853. case usagestatisticmonth.FieldType:
  34854. return m.GetType()
  34855. case usagestatisticmonth.FieldBotID:
  34856. return m.BotID()
  34857. case usagestatisticmonth.FieldOrganizationID:
  34858. return m.OrganizationID()
  34859. case usagestatisticmonth.FieldAiResponse:
  34860. return m.AiResponse()
  34861. case usagestatisticmonth.FieldSopRun:
  34862. return m.SopRun()
  34863. case usagestatisticmonth.FieldTotalFriend:
  34864. return m.TotalFriend()
  34865. case usagestatisticmonth.FieldTotalGroup:
  34866. return m.TotalGroup()
  34867. case usagestatisticmonth.FieldAccountBalance:
  34868. return m.AccountBalance()
  34869. case usagestatisticmonth.FieldConsumeToken:
  34870. return m.ConsumeToken()
  34871. case usagestatisticmonth.FieldActiveUser:
  34872. return m.ActiveUser()
  34873. case usagestatisticmonth.FieldNewUser:
  34874. return m.NewUser()
  34875. case usagestatisticmonth.FieldLabelDist:
  34876. return m.LabelDist()
  34877. }
  34878. return nil, false
  34879. }
  34880. // OldField returns the old value of the field from the database. An error is
  34881. // returned if the mutation operation is not UpdateOne, or the query to the
  34882. // database failed.
  34883. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34884. switch name {
  34885. case usagestatisticmonth.FieldCreatedAt:
  34886. return m.OldCreatedAt(ctx)
  34887. case usagestatisticmonth.FieldUpdatedAt:
  34888. return m.OldUpdatedAt(ctx)
  34889. case usagestatisticmonth.FieldStatus:
  34890. return m.OldStatus(ctx)
  34891. case usagestatisticmonth.FieldDeletedAt:
  34892. return m.OldDeletedAt(ctx)
  34893. case usagestatisticmonth.FieldAddtime:
  34894. return m.OldAddtime(ctx)
  34895. case usagestatisticmonth.FieldType:
  34896. return m.OldType(ctx)
  34897. case usagestatisticmonth.FieldBotID:
  34898. return m.OldBotID(ctx)
  34899. case usagestatisticmonth.FieldOrganizationID:
  34900. return m.OldOrganizationID(ctx)
  34901. case usagestatisticmonth.FieldAiResponse:
  34902. return m.OldAiResponse(ctx)
  34903. case usagestatisticmonth.FieldSopRun:
  34904. return m.OldSopRun(ctx)
  34905. case usagestatisticmonth.FieldTotalFriend:
  34906. return m.OldTotalFriend(ctx)
  34907. case usagestatisticmonth.FieldTotalGroup:
  34908. return m.OldTotalGroup(ctx)
  34909. case usagestatisticmonth.FieldAccountBalance:
  34910. return m.OldAccountBalance(ctx)
  34911. case usagestatisticmonth.FieldConsumeToken:
  34912. return m.OldConsumeToken(ctx)
  34913. case usagestatisticmonth.FieldActiveUser:
  34914. return m.OldActiveUser(ctx)
  34915. case usagestatisticmonth.FieldNewUser:
  34916. return m.OldNewUser(ctx)
  34917. case usagestatisticmonth.FieldLabelDist:
  34918. return m.OldLabelDist(ctx)
  34919. }
  34920. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34921. }
  34922. // SetField sets the value of a field with the given name. It returns an error if
  34923. // the field is not defined in the schema, or if the type mismatched the field
  34924. // type.
  34925. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34926. switch name {
  34927. case usagestatisticmonth.FieldCreatedAt:
  34928. v, ok := value.(time.Time)
  34929. if !ok {
  34930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34931. }
  34932. m.SetCreatedAt(v)
  34933. return nil
  34934. case usagestatisticmonth.FieldUpdatedAt:
  34935. v, ok := value.(time.Time)
  34936. if !ok {
  34937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34938. }
  34939. m.SetUpdatedAt(v)
  34940. return nil
  34941. case usagestatisticmonth.FieldStatus:
  34942. v, ok := value.(uint8)
  34943. if !ok {
  34944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34945. }
  34946. m.SetStatus(v)
  34947. return nil
  34948. case usagestatisticmonth.FieldDeletedAt:
  34949. v, ok := value.(time.Time)
  34950. if !ok {
  34951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34952. }
  34953. m.SetDeletedAt(v)
  34954. return nil
  34955. case usagestatisticmonth.FieldAddtime:
  34956. v, ok := value.(uint64)
  34957. if !ok {
  34958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34959. }
  34960. m.SetAddtime(v)
  34961. return nil
  34962. case usagestatisticmonth.FieldType:
  34963. v, ok := value.(int)
  34964. if !ok {
  34965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34966. }
  34967. m.SetType(v)
  34968. return nil
  34969. case usagestatisticmonth.FieldBotID:
  34970. v, ok := value.(string)
  34971. if !ok {
  34972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34973. }
  34974. m.SetBotID(v)
  34975. return nil
  34976. case usagestatisticmonth.FieldOrganizationID:
  34977. v, ok := value.(uint64)
  34978. if !ok {
  34979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34980. }
  34981. m.SetOrganizationID(v)
  34982. return nil
  34983. case usagestatisticmonth.FieldAiResponse:
  34984. v, ok := value.(uint64)
  34985. if !ok {
  34986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34987. }
  34988. m.SetAiResponse(v)
  34989. return nil
  34990. case usagestatisticmonth.FieldSopRun:
  34991. v, ok := value.(uint64)
  34992. if !ok {
  34993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34994. }
  34995. m.SetSopRun(v)
  34996. return nil
  34997. case usagestatisticmonth.FieldTotalFriend:
  34998. v, ok := value.(uint64)
  34999. if !ok {
  35000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35001. }
  35002. m.SetTotalFriend(v)
  35003. return nil
  35004. case usagestatisticmonth.FieldTotalGroup:
  35005. v, ok := value.(uint64)
  35006. if !ok {
  35007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35008. }
  35009. m.SetTotalGroup(v)
  35010. return nil
  35011. case usagestatisticmonth.FieldAccountBalance:
  35012. v, ok := value.(uint64)
  35013. if !ok {
  35014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35015. }
  35016. m.SetAccountBalance(v)
  35017. return nil
  35018. case usagestatisticmonth.FieldConsumeToken:
  35019. v, ok := value.(uint64)
  35020. if !ok {
  35021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35022. }
  35023. m.SetConsumeToken(v)
  35024. return nil
  35025. case usagestatisticmonth.FieldActiveUser:
  35026. v, ok := value.(uint64)
  35027. if !ok {
  35028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35029. }
  35030. m.SetActiveUser(v)
  35031. return nil
  35032. case usagestatisticmonth.FieldNewUser:
  35033. v, ok := value.(int64)
  35034. if !ok {
  35035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35036. }
  35037. m.SetNewUser(v)
  35038. return nil
  35039. case usagestatisticmonth.FieldLabelDist:
  35040. v, ok := value.([]custom_types.LabelDist)
  35041. if !ok {
  35042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35043. }
  35044. m.SetLabelDist(v)
  35045. return nil
  35046. }
  35047. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35048. }
  35049. // AddedFields returns all numeric fields that were incremented/decremented during
  35050. // this mutation.
  35051. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  35052. var fields []string
  35053. if m.addstatus != nil {
  35054. fields = append(fields, usagestatisticmonth.FieldStatus)
  35055. }
  35056. if m.addaddtime != nil {
  35057. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35058. }
  35059. if m.add_type != nil {
  35060. fields = append(fields, usagestatisticmonth.FieldType)
  35061. }
  35062. if m.addorganization_id != nil {
  35063. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35064. }
  35065. if m.addai_response != nil {
  35066. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35067. }
  35068. if m.addsop_run != nil {
  35069. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35070. }
  35071. if m.addtotal_friend != nil {
  35072. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35073. }
  35074. if m.addtotal_group != nil {
  35075. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35076. }
  35077. if m.addaccount_balance != nil {
  35078. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35079. }
  35080. if m.addconsume_token != nil {
  35081. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35082. }
  35083. if m.addactive_user != nil {
  35084. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35085. }
  35086. if m.addnew_user != nil {
  35087. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35088. }
  35089. return fields
  35090. }
  35091. // AddedField returns the numeric value that was incremented/decremented on a field
  35092. // with the given name. The second boolean return value indicates that this field
  35093. // was not set, or was not defined in the schema.
  35094. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  35095. switch name {
  35096. case usagestatisticmonth.FieldStatus:
  35097. return m.AddedStatus()
  35098. case usagestatisticmonth.FieldAddtime:
  35099. return m.AddedAddtime()
  35100. case usagestatisticmonth.FieldType:
  35101. return m.AddedType()
  35102. case usagestatisticmonth.FieldOrganizationID:
  35103. return m.AddedOrganizationID()
  35104. case usagestatisticmonth.FieldAiResponse:
  35105. return m.AddedAiResponse()
  35106. case usagestatisticmonth.FieldSopRun:
  35107. return m.AddedSopRun()
  35108. case usagestatisticmonth.FieldTotalFriend:
  35109. return m.AddedTotalFriend()
  35110. case usagestatisticmonth.FieldTotalGroup:
  35111. return m.AddedTotalGroup()
  35112. case usagestatisticmonth.FieldAccountBalance:
  35113. return m.AddedAccountBalance()
  35114. case usagestatisticmonth.FieldConsumeToken:
  35115. return m.AddedConsumeToken()
  35116. case usagestatisticmonth.FieldActiveUser:
  35117. return m.AddedActiveUser()
  35118. case usagestatisticmonth.FieldNewUser:
  35119. return m.AddedNewUser()
  35120. }
  35121. return nil, false
  35122. }
  35123. // AddField adds the value to the field with the given name. It returns an error if
  35124. // the field is not defined in the schema, or if the type mismatched the field
  35125. // type.
  35126. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  35127. switch name {
  35128. case usagestatisticmonth.FieldStatus:
  35129. v, ok := value.(int8)
  35130. if !ok {
  35131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35132. }
  35133. m.AddStatus(v)
  35134. return nil
  35135. case usagestatisticmonth.FieldAddtime:
  35136. v, ok := value.(int64)
  35137. if !ok {
  35138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35139. }
  35140. m.AddAddtime(v)
  35141. return nil
  35142. case usagestatisticmonth.FieldType:
  35143. v, ok := value.(int)
  35144. if !ok {
  35145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35146. }
  35147. m.AddType(v)
  35148. return nil
  35149. case usagestatisticmonth.FieldOrganizationID:
  35150. v, ok := value.(int64)
  35151. if !ok {
  35152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35153. }
  35154. m.AddOrganizationID(v)
  35155. return nil
  35156. case usagestatisticmonth.FieldAiResponse:
  35157. v, ok := value.(int64)
  35158. if !ok {
  35159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35160. }
  35161. m.AddAiResponse(v)
  35162. return nil
  35163. case usagestatisticmonth.FieldSopRun:
  35164. v, ok := value.(int64)
  35165. if !ok {
  35166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35167. }
  35168. m.AddSopRun(v)
  35169. return nil
  35170. case usagestatisticmonth.FieldTotalFriend:
  35171. v, ok := value.(int64)
  35172. if !ok {
  35173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35174. }
  35175. m.AddTotalFriend(v)
  35176. return nil
  35177. case usagestatisticmonth.FieldTotalGroup:
  35178. v, ok := value.(int64)
  35179. if !ok {
  35180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35181. }
  35182. m.AddTotalGroup(v)
  35183. return nil
  35184. case usagestatisticmonth.FieldAccountBalance:
  35185. v, ok := value.(int64)
  35186. if !ok {
  35187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35188. }
  35189. m.AddAccountBalance(v)
  35190. return nil
  35191. case usagestatisticmonth.FieldConsumeToken:
  35192. v, ok := value.(int64)
  35193. if !ok {
  35194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35195. }
  35196. m.AddConsumeToken(v)
  35197. return nil
  35198. case usagestatisticmonth.FieldActiveUser:
  35199. v, ok := value.(int64)
  35200. if !ok {
  35201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35202. }
  35203. m.AddActiveUser(v)
  35204. return nil
  35205. case usagestatisticmonth.FieldNewUser:
  35206. v, ok := value.(int64)
  35207. if !ok {
  35208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35209. }
  35210. m.AddNewUser(v)
  35211. return nil
  35212. }
  35213. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  35214. }
  35215. // ClearedFields returns all nullable fields that were cleared during this
  35216. // mutation.
  35217. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  35218. var fields []string
  35219. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  35220. fields = append(fields, usagestatisticmonth.FieldStatus)
  35221. }
  35222. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  35223. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35224. }
  35225. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  35226. fields = append(fields, usagestatisticmonth.FieldBotID)
  35227. }
  35228. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  35229. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35230. }
  35231. return fields
  35232. }
  35233. // FieldCleared returns a boolean indicating if a field with the given name was
  35234. // cleared in this mutation.
  35235. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  35236. _, ok := m.clearedFields[name]
  35237. return ok
  35238. }
  35239. // ClearField clears the value of the field with the given name. It returns an
  35240. // error if the field is not defined in the schema.
  35241. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  35242. switch name {
  35243. case usagestatisticmonth.FieldStatus:
  35244. m.ClearStatus()
  35245. return nil
  35246. case usagestatisticmonth.FieldDeletedAt:
  35247. m.ClearDeletedAt()
  35248. return nil
  35249. case usagestatisticmonth.FieldBotID:
  35250. m.ClearBotID()
  35251. return nil
  35252. case usagestatisticmonth.FieldOrganizationID:
  35253. m.ClearOrganizationID()
  35254. return nil
  35255. }
  35256. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  35257. }
  35258. // ResetField resets all changes in the mutation for the field with the given name.
  35259. // It returns an error if the field is not defined in the schema.
  35260. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  35261. switch name {
  35262. case usagestatisticmonth.FieldCreatedAt:
  35263. m.ResetCreatedAt()
  35264. return nil
  35265. case usagestatisticmonth.FieldUpdatedAt:
  35266. m.ResetUpdatedAt()
  35267. return nil
  35268. case usagestatisticmonth.FieldStatus:
  35269. m.ResetStatus()
  35270. return nil
  35271. case usagestatisticmonth.FieldDeletedAt:
  35272. m.ResetDeletedAt()
  35273. return nil
  35274. case usagestatisticmonth.FieldAddtime:
  35275. m.ResetAddtime()
  35276. return nil
  35277. case usagestatisticmonth.FieldType:
  35278. m.ResetType()
  35279. return nil
  35280. case usagestatisticmonth.FieldBotID:
  35281. m.ResetBotID()
  35282. return nil
  35283. case usagestatisticmonth.FieldOrganizationID:
  35284. m.ResetOrganizationID()
  35285. return nil
  35286. case usagestatisticmonth.FieldAiResponse:
  35287. m.ResetAiResponse()
  35288. return nil
  35289. case usagestatisticmonth.FieldSopRun:
  35290. m.ResetSopRun()
  35291. return nil
  35292. case usagestatisticmonth.FieldTotalFriend:
  35293. m.ResetTotalFriend()
  35294. return nil
  35295. case usagestatisticmonth.FieldTotalGroup:
  35296. m.ResetTotalGroup()
  35297. return nil
  35298. case usagestatisticmonth.FieldAccountBalance:
  35299. m.ResetAccountBalance()
  35300. return nil
  35301. case usagestatisticmonth.FieldConsumeToken:
  35302. m.ResetConsumeToken()
  35303. return nil
  35304. case usagestatisticmonth.FieldActiveUser:
  35305. m.ResetActiveUser()
  35306. return nil
  35307. case usagestatisticmonth.FieldNewUser:
  35308. m.ResetNewUser()
  35309. return nil
  35310. case usagestatisticmonth.FieldLabelDist:
  35311. m.ResetLabelDist()
  35312. return nil
  35313. }
  35314. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35315. }
  35316. // AddedEdges returns all edge names that were set/added in this mutation.
  35317. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  35318. edges := make([]string, 0, 0)
  35319. return edges
  35320. }
  35321. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35322. // name in this mutation.
  35323. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  35324. return nil
  35325. }
  35326. // RemovedEdges returns all edge names that were removed in this mutation.
  35327. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  35328. edges := make([]string, 0, 0)
  35329. return edges
  35330. }
  35331. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35332. // the given name in this mutation.
  35333. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  35334. return nil
  35335. }
  35336. // ClearedEdges returns all edge names that were cleared in this mutation.
  35337. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  35338. edges := make([]string, 0, 0)
  35339. return edges
  35340. }
  35341. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35342. // was cleared in this mutation.
  35343. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  35344. return false
  35345. }
  35346. // ClearEdge clears the value of the edge with the given name. It returns an error
  35347. // if that edge is not defined in the schema.
  35348. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  35349. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  35350. }
  35351. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35352. // It returns an error if the edge is not defined in the schema.
  35353. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  35354. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  35355. }
  35356. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  35357. type UsageTotalMutation struct {
  35358. config
  35359. op Op
  35360. typ string
  35361. id *uint64
  35362. created_at *time.Time
  35363. updated_at *time.Time
  35364. status *uint8
  35365. addstatus *int8
  35366. _type *int
  35367. add_type *int
  35368. bot_id *string
  35369. total_tokens *uint64
  35370. addtotal_tokens *int64
  35371. start_index *uint64
  35372. addstart_index *int64
  35373. end_index *uint64
  35374. addend_index *int64
  35375. organization_id *uint64
  35376. addorganization_id *int64
  35377. clearedFields map[string]struct{}
  35378. done bool
  35379. oldValue func(context.Context) (*UsageTotal, error)
  35380. predicates []predicate.UsageTotal
  35381. }
  35382. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35383. // usagetotalOption allows management of the mutation configuration using functional options.
  35384. type usagetotalOption func(*UsageTotalMutation)
  35385. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35386. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35387. m := &UsageTotalMutation{
  35388. config: c,
  35389. op: op,
  35390. typ: TypeUsageTotal,
  35391. clearedFields: make(map[string]struct{}),
  35392. }
  35393. for _, opt := range opts {
  35394. opt(m)
  35395. }
  35396. return m
  35397. }
  35398. // withUsageTotalID sets the ID field of the mutation.
  35399. func withUsageTotalID(id uint64) usagetotalOption {
  35400. return func(m *UsageTotalMutation) {
  35401. var (
  35402. err error
  35403. once sync.Once
  35404. value *UsageTotal
  35405. )
  35406. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35407. once.Do(func() {
  35408. if m.done {
  35409. err = errors.New("querying old values post mutation is not allowed")
  35410. } else {
  35411. value, err = m.Client().UsageTotal.Get(ctx, id)
  35412. }
  35413. })
  35414. return value, err
  35415. }
  35416. m.id = &id
  35417. }
  35418. }
  35419. // withUsageTotal sets the old UsageTotal of the mutation.
  35420. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35421. return func(m *UsageTotalMutation) {
  35422. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35423. return node, nil
  35424. }
  35425. m.id = &node.ID
  35426. }
  35427. }
  35428. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35429. // executed in a transaction (ent.Tx), a transactional client is returned.
  35430. func (m UsageTotalMutation) Client() *Client {
  35431. client := &Client{config: m.config}
  35432. client.init()
  35433. return client
  35434. }
  35435. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35436. // it returns an error otherwise.
  35437. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35438. if _, ok := m.driver.(*txDriver); !ok {
  35439. return nil, errors.New("ent: mutation is not running in a transaction")
  35440. }
  35441. tx := &Tx{config: m.config}
  35442. tx.init()
  35443. return tx, nil
  35444. }
  35445. // SetID sets the value of the id field. Note that this
  35446. // operation is only accepted on creation of UsageTotal entities.
  35447. func (m *UsageTotalMutation) SetID(id uint64) {
  35448. m.id = &id
  35449. }
  35450. // ID returns the ID value in the mutation. Note that the ID is only available
  35451. // if it was provided to the builder or after it was returned from the database.
  35452. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35453. if m.id == nil {
  35454. return
  35455. }
  35456. return *m.id, true
  35457. }
  35458. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35459. // That means, if the mutation is applied within a transaction with an isolation level such
  35460. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35461. // or updated by the mutation.
  35462. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35463. switch {
  35464. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35465. id, exists := m.ID()
  35466. if exists {
  35467. return []uint64{id}, nil
  35468. }
  35469. fallthrough
  35470. case m.op.Is(OpUpdate | OpDelete):
  35471. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35472. default:
  35473. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35474. }
  35475. }
  35476. // SetCreatedAt sets the "created_at" field.
  35477. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35478. m.created_at = &t
  35479. }
  35480. // CreatedAt returns the value of the "created_at" field in the mutation.
  35481. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35482. v := m.created_at
  35483. if v == nil {
  35484. return
  35485. }
  35486. return *v, true
  35487. }
  35488. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35489. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35491. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35492. if !m.op.Is(OpUpdateOne) {
  35493. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35494. }
  35495. if m.id == nil || m.oldValue == nil {
  35496. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35497. }
  35498. oldValue, err := m.oldValue(ctx)
  35499. if err != nil {
  35500. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35501. }
  35502. return oldValue.CreatedAt, nil
  35503. }
  35504. // ResetCreatedAt resets all changes to the "created_at" field.
  35505. func (m *UsageTotalMutation) ResetCreatedAt() {
  35506. m.created_at = nil
  35507. }
  35508. // SetUpdatedAt sets the "updated_at" field.
  35509. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35510. m.updated_at = &t
  35511. }
  35512. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35513. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35514. v := m.updated_at
  35515. if v == nil {
  35516. return
  35517. }
  35518. return *v, true
  35519. }
  35520. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35521. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35523. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35524. if !m.op.Is(OpUpdateOne) {
  35525. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35526. }
  35527. if m.id == nil || m.oldValue == nil {
  35528. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35529. }
  35530. oldValue, err := m.oldValue(ctx)
  35531. if err != nil {
  35532. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35533. }
  35534. return oldValue.UpdatedAt, nil
  35535. }
  35536. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35537. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35538. m.updated_at = nil
  35539. }
  35540. // SetStatus sets the "status" field.
  35541. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35542. m.status = &u
  35543. m.addstatus = nil
  35544. }
  35545. // Status returns the value of the "status" field in the mutation.
  35546. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35547. v := m.status
  35548. if v == nil {
  35549. return
  35550. }
  35551. return *v, true
  35552. }
  35553. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35554. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35556. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35557. if !m.op.Is(OpUpdateOne) {
  35558. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35559. }
  35560. if m.id == nil || m.oldValue == nil {
  35561. return v, errors.New("OldStatus requires an ID field in the mutation")
  35562. }
  35563. oldValue, err := m.oldValue(ctx)
  35564. if err != nil {
  35565. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35566. }
  35567. return oldValue.Status, nil
  35568. }
  35569. // AddStatus adds u to the "status" field.
  35570. func (m *UsageTotalMutation) AddStatus(u int8) {
  35571. if m.addstatus != nil {
  35572. *m.addstatus += u
  35573. } else {
  35574. m.addstatus = &u
  35575. }
  35576. }
  35577. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35578. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35579. v := m.addstatus
  35580. if v == nil {
  35581. return
  35582. }
  35583. return *v, true
  35584. }
  35585. // ClearStatus clears the value of the "status" field.
  35586. func (m *UsageTotalMutation) ClearStatus() {
  35587. m.status = nil
  35588. m.addstatus = nil
  35589. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35590. }
  35591. // StatusCleared returns if the "status" field was cleared in this mutation.
  35592. func (m *UsageTotalMutation) StatusCleared() bool {
  35593. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35594. return ok
  35595. }
  35596. // ResetStatus resets all changes to the "status" field.
  35597. func (m *UsageTotalMutation) ResetStatus() {
  35598. m.status = nil
  35599. m.addstatus = nil
  35600. delete(m.clearedFields, usagetotal.FieldStatus)
  35601. }
  35602. // SetType sets the "type" field.
  35603. func (m *UsageTotalMutation) SetType(i int) {
  35604. m._type = &i
  35605. m.add_type = nil
  35606. }
  35607. // GetType returns the value of the "type" field in the mutation.
  35608. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35609. v := m._type
  35610. if v == nil {
  35611. return
  35612. }
  35613. return *v, true
  35614. }
  35615. // OldType returns the old "type" field's value of the UsageTotal entity.
  35616. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35618. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35619. if !m.op.Is(OpUpdateOne) {
  35620. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35621. }
  35622. if m.id == nil || m.oldValue == nil {
  35623. return v, errors.New("OldType requires an ID field in the mutation")
  35624. }
  35625. oldValue, err := m.oldValue(ctx)
  35626. if err != nil {
  35627. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35628. }
  35629. return oldValue.Type, nil
  35630. }
  35631. // AddType adds i to the "type" field.
  35632. func (m *UsageTotalMutation) AddType(i int) {
  35633. if m.add_type != nil {
  35634. *m.add_type += i
  35635. } else {
  35636. m.add_type = &i
  35637. }
  35638. }
  35639. // AddedType returns the value that was added to the "type" field in this mutation.
  35640. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35641. v := m.add_type
  35642. if v == nil {
  35643. return
  35644. }
  35645. return *v, true
  35646. }
  35647. // ClearType clears the value of the "type" field.
  35648. func (m *UsageTotalMutation) ClearType() {
  35649. m._type = nil
  35650. m.add_type = nil
  35651. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35652. }
  35653. // TypeCleared returns if the "type" field was cleared in this mutation.
  35654. func (m *UsageTotalMutation) TypeCleared() bool {
  35655. _, ok := m.clearedFields[usagetotal.FieldType]
  35656. return ok
  35657. }
  35658. // ResetType resets all changes to the "type" field.
  35659. func (m *UsageTotalMutation) ResetType() {
  35660. m._type = nil
  35661. m.add_type = nil
  35662. delete(m.clearedFields, usagetotal.FieldType)
  35663. }
  35664. // SetBotID sets the "bot_id" field.
  35665. func (m *UsageTotalMutation) SetBotID(s string) {
  35666. m.bot_id = &s
  35667. }
  35668. // BotID returns the value of the "bot_id" field in the mutation.
  35669. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35670. v := m.bot_id
  35671. if v == nil {
  35672. return
  35673. }
  35674. return *v, true
  35675. }
  35676. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35677. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35679. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35680. if !m.op.Is(OpUpdateOne) {
  35681. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35682. }
  35683. if m.id == nil || m.oldValue == nil {
  35684. return v, errors.New("OldBotID requires an ID field in the mutation")
  35685. }
  35686. oldValue, err := m.oldValue(ctx)
  35687. if err != nil {
  35688. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35689. }
  35690. return oldValue.BotID, nil
  35691. }
  35692. // ResetBotID resets all changes to the "bot_id" field.
  35693. func (m *UsageTotalMutation) ResetBotID() {
  35694. m.bot_id = nil
  35695. }
  35696. // SetTotalTokens sets the "total_tokens" field.
  35697. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35698. m.total_tokens = &u
  35699. m.addtotal_tokens = nil
  35700. }
  35701. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35702. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35703. v := m.total_tokens
  35704. if v == nil {
  35705. return
  35706. }
  35707. return *v, true
  35708. }
  35709. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35710. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35712. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35713. if !m.op.Is(OpUpdateOne) {
  35714. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35715. }
  35716. if m.id == nil || m.oldValue == nil {
  35717. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35718. }
  35719. oldValue, err := m.oldValue(ctx)
  35720. if err != nil {
  35721. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35722. }
  35723. return oldValue.TotalTokens, nil
  35724. }
  35725. // AddTotalTokens adds u to the "total_tokens" field.
  35726. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35727. if m.addtotal_tokens != nil {
  35728. *m.addtotal_tokens += u
  35729. } else {
  35730. m.addtotal_tokens = &u
  35731. }
  35732. }
  35733. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35734. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35735. v := m.addtotal_tokens
  35736. if v == nil {
  35737. return
  35738. }
  35739. return *v, true
  35740. }
  35741. // ClearTotalTokens clears the value of the "total_tokens" field.
  35742. func (m *UsageTotalMutation) ClearTotalTokens() {
  35743. m.total_tokens = nil
  35744. m.addtotal_tokens = nil
  35745. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35746. }
  35747. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35748. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35749. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35750. return ok
  35751. }
  35752. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35753. func (m *UsageTotalMutation) ResetTotalTokens() {
  35754. m.total_tokens = nil
  35755. m.addtotal_tokens = nil
  35756. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35757. }
  35758. // SetStartIndex sets the "start_index" field.
  35759. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35760. m.start_index = &u
  35761. m.addstart_index = nil
  35762. }
  35763. // StartIndex returns the value of the "start_index" field in the mutation.
  35764. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35765. v := m.start_index
  35766. if v == nil {
  35767. return
  35768. }
  35769. return *v, true
  35770. }
  35771. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35772. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35774. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35775. if !m.op.Is(OpUpdateOne) {
  35776. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35777. }
  35778. if m.id == nil || m.oldValue == nil {
  35779. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35780. }
  35781. oldValue, err := m.oldValue(ctx)
  35782. if err != nil {
  35783. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35784. }
  35785. return oldValue.StartIndex, nil
  35786. }
  35787. // AddStartIndex adds u to the "start_index" field.
  35788. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35789. if m.addstart_index != nil {
  35790. *m.addstart_index += u
  35791. } else {
  35792. m.addstart_index = &u
  35793. }
  35794. }
  35795. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35796. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35797. v := m.addstart_index
  35798. if v == nil {
  35799. return
  35800. }
  35801. return *v, true
  35802. }
  35803. // ClearStartIndex clears the value of the "start_index" field.
  35804. func (m *UsageTotalMutation) ClearStartIndex() {
  35805. m.start_index = nil
  35806. m.addstart_index = nil
  35807. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35808. }
  35809. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35810. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35811. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35812. return ok
  35813. }
  35814. // ResetStartIndex resets all changes to the "start_index" field.
  35815. func (m *UsageTotalMutation) ResetStartIndex() {
  35816. m.start_index = nil
  35817. m.addstart_index = nil
  35818. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35819. }
  35820. // SetEndIndex sets the "end_index" field.
  35821. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35822. m.end_index = &u
  35823. m.addend_index = nil
  35824. }
  35825. // EndIndex returns the value of the "end_index" field in the mutation.
  35826. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35827. v := m.end_index
  35828. if v == nil {
  35829. return
  35830. }
  35831. return *v, true
  35832. }
  35833. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35834. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35836. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35837. if !m.op.Is(OpUpdateOne) {
  35838. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35839. }
  35840. if m.id == nil || m.oldValue == nil {
  35841. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35842. }
  35843. oldValue, err := m.oldValue(ctx)
  35844. if err != nil {
  35845. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35846. }
  35847. return oldValue.EndIndex, nil
  35848. }
  35849. // AddEndIndex adds u to the "end_index" field.
  35850. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35851. if m.addend_index != nil {
  35852. *m.addend_index += u
  35853. } else {
  35854. m.addend_index = &u
  35855. }
  35856. }
  35857. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35858. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35859. v := m.addend_index
  35860. if v == nil {
  35861. return
  35862. }
  35863. return *v, true
  35864. }
  35865. // ClearEndIndex clears the value of the "end_index" field.
  35866. func (m *UsageTotalMutation) ClearEndIndex() {
  35867. m.end_index = nil
  35868. m.addend_index = nil
  35869. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35870. }
  35871. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35872. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35873. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35874. return ok
  35875. }
  35876. // ResetEndIndex resets all changes to the "end_index" field.
  35877. func (m *UsageTotalMutation) ResetEndIndex() {
  35878. m.end_index = nil
  35879. m.addend_index = nil
  35880. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35881. }
  35882. // SetOrganizationID sets the "organization_id" field.
  35883. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35884. m.organization_id = &u
  35885. m.addorganization_id = nil
  35886. }
  35887. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35888. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35889. v := m.organization_id
  35890. if v == nil {
  35891. return
  35892. }
  35893. return *v, true
  35894. }
  35895. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35896. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35898. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35899. if !m.op.Is(OpUpdateOne) {
  35900. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35901. }
  35902. if m.id == nil || m.oldValue == nil {
  35903. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35904. }
  35905. oldValue, err := m.oldValue(ctx)
  35906. if err != nil {
  35907. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35908. }
  35909. return oldValue.OrganizationID, nil
  35910. }
  35911. // AddOrganizationID adds u to the "organization_id" field.
  35912. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35913. if m.addorganization_id != nil {
  35914. *m.addorganization_id += u
  35915. } else {
  35916. m.addorganization_id = &u
  35917. }
  35918. }
  35919. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35920. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35921. v := m.addorganization_id
  35922. if v == nil {
  35923. return
  35924. }
  35925. return *v, true
  35926. }
  35927. // ClearOrganizationID clears the value of the "organization_id" field.
  35928. func (m *UsageTotalMutation) ClearOrganizationID() {
  35929. m.organization_id = nil
  35930. m.addorganization_id = nil
  35931. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35932. }
  35933. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35934. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35935. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35936. return ok
  35937. }
  35938. // ResetOrganizationID resets all changes to the "organization_id" field.
  35939. func (m *UsageTotalMutation) ResetOrganizationID() {
  35940. m.organization_id = nil
  35941. m.addorganization_id = nil
  35942. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35943. }
  35944. // Where appends a list predicates to the UsageTotalMutation builder.
  35945. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35946. m.predicates = append(m.predicates, ps...)
  35947. }
  35948. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35949. // users can use type-assertion to append predicates that do not depend on any generated package.
  35950. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35951. p := make([]predicate.UsageTotal, len(ps))
  35952. for i := range ps {
  35953. p[i] = ps[i]
  35954. }
  35955. m.Where(p...)
  35956. }
  35957. // Op returns the operation name.
  35958. func (m *UsageTotalMutation) Op() Op {
  35959. return m.op
  35960. }
  35961. // SetOp allows setting the mutation operation.
  35962. func (m *UsageTotalMutation) SetOp(op Op) {
  35963. m.op = op
  35964. }
  35965. // Type returns the node type of this mutation (UsageTotal).
  35966. func (m *UsageTotalMutation) Type() string {
  35967. return m.typ
  35968. }
  35969. // Fields returns all fields that were changed during this mutation. Note that in
  35970. // order to get all numeric fields that were incremented/decremented, call
  35971. // AddedFields().
  35972. func (m *UsageTotalMutation) Fields() []string {
  35973. fields := make([]string, 0, 9)
  35974. if m.created_at != nil {
  35975. fields = append(fields, usagetotal.FieldCreatedAt)
  35976. }
  35977. if m.updated_at != nil {
  35978. fields = append(fields, usagetotal.FieldUpdatedAt)
  35979. }
  35980. if m.status != nil {
  35981. fields = append(fields, usagetotal.FieldStatus)
  35982. }
  35983. if m._type != nil {
  35984. fields = append(fields, usagetotal.FieldType)
  35985. }
  35986. if m.bot_id != nil {
  35987. fields = append(fields, usagetotal.FieldBotID)
  35988. }
  35989. if m.total_tokens != nil {
  35990. fields = append(fields, usagetotal.FieldTotalTokens)
  35991. }
  35992. if m.start_index != nil {
  35993. fields = append(fields, usagetotal.FieldStartIndex)
  35994. }
  35995. if m.end_index != nil {
  35996. fields = append(fields, usagetotal.FieldEndIndex)
  35997. }
  35998. if m.organization_id != nil {
  35999. fields = append(fields, usagetotal.FieldOrganizationID)
  36000. }
  36001. return fields
  36002. }
  36003. // Field returns the value of a field with the given name. The second boolean
  36004. // return value indicates that this field was not set, or was not defined in the
  36005. // schema.
  36006. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  36007. switch name {
  36008. case usagetotal.FieldCreatedAt:
  36009. return m.CreatedAt()
  36010. case usagetotal.FieldUpdatedAt:
  36011. return m.UpdatedAt()
  36012. case usagetotal.FieldStatus:
  36013. return m.Status()
  36014. case usagetotal.FieldType:
  36015. return m.GetType()
  36016. case usagetotal.FieldBotID:
  36017. return m.BotID()
  36018. case usagetotal.FieldTotalTokens:
  36019. return m.TotalTokens()
  36020. case usagetotal.FieldStartIndex:
  36021. return m.StartIndex()
  36022. case usagetotal.FieldEndIndex:
  36023. return m.EndIndex()
  36024. case usagetotal.FieldOrganizationID:
  36025. return m.OrganizationID()
  36026. }
  36027. return nil, false
  36028. }
  36029. // OldField returns the old value of the field from the database. An error is
  36030. // returned if the mutation operation is not UpdateOne, or the query to the
  36031. // database failed.
  36032. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36033. switch name {
  36034. case usagetotal.FieldCreatedAt:
  36035. return m.OldCreatedAt(ctx)
  36036. case usagetotal.FieldUpdatedAt:
  36037. return m.OldUpdatedAt(ctx)
  36038. case usagetotal.FieldStatus:
  36039. return m.OldStatus(ctx)
  36040. case usagetotal.FieldType:
  36041. return m.OldType(ctx)
  36042. case usagetotal.FieldBotID:
  36043. return m.OldBotID(ctx)
  36044. case usagetotal.FieldTotalTokens:
  36045. return m.OldTotalTokens(ctx)
  36046. case usagetotal.FieldStartIndex:
  36047. return m.OldStartIndex(ctx)
  36048. case usagetotal.FieldEndIndex:
  36049. return m.OldEndIndex(ctx)
  36050. case usagetotal.FieldOrganizationID:
  36051. return m.OldOrganizationID(ctx)
  36052. }
  36053. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  36054. }
  36055. // SetField sets the value of a field with the given name. It returns an error if
  36056. // the field is not defined in the schema, or if the type mismatched the field
  36057. // type.
  36058. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  36059. switch name {
  36060. case usagetotal.FieldCreatedAt:
  36061. v, ok := value.(time.Time)
  36062. if !ok {
  36063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36064. }
  36065. m.SetCreatedAt(v)
  36066. return nil
  36067. case usagetotal.FieldUpdatedAt:
  36068. v, ok := value.(time.Time)
  36069. if !ok {
  36070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36071. }
  36072. m.SetUpdatedAt(v)
  36073. return nil
  36074. case usagetotal.FieldStatus:
  36075. v, ok := value.(uint8)
  36076. if !ok {
  36077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36078. }
  36079. m.SetStatus(v)
  36080. return nil
  36081. case usagetotal.FieldType:
  36082. v, ok := value.(int)
  36083. if !ok {
  36084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36085. }
  36086. m.SetType(v)
  36087. return nil
  36088. case usagetotal.FieldBotID:
  36089. v, ok := value.(string)
  36090. if !ok {
  36091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36092. }
  36093. m.SetBotID(v)
  36094. return nil
  36095. case usagetotal.FieldTotalTokens:
  36096. v, ok := value.(uint64)
  36097. if !ok {
  36098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36099. }
  36100. m.SetTotalTokens(v)
  36101. return nil
  36102. case usagetotal.FieldStartIndex:
  36103. v, ok := value.(uint64)
  36104. if !ok {
  36105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36106. }
  36107. m.SetStartIndex(v)
  36108. return nil
  36109. case usagetotal.FieldEndIndex:
  36110. v, ok := value.(uint64)
  36111. if !ok {
  36112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36113. }
  36114. m.SetEndIndex(v)
  36115. return nil
  36116. case usagetotal.FieldOrganizationID:
  36117. v, ok := value.(uint64)
  36118. if !ok {
  36119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36120. }
  36121. m.SetOrganizationID(v)
  36122. return nil
  36123. }
  36124. return fmt.Errorf("unknown UsageTotal field %s", name)
  36125. }
  36126. // AddedFields returns all numeric fields that were incremented/decremented during
  36127. // this mutation.
  36128. func (m *UsageTotalMutation) AddedFields() []string {
  36129. var fields []string
  36130. if m.addstatus != nil {
  36131. fields = append(fields, usagetotal.FieldStatus)
  36132. }
  36133. if m.add_type != nil {
  36134. fields = append(fields, usagetotal.FieldType)
  36135. }
  36136. if m.addtotal_tokens != nil {
  36137. fields = append(fields, usagetotal.FieldTotalTokens)
  36138. }
  36139. if m.addstart_index != nil {
  36140. fields = append(fields, usagetotal.FieldStartIndex)
  36141. }
  36142. if m.addend_index != nil {
  36143. fields = append(fields, usagetotal.FieldEndIndex)
  36144. }
  36145. if m.addorganization_id != nil {
  36146. fields = append(fields, usagetotal.FieldOrganizationID)
  36147. }
  36148. return fields
  36149. }
  36150. // AddedField returns the numeric value that was incremented/decremented on a field
  36151. // with the given name. The second boolean return value indicates that this field
  36152. // was not set, or was not defined in the schema.
  36153. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  36154. switch name {
  36155. case usagetotal.FieldStatus:
  36156. return m.AddedStatus()
  36157. case usagetotal.FieldType:
  36158. return m.AddedType()
  36159. case usagetotal.FieldTotalTokens:
  36160. return m.AddedTotalTokens()
  36161. case usagetotal.FieldStartIndex:
  36162. return m.AddedStartIndex()
  36163. case usagetotal.FieldEndIndex:
  36164. return m.AddedEndIndex()
  36165. case usagetotal.FieldOrganizationID:
  36166. return m.AddedOrganizationID()
  36167. }
  36168. return nil, false
  36169. }
  36170. // AddField adds the value to the field with the given name. It returns an error if
  36171. // the field is not defined in the schema, or if the type mismatched the field
  36172. // type.
  36173. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  36174. switch name {
  36175. case usagetotal.FieldStatus:
  36176. v, ok := value.(int8)
  36177. if !ok {
  36178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36179. }
  36180. m.AddStatus(v)
  36181. return nil
  36182. case usagetotal.FieldType:
  36183. v, ok := value.(int)
  36184. if !ok {
  36185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36186. }
  36187. m.AddType(v)
  36188. return nil
  36189. case usagetotal.FieldTotalTokens:
  36190. v, ok := value.(int64)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.AddTotalTokens(v)
  36195. return nil
  36196. case usagetotal.FieldStartIndex:
  36197. v, ok := value.(int64)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.AddStartIndex(v)
  36202. return nil
  36203. case usagetotal.FieldEndIndex:
  36204. v, ok := value.(int64)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.AddEndIndex(v)
  36209. return nil
  36210. case usagetotal.FieldOrganizationID:
  36211. v, ok := value.(int64)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.AddOrganizationID(v)
  36216. return nil
  36217. }
  36218. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  36219. }
  36220. // ClearedFields returns all nullable fields that were cleared during this
  36221. // mutation.
  36222. func (m *UsageTotalMutation) ClearedFields() []string {
  36223. var fields []string
  36224. if m.FieldCleared(usagetotal.FieldStatus) {
  36225. fields = append(fields, usagetotal.FieldStatus)
  36226. }
  36227. if m.FieldCleared(usagetotal.FieldType) {
  36228. fields = append(fields, usagetotal.FieldType)
  36229. }
  36230. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  36231. fields = append(fields, usagetotal.FieldTotalTokens)
  36232. }
  36233. if m.FieldCleared(usagetotal.FieldStartIndex) {
  36234. fields = append(fields, usagetotal.FieldStartIndex)
  36235. }
  36236. if m.FieldCleared(usagetotal.FieldEndIndex) {
  36237. fields = append(fields, usagetotal.FieldEndIndex)
  36238. }
  36239. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  36240. fields = append(fields, usagetotal.FieldOrganizationID)
  36241. }
  36242. return fields
  36243. }
  36244. // FieldCleared returns a boolean indicating if a field with the given name was
  36245. // cleared in this mutation.
  36246. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  36247. _, ok := m.clearedFields[name]
  36248. return ok
  36249. }
  36250. // ClearField clears the value of the field with the given name. It returns an
  36251. // error if the field is not defined in the schema.
  36252. func (m *UsageTotalMutation) ClearField(name string) error {
  36253. switch name {
  36254. case usagetotal.FieldStatus:
  36255. m.ClearStatus()
  36256. return nil
  36257. case usagetotal.FieldType:
  36258. m.ClearType()
  36259. return nil
  36260. case usagetotal.FieldTotalTokens:
  36261. m.ClearTotalTokens()
  36262. return nil
  36263. case usagetotal.FieldStartIndex:
  36264. m.ClearStartIndex()
  36265. return nil
  36266. case usagetotal.FieldEndIndex:
  36267. m.ClearEndIndex()
  36268. return nil
  36269. case usagetotal.FieldOrganizationID:
  36270. m.ClearOrganizationID()
  36271. return nil
  36272. }
  36273. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  36274. }
  36275. // ResetField resets all changes in the mutation for the field with the given name.
  36276. // It returns an error if the field is not defined in the schema.
  36277. func (m *UsageTotalMutation) ResetField(name string) error {
  36278. switch name {
  36279. case usagetotal.FieldCreatedAt:
  36280. m.ResetCreatedAt()
  36281. return nil
  36282. case usagetotal.FieldUpdatedAt:
  36283. m.ResetUpdatedAt()
  36284. return nil
  36285. case usagetotal.FieldStatus:
  36286. m.ResetStatus()
  36287. return nil
  36288. case usagetotal.FieldType:
  36289. m.ResetType()
  36290. return nil
  36291. case usagetotal.FieldBotID:
  36292. m.ResetBotID()
  36293. return nil
  36294. case usagetotal.FieldTotalTokens:
  36295. m.ResetTotalTokens()
  36296. return nil
  36297. case usagetotal.FieldStartIndex:
  36298. m.ResetStartIndex()
  36299. return nil
  36300. case usagetotal.FieldEndIndex:
  36301. m.ResetEndIndex()
  36302. return nil
  36303. case usagetotal.FieldOrganizationID:
  36304. m.ResetOrganizationID()
  36305. return nil
  36306. }
  36307. return fmt.Errorf("unknown UsageTotal field %s", name)
  36308. }
  36309. // AddedEdges returns all edge names that were set/added in this mutation.
  36310. func (m *UsageTotalMutation) AddedEdges() []string {
  36311. edges := make([]string, 0, 0)
  36312. return edges
  36313. }
  36314. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36315. // name in this mutation.
  36316. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  36317. return nil
  36318. }
  36319. // RemovedEdges returns all edge names that were removed in this mutation.
  36320. func (m *UsageTotalMutation) RemovedEdges() []string {
  36321. edges := make([]string, 0, 0)
  36322. return edges
  36323. }
  36324. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36325. // the given name in this mutation.
  36326. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  36327. return nil
  36328. }
  36329. // ClearedEdges returns all edge names that were cleared in this mutation.
  36330. func (m *UsageTotalMutation) ClearedEdges() []string {
  36331. edges := make([]string, 0, 0)
  36332. return edges
  36333. }
  36334. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36335. // was cleared in this mutation.
  36336. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  36337. return false
  36338. }
  36339. // ClearEdge clears the value of the edge with the given name. It returns an error
  36340. // if that edge is not defined in the schema.
  36341. func (m *UsageTotalMutation) ClearEdge(name string) error {
  36342. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  36343. }
  36344. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36345. // It returns an error if the edge is not defined in the schema.
  36346. func (m *UsageTotalMutation) ResetEdge(name string) error {
  36347. return fmt.Errorf("unknown UsageTotal edge %s", name)
  36348. }
  36349. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  36350. type WhatsappMutation struct {
  36351. config
  36352. op Op
  36353. typ string
  36354. id *uint64
  36355. created_at *time.Time
  36356. updated_at *time.Time
  36357. status *uint8
  36358. addstatus *int8
  36359. deleted_at *time.Time
  36360. wa_id *string
  36361. wa_name *string
  36362. callback *string
  36363. account *string
  36364. cc *string
  36365. phone *string
  36366. cc_phone *string
  36367. phone_name *string
  36368. phone_status *int8
  36369. addphone_status *int8
  36370. organization_id *uint64
  36371. addorganization_id *int64
  36372. api_base *string
  36373. api_key *string
  36374. allow_list *[]string
  36375. appendallow_list []string
  36376. group_allow_list *[]string
  36377. appendgroup_allow_list []string
  36378. block_list *[]string
  36379. appendblock_list []string
  36380. group_block_list *[]string
  36381. appendgroup_block_list []string
  36382. clearedFields map[string]struct{}
  36383. agent *uint64
  36384. clearedagent bool
  36385. done bool
  36386. oldValue func(context.Context) (*Whatsapp, error)
  36387. predicates []predicate.Whatsapp
  36388. }
  36389. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36390. // whatsappOption allows management of the mutation configuration using functional options.
  36391. type whatsappOption func(*WhatsappMutation)
  36392. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36393. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36394. m := &WhatsappMutation{
  36395. config: c,
  36396. op: op,
  36397. typ: TypeWhatsapp,
  36398. clearedFields: make(map[string]struct{}),
  36399. }
  36400. for _, opt := range opts {
  36401. opt(m)
  36402. }
  36403. return m
  36404. }
  36405. // withWhatsappID sets the ID field of the mutation.
  36406. func withWhatsappID(id uint64) whatsappOption {
  36407. return func(m *WhatsappMutation) {
  36408. var (
  36409. err error
  36410. once sync.Once
  36411. value *Whatsapp
  36412. )
  36413. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36414. once.Do(func() {
  36415. if m.done {
  36416. err = errors.New("querying old values post mutation is not allowed")
  36417. } else {
  36418. value, err = m.Client().Whatsapp.Get(ctx, id)
  36419. }
  36420. })
  36421. return value, err
  36422. }
  36423. m.id = &id
  36424. }
  36425. }
  36426. // withWhatsapp sets the old Whatsapp of the mutation.
  36427. func withWhatsapp(node *Whatsapp) whatsappOption {
  36428. return func(m *WhatsappMutation) {
  36429. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36430. return node, nil
  36431. }
  36432. m.id = &node.ID
  36433. }
  36434. }
  36435. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36436. // executed in a transaction (ent.Tx), a transactional client is returned.
  36437. func (m WhatsappMutation) Client() *Client {
  36438. client := &Client{config: m.config}
  36439. client.init()
  36440. return client
  36441. }
  36442. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36443. // it returns an error otherwise.
  36444. func (m WhatsappMutation) Tx() (*Tx, error) {
  36445. if _, ok := m.driver.(*txDriver); !ok {
  36446. return nil, errors.New("ent: mutation is not running in a transaction")
  36447. }
  36448. tx := &Tx{config: m.config}
  36449. tx.init()
  36450. return tx, nil
  36451. }
  36452. // SetID sets the value of the id field. Note that this
  36453. // operation is only accepted on creation of Whatsapp entities.
  36454. func (m *WhatsappMutation) SetID(id uint64) {
  36455. m.id = &id
  36456. }
  36457. // ID returns the ID value in the mutation. Note that the ID is only available
  36458. // if it was provided to the builder or after it was returned from the database.
  36459. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36460. if m.id == nil {
  36461. return
  36462. }
  36463. return *m.id, true
  36464. }
  36465. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36466. // That means, if the mutation is applied within a transaction with an isolation level such
  36467. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36468. // or updated by the mutation.
  36469. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36470. switch {
  36471. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36472. id, exists := m.ID()
  36473. if exists {
  36474. return []uint64{id}, nil
  36475. }
  36476. fallthrough
  36477. case m.op.Is(OpUpdate | OpDelete):
  36478. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36479. default:
  36480. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36481. }
  36482. }
  36483. // SetCreatedAt sets the "created_at" field.
  36484. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36485. m.created_at = &t
  36486. }
  36487. // CreatedAt returns the value of the "created_at" field in the mutation.
  36488. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36489. v := m.created_at
  36490. if v == nil {
  36491. return
  36492. }
  36493. return *v, true
  36494. }
  36495. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36496. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36498. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36499. if !m.op.Is(OpUpdateOne) {
  36500. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36501. }
  36502. if m.id == nil || m.oldValue == nil {
  36503. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36504. }
  36505. oldValue, err := m.oldValue(ctx)
  36506. if err != nil {
  36507. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36508. }
  36509. return oldValue.CreatedAt, nil
  36510. }
  36511. // ResetCreatedAt resets all changes to the "created_at" field.
  36512. func (m *WhatsappMutation) ResetCreatedAt() {
  36513. m.created_at = nil
  36514. }
  36515. // SetUpdatedAt sets the "updated_at" field.
  36516. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36517. m.updated_at = &t
  36518. }
  36519. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36520. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36521. v := m.updated_at
  36522. if v == nil {
  36523. return
  36524. }
  36525. return *v, true
  36526. }
  36527. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36528. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36530. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36531. if !m.op.Is(OpUpdateOne) {
  36532. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36533. }
  36534. if m.id == nil || m.oldValue == nil {
  36535. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36536. }
  36537. oldValue, err := m.oldValue(ctx)
  36538. if err != nil {
  36539. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36540. }
  36541. return oldValue.UpdatedAt, nil
  36542. }
  36543. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36544. func (m *WhatsappMutation) ResetUpdatedAt() {
  36545. m.updated_at = nil
  36546. }
  36547. // SetStatus sets the "status" field.
  36548. func (m *WhatsappMutation) SetStatus(u uint8) {
  36549. m.status = &u
  36550. m.addstatus = nil
  36551. }
  36552. // Status returns the value of the "status" field in the mutation.
  36553. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36554. v := m.status
  36555. if v == nil {
  36556. return
  36557. }
  36558. return *v, true
  36559. }
  36560. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36561. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36563. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36564. if !m.op.Is(OpUpdateOne) {
  36565. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36566. }
  36567. if m.id == nil || m.oldValue == nil {
  36568. return v, errors.New("OldStatus requires an ID field in the mutation")
  36569. }
  36570. oldValue, err := m.oldValue(ctx)
  36571. if err != nil {
  36572. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36573. }
  36574. return oldValue.Status, nil
  36575. }
  36576. // AddStatus adds u to the "status" field.
  36577. func (m *WhatsappMutation) AddStatus(u int8) {
  36578. if m.addstatus != nil {
  36579. *m.addstatus += u
  36580. } else {
  36581. m.addstatus = &u
  36582. }
  36583. }
  36584. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36585. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36586. v := m.addstatus
  36587. if v == nil {
  36588. return
  36589. }
  36590. return *v, true
  36591. }
  36592. // ClearStatus clears the value of the "status" field.
  36593. func (m *WhatsappMutation) ClearStatus() {
  36594. m.status = nil
  36595. m.addstatus = nil
  36596. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36597. }
  36598. // StatusCleared returns if the "status" field was cleared in this mutation.
  36599. func (m *WhatsappMutation) StatusCleared() bool {
  36600. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36601. return ok
  36602. }
  36603. // ResetStatus resets all changes to the "status" field.
  36604. func (m *WhatsappMutation) ResetStatus() {
  36605. m.status = nil
  36606. m.addstatus = nil
  36607. delete(m.clearedFields, whatsapp.FieldStatus)
  36608. }
  36609. // SetDeletedAt sets the "deleted_at" field.
  36610. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36611. m.deleted_at = &t
  36612. }
  36613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36614. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36615. v := m.deleted_at
  36616. if v == nil {
  36617. return
  36618. }
  36619. return *v, true
  36620. }
  36621. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36622. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36624. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36625. if !m.op.Is(OpUpdateOne) {
  36626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36627. }
  36628. if m.id == nil || m.oldValue == nil {
  36629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36630. }
  36631. oldValue, err := m.oldValue(ctx)
  36632. if err != nil {
  36633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36634. }
  36635. return oldValue.DeletedAt, nil
  36636. }
  36637. // ClearDeletedAt clears the value of the "deleted_at" field.
  36638. func (m *WhatsappMutation) ClearDeletedAt() {
  36639. m.deleted_at = nil
  36640. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36641. }
  36642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36643. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36644. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36645. return ok
  36646. }
  36647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36648. func (m *WhatsappMutation) ResetDeletedAt() {
  36649. m.deleted_at = nil
  36650. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36651. }
  36652. // SetWaID sets the "wa_id" field.
  36653. func (m *WhatsappMutation) SetWaID(s string) {
  36654. m.wa_id = &s
  36655. }
  36656. // WaID returns the value of the "wa_id" field in the mutation.
  36657. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36658. v := m.wa_id
  36659. if v == nil {
  36660. return
  36661. }
  36662. return *v, true
  36663. }
  36664. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36665. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36667. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36668. if !m.op.Is(OpUpdateOne) {
  36669. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36670. }
  36671. if m.id == nil || m.oldValue == nil {
  36672. return v, errors.New("OldWaID requires an ID field in the mutation")
  36673. }
  36674. oldValue, err := m.oldValue(ctx)
  36675. if err != nil {
  36676. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36677. }
  36678. return oldValue.WaID, nil
  36679. }
  36680. // ClearWaID clears the value of the "wa_id" field.
  36681. func (m *WhatsappMutation) ClearWaID() {
  36682. m.wa_id = nil
  36683. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36684. }
  36685. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36686. func (m *WhatsappMutation) WaIDCleared() bool {
  36687. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36688. return ok
  36689. }
  36690. // ResetWaID resets all changes to the "wa_id" field.
  36691. func (m *WhatsappMutation) ResetWaID() {
  36692. m.wa_id = nil
  36693. delete(m.clearedFields, whatsapp.FieldWaID)
  36694. }
  36695. // SetWaName sets the "wa_name" field.
  36696. func (m *WhatsappMutation) SetWaName(s string) {
  36697. m.wa_name = &s
  36698. }
  36699. // WaName returns the value of the "wa_name" field in the mutation.
  36700. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36701. v := m.wa_name
  36702. if v == nil {
  36703. return
  36704. }
  36705. return *v, true
  36706. }
  36707. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36708. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36710. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36711. if !m.op.Is(OpUpdateOne) {
  36712. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36713. }
  36714. if m.id == nil || m.oldValue == nil {
  36715. return v, errors.New("OldWaName requires an ID field in the mutation")
  36716. }
  36717. oldValue, err := m.oldValue(ctx)
  36718. if err != nil {
  36719. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36720. }
  36721. return oldValue.WaName, nil
  36722. }
  36723. // ClearWaName clears the value of the "wa_name" field.
  36724. func (m *WhatsappMutation) ClearWaName() {
  36725. m.wa_name = nil
  36726. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36727. }
  36728. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36729. func (m *WhatsappMutation) WaNameCleared() bool {
  36730. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36731. return ok
  36732. }
  36733. // ResetWaName resets all changes to the "wa_name" field.
  36734. func (m *WhatsappMutation) ResetWaName() {
  36735. m.wa_name = nil
  36736. delete(m.clearedFields, whatsapp.FieldWaName)
  36737. }
  36738. // SetCallback sets the "callback" field.
  36739. func (m *WhatsappMutation) SetCallback(s string) {
  36740. m.callback = &s
  36741. }
  36742. // Callback returns the value of the "callback" field in the mutation.
  36743. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36744. v := m.callback
  36745. if v == nil {
  36746. return
  36747. }
  36748. return *v, true
  36749. }
  36750. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36751. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36753. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36754. if !m.op.Is(OpUpdateOne) {
  36755. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36756. }
  36757. if m.id == nil || m.oldValue == nil {
  36758. return v, errors.New("OldCallback requires an ID field in the mutation")
  36759. }
  36760. oldValue, err := m.oldValue(ctx)
  36761. if err != nil {
  36762. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36763. }
  36764. return oldValue.Callback, nil
  36765. }
  36766. // ClearCallback clears the value of the "callback" field.
  36767. func (m *WhatsappMutation) ClearCallback() {
  36768. m.callback = nil
  36769. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36770. }
  36771. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36772. func (m *WhatsappMutation) CallbackCleared() bool {
  36773. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36774. return ok
  36775. }
  36776. // ResetCallback resets all changes to the "callback" field.
  36777. func (m *WhatsappMutation) ResetCallback() {
  36778. m.callback = nil
  36779. delete(m.clearedFields, whatsapp.FieldCallback)
  36780. }
  36781. // SetAgentID sets the "agent_id" field.
  36782. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36783. m.agent = &u
  36784. }
  36785. // AgentID returns the value of the "agent_id" field in the mutation.
  36786. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36787. v := m.agent
  36788. if v == nil {
  36789. return
  36790. }
  36791. return *v, true
  36792. }
  36793. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36794. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36796. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36797. if !m.op.Is(OpUpdateOne) {
  36798. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36799. }
  36800. if m.id == nil || m.oldValue == nil {
  36801. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36802. }
  36803. oldValue, err := m.oldValue(ctx)
  36804. if err != nil {
  36805. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36806. }
  36807. return oldValue.AgentID, nil
  36808. }
  36809. // ResetAgentID resets all changes to the "agent_id" field.
  36810. func (m *WhatsappMutation) ResetAgentID() {
  36811. m.agent = nil
  36812. }
  36813. // SetAccount sets the "account" field.
  36814. func (m *WhatsappMutation) SetAccount(s string) {
  36815. m.account = &s
  36816. }
  36817. // Account returns the value of the "account" field in the mutation.
  36818. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36819. v := m.account
  36820. if v == nil {
  36821. return
  36822. }
  36823. return *v, true
  36824. }
  36825. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36826. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36828. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36829. if !m.op.Is(OpUpdateOne) {
  36830. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36831. }
  36832. if m.id == nil || m.oldValue == nil {
  36833. return v, errors.New("OldAccount requires an ID field in the mutation")
  36834. }
  36835. oldValue, err := m.oldValue(ctx)
  36836. if err != nil {
  36837. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36838. }
  36839. return oldValue.Account, nil
  36840. }
  36841. // ClearAccount clears the value of the "account" field.
  36842. func (m *WhatsappMutation) ClearAccount() {
  36843. m.account = nil
  36844. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36845. }
  36846. // AccountCleared returns if the "account" field was cleared in this mutation.
  36847. func (m *WhatsappMutation) AccountCleared() bool {
  36848. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36849. return ok
  36850. }
  36851. // ResetAccount resets all changes to the "account" field.
  36852. func (m *WhatsappMutation) ResetAccount() {
  36853. m.account = nil
  36854. delete(m.clearedFields, whatsapp.FieldAccount)
  36855. }
  36856. // SetCc sets the "cc" field.
  36857. func (m *WhatsappMutation) SetCc(s string) {
  36858. m.cc = &s
  36859. }
  36860. // Cc returns the value of the "cc" field in the mutation.
  36861. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36862. v := m.cc
  36863. if v == nil {
  36864. return
  36865. }
  36866. return *v, true
  36867. }
  36868. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36869. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36871. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36872. if !m.op.Is(OpUpdateOne) {
  36873. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36874. }
  36875. if m.id == nil || m.oldValue == nil {
  36876. return v, errors.New("OldCc requires an ID field in the mutation")
  36877. }
  36878. oldValue, err := m.oldValue(ctx)
  36879. if err != nil {
  36880. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36881. }
  36882. return oldValue.Cc, nil
  36883. }
  36884. // ResetCc resets all changes to the "cc" field.
  36885. func (m *WhatsappMutation) ResetCc() {
  36886. m.cc = nil
  36887. }
  36888. // SetPhone sets the "phone" field.
  36889. func (m *WhatsappMutation) SetPhone(s string) {
  36890. m.phone = &s
  36891. }
  36892. // Phone returns the value of the "phone" field in the mutation.
  36893. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36894. v := m.phone
  36895. if v == nil {
  36896. return
  36897. }
  36898. return *v, true
  36899. }
  36900. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36901. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36903. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36904. if !m.op.Is(OpUpdateOne) {
  36905. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36906. }
  36907. if m.id == nil || m.oldValue == nil {
  36908. return v, errors.New("OldPhone requires an ID field in the mutation")
  36909. }
  36910. oldValue, err := m.oldValue(ctx)
  36911. if err != nil {
  36912. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36913. }
  36914. return oldValue.Phone, nil
  36915. }
  36916. // ResetPhone resets all changes to the "phone" field.
  36917. func (m *WhatsappMutation) ResetPhone() {
  36918. m.phone = nil
  36919. }
  36920. // SetCcPhone sets the "cc_phone" field.
  36921. func (m *WhatsappMutation) SetCcPhone(s string) {
  36922. m.cc_phone = &s
  36923. }
  36924. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36925. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36926. v := m.cc_phone
  36927. if v == nil {
  36928. return
  36929. }
  36930. return *v, true
  36931. }
  36932. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36933. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36935. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36936. if !m.op.Is(OpUpdateOne) {
  36937. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36938. }
  36939. if m.id == nil || m.oldValue == nil {
  36940. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36941. }
  36942. oldValue, err := m.oldValue(ctx)
  36943. if err != nil {
  36944. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36945. }
  36946. return oldValue.CcPhone, nil
  36947. }
  36948. // ResetCcPhone resets all changes to the "cc_phone" field.
  36949. func (m *WhatsappMutation) ResetCcPhone() {
  36950. m.cc_phone = nil
  36951. }
  36952. // SetPhoneName sets the "phone_name" field.
  36953. func (m *WhatsappMutation) SetPhoneName(s string) {
  36954. m.phone_name = &s
  36955. }
  36956. // PhoneName returns the value of the "phone_name" field in the mutation.
  36957. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36958. v := m.phone_name
  36959. if v == nil {
  36960. return
  36961. }
  36962. return *v, true
  36963. }
  36964. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36965. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36967. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36968. if !m.op.Is(OpUpdateOne) {
  36969. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36970. }
  36971. if m.id == nil || m.oldValue == nil {
  36972. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36973. }
  36974. oldValue, err := m.oldValue(ctx)
  36975. if err != nil {
  36976. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36977. }
  36978. return oldValue.PhoneName, nil
  36979. }
  36980. // ResetPhoneName resets all changes to the "phone_name" field.
  36981. func (m *WhatsappMutation) ResetPhoneName() {
  36982. m.phone_name = nil
  36983. }
  36984. // SetPhoneStatus sets the "phone_status" field.
  36985. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36986. m.phone_status = &i
  36987. m.addphone_status = nil
  36988. }
  36989. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36990. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36991. v := m.phone_status
  36992. if v == nil {
  36993. return
  36994. }
  36995. return *v, true
  36996. }
  36997. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36998. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37000. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  37001. if !m.op.Is(OpUpdateOne) {
  37002. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  37003. }
  37004. if m.id == nil || m.oldValue == nil {
  37005. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  37006. }
  37007. oldValue, err := m.oldValue(ctx)
  37008. if err != nil {
  37009. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  37010. }
  37011. return oldValue.PhoneStatus, nil
  37012. }
  37013. // AddPhoneStatus adds i to the "phone_status" field.
  37014. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  37015. if m.addphone_status != nil {
  37016. *m.addphone_status += i
  37017. } else {
  37018. m.addphone_status = &i
  37019. }
  37020. }
  37021. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  37022. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  37023. v := m.addphone_status
  37024. if v == nil {
  37025. return
  37026. }
  37027. return *v, true
  37028. }
  37029. // ResetPhoneStatus resets all changes to the "phone_status" field.
  37030. func (m *WhatsappMutation) ResetPhoneStatus() {
  37031. m.phone_status = nil
  37032. m.addphone_status = nil
  37033. }
  37034. // SetOrganizationID sets the "organization_id" field.
  37035. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  37036. m.organization_id = &u
  37037. m.addorganization_id = nil
  37038. }
  37039. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37040. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  37041. v := m.organization_id
  37042. if v == nil {
  37043. return
  37044. }
  37045. return *v, true
  37046. }
  37047. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  37048. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37050. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37051. if !m.op.Is(OpUpdateOne) {
  37052. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37053. }
  37054. if m.id == nil || m.oldValue == nil {
  37055. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37056. }
  37057. oldValue, err := m.oldValue(ctx)
  37058. if err != nil {
  37059. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37060. }
  37061. return oldValue.OrganizationID, nil
  37062. }
  37063. // AddOrganizationID adds u to the "organization_id" field.
  37064. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  37065. if m.addorganization_id != nil {
  37066. *m.addorganization_id += u
  37067. } else {
  37068. m.addorganization_id = &u
  37069. }
  37070. }
  37071. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37072. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  37073. v := m.addorganization_id
  37074. if v == nil {
  37075. return
  37076. }
  37077. return *v, true
  37078. }
  37079. // ClearOrganizationID clears the value of the "organization_id" field.
  37080. func (m *WhatsappMutation) ClearOrganizationID() {
  37081. m.organization_id = nil
  37082. m.addorganization_id = nil
  37083. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  37084. }
  37085. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37086. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  37087. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  37088. return ok
  37089. }
  37090. // ResetOrganizationID resets all changes to the "organization_id" field.
  37091. func (m *WhatsappMutation) ResetOrganizationID() {
  37092. m.organization_id = nil
  37093. m.addorganization_id = nil
  37094. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  37095. }
  37096. // SetAPIBase sets the "api_base" field.
  37097. func (m *WhatsappMutation) SetAPIBase(s string) {
  37098. m.api_base = &s
  37099. }
  37100. // APIBase returns the value of the "api_base" field in the mutation.
  37101. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  37102. v := m.api_base
  37103. if v == nil {
  37104. return
  37105. }
  37106. return *v, true
  37107. }
  37108. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  37109. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37111. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37112. if !m.op.Is(OpUpdateOne) {
  37113. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37114. }
  37115. if m.id == nil || m.oldValue == nil {
  37116. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37117. }
  37118. oldValue, err := m.oldValue(ctx)
  37119. if err != nil {
  37120. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37121. }
  37122. return oldValue.APIBase, nil
  37123. }
  37124. // ClearAPIBase clears the value of the "api_base" field.
  37125. func (m *WhatsappMutation) ClearAPIBase() {
  37126. m.api_base = nil
  37127. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  37128. }
  37129. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37130. func (m *WhatsappMutation) APIBaseCleared() bool {
  37131. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  37132. return ok
  37133. }
  37134. // ResetAPIBase resets all changes to the "api_base" field.
  37135. func (m *WhatsappMutation) ResetAPIBase() {
  37136. m.api_base = nil
  37137. delete(m.clearedFields, whatsapp.FieldAPIBase)
  37138. }
  37139. // SetAPIKey sets the "api_key" field.
  37140. func (m *WhatsappMutation) SetAPIKey(s string) {
  37141. m.api_key = &s
  37142. }
  37143. // APIKey returns the value of the "api_key" field in the mutation.
  37144. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  37145. v := m.api_key
  37146. if v == nil {
  37147. return
  37148. }
  37149. return *v, true
  37150. }
  37151. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  37152. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37154. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37155. if !m.op.Is(OpUpdateOne) {
  37156. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37157. }
  37158. if m.id == nil || m.oldValue == nil {
  37159. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37160. }
  37161. oldValue, err := m.oldValue(ctx)
  37162. if err != nil {
  37163. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37164. }
  37165. return oldValue.APIKey, nil
  37166. }
  37167. // ClearAPIKey clears the value of the "api_key" field.
  37168. func (m *WhatsappMutation) ClearAPIKey() {
  37169. m.api_key = nil
  37170. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  37171. }
  37172. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37173. func (m *WhatsappMutation) APIKeyCleared() bool {
  37174. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  37175. return ok
  37176. }
  37177. // ResetAPIKey resets all changes to the "api_key" field.
  37178. func (m *WhatsappMutation) ResetAPIKey() {
  37179. m.api_key = nil
  37180. delete(m.clearedFields, whatsapp.FieldAPIKey)
  37181. }
  37182. // SetAllowList sets the "allow_list" field.
  37183. func (m *WhatsappMutation) SetAllowList(s []string) {
  37184. m.allow_list = &s
  37185. m.appendallow_list = nil
  37186. }
  37187. // AllowList returns the value of the "allow_list" field in the mutation.
  37188. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  37189. v := m.allow_list
  37190. if v == nil {
  37191. return
  37192. }
  37193. return *v, true
  37194. }
  37195. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  37196. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37198. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  37199. if !m.op.Is(OpUpdateOne) {
  37200. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  37201. }
  37202. if m.id == nil || m.oldValue == nil {
  37203. return v, errors.New("OldAllowList requires an ID field in the mutation")
  37204. }
  37205. oldValue, err := m.oldValue(ctx)
  37206. if err != nil {
  37207. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  37208. }
  37209. return oldValue.AllowList, nil
  37210. }
  37211. // AppendAllowList adds s to the "allow_list" field.
  37212. func (m *WhatsappMutation) AppendAllowList(s []string) {
  37213. m.appendallow_list = append(m.appendallow_list, s...)
  37214. }
  37215. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  37216. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  37217. if len(m.appendallow_list) == 0 {
  37218. return nil, false
  37219. }
  37220. return m.appendallow_list, true
  37221. }
  37222. // ClearAllowList clears the value of the "allow_list" field.
  37223. func (m *WhatsappMutation) ClearAllowList() {
  37224. m.allow_list = nil
  37225. m.appendallow_list = nil
  37226. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  37227. }
  37228. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  37229. func (m *WhatsappMutation) AllowListCleared() bool {
  37230. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  37231. return ok
  37232. }
  37233. // ResetAllowList resets all changes to the "allow_list" field.
  37234. func (m *WhatsappMutation) ResetAllowList() {
  37235. m.allow_list = nil
  37236. m.appendallow_list = nil
  37237. delete(m.clearedFields, whatsapp.FieldAllowList)
  37238. }
  37239. // SetGroupAllowList sets the "group_allow_list" field.
  37240. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  37241. m.group_allow_list = &s
  37242. m.appendgroup_allow_list = nil
  37243. }
  37244. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  37245. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  37246. v := m.group_allow_list
  37247. if v == nil {
  37248. return
  37249. }
  37250. return *v, true
  37251. }
  37252. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  37253. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37255. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  37256. if !m.op.Is(OpUpdateOne) {
  37257. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  37258. }
  37259. if m.id == nil || m.oldValue == nil {
  37260. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  37261. }
  37262. oldValue, err := m.oldValue(ctx)
  37263. if err != nil {
  37264. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  37265. }
  37266. return oldValue.GroupAllowList, nil
  37267. }
  37268. // AppendGroupAllowList adds s to the "group_allow_list" field.
  37269. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  37270. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  37271. }
  37272. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  37273. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  37274. if len(m.appendgroup_allow_list) == 0 {
  37275. return nil, false
  37276. }
  37277. return m.appendgroup_allow_list, true
  37278. }
  37279. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  37280. func (m *WhatsappMutation) ClearGroupAllowList() {
  37281. m.group_allow_list = nil
  37282. m.appendgroup_allow_list = nil
  37283. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  37284. }
  37285. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  37286. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  37287. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37288. return ok
  37289. }
  37290. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37291. func (m *WhatsappMutation) ResetGroupAllowList() {
  37292. m.group_allow_list = nil
  37293. m.appendgroup_allow_list = nil
  37294. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  37295. }
  37296. // SetBlockList sets the "block_list" field.
  37297. func (m *WhatsappMutation) SetBlockList(s []string) {
  37298. m.block_list = &s
  37299. m.appendblock_list = nil
  37300. }
  37301. // BlockList returns the value of the "block_list" field in the mutation.
  37302. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  37303. v := m.block_list
  37304. if v == nil {
  37305. return
  37306. }
  37307. return *v, true
  37308. }
  37309. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  37310. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37312. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  37313. if !m.op.Is(OpUpdateOne) {
  37314. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  37315. }
  37316. if m.id == nil || m.oldValue == nil {
  37317. return v, errors.New("OldBlockList requires an ID field in the mutation")
  37318. }
  37319. oldValue, err := m.oldValue(ctx)
  37320. if err != nil {
  37321. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  37322. }
  37323. return oldValue.BlockList, nil
  37324. }
  37325. // AppendBlockList adds s to the "block_list" field.
  37326. func (m *WhatsappMutation) AppendBlockList(s []string) {
  37327. m.appendblock_list = append(m.appendblock_list, s...)
  37328. }
  37329. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  37330. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  37331. if len(m.appendblock_list) == 0 {
  37332. return nil, false
  37333. }
  37334. return m.appendblock_list, true
  37335. }
  37336. // ClearBlockList clears the value of the "block_list" field.
  37337. func (m *WhatsappMutation) ClearBlockList() {
  37338. m.block_list = nil
  37339. m.appendblock_list = nil
  37340. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  37341. }
  37342. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  37343. func (m *WhatsappMutation) BlockListCleared() bool {
  37344. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  37345. return ok
  37346. }
  37347. // ResetBlockList resets all changes to the "block_list" field.
  37348. func (m *WhatsappMutation) ResetBlockList() {
  37349. m.block_list = nil
  37350. m.appendblock_list = nil
  37351. delete(m.clearedFields, whatsapp.FieldBlockList)
  37352. }
  37353. // SetGroupBlockList sets the "group_block_list" field.
  37354. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  37355. m.group_block_list = &s
  37356. m.appendgroup_block_list = nil
  37357. }
  37358. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  37359. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  37360. v := m.group_block_list
  37361. if v == nil {
  37362. return
  37363. }
  37364. return *v, true
  37365. }
  37366. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37367. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37369. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37370. if !m.op.Is(OpUpdateOne) {
  37371. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37372. }
  37373. if m.id == nil || m.oldValue == nil {
  37374. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37375. }
  37376. oldValue, err := m.oldValue(ctx)
  37377. if err != nil {
  37378. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37379. }
  37380. return oldValue.GroupBlockList, nil
  37381. }
  37382. // AppendGroupBlockList adds s to the "group_block_list" field.
  37383. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37384. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37385. }
  37386. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37387. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37388. if len(m.appendgroup_block_list) == 0 {
  37389. return nil, false
  37390. }
  37391. return m.appendgroup_block_list, true
  37392. }
  37393. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37394. func (m *WhatsappMutation) ClearGroupBlockList() {
  37395. m.group_block_list = nil
  37396. m.appendgroup_block_list = nil
  37397. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37398. }
  37399. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37400. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37401. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37402. return ok
  37403. }
  37404. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37405. func (m *WhatsappMutation) ResetGroupBlockList() {
  37406. m.group_block_list = nil
  37407. m.appendgroup_block_list = nil
  37408. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37409. }
  37410. // ClearAgent clears the "agent" edge to the Agent entity.
  37411. func (m *WhatsappMutation) ClearAgent() {
  37412. m.clearedagent = true
  37413. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37414. }
  37415. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37416. func (m *WhatsappMutation) AgentCleared() bool {
  37417. return m.clearedagent
  37418. }
  37419. // AgentIDs returns the "agent" edge IDs in the mutation.
  37420. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37421. // AgentID instead. It exists only for internal usage by the builders.
  37422. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37423. if id := m.agent; id != nil {
  37424. ids = append(ids, *id)
  37425. }
  37426. return
  37427. }
  37428. // ResetAgent resets all changes to the "agent" edge.
  37429. func (m *WhatsappMutation) ResetAgent() {
  37430. m.agent = nil
  37431. m.clearedagent = false
  37432. }
  37433. // Where appends a list predicates to the WhatsappMutation builder.
  37434. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37435. m.predicates = append(m.predicates, ps...)
  37436. }
  37437. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37438. // users can use type-assertion to append predicates that do not depend on any generated package.
  37439. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37440. p := make([]predicate.Whatsapp, len(ps))
  37441. for i := range ps {
  37442. p[i] = ps[i]
  37443. }
  37444. m.Where(p...)
  37445. }
  37446. // Op returns the operation name.
  37447. func (m *WhatsappMutation) Op() Op {
  37448. return m.op
  37449. }
  37450. // SetOp allows setting the mutation operation.
  37451. func (m *WhatsappMutation) SetOp(op Op) {
  37452. m.op = op
  37453. }
  37454. // Type returns the node type of this mutation (Whatsapp).
  37455. func (m *WhatsappMutation) Type() string {
  37456. return m.typ
  37457. }
  37458. // Fields returns all fields that were changed during this mutation. Note that in
  37459. // order to get all numeric fields that were incremented/decremented, call
  37460. // AddedFields().
  37461. func (m *WhatsappMutation) Fields() []string {
  37462. fields := make([]string, 0, 21)
  37463. if m.created_at != nil {
  37464. fields = append(fields, whatsapp.FieldCreatedAt)
  37465. }
  37466. if m.updated_at != nil {
  37467. fields = append(fields, whatsapp.FieldUpdatedAt)
  37468. }
  37469. if m.status != nil {
  37470. fields = append(fields, whatsapp.FieldStatus)
  37471. }
  37472. if m.deleted_at != nil {
  37473. fields = append(fields, whatsapp.FieldDeletedAt)
  37474. }
  37475. if m.wa_id != nil {
  37476. fields = append(fields, whatsapp.FieldWaID)
  37477. }
  37478. if m.wa_name != nil {
  37479. fields = append(fields, whatsapp.FieldWaName)
  37480. }
  37481. if m.callback != nil {
  37482. fields = append(fields, whatsapp.FieldCallback)
  37483. }
  37484. if m.agent != nil {
  37485. fields = append(fields, whatsapp.FieldAgentID)
  37486. }
  37487. if m.account != nil {
  37488. fields = append(fields, whatsapp.FieldAccount)
  37489. }
  37490. if m.cc != nil {
  37491. fields = append(fields, whatsapp.FieldCc)
  37492. }
  37493. if m.phone != nil {
  37494. fields = append(fields, whatsapp.FieldPhone)
  37495. }
  37496. if m.cc_phone != nil {
  37497. fields = append(fields, whatsapp.FieldCcPhone)
  37498. }
  37499. if m.phone_name != nil {
  37500. fields = append(fields, whatsapp.FieldPhoneName)
  37501. }
  37502. if m.phone_status != nil {
  37503. fields = append(fields, whatsapp.FieldPhoneStatus)
  37504. }
  37505. if m.organization_id != nil {
  37506. fields = append(fields, whatsapp.FieldOrganizationID)
  37507. }
  37508. if m.api_base != nil {
  37509. fields = append(fields, whatsapp.FieldAPIBase)
  37510. }
  37511. if m.api_key != nil {
  37512. fields = append(fields, whatsapp.FieldAPIKey)
  37513. }
  37514. if m.allow_list != nil {
  37515. fields = append(fields, whatsapp.FieldAllowList)
  37516. }
  37517. if m.group_allow_list != nil {
  37518. fields = append(fields, whatsapp.FieldGroupAllowList)
  37519. }
  37520. if m.block_list != nil {
  37521. fields = append(fields, whatsapp.FieldBlockList)
  37522. }
  37523. if m.group_block_list != nil {
  37524. fields = append(fields, whatsapp.FieldGroupBlockList)
  37525. }
  37526. return fields
  37527. }
  37528. // Field returns the value of a field with the given name. The second boolean
  37529. // return value indicates that this field was not set, or was not defined in the
  37530. // schema.
  37531. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37532. switch name {
  37533. case whatsapp.FieldCreatedAt:
  37534. return m.CreatedAt()
  37535. case whatsapp.FieldUpdatedAt:
  37536. return m.UpdatedAt()
  37537. case whatsapp.FieldStatus:
  37538. return m.Status()
  37539. case whatsapp.FieldDeletedAt:
  37540. return m.DeletedAt()
  37541. case whatsapp.FieldWaID:
  37542. return m.WaID()
  37543. case whatsapp.FieldWaName:
  37544. return m.WaName()
  37545. case whatsapp.FieldCallback:
  37546. return m.Callback()
  37547. case whatsapp.FieldAgentID:
  37548. return m.AgentID()
  37549. case whatsapp.FieldAccount:
  37550. return m.Account()
  37551. case whatsapp.FieldCc:
  37552. return m.Cc()
  37553. case whatsapp.FieldPhone:
  37554. return m.Phone()
  37555. case whatsapp.FieldCcPhone:
  37556. return m.CcPhone()
  37557. case whatsapp.FieldPhoneName:
  37558. return m.PhoneName()
  37559. case whatsapp.FieldPhoneStatus:
  37560. return m.PhoneStatus()
  37561. case whatsapp.FieldOrganizationID:
  37562. return m.OrganizationID()
  37563. case whatsapp.FieldAPIBase:
  37564. return m.APIBase()
  37565. case whatsapp.FieldAPIKey:
  37566. return m.APIKey()
  37567. case whatsapp.FieldAllowList:
  37568. return m.AllowList()
  37569. case whatsapp.FieldGroupAllowList:
  37570. return m.GroupAllowList()
  37571. case whatsapp.FieldBlockList:
  37572. return m.BlockList()
  37573. case whatsapp.FieldGroupBlockList:
  37574. return m.GroupBlockList()
  37575. }
  37576. return nil, false
  37577. }
  37578. // OldField returns the old value of the field from the database. An error is
  37579. // returned if the mutation operation is not UpdateOne, or the query to the
  37580. // database failed.
  37581. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37582. switch name {
  37583. case whatsapp.FieldCreatedAt:
  37584. return m.OldCreatedAt(ctx)
  37585. case whatsapp.FieldUpdatedAt:
  37586. return m.OldUpdatedAt(ctx)
  37587. case whatsapp.FieldStatus:
  37588. return m.OldStatus(ctx)
  37589. case whatsapp.FieldDeletedAt:
  37590. return m.OldDeletedAt(ctx)
  37591. case whatsapp.FieldWaID:
  37592. return m.OldWaID(ctx)
  37593. case whatsapp.FieldWaName:
  37594. return m.OldWaName(ctx)
  37595. case whatsapp.FieldCallback:
  37596. return m.OldCallback(ctx)
  37597. case whatsapp.FieldAgentID:
  37598. return m.OldAgentID(ctx)
  37599. case whatsapp.FieldAccount:
  37600. return m.OldAccount(ctx)
  37601. case whatsapp.FieldCc:
  37602. return m.OldCc(ctx)
  37603. case whatsapp.FieldPhone:
  37604. return m.OldPhone(ctx)
  37605. case whatsapp.FieldCcPhone:
  37606. return m.OldCcPhone(ctx)
  37607. case whatsapp.FieldPhoneName:
  37608. return m.OldPhoneName(ctx)
  37609. case whatsapp.FieldPhoneStatus:
  37610. return m.OldPhoneStatus(ctx)
  37611. case whatsapp.FieldOrganizationID:
  37612. return m.OldOrganizationID(ctx)
  37613. case whatsapp.FieldAPIBase:
  37614. return m.OldAPIBase(ctx)
  37615. case whatsapp.FieldAPIKey:
  37616. return m.OldAPIKey(ctx)
  37617. case whatsapp.FieldAllowList:
  37618. return m.OldAllowList(ctx)
  37619. case whatsapp.FieldGroupAllowList:
  37620. return m.OldGroupAllowList(ctx)
  37621. case whatsapp.FieldBlockList:
  37622. return m.OldBlockList(ctx)
  37623. case whatsapp.FieldGroupBlockList:
  37624. return m.OldGroupBlockList(ctx)
  37625. }
  37626. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37627. }
  37628. // SetField sets the value of a field with the given name. It returns an error if
  37629. // the field is not defined in the schema, or if the type mismatched the field
  37630. // type.
  37631. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37632. switch name {
  37633. case whatsapp.FieldCreatedAt:
  37634. v, ok := value.(time.Time)
  37635. if !ok {
  37636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37637. }
  37638. m.SetCreatedAt(v)
  37639. return nil
  37640. case whatsapp.FieldUpdatedAt:
  37641. v, ok := value.(time.Time)
  37642. if !ok {
  37643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37644. }
  37645. m.SetUpdatedAt(v)
  37646. return nil
  37647. case whatsapp.FieldStatus:
  37648. v, ok := value.(uint8)
  37649. if !ok {
  37650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37651. }
  37652. m.SetStatus(v)
  37653. return nil
  37654. case whatsapp.FieldDeletedAt:
  37655. v, ok := value.(time.Time)
  37656. if !ok {
  37657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37658. }
  37659. m.SetDeletedAt(v)
  37660. return nil
  37661. case whatsapp.FieldWaID:
  37662. v, ok := value.(string)
  37663. if !ok {
  37664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37665. }
  37666. m.SetWaID(v)
  37667. return nil
  37668. case whatsapp.FieldWaName:
  37669. v, ok := value.(string)
  37670. if !ok {
  37671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37672. }
  37673. m.SetWaName(v)
  37674. return nil
  37675. case whatsapp.FieldCallback:
  37676. v, ok := value.(string)
  37677. if !ok {
  37678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37679. }
  37680. m.SetCallback(v)
  37681. return nil
  37682. case whatsapp.FieldAgentID:
  37683. v, ok := value.(uint64)
  37684. if !ok {
  37685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37686. }
  37687. m.SetAgentID(v)
  37688. return nil
  37689. case whatsapp.FieldAccount:
  37690. v, ok := value.(string)
  37691. if !ok {
  37692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37693. }
  37694. m.SetAccount(v)
  37695. return nil
  37696. case whatsapp.FieldCc:
  37697. v, ok := value.(string)
  37698. if !ok {
  37699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37700. }
  37701. m.SetCc(v)
  37702. return nil
  37703. case whatsapp.FieldPhone:
  37704. v, ok := value.(string)
  37705. if !ok {
  37706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37707. }
  37708. m.SetPhone(v)
  37709. return nil
  37710. case whatsapp.FieldCcPhone:
  37711. v, ok := value.(string)
  37712. if !ok {
  37713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37714. }
  37715. m.SetCcPhone(v)
  37716. return nil
  37717. case whatsapp.FieldPhoneName:
  37718. v, ok := value.(string)
  37719. if !ok {
  37720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37721. }
  37722. m.SetPhoneName(v)
  37723. return nil
  37724. case whatsapp.FieldPhoneStatus:
  37725. v, ok := value.(int8)
  37726. if !ok {
  37727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37728. }
  37729. m.SetPhoneStatus(v)
  37730. return nil
  37731. case whatsapp.FieldOrganizationID:
  37732. v, ok := value.(uint64)
  37733. if !ok {
  37734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37735. }
  37736. m.SetOrganizationID(v)
  37737. return nil
  37738. case whatsapp.FieldAPIBase:
  37739. v, ok := value.(string)
  37740. if !ok {
  37741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37742. }
  37743. m.SetAPIBase(v)
  37744. return nil
  37745. case whatsapp.FieldAPIKey:
  37746. v, ok := value.(string)
  37747. if !ok {
  37748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37749. }
  37750. m.SetAPIKey(v)
  37751. return nil
  37752. case whatsapp.FieldAllowList:
  37753. v, ok := value.([]string)
  37754. if !ok {
  37755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37756. }
  37757. m.SetAllowList(v)
  37758. return nil
  37759. case whatsapp.FieldGroupAllowList:
  37760. v, ok := value.([]string)
  37761. if !ok {
  37762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37763. }
  37764. m.SetGroupAllowList(v)
  37765. return nil
  37766. case whatsapp.FieldBlockList:
  37767. v, ok := value.([]string)
  37768. if !ok {
  37769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37770. }
  37771. m.SetBlockList(v)
  37772. return nil
  37773. case whatsapp.FieldGroupBlockList:
  37774. v, ok := value.([]string)
  37775. if !ok {
  37776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37777. }
  37778. m.SetGroupBlockList(v)
  37779. return nil
  37780. }
  37781. return fmt.Errorf("unknown Whatsapp field %s", name)
  37782. }
  37783. // AddedFields returns all numeric fields that were incremented/decremented during
  37784. // this mutation.
  37785. func (m *WhatsappMutation) AddedFields() []string {
  37786. var fields []string
  37787. if m.addstatus != nil {
  37788. fields = append(fields, whatsapp.FieldStatus)
  37789. }
  37790. if m.addphone_status != nil {
  37791. fields = append(fields, whatsapp.FieldPhoneStatus)
  37792. }
  37793. if m.addorganization_id != nil {
  37794. fields = append(fields, whatsapp.FieldOrganizationID)
  37795. }
  37796. return fields
  37797. }
  37798. // AddedField returns the numeric value that was incremented/decremented on a field
  37799. // with the given name. The second boolean return value indicates that this field
  37800. // was not set, or was not defined in the schema.
  37801. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37802. switch name {
  37803. case whatsapp.FieldStatus:
  37804. return m.AddedStatus()
  37805. case whatsapp.FieldPhoneStatus:
  37806. return m.AddedPhoneStatus()
  37807. case whatsapp.FieldOrganizationID:
  37808. return m.AddedOrganizationID()
  37809. }
  37810. return nil, false
  37811. }
  37812. // AddField adds the value to the field with the given name. It returns an error if
  37813. // the field is not defined in the schema, or if the type mismatched the field
  37814. // type.
  37815. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37816. switch name {
  37817. case whatsapp.FieldStatus:
  37818. v, ok := value.(int8)
  37819. if !ok {
  37820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37821. }
  37822. m.AddStatus(v)
  37823. return nil
  37824. case whatsapp.FieldPhoneStatus:
  37825. v, ok := value.(int8)
  37826. if !ok {
  37827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37828. }
  37829. m.AddPhoneStatus(v)
  37830. return nil
  37831. case whatsapp.FieldOrganizationID:
  37832. v, ok := value.(int64)
  37833. if !ok {
  37834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37835. }
  37836. m.AddOrganizationID(v)
  37837. return nil
  37838. }
  37839. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37840. }
  37841. // ClearedFields returns all nullable fields that were cleared during this
  37842. // mutation.
  37843. func (m *WhatsappMutation) ClearedFields() []string {
  37844. var fields []string
  37845. if m.FieldCleared(whatsapp.FieldStatus) {
  37846. fields = append(fields, whatsapp.FieldStatus)
  37847. }
  37848. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37849. fields = append(fields, whatsapp.FieldDeletedAt)
  37850. }
  37851. if m.FieldCleared(whatsapp.FieldWaID) {
  37852. fields = append(fields, whatsapp.FieldWaID)
  37853. }
  37854. if m.FieldCleared(whatsapp.FieldWaName) {
  37855. fields = append(fields, whatsapp.FieldWaName)
  37856. }
  37857. if m.FieldCleared(whatsapp.FieldCallback) {
  37858. fields = append(fields, whatsapp.FieldCallback)
  37859. }
  37860. if m.FieldCleared(whatsapp.FieldAccount) {
  37861. fields = append(fields, whatsapp.FieldAccount)
  37862. }
  37863. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37864. fields = append(fields, whatsapp.FieldOrganizationID)
  37865. }
  37866. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37867. fields = append(fields, whatsapp.FieldAPIBase)
  37868. }
  37869. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37870. fields = append(fields, whatsapp.FieldAPIKey)
  37871. }
  37872. if m.FieldCleared(whatsapp.FieldAllowList) {
  37873. fields = append(fields, whatsapp.FieldAllowList)
  37874. }
  37875. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37876. fields = append(fields, whatsapp.FieldGroupAllowList)
  37877. }
  37878. if m.FieldCleared(whatsapp.FieldBlockList) {
  37879. fields = append(fields, whatsapp.FieldBlockList)
  37880. }
  37881. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37882. fields = append(fields, whatsapp.FieldGroupBlockList)
  37883. }
  37884. return fields
  37885. }
  37886. // FieldCleared returns a boolean indicating if a field with the given name was
  37887. // cleared in this mutation.
  37888. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37889. _, ok := m.clearedFields[name]
  37890. return ok
  37891. }
  37892. // ClearField clears the value of the field with the given name. It returns an
  37893. // error if the field is not defined in the schema.
  37894. func (m *WhatsappMutation) ClearField(name string) error {
  37895. switch name {
  37896. case whatsapp.FieldStatus:
  37897. m.ClearStatus()
  37898. return nil
  37899. case whatsapp.FieldDeletedAt:
  37900. m.ClearDeletedAt()
  37901. return nil
  37902. case whatsapp.FieldWaID:
  37903. m.ClearWaID()
  37904. return nil
  37905. case whatsapp.FieldWaName:
  37906. m.ClearWaName()
  37907. return nil
  37908. case whatsapp.FieldCallback:
  37909. m.ClearCallback()
  37910. return nil
  37911. case whatsapp.FieldAccount:
  37912. m.ClearAccount()
  37913. return nil
  37914. case whatsapp.FieldOrganizationID:
  37915. m.ClearOrganizationID()
  37916. return nil
  37917. case whatsapp.FieldAPIBase:
  37918. m.ClearAPIBase()
  37919. return nil
  37920. case whatsapp.FieldAPIKey:
  37921. m.ClearAPIKey()
  37922. return nil
  37923. case whatsapp.FieldAllowList:
  37924. m.ClearAllowList()
  37925. return nil
  37926. case whatsapp.FieldGroupAllowList:
  37927. m.ClearGroupAllowList()
  37928. return nil
  37929. case whatsapp.FieldBlockList:
  37930. m.ClearBlockList()
  37931. return nil
  37932. case whatsapp.FieldGroupBlockList:
  37933. m.ClearGroupBlockList()
  37934. return nil
  37935. }
  37936. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37937. }
  37938. // ResetField resets all changes in the mutation for the field with the given name.
  37939. // It returns an error if the field is not defined in the schema.
  37940. func (m *WhatsappMutation) ResetField(name string) error {
  37941. switch name {
  37942. case whatsapp.FieldCreatedAt:
  37943. m.ResetCreatedAt()
  37944. return nil
  37945. case whatsapp.FieldUpdatedAt:
  37946. m.ResetUpdatedAt()
  37947. return nil
  37948. case whatsapp.FieldStatus:
  37949. m.ResetStatus()
  37950. return nil
  37951. case whatsapp.FieldDeletedAt:
  37952. m.ResetDeletedAt()
  37953. return nil
  37954. case whatsapp.FieldWaID:
  37955. m.ResetWaID()
  37956. return nil
  37957. case whatsapp.FieldWaName:
  37958. m.ResetWaName()
  37959. return nil
  37960. case whatsapp.FieldCallback:
  37961. m.ResetCallback()
  37962. return nil
  37963. case whatsapp.FieldAgentID:
  37964. m.ResetAgentID()
  37965. return nil
  37966. case whatsapp.FieldAccount:
  37967. m.ResetAccount()
  37968. return nil
  37969. case whatsapp.FieldCc:
  37970. m.ResetCc()
  37971. return nil
  37972. case whatsapp.FieldPhone:
  37973. m.ResetPhone()
  37974. return nil
  37975. case whatsapp.FieldCcPhone:
  37976. m.ResetCcPhone()
  37977. return nil
  37978. case whatsapp.FieldPhoneName:
  37979. m.ResetPhoneName()
  37980. return nil
  37981. case whatsapp.FieldPhoneStatus:
  37982. m.ResetPhoneStatus()
  37983. return nil
  37984. case whatsapp.FieldOrganizationID:
  37985. m.ResetOrganizationID()
  37986. return nil
  37987. case whatsapp.FieldAPIBase:
  37988. m.ResetAPIBase()
  37989. return nil
  37990. case whatsapp.FieldAPIKey:
  37991. m.ResetAPIKey()
  37992. return nil
  37993. case whatsapp.FieldAllowList:
  37994. m.ResetAllowList()
  37995. return nil
  37996. case whatsapp.FieldGroupAllowList:
  37997. m.ResetGroupAllowList()
  37998. return nil
  37999. case whatsapp.FieldBlockList:
  38000. m.ResetBlockList()
  38001. return nil
  38002. case whatsapp.FieldGroupBlockList:
  38003. m.ResetGroupBlockList()
  38004. return nil
  38005. }
  38006. return fmt.Errorf("unknown Whatsapp field %s", name)
  38007. }
  38008. // AddedEdges returns all edge names that were set/added in this mutation.
  38009. func (m *WhatsappMutation) AddedEdges() []string {
  38010. edges := make([]string, 0, 1)
  38011. if m.agent != nil {
  38012. edges = append(edges, whatsapp.EdgeAgent)
  38013. }
  38014. return edges
  38015. }
  38016. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38017. // name in this mutation.
  38018. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  38019. switch name {
  38020. case whatsapp.EdgeAgent:
  38021. if id := m.agent; id != nil {
  38022. return []ent.Value{*id}
  38023. }
  38024. }
  38025. return nil
  38026. }
  38027. // RemovedEdges returns all edge names that were removed in this mutation.
  38028. func (m *WhatsappMutation) RemovedEdges() []string {
  38029. edges := make([]string, 0, 1)
  38030. return edges
  38031. }
  38032. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38033. // the given name in this mutation.
  38034. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  38035. return nil
  38036. }
  38037. // ClearedEdges returns all edge names that were cleared in this mutation.
  38038. func (m *WhatsappMutation) ClearedEdges() []string {
  38039. edges := make([]string, 0, 1)
  38040. if m.clearedagent {
  38041. edges = append(edges, whatsapp.EdgeAgent)
  38042. }
  38043. return edges
  38044. }
  38045. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38046. // was cleared in this mutation.
  38047. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  38048. switch name {
  38049. case whatsapp.EdgeAgent:
  38050. return m.clearedagent
  38051. }
  38052. return false
  38053. }
  38054. // ClearEdge clears the value of the edge with the given name. It returns an error
  38055. // if that edge is not defined in the schema.
  38056. func (m *WhatsappMutation) ClearEdge(name string) error {
  38057. switch name {
  38058. case whatsapp.EdgeAgent:
  38059. m.ClearAgent()
  38060. return nil
  38061. }
  38062. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  38063. }
  38064. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38065. // It returns an error if the edge is not defined in the schema.
  38066. func (m *WhatsappMutation) ResetEdge(name string) error {
  38067. switch name {
  38068. case whatsapp.EdgeAgent:
  38069. m.ResetAgent()
  38070. return nil
  38071. }
  38072. return fmt.Errorf("unknown Whatsapp edge %s", name)
  38073. }
  38074. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  38075. type WhatsappChannelMutation struct {
  38076. config
  38077. op Op
  38078. typ string
  38079. id *uint64
  38080. created_at *time.Time
  38081. updated_at *time.Time
  38082. status *uint8
  38083. addstatus *int8
  38084. deleted_at *time.Time
  38085. ak *string
  38086. sk *string
  38087. wa_id *string
  38088. wa_name *string
  38089. waba_id *uint64
  38090. addwaba_id *int64
  38091. business_id *uint64
  38092. addbusiness_id *int64
  38093. organization_id *uint64
  38094. addorganization_id *int64
  38095. verify_account *string
  38096. clearedFields map[string]struct{}
  38097. done bool
  38098. oldValue func(context.Context) (*WhatsappChannel, error)
  38099. predicates []predicate.WhatsappChannel
  38100. }
  38101. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  38102. // whatsappchannelOption allows management of the mutation configuration using functional options.
  38103. type whatsappchannelOption func(*WhatsappChannelMutation)
  38104. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  38105. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  38106. m := &WhatsappChannelMutation{
  38107. config: c,
  38108. op: op,
  38109. typ: TypeWhatsappChannel,
  38110. clearedFields: make(map[string]struct{}),
  38111. }
  38112. for _, opt := range opts {
  38113. opt(m)
  38114. }
  38115. return m
  38116. }
  38117. // withWhatsappChannelID sets the ID field of the mutation.
  38118. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  38119. return func(m *WhatsappChannelMutation) {
  38120. var (
  38121. err error
  38122. once sync.Once
  38123. value *WhatsappChannel
  38124. )
  38125. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  38126. once.Do(func() {
  38127. if m.done {
  38128. err = errors.New("querying old values post mutation is not allowed")
  38129. } else {
  38130. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  38131. }
  38132. })
  38133. return value, err
  38134. }
  38135. m.id = &id
  38136. }
  38137. }
  38138. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  38139. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  38140. return func(m *WhatsappChannelMutation) {
  38141. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  38142. return node, nil
  38143. }
  38144. m.id = &node.ID
  38145. }
  38146. }
  38147. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38148. // executed in a transaction (ent.Tx), a transactional client is returned.
  38149. func (m WhatsappChannelMutation) Client() *Client {
  38150. client := &Client{config: m.config}
  38151. client.init()
  38152. return client
  38153. }
  38154. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38155. // it returns an error otherwise.
  38156. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  38157. if _, ok := m.driver.(*txDriver); !ok {
  38158. return nil, errors.New("ent: mutation is not running in a transaction")
  38159. }
  38160. tx := &Tx{config: m.config}
  38161. tx.init()
  38162. return tx, nil
  38163. }
  38164. // SetID sets the value of the id field. Note that this
  38165. // operation is only accepted on creation of WhatsappChannel entities.
  38166. func (m *WhatsappChannelMutation) SetID(id uint64) {
  38167. m.id = &id
  38168. }
  38169. // ID returns the ID value in the mutation. Note that the ID is only available
  38170. // if it was provided to the builder or after it was returned from the database.
  38171. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  38172. if m.id == nil {
  38173. return
  38174. }
  38175. return *m.id, true
  38176. }
  38177. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38178. // That means, if the mutation is applied within a transaction with an isolation level such
  38179. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38180. // or updated by the mutation.
  38181. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  38182. switch {
  38183. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38184. id, exists := m.ID()
  38185. if exists {
  38186. return []uint64{id}, nil
  38187. }
  38188. fallthrough
  38189. case m.op.Is(OpUpdate | OpDelete):
  38190. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  38191. default:
  38192. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38193. }
  38194. }
  38195. // SetCreatedAt sets the "created_at" field.
  38196. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  38197. m.created_at = &t
  38198. }
  38199. // CreatedAt returns the value of the "created_at" field in the mutation.
  38200. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  38201. v := m.created_at
  38202. if v == nil {
  38203. return
  38204. }
  38205. return *v, true
  38206. }
  38207. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  38208. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38210. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38211. if !m.op.Is(OpUpdateOne) {
  38212. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38213. }
  38214. if m.id == nil || m.oldValue == nil {
  38215. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38216. }
  38217. oldValue, err := m.oldValue(ctx)
  38218. if err != nil {
  38219. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38220. }
  38221. return oldValue.CreatedAt, nil
  38222. }
  38223. // ResetCreatedAt resets all changes to the "created_at" field.
  38224. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  38225. m.created_at = nil
  38226. }
  38227. // SetUpdatedAt sets the "updated_at" field.
  38228. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  38229. m.updated_at = &t
  38230. }
  38231. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38232. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  38233. v := m.updated_at
  38234. if v == nil {
  38235. return
  38236. }
  38237. return *v, true
  38238. }
  38239. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  38240. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38242. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38243. if !m.op.Is(OpUpdateOne) {
  38244. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38245. }
  38246. if m.id == nil || m.oldValue == nil {
  38247. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38248. }
  38249. oldValue, err := m.oldValue(ctx)
  38250. if err != nil {
  38251. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38252. }
  38253. return oldValue.UpdatedAt, nil
  38254. }
  38255. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38256. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  38257. m.updated_at = nil
  38258. }
  38259. // SetStatus sets the "status" field.
  38260. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  38261. m.status = &u
  38262. m.addstatus = nil
  38263. }
  38264. // Status returns the value of the "status" field in the mutation.
  38265. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  38266. v := m.status
  38267. if v == nil {
  38268. return
  38269. }
  38270. return *v, true
  38271. }
  38272. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  38273. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38275. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38276. if !m.op.Is(OpUpdateOne) {
  38277. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38278. }
  38279. if m.id == nil || m.oldValue == nil {
  38280. return v, errors.New("OldStatus requires an ID field in the mutation")
  38281. }
  38282. oldValue, err := m.oldValue(ctx)
  38283. if err != nil {
  38284. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38285. }
  38286. return oldValue.Status, nil
  38287. }
  38288. // AddStatus adds u to the "status" field.
  38289. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38290. if m.addstatus != nil {
  38291. *m.addstatus += u
  38292. } else {
  38293. m.addstatus = &u
  38294. }
  38295. }
  38296. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38297. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  38298. v := m.addstatus
  38299. if v == nil {
  38300. return
  38301. }
  38302. return *v, true
  38303. }
  38304. // ClearStatus clears the value of the "status" field.
  38305. func (m *WhatsappChannelMutation) ClearStatus() {
  38306. m.status = nil
  38307. m.addstatus = nil
  38308. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  38309. }
  38310. // StatusCleared returns if the "status" field was cleared in this mutation.
  38311. func (m *WhatsappChannelMutation) StatusCleared() bool {
  38312. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  38313. return ok
  38314. }
  38315. // ResetStatus resets all changes to the "status" field.
  38316. func (m *WhatsappChannelMutation) ResetStatus() {
  38317. m.status = nil
  38318. m.addstatus = nil
  38319. delete(m.clearedFields, whatsappchannel.FieldStatus)
  38320. }
  38321. // SetDeletedAt sets the "deleted_at" field.
  38322. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  38323. m.deleted_at = &t
  38324. }
  38325. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38326. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  38327. v := m.deleted_at
  38328. if v == nil {
  38329. return
  38330. }
  38331. return *v, true
  38332. }
  38333. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  38334. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38336. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38337. if !m.op.Is(OpUpdateOne) {
  38338. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38339. }
  38340. if m.id == nil || m.oldValue == nil {
  38341. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38342. }
  38343. oldValue, err := m.oldValue(ctx)
  38344. if err != nil {
  38345. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38346. }
  38347. return oldValue.DeletedAt, nil
  38348. }
  38349. // ClearDeletedAt clears the value of the "deleted_at" field.
  38350. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  38351. m.deleted_at = nil
  38352. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  38353. }
  38354. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38355. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  38356. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  38357. return ok
  38358. }
  38359. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38360. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  38361. m.deleted_at = nil
  38362. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  38363. }
  38364. // SetAk sets the "ak" field.
  38365. func (m *WhatsappChannelMutation) SetAk(s string) {
  38366. m.ak = &s
  38367. }
  38368. // Ak returns the value of the "ak" field in the mutation.
  38369. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38370. v := m.ak
  38371. if v == nil {
  38372. return
  38373. }
  38374. return *v, true
  38375. }
  38376. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38377. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38379. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38380. if !m.op.Is(OpUpdateOne) {
  38381. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38382. }
  38383. if m.id == nil || m.oldValue == nil {
  38384. return v, errors.New("OldAk requires an ID field in the mutation")
  38385. }
  38386. oldValue, err := m.oldValue(ctx)
  38387. if err != nil {
  38388. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38389. }
  38390. return oldValue.Ak, nil
  38391. }
  38392. // ClearAk clears the value of the "ak" field.
  38393. func (m *WhatsappChannelMutation) ClearAk() {
  38394. m.ak = nil
  38395. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38396. }
  38397. // AkCleared returns if the "ak" field was cleared in this mutation.
  38398. func (m *WhatsappChannelMutation) AkCleared() bool {
  38399. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38400. return ok
  38401. }
  38402. // ResetAk resets all changes to the "ak" field.
  38403. func (m *WhatsappChannelMutation) ResetAk() {
  38404. m.ak = nil
  38405. delete(m.clearedFields, whatsappchannel.FieldAk)
  38406. }
  38407. // SetSk sets the "sk" field.
  38408. func (m *WhatsappChannelMutation) SetSk(s string) {
  38409. m.sk = &s
  38410. }
  38411. // Sk returns the value of the "sk" field in the mutation.
  38412. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38413. v := m.sk
  38414. if v == nil {
  38415. return
  38416. }
  38417. return *v, true
  38418. }
  38419. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38420. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38422. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38423. if !m.op.Is(OpUpdateOne) {
  38424. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38425. }
  38426. if m.id == nil || m.oldValue == nil {
  38427. return v, errors.New("OldSk requires an ID field in the mutation")
  38428. }
  38429. oldValue, err := m.oldValue(ctx)
  38430. if err != nil {
  38431. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38432. }
  38433. return oldValue.Sk, nil
  38434. }
  38435. // ResetSk resets all changes to the "sk" field.
  38436. func (m *WhatsappChannelMutation) ResetSk() {
  38437. m.sk = nil
  38438. }
  38439. // SetWaID sets the "wa_id" field.
  38440. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38441. m.wa_id = &s
  38442. }
  38443. // WaID returns the value of the "wa_id" field in the mutation.
  38444. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38445. v := m.wa_id
  38446. if v == nil {
  38447. return
  38448. }
  38449. return *v, true
  38450. }
  38451. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38452. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38454. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38455. if !m.op.Is(OpUpdateOne) {
  38456. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38457. }
  38458. if m.id == nil || m.oldValue == nil {
  38459. return v, errors.New("OldWaID requires an ID field in the mutation")
  38460. }
  38461. oldValue, err := m.oldValue(ctx)
  38462. if err != nil {
  38463. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38464. }
  38465. return oldValue.WaID, nil
  38466. }
  38467. // ClearWaID clears the value of the "wa_id" field.
  38468. func (m *WhatsappChannelMutation) ClearWaID() {
  38469. m.wa_id = nil
  38470. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38471. }
  38472. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38473. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38474. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38475. return ok
  38476. }
  38477. // ResetWaID resets all changes to the "wa_id" field.
  38478. func (m *WhatsappChannelMutation) ResetWaID() {
  38479. m.wa_id = nil
  38480. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38481. }
  38482. // SetWaName sets the "wa_name" field.
  38483. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38484. m.wa_name = &s
  38485. }
  38486. // WaName returns the value of the "wa_name" field in the mutation.
  38487. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38488. v := m.wa_name
  38489. if v == nil {
  38490. return
  38491. }
  38492. return *v, true
  38493. }
  38494. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38495. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38497. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38498. if !m.op.Is(OpUpdateOne) {
  38499. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38500. }
  38501. if m.id == nil || m.oldValue == nil {
  38502. return v, errors.New("OldWaName requires an ID field in the mutation")
  38503. }
  38504. oldValue, err := m.oldValue(ctx)
  38505. if err != nil {
  38506. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38507. }
  38508. return oldValue.WaName, nil
  38509. }
  38510. // ClearWaName clears the value of the "wa_name" field.
  38511. func (m *WhatsappChannelMutation) ClearWaName() {
  38512. m.wa_name = nil
  38513. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38514. }
  38515. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38516. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38517. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38518. return ok
  38519. }
  38520. // ResetWaName resets all changes to the "wa_name" field.
  38521. func (m *WhatsappChannelMutation) ResetWaName() {
  38522. m.wa_name = nil
  38523. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38524. }
  38525. // SetWabaID sets the "waba_id" field.
  38526. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38527. m.waba_id = &u
  38528. m.addwaba_id = nil
  38529. }
  38530. // WabaID returns the value of the "waba_id" field in the mutation.
  38531. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38532. v := m.waba_id
  38533. if v == nil {
  38534. return
  38535. }
  38536. return *v, true
  38537. }
  38538. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38539. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38541. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38542. if !m.op.Is(OpUpdateOne) {
  38543. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38544. }
  38545. if m.id == nil || m.oldValue == nil {
  38546. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38547. }
  38548. oldValue, err := m.oldValue(ctx)
  38549. if err != nil {
  38550. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38551. }
  38552. return oldValue.WabaID, nil
  38553. }
  38554. // AddWabaID adds u to the "waba_id" field.
  38555. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38556. if m.addwaba_id != nil {
  38557. *m.addwaba_id += u
  38558. } else {
  38559. m.addwaba_id = &u
  38560. }
  38561. }
  38562. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38563. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38564. v := m.addwaba_id
  38565. if v == nil {
  38566. return
  38567. }
  38568. return *v, true
  38569. }
  38570. // ResetWabaID resets all changes to the "waba_id" field.
  38571. func (m *WhatsappChannelMutation) ResetWabaID() {
  38572. m.waba_id = nil
  38573. m.addwaba_id = nil
  38574. }
  38575. // SetBusinessID sets the "business_id" field.
  38576. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38577. m.business_id = &u
  38578. m.addbusiness_id = nil
  38579. }
  38580. // BusinessID returns the value of the "business_id" field in the mutation.
  38581. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38582. v := m.business_id
  38583. if v == nil {
  38584. return
  38585. }
  38586. return *v, true
  38587. }
  38588. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38589. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38591. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38592. if !m.op.Is(OpUpdateOne) {
  38593. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38594. }
  38595. if m.id == nil || m.oldValue == nil {
  38596. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38597. }
  38598. oldValue, err := m.oldValue(ctx)
  38599. if err != nil {
  38600. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38601. }
  38602. return oldValue.BusinessID, nil
  38603. }
  38604. // AddBusinessID adds u to the "business_id" field.
  38605. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38606. if m.addbusiness_id != nil {
  38607. *m.addbusiness_id += u
  38608. } else {
  38609. m.addbusiness_id = &u
  38610. }
  38611. }
  38612. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38613. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38614. v := m.addbusiness_id
  38615. if v == nil {
  38616. return
  38617. }
  38618. return *v, true
  38619. }
  38620. // ResetBusinessID resets all changes to the "business_id" field.
  38621. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38622. m.business_id = nil
  38623. m.addbusiness_id = nil
  38624. }
  38625. // SetOrganizationID sets the "organization_id" field.
  38626. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38627. m.organization_id = &u
  38628. m.addorganization_id = nil
  38629. }
  38630. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38631. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38632. v := m.organization_id
  38633. if v == nil {
  38634. return
  38635. }
  38636. return *v, true
  38637. }
  38638. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38639. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38641. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38642. if !m.op.Is(OpUpdateOne) {
  38643. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38644. }
  38645. if m.id == nil || m.oldValue == nil {
  38646. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38647. }
  38648. oldValue, err := m.oldValue(ctx)
  38649. if err != nil {
  38650. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38651. }
  38652. return oldValue.OrganizationID, nil
  38653. }
  38654. // AddOrganizationID adds u to the "organization_id" field.
  38655. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38656. if m.addorganization_id != nil {
  38657. *m.addorganization_id += u
  38658. } else {
  38659. m.addorganization_id = &u
  38660. }
  38661. }
  38662. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38663. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38664. v := m.addorganization_id
  38665. if v == nil {
  38666. return
  38667. }
  38668. return *v, true
  38669. }
  38670. // ClearOrganizationID clears the value of the "organization_id" field.
  38671. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38672. m.organization_id = nil
  38673. m.addorganization_id = nil
  38674. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38675. }
  38676. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38677. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38678. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38679. return ok
  38680. }
  38681. // ResetOrganizationID resets all changes to the "organization_id" field.
  38682. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38683. m.organization_id = nil
  38684. m.addorganization_id = nil
  38685. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38686. }
  38687. // SetVerifyAccount sets the "verify_account" field.
  38688. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38689. m.verify_account = &s
  38690. }
  38691. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38692. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38693. v := m.verify_account
  38694. if v == nil {
  38695. return
  38696. }
  38697. return *v, true
  38698. }
  38699. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38700. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38702. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38703. if !m.op.Is(OpUpdateOne) {
  38704. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38705. }
  38706. if m.id == nil || m.oldValue == nil {
  38707. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38708. }
  38709. oldValue, err := m.oldValue(ctx)
  38710. if err != nil {
  38711. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38712. }
  38713. return oldValue.VerifyAccount, nil
  38714. }
  38715. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38716. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38717. m.verify_account = nil
  38718. }
  38719. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38720. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38721. m.predicates = append(m.predicates, ps...)
  38722. }
  38723. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38724. // users can use type-assertion to append predicates that do not depend on any generated package.
  38725. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38726. p := make([]predicate.WhatsappChannel, len(ps))
  38727. for i := range ps {
  38728. p[i] = ps[i]
  38729. }
  38730. m.Where(p...)
  38731. }
  38732. // Op returns the operation name.
  38733. func (m *WhatsappChannelMutation) Op() Op {
  38734. return m.op
  38735. }
  38736. // SetOp allows setting the mutation operation.
  38737. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38738. m.op = op
  38739. }
  38740. // Type returns the node type of this mutation (WhatsappChannel).
  38741. func (m *WhatsappChannelMutation) Type() string {
  38742. return m.typ
  38743. }
  38744. // Fields returns all fields that were changed during this mutation. Note that in
  38745. // order to get all numeric fields that were incremented/decremented, call
  38746. // AddedFields().
  38747. func (m *WhatsappChannelMutation) Fields() []string {
  38748. fields := make([]string, 0, 12)
  38749. if m.created_at != nil {
  38750. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38751. }
  38752. if m.updated_at != nil {
  38753. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38754. }
  38755. if m.status != nil {
  38756. fields = append(fields, whatsappchannel.FieldStatus)
  38757. }
  38758. if m.deleted_at != nil {
  38759. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38760. }
  38761. if m.ak != nil {
  38762. fields = append(fields, whatsappchannel.FieldAk)
  38763. }
  38764. if m.sk != nil {
  38765. fields = append(fields, whatsappchannel.FieldSk)
  38766. }
  38767. if m.wa_id != nil {
  38768. fields = append(fields, whatsappchannel.FieldWaID)
  38769. }
  38770. if m.wa_name != nil {
  38771. fields = append(fields, whatsappchannel.FieldWaName)
  38772. }
  38773. if m.waba_id != nil {
  38774. fields = append(fields, whatsappchannel.FieldWabaID)
  38775. }
  38776. if m.business_id != nil {
  38777. fields = append(fields, whatsappchannel.FieldBusinessID)
  38778. }
  38779. if m.organization_id != nil {
  38780. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38781. }
  38782. if m.verify_account != nil {
  38783. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38784. }
  38785. return fields
  38786. }
  38787. // Field returns the value of a field with the given name. The second boolean
  38788. // return value indicates that this field was not set, or was not defined in the
  38789. // schema.
  38790. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38791. switch name {
  38792. case whatsappchannel.FieldCreatedAt:
  38793. return m.CreatedAt()
  38794. case whatsappchannel.FieldUpdatedAt:
  38795. return m.UpdatedAt()
  38796. case whatsappchannel.FieldStatus:
  38797. return m.Status()
  38798. case whatsappchannel.FieldDeletedAt:
  38799. return m.DeletedAt()
  38800. case whatsappchannel.FieldAk:
  38801. return m.Ak()
  38802. case whatsappchannel.FieldSk:
  38803. return m.Sk()
  38804. case whatsappchannel.FieldWaID:
  38805. return m.WaID()
  38806. case whatsappchannel.FieldWaName:
  38807. return m.WaName()
  38808. case whatsappchannel.FieldWabaID:
  38809. return m.WabaID()
  38810. case whatsappchannel.FieldBusinessID:
  38811. return m.BusinessID()
  38812. case whatsappchannel.FieldOrganizationID:
  38813. return m.OrganizationID()
  38814. case whatsappchannel.FieldVerifyAccount:
  38815. return m.VerifyAccount()
  38816. }
  38817. return nil, false
  38818. }
  38819. // OldField returns the old value of the field from the database. An error is
  38820. // returned if the mutation operation is not UpdateOne, or the query to the
  38821. // database failed.
  38822. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38823. switch name {
  38824. case whatsappchannel.FieldCreatedAt:
  38825. return m.OldCreatedAt(ctx)
  38826. case whatsappchannel.FieldUpdatedAt:
  38827. return m.OldUpdatedAt(ctx)
  38828. case whatsappchannel.FieldStatus:
  38829. return m.OldStatus(ctx)
  38830. case whatsappchannel.FieldDeletedAt:
  38831. return m.OldDeletedAt(ctx)
  38832. case whatsappchannel.FieldAk:
  38833. return m.OldAk(ctx)
  38834. case whatsappchannel.FieldSk:
  38835. return m.OldSk(ctx)
  38836. case whatsappchannel.FieldWaID:
  38837. return m.OldWaID(ctx)
  38838. case whatsappchannel.FieldWaName:
  38839. return m.OldWaName(ctx)
  38840. case whatsappchannel.FieldWabaID:
  38841. return m.OldWabaID(ctx)
  38842. case whatsappchannel.FieldBusinessID:
  38843. return m.OldBusinessID(ctx)
  38844. case whatsappchannel.FieldOrganizationID:
  38845. return m.OldOrganizationID(ctx)
  38846. case whatsappchannel.FieldVerifyAccount:
  38847. return m.OldVerifyAccount(ctx)
  38848. }
  38849. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38850. }
  38851. // SetField sets the value of a field with the given name. It returns an error if
  38852. // the field is not defined in the schema, or if the type mismatched the field
  38853. // type.
  38854. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38855. switch name {
  38856. case whatsappchannel.FieldCreatedAt:
  38857. v, ok := value.(time.Time)
  38858. if !ok {
  38859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38860. }
  38861. m.SetCreatedAt(v)
  38862. return nil
  38863. case whatsappchannel.FieldUpdatedAt:
  38864. v, ok := value.(time.Time)
  38865. if !ok {
  38866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38867. }
  38868. m.SetUpdatedAt(v)
  38869. return nil
  38870. case whatsappchannel.FieldStatus:
  38871. v, ok := value.(uint8)
  38872. if !ok {
  38873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38874. }
  38875. m.SetStatus(v)
  38876. return nil
  38877. case whatsappchannel.FieldDeletedAt:
  38878. v, ok := value.(time.Time)
  38879. if !ok {
  38880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38881. }
  38882. m.SetDeletedAt(v)
  38883. return nil
  38884. case whatsappchannel.FieldAk:
  38885. v, ok := value.(string)
  38886. if !ok {
  38887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38888. }
  38889. m.SetAk(v)
  38890. return nil
  38891. case whatsappchannel.FieldSk:
  38892. v, ok := value.(string)
  38893. if !ok {
  38894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38895. }
  38896. m.SetSk(v)
  38897. return nil
  38898. case whatsappchannel.FieldWaID:
  38899. v, ok := value.(string)
  38900. if !ok {
  38901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38902. }
  38903. m.SetWaID(v)
  38904. return nil
  38905. case whatsappchannel.FieldWaName:
  38906. v, ok := value.(string)
  38907. if !ok {
  38908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38909. }
  38910. m.SetWaName(v)
  38911. return nil
  38912. case whatsappchannel.FieldWabaID:
  38913. v, ok := value.(uint64)
  38914. if !ok {
  38915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38916. }
  38917. m.SetWabaID(v)
  38918. return nil
  38919. case whatsappchannel.FieldBusinessID:
  38920. v, ok := value.(uint64)
  38921. if !ok {
  38922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38923. }
  38924. m.SetBusinessID(v)
  38925. return nil
  38926. case whatsappchannel.FieldOrganizationID:
  38927. v, ok := value.(uint64)
  38928. if !ok {
  38929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38930. }
  38931. m.SetOrganizationID(v)
  38932. return nil
  38933. case whatsappchannel.FieldVerifyAccount:
  38934. v, ok := value.(string)
  38935. if !ok {
  38936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38937. }
  38938. m.SetVerifyAccount(v)
  38939. return nil
  38940. }
  38941. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38942. }
  38943. // AddedFields returns all numeric fields that were incremented/decremented during
  38944. // this mutation.
  38945. func (m *WhatsappChannelMutation) AddedFields() []string {
  38946. var fields []string
  38947. if m.addstatus != nil {
  38948. fields = append(fields, whatsappchannel.FieldStatus)
  38949. }
  38950. if m.addwaba_id != nil {
  38951. fields = append(fields, whatsappchannel.FieldWabaID)
  38952. }
  38953. if m.addbusiness_id != nil {
  38954. fields = append(fields, whatsappchannel.FieldBusinessID)
  38955. }
  38956. if m.addorganization_id != nil {
  38957. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38958. }
  38959. return fields
  38960. }
  38961. // AddedField returns the numeric value that was incremented/decremented on a field
  38962. // with the given name. The second boolean return value indicates that this field
  38963. // was not set, or was not defined in the schema.
  38964. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38965. switch name {
  38966. case whatsappchannel.FieldStatus:
  38967. return m.AddedStatus()
  38968. case whatsappchannel.FieldWabaID:
  38969. return m.AddedWabaID()
  38970. case whatsappchannel.FieldBusinessID:
  38971. return m.AddedBusinessID()
  38972. case whatsappchannel.FieldOrganizationID:
  38973. return m.AddedOrganizationID()
  38974. }
  38975. return nil, false
  38976. }
  38977. // AddField adds the value to the field with the given name. It returns an error if
  38978. // the field is not defined in the schema, or if the type mismatched the field
  38979. // type.
  38980. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38981. switch name {
  38982. case whatsappchannel.FieldStatus:
  38983. v, ok := value.(int8)
  38984. if !ok {
  38985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38986. }
  38987. m.AddStatus(v)
  38988. return nil
  38989. case whatsappchannel.FieldWabaID:
  38990. v, ok := value.(int64)
  38991. if !ok {
  38992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38993. }
  38994. m.AddWabaID(v)
  38995. return nil
  38996. case whatsappchannel.FieldBusinessID:
  38997. v, ok := value.(int64)
  38998. if !ok {
  38999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39000. }
  39001. m.AddBusinessID(v)
  39002. return nil
  39003. case whatsappchannel.FieldOrganizationID:
  39004. v, ok := value.(int64)
  39005. if !ok {
  39006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39007. }
  39008. m.AddOrganizationID(v)
  39009. return nil
  39010. }
  39011. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  39012. }
  39013. // ClearedFields returns all nullable fields that were cleared during this
  39014. // mutation.
  39015. func (m *WhatsappChannelMutation) ClearedFields() []string {
  39016. var fields []string
  39017. if m.FieldCleared(whatsappchannel.FieldStatus) {
  39018. fields = append(fields, whatsappchannel.FieldStatus)
  39019. }
  39020. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  39021. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39022. }
  39023. if m.FieldCleared(whatsappchannel.FieldAk) {
  39024. fields = append(fields, whatsappchannel.FieldAk)
  39025. }
  39026. if m.FieldCleared(whatsappchannel.FieldWaID) {
  39027. fields = append(fields, whatsappchannel.FieldWaID)
  39028. }
  39029. if m.FieldCleared(whatsappchannel.FieldWaName) {
  39030. fields = append(fields, whatsappchannel.FieldWaName)
  39031. }
  39032. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  39033. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39034. }
  39035. return fields
  39036. }
  39037. // FieldCleared returns a boolean indicating if a field with the given name was
  39038. // cleared in this mutation.
  39039. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  39040. _, ok := m.clearedFields[name]
  39041. return ok
  39042. }
  39043. // ClearField clears the value of the field with the given name. It returns an
  39044. // error if the field is not defined in the schema.
  39045. func (m *WhatsappChannelMutation) ClearField(name string) error {
  39046. switch name {
  39047. case whatsappchannel.FieldStatus:
  39048. m.ClearStatus()
  39049. return nil
  39050. case whatsappchannel.FieldDeletedAt:
  39051. m.ClearDeletedAt()
  39052. return nil
  39053. case whatsappchannel.FieldAk:
  39054. m.ClearAk()
  39055. return nil
  39056. case whatsappchannel.FieldWaID:
  39057. m.ClearWaID()
  39058. return nil
  39059. case whatsappchannel.FieldWaName:
  39060. m.ClearWaName()
  39061. return nil
  39062. case whatsappchannel.FieldOrganizationID:
  39063. m.ClearOrganizationID()
  39064. return nil
  39065. }
  39066. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  39067. }
  39068. // ResetField resets all changes in the mutation for the field with the given name.
  39069. // It returns an error if the field is not defined in the schema.
  39070. func (m *WhatsappChannelMutation) ResetField(name string) error {
  39071. switch name {
  39072. case whatsappchannel.FieldCreatedAt:
  39073. m.ResetCreatedAt()
  39074. return nil
  39075. case whatsappchannel.FieldUpdatedAt:
  39076. m.ResetUpdatedAt()
  39077. return nil
  39078. case whatsappchannel.FieldStatus:
  39079. m.ResetStatus()
  39080. return nil
  39081. case whatsappchannel.FieldDeletedAt:
  39082. m.ResetDeletedAt()
  39083. return nil
  39084. case whatsappchannel.FieldAk:
  39085. m.ResetAk()
  39086. return nil
  39087. case whatsappchannel.FieldSk:
  39088. m.ResetSk()
  39089. return nil
  39090. case whatsappchannel.FieldWaID:
  39091. m.ResetWaID()
  39092. return nil
  39093. case whatsappchannel.FieldWaName:
  39094. m.ResetWaName()
  39095. return nil
  39096. case whatsappchannel.FieldWabaID:
  39097. m.ResetWabaID()
  39098. return nil
  39099. case whatsappchannel.FieldBusinessID:
  39100. m.ResetBusinessID()
  39101. return nil
  39102. case whatsappchannel.FieldOrganizationID:
  39103. m.ResetOrganizationID()
  39104. return nil
  39105. case whatsappchannel.FieldVerifyAccount:
  39106. m.ResetVerifyAccount()
  39107. return nil
  39108. }
  39109. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39110. }
  39111. // AddedEdges returns all edge names that were set/added in this mutation.
  39112. func (m *WhatsappChannelMutation) AddedEdges() []string {
  39113. edges := make([]string, 0, 0)
  39114. return edges
  39115. }
  39116. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39117. // name in this mutation.
  39118. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  39119. return nil
  39120. }
  39121. // RemovedEdges returns all edge names that were removed in this mutation.
  39122. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  39123. edges := make([]string, 0, 0)
  39124. return edges
  39125. }
  39126. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39127. // the given name in this mutation.
  39128. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  39129. return nil
  39130. }
  39131. // ClearedEdges returns all edge names that were cleared in this mutation.
  39132. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  39133. edges := make([]string, 0, 0)
  39134. return edges
  39135. }
  39136. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39137. // was cleared in this mutation.
  39138. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  39139. return false
  39140. }
  39141. // ClearEdge clears the value of the edge with the given name. It returns an error
  39142. // if that edge is not defined in the schema.
  39143. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  39144. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  39145. }
  39146. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39147. // It returns an error if the edge is not defined in the schema.
  39148. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  39149. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  39150. }
  39151. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  39152. type WorkExperienceMutation struct {
  39153. config
  39154. op Op
  39155. typ string
  39156. id *uint64
  39157. created_at *time.Time
  39158. updated_at *time.Time
  39159. deleted_at *time.Time
  39160. start_date *time.Time
  39161. end_date *time.Time
  39162. company *string
  39163. experience *string
  39164. organization_id *uint64
  39165. addorganization_id *int64
  39166. clearedFields map[string]struct{}
  39167. employee *uint64
  39168. clearedemployee bool
  39169. done bool
  39170. oldValue func(context.Context) (*WorkExperience, error)
  39171. predicates []predicate.WorkExperience
  39172. }
  39173. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  39174. // workexperienceOption allows management of the mutation configuration using functional options.
  39175. type workexperienceOption func(*WorkExperienceMutation)
  39176. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  39177. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  39178. m := &WorkExperienceMutation{
  39179. config: c,
  39180. op: op,
  39181. typ: TypeWorkExperience,
  39182. clearedFields: make(map[string]struct{}),
  39183. }
  39184. for _, opt := range opts {
  39185. opt(m)
  39186. }
  39187. return m
  39188. }
  39189. // withWorkExperienceID sets the ID field of the mutation.
  39190. func withWorkExperienceID(id uint64) workexperienceOption {
  39191. return func(m *WorkExperienceMutation) {
  39192. var (
  39193. err error
  39194. once sync.Once
  39195. value *WorkExperience
  39196. )
  39197. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  39198. once.Do(func() {
  39199. if m.done {
  39200. err = errors.New("querying old values post mutation is not allowed")
  39201. } else {
  39202. value, err = m.Client().WorkExperience.Get(ctx, id)
  39203. }
  39204. })
  39205. return value, err
  39206. }
  39207. m.id = &id
  39208. }
  39209. }
  39210. // withWorkExperience sets the old WorkExperience of the mutation.
  39211. func withWorkExperience(node *WorkExperience) workexperienceOption {
  39212. return func(m *WorkExperienceMutation) {
  39213. m.oldValue = func(context.Context) (*WorkExperience, error) {
  39214. return node, nil
  39215. }
  39216. m.id = &node.ID
  39217. }
  39218. }
  39219. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39220. // executed in a transaction (ent.Tx), a transactional client is returned.
  39221. func (m WorkExperienceMutation) Client() *Client {
  39222. client := &Client{config: m.config}
  39223. client.init()
  39224. return client
  39225. }
  39226. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39227. // it returns an error otherwise.
  39228. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  39229. if _, ok := m.driver.(*txDriver); !ok {
  39230. return nil, errors.New("ent: mutation is not running in a transaction")
  39231. }
  39232. tx := &Tx{config: m.config}
  39233. tx.init()
  39234. return tx, nil
  39235. }
  39236. // SetID sets the value of the id field. Note that this
  39237. // operation is only accepted on creation of WorkExperience entities.
  39238. func (m *WorkExperienceMutation) SetID(id uint64) {
  39239. m.id = &id
  39240. }
  39241. // ID returns the ID value in the mutation. Note that the ID is only available
  39242. // if it was provided to the builder or after it was returned from the database.
  39243. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  39244. if m.id == nil {
  39245. return
  39246. }
  39247. return *m.id, true
  39248. }
  39249. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39250. // That means, if the mutation is applied within a transaction with an isolation level such
  39251. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39252. // or updated by the mutation.
  39253. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  39254. switch {
  39255. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39256. id, exists := m.ID()
  39257. if exists {
  39258. return []uint64{id}, nil
  39259. }
  39260. fallthrough
  39261. case m.op.Is(OpUpdate | OpDelete):
  39262. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  39263. default:
  39264. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39265. }
  39266. }
  39267. // SetCreatedAt sets the "created_at" field.
  39268. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  39269. m.created_at = &t
  39270. }
  39271. // CreatedAt returns the value of the "created_at" field in the mutation.
  39272. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  39273. v := m.created_at
  39274. if v == nil {
  39275. return
  39276. }
  39277. return *v, true
  39278. }
  39279. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  39280. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39282. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39283. if !m.op.Is(OpUpdateOne) {
  39284. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39285. }
  39286. if m.id == nil || m.oldValue == nil {
  39287. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39288. }
  39289. oldValue, err := m.oldValue(ctx)
  39290. if err != nil {
  39291. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39292. }
  39293. return oldValue.CreatedAt, nil
  39294. }
  39295. // ResetCreatedAt resets all changes to the "created_at" field.
  39296. func (m *WorkExperienceMutation) ResetCreatedAt() {
  39297. m.created_at = nil
  39298. }
  39299. // SetUpdatedAt sets the "updated_at" field.
  39300. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  39301. m.updated_at = &t
  39302. }
  39303. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39304. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  39305. v := m.updated_at
  39306. if v == nil {
  39307. return
  39308. }
  39309. return *v, true
  39310. }
  39311. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  39312. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39314. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39315. if !m.op.Is(OpUpdateOne) {
  39316. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39317. }
  39318. if m.id == nil || m.oldValue == nil {
  39319. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39320. }
  39321. oldValue, err := m.oldValue(ctx)
  39322. if err != nil {
  39323. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39324. }
  39325. return oldValue.UpdatedAt, nil
  39326. }
  39327. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39328. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  39329. m.updated_at = nil
  39330. }
  39331. // SetDeletedAt sets the "deleted_at" field.
  39332. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  39333. m.deleted_at = &t
  39334. }
  39335. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39336. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  39337. v := m.deleted_at
  39338. if v == nil {
  39339. return
  39340. }
  39341. return *v, true
  39342. }
  39343. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  39344. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39346. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39347. if !m.op.Is(OpUpdateOne) {
  39348. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39349. }
  39350. if m.id == nil || m.oldValue == nil {
  39351. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39352. }
  39353. oldValue, err := m.oldValue(ctx)
  39354. if err != nil {
  39355. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39356. }
  39357. return oldValue.DeletedAt, nil
  39358. }
  39359. // ClearDeletedAt clears the value of the "deleted_at" field.
  39360. func (m *WorkExperienceMutation) ClearDeletedAt() {
  39361. m.deleted_at = nil
  39362. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  39363. }
  39364. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39365. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39366. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39367. return ok
  39368. }
  39369. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39370. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39371. m.deleted_at = nil
  39372. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39373. }
  39374. // SetEmployeeID sets the "employee_id" field.
  39375. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39376. m.employee = &u
  39377. }
  39378. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39379. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39380. v := m.employee
  39381. if v == nil {
  39382. return
  39383. }
  39384. return *v, true
  39385. }
  39386. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39387. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39389. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39390. if !m.op.Is(OpUpdateOne) {
  39391. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39392. }
  39393. if m.id == nil || m.oldValue == nil {
  39394. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39395. }
  39396. oldValue, err := m.oldValue(ctx)
  39397. if err != nil {
  39398. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39399. }
  39400. return oldValue.EmployeeID, nil
  39401. }
  39402. // ResetEmployeeID resets all changes to the "employee_id" field.
  39403. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39404. m.employee = nil
  39405. }
  39406. // SetStartDate sets the "start_date" field.
  39407. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39408. m.start_date = &t
  39409. }
  39410. // StartDate returns the value of the "start_date" field in the mutation.
  39411. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39412. v := m.start_date
  39413. if v == nil {
  39414. return
  39415. }
  39416. return *v, true
  39417. }
  39418. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39419. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39421. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39422. if !m.op.Is(OpUpdateOne) {
  39423. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39424. }
  39425. if m.id == nil || m.oldValue == nil {
  39426. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39427. }
  39428. oldValue, err := m.oldValue(ctx)
  39429. if err != nil {
  39430. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39431. }
  39432. return oldValue.StartDate, nil
  39433. }
  39434. // ResetStartDate resets all changes to the "start_date" field.
  39435. func (m *WorkExperienceMutation) ResetStartDate() {
  39436. m.start_date = nil
  39437. }
  39438. // SetEndDate sets the "end_date" field.
  39439. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39440. m.end_date = &t
  39441. }
  39442. // EndDate returns the value of the "end_date" field in the mutation.
  39443. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39444. v := m.end_date
  39445. if v == nil {
  39446. return
  39447. }
  39448. return *v, true
  39449. }
  39450. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39451. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39453. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39454. if !m.op.Is(OpUpdateOne) {
  39455. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39456. }
  39457. if m.id == nil || m.oldValue == nil {
  39458. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39459. }
  39460. oldValue, err := m.oldValue(ctx)
  39461. if err != nil {
  39462. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39463. }
  39464. return oldValue.EndDate, nil
  39465. }
  39466. // ResetEndDate resets all changes to the "end_date" field.
  39467. func (m *WorkExperienceMutation) ResetEndDate() {
  39468. m.end_date = nil
  39469. }
  39470. // SetCompany sets the "company" field.
  39471. func (m *WorkExperienceMutation) SetCompany(s string) {
  39472. m.company = &s
  39473. }
  39474. // Company returns the value of the "company" field in the mutation.
  39475. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39476. v := m.company
  39477. if v == nil {
  39478. return
  39479. }
  39480. return *v, true
  39481. }
  39482. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39483. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39485. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39486. if !m.op.Is(OpUpdateOne) {
  39487. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39488. }
  39489. if m.id == nil || m.oldValue == nil {
  39490. return v, errors.New("OldCompany requires an ID field in the mutation")
  39491. }
  39492. oldValue, err := m.oldValue(ctx)
  39493. if err != nil {
  39494. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39495. }
  39496. return oldValue.Company, nil
  39497. }
  39498. // ResetCompany resets all changes to the "company" field.
  39499. func (m *WorkExperienceMutation) ResetCompany() {
  39500. m.company = nil
  39501. }
  39502. // SetExperience sets the "experience" field.
  39503. func (m *WorkExperienceMutation) SetExperience(s string) {
  39504. m.experience = &s
  39505. }
  39506. // Experience returns the value of the "experience" field in the mutation.
  39507. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39508. v := m.experience
  39509. if v == nil {
  39510. return
  39511. }
  39512. return *v, true
  39513. }
  39514. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39515. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39517. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39518. if !m.op.Is(OpUpdateOne) {
  39519. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39520. }
  39521. if m.id == nil || m.oldValue == nil {
  39522. return v, errors.New("OldExperience requires an ID field in the mutation")
  39523. }
  39524. oldValue, err := m.oldValue(ctx)
  39525. if err != nil {
  39526. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39527. }
  39528. return oldValue.Experience, nil
  39529. }
  39530. // ResetExperience resets all changes to the "experience" field.
  39531. func (m *WorkExperienceMutation) ResetExperience() {
  39532. m.experience = nil
  39533. }
  39534. // SetOrganizationID sets the "organization_id" field.
  39535. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39536. m.organization_id = &u
  39537. m.addorganization_id = nil
  39538. }
  39539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39540. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39541. v := m.organization_id
  39542. if v == nil {
  39543. return
  39544. }
  39545. return *v, true
  39546. }
  39547. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39548. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39550. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39551. if !m.op.Is(OpUpdateOne) {
  39552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39553. }
  39554. if m.id == nil || m.oldValue == nil {
  39555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39556. }
  39557. oldValue, err := m.oldValue(ctx)
  39558. if err != nil {
  39559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39560. }
  39561. return oldValue.OrganizationID, nil
  39562. }
  39563. // AddOrganizationID adds u to the "organization_id" field.
  39564. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39565. if m.addorganization_id != nil {
  39566. *m.addorganization_id += u
  39567. } else {
  39568. m.addorganization_id = &u
  39569. }
  39570. }
  39571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39572. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39573. v := m.addorganization_id
  39574. if v == nil {
  39575. return
  39576. }
  39577. return *v, true
  39578. }
  39579. // ResetOrganizationID resets all changes to the "organization_id" field.
  39580. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39581. m.organization_id = nil
  39582. m.addorganization_id = nil
  39583. }
  39584. // ClearEmployee clears the "employee" edge to the Employee entity.
  39585. func (m *WorkExperienceMutation) ClearEmployee() {
  39586. m.clearedemployee = true
  39587. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39588. }
  39589. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39590. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39591. return m.clearedemployee
  39592. }
  39593. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39594. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39595. // EmployeeID instead. It exists only for internal usage by the builders.
  39596. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39597. if id := m.employee; id != nil {
  39598. ids = append(ids, *id)
  39599. }
  39600. return
  39601. }
  39602. // ResetEmployee resets all changes to the "employee" edge.
  39603. func (m *WorkExperienceMutation) ResetEmployee() {
  39604. m.employee = nil
  39605. m.clearedemployee = false
  39606. }
  39607. // Where appends a list predicates to the WorkExperienceMutation builder.
  39608. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39609. m.predicates = append(m.predicates, ps...)
  39610. }
  39611. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39612. // users can use type-assertion to append predicates that do not depend on any generated package.
  39613. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39614. p := make([]predicate.WorkExperience, len(ps))
  39615. for i := range ps {
  39616. p[i] = ps[i]
  39617. }
  39618. m.Where(p...)
  39619. }
  39620. // Op returns the operation name.
  39621. func (m *WorkExperienceMutation) Op() Op {
  39622. return m.op
  39623. }
  39624. // SetOp allows setting the mutation operation.
  39625. func (m *WorkExperienceMutation) SetOp(op Op) {
  39626. m.op = op
  39627. }
  39628. // Type returns the node type of this mutation (WorkExperience).
  39629. func (m *WorkExperienceMutation) Type() string {
  39630. return m.typ
  39631. }
  39632. // Fields returns all fields that were changed during this mutation. Note that in
  39633. // order to get all numeric fields that were incremented/decremented, call
  39634. // AddedFields().
  39635. func (m *WorkExperienceMutation) Fields() []string {
  39636. fields := make([]string, 0, 9)
  39637. if m.created_at != nil {
  39638. fields = append(fields, workexperience.FieldCreatedAt)
  39639. }
  39640. if m.updated_at != nil {
  39641. fields = append(fields, workexperience.FieldUpdatedAt)
  39642. }
  39643. if m.deleted_at != nil {
  39644. fields = append(fields, workexperience.FieldDeletedAt)
  39645. }
  39646. if m.employee != nil {
  39647. fields = append(fields, workexperience.FieldEmployeeID)
  39648. }
  39649. if m.start_date != nil {
  39650. fields = append(fields, workexperience.FieldStartDate)
  39651. }
  39652. if m.end_date != nil {
  39653. fields = append(fields, workexperience.FieldEndDate)
  39654. }
  39655. if m.company != nil {
  39656. fields = append(fields, workexperience.FieldCompany)
  39657. }
  39658. if m.experience != nil {
  39659. fields = append(fields, workexperience.FieldExperience)
  39660. }
  39661. if m.organization_id != nil {
  39662. fields = append(fields, workexperience.FieldOrganizationID)
  39663. }
  39664. return fields
  39665. }
  39666. // Field returns the value of a field with the given name. The second boolean
  39667. // return value indicates that this field was not set, or was not defined in the
  39668. // schema.
  39669. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39670. switch name {
  39671. case workexperience.FieldCreatedAt:
  39672. return m.CreatedAt()
  39673. case workexperience.FieldUpdatedAt:
  39674. return m.UpdatedAt()
  39675. case workexperience.FieldDeletedAt:
  39676. return m.DeletedAt()
  39677. case workexperience.FieldEmployeeID:
  39678. return m.EmployeeID()
  39679. case workexperience.FieldStartDate:
  39680. return m.StartDate()
  39681. case workexperience.FieldEndDate:
  39682. return m.EndDate()
  39683. case workexperience.FieldCompany:
  39684. return m.Company()
  39685. case workexperience.FieldExperience:
  39686. return m.Experience()
  39687. case workexperience.FieldOrganizationID:
  39688. return m.OrganizationID()
  39689. }
  39690. return nil, false
  39691. }
  39692. // OldField returns the old value of the field from the database. An error is
  39693. // returned if the mutation operation is not UpdateOne, or the query to the
  39694. // database failed.
  39695. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39696. switch name {
  39697. case workexperience.FieldCreatedAt:
  39698. return m.OldCreatedAt(ctx)
  39699. case workexperience.FieldUpdatedAt:
  39700. return m.OldUpdatedAt(ctx)
  39701. case workexperience.FieldDeletedAt:
  39702. return m.OldDeletedAt(ctx)
  39703. case workexperience.FieldEmployeeID:
  39704. return m.OldEmployeeID(ctx)
  39705. case workexperience.FieldStartDate:
  39706. return m.OldStartDate(ctx)
  39707. case workexperience.FieldEndDate:
  39708. return m.OldEndDate(ctx)
  39709. case workexperience.FieldCompany:
  39710. return m.OldCompany(ctx)
  39711. case workexperience.FieldExperience:
  39712. return m.OldExperience(ctx)
  39713. case workexperience.FieldOrganizationID:
  39714. return m.OldOrganizationID(ctx)
  39715. }
  39716. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39717. }
  39718. // SetField sets the value of a field with the given name. It returns an error if
  39719. // the field is not defined in the schema, or if the type mismatched the field
  39720. // type.
  39721. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39722. switch name {
  39723. case workexperience.FieldCreatedAt:
  39724. v, ok := value.(time.Time)
  39725. if !ok {
  39726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39727. }
  39728. m.SetCreatedAt(v)
  39729. return nil
  39730. case workexperience.FieldUpdatedAt:
  39731. v, ok := value.(time.Time)
  39732. if !ok {
  39733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39734. }
  39735. m.SetUpdatedAt(v)
  39736. return nil
  39737. case workexperience.FieldDeletedAt:
  39738. v, ok := value.(time.Time)
  39739. if !ok {
  39740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39741. }
  39742. m.SetDeletedAt(v)
  39743. return nil
  39744. case workexperience.FieldEmployeeID:
  39745. v, ok := value.(uint64)
  39746. if !ok {
  39747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39748. }
  39749. m.SetEmployeeID(v)
  39750. return nil
  39751. case workexperience.FieldStartDate:
  39752. v, ok := value.(time.Time)
  39753. if !ok {
  39754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39755. }
  39756. m.SetStartDate(v)
  39757. return nil
  39758. case workexperience.FieldEndDate:
  39759. v, ok := value.(time.Time)
  39760. if !ok {
  39761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39762. }
  39763. m.SetEndDate(v)
  39764. return nil
  39765. case workexperience.FieldCompany:
  39766. v, ok := value.(string)
  39767. if !ok {
  39768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39769. }
  39770. m.SetCompany(v)
  39771. return nil
  39772. case workexperience.FieldExperience:
  39773. v, ok := value.(string)
  39774. if !ok {
  39775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39776. }
  39777. m.SetExperience(v)
  39778. return nil
  39779. case workexperience.FieldOrganizationID:
  39780. v, ok := value.(uint64)
  39781. if !ok {
  39782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39783. }
  39784. m.SetOrganizationID(v)
  39785. return nil
  39786. }
  39787. return fmt.Errorf("unknown WorkExperience field %s", name)
  39788. }
  39789. // AddedFields returns all numeric fields that were incremented/decremented during
  39790. // this mutation.
  39791. func (m *WorkExperienceMutation) AddedFields() []string {
  39792. var fields []string
  39793. if m.addorganization_id != nil {
  39794. fields = append(fields, workexperience.FieldOrganizationID)
  39795. }
  39796. return fields
  39797. }
  39798. // AddedField returns the numeric value that was incremented/decremented on a field
  39799. // with the given name. The second boolean return value indicates that this field
  39800. // was not set, or was not defined in the schema.
  39801. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39802. switch name {
  39803. case workexperience.FieldOrganizationID:
  39804. return m.AddedOrganizationID()
  39805. }
  39806. return nil, false
  39807. }
  39808. // AddField adds the value to the field with the given name. It returns an error if
  39809. // the field is not defined in the schema, or if the type mismatched the field
  39810. // type.
  39811. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39812. switch name {
  39813. case workexperience.FieldOrganizationID:
  39814. v, ok := value.(int64)
  39815. if !ok {
  39816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39817. }
  39818. m.AddOrganizationID(v)
  39819. return nil
  39820. }
  39821. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39822. }
  39823. // ClearedFields returns all nullable fields that were cleared during this
  39824. // mutation.
  39825. func (m *WorkExperienceMutation) ClearedFields() []string {
  39826. var fields []string
  39827. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39828. fields = append(fields, workexperience.FieldDeletedAt)
  39829. }
  39830. return fields
  39831. }
  39832. // FieldCleared returns a boolean indicating if a field with the given name was
  39833. // cleared in this mutation.
  39834. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39835. _, ok := m.clearedFields[name]
  39836. return ok
  39837. }
  39838. // ClearField clears the value of the field with the given name. It returns an
  39839. // error if the field is not defined in the schema.
  39840. func (m *WorkExperienceMutation) ClearField(name string) error {
  39841. switch name {
  39842. case workexperience.FieldDeletedAt:
  39843. m.ClearDeletedAt()
  39844. return nil
  39845. }
  39846. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39847. }
  39848. // ResetField resets all changes in the mutation for the field with the given name.
  39849. // It returns an error if the field is not defined in the schema.
  39850. func (m *WorkExperienceMutation) ResetField(name string) error {
  39851. switch name {
  39852. case workexperience.FieldCreatedAt:
  39853. m.ResetCreatedAt()
  39854. return nil
  39855. case workexperience.FieldUpdatedAt:
  39856. m.ResetUpdatedAt()
  39857. return nil
  39858. case workexperience.FieldDeletedAt:
  39859. m.ResetDeletedAt()
  39860. return nil
  39861. case workexperience.FieldEmployeeID:
  39862. m.ResetEmployeeID()
  39863. return nil
  39864. case workexperience.FieldStartDate:
  39865. m.ResetStartDate()
  39866. return nil
  39867. case workexperience.FieldEndDate:
  39868. m.ResetEndDate()
  39869. return nil
  39870. case workexperience.FieldCompany:
  39871. m.ResetCompany()
  39872. return nil
  39873. case workexperience.FieldExperience:
  39874. m.ResetExperience()
  39875. return nil
  39876. case workexperience.FieldOrganizationID:
  39877. m.ResetOrganizationID()
  39878. return nil
  39879. }
  39880. return fmt.Errorf("unknown WorkExperience field %s", name)
  39881. }
  39882. // AddedEdges returns all edge names that were set/added in this mutation.
  39883. func (m *WorkExperienceMutation) AddedEdges() []string {
  39884. edges := make([]string, 0, 1)
  39885. if m.employee != nil {
  39886. edges = append(edges, workexperience.EdgeEmployee)
  39887. }
  39888. return edges
  39889. }
  39890. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39891. // name in this mutation.
  39892. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39893. switch name {
  39894. case workexperience.EdgeEmployee:
  39895. if id := m.employee; id != nil {
  39896. return []ent.Value{*id}
  39897. }
  39898. }
  39899. return nil
  39900. }
  39901. // RemovedEdges returns all edge names that were removed in this mutation.
  39902. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39903. edges := make([]string, 0, 1)
  39904. return edges
  39905. }
  39906. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39907. // the given name in this mutation.
  39908. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39909. return nil
  39910. }
  39911. // ClearedEdges returns all edge names that were cleared in this mutation.
  39912. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39913. edges := make([]string, 0, 1)
  39914. if m.clearedemployee {
  39915. edges = append(edges, workexperience.EdgeEmployee)
  39916. }
  39917. return edges
  39918. }
  39919. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39920. // was cleared in this mutation.
  39921. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39922. switch name {
  39923. case workexperience.EdgeEmployee:
  39924. return m.clearedemployee
  39925. }
  39926. return false
  39927. }
  39928. // ClearEdge clears the value of the edge with the given name. It returns an error
  39929. // if that edge is not defined in the schema.
  39930. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39931. switch name {
  39932. case workexperience.EdgeEmployee:
  39933. m.ClearEmployee()
  39934. return nil
  39935. }
  39936. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39937. }
  39938. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39939. // It returns an error if the edge is not defined in the schema.
  39940. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39941. switch name {
  39942. case workexperience.EdgeEmployee:
  39943. m.ResetEmployee()
  39944. return nil
  39945. }
  39946. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39947. }
  39948. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39949. type WpChatroomMutation struct {
  39950. config
  39951. op Op
  39952. typ string
  39953. id *uint64
  39954. created_at *time.Time
  39955. updated_at *time.Time
  39956. status *uint8
  39957. addstatus *int8
  39958. wx_wxid *string
  39959. chatroom_id *string
  39960. nickname *string
  39961. owner *string
  39962. avatar *string
  39963. member_list *[]string
  39964. appendmember_list []string
  39965. clearedFields map[string]struct{}
  39966. done bool
  39967. oldValue func(context.Context) (*WpChatroom, error)
  39968. predicates []predicate.WpChatroom
  39969. }
  39970. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39971. // wpchatroomOption allows management of the mutation configuration using functional options.
  39972. type wpchatroomOption func(*WpChatroomMutation)
  39973. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39974. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39975. m := &WpChatroomMutation{
  39976. config: c,
  39977. op: op,
  39978. typ: TypeWpChatroom,
  39979. clearedFields: make(map[string]struct{}),
  39980. }
  39981. for _, opt := range opts {
  39982. opt(m)
  39983. }
  39984. return m
  39985. }
  39986. // withWpChatroomID sets the ID field of the mutation.
  39987. func withWpChatroomID(id uint64) wpchatroomOption {
  39988. return func(m *WpChatroomMutation) {
  39989. var (
  39990. err error
  39991. once sync.Once
  39992. value *WpChatroom
  39993. )
  39994. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39995. once.Do(func() {
  39996. if m.done {
  39997. err = errors.New("querying old values post mutation is not allowed")
  39998. } else {
  39999. value, err = m.Client().WpChatroom.Get(ctx, id)
  40000. }
  40001. })
  40002. return value, err
  40003. }
  40004. m.id = &id
  40005. }
  40006. }
  40007. // withWpChatroom sets the old WpChatroom of the mutation.
  40008. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  40009. return func(m *WpChatroomMutation) {
  40010. m.oldValue = func(context.Context) (*WpChatroom, error) {
  40011. return node, nil
  40012. }
  40013. m.id = &node.ID
  40014. }
  40015. }
  40016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40017. // executed in a transaction (ent.Tx), a transactional client is returned.
  40018. func (m WpChatroomMutation) Client() *Client {
  40019. client := &Client{config: m.config}
  40020. client.init()
  40021. return client
  40022. }
  40023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40024. // it returns an error otherwise.
  40025. func (m WpChatroomMutation) Tx() (*Tx, error) {
  40026. if _, ok := m.driver.(*txDriver); !ok {
  40027. return nil, errors.New("ent: mutation is not running in a transaction")
  40028. }
  40029. tx := &Tx{config: m.config}
  40030. tx.init()
  40031. return tx, nil
  40032. }
  40033. // SetID sets the value of the id field. Note that this
  40034. // operation is only accepted on creation of WpChatroom entities.
  40035. func (m *WpChatroomMutation) SetID(id uint64) {
  40036. m.id = &id
  40037. }
  40038. // ID returns the ID value in the mutation. Note that the ID is only available
  40039. // if it was provided to the builder or after it was returned from the database.
  40040. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  40041. if m.id == nil {
  40042. return
  40043. }
  40044. return *m.id, true
  40045. }
  40046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40047. // That means, if the mutation is applied within a transaction with an isolation level such
  40048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40049. // or updated by the mutation.
  40050. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  40051. switch {
  40052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40053. id, exists := m.ID()
  40054. if exists {
  40055. return []uint64{id}, nil
  40056. }
  40057. fallthrough
  40058. case m.op.Is(OpUpdate | OpDelete):
  40059. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  40060. default:
  40061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40062. }
  40063. }
  40064. // SetCreatedAt sets the "created_at" field.
  40065. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  40066. m.created_at = &t
  40067. }
  40068. // CreatedAt returns the value of the "created_at" field in the mutation.
  40069. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  40070. v := m.created_at
  40071. if v == nil {
  40072. return
  40073. }
  40074. return *v, true
  40075. }
  40076. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  40077. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40079. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40080. if !m.op.Is(OpUpdateOne) {
  40081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40082. }
  40083. if m.id == nil || m.oldValue == nil {
  40084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40085. }
  40086. oldValue, err := m.oldValue(ctx)
  40087. if err != nil {
  40088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40089. }
  40090. return oldValue.CreatedAt, nil
  40091. }
  40092. // ResetCreatedAt resets all changes to the "created_at" field.
  40093. func (m *WpChatroomMutation) ResetCreatedAt() {
  40094. m.created_at = nil
  40095. }
  40096. // SetUpdatedAt sets the "updated_at" field.
  40097. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  40098. m.updated_at = &t
  40099. }
  40100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40101. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  40102. v := m.updated_at
  40103. if v == nil {
  40104. return
  40105. }
  40106. return *v, true
  40107. }
  40108. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  40109. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40111. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40112. if !m.op.Is(OpUpdateOne) {
  40113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40114. }
  40115. if m.id == nil || m.oldValue == nil {
  40116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40117. }
  40118. oldValue, err := m.oldValue(ctx)
  40119. if err != nil {
  40120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40121. }
  40122. return oldValue.UpdatedAt, nil
  40123. }
  40124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40125. func (m *WpChatroomMutation) ResetUpdatedAt() {
  40126. m.updated_at = nil
  40127. }
  40128. // SetStatus sets the "status" field.
  40129. func (m *WpChatroomMutation) SetStatus(u uint8) {
  40130. m.status = &u
  40131. m.addstatus = nil
  40132. }
  40133. // Status returns the value of the "status" field in the mutation.
  40134. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  40135. v := m.status
  40136. if v == nil {
  40137. return
  40138. }
  40139. return *v, true
  40140. }
  40141. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  40142. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40144. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40145. if !m.op.Is(OpUpdateOne) {
  40146. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40147. }
  40148. if m.id == nil || m.oldValue == nil {
  40149. return v, errors.New("OldStatus requires an ID field in the mutation")
  40150. }
  40151. oldValue, err := m.oldValue(ctx)
  40152. if err != nil {
  40153. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40154. }
  40155. return oldValue.Status, nil
  40156. }
  40157. // AddStatus adds u to the "status" field.
  40158. func (m *WpChatroomMutation) AddStatus(u int8) {
  40159. if m.addstatus != nil {
  40160. *m.addstatus += u
  40161. } else {
  40162. m.addstatus = &u
  40163. }
  40164. }
  40165. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40166. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  40167. v := m.addstatus
  40168. if v == nil {
  40169. return
  40170. }
  40171. return *v, true
  40172. }
  40173. // ClearStatus clears the value of the "status" field.
  40174. func (m *WpChatroomMutation) ClearStatus() {
  40175. m.status = nil
  40176. m.addstatus = nil
  40177. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  40178. }
  40179. // StatusCleared returns if the "status" field was cleared in this mutation.
  40180. func (m *WpChatroomMutation) StatusCleared() bool {
  40181. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  40182. return ok
  40183. }
  40184. // ResetStatus resets all changes to the "status" field.
  40185. func (m *WpChatroomMutation) ResetStatus() {
  40186. m.status = nil
  40187. m.addstatus = nil
  40188. delete(m.clearedFields, wpchatroom.FieldStatus)
  40189. }
  40190. // SetWxWxid sets the "wx_wxid" field.
  40191. func (m *WpChatroomMutation) SetWxWxid(s string) {
  40192. m.wx_wxid = &s
  40193. }
  40194. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40195. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  40196. v := m.wx_wxid
  40197. if v == nil {
  40198. return
  40199. }
  40200. return *v, true
  40201. }
  40202. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  40203. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40205. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40206. if !m.op.Is(OpUpdateOne) {
  40207. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40208. }
  40209. if m.id == nil || m.oldValue == nil {
  40210. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40211. }
  40212. oldValue, err := m.oldValue(ctx)
  40213. if err != nil {
  40214. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40215. }
  40216. return oldValue.WxWxid, nil
  40217. }
  40218. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40219. func (m *WpChatroomMutation) ResetWxWxid() {
  40220. m.wx_wxid = nil
  40221. }
  40222. // SetChatroomID sets the "chatroom_id" field.
  40223. func (m *WpChatroomMutation) SetChatroomID(s string) {
  40224. m.chatroom_id = &s
  40225. }
  40226. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  40227. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  40228. v := m.chatroom_id
  40229. if v == nil {
  40230. return
  40231. }
  40232. return *v, true
  40233. }
  40234. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  40235. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40237. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  40238. if !m.op.Is(OpUpdateOne) {
  40239. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  40240. }
  40241. if m.id == nil || m.oldValue == nil {
  40242. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  40243. }
  40244. oldValue, err := m.oldValue(ctx)
  40245. if err != nil {
  40246. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  40247. }
  40248. return oldValue.ChatroomID, nil
  40249. }
  40250. // ResetChatroomID resets all changes to the "chatroom_id" field.
  40251. func (m *WpChatroomMutation) ResetChatroomID() {
  40252. m.chatroom_id = nil
  40253. }
  40254. // SetNickname sets the "nickname" field.
  40255. func (m *WpChatroomMutation) SetNickname(s string) {
  40256. m.nickname = &s
  40257. }
  40258. // Nickname returns the value of the "nickname" field in the mutation.
  40259. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  40260. v := m.nickname
  40261. if v == nil {
  40262. return
  40263. }
  40264. return *v, true
  40265. }
  40266. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  40267. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40269. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  40270. if !m.op.Is(OpUpdateOne) {
  40271. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40272. }
  40273. if m.id == nil || m.oldValue == nil {
  40274. return v, errors.New("OldNickname requires an ID field in the mutation")
  40275. }
  40276. oldValue, err := m.oldValue(ctx)
  40277. if err != nil {
  40278. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40279. }
  40280. return oldValue.Nickname, nil
  40281. }
  40282. // ResetNickname resets all changes to the "nickname" field.
  40283. func (m *WpChatroomMutation) ResetNickname() {
  40284. m.nickname = nil
  40285. }
  40286. // SetOwner sets the "owner" field.
  40287. func (m *WpChatroomMutation) SetOwner(s string) {
  40288. m.owner = &s
  40289. }
  40290. // Owner returns the value of the "owner" field in the mutation.
  40291. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40292. v := m.owner
  40293. if v == nil {
  40294. return
  40295. }
  40296. return *v, true
  40297. }
  40298. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  40299. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40301. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  40302. if !m.op.Is(OpUpdateOne) {
  40303. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  40304. }
  40305. if m.id == nil || m.oldValue == nil {
  40306. return v, errors.New("OldOwner requires an ID field in the mutation")
  40307. }
  40308. oldValue, err := m.oldValue(ctx)
  40309. if err != nil {
  40310. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  40311. }
  40312. return oldValue.Owner, nil
  40313. }
  40314. // ResetOwner resets all changes to the "owner" field.
  40315. func (m *WpChatroomMutation) ResetOwner() {
  40316. m.owner = nil
  40317. }
  40318. // SetAvatar sets the "avatar" field.
  40319. func (m *WpChatroomMutation) SetAvatar(s string) {
  40320. m.avatar = &s
  40321. }
  40322. // Avatar returns the value of the "avatar" field in the mutation.
  40323. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  40324. v := m.avatar
  40325. if v == nil {
  40326. return
  40327. }
  40328. return *v, true
  40329. }
  40330. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  40331. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40333. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40334. if !m.op.Is(OpUpdateOne) {
  40335. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40336. }
  40337. if m.id == nil || m.oldValue == nil {
  40338. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40339. }
  40340. oldValue, err := m.oldValue(ctx)
  40341. if err != nil {
  40342. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40343. }
  40344. return oldValue.Avatar, nil
  40345. }
  40346. // ResetAvatar resets all changes to the "avatar" field.
  40347. func (m *WpChatroomMutation) ResetAvatar() {
  40348. m.avatar = nil
  40349. }
  40350. // SetMemberList sets the "member_list" field.
  40351. func (m *WpChatroomMutation) SetMemberList(s []string) {
  40352. m.member_list = &s
  40353. m.appendmember_list = nil
  40354. }
  40355. // MemberList returns the value of the "member_list" field in the mutation.
  40356. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  40357. v := m.member_list
  40358. if v == nil {
  40359. return
  40360. }
  40361. return *v, true
  40362. }
  40363. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40364. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40366. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40367. if !m.op.Is(OpUpdateOne) {
  40368. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40369. }
  40370. if m.id == nil || m.oldValue == nil {
  40371. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40372. }
  40373. oldValue, err := m.oldValue(ctx)
  40374. if err != nil {
  40375. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40376. }
  40377. return oldValue.MemberList, nil
  40378. }
  40379. // AppendMemberList adds s to the "member_list" field.
  40380. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40381. m.appendmember_list = append(m.appendmember_list, s...)
  40382. }
  40383. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40384. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40385. if len(m.appendmember_list) == 0 {
  40386. return nil, false
  40387. }
  40388. return m.appendmember_list, true
  40389. }
  40390. // ResetMemberList resets all changes to the "member_list" field.
  40391. func (m *WpChatroomMutation) ResetMemberList() {
  40392. m.member_list = nil
  40393. m.appendmember_list = nil
  40394. }
  40395. // Where appends a list predicates to the WpChatroomMutation builder.
  40396. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40397. m.predicates = append(m.predicates, ps...)
  40398. }
  40399. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40400. // users can use type-assertion to append predicates that do not depend on any generated package.
  40401. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40402. p := make([]predicate.WpChatroom, len(ps))
  40403. for i := range ps {
  40404. p[i] = ps[i]
  40405. }
  40406. m.Where(p...)
  40407. }
  40408. // Op returns the operation name.
  40409. func (m *WpChatroomMutation) Op() Op {
  40410. return m.op
  40411. }
  40412. // SetOp allows setting the mutation operation.
  40413. func (m *WpChatroomMutation) SetOp(op Op) {
  40414. m.op = op
  40415. }
  40416. // Type returns the node type of this mutation (WpChatroom).
  40417. func (m *WpChatroomMutation) Type() string {
  40418. return m.typ
  40419. }
  40420. // Fields returns all fields that were changed during this mutation. Note that in
  40421. // order to get all numeric fields that were incremented/decremented, call
  40422. // AddedFields().
  40423. func (m *WpChatroomMutation) Fields() []string {
  40424. fields := make([]string, 0, 9)
  40425. if m.created_at != nil {
  40426. fields = append(fields, wpchatroom.FieldCreatedAt)
  40427. }
  40428. if m.updated_at != nil {
  40429. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40430. }
  40431. if m.status != nil {
  40432. fields = append(fields, wpchatroom.FieldStatus)
  40433. }
  40434. if m.wx_wxid != nil {
  40435. fields = append(fields, wpchatroom.FieldWxWxid)
  40436. }
  40437. if m.chatroom_id != nil {
  40438. fields = append(fields, wpchatroom.FieldChatroomID)
  40439. }
  40440. if m.nickname != nil {
  40441. fields = append(fields, wpchatroom.FieldNickname)
  40442. }
  40443. if m.owner != nil {
  40444. fields = append(fields, wpchatroom.FieldOwner)
  40445. }
  40446. if m.avatar != nil {
  40447. fields = append(fields, wpchatroom.FieldAvatar)
  40448. }
  40449. if m.member_list != nil {
  40450. fields = append(fields, wpchatroom.FieldMemberList)
  40451. }
  40452. return fields
  40453. }
  40454. // Field returns the value of a field with the given name. The second boolean
  40455. // return value indicates that this field was not set, or was not defined in the
  40456. // schema.
  40457. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40458. switch name {
  40459. case wpchatroom.FieldCreatedAt:
  40460. return m.CreatedAt()
  40461. case wpchatroom.FieldUpdatedAt:
  40462. return m.UpdatedAt()
  40463. case wpchatroom.FieldStatus:
  40464. return m.Status()
  40465. case wpchatroom.FieldWxWxid:
  40466. return m.WxWxid()
  40467. case wpchatroom.FieldChatroomID:
  40468. return m.ChatroomID()
  40469. case wpchatroom.FieldNickname:
  40470. return m.Nickname()
  40471. case wpchatroom.FieldOwner:
  40472. return m.Owner()
  40473. case wpchatroom.FieldAvatar:
  40474. return m.Avatar()
  40475. case wpchatroom.FieldMemberList:
  40476. return m.MemberList()
  40477. }
  40478. return nil, false
  40479. }
  40480. // OldField returns the old value of the field from the database. An error is
  40481. // returned if the mutation operation is not UpdateOne, or the query to the
  40482. // database failed.
  40483. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40484. switch name {
  40485. case wpchatroom.FieldCreatedAt:
  40486. return m.OldCreatedAt(ctx)
  40487. case wpchatroom.FieldUpdatedAt:
  40488. return m.OldUpdatedAt(ctx)
  40489. case wpchatroom.FieldStatus:
  40490. return m.OldStatus(ctx)
  40491. case wpchatroom.FieldWxWxid:
  40492. return m.OldWxWxid(ctx)
  40493. case wpchatroom.FieldChatroomID:
  40494. return m.OldChatroomID(ctx)
  40495. case wpchatroom.FieldNickname:
  40496. return m.OldNickname(ctx)
  40497. case wpchatroom.FieldOwner:
  40498. return m.OldOwner(ctx)
  40499. case wpchatroom.FieldAvatar:
  40500. return m.OldAvatar(ctx)
  40501. case wpchatroom.FieldMemberList:
  40502. return m.OldMemberList(ctx)
  40503. }
  40504. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40505. }
  40506. // SetField sets the value of a field with the given name. It returns an error if
  40507. // the field is not defined in the schema, or if the type mismatched the field
  40508. // type.
  40509. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40510. switch name {
  40511. case wpchatroom.FieldCreatedAt:
  40512. v, ok := value.(time.Time)
  40513. if !ok {
  40514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40515. }
  40516. m.SetCreatedAt(v)
  40517. return nil
  40518. case wpchatroom.FieldUpdatedAt:
  40519. v, ok := value.(time.Time)
  40520. if !ok {
  40521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40522. }
  40523. m.SetUpdatedAt(v)
  40524. return nil
  40525. case wpchatroom.FieldStatus:
  40526. v, ok := value.(uint8)
  40527. if !ok {
  40528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40529. }
  40530. m.SetStatus(v)
  40531. return nil
  40532. case wpchatroom.FieldWxWxid:
  40533. v, ok := value.(string)
  40534. if !ok {
  40535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40536. }
  40537. m.SetWxWxid(v)
  40538. return nil
  40539. case wpchatroom.FieldChatroomID:
  40540. v, ok := value.(string)
  40541. if !ok {
  40542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40543. }
  40544. m.SetChatroomID(v)
  40545. return nil
  40546. case wpchatroom.FieldNickname:
  40547. v, ok := value.(string)
  40548. if !ok {
  40549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40550. }
  40551. m.SetNickname(v)
  40552. return nil
  40553. case wpchatroom.FieldOwner:
  40554. v, ok := value.(string)
  40555. if !ok {
  40556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40557. }
  40558. m.SetOwner(v)
  40559. return nil
  40560. case wpchatroom.FieldAvatar:
  40561. v, ok := value.(string)
  40562. if !ok {
  40563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40564. }
  40565. m.SetAvatar(v)
  40566. return nil
  40567. case wpchatroom.FieldMemberList:
  40568. v, ok := value.([]string)
  40569. if !ok {
  40570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40571. }
  40572. m.SetMemberList(v)
  40573. return nil
  40574. }
  40575. return fmt.Errorf("unknown WpChatroom field %s", name)
  40576. }
  40577. // AddedFields returns all numeric fields that were incremented/decremented during
  40578. // this mutation.
  40579. func (m *WpChatroomMutation) AddedFields() []string {
  40580. var fields []string
  40581. if m.addstatus != nil {
  40582. fields = append(fields, wpchatroom.FieldStatus)
  40583. }
  40584. return fields
  40585. }
  40586. // AddedField returns the numeric value that was incremented/decremented on a field
  40587. // with the given name. The second boolean return value indicates that this field
  40588. // was not set, or was not defined in the schema.
  40589. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40590. switch name {
  40591. case wpchatroom.FieldStatus:
  40592. return m.AddedStatus()
  40593. }
  40594. return nil, false
  40595. }
  40596. // AddField adds the value to the field with the given name. It returns an error if
  40597. // the field is not defined in the schema, or if the type mismatched the field
  40598. // type.
  40599. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40600. switch name {
  40601. case wpchatroom.FieldStatus:
  40602. v, ok := value.(int8)
  40603. if !ok {
  40604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40605. }
  40606. m.AddStatus(v)
  40607. return nil
  40608. }
  40609. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40610. }
  40611. // ClearedFields returns all nullable fields that were cleared during this
  40612. // mutation.
  40613. func (m *WpChatroomMutation) ClearedFields() []string {
  40614. var fields []string
  40615. if m.FieldCleared(wpchatroom.FieldStatus) {
  40616. fields = append(fields, wpchatroom.FieldStatus)
  40617. }
  40618. return fields
  40619. }
  40620. // FieldCleared returns a boolean indicating if a field with the given name was
  40621. // cleared in this mutation.
  40622. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40623. _, ok := m.clearedFields[name]
  40624. return ok
  40625. }
  40626. // ClearField clears the value of the field with the given name. It returns an
  40627. // error if the field is not defined in the schema.
  40628. func (m *WpChatroomMutation) ClearField(name string) error {
  40629. switch name {
  40630. case wpchatroom.FieldStatus:
  40631. m.ClearStatus()
  40632. return nil
  40633. }
  40634. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40635. }
  40636. // ResetField resets all changes in the mutation for the field with the given name.
  40637. // It returns an error if the field is not defined in the schema.
  40638. func (m *WpChatroomMutation) ResetField(name string) error {
  40639. switch name {
  40640. case wpchatroom.FieldCreatedAt:
  40641. m.ResetCreatedAt()
  40642. return nil
  40643. case wpchatroom.FieldUpdatedAt:
  40644. m.ResetUpdatedAt()
  40645. return nil
  40646. case wpchatroom.FieldStatus:
  40647. m.ResetStatus()
  40648. return nil
  40649. case wpchatroom.FieldWxWxid:
  40650. m.ResetWxWxid()
  40651. return nil
  40652. case wpchatroom.FieldChatroomID:
  40653. m.ResetChatroomID()
  40654. return nil
  40655. case wpchatroom.FieldNickname:
  40656. m.ResetNickname()
  40657. return nil
  40658. case wpchatroom.FieldOwner:
  40659. m.ResetOwner()
  40660. return nil
  40661. case wpchatroom.FieldAvatar:
  40662. m.ResetAvatar()
  40663. return nil
  40664. case wpchatroom.FieldMemberList:
  40665. m.ResetMemberList()
  40666. return nil
  40667. }
  40668. return fmt.Errorf("unknown WpChatroom field %s", name)
  40669. }
  40670. // AddedEdges returns all edge names that were set/added in this mutation.
  40671. func (m *WpChatroomMutation) AddedEdges() []string {
  40672. edges := make([]string, 0, 0)
  40673. return edges
  40674. }
  40675. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40676. // name in this mutation.
  40677. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40678. return nil
  40679. }
  40680. // RemovedEdges returns all edge names that were removed in this mutation.
  40681. func (m *WpChatroomMutation) RemovedEdges() []string {
  40682. edges := make([]string, 0, 0)
  40683. return edges
  40684. }
  40685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40686. // the given name in this mutation.
  40687. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40688. return nil
  40689. }
  40690. // ClearedEdges returns all edge names that were cleared in this mutation.
  40691. func (m *WpChatroomMutation) ClearedEdges() []string {
  40692. edges := make([]string, 0, 0)
  40693. return edges
  40694. }
  40695. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40696. // was cleared in this mutation.
  40697. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40698. return false
  40699. }
  40700. // ClearEdge clears the value of the edge with the given name. It returns an error
  40701. // if that edge is not defined in the schema.
  40702. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40703. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40704. }
  40705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40706. // It returns an error if the edge is not defined in the schema.
  40707. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40708. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40709. }
  40710. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40711. type WpChatroomMemberMutation struct {
  40712. config
  40713. op Op
  40714. typ string
  40715. id *uint64
  40716. created_at *time.Time
  40717. updated_at *time.Time
  40718. status *uint8
  40719. addstatus *int8
  40720. wx_wxid *string
  40721. wxid *string
  40722. nickname *string
  40723. avatar *string
  40724. clearedFields map[string]struct{}
  40725. done bool
  40726. oldValue func(context.Context) (*WpChatroomMember, error)
  40727. predicates []predicate.WpChatroomMember
  40728. }
  40729. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40730. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40731. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40732. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40733. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40734. m := &WpChatroomMemberMutation{
  40735. config: c,
  40736. op: op,
  40737. typ: TypeWpChatroomMember,
  40738. clearedFields: make(map[string]struct{}),
  40739. }
  40740. for _, opt := range opts {
  40741. opt(m)
  40742. }
  40743. return m
  40744. }
  40745. // withWpChatroomMemberID sets the ID field of the mutation.
  40746. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40747. return func(m *WpChatroomMemberMutation) {
  40748. var (
  40749. err error
  40750. once sync.Once
  40751. value *WpChatroomMember
  40752. )
  40753. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40754. once.Do(func() {
  40755. if m.done {
  40756. err = errors.New("querying old values post mutation is not allowed")
  40757. } else {
  40758. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40759. }
  40760. })
  40761. return value, err
  40762. }
  40763. m.id = &id
  40764. }
  40765. }
  40766. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40767. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40768. return func(m *WpChatroomMemberMutation) {
  40769. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40770. return node, nil
  40771. }
  40772. m.id = &node.ID
  40773. }
  40774. }
  40775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40776. // executed in a transaction (ent.Tx), a transactional client is returned.
  40777. func (m WpChatroomMemberMutation) Client() *Client {
  40778. client := &Client{config: m.config}
  40779. client.init()
  40780. return client
  40781. }
  40782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40783. // it returns an error otherwise.
  40784. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40785. if _, ok := m.driver.(*txDriver); !ok {
  40786. return nil, errors.New("ent: mutation is not running in a transaction")
  40787. }
  40788. tx := &Tx{config: m.config}
  40789. tx.init()
  40790. return tx, nil
  40791. }
  40792. // SetID sets the value of the id field. Note that this
  40793. // operation is only accepted on creation of WpChatroomMember entities.
  40794. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40795. m.id = &id
  40796. }
  40797. // ID returns the ID value in the mutation. Note that the ID is only available
  40798. // if it was provided to the builder or after it was returned from the database.
  40799. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40800. if m.id == nil {
  40801. return
  40802. }
  40803. return *m.id, true
  40804. }
  40805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40806. // That means, if the mutation is applied within a transaction with an isolation level such
  40807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40808. // or updated by the mutation.
  40809. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40810. switch {
  40811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40812. id, exists := m.ID()
  40813. if exists {
  40814. return []uint64{id}, nil
  40815. }
  40816. fallthrough
  40817. case m.op.Is(OpUpdate | OpDelete):
  40818. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40819. default:
  40820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40821. }
  40822. }
  40823. // SetCreatedAt sets the "created_at" field.
  40824. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40825. m.created_at = &t
  40826. }
  40827. // CreatedAt returns the value of the "created_at" field in the mutation.
  40828. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40829. v := m.created_at
  40830. if v == nil {
  40831. return
  40832. }
  40833. return *v, true
  40834. }
  40835. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40836. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40838. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40839. if !m.op.Is(OpUpdateOne) {
  40840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40841. }
  40842. if m.id == nil || m.oldValue == nil {
  40843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40844. }
  40845. oldValue, err := m.oldValue(ctx)
  40846. if err != nil {
  40847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40848. }
  40849. return oldValue.CreatedAt, nil
  40850. }
  40851. // ResetCreatedAt resets all changes to the "created_at" field.
  40852. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40853. m.created_at = nil
  40854. }
  40855. // SetUpdatedAt sets the "updated_at" field.
  40856. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40857. m.updated_at = &t
  40858. }
  40859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40860. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40861. v := m.updated_at
  40862. if v == nil {
  40863. return
  40864. }
  40865. return *v, true
  40866. }
  40867. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40868. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40870. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40871. if !m.op.Is(OpUpdateOne) {
  40872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40873. }
  40874. if m.id == nil || m.oldValue == nil {
  40875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40876. }
  40877. oldValue, err := m.oldValue(ctx)
  40878. if err != nil {
  40879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40880. }
  40881. return oldValue.UpdatedAt, nil
  40882. }
  40883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40884. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40885. m.updated_at = nil
  40886. }
  40887. // SetStatus sets the "status" field.
  40888. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40889. m.status = &u
  40890. m.addstatus = nil
  40891. }
  40892. // Status returns the value of the "status" field in the mutation.
  40893. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40894. v := m.status
  40895. if v == nil {
  40896. return
  40897. }
  40898. return *v, true
  40899. }
  40900. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40901. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40903. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40904. if !m.op.Is(OpUpdateOne) {
  40905. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40906. }
  40907. if m.id == nil || m.oldValue == nil {
  40908. return v, errors.New("OldStatus requires an ID field in the mutation")
  40909. }
  40910. oldValue, err := m.oldValue(ctx)
  40911. if err != nil {
  40912. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40913. }
  40914. return oldValue.Status, nil
  40915. }
  40916. // AddStatus adds u to the "status" field.
  40917. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40918. if m.addstatus != nil {
  40919. *m.addstatus += u
  40920. } else {
  40921. m.addstatus = &u
  40922. }
  40923. }
  40924. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40925. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40926. v := m.addstatus
  40927. if v == nil {
  40928. return
  40929. }
  40930. return *v, true
  40931. }
  40932. // ClearStatus clears the value of the "status" field.
  40933. func (m *WpChatroomMemberMutation) ClearStatus() {
  40934. m.status = nil
  40935. m.addstatus = nil
  40936. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40937. }
  40938. // StatusCleared returns if the "status" field was cleared in this mutation.
  40939. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40940. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40941. return ok
  40942. }
  40943. // ResetStatus resets all changes to the "status" field.
  40944. func (m *WpChatroomMemberMutation) ResetStatus() {
  40945. m.status = nil
  40946. m.addstatus = nil
  40947. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40948. }
  40949. // SetWxWxid sets the "wx_wxid" field.
  40950. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40951. m.wx_wxid = &s
  40952. }
  40953. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40954. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40955. v := m.wx_wxid
  40956. if v == nil {
  40957. return
  40958. }
  40959. return *v, true
  40960. }
  40961. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40962. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40964. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40965. if !m.op.Is(OpUpdateOne) {
  40966. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40967. }
  40968. if m.id == nil || m.oldValue == nil {
  40969. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40970. }
  40971. oldValue, err := m.oldValue(ctx)
  40972. if err != nil {
  40973. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40974. }
  40975. return oldValue.WxWxid, nil
  40976. }
  40977. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40978. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40979. m.wx_wxid = nil
  40980. }
  40981. // SetWxid sets the "wxid" field.
  40982. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40983. m.wxid = &s
  40984. }
  40985. // Wxid returns the value of the "wxid" field in the mutation.
  40986. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40987. v := m.wxid
  40988. if v == nil {
  40989. return
  40990. }
  40991. return *v, true
  40992. }
  40993. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40994. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40996. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40997. if !m.op.Is(OpUpdateOne) {
  40998. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40999. }
  41000. if m.id == nil || m.oldValue == nil {
  41001. return v, errors.New("OldWxid requires an ID field in the mutation")
  41002. }
  41003. oldValue, err := m.oldValue(ctx)
  41004. if err != nil {
  41005. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41006. }
  41007. return oldValue.Wxid, nil
  41008. }
  41009. // ResetWxid resets all changes to the "wxid" field.
  41010. func (m *WpChatroomMemberMutation) ResetWxid() {
  41011. m.wxid = nil
  41012. }
  41013. // SetNickname sets the "nickname" field.
  41014. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  41015. m.nickname = &s
  41016. }
  41017. // Nickname returns the value of the "nickname" field in the mutation.
  41018. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  41019. v := m.nickname
  41020. if v == nil {
  41021. return
  41022. }
  41023. return *v, true
  41024. }
  41025. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  41026. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41028. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  41029. if !m.op.Is(OpUpdateOne) {
  41030. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41031. }
  41032. if m.id == nil || m.oldValue == nil {
  41033. return v, errors.New("OldNickname requires an ID field in the mutation")
  41034. }
  41035. oldValue, err := m.oldValue(ctx)
  41036. if err != nil {
  41037. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41038. }
  41039. return oldValue.Nickname, nil
  41040. }
  41041. // ResetNickname resets all changes to the "nickname" field.
  41042. func (m *WpChatroomMemberMutation) ResetNickname() {
  41043. m.nickname = nil
  41044. }
  41045. // SetAvatar sets the "avatar" field.
  41046. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  41047. m.avatar = &s
  41048. }
  41049. // Avatar returns the value of the "avatar" field in the mutation.
  41050. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  41051. v := m.avatar
  41052. if v == nil {
  41053. return
  41054. }
  41055. return *v, true
  41056. }
  41057. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  41058. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41060. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41061. if !m.op.Is(OpUpdateOne) {
  41062. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41063. }
  41064. if m.id == nil || m.oldValue == nil {
  41065. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41066. }
  41067. oldValue, err := m.oldValue(ctx)
  41068. if err != nil {
  41069. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41070. }
  41071. return oldValue.Avatar, nil
  41072. }
  41073. // ResetAvatar resets all changes to the "avatar" field.
  41074. func (m *WpChatroomMemberMutation) ResetAvatar() {
  41075. m.avatar = nil
  41076. }
  41077. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  41078. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  41079. m.predicates = append(m.predicates, ps...)
  41080. }
  41081. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  41082. // users can use type-assertion to append predicates that do not depend on any generated package.
  41083. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  41084. p := make([]predicate.WpChatroomMember, len(ps))
  41085. for i := range ps {
  41086. p[i] = ps[i]
  41087. }
  41088. m.Where(p...)
  41089. }
  41090. // Op returns the operation name.
  41091. func (m *WpChatroomMemberMutation) Op() Op {
  41092. return m.op
  41093. }
  41094. // SetOp allows setting the mutation operation.
  41095. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  41096. m.op = op
  41097. }
  41098. // Type returns the node type of this mutation (WpChatroomMember).
  41099. func (m *WpChatroomMemberMutation) Type() string {
  41100. return m.typ
  41101. }
  41102. // Fields returns all fields that were changed during this mutation. Note that in
  41103. // order to get all numeric fields that were incremented/decremented, call
  41104. // AddedFields().
  41105. func (m *WpChatroomMemberMutation) Fields() []string {
  41106. fields := make([]string, 0, 7)
  41107. if m.created_at != nil {
  41108. fields = append(fields, wpchatroommember.FieldCreatedAt)
  41109. }
  41110. if m.updated_at != nil {
  41111. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  41112. }
  41113. if m.status != nil {
  41114. fields = append(fields, wpchatroommember.FieldStatus)
  41115. }
  41116. if m.wx_wxid != nil {
  41117. fields = append(fields, wpchatroommember.FieldWxWxid)
  41118. }
  41119. if m.wxid != nil {
  41120. fields = append(fields, wpchatroommember.FieldWxid)
  41121. }
  41122. if m.nickname != nil {
  41123. fields = append(fields, wpchatroommember.FieldNickname)
  41124. }
  41125. if m.avatar != nil {
  41126. fields = append(fields, wpchatroommember.FieldAvatar)
  41127. }
  41128. return fields
  41129. }
  41130. // Field returns the value of a field with the given name. The second boolean
  41131. // return value indicates that this field was not set, or was not defined in the
  41132. // schema.
  41133. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  41134. switch name {
  41135. case wpchatroommember.FieldCreatedAt:
  41136. return m.CreatedAt()
  41137. case wpchatroommember.FieldUpdatedAt:
  41138. return m.UpdatedAt()
  41139. case wpchatroommember.FieldStatus:
  41140. return m.Status()
  41141. case wpchatroommember.FieldWxWxid:
  41142. return m.WxWxid()
  41143. case wpchatroommember.FieldWxid:
  41144. return m.Wxid()
  41145. case wpchatroommember.FieldNickname:
  41146. return m.Nickname()
  41147. case wpchatroommember.FieldAvatar:
  41148. return m.Avatar()
  41149. }
  41150. return nil, false
  41151. }
  41152. // OldField returns the old value of the field from the database. An error is
  41153. // returned if the mutation operation is not UpdateOne, or the query to the
  41154. // database failed.
  41155. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41156. switch name {
  41157. case wpchatroommember.FieldCreatedAt:
  41158. return m.OldCreatedAt(ctx)
  41159. case wpchatroommember.FieldUpdatedAt:
  41160. return m.OldUpdatedAt(ctx)
  41161. case wpchatroommember.FieldStatus:
  41162. return m.OldStatus(ctx)
  41163. case wpchatroommember.FieldWxWxid:
  41164. return m.OldWxWxid(ctx)
  41165. case wpchatroommember.FieldWxid:
  41166. return m.OldWxid(ctx)
  41167. case wpchatroommember.FieldNickname:
  41168. return m.OldNickname(ctx)
  41169. case wpchatroommember.FieldAvatar:
  41170. return m.OldAvatar(ctx)
  41171. }
  41172. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  41173. }
  41174. // SetField sets the value of a field with the given name. It returns an error if
  41175. // the field is not defined in the schema, or if the type mismatched the field
  41176. // type.
  41177. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  41178. switch name {
  41179. case wpchatroommember.FieldCreatedAt:
  41180. v, ok := value.(time.Time)
  41181. if !ok {
  41182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41183. }
  41184. m.SetCreatedAt(v)
  41185. return nil
  41186. case wpchatroommember.FieldUpdatedAt:
  41187. v, ok := value.(time.Time)
  41188. if !ok {
  41189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41190. }
  41191. m.SetUpdatedAt(v)
  41192. return nil
  41193. case wpchatroommember.FieldStatus:
  41194. v, ok := value.(uint8)
  41195. if !ok {
  41196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41197. }
  41198. m.SetStatus(v)
  41199. return nil
  41200. case wpchatroommember.FieldWxWxid:
  41201. v, ok := value.(string)
  41202. if !ok {
  41203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41204. }
  41205. m.SetWxWxid(v)
  41206. return nil
  41207. case wpchatroommember.FieldWxid:
  41208. v, ok := value.(string)
  41209. if !ok {
  41210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41211. }
  41212. m.SetWxid(v)
  41213. return nil
  41214. case wpchatroommember.FieldNickname:
  41215. v, ok := value.(string)
  41216. if !ok {
  41217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41218. }
  41219. m.SetNickname(v)
  41220. return nil
  41221. case wpchatroommember.FieldAvatar:
  41222. v, ok := value.(string)
  41223. if !ok {
  41224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41225. }
  41226. m.SetAvatar(v)
  41227. return nil
  41228. }
  41229. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41230. }
  41231. // AddedFields returns all numeric fields that were incremented/decremented during
  41232. // this mutation.
  41233. func (m *WpChatroomMemberMutation) AddedFields() []string {
  41234. var fields []string
  41235. if m.addstatus != nil {
  41236. fields = append(fields, wpchatroommember.FieldStatus)
  41237. }
  41238. return fields
  41239. }
  41240. // AddedField returns the numeric value that was incremented/decremented on a field
  41241. // with the given name. The second boolean return value indicates that this field
  41242. // was not set, or was not defined in the schema.
  41243. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  41244. switch name {
  41245. case wpchatroommember.FieldStatus:
  41246. return m.AddedStatus()
  41247. }
  41248. return nil, false
  41249. }
  41250. // AddField adds the value to the field with the given name. It returns an error if
  41251. // the field is not defined in the schema, or if the type mismatched the field
  41252. // type.
  41253. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  41254. switch name {
  41255. case wpchatroommember.FieldStatus:
  41256. v, ok := value.(int8)
  41257. if !ok {
  41258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41259. }
  41260. m.AddStatus(v)
  41261. return nil
  41262. }
  41263. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  41264. }
  41265. // ClearedFields returns all nullable fields that were cleared during this
  41266. // mutation.
  41267. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  41268. var fields []string
  41269. if m.FieldCleared(wpchatroommember.FieldStatus) {
  41270. fields = append(fields, wpchatroommember.FieldStatus)
  41271. }
  41272. return fields
  41273. }
  41274. // FieldCleared returns a boolean indicating if a field with the given name was
  41275. // cleared in this mutation.
  41276. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  41277. _, ok := m.clearedFields[name]
  41278. return ok
  41279. }
  41280. // ClearField clears the value of the field with the given name. It returns an
  41281. // error if the field is not defined in the schema.
  41282. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  41283. switch name {
  41284. case wpchatroommember.FieldStatus:
  41285. m.ClearStatus()
  41286. return nil
  41287. }
  41288. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41289. }
  41290. // ResetField resets all changes in the mutation for the field with the given name.
  41291. // It returns an error if the field is not defined in the schema.
  41292. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41293. switch name {
  41294. case wpchatroommember.FieldCreatedAt:
  41295. m.ResetCreatedAt()
  41296. return nil
  41297. case wpchatroommember.FieldUpdatedAt:
  41298. m.ResetUpdatedAt()
  41299. return nil
  41300. case wpchatroommember.FieldStatus:
  41301. m.ResetStatus()
  41302. return nil
  41303. case wpchatroommember.FieldWxWxid:
  41304. m.ResetWxWxid()
  41305. return nil
  41306. case wpchatroommember.FieldWxid:
  41307. m.ResetWxid()
  41308. return nil
  41309. case wpchatroommember.FieldNickname:
  41310. m.ResetNickname()
  41311. return nil
  41312. case wpchatroommember.FieldAvatar:
  41313. m.ResetAvatar()
  41314. return nil
  41315. }
  41316. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41317. }
  41318. // AddedEdges returns all edge names that were set/added in this mutation.
  41319. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  41320. edges := make([]string, 0, 0)
  41321. return edges
  41322. }
  41323. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41324. // name in this mutation.
  41325. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  41326. return nil
  41327. }
  41328. // RemovedEdges returns all edge names that were removed in this mutation.
  41329. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  41330. edges := make([]string, 0, 0)
  41331. return edges
  41332. }
  41333. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41334. // the given name in this mutation.
  41335. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  41336. return nil
  41337. }
  41338. // ClearedEdges returns all edge names that were cleared in this mutation.
  41339. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  41340. edges := make([]string, 0, 0)
  41341. return edges
  41342. }
  41343. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41344. // was cleared in this mutation.
  41345. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  41346. return false
  41347. }
  41348. // ClearEdge clears the value of the edge with the given name. It returns an error
  41349. // if that edge is not defined in the schema.
  41350. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  41351. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  41352. }
  41353. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41354. // It returns an error if the edge is not defined in the schema.
  41355. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  41356. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  41357. }
  41358. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  41359. type WxMutation struct {
  41360. config
  41361. op Op
  41362. typ string
  41363. id *uint64
  41364. created_at *time.Time
  41365. updated_at *time.Time
  41366. status *uint8
  41367. addstatus *int8
  41368. deleted_at *time.Time
  41369. port *string
  41370. process_id *string
  41371. callback *string
  41372. wxid *string
  41373. account *string
  41374. nickname *string
  41375. tel *string
  41376. head_big *string
  41377. organization_id *uint64
  41378. addorganization_id *int64
  41379. api_base *string
  41380. api_key *string
  41381. allow_list *[]string
  41382. appendallow_list []string
  41383. group_allow_list *[]string
  41384. appendgroup_allow_list []string
  41385. block_list *[]string
  41386. appendblock_list []string
  41387. group_block_list *[]string
  41388. appendgroup_block_list []string
  41389. ctype *uint64
  41390. addctype *int64
  41391. clearedFields map[string]struct{}
  41392. server *uint64
  41393. clearedserver bool
  41394. agent *uint64
  41395. clearedagent bool
  41396. done bool
  41397. oldValue func(context.Context) (*Wx, error)
  41398. predicates []predicate.Wx
  41399. }
  41400. var _ ent.Mutation = (*WxMutation)(nil)
  41401. // wxOption allows management of the mutation configuration using functional options.
  41402. type wxOption func(*WxMutation)
  41403. // newWxMutation creates new mutation for the Wx entity.
  41404. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41405. m := &WxMutation{
  41406. config: c,
  41407. op: op,
  41408. typ: TypeWx,
  41409. clearedFields: make(map[string]struct{}),
  41410. }
  41411. for _, opt := range opts {
  41412. opt(m)
  41413. }
  41414. return m
  41415. }
  41416. // withWxID sets the ID field of the mutation.
  41417. func withWxID(id uint64) wxOption {
  41418. return func(m *WxMutation) {
  41419. var (
  41420. err error
  41421. once sync.Once
  41422. value *Wx
  41423. )
  41424. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41425. once.Do(func() {
  41426. if m.done {
  41427. err = errors.New("querying old values post mutation is not allowed")
  41428. } else {
  41429. value, err = m.Client().Wx.Get(ctx, id)
  41430. }
  41431. })
  41432. return value, err
  41433. }
  41434. m.id = &id
  41435. }
  41436. }
  41437. // withWx sets the old Wx of the mutation.
  41438. func withWx(node *Wx) wxOption {
  41439. return func(m *WxMutation) {
  41440. m.oldValue = func(context.Context) (*Wx, error) {
  41441. return node, nil
  41442. }
  41443. m.id = &node.ID
  41444. }
  41445. }
  41446. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41447. // executed in a transaction (ent.Tx), a transactional client is returned.
  41448. func (m WxMutation) Client() *Client {
  41449. client := &Client{config: m.config}
  41450. client.init()
  41451. return client
  41452. }
  41453. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41454. // it returns an error otherwise.
  41455. func (m WxMutation) Tx() (*Tx, error) {
  41456. if _, ok := m.driver.(*txDriver); !ok {
  41457. return nil, errors.New("ent: mutation is not running in a transaction")
  41458. }
  41459. tx := &Tx{config: m.config}
  41460. tx.init()
  41461. return tx, nil
  41462. }
  41463. // SetID sets the value of the id field. Note that this
  41464. // operation is only accepted on creation of Wx entities.
  41465. func (m *WxMutation) SetID(id uint64) {
  41466. m.id = &id
  41467. }
  41468. // ID returns the ID value in the mutation. Note that the ID is only available
  41469. // if it was provided to the builder or after it was returned from the database.
  41470. func (m *WxMutation) ID() (id uint64, exists bool) {
  41471. if m.id == nil {
  41472. return
  41473. }
  41474. return *m.id, true
  41475. }
  41476. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41477. // That means, if the mutation is applied within a transaction with an isolation level such
  41478. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41479. // or updated by the mutation.
  41480. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41481. switch {
  41482. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41483. id, exists := m.ID()
  41484. if exists {
  41485. return []uint64{id}, nil
  41486. }
  41487. fallthrough
  41488. case m.op.Is(OpUpdate | OpDelete):
  41489. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41490. default:
  41491. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41492. }
  41493. }
  41494. // SetCreatedAt sets the "created_at" field.
  41495. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41496. m.created_at = &t
  41497. }
  41498. // CreatedAt returns the value of the "created_at" field in the mutation.
  41499. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41500. v := m.created_at
  41501. if v == nil {
  41502. return
  41503. }
  41504. return *v, true
  41505. }
  41506. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41507. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41509. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41510. if !m.op.Is(OpUpdateOne) {
  41511. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41512. }
  41513. if m.id == nil || m.oldValue == nil {
  41514. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41515. }
  41516. oldValue, err := m.oldValue(ctx)
  41517. if err != nil {
  41518. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41519. }
  41520. return oldValue.CreatedAt, nil
  41521. }
  41522. // ResetCreatedAt resets all changes to the "created_at" field.
  41523. func (m *WxMutation) ResetCreatedAt() {
  41524. m.created_at = nil
  41525. }
  41526. // SetUpdatedAt sets the "updated_at" field.
  41527. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41528. m.updated_at = &t
  41529. }
  41530. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41531. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41532. v := m.updated_at
  41533. if v == nil {
  41534. return
  41535. }
  41536. return *v, true
  41537. }
  41538. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41539. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41541. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41542. if !m.op.Is(OpUpdateOne) {
  41543. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41544. }
  41545. if m.id == nil || m.oldValue == nil {
  41546. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41547. }
  41548. oldValue, err := m.oldValue(ctx)
  41549. if err != nil {
  41550. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41551. }
  41552. return oldValue.UpdatedAt, nil
  41553. }
  41554. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41555. func (m *WxMutation) ResetUpdatedAt() {
  41556. m.updated_at = nil
  41557. }
  41558. // SetStatus sets the "status" field.
  41559. func (m *WxMutation) SetStatus(u uint8) {
  41560. m.status = &u
  41561. m.addstatus = nil
  41562. }
  41563. // Status returns the value of the "status" field in the mutation.
  41564. func (m *WxMutation) Status() (r uint8, exists bool) {
  41565. v := m.status
  41566. if v == nil {
  41567. return
  41568. }
  41569. return *v, true
  41570. }
  41571. // OldStatus returns the old "status" field's value of the Wx entity.
  41572. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41574. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41575. if !m.op.Is(OpUpdateOne) {
  41576. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41577. }
  41578. if m.id == nil || m.oldValue == nil {
  41579. return v, errors.New("OldStatus requires an ID field in the mutation")
  41580. }
  41581. oldValue, err := m.oldValue(ctx)
  41582. if err != nil {
  41583. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41584. }
  41585. return oldValue.Status, nil
  41586. }
  41587. // AddStatus adds u to the "status" field.
  41588. func (m *WxMutation) AddStatus(u int8) {
  41589. if m.addstatus != nil {
  41590. *m.addstatus += u
  41591. } else {
  41592. m.addstatus = &u
  41593. }
  41594. }
  41595. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41596. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41597. v := m.addstatus
  41598. if v == nil {
  41599. return
  41600. }
  41601. return *v, true
  41602. }
  41603. // ClearStatus clears the value of the "status" field.
  41604. func (m *WxMutation) ClearStatus() {
  41605. m.status = nil
  41606. m.addstatus = nil
  41607. m.clearedFields[wx.FieldStatus] = struct{}{}
  41608. }
  41609. // StatusCleared returns if the "status" field was cleared in this mutation.
  41610. func (m *WxMutation) StatusCleared() bool {
  41611. _, ok := m.clearedFields[wx.FieldStatus]
  41612. return ok
  41613. }
  41614. // ResetStatus resets all changes to the "status" field.
  41615. func (m *WxMutation) ResetStatus() {
  41616. m.status = nil
  41617. m.addstatus = nil
  41618. delete(m.clearedFields, wx.FieldStatus)
  41619. }
  41620. // SetDeletedAt sets the "deleted_at" field.
  41621. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41622. m.deleted_at = &t
  41623. }
  41624. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41625. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41626. v := m.deleted_at
  41627. if v == nil {
  41628. return
  41629. }
  41630. return *v, true
  41631. }
  41632. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41633. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41635. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41636. if !m.op.Is(OpUpdateOne) {
  41637. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41638. }
  41639. if m.id == nil || m.oldValue == nil {
  41640. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41641. }
  41642. oldValue, err := m.oldValue(ctx)
  41643. if err != nil {
  41644. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41645. }
  41646. return oldValue.DeletedAt, nil
  41647. }
  41648. // ClearDeletedAt clears the value of the "deleted_at" field.
  41649. func (m *WxMutation) ClearDeletedAt() {
  41650. m.deleted_at = nil
  41651. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41652. }
  41653. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41654. func (m *WxMutation) DeletedAtCleared() bool {
  41655. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41656. return ok
  41657. }
  41658. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41659. func (m *WxMutation) ResetDeletedAt() {
  41660. m.deleted_at = nil
  41661. delete(m.clearedFields, wx.FieldDeletedAt)
  41662. }
  41663. // SetServerID sets the "server_id" field.
  41664. func (m *WxMutation) SetServerID(u uint64) {
  41665. m.server = &u
  41666. }
  41667. // ServerID returns the value of the "server_id" field in the mutation.
  41668. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41669. v := m.server
  41670. if v == nil {
  41671. return
  41672. }
  41673. return *v, true
  41674. }
  41675. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41676. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41678. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41679. if !m.op.Is(OpUpdateOne) {
  41680. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41681. }
  41682. if m.id == nil || m.oldValue == nil {
  41683. return v, errors.New("OldServerID requires an ID field in the mutation")
  41684. }
  41685. oldValue, err := m.oldValue(ctx)
  41686. if err != nil {
  41687. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41688. }
  41689. return oldValue.ServerID, nil
  41690. }
  41691. // ClearServerID clears the value of the "server_id" field.
  41692. func (m *WxMutation) ClearServerID() {
  41693. m.server = nil
  41694. m.clearedFields[wx.FieldServerID] = struct{}{}
  41695. }
  41696. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41697. func (m *WxMutation) ServerIDCleared() bool {
  41698. _, ok := m.clearedFields[wx.FieldServerID]
  41699. return ok
  41700. }
  41701. // ResetServerID resets all changes to the "server_id" field.
  41702. func (m *WxMutation) ResetServerID() {
  41703. m.server = nil
  41704. delete(m.clearedFields, wx.FieldServerID)
  41705. }
  41706. // SetPort sets the "port" field.
  41707. func (m *WxMutation) SetPort(s string) {
  41708. m.port = &s
  41709. }
  41710. // Port returns the value of the "port" field in the mutation.
  41711. func (m *WxMutation) Port() (r string, exists bool) {
  41712. v := m.port
  41713. if v == nil {
  41714. return
  41715. }
  41716. return *v, true
  41717. }
  41718. // OldPort returns the old "port" field's value of the Wx entity.
  41719. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41721. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41722. if !m.op.Is(OpUpdateOne) {
  41723. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41724. }
  41725. if m.id == nil || m.oldValue == nil {
  41726. return v, errors.New("OldPort requires an ID field in the mutation")
  41727. }
  41728. oldValue, err := m.oldValue(ctx)
  41729. if err != nil {
  41730. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41731. }
  41732. return oldValue.Port, nil
  41733. }
  41734. // ResetPort resets all changes to the "port" field.
  41735. func (m *WxMutation) ResetPort() {
  41736. m.port = nil
  41737. }
  41738. // SetProcessID sets the "process_id" field.
  41739. func (m *WxMutation) SetProcessID(s string) {
  41740. m.process_id = &s
  41741. }
  41742. // ProcessID returns the value of the "process_id" field in the mutation.
  41743. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41744. v := m.process_id
  41745. if v == nil {
  41746. return
  41747. }
  41748. return *v, true
  41749. }
  41750. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41751. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41753. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41754. if !m.op.Is(OpUpdateOne) {
  41755. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41756. }
  41757. if m.id == nil || m.oldValue == nil {
  41758. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41759. }
  41760. oldValue, err := m.oldValue(ctx)
  41761. if err != nil {
  41762. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41763. }
  41764. return oldValue.ProcessID, nil
  41765. }
  41766. // ResetProcessID resets all changes to the "process_id" field.
  41767. func (m *WxMutation) ResetProcessID() {
  41768. m.process_id = nil
  41769. }
  41770. // SetCallback sets the "callback" field.
  41771. func (m *WxMutation) SetCallback(s string) {
  41772. m.callback = &s
  41773. }
  41774. // Callback returns the value of the "callback" field in the mutation.
  41775. func (m *WxMutation) Callback() (r string, exists bool) {
  41776. v := m.callback
  41777. if v == nil {
  41778. return
  41779. }
  41780. return *v, true
  41781. }
  41782. // OldCallback returns the old "callback" field's value of the Wx entity.
  41783. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41785. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41786. if !m.op.Is(OpUpdateOne) {
  41787. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41788. }
  41789. if m.id == nil || m.oldValue == nil {
  41790. return v, errors.New("OldCallback requires an ID field in the mutation")
  41791. }
  41792. oldValue, err := m.oldValue(ctx)
  41793. if err != nil {
  41794. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41795. }
  41796. return oldValue.Callback, nil
  41797. }
  41798. // ResetCallback resets all changes to the "callback" field.
  41799. func (m *WxMutation) ResetCallback() {
  41800. m.callback = nil
  41801. }
  41802. // SetWxid sets the "wxid" field.
  41803. func (m *WxMutation) SetWxid(s string) {
  41804. m.wxid = &s
  41805. }
  41806. // Wxid returns the value of the "wxid" field in the mutation.
  41807. func (m *WxMutation) Wxid() (r string, exists bool) {
  41808. v := m.wxid
  41809. if v == nil {
  41810. return
  41811. }
  41812. return *v, true
  41813. }
  41814. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41815. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41817. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41818. if !m.op.Is(OpUpdateOne) {
  41819. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41820. }
  41821. if m.id == nil || m.oldValue == nil {
  41822. return v, errors.New("OldWxid requires an ID field in the mutation")
  41823. }
  41824. oldValue, err := m.oldValue(ctx)
  41825. if err != nil {
  41826. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41827. }
  41828. return oldValue.Wxid, nil
  41829. }
  41830. // ResetWxid resets all changes to the "wxid" field.
  41831. func (m *WxMutation) ResetWxid() {
  41832. m.wxid = nil
  41833. }
  41834. // SetAccount sets the "account" field.
  41835. func (m *WxMutation) SetAccount(s string) {
  41836. m.account = &s
  41837. }
  41838. // Account returns the value of the "account" field in the mutation.
  41839. func (m *WxMutation) Account() (r string, exists bool) {
  41840. v := m.account
  41841. if v == nil {
  41842. return
  41843. }
  41844. return *v, true
  41845. }
  41846. // OldAccount returns the old "account" field's value of the Wx entity.
  41847. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41849. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41850. if !m.op.Is(OpUpdateOne) {
  41851. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41852. }
  41853. if m.id == nil || m.oldValue == nil {
  41854. return v, errors.New("OldAccount requires an ID field in the mutation")
  41855. }
  41856. oldValue, err := m.oldValue(ctx)
  41857. if err != nil {
  41858. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41859. }
  41860. return oldValue.Account, nil
  41861. }
  41862. // ResetAccount resets all changes to the "account" field.
  41863. func (m *WxMutation) ResetAccount() {
  41864. m.account = nil
  41865. }
  41866. // SetNickname sets the "nickname" field.
  41867. func (m *WxMutation) SetNickname(s string) {
  41868. m.nickname = &s
  41869. }
  41870. // Nickname returns the value of the "nickname" field in the mutation.
  41871. func (m *WxMutation) Nickname() (r string, exists bool) {
  41872. v := m.nickname
  41873. if v == nil {
  41874. return
  41875. }
  41876. return *v, true
  41877. }
  41878. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41879. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41881. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41882. if !m.op.Is(OpUpdateOne) {
  41883. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41884. }
  41885. if m.id == nil || m.oldValue == nil {
  41886. return v, errors.New("OldNickname requires an ID field in the mutation")
  41887. }
  41888. oldValue, err := m.oldValue(ctx)
  41889. if err != nil {
  41890. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41891. }
  41892. return oldValue.Nickname, nil
  41893. }
  41894. // ResetNickname resets all changes to the "nickname" field.
  41895. func (m *WxMutation) ResetNickname() {
  41896. m.nickname = nil
  41897. }
  41898. // SetTel sets the "tel" field.
  41899. func (m *WxMutation) SetTel(s string) {
  41900. m.tel = &s
  41901. }
  41902. // Tel returns the value of the "tel" field in the mutation.
  41903. func (m *WxMutation) Tel() (r string, exists bool) {
  41904. v := m.tel
  41905. if v == nil {
  41906. return
  41907. }
  41908. return *v, true
  41909. }
  41910. // OldTel returns the old "tel" field's value of the Wx entity.
  41911. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41913. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41914. if !m.op.Is(OpUpdateOne) {
  41915. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41916. }
  41917. if m.id == nil || m.oldValue == nil {
  41918. return v, errors.New("OldTel requires an ID field in the mutation")
  41919. }
  41920. oldValue, err := m.oldValue(ctx)
  41921. if err != nil {
  41922. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41923. }
  41924. return oldValue.Tel, nil
  41925. }
  41926. // ResetTel resets all changes to the "tel" field.
  41927. func (m *WxMutation) ResetTel() {
  41928. m.tel = nil
  41929. }
  41930. // SetHeadBig sets the "head_big" field.
  41931. func (m *WxMutation) SetHeadBig(s string) {
  41932. m.head_big = &s
  41933. }
  41934. // HeadBig returns the value of the "head_big" field in the mutation.
  41935. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41936. v := m.head_big
  41937. if v == nil {
  41938. return
  41939. }
  41940. return *v, true
  41941. }
  41942. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41943. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41945. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41946. if !m.op.Is(OpUpdateOne) {
  41947. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41948. }
  41949. if m.id == nil || m.oldValue == nil {
  41950. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41951. }
  41952. oldValue, err := m.oldValue(ctx)
  41953. if err != nil {
  41954. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41955. }
  41956. return oldValue.HeadBig, nil
  41957. }
  41958. // ResetHeadBig resets all changes to the "head_big" field.
  41959. func (m *WxMutation) ResetHeadBig() {
  41960. m.head_big = nil
  41961. }
  41962. // SetOrganizationID sets the "organization_id" field.
  41963. func (m *WxMutation) SetOrganizationID(u uint64) {
  41964. m.organization_id = &u
  41965. m.addorganization_id = nil
  41966. }
  41967. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41968. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41969. v := m.organization_id
  41970. if v == nil {
  41971. return
  41972. }
  41973. return *v, true
  41974. }
  41975. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41976. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41978. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41979. if !m.op.Is(OpUpdateOne) {
  41980. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41981. }
  41982. if m.id == nil || m.oldValue == nil {
  41983. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41984. }
  41985. oldValue, err := m.oldValue(ctx)
  41986. if err != nil {
  41987. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41988. }
  41989. return oldValue.OrganizationID, nil
  41990. }
  41991. // AddOrganizationID adds u to the "organization_id" field.
  41992. func (m *WxMutation) AddOrganizationID(u int64) {
  41993. if m.addorganization_id != nil {
  41994. *m.addorganization_id += u
  41995. } else {
  41996. m.addorganization_id = &u
  41997. }
  41998. }
  41999. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42000. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  42001. v := m.addorganization_id
  42002. if v == nil {
  42003. return
  42004. }
  42005. return *v, true
  42006. }
  42007. // ClearOrganizationID clears the value of the "organization_id" field.
  42008. func (m *WxMutation) ClearOrganizationID() {
  42009. m.organization_id = nil
  42010. m.addorganization_id = nil
  42011. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  42012. }
  42013. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42014. func (m *WxMutation) OrganizationIDCleared() bool {
  42015. _, ok := m.clearedFields[wx.FieldOrganizationID]
  42016. return ok
  42017. }
  42018. // ResetOrganizationID resets all changes to the "organization_id" field.
  42019. func (m *WxMutation) ResetOrganizationID() {
  42020. m.organization_id = nil
  42021. m.addorganization_id = nil
  42022. delete(m.clearedFields, wx.FieldOrganizationID)
  42023. }
  42024. // SetAgentID sets the "agent_id" field.
  42025. func (m *WxMutation) SetAgentID(u uint64) {
  42026. m.agent = &u
  42027. }
  42028. // AgentID returns the value of the "agent_id" field in the mutation.
  42029. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  42030. v := m.agent
  42031. if v == nil {
  42032. return
  42033. }
  42034. return *v, true
  42035. }
  42036. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  42037. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42039. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42040. if !m.op.Is(OpUpdateOne) {
  42041. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42042. }
  42043. if m.id == nil || m.oldValue == nil {
  42044. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42045. }
  42046. oldValue, err := m.oldValue(ctx)
  42047. if err != nil {
  42048. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42049. }
  42050. return oldValue.AgentID, nil
  42051. }
  42052. // ResetAgentID resets all changes to the "agent_id" field.
  42053. func (m *WxMutation) ResetAgentID() {
  42054. m.agent = nil
  42055. }
  42056. // SetAPIBase sets the "api_base" field.
  42057. func (m *WxMutation) SetAPIBase(s string) {
  42058. m.api_base = &s
  42059. }
  42060. // APIBase returns the value of the "api_base" field in the mutation.
  42061. func (m *WxMutation) APIBase() (r string, exists bool) {
  42062. v := m.api_base
  42063. if v == nil {
  42064. return
  42065. }
  42066. return *v, true
  42067. }
  42068. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  42069. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42071. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42072. if !m.op.Is(OpUpdateOne) {
  42073. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42074. }
  42075. if m.id == nil || m.oldValue == nil {
  42076. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42077. }
  42078. oldValue, err := m.oldValue(ctx)
  42079. if err != nil {
  42080. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42081. }
  42082. return oldValue.APIBase, nil
  42083. }
  42084. // ClearAPIBase clears the value of the "api_base" field.
  42085. func (m *WxMutation) ClearAPIBase() {
  42086. m.api_base = nil
  42087. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  42088. }
  42089. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42090. func (m *WxMutation) APIBaseCleared() bool {
  42091. _, ok := m.clearedFields[wx.FieldAPIBase]
  42092. return ok
  42093. }
  42094. // ResetAPIBase resets all changes to the "api_base" field.
  42095. func (m *WxMutation) ResetAPIBase() {
  42096. m.api_base = nil
  42097. delete(m.clearedFields, wx.FieldAPIBase)
  42098. }
  42099. // SetAPIKey sets the "api_key" field.
  42100. func (m *WxMutation) SetAPIKey(s string) {
  42101. m.api_key = &s
  42102. }
  42103. // APIKey returns the value of the "api_key" field in the mutation.
  42104. func (m *WxMutation) APIKey() (r string, exists bool) {
  42105. v := m.api_key
  42106. if v == nil {
  42107. return
  42108. }
  42109. return *v, true
  42110. }
  42111. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  42112. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42114. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42115. if !m.op.Is(OpUpdateOne) {
  42116. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42117. }
  42118. if m.id == nil || m.oldValue == nil {
  42119. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42120. }
  42121. oldValue, err := m.oldValue(ctx)
  42122. if err != nil {
  42123. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42124. }
  42125. return oldValue.APIKey, nil
  42126. }
  42127. // ClearAPIKey clears the value of the "api_key" field.
  42128. func (m *WxMutation) ClearAPIKey() {
  42129. m.api_key = nil
  42130. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  42131. }
  42132. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42133. func (m *WxMutation) APIKeyCleared() bool {
  42134. _, ok := m.clearedFields[wx.FieldAPIKey]
  42135. return ok
  42136. }
  42137. // ResetAPIKey resets all changes to the "api_key" field.
  42138. func (m *WxMutation) ResetAPIKey() {
  42139. m.api_key = nil
  42140. delete(m.clearedFields, wx.FieldAPIKey)
  42141. }
  42142. // SetAllowList sets the "allow_list" field.
  42143. func (m *WxMutation) SetAllowList(s []string) {
  42144. m.allow_list = &s
  42145. m.appendallow_list = nil
  42146. }
  42147. // AllowList returns the value of the "allow_list" field in the mutation.
  42148. func (m *WxMutation) AllowList() (r []string, exists bool) {
  42149. v := m.allow_list
  42150. if v == nil {
  42151. return
  42152. }
  42153. return *v, true
  42154. }
  42155. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  42156. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42158. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42159. if !m.op.Is(OpUpdateOne) {
  42160. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42161. }
  42162. if m.id == nil || m.oldValue == nil {
  42163. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42164. }
  42165. oldValue, err := m.oldValue(ctx)
  42166. if err != nil {
  42167. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42168. }
  42169. return oldValue.AllowList, nil
  42170. }
  42171. // AppendAllowList adds s to the "allow_list" field.
  42172. func (m *WxMutation) AppendAllowList(s []string) {
  42173. m.appendallow_list = append(m.appendallow_list, s...)
  42174. }
  42175. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42176. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  42177. if len(m.appendallow_list) == 0 {
  42178. return nil, false
  42179. }
  42180. return m.appendallow_list, true
  42181. }
  42182. // ResetAllowList resets all changes to the "allow_list" field.
  42183. func (m *WxMutation) ResetAllowList() {
  42184. m.allow_list = nil
  42185. m.appendallow_list = nil
  42186. }
  42187. // SetGroupAllowList sets the "group_allow_list" field.
  42188. func (m *WxMutation) SetGroupAllowList(s []string) {
  42189. m.group_allow_list = &s
  42190. m.appendgroup_allow_list = nil
  42191. }
  42192. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42193. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  42194. v := m.group_allow_list
  42195. if v == nil {
  42196. return
  42197. }
  42198. return *v, true
  42199. }
  42200. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  42201. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42203. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42204. if !m.op.Is(OpUpdateOne) {
  42205. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42206. }
  42207. if m.id == nil || m.oldValue == nil {
  42208. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42209. }
  42210. oldValue, err := m.oldValue(ctx)
  42211. if err != nil {
  42212. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42213. }
  42214. return oldValue.GroupAllowList, nil
  42215. }
  42216. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42217. func (m *WxMutation) AppendGroupAllowList(s []string) {
  42218. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42219. }
  42220. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42221. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  42222. if len(m.appendgroup_allow_list) == 0 {
  42223. return nil, false
  42224. }
  42225. return m.appendgroup_allow_list, true
  42226. }
  42227. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42228. func (m *WxMutation) ResetGroupAllowList() {
  42229. m.group_allow_list = nil
  42230. m.appendgroup_allow_list = nil
  42231. }
  42232. // SetBlockList sets the "block_list" field.
  42233. func (m *WxMutation) SetBlockList(s []string) {
  42234. m.block_list = &s
  42235. m.appendblock_list = nil
  42236. }
  42237. // BlockList returns the value of the "block_list" field in the mutation.
  42238. func (m *WxMutation) BlockList() (r []string, exists bool) {
  42239. v := m.block_list
  42240. if v == nil {
  42241. return
  42242. }
  42243. return *v, true
  42244. }
  42245. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  42246. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42248. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42249. if !m.op.Is(OpUpdateOne) {
  42250. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42251. }
  42252. if m.id == nil || m.oldValue == nil {
  42253. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42254. }
  42255. oldValue, err := m.oldValue(ctx)
  42256. if err != nil {
  42257. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42258. }
  42259. return oldValue.BlockList, nil
  42260. }
  42261. // AppendBlockList adds s to the "block_list" field.
  42262. func (m *WxMutation) AppendBlockList(s []string) {
  42263. m.appendblock_list = append(m.appendblock_list, s...)
  42264. }
  42265. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42266. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  42267. if len(m.appendblock_list) == 0 {
  42268. return nil, false
  42269. }
  42270. return m.appendblock_list, true
  42271. }
  42272. // ResetBlockList resets all changes to the "block_list" field.
  42273. func (m *WxMutation) ResetBlockList() {
  42274. m.block_list = nil
  42275. m.appendblock_list = nil
  42276. }
  42277. // SetGroupBlockList sets the "group_block_list" field.
  42278. func (m *WxMutation) SetGroupBlockList(s []string) {
  42279. m.group_block_list = &s
  42280. m.appendgroup_block_list = nil
  42281. }
  42282. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42283. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  42284. v := m.group_block_list
  42285. if v == nil {
  42286. return
  42287. }
  42288. return *v, true
  42289. }
  42290. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42291. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42293. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42294. if !m.op.Is(OpUpdateOne) {
  42295. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42296. }
  42297. if m.id == nil || m.oldValue == nil {
  42298. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42299. }
  42300. oldValue, err := m.oldValue(ctx)
  42301. if err != nil {
  42302. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42303. }
  42304. return oldValue.GroupBlockList, nil
  42305. }
  42306. // AppendGroupBlockList adds s to the "group_block_list" field.
  42307. func (m *WxMutation) AppendGroupBlockList(s []string) {
  42308. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42309. }
  42310. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42311. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  42312. if len(m.appendgroup_block_list) == 0 {
  42313. return nil, false
  42314. }
  42315. return m.appendgroup_block_list, true
  42316. }
  42317. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42318. func (m *WxMutation) ResetGroupBlockList() {
  42319. m.group_block_list = nil
  42320. m.appendgroup_block_list = nil
  42321. }
  42322. // SetCtype sets the "ctype" field.
  42323. func (m *WxMutation) SetCtype(u uint64) {
  42324. m.ctype = &u
  42325. m.addctype = nil
  42326. }
  42327. // Ctype returns the value of the "ctype" field in the mutation.
  42328. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  42329. v := m.ctype
  42330. if v == nil {
  42331. return
  42332. }
  42333. return *v, true
  42334. }
  42335. // OldCtype returns the old "ctype" field's value of the Wx entity.
  42336. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42338. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  42339. if !m.op.Is(OpUpdateOne) {
  42340. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  42341. }
  42342. if m.id == nil || m.oldValue == nil {
  42343. return v, errors.New("OldCtype requires an ID field in the mutation")
  42344. }
  42345. oldValue, err := m.oldValue(ctx)
  42346. if err != nil {
  42347. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  42348. }
  42349. return oldValue.Ctype, nil
  42350. }
  42351. // AddCtype adds u to the "ctype" field.
  42352. func (m *WxMutation) AddCtype(u int64) {
  42353. if m.addctype != nil {
  42354. *m.addctype += u
  42355. } else {
  42356. m.addctype = &u
  42357. }
  42358. }
  42359. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  42360. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  42361. v := m.addctype
  42362. if v == nil {
  42363. return
  42364. }
  42365. return *v, true
  42366. }
  42367. // ClearCtype clears the value of the "ctype" field.
  42368. func (m *WxMutation) ClearCtype() {
  42369. m.ctype = nil
  42370. m.addctype = nil
  42371. m.clearedFields[wx.FieldCtype] = struct{}{}
  42372. }
  42373. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42374. func (m *WxMutation) CtypeCleared() bool {
  42375. _, ok := m.clearedFields[wx.FieldCtype]
  42376. return ok
  42377. }
  42378. // ResetCtype resets all changes to the "ctype" field.
  42379. func (m *WxMutation) ResetCtype() {
  42380. m.ctype = nil
  42381. m.addctype = nil
  42382. delete(m.clearedFields, wx.FieldCtype)
  42383. }
  42384. // ClearServer clears the "server" edge to the Server entity.
  42385. func (m *WxMutation) ClearServer() {
  42386. m.clearedserver = true
  42387. m.clearedFields[wx.FieldServerID] = struct{}{}
  42388. }
  42389. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42390. func (m *WxMutation) ServerCleared() bool {
  42391. return m.ServerIDCleared() || m.clearedserver
  42392. }
  42393. // ServerIDs returns the "server" edge IDs in the mutation.
  42394. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42395. // ServerID instead. It exists only for internal usage by the builders.
  42396. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42397. if id := m.server; id != nil {
  42398. ids = append(ids, *id)
  42399. }
  42400. return
  42401. }
  42402. // ResetServer resets all changes to the "server" edge.
  42403. func (m *WxMutation) ResetServer() {
  42404. m.server = nil
  42405. m.clearedserver = false
  42406. }
  42407. // ClearAgent clears the "agent" edge to the Agent entity.
  42408. func (m *WxMutation) ClearAgent() {
  42409. m.clearedagent = true
  42410. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42411. }
  42412. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42413. func (m *WxMutation) AgentCleared() bool {
  42414. return m.clearedagent
  42415. }
  42416. // AgentIDs returns the "agent" edge IDs in the mutation.
  42417. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42418. // AgentID instead. It exists only for internal usage by the builders.
  42419. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42420. if id := m.agent; id != nil {
  42421. ids = append(ids, *id)
  42422. }
  42423. return
  42424. }
  42425. // ResetAgent resets all changes to the "agent" edge.
  42426. func (m *WxMutation) ResetAgent() {
  42427. m.agent = nil
  42428. m.clearedagent = false
  42429. }
  42430. // Where appends a list predicates to the WxMutation builder.
  42431. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42432. m.predicates = append(m.predicates, ps...)
  42433. }
  42434. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42435. // users can use type-assertion to append predicates that do not depend on any generated package.
  42436. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42437. p := make([]predicate.Wx, len(ps))
  42438. for i := range ps {
  42439. p[i] = ps[i]
  42440. }
  42441. m.Where(p...)
  42442. }
  42443. // Op returns the operation name.
  42444. func (m *WxMutation) Op() Op {
  42445. return m.op
  42446. }
  42447. // SetOp allows setting the mutation operation.
  42448. func (m *WxMutation) SetOp(op Op) {
  42449. m.op = op
  42450. }
  42451. // Type returns the node type of this mutation (Wx).
  42452. func (m *WxMutation) Type() string {
  42453. return m.typ
  42454. }
  42455. // Fields returns all fields that were changed during this mutation. Note that in
  42456. // order to get all numeric fields that were incremented/decremented, call
  42457. // AddedFields().
  42458. func (m *WxMutation) Fields() []string {
  42459. fields := make([]string, 0, 22)
  42460. if m.created_at != nil {
  42461. fields = append(fields, wx.FieldCreatedAt)
  42462. }
  42463. if m.updated_at != nil {
  42464. fields = append(fields, wx.FieldUpdatedAt)
  42465. }
  42466. if m.status != nil {
  42467. fields = append(fields, wx.FieldStatus)
  42468. }
  42469. if m.deleted_at != nil {
  42470. fields = append(fields, wx.FieldDeletedAt)
  42471. }
  42472. if m.server != nil {
  42473. fields = append(fields, wx.FieldServerID)
  42474. }
  42475. if m.port != nil {
  42476. fields = append(fields, wx.FieldPort)
  42477. }
  42478. if m.process_id != nil {
  42479. fields = append(fields, wx.FieldProcessID)
  42480. }
  42481. if m.callback != nil {
  42482. fields = append(fields, wx.FieldCallback)
  42483. }
  42484. if m.wxid != nil {
  42485. fields = append(fields, wx.FieldWxid)
  42486. }
  42487. if m.account != nil {
  42488. fields = append(fields, wx.FieldAccount)
  42489. }
  42490. if m.nickname != nil {
  42491. fields = append(fields, wx.FieldNickname)
  42492. }
  42493. if m.tel != nil {
  42494. fields = append(fields, wx.FieldTel)
  42495. }
  42496. if m.head_big != nil {
  42497. fields = append(fields, wx.FieldHeadBig)
  42498. }
  42499. if m.organization_id != nil {
  42500. fields = append(fields, wx.FieldOrganizationID)
  42501. }
  42502. if m.agent != nil {
  42503. fields = append(fields, wx.FieldAgentID)
  42504. }
  42505. if m.api_base != nil {
  42506. fields = append(fields, wx.FieldAPIBase)
  42507. }
  42508. if m.api_key != nil {
  42509. fields = append(fields, wx.FieldAPIKey)
  42510. }
  42511. if m.allow_list != nil {
  42512. fields = append(fields, wx.FieldAllowList)
  42513. }
  42514. if m.group_allow_list != nil {
  42515. fields = append(fields, wx.FieldGroupAllowList)
  42516. }
  42517. if m.block_list != nil {
  42518. fields = append(fields, wx.FieldBlockList)
  42519. }
  42520. if m.group_block_list != nil {
  42521. fields = append(fields, wx.FieldGroupBlockList)
  42522. }
  42523. if m.ctype != nil {
  42524. fields = append(fields, wx.FieldCtype)
  42525. }
  42526. return fields
  42527. }
  42528. // Field returns the value of a field with the given name. The second boolean
  42529. // return value indicates that this field was not set, or was not defined in the
  42530. // schema.
  42531. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42532. switch name {
  42533. case wx.FieldCreatedAt:
  42534. return m.CreatedAt()
  42535. case wx.FieldUpdatedAt:
  42536. return m.UpdatedAt()
  42537. case wx.FieldStatus:
  42538. return m.Status()
  42539. case wx.FieldDeletedAt:
  42540. return m.DeletedAt()
  42541. case wx.FieldServerID:
  42542. return m.ServerID()
  42543. case wx.FieldPort:
  42544. return m.Port()
  42545. case wx.FieldProcessID:
  42546. return m.ProcessID()
  42547. case wx.FieldCallback:
  42548. return m.Callback()
  42549. case wx.FieldWxid:
  42550. return m.Wxid()
  42551. case wx.FieldAccount:
  42552. return m.Account()
  42553. case wx.FieldNickname:
  42554. return m.Nickname()
  42555. case wx.FieldTel:
  42556. return m.Tel()
  42557. case wx.FieldHeadBig:
  42558. return m.HeadBig()
  42559. case wx.FieldOrganizationID:
  42560. return m.OrganizationID()
  42561. case wx.FieldAgentID:
  42562. return m.AgentID()
  42563. case wx.FieldAPIBase:
  42564. return m.APIBase()
  42565. case wx.FieldAPIKey:
  42566. return m.APIKey()
  42567. case wx.FieldAllowList:
  42568. return m.AllowList()
  42569. case wx.FieldGroupAllowList:
  42570. return m.GroupAllowList()
  42571. case wx.FieldBlockList:
  42572. return m.BlockList()
  42573. case wx.FieldGroupBlockList:
  42574. return m.GroupBlockList()
  42575. case wx.FieldCtype:
  42576. return m.Ctype()
  42577. }
  42578. return nil, false
  42579. }
  42580. // OldField returns the old value of the field from the database. An error is
  42581. // returned if the mutation operation is not UpdateOne, or the query to the
  42582. // database failed.
  42583. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42584. switch name {
  42585. case wx.FieldCreatedAt:
  42586. return m.OldCreatedAt(ctx)
  42587. case wx.FieldUpdatedAt:
  42588. return m.OldUpdatedAt(ctx)
  42589. case wx.FieldStatus:
  42590. return m.OldStatus(ctx)
  42591. case wx.FieldDeletedAt:
  42592. return m.OldDeletedAt(ctx)
  42593. case wx.FieldServerID:
  42594. return m.OldServerID(ctx)
  42595. case wx.FieldPort:
  42596. return m.OldPort(ctx)
  42597. case wx.FieldProcessID:
  42598. return m.OldProcessID(ctx)
  42599. case wx.FieldCallback:
  42600. return m.OldCallback(ctx)
  42601. case wx.FieldWxid:
  42602. return m.OldWxid(ctx)
  42603. case wx.FieldAccount:
  42604. return m.OldAccount(ctx)
  42605. case wx.FieldNickname:
  42606. return m.OldNickname(ctx)
  42607. case wx.FieldTel:
  42608. return m.OldTel(ctx)
  42609. case wx.FieldHeadBig:
  42610. return m.OldHeadBig(ctx)
  42611. case wx.FieldOrganizationID:
  42612. return m.OldOrganizationID(ctx)
  42613. case wx.FieldAgentID:
  42614. return m.OldAgentID(ctx)
  42615. case wx.FieldAPIBase:
  42616. return m.OldAPIBase(ctx)
  42617. case wx.FieldAPIKey:
  42618. return m.OldAPIKey(ctx)
  42619. case wx.FieldAllowList:
  42620. return m.OldAllowList(ctx)
  42621. case wx.FieldGroupAllowList:
  42622. return m.OldGroupAllowList(ctx)
  42623. case wx.FieldBlockList:
  42624. return m.OldBlockList(ctx)
  42625. case wx.FieldGroupBlockList:
  42626. return m.OldGroupBlockList(ctx)
  42627. case wx.FieldCtype:
  42628. return m.OldCtype(ctx)
  42629. }
  42630. return nil, fmt.Errorf("unknown Wx field %s", name)
  42631. }
  42632. // SetField sets the value of a field with the given name. It returns an error if
  42633. // the field is not defined in the schema, or if the type mismatched the field
  42634. // type.
  42635. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42636. switch name {
  42637. case wx.FieldCreatedAt:
  42638. v, ok := value.(time.Time)
  42639. if !ok {
  42640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42641. }
  42642. m.SetCreatedAt(v)
  42643. return nil
  42644. case wx.FieldUpdatedAt:
  42645. v, ok := value.(time.Time)
  42646. if !ok {
  42647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42648. }
  42649. m.SetUpdatedAt(v)
  42650. return nil
  42651. case wx.FieldStatus:
  42652. v, ok := value.(uint8)
  42653. if !ok {
  42654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42655. }
  42656. m.SetStatus(v)
  42657. return nil
  42658. case wx.FieldDeletedAt:
  42659. v, ok := value.(time.Time)
  42660. if !ok {
  42661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42662. }
  42663. m.SetDeletedAt(v)
  42664. return nil
  42665. case wx.FieldServerID:
  42666. v, ok := value.(uint64)
  42667. if !ok {
  42668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42669. }
  42670. m.SetServerID(v)
  42671. return nil
  42672. case wx.FieldPort:
  42673. v, ok := value.(string)
  42674. if !ok {
  42675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42676. }
  42677. m.SetPort(v)
  42678. return nil
  42679. case wx.FieldProcessID:
  42680. v, ok := value.(string)
  42681. if !ok {
  42682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42683. }
  42684. m.SetProcessID(v)
  42685. return nil
  42686. case wx.FieldCallback:
  42687. v, ok := value.(string)
  42688. if !ok {
  42689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42690. }
  42691. m.SetCallback(v)
  42692. return nil
  42693. case wx.FieldWxid:
  42694. v, ok := value.(string)
  42695. if !ok {
  42696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42697. }
  42698. m.SetWxid(v)
  42699. return nil
  42700. case wx.FieldAccount:
  42701. v, ok := value.(string)
  42702. if !ok {
  42703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42704. }
  42705. m.SetAccount(v)
  42706. return nil
  42707. case wx.FieldNickname:
  42708. v, ok := value.(string)
  42709. if !ok {
  42710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42711. }
  42712. m.SetNickname(v)
  42713. return nil
  42714. case wx.FieldTel:
  42715. v, ok := value.(string)
  42716. if !ok {
  42717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42718. }
  42719. m.SetTel(v)
  42720. return nil
  42721. case wx.FieldHeadBig:
  42722. v, ok := value.(string)
  42723. if !ok {
  42724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42725. }
  42726. m.SetHeadBig(v)
  42727. return nil
  42728. case wx.FieldOrganizationID:
  42729. v, ok := value.(uint64)
  42730. if !ok {
  42731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42732. }
  42733. m.SetOrganizationID(v)
  42734. return nil
  42735. case wx.FieldAgentID:
  42736. v, ok := value.(uint64)
  42737. if !ok {
  42738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42739. }
  42740. m.SetAgentID(v)
  42741. return nil
  42742. case wx.FieldAPIBase:
  42743. v, ok := value.(string)
  42744. if !ok {
  42745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42746. }
  42747. m.SetAPIBase(v)
  42748. return nil
  42749. case wx.FieldAPIKey:
  42750. v, ok := value.(string)
  42751. if !ok {
  42752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42753. }
  42754. m.SetAPIKey(v)
  42755. return nil
  42756. case wx.FieldAllowList:
  42757. v, ok := value.([]string)
  42758. if !ok {
  42759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42760. }
  42761. m.SetAllowList(v)
  42762. return nil
  42763. case wx.FieldGroupAllowList:
  42764. v, ok := value.([]string)
  42765. if !ok {
  42766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42767. }
  42768. m.SetGroupAllowList(v)
  42769. return nil
  42770. case wx.FieldBlockList:
  42771. v, ok := value.([]string)
  42772. if !ok {
  42773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42774. }
  42775. m.SetBlockList(v)
  42776. return nil
  42777. case wx.FieldGroupBlockList:
  42778. v, ok := value.([]string)
  42779. if !ok {
  42780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42781. }
  42782. m.SetGroupBlockList(v)
  42783. return nil
  42784. case wx.FieldCtype:
  42785. v, ok := value.(uint64)
  42786. if !ok {
  42787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42788. }
  42789. m.SetCtype(v)
  42790. return nil
  42791. }
  42792. return fmt.Errorf("unknown Wx field %s", name)
  42793. }
  42794. // AddedFields returns all numeric fields that were incremented/decremented during
  42795. // this mutation.
  42796. func (m *WxMutation) AddedFields() []string {
  42797. var fields []string
  42798. if m.addstatus != nil {
  42799. fields = append(fields, wx.FieldStatus)
  42800. }
  42801. if m.addorganization_id != nil {
  42802. fields = append(fields, wx.FieldOrganizationID)
  42803. }
  42804. if m.addctype != nil {
  42805. fields = append(fields, wx.FieldCtype)
  42806. }
  42807. return fields
  42808. }
  42809. // AddedField returns the numeric value that was incremented/decremented on a field
  42810. // with the given name. The second boolean return value indicates that this field
  42811. // was not set, or was not defined in the schema.
  42812. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42813. switch name {
  42814. case wx.FieldStatus:
  42815. return m.AddedStatus()
  42816. case wx.FieldOrganizationID:
  42817. return m.AddedOrganizationID()
  42818. case wx.FieldCtype:
  42819. return m.AddedCtype()
  42820. }
  42821. return nil, false
  42822. }
  42823. // AddField adds the value to the field with the given name. It returns an error if
  42824. // the field is not defined in the schema, or if the type mismatched the field
  42825. // type.
  42826. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42827. switch name {
  42828. case wx.FieldStatus:
  42829. v, ok := value.(int8)
  42830. if !ok {
  42831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42832. }
  42833. m.AddStatus(v)
  42834. return nil
  42835. case wx.FieldOrganizationID:
  42836. v, ok := value.(int64)
  42837. if !ok {
  42838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42839. }
  42840. m.AddOrganizationID(v)
  42841. return nil
  42842. case wx.FieldCtype:
  42843. v, ok := value.(int64)
  42844. if !ok {
  42845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42846. }
  42847. m.AddCtype(v)
  42848. return nil
  42849. }
  42850. return fmt.Errorf("unknown Wx numeric field %s", name)
  42851. }
  42852. // ClearedFields returns all nullable fields that were cleared during this
  42853. // mutation.
  42854. func (m *WxMutation) ClearedFields() []string {
  42855. var fields []string
  42856. if m.FieldCleared(wx.FieldStatus) {
  42857. fields = append(fields, wx.FieldStatus)
  42858. }
  42859. if m.FieldCleared(wx.FieldDeletedAt) {
  42860. fields = append(fields, wx.FieldDeletedAt)
  42861. }
  42862. if m.FieldCleared(wx.FieldServerID) {
  42863. fields = append(fields, wx.FieldServerID)
  42864. }
  42865. if m.FieldCleared(wx.FieldOrganizationID) {
  42866. fields = append(fields, wx.FieldOrganizationID)
  42867. }
  42868. if m.FieldCleared(wx.FieldAPIBase) {
  42869. fields = append(fields, wx.FieldAPIBase)
  42870. }
  42871. if m.FieldCleared(wx.FieldAPIKey) {
  42872. fields = append(fields, wx.FieldAPIKey)
  42873. }
  42874. if m.FieldCleared(wx.FieldCtype) {
  42875. fields = append(fields, wx.FieldCtype)
  42876. }
  42877. return fields
  42878. }
  42879. // FieldCleared returns a boolean indicating if a field with the given name was
  42880. // cleared in this mutation.
  42881. func (m *WxMutation) FieldCleared(name string) bool {
  42882. _, ok := m.clearedFields[name]
  42883. return ok
  42884. }
  42885. // ClearField clears the value of the field with the given name. It returns an
  42886. // error if the field is not defined in the schema.
  42887. func (m *WxMutation) ClearField(name string) error {
  42888. switch name {
  42889. case wx.FieldStatus:
  42890. m.ClearStatus()
  42891. return nil
  42892. case wx.FieldDeletedAt:
  42893. m.ClearDeletedAt()
  42894. return nil
  42895. case wx.FieldServerID:
  42896. m.ClearServerID()
  42897. return nil
  42898. case wx.FieldOrganizationID:
  42899. m.ClearOrganizationID()
  42900. return nil
  42901. case wx.FieldAPIBase:
  42902. m.ClearAPIBase()
  42903. return nil
  42904. case wx.FieldAPIKey:
  42905. m.ClearAPIKey()
  42906. return nil
  42907. case wx.FieldCtype:
  42908. m.ClearCtype()
  42909. return nil
  42910. }
  42911. return fmt.Errorf("unknown Wx nullable field %s", name)
  42912. }
  42913. // ResetField resets all changes in the mutation for the field with the given name.
  42914. // It returns an error if the field is not defined in the schema.
  42915. func (m *WxMutation) ResetField(name string) error {
  42916. switch name {
  42917. case wx.FieldCreatedAt:
  42918. m.ResetCreatedAt()
  42919. return nil
  42920. case wx.FieldUpdatedAt:
  42921. m.ResetUpdatedAt()
  42922. return nil
  42923. case wx.FieldStatus:
  42924. m.ResetStatus()
  42925. return nil
  42926. case wx.FieldDeletedAt:
  42927. m.ResetDeletedAt()
  42928. return nil
  42929. case wx.FieldServerID:
  42930. m.ResetServerID()
  42931. return nil
  42932. case wx.FieldPort:
  42933. m.ResetPort()
  42934. return nil
  42935. case wx.FieldProcessID:
  42936. m.ResetProcessID()
  42937. return nil
  42938. case wx.FieldCallback:
  42939. m.ResetCallback()
  42940. return nil
  42941. case wx.FieldWxid:
  42942. m.ResetWxid()
  42943. return nil
  42944. case wx.FieldAccount:
  42945. m.ResetAccount()
  42946. return nil
  42947. case wx.FieldNickname:
  42948. m.ResetNickname()
  42949. return nil
  42950. case wx.FieldTel:
  42951. m.ResetTel()
  42952. return nil
  42953. case wx.FieldHeadBig:
  42954. m.ResetHeadBig()
  42955. return nil
  42956. case wx.FieldOrganizationID:
  42957. m.ResetOrganizationID()
  42958. return nil
  42959. case wx.FieldAgentID:
  42960. m.ResetAgentID()
  42961. return nil
  42962. case wx.FieldAPIBase:
  42963. m.ResetAPIBase()
  42964. return nil
  42965. case wx.FieldAPIKey:
  42966. m.ResetAPIKey()
  42967. return nil
  42968. case wx.FieldAllowList:
  42969. m.ResetAllowList()
  42970. return nil
  42971. case wx.FieldGroupAllowList:
  42972. m.ResetGroupAllowList()
  42973. return nil
  42974. case wx.FieldBlockList:
  42975. m.ResetBlockList()
  42976. return nil
  42977. case wx.FieldGroupBlockList:
  42978. m.ResetGroupBlockList()
  42979. return nil
  42980. case wx.FieldCtype:
  42981. m.ResetCtype()
  42982. return nil
  42983. }
  42984. return fmt.Errorf("unknown Wx field %s", name)
  42985. }
  42986. // AddedEdges returns all edge names that were set/added in this mutation.
  42987. func (m *WxMutation) AddedEdges() []string {
  42988. edges := make([]string, 0, 2)
  42989. if m.server != nil {
  42990. edges = append(edges, wx.EdgeServer)
  42991. }
  42992. if m.agent != nil {
  42993. edges = append(edges, wx.EdgeAgent)
  42994. }
  42995. return edges
  42996. }
  42997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42998. // name in this mutation.
  42999. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  43000. switch name {
  43001. case wx.EdgeServer:
  43002. if id := m.server; id != nil {
  43003. return []ent.Value{*id}
  43004. }
  43005. case wx.EdgeAgent:
  43006. if id := m.agent; id != nil {
  43007. return []ent.Value{*id}
  43008. }
  43009. }
  43010. return nil
  43011. }
  43012. // RemovedEdges returns all edge names that were removed in this mutation.
  43013. func (m *WxMutation) RemovedEdges() []string {
  43014. edges := make([]string, 0, 2)
  43015. return edges
  43016. }
  43017. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43018. // the given name in this mutation.
  43019. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  43020. return nil
  43021. }
  43022. // ClearedEdges returns all edge names that were cleared in this mutation.
  43023. func (m *WxMutation) ClearedEdges() []string {
  43024. edges := make([]string, 0, 2)
  43025. if m.clearedserver {
  43026. edges = append(edges, wx.EdgeServer)
  43027. }
  43028. if m.clearedagent {
  43029. edges = append(edges, wx.EdgeAgent)
  43030. }
  43031. return edges
  43032. }
  43033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43034. // was cleared in this mutation.
  43035. func (m *WxMutation) EdgeCleared(name string) bool {
  43036. switch name {
  43037. case wx.EdgeServer:
  43038. return m.clearedserver
  43039. case wx.EdgeAgent:
  43040. return m.clearedagent
  43041. }
  43042. return false
  43043. }
  43044. // ClearEdge clears the value of the edge with the given name. It returns an error
  43045. // if that edge is not defined in the schema.
  43046. func (m *WxMutation) ClearEdge(name string) error {
  43047. switch name {
  43048. case wx.EdgeServer:
  43049. m.ClearServer()
  43050. return nil
  43051. case wx.EdgeAgent:
  43052. m.ClearAgent()
  43053. return nil
  43054. }
  43055. return fmt.Errorf("unknown Wx unique edge %s", name)
  43056. }
  43057. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43058. // It returns an error if the edge is not defined in the schema.
  43059. func (m *WxMutation) ResetEdge(name string) error {
  43060. switch name {
  43061. case wx.EdgeServer:
  43062. m.ResetServer()
  43063. return nil
  43064. case wx.EdgeAgent:
  43065. m.ResetAgent()
  43066. return nil
  43067. }
  43068. return fmt.Errorf("unknown Wx edge %s", name)
  43069. }
  43070. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  43071. type WxCardMutation struct {
  43072. config
  43073. op Op
  43074. typ string
  43075. id *uint64
  43076. created_at *time.Time
  43077. updated_at *time.Time
  43078. deleted_at *time.Time
  43079. user_id *uint64
  43080. adduser_id *int64
  43081. wx_user_id *uint64
  43082. addwx_user_id *int64
  43083. avatar *string
  43084. logo *string
  43085. name *string
  43086. company *string
  43087. address *string
  43088. phone *string
  43089. official_account *string
  43090. wechat_account *string
  43091. email *string
  43092. api_base *string
  43093. api_key *string
  43094. ai_info *string
  43095. intro *string
  43096. clearedFields map[string]struct{}
  43097. done bool
  43098. oldValue func(context.Context) (*WxCard, error)
  43099. predicates []predicate.WxCard
  43100. }
  43101. var _ ent.Mutation = (*WxCardMutation)(nil)
  43102. // wxcardOption allows management of the mutation configuration using functional options.
  43103. type wxcardOption func(*WxCardMutation)
  43104. // newWxCardMutation creates new mutation for the WxCard entity.
  43105. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  43106. m := &WxCardMutation{
  43107. config: c,
  43108. op: op,
  43109. typ: TypeWxCard,
  43110. clearedFields: make(map[string]struct{}),
  43111. }
  43112. for _, opt := range opts {
  43113. opt(m)
  43114. }
  43115. return m
  43116. }
  43117. // withWxCardID sets the ID field of the mutation.
  43118. func withWxCardID(id uint64) wxcardOption {
  43119. return func(m *WxCardMutation) {
  43120. var (
  43121. err error
  43122. once sync.Once
  43123. value *WxCard
  43124. )
  43125. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  43126. once.Do(func() {
  43127. if m.done {
  43128. err = errors.New("querying old values post mutation is not allowed")
  43129. } else {
  43130. value, err = m.Client().WxCard.Get(ctx, id)
  43131. }
  43132. })
  43133. return value, err
  43134. }
  43135. m.id = &id
  43136. }
  43137. }
  43138. // withWxCard sets the old WxCard of the mutation.
  43139. func withWxCard(node *WxCard) wxcardOption {
  43140. return func(m *WxCardMutation) {
  43141. m.oldValue = func(context.Context) (*WxCard, error) {
  43142. return node, nil
  43143. }
  43144. m.id = &node.ID
  43145. }
  43146. }
  43147. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43148. // executed in a transaction (ent.Tx), a transactional client is returned.
  43149. func (m WxCardMutation) Client() *Client {
  43150. client := &Client{config: m.config}
  43151. client.init()
  43152. return client
  43153. }
  43154. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43155. // it returns an error otherwise.
  43156. func (m WxCardMutation) Tx() (*Tx, error) {
  43157. if _, ok := m.driver.(*txDriver); !ok {
  43158. return nil, errors.New("ent: mutation is not running in a transaction")
  43159. }
  43160. tx := &Tx{config: m.config}
  43161. tx.init()
  43162. return tx, nil
  43163. }
  43164. // SetID sets the value of the id field. Note that this
  43165. // operation is only accepted on creation of WxCard entities.
  43166. func (m *WxCardMutation) SetID(id uint64) {
  43167. m.id = &id
  43168. }
  43169. // ID returns the ID value in the mutation. Note that the ID is only available
  43170. // if it was provided to the builder or after it was returned from the database.
  43171. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  43172. if m.id == nil {
  43173. return
  43174. }
  43175. return *m.id, true
  43176. }
  43177. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43178. // That means, if the mutation is applied within a transaction with an isolation level such
  43179. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43180. // or updated by the mutation.
  43181. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  43182. switch {
  43183. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43184. id, exists := m.ID()
  43185. if exists {
  43186. return []uint64{id}, nil
  43187. }
  43188. fallthrough
  43189. case m.op.Is(OpUpdate | OpDelete):
  43190. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  43191. default:
  43192. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43193. }
  43194. }
  43195. // SetCreatedAt sets the "created_at" field.
  43196. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  43197. m.created_at = &t
  43198. }
  43199. // CreatedAt returns the value of the "created_at" field in the mutation.
  43200. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  43201. v := m.created_at
  43202. if v == nil {
  43203. return
  43204. }
  43205. return *v, true
  43206. }
  43207. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  43208. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43210. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43211. if !m.op.Is(OpUpdateOne) {
  43212. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43213. }
  43214. if m.id == nil || m.oldValue == nil {
  43215. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43216. }
  43217. oldValue, err := m.oldValue(ctx)
  43218. if err != nil {
  43219. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43220. }
  43221. return oldValue.CreatedAt, nil
  43222. }
  43223. // ResetCreatedAt resets all changes to the "created_at" field.
  43224. func (m *WxCardMutation) ResetCreatedAt() {
  43225. m.created_at = nil
  43226. }
  43227. // SetUpdatedAt sets the "updated_at" field.
  43228. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  43229. m.updated_at = &t
  43230. }
  43231. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43232. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  43233. v := m.updated_at
  43234. if v == nil {
  43235. return
  43236. }
  43237. return *v, true
  43238. }
  43239. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  43240. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43242. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43243. if !m.op.Is(OpUpdateOne) {
  43244. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43245. }
  43246. if m.id == nil || m.oldValue == nil {
  43247. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43248. }
  43249. oldValue, err := m.oldValue(ctx)
  43250. if err != nil {
  43251. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43252. }
  43253. return oldValue.UpdatedAt, nil
  43254. }
  43255. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43256. func (m *WxCardMutation) ResetUpdatedAt() {
  43257. m.updated_at = nil
  43258. }
  43259. // SetDeletedAt sets the "deleted_at" field.
  43260. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  43261. m.deleted_at = &t
  43262. }
  43263. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43264. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  43265. v := m.deleted_at
  43266. if v == nil {
  43267. return
  43268. }
  43269. return *v, true
  43270. }
  43271. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  43272. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43274. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43275. if !m.op.Is(OpUpdateOne) {
  43276. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43277. }
  43278. if m.id == nil || m.oldValue == nil {
  43279. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43280. }
  43281. oldValue, err := m.oldValue(ctx)
  43282. if err != nil {
  43283. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43284. }
  43285. return oldValue.DeletedAt, nil
  43286. }
  43287. // ClearDeletedAt clears the value of the "deleted_at" field.
  43288. func (m *WxCardMutation) ClearDeletedAt() {
  43289. m.deleted_at = nil
  43290. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43291. }
  43292. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43293. func (m *WxCardMutation) DeletedAtCleared() bool {
  43294. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  43295. return ok
  43296. }
  43297. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43298. func (m *WxCardMutation) ResetDeletedAt() {
  43299. m.deleted_at = nil
  43300. delete(m.clearedFields, wxcard.FieldDeletedAt)
  43301. }
  43302. // SetUserID sets the "user_id" field.
  43303. func (m *WxCardMutation) SetUserID(u uint64) {
  43304. m.user_id = &u
  43305. m.adduser_id = nil
  43306. }
  43307. // UserID returns the value of the "user_id" field in the mutation.
  43308. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  43309. v := m.user_id
  43310. if v == nil {
  43311. return
  43312. }
  43313. return *v, true
  43314. }
  43315. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  43316. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43318. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43319. if !m.op.Is(OpUpdateOne) {
  43320. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43321. }
  43322. if m.id == nil || m.oldValue == nil {
  43323. return v, errors.New("OldUserID requires an ID field in the mutation")
  43324. }
  43325. oldValue, err := m.oldValue(ctx)
  43326. if err != nil {
  43327. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43328. }
  43329. return oldValue.UserID, nil
  43330. }
  43331. // AddUserID adds u to the "user_id" field.
  43332. func (m *WxCardMutation) AddUserID(u int64) {
  43333. if m.adduser_id != nil {
  43334. *m.adduser_id += u
  43335. } else {
  43336. m.adduser_id = &u
  43337. }
  43338. }
  43339. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43340. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  43341. v := m.adduser_id
  43342. if v == nil {
  43343. return
  43344. }
  43345. return *v, true
  43346. }
  43347. // ClearUserID clears the value of the "user_id" field.
  43348. func (m *WxCardMutation) ClearUserID() {
  43349. m.user_id = nil
  43350. m.adduser_id = nil
  43351. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  43352. }
  43353. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43354. func (m *WxCardMutation) UserIDCleared() bool {
  43355. _, ok := m.clearedFields[wxcard.FieldUserID]
  43356. return ok
  43357. }
  43358. // ResetUserID resets all changes to the "user_id" field.
  43359. func (m *WxCardMutation) ResetUserID() {
  43360. m.user_id = nil
  43361. m.adduser_id = nil
  43362. delete(m.clearedFields, wxcard.FieldUserID)
  43363. }
  43364. // SetWxUserID sets the "wx_user_id" field.
  43365. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43366. m.wx_user_id = &u
  43367. m.addwx_user_id = nil
  43368. }
  43369. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43370. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43371. v := m.wx_user_id
  43372. if v == nil {
  43373. return
  43374. }
  43375. return *v, true
  43376. }
  43377. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43378. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43380. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43381. if !m.op.Is(OpUpdateOne) {
  43382. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43383. }
  43384. if m.id == nil || m.oldValue == nil {
  43385. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43386. }
  43387. oldValue, err := m.oldValue(ctx)
  43388. if err != nil {
  43389. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43390. }
  43391. return oldValue.WxUserID, nil
  43392. }
  43393. // AddWxUserID adds u to the "wx_user_id" field.
  43394. func (m *WxCardMutation) AddWxUserID(u int64) {
  43395. if m.addwx_user_id != nil {
  43396. *m.addwx_user_id += u
  43397. } else {
  43398. m.addwx_user_id = &u
  43399. }
  43400. }
  43401. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43402. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43403. v := m.addwx_user_id
  43404. if v == nil {
  43405. return
  43406. }
  43407. return *v, true
  43408. }
  43409. // ClearWxUserID clears the value of the "wx_user_id" field.
  43410. func (m *WxCardMutation) ClearWxUserID() {
  43411. m.wx_user_id = nil
  43412. m.addwx_user_id = nil
  43413. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43414. }
  43415. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43416. func (m *WxCardMutation) WxUserIDCleared() bool {
  43417. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43418. return ok
  43419. }
  43420. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43421. func (m *WxCardMutation) ResetWxUserID() {
  43422. m.wx_user_id = nil
  43423. m.addwx_user_id = nil
  43424. delete(m.clearedFields, wxcard.FieldWxUserID)
  43425. }
  43426. // SetAvatar sets the "avatar" field.
  43427. func (m *WxCardMutation) SetAvatar(s string) {
  43428. m.avatar = &s
  43429. }
  43430. // Avatar returns the value of the "avatar" field in the mutation.
  43431. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43432. v := m.avatar
  43433. if v == nil {
  43434. return
  43435. }
  43436. return *v, true
  43437. }
  43438. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43439. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43441. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43442. if !m.op.Is(OpUpdateOne) {
  43443. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43444. }
  43445. if m.id == nil || m.oldValue == nil {
  43446. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43447. }
  43448. oldValue, err := m.oldValue(ctx)
  43449. if err != nil {
  43450. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43451. }
  43452. return oldValue.Avatar, nil
  43453. }
  43454. // ResetAvatar resets all changes to the "avatar" field.
  43455. func (m *WxCardMutation) ResetAvatar() {
  43456. m.avatar = nil
  43457. }
  43458. // SetLogo sets the "logo" field.
  43459. func (m *WxCardMutation) SetLogo(s string) {
  43460. m.logo = &s
  43461. }
  43462. // Logo returns the value of the "logo" field in the mutation.
  43463. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43464. v := m.logo
  43465. if v == nil {
  43466. return
  43467. }
  43468. return *v, true
  43469. }
  43470. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43471. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43473. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43474. if !m.op.Is(OpUpdateOne) {
  43475. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43476. }
  43477. if m.id == nil || m.oldValue == nil {
  43478. return v, errors.New("OldLogo requires an ID field in the mutation")
  43479. }
  43480. oldValue, err := m.oldValue(ctx)
  43481. if err != nil {
  43482. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43483. }
  43484. return oldValue.Logo, nil
  43485. }
  43486. // ResetLogo resets all changes to the "logo" field.
  43487. func (m *WxCardMutation) ResetLogo() {
  43488. m.logo = nil
  43489. }
  43490. // SetName sets the "name" field.
  43491. func (m *WxCardMutation) SetName(s string) {
  43492. m.name = &s
  43493. }
  43494. // Name returns the value of the "name" field in the mutation.
  43495. func (m *WxCardMutation) Name() (r string, exists bool) {
  43496. v := m.name
  43497. if v == nil {
  43498. return
  43499. }
  43500. return *v, true
  43501. }
  43502. // OldName returns the old "name" field's value of the WxCard entity.
  43503. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43505. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43506. if !m.op.Is(OpUpdateOne) {
  43507. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43508. }
  43509. if m.id == nil || m.oldValue == nil {
  43510. return v, errors.New("OldName requires an ID field in the mutation")
  43511. }
  43512. oldValue, err := m.oldValue(ctx)
  43513. if err != nil {
  43514. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43515. }
  43516. return oldValue.Name, nil
  43517. }
  43518. // ResetName resets all changes to the "name" field.
  43519. func (m *WxCardMutation) ResetName() {
  43520. m.name = nil
  43521. }
  43522. // SetCompany sets the "company" field.
  43523. func (m *WxCardMutation) SetCompany(s string) {
  43524. m.company = &s
  43525. }
  43526. // Company returns the value of the "company" field in the mutation.
  43527. func (m *WxCardMutation) Company() (r string, exists bool) {
  43528. v := m.company
  43529. if v == nil {
  43530. return
  43531. }
  43532. return *v, true
  43533. }
  43534. // OldCompany returns the old "company" field's value of the WxCard entity.
  43535. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43537. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43538. if !m.op.Is(OpUpdateOne) {
  43539. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43540. }
  43541. if m.id == nil || m.oldValue == nil {
  43542. return v, errors.New("OldCompany requires an ID field in the mutation")
  43543. }
  43544. oldValue, err := m.oldValue(ctx)
  43545. if err != nil {
  43546. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43547. }
  43548. return oldValue.Company, nil
  43549. }
  43550. // ResetCompany resets all changes to the "company" field.
  43551. func (m *WxCardMutation) ResetCompany() {
  43552. m.company = nil
  43553. }
  43554. // SetAddress sets the "address" field.
  43555. func (m *WxCardMutation) SetAddress(s string) {
  43556. m.address = &s
  43557. }
  43558. // Address returns the value of the "address" field in the mutation.
  43559. func (m *WxCardMutation) Address() (r string, exists bool) {
  43560. v := m.address
  43561. if v == nil {
  43562. return
  43563. }
  43564. return *v, true
  43565. }
  43566. // OldAddress returns the old "address" field's value of the WxCard entity.
  43567. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43569. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43570. if !m.op.Is(OpUpdateOne) {
  43571. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43572. }
  43573. if m.id == nil || m.oldValue == nil {
  43574. return v, errors.New("OldAddress requires an ID field in the mutation")
  43575. }
  43576. oldValue, err := m.oldValue(ctx)
  43577. if err != nil {
  43578. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43579. }
  43580. return oldValue.Address, nil
  43581. }
  43582. // ResetAddress resets all changes to the "address" field.
  43583. func (m *WxCardMutation) ResetAddress() {
  43584. m.address = nil
  43585. }
  43586. // SetPhone sets the "phone" field.
  43587. func (m *WxCardMutation) SetPhone(s string) {
  43588. m.phone = &s
  43589. }
  43590. // Phone returns the value of the "phone" field in the mutation.
  43591. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43592. v := m.phone
  43593. if v == nil {
  43594. return
  43595. }
  43596. return *v, true
  43597. }
  43598. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43599. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43601. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43602. if !m.op.Is(OpUpdateOne) {
  43603. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43604. }
  43605. if m.id == nil || m.oldValue == nil {
  43606. return v, errors.New("OldPhone requires an ID field in the mutation")
  43607. }
  43608. oldValue, err := m.oldValue(ctx)
  43609. if err != nil {
  43610. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43611. }
  43612. return oldValue.Phone, nil
  43613. }
  43614. // ResetPhone resets all changes to the "phone" field.
  43615. func (m *WxCardMutation) ResetPhone() {
  43616. m.phone = nil
  43617. }
  43618. // SetOfficialAccount sets the "official_account" field.
  43619. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43620. m.official_account = &s
  43621. }
  43622. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43623. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43624. v := m.official_account
  43625. if v == nil {
  43626. return
  43627. }
  43628. return *v, true
  43629. }
  43630. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43631. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43633. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43634. if !m.op.Is(OpUpdateOne) {
  43635. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43636. }
  43637. if m.id == nil || m.oldValue == nil {
  43638. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43639. }
  43640. oldValue, err := m.oldValue(ctx)
  43641. if err != nil {
  43642. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43643. }
  43644. return oldValue.OfficialAccount, nil
  43645. }
  43646. // ResetOfficialAccount resets all changes to the "official_account" field.
  43647. func (m *WxCardMutation) ResetOfficialAccount() {
  43648. m.official_account = nil
  43649. }
  43650. // SetWechatAccount sets the "wechat_account" field.
  43651. func (m *WxCardMutation) SetWechatAccount(s string) {
  43652. m.wechat_account = &s
  43653. }
  43654. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43655. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43656. v := m.wechat_account
  43657. if v == nil {
  43658. return
  43659. }
  43660. return *v, true
  43661. }
  43662. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43663. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43665. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43666. if !m.op.Is(OpUpdateOne) {
  43667. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43668. }
  43669. if m.id == nil || m.oldValue == nil {
  43670. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43671. }
  43672. oldValue, err := m.oldValue(ctx)
  43673. if err != nil {
  43674. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43675. }
  43676. return oldValue.WechatAccount, nil
  43677. }
  43678. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43679. func (m *WxCardMutation) ResetWechatAccount() {
  43680. m.wechat_account = nil
  43681. }
  43682. // SetEmail sets the "email" field.
  43683. func (m *WxCardMutation) SetEmail(s string) {
  43684. m.email = &s
  43685. }
  43686. // Email returns the value of the "email" field in the mutation.
  43687. func (m *WxCardMutation) Email() (r string, exists bool) {
  43688. v := m.email
  43689. if v == nil {
  43690. return
  43691. }
  43692. return *v, true
  43693. }
  43694. // OldEmail returns the old "email" field's value of the WxCard entity.
  43695. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43697. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43698. if !m.op.Is(OpUpdateOne) {
  43699. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43700. }
  43701. if m.id == nil || m.oldValue == nil {
  43702. return v, errors.New("OldEmail requires an ID field in the mutation")
  43703. }
  43704. oldValue, err := m.oldValue(ctx)
  43705. if err != nil {
  43706. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43707. }
  43708. return oldValue.Email, nil
  43709. }
  43710. // ClearEmail clears the value of the "email" field.
  43711. func (m *WxCardMutation) ClearEmail() {
  43712. m.email = nil
  43713. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43714. }
  43715. // EmailCleared returns if the "email" field was cleared in this mutation.
  43716. func (m *WxCardMutation) EmailCleared() bool {
  43717. _, ok := m.clearedFields[wxcard.FieldEmail]
  43718. return ok
  43719. }
  43720. // ResetEmail resets all changes to the "email" field.
  43721. func (m *WxCardMutation) ResetEmail() {
  43722. m.email = nil
  43723. delete(m.clearedFields, wxcard.FieldEmail)
  43724. }
  43725. // SetAPIBase sets the "api_base" field.
  43726. func (m *WxCardMutation) SetAPIBase(s string) {
  43727. m.api_base = &s
  43728. }
  43729. // APIBase returns the value of the "api_base" field in the mutation.
  43730. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43731. v := m.api_base
  43732. if v == nil {
  43733. return
  43734. }
  43735. return *v, true
  43736. }
  43737. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43738. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43740. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43741. if !m.op.Is(OpUpdateOne) {
  43742. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43743. }
  43744. if m.id == nil || m.oldValue == nil {
  43745. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43746. }
  43747. oldValue, err := m.oldValue(ctx)
  43748. if err != nil {
  43749. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43750. }
  43751. return oldValue.APIBase, nil
  43752. }
  43753. // ClearAPIBase clears the value of the "api_base" field.
  43754. func (m *WxCardMutation) ClearAPIBase() {
  43755. m.api_base = nil
  43756. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43757. }
  43758. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43759. func (m *WxCardMutation) APIBaseCleared() bool {
  43760. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43761. return ok
  43762. }
  43763. // ResetAPIBase resets all changes to the "api_base" field.
  43764. func (m *WxCardMutation) ResetAPIBase() {
  43765. m.api_base = nil
  43766. delete(m.clearedFields, wxcard.FieldAPIBase)
  43767. }
  43768. // SetAPIKey sets the "api_key" field.
  43769. func (m *WxCardMutation) SetAPIKey(s string) {
  43770. m.api_key = &s
  43771. }
  43772. // APIKey returns the value of the "api_key" field in the mutation.
  43773. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43774. v := m.api_key
  43775. if v == nil {
  43776. return
  43777. }
  43778. return *v, true
  43779. }
  43780. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43781. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43783. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43784. if !m.op.Is(OpUpdateOne) {
  43785. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43786. }
  43787. if m.id == nil || m.oldValue == nil {
  43788. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43789. }
  43790. oldValue, err := m.oldValue(ctx)
  43791. if err != nil {
  43792. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43793. }
  43794. return oldValue.APIKey, nil
  43795. }
  43796. // ClearAPIKey clears the value of the "api_key" field.
  43797. func (m *WxCardMutation) ClearAPIKey() {
  43798. m.api_key = nil
  43799. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43800. }
  43801. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43802. func (m *WxCardMutation) APIKeyCleared() bool {
  43803. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43804. return ok
  43805. }
  43806. // ResetAPIKey resets all changes to the "api_key" field.
  43807. func (m *WxCardMutation) ResetAPIKey() {
  43808. m.api_key = nil
  43809. delete(m.clearedFields, wxcard.FieldAPIKey)
  43810. }
  43811. // SetAiInfo sets the "ai_info" field.
  43812. func (m *WxCardMutation) SetAiInfo(s string) {
  43813. m.ai_info = &s
  43814. }
  43815. // AiInfo returns the value of the "ai_info" field in the mutation.
  43816. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43817. v := m.ai_info
  43818. if v == nil {
  43819. return
  43820. }
  43821. return *v, true
  43822. }
  43823. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43824. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43826. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43827. if !m.op.Is(OpUpdateOne) {
  43828. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43829. }
  43830. if m.id == nil || m.oldValue == nil {
  43831. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43832. }
  43833. oldValue, err := m.oldValue(ctx)
  43834. if err != nil {
  43835. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43836. }
  43837. return oldValue.AiInfo, nil
  43838. }
  43839. // ClearAiInfo clears the value of the "ai_info" field.
  43840. func (m *WxCardMutation) ClearAiInfo() {
  43841. m.ai_info = nil
  43842. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43843. }
  43844. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43845. func (m *WxCardMutation) AiInfoCleared() bool {
  43846. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43847. return ok
  43848. }
  43849. // ResetAiInfo resets all changes to the "ai_info" field.
  43850. func (m *WxCardMutation) ResetAiInfo() {
  43851. m.ai_info = nil
  43852. delete(m.clearedFields, wxcard.FieldAiInfo)
  43853. }
  43854. // SetIntro sets the "intro" field.
  43855. func (m *WxCardMutation) SetIntro(s string) {
  43856. m.intro = &s
  43857. }
  43858. // Intro returns the value of the "intro" field in the mutation.
  43859. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43860. v := m.intro
  43861. if v == nil {
  43862. return
  43863. }
  43864. return *v, true
  43865. }
  43866. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43867. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43869. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43870. if !m.op.Is(OpUpdateOne) {
  43871. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43872. }
  43873. if m.id == nil || m.oldValue == nil {
  43874. return v, errors.New("OldIntro requires an ID field in the mutation")
  43875. }
  43876. oldValue, err := m.oldValue(ctx)
  43877. if err != nil {
  43878. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43879. }
  43880. return oldValue.Intro, nil
  43881. }
  43882. // ClearIntro clears the value of the "intro" field.
  43883. func (m *WxCardMutation) ClearIntro() {
  43884. m.intro = nil
  43885. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43886. }
  43887. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43888. func (m *WxCardMutation) IntroCleared() bool {
  43889. _, ok := m.clearedFields[wxcard.FieldIntro]
  43890. return ok
  43891. }
  43892. // ResetIntro resets all changes to the "intro" field.
  43893. func (m *WxCardMutation) ResetIntro() {
  43894. m.intro = nil
  43895. delete(m.clearedFields, wxcard.FieldIntro)
  43896. }
  43897. // Where appends a list predicates to the WxCardMutation builder.
  43898. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43899. m.predicates = append(m.predicates, ps...)
  43900. }
  43901. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43902. // users can use type-assertion to append predicates that do not depend on any generated package.
  43903. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43904. p := make([]predicate.WxCard, len(ps))
  43905. for i := range ps {
  43906. p[i] = ps[i]
  43907. }
  43908. m.Where(p...)
  43909. }
  43910. // Op returns the operation name.
  43911. func (m *WxCardMutation) Op() Op {
  43912. return m.op
  43913. }
  43914. // SetOp allows setting the mutation operation.
  43915. func (m *WxCardMutation) SetOp(op Op) {
  43916. m.op = op
  43917. }
  43918. // Type returns the node type of this mutation (WxCard).
  43919. func (m *WxCardMutation) Type() string {
  43920. return m.typ
  43921. }
  43922. // Fields returns all fields that were changed during this mutation. Note that in
  43923. // order to get all numeric fields that were incremented/decremented, call
  43924. // AddedFields().
  43925. func (m *WxCardMutation) Fields() []string {
  43926. fields := make([]string, 0, 18)
  43927. if m.created_at != nil {
  43928. fields = append(fields, wxcard.FieldCreatedAt)
  43929. }
  43930. if m.updated_at != nil {
  43931. fields = append(fields, wxcard.FieldUpdatedAt)
  43932. }
  43933. if m.deleted_at != nil {
  43934. fields = append(fields, wxcard.FieldDeletedAt)
  43935. }
  43936. if m.user_id != nil {
  43937. fields = append(fields, wxcard.FieldUserID)
  43938. }
  43939. if m.wx_user_id != nil {
  43940. fields = append(fields, wxcard.FieldWxUserID)
  43941. }
  43942. if m.avatar != nil {
  43943. fields = append(fields, wxcard.FieldAvatar)
  43944. }
  43945. if m.logo != nil {
  43946. fields = append(fields, wxcard.FieldLogo)
  43947. }
  43948. if m.name != nil {
  43949. fields = append(fields, wxcard.FieldName)
  43950. }
  43951. if m.company != nil {
  43952. fields = append(fields, wxcard.FieldCompany)
  43953. }
  43954. if m.address != nil {
  43955. fields = append(fields, wxcard.FieldAddress)
  43956. }
  43957. if m.phone != nil {
  43958. fields = append(fields, wxcard.FieldPhone)
  43959. }
  43960. if m.official_account != nil {
  43961. fields = append(fields, wxcard.FieldOfficialAccount)
  43962. }
  43963. if m.wechat_account != nil {
  43964. fields = append(fields, wxcard.FieldWechatAccount)
  43965. }
  43966. if m.email != nil {
  43967. fields = append(fields, wxcard.FieldEmail)
  43968. }
  43969. if m.api_base != nil {
  43970. fields = append(fields, wxcard.FieldAPIBase)
  43971. }
  43972. if m.api_key != nil {
  43973. fields = append(fields, wxcard.FieldAPIKey)
  43974. }
  43975. if m.ai_info != nil {
  43976. fields = append(fields, wxcard.FieldAiInfo)
  43977. }
  43978. if m.intro != nil {
  43979. fields = append(fields, wxcard.FieldIntro)
  43980. }
  43981. return fields
  43982. }
  43983. // Field returns the value of a field with the given name. The second boolean
  43984. // return value indicates that this field was not set, or was not defined in the
  43985. // schema.
  43986. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43987. switch name {
  43988. case wxcard.FieldCreatedAt:
  43989. return m.CreatedAt()
  43990. case wxcard.FieldUpdatedAt:
  43991. return m.UpdatedAt()
  43992. case wxcard.FieldDeletedAt:
  43993. return m.DeletedAt()
  43994. case wxcard.FieldUserID:
  43995. return m.UserID()
  43996. case wxcard.FieldWxUserID:
  43997. return m.WxUserID()
  43998. case wxcard.FieldAvatar:
  43999. return m.Avatar()
  44000. case wxcard.FieldLogo:
  44001. return m.Logo()
  44002. case wxcard.FieldName:
  44003. return m.Name()
  44004. case wxcard.FieldCompany:
  44005. return m.Company()
  44006. case wxcard.FieldAddress:
  44007. return m.Address()
  44008. case wxcard.FieldPhone:
  44009. return m.Phone()
  44010. case wxcard.FieldOfficialAccount:
  44011. return m.OfficialAccount()
  44012. case wxcard.FieldWechatAccount:
  44013. return m.WechatAccount()
  44014. case wxcard.FieldEmail:
  44015. return m.Email()
  44016. case wxcard.FieldAPIBase:
  44017. return m.APIBase()
  44018. case wxcard.FieldAPIKey:
  44019. return m.APIKey()
  44020. case wxcard.FieldAiInfo:
  44021. return m.AiInfo()
  44022. case wxcard.FieldIntro:
  44023. return m.Intro()
  44024. }
  44025. return nil, false
  44026. }
  44027. // OldField returns the old value of the field from the database. An error is
  44028. // returned if the mutation operation is not UpdateOne, or the query to the
  44029. // database failed.
  44030. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44031. switch name {
  44032. case wxcard.FieldCreatedAt:
  44033. return m.OldCreatedAt(ctx)
  44034. case wxcard.FieldUpdatedAt:
  44035. return m.OldUpdatedAt(ctx)
  44036. case wxcard.FieldDeletedAt:
  44037. return m.OldDeletedAt(ctx)
  44038. case wxcard.FieldUserID:
  44039. return m.OldUserID(ctx)
  44040. case wxcard.FieldWxUserID:
  44041. return m.OldWxUserID(ctx)
  44042. case wxcard.FieldAvatar:
  44043. return m.OldAvatar(ctx)
  44044. case wxcard.FieldLogo:
  44045. return m.OldLogo(ctx)
  44046. case wxcard.FieldName:
  44047. return m.OldName(ctx)
  44048. case wxcard.FieldCompany:
  44049. return m.OldCompany(ctx)
  44050. case wxcard.FieldAddress:
  44051. return m.OldAddress(ctx)
  44052. case wxcard.FieldPhone:
  44053. return m.OldPhone(ctx)
  44054. case wxcard.FieldOfficialAccount:
  44055. return m.OldOfficialAccount(ctx)
  44056. case wxcard.FieldWechatAccount:
  44057. return m.OldWechatAccount(ctx)
  44058. case wxcard.FieldEmail:
  44059. return m.OldEmail(ctx)
  44060. case wxcard.FieldAPIBase:
  44061. return m.OldAPIBase(ctx)
  44062. case wxcard.FieldAPIKey:
  44063. return m.OldAPIKey(ctx)
  44064. case wxcard.FieldAiInfo:
  44065. return m.OldAiInfo(ctx)
  44066. case wxcard.FieldIntro:
  44067. return m.OldIntro(ctx)
  44068. }
  44069. return nil, fmt.Errorf("unknown WxCard field %s", name)
  44070. }
  44071. // SetField sets the value of a field with the given name. It returns an error if
  44072. // the field is not defined in the schema, or if the type mismatched the field
  44073. // type.
  44074. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  44075. switch name {
  44076. case wxcard.FieldCreatedAt:
  44077. v, ok := value.(time.Time)
  44078. if !ok {
  44079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44080. }
  44081. m.SetCreatedAt(v)
  44082. return nil
  44083. case wxcard.FieldUpdatedAt:
  44084. v, ok := value.(time.Time)
  44085. if !ok {
  44086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44087. }
  44088. m.SetUpdatedAt(v)
  44089. return nil
  44090. case wxcard.FieldDeletedAt:
  44091. v, ok := value.(time.Time)
  44092. if !ok {
  44093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44094. }
  44095. m.SetDeletedAt(v)
  44096. return nil
  44097. case wxcard.FieldUserID:
  44098. v, ok := value.(uint64)
  44099. if !ok {
  44100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44101. }
  44102. m.SetUserID(v)
  44103. return nil
  44104. case wxcard.FieldWxUserID:
  44105. v, ok := value.(uint64)
  44106. if !ok {
  44107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44108. }
  44109. m.SetWxUserID(v)
  44110. return nil
  44111. case wxcard.FieldAvatar:
  44112. v, ok := value.(string)
  44113. if !ok {
  44114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44115. }
  44116. m.SetAvatar(v)
  44117. return nil
  44118. case wxcard.FieldLogo:
  44119. v, ok := value.(string)
  44120. if !ok {
  44121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44122. }
  44123. m.SetLogo(v)
  44124. return nil
  44125. case wxcard.FieldName:
  44126. v, ok := value.(string)
  44127. if !ok {
  44128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44129. }
  44130. m.SetName(v)
  44131. return nil
  44132. case wxcard.FieldCompany:
  44133. v, ok := value.(string)
  44134. if !ok {
  44135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44136. }
  44137. m.SetCompany(v)
  44138. return nil
  44139. case wxcard.FieldAddress:
  44140. v, ok := value.(string)
  44141. if !ok {
  44142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44143. }
  44144. m.SetAddress(v)
  44145. return nil
  44146. case wxcard.FieldPhone:
  44147. v, ok := value.(string)
  44148. if !ok {
  44149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44150. }
  44151. m.SetPhone(v)
  44152. return nil
  44153. case wxcard.FieldOfficialAccount:
  44154. v, ok := value.(string)
  44155. if !ok {
  44156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44157. }
  44158. m.SetOfficialAccount(v)
  44159. return nil
  44160. case wxcard.FieldWechatAccount:
  44161. v, ok := value.(string)
  44162. if !ok {
  44163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44164. }
  44165. m.SetWechatAccount(v)
  44166. return nil
  44167. case wxcard.FieldEmail:
  44168. v, ok := value.(string)
  44169. if !ok {
  44170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44171. }
  44172. m.SetEmail(v)
  44173. return nil
  44174. case wxcard.FieldAPIBase:
  44175. v, ok := value.(string)
  44176. if !ok {
  44177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44178. }
  44179. m.SetAPIBase(v)
  44180. return nil
  44181. case wxcard.FieldAPIKey:
  44182. v, ok := value.(string)
  44183. if !ok {
  44184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44185. }
  44186. m.SetAPIKey(v)
  44187. return nil
  44188. case wxcard.FieldAiInfo:
  44189. v, ok := value.(string)
  44190. if !ok {
  44191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44192. }
  44193. m.SetAiInfo(v)
  44194. return nil
  44195. case wxcard.FieldIntro:
  44196. v, ok := value.(string)
  44197. if !ok {
  44198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44199. }
  44200. m.SetIntro(v)
  44201. return nil
  44202. }
  44203. return fmt.Errorf("unknown WxCard field %s", name)
  44204. }
  44205. // AddedFields returns all numeric fields that were incremented/decremented during
  44206. // this mutation.
  44207. func (m *WxCardMutation) AddedFields() []string {
  44208. var fields []string
  44209. if m.adduser_id != nil {
  44210. fields = append(fields, wxcard.FieldUserID)
  44211. }
  44212. if m.addwx_user_id != nil {
  44213. fields = append(fields, wxcard.FieldWxUserID)
  44214. }
  44215. return fields
  44216. }
  44217. // AddedField returns the numeric value that was incremented/decremented on a field
  44218. // with the given name. The second boolean return value indicates that this field
  44219. // was not set, or was not defined in the schema.
  44220. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  44221. switch name {
  44222. case wxcard.FieldUserID:
  44223. return m.AddedUserID()
  44224. case wxcard.FieldWxUserID:
  44225. return m.AddedWxUserID()
  44226. }
  44227. return nil, false
  44228. }
  44229. // AddField adds the value to the field with the given name. It returns an error if
  44230. // the field is not defined in the schema, or if the type mismatched the field
  44231. // type.
  44232. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  44233. switch name {
  44234. case wxcard.FieldUserID:
  44235. v, ok := value.(int64)
  44236. if !ok {
  44237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44238. }
  44239. m.AddUserID(v)
  44240. return nil
  44241. case wxcard.FieldWxUserID:
  44242. v, ok := value.(int64)
  44243. if !ok {
  44244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44245. }
  44246. m.AddWxUserID(v)
  44247. return nil
  44248. }
  44249. return fmt.Errorf("unknown WxCard numeric field %s", name)
  44250. }
  44251. // ClearedFields returns all nullable fields that were cleared during this
  44252. // mutation.
  44253. func (m *WxCardMutation) ClearedFields() []string {
  44254. var fields []string
  44255. if m.FieldCleared(wxcard.FieldDeletedAt) {
  44256. fields = append(fields, wxcard.FieldDeletedAt)
  44257. }
  44258. if m.FieldCleared(wxcard.FieldUserID) {
  44259. fields = append(fields, wxcard.FieldUserID)
  44260. }
  44261. if m.FieldCleared(wxcard.FieldWxUserID) {
  44262. fields = append(fields, wxcard.FieldWxUserID)
  44263. }
  44264. if m.FieldCleared(wxcard.FieldEmail) {
  44265. fields = append(fields, wxcard.FieldEmail)
  44266. }
  44267. if m.FieldCleared(wxcard.FieldAPIBase) {
  44268. fields = append(fields, wxcard.FieldAPIBase)
  44269. }
  44270. if m.FieldCleared(wxcard.FieldAPIKey) {
  44271. fields = append(fields, wxcard.FieldAPIKey)
  44272. }
  44273. if m.FieldCleared(wxcard.FieldAiInfo) {
  44274. fields = append(fields, wxcard.FieldAiInfo)
  44275. }
  44276. if m.FieldCleared(wxcard.FieldIntro) {
  44277. fields = append(fields, wxcard.FieldIntro)
  44278. }
  44279. return fields
  44280. }
  44281. // FieldCleared returns a boolean indicating if a field with the given name was
  44282. // cleared in this mutation.
  44283. func (m *WxCardMutation) FieldCleared(name string) bool {
  44284. _, ok := m.clearedFields[name]
  44285. return ok
  44286. }
  44287. // ClearField clears the value of the field with the given name. It returns an
  44288. // error if the field is not defined in the schema.
  44289. func (m *WxCardMutation) ClearField(name string) error {
  44290. switch name {
  44291. case wxcard.FieldDeletedAt:
  44292. m.ClearDeletedAt()
  44293. return nil
  44294. case wxcard.FieldUserID:
  44295. m.ClearUserID()
  44296. return nil
  44297. case wxcard.FieldWxUserID:
  44298. m.ClearWxUserID()
  44299. return nil
  44300. case wxcard.FieldEmail:
  44301. m.ClearEmail()
  44302. return nil
  44303. case wxcard.FieldAPIBase:
  44304. m.ClearAPIBase()
  44305. return nil
  44306. case wxcard.FieldAPIKey:
  44307. m.ClearAPIKey()
  44308. return nil
  44309. case wxcard.FieldAiInfo:
  44310. m.ClearAiInfo()
  44311. return nil
  44312. case wxcard.FieldIntro:
  44313. m.ClearIntro()
  44314. return nil
  44315. }
  44316. return fmt.Errorf("unknown WxCard nullable field %s", name)
  44317. }
  44318. // ResetField resets all changes in the mutation for the field with the given name.
  44319. // It returns an error if the field is not defined in the schema.
  44320. func (m *WxCardMutation) ResetField(name string) error {
  44321. switch name {
  44322. case wxcard.FieldCreatedAt:
  44323. m.ResetCreatedAt()
  44324. return nil
  44325. case wxcard.FieldUpdatedAt:
  44326. m.ResetUpdatedAt()
  44327. return nil
  44328. case wxcard.FieldDeletedAt:
  44329. m.ResetDeletedAt()
  44330. return nil
  44331. case wxcard.FieldUserID:
  44332. m.ResetUserID()
  44333. return nil
  44334. case wxcard.FieldWxUserID:
  44335. m.ResetWxUserID()
  44336. return nil
  44337. case wxcard.FieldAvatar:
  44338. m.ResetAvatar()
  44339. return nil
  44340. case wxcard.FieldLogo:
  44341. m.ResetLogo()
  44342. return nil
  44343. case wxcard.FieldName:
  44344. m.ResetName()
  44345. return nil
  44346. case wxcard.FieldCompany:
  44347. m.ResetCompany()
  44348. return nil
  44349. case wxcard.FieldAddress:
  44350. m.ResetAddress()
  44351. return nil
  44352. case wxcard.FieldPhone:
  44353. m.ResetPhone()
  44354. return nil
  44355. case wxcard.FieldOfficialAccount:
  44356. m.ResetOfficialAccount()
  44357. return nil
  44358. case wxcard.FieldWechatAccount:
  44359. m.ResetWechatAccount()
  44360. return nil
  44361. case wxcard.FieldEmail:
  44362. m.ResetEmail()
  44363. return nil
  44364. case wxcard.FieldAPIBase:
  44365. m.ResetAPIBase()
  44366. return nil
  44367. case wxcard.FieldAPIKey:
  44368. m.ResetAPIKey()
  44369. return nil
  44370. case wxcard.FieldAiInfo:
  44371. m.ResetAiInfo()
  44372. return nil
  44373. case wxcard.FieldIntro:
  44374. m.ResetIntro()
  44375. return nil
  44376. }
  44377. return fmt.Errorf("unknown WxCard field %s", name)
  44378. }
  44379. // AddedEdges returns all edge names that were set/added in this mutation.
  44380. func (m *WxCardMutation) AddedEdges() []string {
  44381. edges := make([]string, 0, 0)
  44382. return edges
  44383. }
  44384. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44385. // name in this mutation.
  44386. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44387. return nil
  44388. }
  44389. // RemovedEdges returns all edge names that were removed in this mutation.
  44390. func (m *WxCardMutation) RemovedEdges() []string {
  44391. edges := make([]string, 0, 0)
  44392. return edges
  44393. }
  44394. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44395. // the given name in this mutation.
  44396. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44397. return nil
  44398. }
  44399. // ClearedEdges returns all edge names that were cleared in this mutation.
  44400. func (m *WxCardMutation) ClearedEdges() []string {
  44401. edges := make([]string, 0, 0)
  44402. return edges
  44403. }
  44404. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44405. // was cleared in this mutation.
  44406. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44407. return false
  44408. }
  44409. // ClearEdge clears the value of the edge with the given name. It returns an error
  44410. // if that edge is not defined in the schema.
  44411. func (m *WxCardMutation) ClearEdge(name string) error {
  44412. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44413. }
  44414. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44415. // It returns an error if the edge is not defined in the schema.
  44416. func (m *WxCardMutation) ResetEdge(name string) error {
  44417. return fmt.Errorf("unknown WxCard edge %s", name)
  44418. }
  44419. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44420. type WxCardUserMutation struct {
  44421. config
  44422. op Op
  44423. typ string
  44424. id *uint64
  44425. created_at *time.Time
  44426. updated_at *time.Time
  44427. deleted_at *time.Time
  44428. wxid *string
  44429. account *string
  44430. avatar *string
  44431. nickname *string
  44432. remark *string
  44433. phone *string
  44434. open_id *string
  44435. union_id *string
  44436. session_key *string
  44437. is_vip *int
  44438. addis_vip *int
  44439. clearedFields map[string]struct{}
  44440. done bool
  44441. oldValue func(context.Context) (*WxCardUser, error)
  44442. predicates []predicate.WxCardUser
  44443. }
  44444. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44445. // wxcarduserOption allows management of the mutation configuration using functional options.
  44446. type wxcarduserOption func(*WxCardUserMutation)
  44447. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44448. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44449. m := &WxCardUserMutation{
  44450. config: c,
  44451. op: op,
  44452. typ: TypeWxCardUser,
  44453. clearedFields: make(map[string]struct{}),
  44454. }
  44455. for _, opt := range opts {
  44456. opt(m)
  44457. }
  44458. return m
  44459. }
  44460. // withWxCardUserID sets the ID field of the mutation.
  44461. func withWxCardUserID(id uint64) wxcarduserOption {
  44462. return func(m *WxCardUserMutation) {
  44463. var (
  44464. err error
  44465. once sync.Once
  44466. value *WxCardUser
  44467. )
  44468. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44469. once.Do(func() {
  44470. if m.done {
  44471. err = errors.New("querying old values post mutation is not allowed")
  44472. } else {
  44473. value, err = m.Client().WxCardUser.Get(ctx, id)
  44474. }
  44475. })
  44476. return value, err
  44477. }
  44478. m.id = &id
  44479. }
  44480. }
  44481. // withWxCardUser sets the old WxCardUser of the mutation.
  44482. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44483. return func(m *WxCardUserMutation) {
  44484. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44485. return node, nil
  44486. }
  44487. m.id = &node.ID
  44488. }
  44489. }
  44490. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44491. // executed in a transaction (ent.Tx), a transactional client is returned.
  44492. func (m WxCardUserMutation) Client() *Client {
  44493. client := &Client{config: m.config}
  44494. client.init()
  44495. return client
  44496. }
  44497. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44498. // it returns an error otherwise.
  44499. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44500. if _, ok := m.driver.(*txDriver); !ok {
  44501. return nil, errors.New("ent: mutation is not running in a transaction")
  44502. }
  44503. tx := &Tx{config: m.config}
  44504. tx.init()
  44505. return tx, nil
  44506. }
  44507. // SetID sets the value of the id field. Note that this
  44508. // operation is only accepted on creation of WxCardUser entities.
  44509. func (m *WxCardUserMutation) SetID(id uint64) {
  44510. m.id = &id
  44511. }
  44512. // ID returns the ID value in the mutation. Note that the ID is only available
  44513. // if it was provided to the builder or after it was returned from the database.
  44514. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44515. if m.id == nil {
  44516. return
  44517. }
  44518. return *m.id, true
  44519. }
  44520. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44521. // That means, if the mutation is applied within a transaction with an isolation level such
  44522. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44523. // or updated by the mutation.
  44524. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44525. switch {
  44526. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44527. id, exists := m.ID()
  44528. if exists {
  44529. return []uint64{id}, nil
  44530. }
  44531. fallthrough
  44532. case m.op.Is(OpUpdate | OpDelete):
  44533. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44534. default:
  44535. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44536. }
  44537. }
  44538. // SetCreatedAt sets the "created_at" field.
  44539. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44540. m.created_at = &t
  44541. }
  44542. // CreatedAt returns the value of the "created_at" field in the mutation.
  44543. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44544. v := m.created_at
  44545. if v == nil {
  44546. return
  44547. }
  44548. return *v, true
  44549. }
  44550. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44551. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44553. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44554. if !m.op.Is(OpUpdateOne) {
  44555. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44556. }
  44557. if m.id == nil || m.oldValue == nil {
  44558. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44559. }
  44560. oldValue, err := m.oldValue(ctx)
  44561. if err != nil {
  44562. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44563. }
  44564. return oldValue.CreatedAt, nil
  44565. }
  44566. // ResetCreatedAt resets all changes to the "created_at" field.
  44567. func (m *WxCardUserMutation) ResetCreatedAt() {
  44568. m.created_at = nil
  44569. }
  44570. // SetUpdatedAt sets the "updated_at" field.
  44571. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44572. m.updated_at = &t
  44573. }
  44574. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44575. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44576. v := m.updated_at
  44577. if v == nil {
  44578. return
  44579. }
  44580. return *v, true
  44581. }
  44582. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44585. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44586. if !m.op.Is(OpUpdateOne) {
  44587. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44588. }
  44589. if m.id == nil || m.oldValue == nil {
  44590. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44591. }
  44592. oldValue, err := m.oldValue(ctx)
  44593. if err != nil {
  44594. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44595. }
  44596. return oldValue.UpdatedAt, nil
  44597. }
  44598. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44599. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44600. m.updated_at = nil
  44601. }
  44602. // SetDeletedAt sets the "deleted_at" field.
  44603. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44604. m.deleted_at = &t
  44605. }
  44606. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44607. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44608. v := m.deleted_at
  44609. if v == nil {
  44610. return
  44611. }
  44612. return *v, true
  44613. }
  44614. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44615. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44617. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44618. if !m.op.Is(OpUpdateOne) {
  44619. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44620. }
  44621. if m.id == nil || m.oldValue == nil {
  44622. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44623. }
  44624. oldValue, err := m.oldValue(ctx)
  44625. if err != nil {
  44626. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44627. }
  44628. return oldValue.DeletedAt, nil
  44629. }
  44630. // ClearDeletedAt clears the value of the "deleted_at" field.
  44631. func (m *WxCardUserMutation) ClearDeletedAt() {
  44632. m.deleted_at = nil
  44633. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44634. }
  44635. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44636. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44637. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44638. return ok
  44639. }
  44640. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44641. func (m *WxCardUserMutation) ResetDeletedAt() {
  44642. m.deleted_at = nil
  44643. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44644. }
  44645. // SetWxid sets the "wxid" field.
  44646. func (m *WxCardUserMutation) SetWxid(s string) {
  44647. m.wxid = &s
  44648. }
  44649. // Wxid returns the value of the "wxid" field in the mutation.
  44650. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44651. v := m.wxid
  44652. if v == nil {
  44653. return
  44654. }
  44655. return *v, true
  44656. }
  44657. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44658. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44660. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44661. if !m.op.Is(OpUpdateOne) {
  44662. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44663. }
  44664. if m.id == nil || m.oldValue == nil {
  44665. return v, errors.New("OldWxid requires an ID field in the mutation")
  44666. }
  44667. oldValue, err := m.oldValue(ctx)
  44668. if err != nil {
  44669. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44670. }
  44671. return oldValue.Wxid, nil
  44672. }
  44673. // ResetWxid resets all changes to the "wxid" field.
  44674. func (m *WxCardUserMutation) ResetWxid() {
  44675. m.wxid = nil
  44676. }
  44677. // SetAccount sets the "account" field.
  44678. func (m *WxCardUserMutation) SetAccount(s string) {
  44679. m.account = &s
  44680. }
  44681. // Account returns the value of the "account" field in the mutation.
  44682. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44683. v := m.account
  44684. if v == nil {
  44685. return
  44686. }
  44687. return *v, true
  44688. }
  44689. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44690. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44692. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44693. if !m.op.Is(OpUpdateOne) {
  44694. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44695. }
  44696. if m.id == nil || m.oldValue == nil {
  44697. return v, errors.New("OldAccount requires an ID field in the mutation")
  44698. }
  44699. oldValue, err := m.oldValue(ctx)
  44700. if err != nil {
  44701. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44702. }
  44703. return oldValue.Account, nil
  44704. }
  44705. // ResetAccount resets all changes to the "account" field.
  44706. func (m *WxCardUserMutation) ResetAccount() {
  44707. m.account = nil
  44708. }
  44709. // SetAvatar sets the "avatar" field.
  44710. func (m *WxCardUserMutation) SetAvatar(s string) {
  44711. m.avatar = &s
  44712. }
  44713. // Avatar returns the value of the "avatar" field in the mutation.
  44714. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44715. v := m.avatar
  44716. if v == nil {
  44717. return
  44718. }
  44719. return *v, true
  44720. }
  44721. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44722. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44724. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44725. if !m.op.Is(OpUpdateOne) {
  44726. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44727. }
  44728. if m.id == nil || m.oldValue == nil {
  44729. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44730. }
  44731. oldValue, err := m.oldValue(ctx)
  44732. if err != nil {
  44733. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44734. }
  44735. return oldValue.Avatar, nil
  44736. }
  44737. // ResetAvatar resets all changes to the "avatar" field.
  44738. func (m *WxCardUserMutation) ResetAvatar() {
  44739. m.avatar = nil
  44740. }
  44741. // SetNickname sets the "nickname" field.
  44742. func (m *WxCardUserMutation) SetNickname(s string) {
  44743. m.nickname = &s
  44744. }
  44745. // Nickname returns the value of the "nickname" field in the mutation.
  44746. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44747. v := m.nickname
  44748. if v == nil {
  44749. return
  44750. }
  44751. return *v, true
  44752. }
  44753. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44754. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44756. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44757. if !m.op.Is(OpUpdateOne) {
  44758. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44759. }
  44760. if m.id == nil || m.oldValue == nil {
  44761. return v, errors.New("OldNickname requires an ID field in the mutation")
  44762. }
  44763. oldValue, err := m.oldValue(ctx)
  44764. if err != nil {
  44765. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44766. }
  44767. return oldValue.Nickname, nil
  44768. }
  44769. // ResetNickname resets all changes to the "nickname" field.
  44770. func (m *WxCardUserMutation) ResetNickname() {
  44771. m.nickname = nil
  44772. }
  44773. // SetRemark sets the "remark" field.
  44774. func (m *WxCardUserMutation) SetRemark(s string) {
  44775. m.remark = &s
  44776. }
  44777. // Remark returns the value of the "remark" field in the mutation.
  44778. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44779. v := m.remark
  44780. if v == nil {
  44781. return
  44782. }
  44783. return *v, true
  44784. }
  44785. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44786. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44788. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44789. if !m.op.Is(OpUpdateOne) {
  44790. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44791. }
  44792. if m.id == nil || m.oldValue == nil {
  44793. return v, errors.New("OldRemark requires an ID field in the mutation")
  44794. }
  44795. oldValue, err := m.oldValue(ctx)
  44796. if err != nil {
  44797. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44798. }
  44799. return oldValue.Remark, nil
  44800. }
  44801. // ResetRemark resets all changes to the "remark" field.
  44802. func (m *WxCardUserMutation) ResetRemark() {
  44803. m.remark = nil
  44804. }
  44805. // SetPhone sets the "phone" field.
  44806. func (m *WxCardUserMutation) SetPhone(s string) {
  44807. m.phone = &s
  44808. }
  44809. // Phone returns the value of the "phone" field in the mutation.
  44810. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44811. v := m.phone
  44812. if v == nil {
  44813. return
  44814. }
  44815. return *v, true
  44816. }
  44817. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44818. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44820. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44821. if !m.op.Is(OpUpdateOne) {
  44822. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44823. }
  44824. if m.id == nil || m.oldValue == nil {
  44825. return v, errors.New("OldPhone requires an ID field in the mutation")
  44826. }
  44827. oldValue, err := m.oldValue(ctx)
  44828. if err != nil {
  44829. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44830. }
  44831. return oldValue.Phone, nil
  44832. }
  44833. // ResetPhone resets all changes to the "phone" field.
  44834. func (m *WxCardUserMutation) ResetPhone() {
  44835. m.phone = nil
  44836. }
  44837. // SetOpenID sets the "open_id" field.
  44838. func (m *WxCardUserMutation) SetOpenID(s string) {
  44839. m.open_id = &s
  44840. }
  44841. // OpenID returns the value of the "open_id" field in the mutation.
  44842. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44843. v := m.open_id
  44844. if v == nil {
  44845. return
  44846. }
  44847. return *v, true
  44848. }
  44849. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44850. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44852. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44853. if !m.op.Is(OpUpdateOne) {
  44854. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44855. }
  44856. if m.id == nil || m.oldValue == nil {
  44857. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44858. }
  44859. oldValue, err := m.oldValue(ctx)
  44860. if err != nil {
  44861. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44862. }
  44863. return oldValue.OpenID, nil
  44864. }
  44865. // ResetOpenID resets all changes to the "open_id" field.
  44866. func (m *WxCardUserMutation) ResetOpenID() {
  44867. m.open_id = nil
  44868. }
  44869. // SetUnionID sets the "union_id" field.
  44870. func (m *WxCardUserMutation) SetUnionID(s string) {
  44871. m.union_id = &s
  44872. }
  44873. // UnionID returns the value of the "union_id" field in the mutation.
  44874. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44875. v := m.union_id
  44876. if v == nil {
  44877. return
  44878. }
  44879. return *v, true
  44880. }
  44881. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44882. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44884. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44885. if !m.op.Is(OpUpdateOne) {
  44886. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44887. }
  44888. if m.id == nil || m.oldValue == nil {
  44889. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44890. }
  44891. oldValue, err := m.oldValue(ctx)
  44892. if err != nil {
  44893. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44894. }
  44895. return oldValue.UnionID, nil
  44896. }
  44897. // ResetUnionID resets all changes to the "union_id" field.
  44898. func (m *WxCardUserMutation) ResetUnionID() {
  44899. m.union_id = nil
  44900. }
  44901. // SetSessionKey sets the "session_key" field.
  44902. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44903. m.session_key = &s
  44904. }
  44905. // SessionKey returns the value of the "session_key" field in the mutation.
  44906. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44907. v := m.session_key
  44908. if v == nil {
  44909. return
  44910. }
  44911. return *v, true
  44912. }
  44913. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44914. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44916. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44917. if !m.op.Is(OpUpdateOne) {
  44918. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44919. }
  44920. if m.id == nil || m.oldValue == nil {
  44921. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44922. }
  44923. oldValue, err := m.oldValue(ctx)
  44924. if err != nil {
  44925. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44926. }
  44927. return oldValue.SessionKey, nil
  44928. }
  44929. // ResetSessionKey resets all changes to the "session_key" field.
  44930. func (m *WxCardUserMutation) ResetSessionKey() {
  44931. m.session_key = nil
  44932. }
  44933. // SetIsVip sets the "is_vip" field.
  44934. func (m *WxCardUserMutation) SetIsVip(i int) {
  44935. m.is_vip = &i
  44936. m.addis_vip = nil
  44937. }
  44938. // IsVip returns the value of the "is_vip" field in the mutation.
  44939. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44940. v := m.is_vip
  44941. if v == nil {
  44942. return
  44943. }
  44944. return *v, true
  44945. }
  44946. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44947. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44949. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44950. if !m.op.Is(OpUpdateOne) {
  44951. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44952. }
  44953. if m.id == nil || m.oldValue == nil {
  44954. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44955. }
  44956. oldValue, err := m.oldValue(ctx)
  44957. if err != nil {
  44958. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44959. }
  44960. return oldValue.IsVip, nil
  44961. }
  44962. // AddIsVip adds i to the "is_vip" field.
  44963. func (m *WxCardUserMutation) AddIsVip(i int) {
  44964. if m.addis_vip != nil {
  44965. *m.addis_vip += i
  44966. } else {
  44967. m.addis_vip = &i
  44968. }
  44969. }
  44970. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44971. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44972. v := m.addis_vip
  44973. if v == nil {
  44974. return
  44975. }
  44976. return *v, true
  44977. }
  44978. // ResetIsVip resets all changes to the "is_vip" field.
  44979. func (m *WxCardUserMutation) ResetIsVip() {
  44980. m.is_vip = nil
  44981. m.addis_vip = nil
  44982. }
  44983. // Where appends a list predicates to the WxCardUserMutation builder.
  44984. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44985. m.predicates = append(m.predicates, ps...)
  44986. }
  44987. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44988. // users can use type-assertion to append predicates that do not depend on any generated package.
  44989. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44990. p := make([]predicate.WxCardUser, len(ps))
  44991. for i := range ps {
  44992. p[i] = ps[i]
  44993. }
  44994. m.Where(p...)
  44995. }
  44996. // Op returns the operation name.
  44997. func (m *WxCardUserMutation) Op() Op {
  44998. return m.op
  44999. }
  45000. // SetOp allows setting the mutation operation.
  45001. func (m *WxCardUserMutation) SetOp(op Op) {
  45002. m.op = op
  45003. }
  45004. // Type returns the node type of this mutation (WxCardUser).
  45005. func (m *WxCardUserMutation) Type() string {
  45006. return m.typ
  45007. }
  45008. // Fields returns all fields that were changed during this mutation. Note that in
  45009. // order to get all numeric fields that were incremented/decremented, call
  45010. // AddedFields().
  45011. func (m *WxCardUserMutation) Fields() []string {
  45012. fields := make([]string, 0, 13)
  45013. if m.created_at != nil {
  45014. fields = append(fields, wxcarduser.FieldCreatedAt)
  45015. }
  45016. if m.updated_at != nil {
  45017. fields = append(fields, wxcarduser.FieldUpdatedAt)
  45018. }
  45019. if m.deleted_at != nil {
  45020. fields = append(fields, wxcarduser.FieldDeletedAt)
  45021. }
  45022. if m.wxid != nil {
  45023. fields = append(fields, wxcarduser.FieldWxid)
  45024. }
  45025. if m.account != nil {
  45026. fields = append(fields, wxcarduser.FieldAccount)
  45027. }
  45028. if m.avatar != nil {
  45029. fields = append(fields, wxcarduser.FieldAvatar)
  45030. }
  45031. if m.nickname != nil {
  45032. fields = append(fields, wxcarduser.FieldNickname)
  45033. }
  45034. if m.remark != nil {
  45035. fields = append(fields, wxcarduser.FieldRemark)
  45036. }
  45037. if m.phone != nil {
  45038. fields = append(fields, wxcarduser.FieldPhone)
  45039. }
  45040. if m.open_id != nil {
  45041. fields = append(fields, wxcarduser.FieldOpenID)
  45042. }
  45043. if m.union_id != nil {
  45044. fields = append(fields, wxcarduser.FieldUnionID)
  45045. }
  45046. if m.session_key != nil {
  45047. fields = append(fields, wxcarduser.FieldSessionKey)
  45048. }
  45049. if m.is_vip != nil {
  45050. fields = append(fields, wxcarduser.FieldIsVip)
  45051. }
  45052. return fields
  45053. }
  45054. // Field returns the value of a field with the given name. The second boolean
  45055. // return value indicates that this field was not set, or was not defined in the
  45056. // schema.
  45057. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  45058. switch name {
  45059. case wxcarduser.FieldCreatedAt:
  45060. return m.CreatedAt()
  45061. case wxcarduser.FieldUpdatedAt:
  45062. return m.UpdatedAt()
  45063. case wxcarduser.FieldDeletedAt:
  45064. return m.DeletedAt()
  45065. case wxcarduser.FieldWxid:
  45066. return m.Wxid()
  45067. case wxcarduser.FieldAccount:
  45068. return m.Account()
  45069. case wxcarduser.FieldAvatar:
  45070. return m.Avatar()
  45071. case wxcarduser.FieldNickname:
  45072. return m.Nickname()
  45073. case wxcarduser.FieldRemark:
  45074. return m.Remark()
  45075. case wxcarduser.FieldPhone:
  45076. return m.Phone()
  45077. case wxcarduser.FieldOpenID:
  45078. return m.OpenID()
  45079. case wxcarduser.FieldUnionID:
  45080. return m.UnionID()
  45081. case wxcarduser.FieldSessionKey:
  45082. return m.SessionKey()
  45083. case wxcarduser.FieldIsVip:
  45084. return m.IsVip()
  45085. }
  45086. return nil, false
  45087. }
  45088. // OldField returns the old value of the field from the database. An error is
  45089. // returned if the mutation operation is not UpdateOne, or the query to the
  45090. // database failed.
  45091. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45092. switch name {
  45093. case wxcarduser.FieldCreatedAt:
  45094. return m.OldCreatedAt(ctx)
  45095. case wxcarduser.FieldUpdatedAt:
  45096. return m.OldUpdatedAt(ctx)
  45097. case wxcarduser.FieldDeletedAt:
  45098. return m.OldDeletedAt(ctx)
  45099. case wxcarduser.FieldWxid:
  45100. return m.OldWxid(ctx)
  45101. case wxcarduser.FieldAccount:
  45102. return m.OldAccount(ctx)
  45103. case wxcarduser.FieldAvatar:
  45104. return m.OldAvatar(ctx)
  45105. case wxcarduser.FieldNickname:
  45106. return m.OldNickname(ctx)
  45107. case wxcarduser.FieldRemark:
  45108. return m.OldRemark(ctx)
  45109. case wxcarduser.FieldPhone:
  45110. return m.OldPhone(ctx)
  45111. case wxcarduser.FieldOpenID:
  45112. return m.OldOpenID(ctx)
  45113. case wxcarduser.FieldUnionID:
  45114. return m.OldUnionID(ctx)
  45115. case wxcarduser.FieldSessionKey:
  45116. return m.OldSessionKey(ctx)
  45117. case wxcarduser.FieldIsVip:
  45118. return m.OldIsVip(ctx)
  45119. }
  45120. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  45121. }
  45122. // SetField sets the value of a field with the given name. It returns an error if
  45123. // the field is not defined in the schema, or if the type mismatched the field
  45124. // type.
  45125. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  45126. switch name {
  45127. case wxcarduser.FieldCreatedAt:
  45128. v, ok := value.(time.Time)
  45129. if !ok {
  45130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45131. }
  45132. m.SetCreatedAt(v)
  45133. return nil
  45134. case wxcarduser.FieldUpdatedAt:
  45135. v, ok := value.(time.Time)
  45136. if !ok {
  45137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45138. }
  45139. m.SetUpdatedAt(v)
  45140. return nil
  45141. case wxcarduser.FieldDeletedAt:
  45142. v, ok := value.(time.Time)
  45143. if !ok {
  45144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45145. }
  45146. m.SetDeletedAt(v)
  45147. return nil
  45148. case wxcarduser.FieldWxid:
  45149. v, ok := value.(string)
  45150. if !ok {
  45151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45152. }
  45153. m.SetWxid(v)
  45154. return nil
  45155. case wxcarduser.FieldAccount:
  45156. v, ok := value.(string)
  45157. if !ok {
  45158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45159. }
  45160. m.SetAccount(v)
  45161. return nil
  45162. case wxcarduser.FieldAvatar:
  45163. v, ok := value.(string)
  45164. if !ok {
  45165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45166. }
  45167. m.SetAvatar(v)
  45168. return nil
  45169. case wxcarduser.FieldNickname:
  45170. v, ok := value.(string)
  45171. if !ok {
  45172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45173. }
  45174. m.SetNickname(v)
  45175. return nil
  45176. case wxcarduser.FieldRemark:
  45177. v, ok := value.(string)
  45178. if !ok {
  45179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45180. }
  45181. m.SetRemark(v)
  45182. return nil
  45183. case wxcarduser.FieldPhone:
  45184. v, ok := value.(string)
  45185. if !ok {
  45186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45187. }
  45188. m.SetPhone(v)
  45189. return nil
  45190. case wxcarduser.FieldOpenID:
  45191. v, ok := value.(string)
  45192. if !ok {
  45193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45194. }
  45195. m.SetOpenID(v)
  45196. return nil
  45197. case wxcarduser.FieldUnionID:
  45198. v, ok := value.(string)
  45199. if !ok {
  45200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45201. }
  45202. m.SetUnionID(v)
  45203. return nil
  45204. case wxcarduser.FieldSessionKey:
  45205. v, ok := value.(string)
  45206. if !ok {
  45207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45208. }
  45209. m.SetSessionKey(v)
  45210. return nil
  45211. case wxcarduser.FieldIsVip:
  45212. v, ok := value.(int)
  45213. if !ok {
  45214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45215. }
  45216. m.SetIsVip(v)
  45217. return nil
  45218. }
  45219. return fmt.Errorf("unknown WxCardUser field %s", name)
  45220. }
  45221. // AddedFields returns all numeric fields that were incremented/decremented during
  45222. // this mutation.
  45223. func (m *WxCardUserMutation) AddedFields() []string {
  45224. var fields []string
  45225. if m.addis_vip != nil {
  45226. fields = append(fields, wxcarduser.FieldIsVip)
  45227. }
  45228. return fields
  45229. }
  45230. // AddedField returns the numeric value that was incremented/decremented on a field
  45231. // with the given name. The second boolean return value indicates that this field
  45232. // was not set, or was not defined in the schema.
  45233. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  45234. switch name {
  45235. case wxcarduser.FieldIsVip:
  45236. return m.AddedIsVip()
  45237. }
  45238. return nil, false
  45239. }
  45240. // AddField adds the value to the field with the given name. It returns an error if
  45241. // the field is not defined in the schema, or if the type mismatched the field
  45242. // type.
  45243. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  45244. switch name {
  45245. case wxcarduser.FieldIsVip:
  45246. v, ok := value.(int)
  45247. if !ok {
  45248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45249. }
  45250. m.AddIsVip(v)
  45251. return nil
  45252. }
  45253. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  45254. }
  45255. // ClearedFields returns all nullable fields that were cleared during this
  45256. // mutation.
  45257. func (m *WxCardUserMutation) ClearedFields() []string {
  45258. var fields []string
  45259. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  45260. fields = append(fields, wxcarduser.FieldDeletedAt)
  45261. }
  45262. return fields
  45263. }
  45264. // FieldCleared returns a boolean indicating if a field with the given name was
  45265. // cleared in this mutation.
  45266. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  45267. _, ok := m.clearedFields[name]
  45268. return ok
  45269. }
  45270. // ClearField clears the value of the field with the given name. It returns an
  45271. // error if the field is not defined in the schema.
  45272. func (m *WxCardUserMutation) ClearField(name string) error {
  45273. switch name {
  45274. case wxcarduser.FieldDeletedAt:
  45275. m.ClearDeletedAt()
  45276. return nil
  45277. }
  45278. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  45279. }
  45280. // ResetField resets all changes in the mutation for the field with the given name.
  45281. // It returns an error if the field is not defined in the schema.
  45282. func (m *WxCardUserMutation) ResetField(name string) error {
  45283. switch name {
  45284. case wxcarduser.FieldCreatedAt:
  45285. m.ResetCreatedAt()
  45286. return nil
  45287. case wxcarduser.FieldUpdatedAt:
  45288. m.ResetUpdatedAt()
  45289. return nil
  45290. case wxcarduser.FieldDeletedAt:
  45291. m.ResetDeletedAt()
  45292. return nil
  45293. case wxcarduser.FieldWxid:
  45294. m.ResetWxid()
  45295. return nil
  45296. case wxcarduser.FieldAccount:
  45297. m.ResetAccount()
  45298. return nil
  45299. case wxcarduser.FieldAvatar:
  45300. m.ResetAvatar()
  45301. return nil
  45302. case wxcarduser.FieldNickname:
  45303. m.ResetNickname()
  45304. return nil
  45305. case wxcarduser.FieldRemark:
  45306. m.ResetRemark()
  45307. return nil
  45308. case wxcarduser.FieldPhone:
  45309. m.ResetPhone()
  45310. return nil
  45311. case wxcarduser.FieldOpenID:
  45312. m.ResetOpenID()
  45313. return nil
  45314. case wxcarduser.FieldUnionID:
  45315. m.ResetUnionID()
  45316. return nil
  45317. case wxcarduser.FieldSessionKey:
  45318. m.ResetSessionKey()
  45319. return nil
  45320. case wxcarduser.FieldIsVip:
  45321. m.ResetIsVip()
  45322. return nil
  45323. }
  45324. return fmt.Errorf("unknown WxCardUser field %s", name)
  45325. }
  45326. // AddedEdges returns all edge names that were set/added in this mutation.
  45327. func (m *WxCardUserMutation) AddedEdges() []string {
  45328. edges := make([]string, 0, 0)
  45329. return edges
  45330. }
  45331. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45332. // name in this mutation.
  45333. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  45334. return nil
  45335. }
  45336. // RemovedEdges returns all edge names that were removed in this mutation.
  45337. func (m *WxCardUserMutation) RemovedEdges() []string {
  45338. edges := make([]string, 0, 0)
  45339. return edges
  45340. }
  45341. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45342. // the given name in this mutation.
  45343. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  45344. return nil
  45345. }
  45346. // ClearedEdges returns all edge names that were cleared in this mutation.
  45347. func (m *WxCardUserMutation) ClearedEdges() []string {
  45348. edges := make([]string, 0, 0)
  45349. return edges
  45350. }
  45351. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45352. // was cleared in this mutation.
  45353. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  45354. return false
  45355. }
  45356. // ClearEdge clears the value of the edge with the given name. It returns an error
  45357. // if that edge is not defined in the schema.
  45358. func (m *WxCardUserMutation) ClearEdge(name string) error {
  45359. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  45360. }
  45361. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45362. // It returns an error if the edge is not defined in the schema.
  45363. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45364. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45365. }
  45366. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45367. type WxCardVisitMutation struct {
  45368. config
  45369. op Op
  45370. typ string
  45371. id *uint64
  45372. created_at *time.Time
  45373. updated_at *time.Time
  45374. deleted_at *time.Time
  45375. user_id *uint64
  45376. adduser_id *int64
  45377. bot_id *uint64
  45378. addbot_id *int64
  45379. bot_type *uint8
  45380. addbot_type *int8
  45381. clearedFields map[string]struct{}
  45382. done bool
  45383. oldValue func(context.Context) (*WxCardVisit, error)
  45384. predicates []predicate.WxCardVisit
  45385. }
  45386. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45387. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45388. type wxcardvisitOption func(*WxCardVisitMutation)
  45389. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45390. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45391. m := &WxCardVisitMutation{
  45392. config: c,
  45393. op: op,
  45394. typ: TypeWxCardVisit,
  45395. clearedFields: make(map[string]struct{}),
  45396. }
  45397. for _, opt := range opts {
  45398. opt(m)
  45399. }
  45400. return m
  45401. }
  45402. // withWxCardVisitID sets the ID field of the mutation.
  45403. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45404. return func(m *WxCardVisitMutation) {
  45405. var (
  45406. err error
  45407. once sync.Once
  45408. value *WxCardVisit
  45409. )
  45410. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45411. once.Do(func() {
  45412. if m.done {
  45413. err = errors.New("querying old values post mutation is not allowed")
  45414. } else {
  45415. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45416. }
  45417. })
  45418. return value, err
  45419. }
  45420. m.id = &id
  45421. }
  45422. }
  45423. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45424. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45425. return func(m *WxCardVisitMutation) {
  45426. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45427. return node, nil
  45428. }
  45429. m.id = &node.ID
  45430. }
  45431. }
  45432. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45433. // executed in a transaction (ent.Tx), a transactional client is returned.
  45434. func (m WxCardVisitMutation) Client() *Client {
  45435. client := &Client{config: m.config}
  45436. client.init()
  45437. return client
  45438. }
  45439. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45440. // it returns an error otherwise.
  45441. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45442. if _, ok := m.driver.(*txDriver); !ok {
  45443. return nil, errors.New("ent: mutation is not running in a transaction")
  45444. }
  45445. tx := &Tx{config: m.config}
  45446. tx.init()
  45447. return tx, nil
  45448. }
  45449. // SetID sets the value of the id field. Note that this
  45450. // operation is only accepted on creation of WxCardVisit entities.
  45451. func (m *WxCardVisitMutation) SetID(id uint64) {
  45452. m.id = &id
  45453. }
  45454. // ID returns the ID value in the mutation. Note that the ID is only available
  45455. // if it was provided to the builder or after it was returned from the database.
  45456. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45457. if m.id == nil {
  45458. return
  45459. }
  45460. return *m.id, true
  45461. }
  45462. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45463. // That means, if the mutation is applied within a transaction with an isolation level such
  45464. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45465. // or updated by the mutation.
  45466. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45467. switch {
  45468. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45469. id, exists := m.ID()
  45470. if exists {
  45471. return []uint64{id}, nil
  45472. }
  45473. fallthrough
  45474. case m.op.Is(OpUpdate | OpDelete):
  45475. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45476. default:
  45477. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45478. }
  45479. }
  45480. // SetCreatedAt sets the "created_at" field.
  45481. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45482. m.created_at = &t
  45483. }
  45484. // CreatedAt returns the value of the "created_at" field in the mutation.
  45485. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45486. v := m.created_at
  45487. if v == nil {
  45488. return
  45489. }
  45490. return *v, true
  45491. }
  45492. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45493. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45495. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45496. if !m.op.Is(OpUpdateOne) {
  45497. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45498. }
  45499. if m.id == nil || m.oldValue == nil {
  45500. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45501. }
  45502. oldValue, err := m.oldValue(ctx)
  45503. if err != nil {
  45504. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45505. }
  45506. return oldValue.CreatedAt, nil
  45507. }
  45508. // ResetCreatedAt resets all changes to the "created_at" field.
  45509. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45510. m.created_at = nil
  45511. }
  45512. // SetUpdatedAt sets the "updated_at" field.
  45513. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45514. m.updated_at = &t
  45515. }
  45516. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45517. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45518. v := m.updated_at
  45519. if v == nil {
  45520. return
  45521. }
  45522. return *v, true
  45523. }
  45524. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45525. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45527. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45528. if !m.op.Is(OpUpdateOne) {
  45529. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45530. }
  45531. if m.id == nil || m.oldValue == nil {
  45532. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45533. }
  45534. oldValue, err := m.oldValue(ctx)
  45535. if err != nil {
  45536. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45537. }
  45538. return oldValue.UpdatedAt, nil
  45539. }
  45540. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45541. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45542. m.updated_at = nil
  45543. }
  45544. // SetDeletedAt sets the "deleted_at" field.
  45545. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45546. m.deleted_at = &t
  45547. }
  45548. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45549. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45550. v := m.deleted_at
  45551. if v == nil {
  45552. return
  45553. }
  45554. return *v, true
  45555. }
  45556. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45557. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45559. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45560. if !m.op.Is(OpUpdateOne) {
  45561. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45562. }
  45563. if m.id == nil || m.oldValue == nil {
  45564. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45565. }
  45566. oldValue, err := m.oldValue(ctx)
  45567. if err != nil {
  45568. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45569. }
  45570. return oldValue.DeletedAt, nil
  45571. }
  45572. // ClearDeletedAt clears the value of the "deleted_at" field.
  45573. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45574. m.deleted_at = nil
  45575. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45576. }
  45577. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45578. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45579. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45580. return ok
  45581. }
  45582. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45583. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45584. m.deleted_at = nil
  45585. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45586. }
  45587. // SetUserID sets the "user_id" field.
  45588. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45589. m.user_id = &u
  45590. m.adduser_id = nil
  45591. }
  45592. // UserID returns the value of the "user_id" field in the mutation.
  45593. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45594. v := m.user_id
  45595. if v == nil {
  45596. return
  45597. }
  45598. return *v, true
  45599. }
  45600. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45601. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45603. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45604. if !m.op.Is(OpUpdateOne) {
  45605. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45606. }
  45607. if m.id == nil || m.oldValue == nil {
  45608. return v, errors.New("OldUserID requires an ID field in the mutation")
  45609. }
  45610. oldValue, err := m.oldValue(ctx)
  45611. if err != nil {
  45612. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45613. }
  45614. return oldValue.UserID, nil
  45615. }
  45616. // AddUserID adds u to the "user_id" field.
  45617. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45618. if m.adduser_id != nil {
  45619. *m.adduser_id += u
  45620. } else {
  45621. m.adduser_id = &u
  45622. }
  45623. }
  45624. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45625. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45626. v := m.adduser_id
  45627. if v == nil {
  45628. return
  45629. }
  45630. return *v, true
  45631. }
  45632. // ClearUserID clears the value of the "user_id" field.
  45633. func (m *WxCardVisitMutation) ClearUserID() {
  45634. m.user_id = nil
  45635. m.adduser_id = nil
  45636. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45637. }
  45638. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45639. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45640. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45641. return ok
  45642. }
  45643. // ResetUserID resets all changes to the "user_id" field.
  45644. func (m *WxCardVisitMutation) ResetUserID() {
  45645. m.user_id = nil
  45646. m.adduser_id = nil
  45647. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45648. }
  45649. // SetBotID sets the "bot_id" field.
  45650. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45651. m.bot_id = &u
  45652. m.addbot_id = nil
  45653. }
  45654. // BotID returns the value of the "bot_id" field in the mutation.
  45655. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45656. v := m.bot_id
  45657. if v == nil {
  45658. return
  45659. }
  45660. return *v, true
  45661. }
  45662. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45663. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45665. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45666. if !m.op.Is(OpUpdateOne) {
  45667. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45668. }
  45669. if m.id == nil || m.oldValue == nil {
  45670. return v, errors.New("OldBotID requires an ID field in the mutation")
  45671. }
  45672. oldValue, err := m.oldValue(ctx)
  45673. if err != nil {
  45674. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45675. }
  45676. return oldValue.BotID, nil
  45677. }
  45678. // AddBotID adds u to the "bot_id" field.
  45679. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45680. if m.addbot_id != nil {
  45681. *m.addbot_id += u
  45682. } else {
  45683. m.addbot_id = &u
  45684. }
  45685. }
  45686. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45687. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45688. v := m.addbot_id
  45689. if v == nil {
  45690. return
  45691. }
  45692. return *v, true
  45693. }
  45694. // ResetBotID resets all changes to the "bot_id" field.
  45695. func (m *WxCardVisitMutation) ResetBotID() {
  45696. m.bot_id = nil
  45697. m.addbot_id = nil
  45698. }
  45699. // SetBotType sets the "bot_type" field.
  45700. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45701. m.bot_type = &u
  45702. m.addbot_type = nil
  45703. }
  45704. // BotType returns the value of the "bot_type" field in the mutation.
  45705. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45706. v := m.bot_type
  45707. if v == nil {
  45708. return
  45709. }
  45710. return *v, true
  45711. }
  45712. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45713. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45715. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45716. if !m.op.Is(OpUpdateOne) {
  45717. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45718. }
  45719. if m.id == nil || m.oldValue == nil {
  45720. return v, errors.New("OldBotType requires an ID field in the mutation")
  45721. }
  45722. oldValue, err := m.oldValue(ctx)
  45723. if err != nil {
  45724. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45725. }
  45726. return oldValue.BotType, nil
  45727. }
  45728. // AddBotType adds u to the "bot_type" field.
  45729. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45730. if m.addbot_type != nil {
  45731. *m.addbot_type += u
  45732. } else {
  45733. m.addbot_type = &u
  45734. }
  45735. }
  45736. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45737. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45738. v := m.addbot_type
  45739. if v == nil {
  45740. return
  45741. }
  45742. return *v, true
  45743. }
  45744. // ResetBotType resets all changes to the "bot_type" field.
  45745. func (m *WxCardVisitMutation) ResetBotType() {
  45746. m.bot_type = nil
  45747. m.addbot_type = nil
  45748. }
  45749. // Where appends a list predicates to the WxCardVisitMutation builder.
  45750. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45751. m.predicates = append(m.predicates, ps...)
  45752. }
  45753. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45754. // users can use type-assertion to append predicates that do not depend on any generated package.
  45755. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45756. p := make([]predicate.WxCardVisit, len(ps))
  45757. for i := range ps {
  45758. p[i] = ps[i]
  45759. }
  45760. m.Where(p...)
  45761. }
  45762. // Op returns the operation name.
  45763. func (m *WxCardVisitMutation) Op() Op {
  45764. return m.op
  45765. }
  45766. // SetOp allows setting the mutation operation.
  45767. func (m *WxCardVisitMutation) SetOp(op Op) {
  45768. m.op = op
  45769. }
  45770. // Type returns the node type of this mutation (WxCardVisit).
  45771. func (m *WxCardVisitMutation) Type() string {
  45772. return m.typ
  45773. }
  45774. // Fields returns all fields that were changed during this mutation. Note that in
  45775. // order to get all numeric fields that were incremented/decremented, call
  45776. // AddedFields().
  45777. func (m *WxCardVisitMutation) Fields() []string {
  45778. fields := make([]string, 0, 6)
  45779. if m.created_at != nil {
  45780. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45781. }
  45782. if m.updated_at != nil {
  45783. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45784. }
  45785. if m.deleted_at != nil {
  45786. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45787. }
  45788. if m.user_id != nil {
  45789. fields = append(fields, wxcardvisit.FieldUserID)
  45790. }
  45791. if m.bot_id != nil {
  45792. fields = append(fields, wxcardvisit.FieldBotID)
  45793. }
  45794. if m.bot_type != nil {
  45795. fields = append(fields, wxcardvisit.FieldBotType)
  45796. }
  45797. return fields
  45798. }
  45799. // Field returns the value of a field with the given name. The second boolean
  45800. // return value indicates that this field was not set, or was not defined in the
  45801. // schema.
  45802. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45803. switch name {
  45804. case wxcardvisit.FieldCreatedAt:
  45805. return m.CreatedAt()
  45806. case wxcardvisit.FieldUpdatedAt:
  45807. return m.UpdatedAt()
  45808. case wxcardvisit.FieldDeletedAt:
  45809. return m.DeletedAt()
  45810. case wxcardvisit.FieldUserID:
  45811. return m.UserID()
  45812. case wxcardvisit.FieldBotID:
  45813. return m.BotID()
  45814. case wxcardvisit.FieldBotType:
  45815. return m.BotType()
  45816. }
  45817. return nil, false
  45818. }
  45819. // OldField returns the old value of the field from the database. An error is
  45820. // returned if the mutation operation is not UpdateOne, or the query to the
  45821. // database failed.
  45822. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45823. switch name {
  45824. case wxcardvisit.FieldCreatedAt:
  45825. return m.OldCreatedAt(ctx)
  45826. case wxcardvisit.FieldUpdatedAt:
  45827. return m.OldUpdatedAt(ctx)
  45828. case wxcardvisit.FieldDeletedAt:
  45829. return m.OldDeletedAt(ctx)
  45830. case wxcardvisit.FieldUserID:
  45831. return m.OldUserID(ctx)
  45832. case wxcardvisit.FieldBotID:
  45833. return m.OldBotID(ctx)
  45834. case wxcardvisit.FieldBotType:
  45835. return m.OldBotType(ctx)
  45836. }
  45837. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45838. }
  45839. // SetField sets the value of a field with the given name. It returns an error if
  45840. // the field is not defined in the schema, or if the type mismatched the field
  45841. // type.
  45842. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45843. switch name {
  45844. case wxcardvisit.FieldCreatedAt:
  45845. v, ok := value.(time.Time)
  45846. if !ok {
  45847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45848. }
  45849. m.SetCreatedAt(v)
  45850. return nil
  45851. case wxcardvisit.FieldUpdatedAt:
  45852. v, ok := value.(time.Time)
  45853. if !ok {
  45854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45855. }
  45856. m.SetUpdatedAt(v)
  45857. return nil
  45858. case wxcardvisit.FieldDeletedAt:
  45859. v, ok := value.(time.Time)
  45860. if !ok {
  45861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45862. }
  45863. m.SetDeletedAt(v)
  45864. return nil
  45865. case wxcardvisit.FieldUserID:
  45866. v, ok := value.(uint64)
  45867. if !ok {
  45868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45869. }
  45870. m.SetUserID(v)
  45871. return nil
  45872. case wxcardvisit.FieldBotID:
  45873. v, ok := value.(uint64)
  45874. if !ok {
  45875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45876. }
  45877. m.SetBotID(v)
  45878. return nil
  45879. case wxcardvisit.FieldBotType:
  45880. v, ok := value.(uint8)
  45881. if !ok {
  45882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45883. }
  45884. m.SetBotType(v)
  45885. return nil
  45886. }
  45887. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45888. }
  45889. // AddedFields returns all numeric fields that were incremented/decremented during
  45890. // this mutation.
  45891. func (m *WxCardVisitMutation) AddedFields() []string {
  45892. var fields []string
  45893. if m.adduser_id != nil {
  45894. fields = append(fields, wxcardvisit.FieldUserID)
  45895. }
  45896. if m.addbot_id != nil {
  45897. fields = append(fields, wxcardvisit.FieldBotID)
  45898. }
  45899. if m.addbot_type != nil {
  45900. fields = append(fields, wxcardvisit.FieldBotType)
  45901. }
  45902. return fields
  45903. }
  45904. // AddedField returns the numeric value that was incremented/decremented on a field
  45905. // with the given name. The second boolean return value indicates that this field
  45906. // was not set, or was not defined in the schema.
  45907. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45908. switch name {
  45909. case wxcardvisit.FieldUserID:
  45910. return m.AddedUserID()
  45911. case wxcardvisit.FieldBotID:
  45912. return m.AddedBotID()
  45913. case wxcardvisit.FieldBotType:
  45914. return m.AddedBotType()
  45915. }
  45916. return nil, false
  45917. }
  45918. // AddField adds the value to the field with the given name. It returns an error if
  45919. // the field is not defined in the schema, or if the type mismatched the field
  45920. // type.
  45921. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45922. switch name {
  45923. case wxcardvisit.FieldUserID:
  45924. v, ok := value.(int64)
  45925. if !ok {
  45926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45927. }
  45928. m.AddUserID(v)
  45929. return nil
  45930. case wxcardvisit.FieldBotID:
  45931. v, ok := value.(int64)
  45932. if !ok {
  45933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45934. }
  45935. m.AddBotID(v)
  45936. return nil
  45937. case wxcardvisit.FieldBotType:
  45938. v, ok := value.(int8)
  45939. if !ok {
  45940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45941. }
  45942. m.AddBotType(v)
  45943. return nil
  45944. }
  45945. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45946. }
  45947. // ClearedFields returns all nullable fields that were cleared during this
  45948. // mutation.
  45949. func (m *WxCardVisitMutation) ClearedFields() []string {
  45950. var fields []string
  45951. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45952. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45953. }
  45954. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45955. fields = append(fields, wxcardvisit.FieldUserID)
  45956. }
  45957. return fields
  45958. }
  45959. // FieldCleared returns a boolean indicating if a field with the given name was
  45960. // cleared in this mutation.
  45961. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45962. _, ok := m.clearedFields[name]
  45963. return ok
  45964. }
  45965. // ClearField clears the value of the field with the given name. It returns an
  45966. // error if the field is not defined in the schema.
  45967. func (m *WxCardVisitMutation) ClearField(name string) error {
  45968. switch name {
  45969. case wxcardvisit.FieldDeletedAt:
  45970. m.ClearDeletedAt()
  45971. return nil
  45972. case wxcardvisit.FieldUserID:
  45973. m.ClearUserID()
  45974. return nil
  45975. }
  45976. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45977. }
  45978. // ResetField resets all changes in the mutation for the field with the given name.
  45979. // It returns an error if the field is not defined in the schema.
  45980. func (m *WxCardVisitMutation) ResetField(name string) error {
  45981. switch name {
  45982. case wxcardvisit.FieldCreatedAt:
  45983. m.ResetCreatedAt()
  45984. return nil
  45985. case wxcardvisit.FieldUpdatedAt:
  45986. m.ResetUpdatedAt()
  45987. return nil
  45988. case wxcardvisit.FieldDeletedAt:
  45989. m.ResetDeletedAt()
  45990. return nil
  45991. case wxcardvisit.FieldUserID:
  45992. m.ResetUserID()
  45993. return nil
  45994. case wxcardvisit.FieldBotID:
  45995. m.ResetBotID()
  45996. return nil
  45997. case wxcardvisit.FieldBotType:
  45998. m.ResetBotType()
  45999. return nil
  46000. }
  46001. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46002. }
  46003. // AddedEdges returns all edge names that were set/added in this mutation.
  46004. func (m *WxCardVisitMutation) AddedEdges() []string {
  46005. edges := make([]string, 0, 0)
  46006. return edges
  46007. }
  46008. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46009. // name in this mutation.
  46010. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  46011. return nil
  46012. }
  46013. // RemovedEdges returns all edge names that were removed in this mutation.
  46014. func (m *WxCardVisitMutation) RemovedEdges() []string {
  46015. edges := make([]string, 0, 0)
  46016. return edges
  46017. }
  46018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46019. // the given name in this mutation.
  46020. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  46021. return nil
  46022. }
  46023. // ClearedEdges returns all edge names that were cleared in this mutation.
  46024. func (m *WxCardVisitMutation) ClearedEdges() []string {
  46025. edges := make([]string, 0, 0)
  46026. return edges
  46027. }
  46028. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46029. // was cleared in this mutation.
  46030. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  46031. return false
  46032. }
  46033. // ClearEdge clears the value of the edge with the given name. It returns an error
  46034. // if that edge is not defined in the schema.
  46035. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  46036. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  46037. }
  46038. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46039. // It returns an error if the edge is not defined in the schema.
  46040. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  46041. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  46042. }
  46043. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  46044. type XunjiMutation struct {
  46045. config
  46046. op Op
  46047. typ string
  46048. id *uint64
  46049. created_at *time.Time
  46050. updated_at *time.Time
  46051. status *uint8
  46052. addstatus *int8
  46053. deleted_at *time.Time
  46054. app_key *string
  46055. app_secret *string
  46056. token *string
  46057. encoding_key *string
  46058. organization_id *uint64
  46059. addorganization_id *int64
  46060. clearedFields map[string]struct{}
  46061. done bool
  46062. oldValue func(context.Context) (*Xunji, error)
  46063. predicates []predicate.Xunji
  46064. }
  46065. var _ ent.Mutation = (*XunjiMutation)(nil)
  46066. // xunjiOption allows management of the mutation configuration using functional options.
  46067. type xunjiOption func(*XunjiMutation)
  46068. // newXunjiMutation creates new mutation for the Xunji entity.
  46069. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  46070. m := &XunjiMutation{
  46071. config: c,
  46072. op: op,
  46073. typ: TypeXunji,
  46074. clearedFields: make(map[string]struct{}),
  46075. }
  46076. for _, opt := range opts {
  46077. opt(m)
  46078. }
  46079. return m
  46080. }
  46081. // withXunjiID sets the ID field of the mutation.
  46082. func withXunjiID(id uint64) xunjiOption {
  46083. return func(m *XunjiMutation) {
  46084. var (
  46085. err error
  46086. once sync.Once
  46087. value *Xunji
  46088. )
  46089. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  46090. once.Do(func() {
  46091. if m.done {
  46092. err = errors.New("querying old values post mutation is not allowed")
  46093. } else {
  46094. value, err = m.Client().Xunji.Get(ctx, id)
  46095. }
  46096. })
  46097. return value, err
  46098. }
  46099. m.id = &id
  46100. }
  46101. }
  46102. // withXunji sets the old Xunji of the mutation.
  46103. func withXunji(node *Xunji) xunjiOption {
  46104. return func(m *XunjiMutation) {
  46105. m.oldValue = func(context.Context) (*Xunji, error) {
  46106. return node, nil
  46107. }
  46108. m.id = &node.ID
  46109. }
  46110. }
  46111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46112. // executed in a transaction (ent.Tx), a transactional client is returned.
  46113. func (m XunjiMutation) Client() *Client {
  46114. client := &Client{config: m.config}
  46115. client.init()
  46116. return client
  46117. }
  46118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46119. // it returns an error otherwise.
  46120. func (m XunjiMutation) Tx() (*Tx, error) {
  46121. if _, ok := m.driver.(*txDriver); !ok {
  46122. return nil, errors.New("ent: mutation is not running in a transaction")
  46123. }
  46124. tx := &Tx{config: m.config}
  46125. tx.init()
  46126. return tx, nil
  46127. }
  46128. // SetID sets the value of the id field. Note that this
  46129. // operation is only accepted on creation of Xunji entities.
  46130. func (m *XunjiMutation) SetID(id uint64) {
  46131. m.id = &id
  46132. }
  46133. // ID returns the ID value in the mutation. Note that the ID is only available
  46134. // if it was provided to the builder or after it was returned from the database.
  46135. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  46136. if m.id == nil {
  46137. return
  46138. }
  46139. return *m.id, true
  46140. }
  46141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46142. // That means, if the mutation is applied within a transaction with an isolation level such
  46143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46144. // or updated by the mutation.
  46145. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  46146. switch {
  46147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46148. id, exists := m.ID()
  46149. if exists {
  46150. return []uint64{id}, nil
  46151. }
  46152. fallthrough
  46153. case m.op.Is(OpUpdate | OpDelete):
  46154. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  46155. default:
  46156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46157. }
  46158. }
  46159. // SetCreatedAt sets the "created_at" field.
  46160. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  46161. m.created_at = &t
  46162. }
  46163. // CreatedAt returns the value of the "created_at" field in the mutation.
  46164. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  46165. v := m.created_at
  46166. if v == nil {
  46167. return
  46168. }
  46169. return *v, true
  46170. }
  46171. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  46172. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46174. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46175. if !m.op.Is(OpUpdateOne) {
  46176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46177. }
  46178. if m.id == nil || m.oldValue == nil {
  46179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46180. }
  46181. oldValue, err := m.oldValue(ctx)
  46182. if err != nil {
  46183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46184. }
  46185. return oldValue.CreatedAt, nil
  46186. }
  46187. // ResetCreatedAt resets all changes to the "created_at" field.
  46188. func (m *XunjiMutation) ResetCreatedAt() {
  46189. m.created_at = nil
  46190. }
  46191. // SetUpdatedAt sets the "updated_at" field.
  46192. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  46193. m.updated_at = &t
  46194. }
  46195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46196. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  46197. v := m.updated_at
  46198. if v == nil {
  46199. return
  46200. }
  46201. return *v, true
  46202. }
  46203. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  46204. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46206. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46207. if !m.op.Is(OpUpdateOne) {
  46208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46209. }
  46210. if m.id == nil || m.oldValue == nil {
  46211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46212. }
  46213. oldValue, err := m.oldValue(ctx)
  46214. if err != nil {
  46215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46216. }
  46217. return oldValue.UpdatedAt, nil
  46218. }
  46219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46220. func (m *XunjiMutation) ResetUpdatedAt() {
  46221. m.updated_at = nil
  46222. }
  46223. // SetStatus sets the "status" field.
  46224. func (m *XunjiMutation) SetStatus(u uint8) {
  46225. m.status = &u
  46226. m.addstatus = nil
  46227. }
  46228. // Status returns the value of the "status" field in the mutation.
  46229. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  46230. v := m.status
  46231. if v == nil {
  46232. return
  46233. }
  46234. return *v, true
  46235. }
  46236. // OldStatus returns the old "status" field's value of the Xunji entity.
  46237. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46239. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46240. if !m.op.Is(OpUpdateOne) {
  46241. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46242. }
  46243. if m.id == nil || m.oldValue == nil {
  46244. return v, errors.New("OldStatus requires an ID field in the mutation")
  46245. }
  46246. oldValue, err := m.oldValue(ctx)
  46247. if err != nil {
  46248. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46249. }
  46250. return oldValue.Status, nil
  46251. }
  46252. // AddStatus adds u to the "status" field.
  46253. func (m *XunjiMutation) AddStatus(u int8) {
  46254. if m.addstatus != nil {
  46255. *m.addstatus += u
  46256. } else {
  46257. m.addstatus = &u
  46258. }
  46259. }
  46260. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46261. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  46262. v := m.addstatus
  46263. if v == nil {
  46264. return
  46265. }
  46266. return *v, true
  46267. }
  46268. // ClearStatus clears the value of the "status" field.
  46269. func (m *XunjiMutation) ClearStatus() {
  46270. m.status = nil
  46271. m.addstatus = nil
  46272. m.clearedFields[xunji.FieldStatus] = struct{}{}
  46273. }
  46274. // StatusCleared returns if the "status" field was cleared in this mutation.
  46275. func (m *XunjiMutation) StatusCleared() bool {
  46276. _, ok := m.clearedFields[xunji.FieldStatus]
  46277. return ok
  46278. }
  46279. // ResetStatus resets all changes to the "status" field.
  46280. func (m *XunjiMutation) ResetStatus() {
  46281. m.status = nil
  46282. m.addstatus = nil
  46283. delete(m.clearedFields, xunji.FieldStatus)
  46284. }
  46285. // SetDeletedAt sets the "deleted_at" field.
  46286. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  46287. m.deleted_at = &t
  46288. }
  46289. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46290. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  46291. v := m.deleted_at
  46292. if v == nil {
  46293. return
  46294. }
  46295. return *v, true
  46296. }
  46297. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  46298. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46300. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46301. if !m.op.Is(OpUpdateOne) {
  46302. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46303. }
  46304. if m.id == nil || m.oldValue == nil {
  46305. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46306. }
  46307. oldValue, err := m.oldValue(ctx)
  46308. if err != nil {
  46309. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46310. }
  46311. return oldValue.DeletedAt, nil
  46312. }
  46313. // ClearDeletedAt clears the value of the "deleted_at" field.
  46314. func (m *XunjiMutation) ClearDeletedAt() {
  46315. m.deleted_at = nil
  46316. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  46317. }
  46318. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46319. func (m *XunjiMutation) DeletedAtCleared() bool {
  46320. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  46321. return ok
  46322. }
  46323. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46324. func (m *XunjiMutation) ResetDeletedAt() {
  46325. m.deleted_at = nil
  46326. delete(m.clearedFields, xunji.FieldDeletedAt)
  46327. }
  46328. // SetAppKey sets the "app_key" field.
  46329. func (m *XunjiMutation) SetAppKey(s string) {
  46330. m.app_key = &s
  46331. }
  46332. // AppKey returns the value of the "app_key" field in the mutation.
  46333. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  46334. v := m.app_key
  46335. if v == nil {
  46336. return
  46337. }
  46338. return *v, true
  46339. }
  46340. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  46341. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46343. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  46344. if !m.op.Is(OpUpdateOne) {
  46345. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  46346. }
  46347. if m.id == nil || m.oldValue == nil {
  46348. return v, errors.New("OldAppKey requires an ID field in the mutation")
  46349. }
  46350. oldValue, err := m.oldValue(ctx)
  46351. if err != nil {
  46352. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  46353. }
  46354. return oldValue.AppKey, nil
  46355. }
  46356. // ClearAppKey clears the value of the "app_key" field.
  46357. func (m *XunjiMutation) ClearAppKey() {
  46358. m.app_key = nil
  46359. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  46360. }
  46361. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  46362. func (m *XunjiMutation) AppKeyCleared() bool {
  46363. _, ok := m.clearedFields[xunji.FieldAppKey]
  46364. return ok
  46365. }
  46366. // ResetAppKey resets all changes to the "app_key" field.
  46367. func (m *XunjiMutation) ResetAppKey() {
  46368. m.app_key = nil
  46369. delete(m.clearedFields, xunji.FieldAppKey)
  46370. }
  46371. // SetAppSecret sets the "app_secret" field.
  46372. func (m *XunjiMutation) SetAppSecret(s string) {
  46373. m.app_secret = &s
  46374. }
  46375. // AppSecret returns the value of the "app_secret" field in the mutation.
  46376. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46377. v := m.app_secret
  46378. if v == nil {
  46379. return
  46380. }
  46381. return *v, true
  46382. }
  46383. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46384. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46386. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46387. if !m.op.Is(OpUpdateOne) {
  46388. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46389. }
  46390. if m.id == nil || m.oldValue == nil {
  46391. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46392. }
  46393. oldValue, err := m.oldValue(ctx)
  46394. if err != nil {
  46395. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46396. }
  46397. return oldValue.AppSecret, nil
  46398. }
  46399. // ClearAppSecret clears the value of the "app_secret" field.
  46400. func (m *XunjiMutation) ClearAppSecret() {
  46401. m.app_secret = nil
  46402. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  46403. }
  46404. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  46405. func (m *XunjiMutation) AppSecretCleared() bool {
  46406. _, ok := m.clearedFields[xunji.FieldAppSecret]
  46407. return ok
  46408. }
  46409. // ResetAppSecret resets all changes to the "app_secret" field.
  46410. func (m *XunjiMutation) ResetAppSecret() {
  46411. m.app_secret = nil
  46412. delete(m.clearedFields, xunji.FieldAppSecret)
  46413. }
  46414. // SetToken sets the "token" field.
  46415. func (m *XunjiMutation) SetToken(s string) {
  46416. m.token = &s
  46417. }
  46418. // Token returns the value of the "token" field in the mutation.
  46419. func (m *XunjiMutation) Token() (r string, exists bool) {
  46420. v := m.token
  46421. if v == nil {
  46422. return
  46423. }
  46424. return *v, true
  46425. }
  46426. // OldToken returns the old "token" field's value of the Xunji entity.
  46427. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46429. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46430. if !m.op.Is(OpUpdateOne) {
  46431. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46432. }
  46433. if m.id == nil || m.oldValue == nil {
  46434. return v, errors.New("OldToken requires an ID field in the mutation")
  46435. }
  46436. oldValue, err := m.oldValue(ctx)
  46437. if err != nil {
  46438. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46439. }
  46440. return oldValue.Token, nil
  46441. }
  46442. // ClearToken clears the value of the "token" field.
  46443. func (m *XunjiMutation) ClearToken() {
  46444. m.token = nil
  46445. m.clearedFields[xunji.FieldToken] = struct{}{}
  46446. }
  46447. // TokenCleared returns if the "token" field was cleared in this mutation.
  46448. func (m *XunjiMutation) TokenCleared() bool {
  46449. _, ok := m.clearedFields[xunji.FieldToken]
  46450. return ok
  46451. }
  46452. // ResetToken resets all changes to the "token" field.
  46453. func (m *XunjiMutation) ResetToken() {
  46454. m.token = nil
  46455. delete(m.clearedFields, xunji.FieldToken)
  46456. }
  46457. // SetEncodingKey sets the "encoding_key" field.
  46458. func (m *XunjiMutation) SetEncodingKey(s string) {
  46459. m.encoding_key = &s
  46460. }
  46461. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46462. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46463. v := m.encoding_key
  46464. if v == nil {
  46465. return
  46466. }
  46467. return *v, true
  46468. }
  46469. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46470. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46472. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46473. if !m.op.Is(OpUpdateOne) {
  46474. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46475. }
  46476. if m.id == nil || m.oldValue == nil {
  46477. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46478. }
  46479. oldValue, err := m.oldValue(ctx)
  46480. if err != nil {
  46481. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46482. }
  46483. return oldValue.EncodingKey, nil
  46484. }
  46485. // ClearEncodingKey clears the value of the "encoding_key" field.
  46486. func (m *XunjiMutation) ClearEncodingKey() {
  46487. m.encoding_key = nil
  46488. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  46489. }
  46490. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  46491. func (m *XunjiMutation) EncodingKeyCleared() bool {
  46492. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  46493. return ok
  46494. }
  46495. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46496. func (m *XunjiMutation) ResetEncodingKey() {
  46497. m.encoding_key = nil
  46498. delete(m.clearedFields, xunji.FieldEncodingKey)
  46499. }
  46500. // SetOrganizationID sets the "organization_id" field.
  46501. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46502. m.organization_id = &u
  46503. m.addorganization_id = nil
  46504. }
  46505. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46506. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46507. v := m.organization_id
  46508. if v == nil {
  46509. return
  46510. }
  46511. return *v, true
  46512. }
  46513. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46514. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46516. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46517. if !m.op.Is(OpUpdateOne) {
  46518. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46519. }
  46520. if m.id == nil || m.oldValue == nil {
  46521. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46522. }
  46523. oldValue, err := m.oldValue(ctx)
  46524. if err != nil {
  46525. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46526. }
  46527. return oldValue.OrganizationID, nil
  46528. }
  46529. // AddOrganizationID adds u to the "organization_id" field.
  46530. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46531. if m.addorganization_id != nil {
  46532. *m.addorganization_id += u
  46533. } else {
  46534. m.addorganization_id = &u
  46535. }
  46536. }
  46537. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46538. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46539. v := m.addorganization_id
  46540. if v == nil {
  46541. return
  46542. }
  46543. return *v, true
  46544. }
  46545. // ResetOrganizationID resets all changes to the "organization_id" field.
  46546. func (m *XunjiMutation) ResetOrganizationID() {
  46547. m.organization_id = nil
  46548. m.addorganization_id = nil
  46549. }
  46550. // Where appends a list predicates to the XunjiMutation builder.
  46551. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46552. m.predicates = append(m.predicates, ps...)
  46553. }
  46554. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46555. // users can use type-assertion to append predicates that do not depend on any generated package.
  46556. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46557. p := make([]predicate.Xunji, len(ps))
  46558. for i := range ps {
  46559. p[i] = ps[i]
  46560. }
  46561. m.Where(p...)
  46562. }
  46563. // Op returns the operation name.
  46564. func (m *XunjiMutation) Op() Op {
  46565. return m.op
  46566. }
  46567. // SetOp allows setting the mutation operation.
  46568. func (m *XunjiMutation) SetOp(op Op) {
  46569. m.op = op
  46570. }
  46571. // Type returns the node type of this mutation (Xunji).
  46572. func (m *XunjiMutation) Type() string {
  46573. return m.typ
  46574. }
  46575. // Fields returns all fields that were changed during this mutation. Note that in
  46576. // order to get all numeric fields that were incremented/decremented, call
  46577. // AddedFields().
  46578. func (m *XunjiMutation) Fields() []string {
  46579. fields := make([]string, 0, 9)
  46580. if m.created_at != nil {
  46581. fields = append(fields, xunji.FieldCreatedAt)
  46582. }
  46583. if m.updated_at != nil {
  46584. fields = append(fields, xunji.FieldUpdatedAt)
  46585. }
  46586. if m.status != nil {
  46587. fields = append(fields, xunji.FieldStatus)
  46588. }
  46589. if m.deleted_at != nil {
  46590. fields = append(fields, xunji.FieldDeletedAt)
  46591. }
  46592. if m.app_key != nil {
  46593. fields = append(fields, xunji.FieldAppKey)
  46594. }
  46595. if m.app_secret != nil {
  46596. fields = append(fields, xunji.FieldAppSecret)
  46597. }
  46598. if m.token != nil {
  46599. fields = append(fields, xunji.FieldToken)
  46600. }
  46601. if m.encoding_key != nil {
  46602. fields = append(fields, xunji.FieldEncodingKey)
  46603. }
  46604. if m.organization_id != nil {
  46605. fields = append(fields, xunji.FieldOrganizationID)
  46606. }
  46607. return fields
  46608. }
  46609. // Field returns the value of a field with the given name. The second boolean
  46610. // return value indicates that this field was not set, or was not defined in the
  46611. // schema.
  46612. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46613. switch name {
  46614. case xunji.FieldCreatedAt:
  46615. return m.CreatedAt()
  46616. case xunji.FieldUpdatedAt:
  46617. return m.UpdatedAt()
  46618. case xunji.FieldStatus:
  46619. return m.Status()
  46620. case xunji.FieldDeletedAt:
  46621. return m.DeletedAt()
  46622. case xunji.FieldAppKey:
  46623. return m.AppKey()
  46624. case xunji.FieldAppSecret:
  46625. return m.AppSecret()
  46626. case xunji.FieldToken:
  46627. return m.Token()
  46628. case xunji.FieldEncodingKey:
  46629. return m.EncodingKey()
  46630. case xunji.FieldOrganizationID:
  46631. return m.OrganizationID()
  46632. }
  46633. return nil, false
  46634. }
  46635. // OldField returns the old value of the field from the database. An error is
  46636. // returned if the mutation operation is not UpdateOne, or the query to the
  46637. // database failed.
  46638. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46639. switch name {
  46640. case xunji.FieldCreatedAt:
  46641. return m.OldCreatedAt(ctx)
  46642. case xunji.FieldUpdatedAt:
  46643. return m.OldUpdatedAt(ctx)
  46644. case xunji.FieldStatus:
  46645. return m.OldStatus(ctx)
  46646. case xunji.FieldDeletedAt:
  46647. return m.OldDeletedAt(ctx)
  46648. case xunji.FieldAppKey:
  46649. return m.OldAppKey(ctx)
  46650. case xunji.FieldAppSecret:
  46651. return m.OldAppSecret(ctx)
  46652. case xunji.FieldToken:
  46653. return m.OldToken(ctx)
  46654. case xunji.FieldEncodingKey:
  46655. return m.OldEncodingKey(ctx)
  46656. case xunji.FieldOrganizationID:
  46657. return m.OldOrganizationID(ctx)
  46658. }
  46659. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46660. }
  46661. // SetField sets the value of a field with the given name. It returns an error if
  46662. // the field is not defined in the schema, or if the type mismatched the field
  46663. // type.
  46664. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46665. switch name {
  46666. case xunji.FieldCreatedAt:
  46667. v, ok := value.(time.Time)
  46668. if !ok {
  46669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46670. }
  46671. m.SetCreatedAt(v)
  46672. return nil
  46673. case xunji.FieldUpdatedAt:
  46674. v, ok := value.(time.Time)
  46675. if !ok {
  46676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46677. }
  46678. m.SetUpdatedAt(v)
  46679. return nil
  46680. case xunji.FieldStatus:
  46681. v, ok := value.(uint8)
  46682. if !ok {
  46683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46684. }
  46685. m.SetStatus(v)
  46686. return nil
  46687. case xunji.FieldDeletedAt:
  46688. v, ok := value.(time.Time)
  46689. if !ok {
  46690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46691. }
  46692. m.SetDeletedAt(v)
  46693. return nil
  46694. case xunji.FieldAppKey:
  46695. v, ok := value.(string)
  46696. if !ok {
  46697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46698. }
  46699. m.SetAppKey(v)
  46700. return nil
  46701. case xunji.FieldAppSecret:
  46702. v, ok := value.(string)
  46703. if !ok {
  46704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46705. }
  46706. m.SetAppSecret(v)
  46707. return nil
  46708. case xunji.FieldToken:
  46709. v, ok := value.(string)
  46710. if !ok {
  46711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46712. }
  46713. m.SetToken(v)
  46714. return nil
  46715. case xunji.FieldEncodingKey:
  46716. v, ok := value.(string)
  46717. if !ok {
  46718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46719. }
  46720. m.SetEncodingKey(v)
  46721. return nil
  46722. case xunji.FieldOrganizationID:
  46723. v, ok := value.(uint64)
  46724. if !ok {
  46725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46726. }
  46727. m.SetOrganizationID(v)
  46728. return nil
  46729. }
  46730. return fmt.Errorf("unknown Xunji field %s", name)
  46731. }
  46732. // AddedFields returns all numeric fields that were incremented/decremented during
  46733. // this mutation.
  46734. func (m *XunjiMutation) AddedFields() []string {
  46735. var fields []string
  46736. if m.addstatus != nil {
  46737. fields = append(fields, xunji.FieldStatus)
  46738. }
  46739. if m.addorganization_id != nil {
  46740. fields = append(fields, xunji.FieldOrganizationID)
  46741. }
  46742. return fields
  46743. }
  46744. // AddedField returns the numeric value that was incremented/decremented on a field
  46745. // with the given name. The second boolean return value indicates that this field
  46746. // was not set, or was not defined in the schema.
  46747. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46748. switch name {
  46749. case xunji.FieldStatus:
  46750. return m.AddedStatus()
  46751. case xunji.FieldOrganizationID:
  46752. return m.AddedOrganizationID()
  46753. }
  46754. return nil, false
  46755. }
  46756. // AddField adds the value to the field with the given name. It returns an error if
  46757. // the field is not defined in the schema, or if the type mismatched the field
  46758. // type.
  46759. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46760. switch name {
  46761. case xunji.FieldStatus:
  46762. v, ok := value.(int8)
  46763. if !ok {
  46764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46765. }
  46766. m.AddStatus(v)
  46767. return nil
  46768. case xunji.FieldOrganizationID:
  46769. v, ok := value.(int64)
  46770. if !ok {
  46771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46772. }
  46773. m.AddOrganizationID(v)
  46774. return nil
  46775. }
  46776. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46777. }
  46778. // ClearedFields returns all nullable fields that were cleared during this
  46779. // mutation.
  46780. func (m *XunjiMutation) ClearedFields() []string {
  46781. var fields []string
  46782. if m.FieldCleared(xunji.FieldStatus) {
  46783. fields = append(fields, xunji.FieldStatus)
  46784. }
  46785. if m.FieldCleared(xunji.FieldDeletedAt) {
  46786. fields = append(fields, xunji.FieldDeletedAt)
  46787. }
  46788. if m.FieldCleared(xunji.FieldAppKey) {
  46789. fields = append(fields, xunji.FieldAppKey)
  46790. }
  46791. if m.FieldCleared(xunji.FieldAppSecret) {
  46792. fields = append(fields, xunji.FieldAppSecret)
  46793. }
  46794. if m.FieldCleared(xunji.FieldToken) {
  46795. fields = append(fields, xunji.FieldToken)
  46796. }
  46797. if m.FieldCleared(xunji.FieldEncodingKey) {
  46798. fields = append(fields, xunji.FieldEncodingKey)
  46799. }
  46800. return fields
  46801. }
  46802. // FieldCleared returns a boolean indicating if a field with the given name was
  46803. // cleared in this mutation.
  46804. func (m *XunjiMutation) FieldCleared(name string) bool {
  46805. _, ok := m.clearedFields[name]
  46806. return ok
  46807. }
  46808. // ClearField clears the value of the field with the given name. It returns an
  46809. // error if the field is not defined in the schema.
  46810. func (m *XunjiMutation) ClearField(name string) error {
  46811. switch name {
  46812. case xunji.FieldStatus:
  46813. m.ClearStatus()
  46814. return nil
  46815. case xunji.FieldDeletedAt:
  46816. m.ClearDeletedAt()
  46817. return nil
  46818. case xunji.FieldAppKey:
  46819. m.ClearAppKey()
  46820. return nil
  46821. case xunji.FieldAppSecret:
  46822. m.ClearAppSecret()
  46823. return nil
  46824. case xunji.FieldToken:
  46825. m.ClearToken()
  46826. return nil
  46827. case xunji.FieldEncodingKey:
  46828. m.ClearEncodingKey()
  46829. return nil
  46830. }
  46831. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46832. }
  46833. // ResetField resets all changes in the mutation for the field with the given name.
  46834. // It returns an error if the field is not defined in the schema.
  46835. func (m *XunjiMutation) ResetField(name string) error {
  46836. switch name {
  46837. case xunji.FieldCreatedAt:
  46838. m.ResetCreatedAt()
  46839. return nil
  46840. case xunji.FieldUpdatedAt:
  46841. m.ResetUpdatedAt()
  46842. return nil
  46843. case xunji.FieldStatus:
  46844. m.ResetStatus()
  46845. return nil
  46846. case xunji.FieldDeletedAt:
  46847. m.ResetDeletedAt()
  46848. return nil
  46849. case xunji.FieldAppKey:
  46850. m.ResetAppKey()
  46851. return nil
  46852. case xunji.FieldAppSecret:
  46853. m.ResetAppSecret()
  46854. return nil
  46855. case xunji.FieldToken:
  46856. m.ResetToken()
  46857. return nil
  46858. case xunji.FieldEncodingKey:
  46859. m.ResetEncodingKey()
  46860. return nil
  46861. case xunji.FieldOrganizationID:
  46862. m.ResetOrganizationID()
  46863. return nil
  46864. }
  46865. return fmt.Errorf("unknown Xunji field %s", name)
  46866. }
  46867. // AddedEdges returns all edge names that were set/added in this mutation.
  46868. func (m *XunjiMutation) AddedEdges() []string {
  46869. edges := make([]string, 0, 0)
  46870. return edges
  46871. }
  46872. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46873. // name in this mutation.
  46874. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46875. return nil
  46876. }
  46877. // RemovedEdges returns all edge names that were removed in this mutation.
  46878. func (m *XunjiMutation) RemovedEdges() []string {
  46879. edges := make([]string, 0, 0)
  46880. return edges
  46881. }
  46882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46883. // the given name in this mutation.
  46884. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46885. return nil
  46886. }
  46887. // ClearedEdges returns all edge names that were cleared in this mutation.
  46888. func (m *XunjiMutation) ClearedEdges() []string {
  46889. edges := make([]string, 0, 0)
  46890. return edges
  46891. }
  46892. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46893. // was cleared in this mutation.
  46894. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46895. return false
  46896. }
  46897. // ClearEdge clears the value of the edge with the given name. It returns an error
  46898. // if that edge is not defined in the schema.
  46899. func (m *XunjiMutation) ClearEdge(name string) error {
  46900. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46901. }
  46902. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46903. // It returns an error if the edge is not defined in the schema.
  46904. func (m *XunjiMutation) ResetEdge(name string) error {
  46905. return fmt.Errorf("unknown Xunji edge %s", name)
  46906. }
  46907. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46908. type XunjiServiceMutation struct {
  46909. config
  46910. op Op
  46911. typ string
  46912. id *uint64
  46913. created_at *time.Time
  46914. updated_at *time.Time
  46915. status *uint8
  46916. addstatus *int8
  46917. deleted_at *time.Time
  46918. xunji_id *uint64
  46919. addxunji_id *int64
  46920. organization_id *uint64
  46921. addorganization_id *int64
  46922. wxid *string
  46923. api_base *string
  46924. api_key *string
  46925. clearedFields map[string]struct{}
  46926. agent *uint64
  46927. clearedagent bool
  46928. done bool
  46929. oldValue func(context.Context) (*XunjiService, error)
  46930. predicates []predicate.XunjiService
  46931. }
  46932. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46933. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46934. type xunjiserviceOption func(*XunjiServiceMutation)
  46935. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46936. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46937. m := &XunjiServiceMutation{
  46938. config: c,
  46939. op: op,
  46940. typ: TypeXunjiService,
  46941. clearedFields: make(map[string]struct{}),
  46942. }
  46943. for _, opt := range opts {
  46944. opt(m)
  46945. }
  46946. return m
  46947. }
  46948. // withXunjiServiceID sets the ID field of the mutation.
  46949. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46950. return func(m *XunjiServiceMutation) {
  46951. var (
  46952. err error
  46953. once sync.Once
  46954. value *XunjiService
  46955. )
  46956. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46957. once.Do(func() {
  46958. if m.done {
  46959. err = errors.New("querying old values post mutation is not allowed")
  46960. } else {
  46961. value, err = m.Client().XunjiService.Get(ctx, id)
  46962. }
  46963. })
  46964. return value, err
  46965. }
  46966. m.id = &id
  46967. }
  46968. }
  46969. // withXunjiService sets the old XunjiService of the mutation.
  46970. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46971. return func(m *XunjiServiceMutation) {
  46972. m.oldValue = func(context.Context) (*XunjiService, error) {
  46973. return node, nil
  46974. }
  46975. m.id = &node.ID
  46976. }
  46977. }
  46978. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46979. // executed in a transaction (ent.Tx), a transactional client is returned.
  46980. func (m XunjiServiceMutation) Client() *Client {
  46981. client := &Client{config: m.config}
  46982. client.init()
  46983. return client
  46984. }
  46985. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46986. // it returns an error otherwise.
  46987. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46988. if _, ok := m.driver.(*txDriver); !ok {
  46989. return nil, errors.New("ent: mutation is not running in a transaction")
  46990. }
  46991. tx := &Tx{config: m.config}
  46992. tx.init()
  46993. return tx, nil
  46994. }
  46995. // SetID sets the value of the id field. Note that this
  46996. // operation is only accepted on creation of XunjiService entities.
  46997. func (m *XunjiServiceMutation) SetID(id uint64) {
  46998. m.id = &id
  46999. }
  47000. // ID returns the ID value in the mutation. Note that the ID is only available
  47001. // if it was provided to the builder or after it was returned from the database.
  47002. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  47003. if m.id == nil {
  47004. return
  47005. }
  47006. return *m.id, true
  47007. }
  47008. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47009. // That means, if the mutation is applied within a transaction with an isolation level such
  47010. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47011. // or updated by the mutation.
  47012. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  47013. switch {
  47014. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47015. id, exists := m.ID()
  47016. if exists {
  47017. return []uint64{id}, nil
  47018. }
  47019. fallthrough
  47020. case m.op.Is(OpUpdate | OpDelete):
  47021. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  47022. default:
  47023. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47024. }
  47025. }
  47026. // SetCreatedAt sets the "created_at" field.
  47027. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  47028. m.created_at = &t
  47029. }
  47030. // CreatedAt returns the value of the "created_at" field in the mutation.
  47031. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  47032. v := m.created_at
  47033. if v == nil {
  47034. return
  47035. }
  47036. return *v, true
  47037. }
  47038. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  47039. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47041. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47042. if !m.op.Is(OpUpdateOne) {
  47043. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47044. }
  47045. if m.id == nil || m.oldValue == nil {
  47046. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47047. }
  47048. oldValue, err := m.oldValue(ctx)
  47049. if err != nil {
  47050. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47051. }
  47052. return oldValue.CreatedAt, nil
  47053. }
  47054. // ResetCreatedAt resets all changes to the "created_at" field.
  47055. func (m *XunjiServiceMutation) ResetCreatedAt() {
  47056. m.created_at = nil
  47057. }
  47058. // SetUpdatedAt sets the "updated_at" field.
  47059. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  47060. m.updated_at = &t
  47061. }
  47062. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47063. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  47064. v := m.updated_at
  47065. if v == nil {
  47066. return
  47067. }
  47068. return *v, true
  47069. }
  47070. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  47071. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47073. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47074. if !m.op.Is(OpUpdateOne) {
  47075. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47076. }
  47077. if m.id == nil || m.oldValue == nil {
  47078. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47079. }
  47080. oldValue, err := m.oldValue(ctx)
  47081. if err != nil {
  47082. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47083. }
  47084. return oldValue.UpdatedAt, nil
  47085. }
  47086. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47087. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  47088. m.updated_at = nil
  47089. }
  47090. // SetStatus sets the "status" field.
  47091. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  47092. m.status = &u
  47093. m.addstatus = nil
  47094. }
  47095. // Status returns the value of the "status" field in the mutation.
  47096. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  47097. v := m.status
  47098. if v == nil {
  47099. return
  47100. }
  47101. return *v, true
  47102. }
  47103. // OldStatus returns the old "status" field's value of the XunjiService entity.
  47104. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47106. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47107. if !m.op.Is(OpUpdateOne) {
  47108. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47109. }
  47110. if m.id == nil || m.oldValue == nil {
  47111. return v, errors.New("OldStatus requires an ID field in the mutation")
  47112. }
  47113. oldValue, err := m.oldValue(ctx)
  47114. if err != nil {
  47115. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47116. }
  47117. return oldValue.Status, nil
  47118. }
  47119. // AddStatus adds u to the "status" field.
  47120. func (m *XunjiServiceMutation) AddStatus(u int8) {
  47121. if m.addstatus != nil {
  47122. *m.addstatus += u
  47123. } else {
  47124. m.addstatus = &u
  47125. }
  47126. }
  47127. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47128. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  47129. v := m.addstatus
  47130. if v == nil {
  47131. return
  47132. }
  47133. return *v, true
  47134. }
  47135. // ClearStatus clears the value of the "status" field.
  47136. func (m *XunjiServiceMutation) ClearStatus() {
  47137. m.status = nil
  47138. m.addstatus = nil
  47139. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  47140. }
  47141. // StatusCleared returns if the "status" field was cleared in this mutation.
  47142. func (m *XunjiServiceMutation) StatusCleared() bool {
  47143. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  47144. return ok
  47145. }
  47146. // ResetStatus resets all changes to the "status" field.
  47147. func (m *XunjiServiceMutation) ResetStatus() {
  47148. m.status = nil
  47149. m.addstatus = nil
  47150. delete(m.clearedFields, xunjiservice.FieldStatus)
  47151. }
  47152. // SetDeletedAt sets the "deleted_at" field.
  47153. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  47154. m.deleted_at = &t
  47155. }
  47156. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47157. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  47158. v := m.deleted_at
  47159. if v == nil {
  47160. return
  47161. }
  47162. return *v, true
  47163. }
  47164. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  47165. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47167. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47168. if !m.op.Is(OpUpdateOne) {
  47169. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47170. }
  47171. if m.id == nil || m.oldValue == nil {
  47172. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47173. }
  47174. oldValue, err := m.oldValue(ctx)
  47175. if err != nil {
  47176. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47177. }
  47178. return oldValue.DeletedAt, nil
  47179. }
  47180. // ClearDeletedAt clears the value of the "deleted_at" field.
  47181. func (m *XunjiServiceMutation) ClearDeletedAt() {
  47182. m.deleted_at = nil
  47183. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  47184. }
  47185. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47186. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  47187. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  47188. return ok
  47189. }
  47190. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47191. func (m *XunjiServiceMutation) ResetDeletedAt() {
  47192. m.deleted_at = nil
  47193. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  47194. }
  47195. // SetXunjiID sets the "xunji_id" field.
  47196. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  47197. m.xunji_id = &u
  47198. m.addxunji_id = nil
  47199. }
  47200. // XunjiID returns the value of the "xunji_id" field in the mutation.
  47201. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  47202. v := m.xunji_id
  47203. if v == nil {
  47204. return
  47205. }
  47206. return *v, true
  47207. }
  47208. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  47209. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47211. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  47212. if !m.op.Is(OpUpdateOne) {
  47213. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  47214. }
  47215. if m.id == nil || m.oldValue == nil {
  47216. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  47217. }
  47218. oldValue, err := m.oldValue(ctx)
  47219. if err != nil {
  47220. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  47221. }
  47222. return oldValue.XunjiID, nil
  47223. }
  47224. // AddXunjiID adds u to the "xunji_id" field.
  47225. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  47226. if m.addxunji_id != nil {
  47227. *m.addxunji_id += u
  47228. } else {
  47229. m.addxunji_id = &u
  47230. }
  47231. }
  47232. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  47233. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  47234. v := m.addxunji_id
  47235. if v == nil {
  47236. return
  47237. }
  47238. return *v, true
  47239. }
  47240. // ResetXunjiID resets all changes to the "xunji_id" field.
  47241. func (m *XunjiServiceMutation) ResetXunjiID() {
  47242. m.xunji_id = nil
  47243. m.addxunji_id = nil
  47244. }
  47245. // SetAgentID sets the "agent_id" field.
  47246. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  47247. m.agent = &u
  47248. }
  47249. // AgentID returns the value of the "agent_id" field in the mutation.
  47250. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  47251. v := m.agent
  47252. if v == nil {
  47253. return
  47254. }
  47255. return *v, true
  47256. }
  47257. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  47258. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47260. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47261. if !m.op.Is(OpUpdateOne) {
  47262. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47263. }
  47264. if m.id == nil || m.oldValue == nil {
  47265. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47266. }
  47267. oldValue, err := m.oldValue(ctx)
  47268. if err != nil {
  47269. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47270. }
  47271. return oldValue.AgentID, nil
  47272. }
  47273. // ResetAgentID resets all changes to the "agent_id" field.
  47274. func (m *XunjiServiceMutation) ResetAgentID() {
  47275. m.agent = nil
  47276. }
  47277. // SetOrganizationID sets the "organization_id" field.
  47278. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  47279. m.organization_id = &u
  47280. m.addorganization_id = nil
  47281. }
  47282. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47283. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  47284. v := m.organization_id
  47285. if v == nil {
  47286. return
  47287. }
  47288. return *v, true
  47289. }
  47290. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  47291. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47293. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47294. if !m.op.Is(OpUpdateOne) {
  47295. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47296. }
  47297. if m.id == nil || m.oldValue == nil {
  47298. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47299. }
  47300. oldValue, err := m.oldValue(ctx)
  47301. if err != nil {
  47302. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47303. }
  47304. return oldValue.OrganizationID, nil
  47305. }
  47306. // AddOrganizationID adds u to the "organization_id" field.
  47307. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  47308. if m.addorganization_id != nil {
  47309. *m.addorganization_id += u
  47310. } else {
  47311. m.addorganization_id = &u
  47312. }
  47313. }
  47314. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47315. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  47316. v := m.addorganization_id
  47317. if v == nil {
  47318. return
  47319. }
  47320. return *v, true
  47321. }
  47322. // ResetOrganizationID resets all changes to the "organization_id" field.
  47323. func (m *XunjiServiceMutation) ResetOrganizationID() {
  47324. m.organization_id = nil
  47325. m.addorganization_id = nil
  47326. }
  47327. // SetWxid sets the "wxid" field.
  47328. func (m *XunjiServiceMutation) SetWxid(s string) {
  47329. m.wxid = &s
  47330. }
  47331. // Wxid returns the value of the "wxid" field in the mutation.
  47332. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  47333. v := m.wxid
  47334. if v == nil {
  47335. return
  47336. }
  47337. return *v, true
  47338. }
  47339. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  47340. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47342. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  47343. if !m.op.Is(OpUpdateOne) {
  47344. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47345. }
  47346. if m.id == nil || m.oldValue == nil {
  47347. return v, errors.New("OldWxid requires an ID field in the mutation")
  47348. }
  47349. oldValue, err := m.oldValue(ctx)
  47350. if err != nil {
  47351. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47352. }
  47353. return oldValue.Wxid, nil
  47354. }
  47355. // ResetWxid resets all changes to the "wxid" field.
  47356. func (m *XunjiServiceMutation) ResetWxid() {
  47357. m.wxid = nil
  47358. }
  47359. // SetAPIBase sets the "api_base" field.
  47360. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  47361. m.api_base = &s
  47362. }
  47363. // APIBase returns the value of the "api_base" field in the mutation.
  47364. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47365. v := m.api_base
  47366. if v == nil {
  47367. return
  47368. }
  47369. return *v, true
  47370. }
  47371. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47372. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47374. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47375. if !m.op.Is(OpUpdateOne) {
  47376. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47377. }
  47378. if m.id == nil || m.oldValue == nil {
  47379. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47380. }
  47381. oldValue, err := m.oldValue(ctx)
  47382. if err != nil {
  47383. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47384. }
  47385. return oldValue.APIBase, nil
  47386. }
  47387. // ClearAPIBase clears the value of the "api_base" field.
  47388. func (m *XunjiServiceMutation) ClearAPIBase() {
  47389. m.api_base = nil
  47390. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47391. }
  47392. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47393. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47394. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47395. return ok
  47396. }
  47397. // ResetAPIBase resets all changes to the "api_base" field.
  47398. func (m *XunjiServiceMutation) ResetAPIBase() {
  47399. m.api_base = nil
  47400. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47401. }
  47402. // SetAPIKey sets the "api_key" field.
  47403. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47404. m.api_key = &s
  47405. }
  47406. // APIKey returns the value of the "api_key" field in the mutation.
  47407. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47408. v := m.api_key
  47409. if v == nil {
  47410. return
  47411. }
  47412. return *v, true
  47413. }
  47414. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47415. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47417. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47418. if !m.op.Is(OpUpdateOne) {
  47419. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47420. }
  47421. if m.id == nil || m.oldValue == nil {
  47422. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47423. }
  47424. oldValue, err := m.oldValue(ctx)
  47425. if err != nil {
  47426. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47427. }
  47428. return oldValue.APIKey, nil
  47429. }
  47430. // ClearAPIKey clears the value of the "api_key" field.
  47431. func (m *XunjiServiceMutation) ClearAPIKey() {
  47432. m.api_key = nil
  47433. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47434. }
  47435. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47436. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47437. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47438. return ok
  47439. }
  47440. // ResetAPIKey resets all changes to the "api_key" field.
  47441. func (m *XunjiServiceMutation) ResetAPIKey() {
  47442. m.api_key = nil
  47443. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47444. }
  47445. // ClearAgent clears the "agent" edge to the Agent entity.
  47446. func (m *XunjiServiceMutation) ClearAgent() {
  47447. m.clearedagent = true
  47448. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47449. }
  47450. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47451. func (m *XunjiServiceMutation) AgentCleared() bool {
  47452. return m.clearedagent
  47453. }
  47454. // AgentIDs returns the "agent" edge IDs in the mutation.
  47455. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47456. // AgentID instead. It exists only for internal usage by the builders.
  47457. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47458. if id := m.agent; id != nil {
  47459. ids = append(ids, *id)
  47460. }
  47461. return
  47462. }
  47463. // ResetAgent resets all changes to the "agent" edge.
  47464. func (m *XunjiServiceMutation) ResetAgent() {
  47465. m.agent = nil
  47466. m.clearedagent = false
  47467. }
  47468. // Where appends a list predicates to the XunjiServiceMutation builder.
  47469. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47470. m.predicates = append(m.predicates, ps...)
  47471. }
  47472. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47473. // users can use type-assertion to append predicates that do not depend on any generated package.
  47474. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47475. p := make([]predicate.XunjiService, len(ps))
  47476. for i := range ps {
  47477. p[i] = ps[i]
  47478. }
  47479. m.Where(p...)
  47480. }
  47481. // Op returns the operation name.
  47482. func (m *XunjiServiceMutation) Op() Op {
  47483. return m.op
  47484. }
  47485. // SetOp allows setting the mutation operation.
  47486. func (m *XunjiServiceMutation) SetOp(op Op) {
  47487. m.op = op
  47488. }
  47489. // Type returns the node type of this mutation (XunjiService).
  47490. func (m *XunjiServiceMutation) Type() string {
  47491. return m.typ
  47492. }
  47493. // Fields returns all fields that were changed during this mutation. Note that in
  47494. // order to get all numeric fields that were incremented/decremented, call
  47495. // AddedFields().
  47496. func (m *XunjiServiceMutation) Fields() []string {
  47497. fields := make([]string, 0, 10)
  47498. if m.created_at != nil {
  47499. fields = append(fields, xunjiservice.FieldCreatedAt)
  47500. }
  47501. if m.updated_at != nil {
  47502. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47503. }
  47504. if m.status != nil {
  47505. fields = append(fields, xunjiservice.FieldStatus)
  47506. }
  47507. if m.deleted_at != nil {
  47508. fields = append(fields, xunjiservice.FieldDeletedAt)
  47509. }
  47510. if m.xunji_id != nil {
  47511. fields = append(fields, xunjiservice.FieldXunjiID)
  47512. }
  47513. if m.agent != nil {
  47514. fields = append(fields, xunjiservice.FieldAgentID)
  47515. }
  47516. if m.organization_id != nil {
  47517. fields = append(fields, xunjiservice.FieldOrganizationID)
  47518. }
  47519. if m.wxid != nil {
  47520. fields = append(fields, xunjiservice.FieldWxid)
  47521. }
  47522. if m.api_base != nil {
  47523. fields = append(fields, xunjiservice.FieldAPIBase)
  47524. }
  47525. if m.api_key != nil {
  47526. fields = append(fields, xunjiservice.FieldAPIKey)
  47527. }
  47528. return fields
  47529. }
  47530. // Field returns the value of a field with the given name. The second boolean
  47531. // return value indicates that this field was not set, or was not defined in the
  47532. // schema.
  47533. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47534. switch name {
  47535. case xunjiservice.FieldCreatedAt:
  47536. return m.CreatedAt()
  47537. case xunjiservice.FieldUpdatedAt:
  47538. return m.UpdatedAt()
  47539. case xunjiservice.FieldStatus:
  47540. return m.Status()
  47541. case xunjiservice.FieldDeletedAt:
  47542. return m.DeletedAt()
  47543. case xunjiservice.FieldXunjiID:
  47544. return m.XunjiID()
  47545. case xunjiservice.FieldAgentID:
  47546. return m.AgentID()
  47547. case xunjiservice.FieldOrganizationID:
  47548. return m.OrganizationID()
  47549. case xunjiservice.FieldWxid:
  47550. return m.Wxid()
  47551. case xunjiservice.FieldAPIBase:
  47552. return m.APIBase()
  47553. case xunjiservice.FieldAPIKey:
  47554. return m.APIKey()
  47555. }
  47556. return nil, false
  47557. }
  47558. // OldField returns the old value of the field from the database. An error is
  47559. // returned if the mutation operation is not UpdateOne, or the query to the
  47560. // database failed.
  47561. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47562. switch name {
  47563. case xunjiservice.FieldCreatedAt:
  47564. return m.OldCreatedAt(ctx)
  47565. case xunjiservice.FieldUpdatedAt:
  47566. return m.OldUpdatedAt(ctx)
  47567. case xunjiservice.FieldStatus:
  47568. return m.OldStatus(ctx)
  47569. case xunjiservice.FieldDeletedAt:
  47570. return m.OldDeletedAt(ctx)
  47571. case xunjiservice.FieldXunjiID:
  47572. return m.OldXunjiID(ctx)
  47573. case xunjiservice.FieldAgentID:
  47574. return m.OldAgentID(ctx)
  47575. case xunjiservice.FieldOrganizationID:
  47576. return m.OldOrganizationID(ctx)
  47577. case xunjiservice.FieldWxid:
  47578. return m.OldWxid(ctx)
  47579. case xunjiservice.FieldAPIBase:
  47580. return m.OldAPIBase(ctx)
  47581. case xunjiservice.FieldAPIKey:
  47582. return m.OldAPIKey(ctx)
  47583. }
  47584. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47585. }
  47586. // SetField sets the value of a field with the given name. It returns an error if
  47587. // the field is not defined in the schema, or if the type mismatched the field
  47588. // type.
  47589. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47590. switch name {
  47591. case xunjiservice.FieldCreatedAt:
  47592. v, ok := value.(time.Time)
  47593. if !ok {
  47594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47595. }
  47596. m.SetCreatedAt(v)
  47597. return nil
  47598. case xunjiservice.FieldUpdatedAt:
  47599. v, ok := value.(time.Time)
  47600. if !ok {
  47601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47602. }
  47603. m.SetUpdatedAt(v)
  47604. return nil
  47605. case xunjiservice.FieldStatus:
  47606. v, ok := value.(uint8)
  47607. if !ok {
  47608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47609. }
  47610. m.SetStatus(v)
  47611. return nil
  47612. case xunjiservice.FieldDeletedAt:
  47613. v, ok := value.(time.Time)
  47614. if !ok {
  47615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47616. }
  47617. m.SetDeletedAt(v)
  47618. return nil
  47619. case xunjiservice.FieldXunjiID:
  47620. v, ok := value.(uint64)
  47621. if !ok {
  47622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47623. }
  47624. m.SetXunjiID(v)
  47625. return nil
  47626. case xunjiservice.FieldAgentID:
  47627. v, ok := value.(uint64)
  47628. if !ok {
  47629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47630. }
  47631. m.SetAgentID(v)
  47632. return nil
  47633. case xunjiservice.FieldOrganizationID:
  47634. v, ok := value.(uint64)
  47635. if !ok {
  47636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47637. }
  47638. m.SetOrganizationID(v)
  47639. return nil
  47640. case xunjiservice.FieldWxid:
  47641. v, ok := value.(string)
  47642. if !ok {
  47643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47644. }
  47645. m.SetWxid(v)
  47646. return nil
  47647. case xunjiservice.FieldAPIBase:
  47648. v, ok := value.(string)
  47649. if !ok {
  47650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47651. }
  47652. m.SetAPIBase(v)
  47653. return nil
  47654. case xunjiservice.FieldAPIKey:
  47655. v, ok := value.(string)
  47656. if !ok {
  47657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47658. }
  47659. m.SetAPIKey(v)
  47660. return nil
  47661. }
  47662. return fmt.Errorf("unknown XunjiService field %s", name)
  47663. }
  47664. // AddedFields returns all numeric fields that were incremented/decremented during
  47665. // this mutation.
  47666. func (m *XunjiServiceMutation) AddedFields() []string {
  47667. var fields []string
  47668. if m.addstatus != nil {
  47669. fields = append(fields, xunjiservice.FieldStatus)
  47670. }
  47671. if m.addxunji_id != nil {
  47672. fields = append(fields, xunjiservice.FieldXunjiID)
  47673. }
  47674. if m.addorganization_id != nil {
  47675. fields = append(fields, xunjiservice.FieldOrganizationID)
  47676. }
  47677. return fields
  47678. }
  47679. // AddedField returns the numeric value that was incremented/decremented on a field
  47680. // with the given name. The second boolean return value indicates that this field
  47681. // was not set, or was not defined in the schema.
  47682. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47683. switch name {
  47684. case xunjiservice.FieldStatus:
  47685. return m.AddedStatus()
  47686. case xunjiservice.FieldXunjiID:
  47687. return m.AddedXunjiID()
  47688. case xunjiservice.FieldOrganizationID:
  47689. return m.AddedOrganizationID()
  47690. }
  47691. return nil, false
  47692. }
  47693. // AddField adds the value to the field with the given name. It returns an error if
  47694. // the field is not defined in the schema, or if the type mismatched the field
  47695. // type.
  47696. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47697. switch name {
  47698. case xunjiservice.FieldStatus:
  47699. v, ok := value.(int8)
  47700. if !ok {
  47701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47702. }
  47703. m.AddStatus(v)
  47704. return nil
  47705. case xunjiservice.FieldXunjiID:
  47706. v, ok := value.(int64)
  47707. if !ok {
  47708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47709. }
  47710. m.AddXunjiID(v)
  47711. return nil
  47712. case xunjiservice.FieldOrganizationID:
  47713. v, ok := value.(int64)
  47714. if !ok {
  47715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47716. }
  47717. m.AddOrganizationID(v)
  47718. return nil
  47719. }
  47720. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47721. }
  47722. // ClearedFields returns all nullable fields that were cleared during this
  47723. // mutation.
  47724. func (m *XunjiServiceMutation) ClearedFields() []string {
  47725. var fields []string
  47726. if m.FieldCleared(xunjiservice.FieldStatus) {
  47727. fields = append(fields, xunjiservice.FieldStatus)
  47728. }
  47729. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47730. fields = append(fields, xunjiservice.FieldDeletedAt)
  47731. }
  47732. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47733. fields = append(fields, xunjiservice.FieldAPIBase)
  47734. }
  47735. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47736. fields = append(fields, xunjiservice.FieldAPIKey)
  47737. }
  47738. return fields
  47739. }
  47740. // FieldCleared returns a boolean indicating if a field with the given name was
  47741. // cleared in this mutation.
  47742. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47743. _, ok := m.clearedFields[name]
  47744. return ok
  47745. }
  47746. // ClearField clears the value of the field with the given name. It returns an
  47747. // error if the field is not defined in the schema.
  47748. func (m *XunjiServiceMutation) ClearField(name string) error {
  47749. switch name {
  47750. case xunjiservice.FieldStatus:
  47751. m.ClearStatus()
  47752. return nil
  47753. case xunjiservice.FieldDeletedAt:
  47754. m.ClearDeletedAt()
  47755. return nil
  47756. case xunjiservice.FieldAPIBase:
  47757. m.ClearAPIBase()
  47758. return nil
  47759. case xunjiservice.FieldAPIKey:
  47760. m.ClearAPIKey()
  47761. return nil
  47762. }
  47763. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47764. }
  47765. // ResetField resets all changes in the mutation for the field with the given name.
  47766. // It returns an error if the field is not defined in the schema.
  47767. func (m *XunjiServiceMutation) ResetField(name string) error {
  47768. switch name {
  47769. case xunjiservice.FieldCreatedAt:
  47770. m.ResetCreatedAt()
  47771. return nil
  47772. case xunjiservice.FieldUpdatedAt:
  47773. m.ResetUpdatedAt()
  47774. return nil
  47775. case xunjiservice.FieldStatus:
  47776. m.ResetStatus()
  47777. return nil
  47778. case xunjiservice.FieldDeletedAt:
  47779. m.ResetDeletedAt()
  47780. return nil
  47781. case xunjiservice.FieldXunjiID:
  47782. m.ResetXunjiID()
  47783. return nil
  47784. case xunjiservice.FieldAgentID:
  47785. m.ResetAgentID()
  47786. return nil
  47787. case xunjiservice.FieldOrganizationID:
  47788. m.ResetOrganizationID()
  47789. return nil
  47790. case xunjiservice.FieldWxid:
  47791. m.ResetWxid()
  47792. return nil
  47793. case xunjiservice.FieldAPIBase:
  47794. m.ResetAPIBase()
  47795. return nil
  47796. case xunjiservice.FieldAPIKey:
  47797. m.ResetAPIKey()
  47798. return nil
  47799. }
  47800. return fmt.Errorf("unknown XunjiService field %s", name)
  47801. }
  47802. // AddedEdges returns all edge names that were set/added in this mutation.
  47803. func (m *XunjiServiceMutation) AddedEdges() []string {
  47804. edges := make([]string, 0, 1)
  47805. if m.agent != nil {
  47806. edges = append(edges, xunjiservice.EdgeAgent)
  47807. }
  47808. return edges
  47809. }
  47810. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47811. // name in this mutation.
  47812. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47813. switch name {
  47814. case xunjiservice.EdgeAgent:
  47815. if id := m.agent; id != nil {
  47816. return []ent.Value{*id}
  47817. }
  47818. }
  47819. return nil
  47820. }
  47821. // RemovedEdges returns all edge names that were removed in this mutation.
  47822. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47823. edges := make([]string, 0, 1)
  47824. return edges
  47825. }
  47826. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47827. // the given name in this mutation.
  47828. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47829. return nil
  47830. }
  47831. // ClearedEdges returns all edge names that were cleared in this mutation.
  47832. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47833. edges := make([]string, 0, 1)
  47834. if m.clearedagent {
  47835. edges = append(edges, xunjiservice.EdgeAgent)
  47836. }
  47837. return edges
  47838. }
  47839. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47840. // was cleared in this mutation.
  47841. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47842. switch name {
  47843. case xunjiservice.EdgeAgent:
  47844. return m.clearedagent
  47845. }
  47846. return false
  47847. }
  47848. // ClearEdge clears the value of the edge with the given name. It returns an error
  47849. // if that edge is not defined in the schema.
  47850. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47851. switch name {
  47852. case xunjiservice.EdgeAgent:
  47853. m.ClearAgent()
  47854. return nil
  47855. }
  47856. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47857. }
  47858. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47859. // It returns an error if the edge is not defined in the schema.
  47860. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47861. switch name {
  47862. case xunjiservice.EdgeAgent:
  47863. m.ResetAgent()
  47864. return nil
  47865. }
  47866. return fmt.Errorf("unknown XunjiService edge %s", name)
  47867. }