mutation.go 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075
  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/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/workexperience"
  44. "wechat-api/ent/wpchatroom"
  45. "wechat-api/ent/wpchatroommember"
  46. "wechat-api/ent/wx"
  47. "wechat-api/ent/wxcard"
  48. "wechat-api/ent/wxcarduser"
  49. "wechat-api/ent/wxcardvisit"
  50. "entgo.io/ent"
  51. "entgo.io/ent/dialect/sql"
  52. )
  53. const (
  54. // Operation types.
  55. OpCreate = ent.OpCreate
  56. OpDelete = ent.OpDelete
  57. OpDeleteOne = ent.OpDeleteOne
  58. OpUpdate = ent.OpUpdate
  59. OpUpdateOne = ent.OpUpdateOne
  60. // Node types.
  61. TypeAgent = "Agent"
  62. TypeAgentBase = "AgentBase"
  63. TypeAliyunAvatar = "AliyunAvatar"
  64. TypeAllocAgent = "AllocAgent"
  65. TypeBatchMsg = "BatchMsg"
  66. TypeCategory = "Category"
  67. TypeChatRecords = "ChatRecords"
  68. TypeChatSession = "ChatSession"
  69. TypeContact = "Contact"
  70. TypeCreditBalance = "CreditBalance"
  71. TypeCreditUsage = "CreditUsage"
  72. TypeEmployee = "Employee"
  73. TypeEmployeeConfig = "EmployeeConfig"
  74. TypeLabel = "Label"
  75. TypeLabelRelationship = "LabelRelationship"
  76. TypeLabelTagging = "LabelTagging"
  77. TypeMessage = "Message"
  78. TypeMessageRecords = "MessageRecords"
  79. TypeMsg = "Msg"
  80. TypePayRecharge = "PayRecharge"
  81. TypeServer = "Server"
  82. TypeSopNode = "SopNode"
  83. TypeSopStage = "SopStage"
  84. TypeSopTask = "SopTask"
  85. TypeToken = "Token"
  86. TypeTutorial = "Tutorial"
  87. TypeUsageDetail = "UsageDetail"
  88. TypeUsageStatisticDay = "UsageStatisticDay"
  89. TypeUsageStatisticHour = "UsageStatisticHour"
  90. TypeUsageStatisticMonth = "UsageStatisticMonth"
  91. TypeUsageTotal = "UsageTotal"
  92. TypeWhatsapp = "Whatsapp"
  93. TypeWorkExperience = "WorkExperience"
  94. TypeWpChatroom = "WpChatroom"
  95. TypeWpChatroomMember = "WpChatroomMember"
  96. TypeWx = "Wx"
  97. TypeWxCard = "WxCard"
  98. TypeWxCardUser = "WxCardUser"
  99. TypeWxCardVisit = "WxCardVisit"
  100. )
  101. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  102. type AgentMutation struct {
  103. config
  104. op Op
  105. typ string
  106. id *uint64
  107. created_at *time.Time
  108. updated_at *time.Time
  109. deleted_at *time.Time
  110. name *string
  111. role *string
  112. status *int
  113. addstatus *int
  114. background *string
  115. examples *string
  116. organization_id *uint64
  117. addorganization_id *int64
  118. dataset_id *string
  119. collection_id *string
  120. clearedFields map[string]struct{}
  121. wx_agent map[uint64]struct{}
  122. removedwx_agent map[uint64]struct{}
  123. clearedwx_agent bool
  124. token_agent map[uint64]struct{}
  125. removedtoken_agent map[uint64]struct{}
  126. clearedtoken_agent bool
  127. wa_agent map[uint64]struct{}
  128. removedwa_agent map[uint64]struct{}
  129. clearedwa_agent bool
  130. done bool
  131. oldValue func(context.Context) (*Agent, error)
  132. predicates []predicate.Agent
  133. }
  134. var _ ent.Mutation = (*AgentMutation)(nil)
  135. // agentOption allows management of the mutation configuration using functional options.
  136. type agentOption func(*AgentMutation)
  137. // newAgentMutation creates new mutation for the Agent entity.
  138. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  139. m := &AgentMutation{
  140. config: c,
  141. op: op,
  142. typ: TypeAgent,
  143. clearedFields: make(map[string]struct{}),
  144. }
  145. for _, opt := range opts {
  146. opt(m)
  147. }
  148. return m
  149. }
  150. // withAgentID sets the ID field of the mutation.
  151. func withAgentID(id uint64) agentOption {
  152. return func(m *AgentMutation) {
  153. var (
  154. err error
  155. once sync.Once
  156. value *Agent
  157. )
  158. m.oldValue = func(ctx context.Context) (*Agent, error) {
  159. once.Do(func() {
  160. if m.done {
  161. err = errors.New("querying old values post mutation is not allowed")
  162. } else {
  163. value, err = m.Client().Agent.Get(ctx, id)
  164. }
  165. })
  166. return value, err
  167. }
  168. m.id = &id
  169. }
  170. }
  171. // withAgent sets the old Agent of the mutation.
  172. func withAgent(node *Agent) agentOption {
  173. return func(m *AgentMutation) {
  174. m.oldValue = func(context.Context) (*Agent, error) {
  175. return node, nil
  176. }
  177. m.id = &node.ID
  178. }
  179. }
  180. // Client returns a new `ent.Client` from the mutation. If the mutation was
  181. // executed in a transaction (ent.Tx), a transactional client is returned.
  182. func (m AgentMutation) Client() *Client {
  183. client := &Client{config: m.config}
  184. client.init()
  185. return client
  186. }
  187. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  188. // it returns an error otherwise.
  189. func (m AgentMutation) Tx() (*Tx, error) {
  190. if _, ok := m.driver.(*txDriver); !ok {
  191. return nil, errors.New("ent: mutation is not running in a transaction")
  192. }
  193. tx := &Tx{config: m.config}
  194. tx.init()
  195. return tx, nil
  196. }
  197. // SetID sets the value of the id field. Note that this
  198. // operation is only accepted on creation of Agent entities.
  199. func (m *AgentMutation) SetID(id uint64) {
  200. m.id = &id
  201. }
  202. // ID returns the ID value in the mutation. Note that the ID is only available
  203. // if it was provided to the builder or after it was returned from the database.
  204. func (m *AgentMutation) ID() (id uint64, exists bool) {
  205. if m.id == nil {
  206. return
  207. }
  208. return *m.id, true
  209. }
  210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  211. // That means, if the mutation is applied within a transaction with an isolation level such
  212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  213. // or updated by the mutation.
  214. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  215. switch {
  216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  217. id, exists := m.ID()
  218. if exists {
  219. return []uint64{id}, nil
  220. }
  221. fallthrough
  222. case m.op.Is(OpUpdate | OpDelete):
  223. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  224. default:
  225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  226. }
  227. }
  228. // SetCreatedAt sets the "created_at" field.
  229. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  230. m.created_at = &t
  231. }
  232. // CreatedAt returns the value of the "created_at" field in the mutation.
  233. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  234. v := m.created_at
  235. if v == nil {
  236. return
  237. }
  238. return *v, true
  239. }
  240. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  241. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  243. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  244. if !m.op.Is(OpUpdateOne) {
  245. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  246. }
  247. if m.id == nil || m.oldValue == nil {
  248. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  249. }
  250. oldValue, err := m.oldValue(ctx)
  251. if err != nil {
  252. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  253. }
  254. return oldValue.CreatedAt, nil
  255. }
  256. // ResetCreatedAt resets all changes to the "created_at" field.
  257. func (m *AgentMutation) ResetCreatedAt() {
  258. m.created_at = nil
  259. }
  260. // SetUpdatedAt sets the "updated_at" field.
  261. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  262. m.updated_at = &t
  263. }
  264. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  265. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  266. v := m.updated_at
  267. if v == nil {
  268. return
  269. }
  270. return *v, true
  271. }
  272. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  273. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  275. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  276. if !m.op.Is(OpUpdateOne) {
  277. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  278. }
  279. if m.id == nil || m.oldValue == nil {
  280. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  281. }
  282. oldValue, err := m.oldValue(ctx)
  283. if err != nil {
  284. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  285. }
  286. return oldValue.UpdatedAt, nil
  287. }
  288. // ResetUpdatedAt resets all changes to the "updated_at" field.
  289. func (m *AgentMutation) ResetUpdatedAt() {
  290. m.updated_at = nil
  291. }
  292. // SetDeletedAt sets the "deleted_at" field.
  293. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  294. m.deleted_at = &t
  295. }
  296. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  297. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  298. v := m.deleted_at
  299. if v == nil {
  300. return
  301. }
  302. return *v, true
  303. }
  304. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  305. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  307. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  308. if !m.op.Is(OpUpdateOne) {
  309. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  310. }
  311. if m.id == nil || m.oldValue == nil {
  312. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  313. }
  314. oldValue, err := m.oldValue(ctx)
  315. if err != nil {
  316. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  317. }
  318. return oldValue.DeletedAt, nil
  319. }
  320. // ClearDeletedAt clears the value of the "deleted_at" field.
  321. func (m *AgentMutation) ClearDeletedAt() {
  322. m.deleted_at = nil
  323. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  324. }
  325. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  326. func (m *AgentMutation) DeletedAtCleared() bool {
  327. _, ok := m.clearedFields[agent.FieldDeletedAt]
  328. return ok
  329. }
  330. // ResetDeletedAt resets all changes to the "deleted_at" field.
  331. func (m *AgentMutation) ResetDeletedAt() {
  332. m.deleted_at = nil
  333. delete(m.clearedFields, agent.FieldDeletedAt)
  334. }
  335. // SetName sets the "name" field.
  336. func (m *AgentMutation) SetName(s string) {
  337. m.name = &s
  338. }
  339. // Name returns the value of the "name" field in the mutation.
  340. func (m *AgentMutation) Name() (r string, exists bool) {
  341. v := m.name
  342. if v == nil {
  343. return
  344. }
  345. return *v, true
  346. }
  347. // OldName returns the old "name" field's value of the Agent entity.
  348. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  350. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  351. if !m.op.Is(OpUpdateOne) {
  352. return v, errors.New("OldName is only allowed on UpdateOne operations")
  353. }
  354. if m.id == nil || m.oldValue == nil {
  355. return v, errors.New("OldName requires an ID field in the mutation")
  356. }
  357. oldValue, err := m.oldValue(ctx)
  358. if err != nil {
  359. return v, fmt.Errorf("querying old value for OldName: %w", err)
  360. }
  361. return oldValue.Name, nil
  362. }
  363. // ResetName resets all changes to the "name" field.
  364. func (m *AgentMutation) ResetName() {
  365. m.name = nil
  366. }
  367. // SetRole sets the "role" field.
  368. func (m *AgentMutation) SetRole(s string) {
  369. m.role = &s
  370. }
  371. // Role returns the value of the "role" field in the mutation.
  372. func (m *AgentMutation) Role() (r string, exists bool) {
  373. v := m.role
  374. if v == nil {
  375. return
  376. }
  377. return *v, true
  378. }
  379. // OldRole returns the old "role" field's value of the Agent entity.
  380. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  382. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  383. if !m.op.Is(OpUpdateOne) {
  384. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  385. }
  386. if m.id == nil || m.oldValue == nil {
  387. return v, errors.New("OldRole requires an ID field in the mutation")
  388. }
  389. oldValue, err := m.oldValue(ctx)
  390. if err != nil {
  391. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  392. }
  393. return oldValue.Role, nil
  394. }
  395. // ResetRole resets all changes to the "role" field.
  396. func (m *AgentMutation) ResetRole() {
  397. m.role = nil
  398. }
  399. // SetStatus sets the "status" field.
  400. func (m *AgentMutation) SetStatus(i int) {
  401. m.status = &i
  402. m.addstatus = nil
  403. }
  404. // Status returns the value of the "status" field in the mutation.
  405. func (m *AgentMutation) Status() (r int, exists bool) {
  406. v := m.status
  407. if v == nil {
  408. return
  409. }
  410. return *v, true
  411. }
  412. // OldStatus returns the old "status" field's value of the Agent entity.
  413. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  415. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  416. if !m.op.Is(OpUpdateOne) {
  417. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  418. }
  419. if m.id == nil || m.oldValue == nil {
  420. return v, errors.New("OldStatus requires an ID field in the mutation")
  421. }
  422. oldValue, err := m.oldValue(ctx)
  423. if err != nil {
  424. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  425. }
  426. return oldValue.Status, nil
  427. }
  428. // AddStatus adds i to the "status" field.
  429. func (m *AgentMutation) AddStatus(i int) {
  430. if m.addstatus != nil {
  431. *m.addstatus += i
  432. } else {
  433. m.addstatus = &i
  434. }
  435. }
  436. // AddedStatus returns the value that was added to the "status" field in this mutation.
  437. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  438. v := m.addstatus
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // ClearStatus clears the value of the "status" field.
  445. func (m *AgentMutation) ClearStatus() {
  446. m.status = nil
  447. m.addstatus = nil
  448. m.clearedFields[agent.FieldStatus] = struct{}{}
  449. }
  450. // StatusCleared returns if the "status" field was cleared in this mutation.
  451. func (m *AgentMutation) StatusCleared() bool {
  452. _, ok := m.clearedFields[agent.FieldStatus]
  453. return ok
  454. }
  455. // ResetStatus resets all changes to the "status" field.
  456. func (m *AgentMutation) ResetStatus() {
  457. m.status = nil
  458. m.addstatus = nil
  459. delete(m.clearedFields, agent.FieldStatus)
  460. }
  461. // SetBackground sets the "background" field.
  462. func (m *AgentMutation) SetBackground(s string) {
  463. m.background = &s
  464. }
  465. // Background returns the value of the "background" field in the mutation.
  466. func (m *AgentMutation) Background() (r string, exists bool) {
  467. v := m.background
  468. if v == nil {
  469. return
  470. }
  471. return *v, true
  472. }
  473. // OldBackground returns the old "background" field's value of the Agent entity.
  474. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  476. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  477. if !m.op.Is(OpUpdateOne) {
  478. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  479. }
  480. if m.id == nil || m.oldValue == nil {
  481. return v, errors.New("OldBackground requires an ID field in the mutation")
  482. }
  483. oldValue, err := m.oldValue(ctx)
  484. if err != nil {
  485. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  486. }
  487. return oldValue.Background, nil
  488. }
  489. // ClearBackground clears the value of the "background" field.
  490. func (m *AgentMutation) ClearBackground() {
  491. m.background = nil
  492. m.clearedFields[agent.FieldBackground] = struct{}{}
  493. }
  494. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  495. func (m *AgentMutation) BackgroundCleared() bool {
  496. _, ok := m.clearedFields[agent.FieldBackground]
  497. return ok
  498. }
  499. // ResetBackground resets all changes to the "background" field.
  500. func (m *AgentMutation) ResetBackground() {
  501. m.background = nil
  502. delete(m.clearedFields, agent.FieldBackground)
  503. }
  504. // SetExamples sets the "examples" field.
  505. func (m *AgentMutation) SetExamples(s string) {
  506. m.examples = &s
  507. }
  508. // Examples returns the value of the "examples" field in the mutation.
  509. func (m *AgentMutation) Examples() (r string, exists bool) {
  510. v := m.examples
  511. if v == nil {
  512. return
  513. }
  514. return *v, true
  515. }
  516. // OldExamples returns the old "examples" field's value of the Agent entity.
  517. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  519. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  520. if !m.op.Is(OpUpdateOne) {
  521. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  522. }
  523. if m.id == nil || m.oldValue == nil {
  524. return v, errors.New("OldExamples requires an ID field in the mutation")
  525. }
  526. oldValue, err := m.oldValue(ctx)
  527. if err != nil {
  528. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  529. }
  530. return oldValue.Examples, nil
  531. }
  532. // ClearExamples clears the value of the "examples" field.
  533. func (m *AgentMutation) ClearExamples() {
  534. m.examples = nil
  535. m.clearedFields[agent.FieldExamples] = struct{}{}
  536. }
  537. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  538. func (m *AgentMutation) ExamplesCleared() bool {
  539. _, ok := m.clearedFields[agent.FieldExamples]
  540. return ok
  541. }
  542. // ResetExamples resets all changes to the "examples" field.
  543. func (m *AgentMutation) ResetExamples() {
  544. m.examples = nil
  545. delete(m.clearedFields, agent.FieldExamples)
  546. }
  547. // SetOrganizationID sets the "organization_id" field.
  548. func (m *AgentMutation) SetOrganizationID(u uint64) {
  549. m.organization_id = &u
  550. m.addorganization_id = nil
  551. }
  552. // OrganizationID returns the value of the "organization_id" field in the mutation.
  553. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  554. v := m.organization_id
  555. if v == nil {
  556. return
  557. }
  558. return *v, true
  559. }
  560. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  561. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  563. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  564. if !m.op.Is(OpUpdateOne) {
  565. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  566. }
  567. if m.id == nil || m.oldValue == nil {
  568. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  569. }
  570. oldValue, err := m.oldValue(ctx)
  571. if err != nil {
  572. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  573. }
  574. return oldValue.OrganizationID, nil
  575. }
  576. // AddOrganizationID adds u to the "organization_id" field.
  577. func (m *AgentMutation) AddOrganizationID(u int64) {
  578. if m.addorganization_id != nil {
  579. *m.addorganization_id += u
  580. } else {
  581. m.addorganization_id = &u
  582. }
  583. }
  584. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  585. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  586. v := m.addorganization_id
  587. if v == nil {
  588. return
  589. }
  590. return *v, true
  591. }
  592. // ResetOrganizationID resets all changes to the "organization_id" field.
  593. func (m *AgentMutation) ResetOrganizationID() {
  594. m.organization_id = nil
  595. m.addorganization_id = nil
  596. }
  597. // SetDatasetID sets the "dataset_id" field.
  598. func (m *AgentMutation) SetDatasetID(s string) {
  599. m.dataset_id = &s
  600. }
  601. // DatasetID returns the value of the "dataset_id" field in the mutation.
  602. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  603. v := m.dataset_id
  604. if v == nil {
  605. return
  606. }
  607. return *v, true
  608. }
  609. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  610. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  612. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  613. if !m.op.Is(OpUpdateOne) {
  614. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  615. }
  616. if m.id == nil || m.oldValue == nil {
  617. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  618. }
  619. oldValue, err := m.oldValue(ctx)
  620. if err != nil {
  621. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  622. }
  623. return oldValue.DatasetID, nil
  624. }
  625. // ResetDatasetID resets all changes to the "dataset_id" field.
  626. func (m *AgentMutation) ResetDatasetID() {
  627. m.dataset_id = nil
  628. }
  629. // SetCollectionID sets the "collection_id" field.
  630. func (m *AgentMutation) SetCollectionID(s string) {
  631. m.collection_id = &s
  632. }
  633. // CollectionID returns the value of the "collection_id" field in the mutation.
  634. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  635. v := m.collection_id
  636. if v == nil {
  637. return
  638. }
  639. return *v, true
  640. }
  641. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  642. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  644. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  645. if !m.op.Is(OpUpdateOne) {
  646. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  647. }
  648. if m.id == nil || m.oldValue == nil {
  649. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  650. }
  651. oldValue, err := m.oldValue(ctx)
  652. if err != nil {
  653. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  654. }
  655. return oldValue.CollectionID, nil
  656. }
  657. // ResetCollectionID resets all changes to the "collection_id" field.
  658. func (m *AgentMutation) ResetCollectionID() {
  659. m.collection_id = nil
  660. }
  661. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  662. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  663. if m.wx_agent == nil {
  664. m.wx_agent = make(map[uint64]struct{})
  665. }
  666. for i := range ids {
  667. m.wx_agent[ids[i]] = struct{}{}
  668. }
  669. }
  670. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  671. func (m *AgentMutation) ClearWxAgent() {
  672. m.clearedwx_agent = true
  673. }
  674. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  675. func (m *AgentMutation) WxAgentCleared() bool {
  676. return m.clearedwx_agent
  677. }
  678. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  679. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  680. if m.removedwx_agent == nil {
  681. m.removedwx_agent = make(map[uint64]struct{})
  682. }
  683. for i := range ids {
  684. delete(m.wx_agent, ids[i])
  685. m.removedwx_agent[ids[i]] = struct{}{}
  686. }
  687. }
  688. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  689. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  690. for id := range m.removedwx_agent {
  691. ids = append(ids, id)
  692. }
  693. return
  694. }
  695. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  696. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  697. for id := range m.wx_agent {
  698. ids = append(ids, id)
  699. }
  700. return
  701. }
  702. // ResetWxAgent resets all changes to the "wx_agent" edge.
  703. func (m *AgentMutation) ResetWxAgent() {
  704. m.wx_agent = nil
  705. m.clearedwx_agent = false
  706. m.removedwx_agent = nil
  707. }
  708. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  709. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  710. if m.token_agent == nil {
  711. m.token_agent = make(map[uint64]struct{})
  712. }
  713. for i := range ids {
  714. m.token_agent[ids[i]] = struct{}{}
  715. }
  716. }
  717. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  718. func (m *AgentMutation) ClearTokenAgent() {
  719. m.clearedtoken_agent = true
  720. }
  721. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  722. func (m *AgentMutation) TokenAgentCleared() bool {
  723. return m.clearedtoken_agent
  724. }
  725. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  726. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  727. if m.removedtoken_agent == nil {
  728. m.removedtoken_agent = make(map[uint64]struct{})
  729. }
  730. for i := range ids {
  731. delete(m.token_agent, ids[i])
  732. m.removedtoken_agent[ids[i]] = struct{}{}
  733. }
  734. }
  735. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  736. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  737. for id := range m.removedtoken_agent {
  738. ids = append(ids, id)
  739. }
  740. return
  741. }
  742. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  743. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  744. for id := range m.token_agent {
  745. ids = append(ids, id)
  746. }
  747. return
  748. }
  749. // ResetTokenAgent resets all changes to the "token_agent" edge.
  750. func (m *AgentMutation) ResetTokenAgent() {
  751. m.token_agent = nil
  752. m.clearedtoken_agent = false
  753. m.removedtoken_agent = nil
  754. }
  755. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  756. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  757. if m.wa_agent == nil {
  758. m.wa_agent = make(map[uint64]struct{})
  759. }
  760. for i := range ids {
  761. m.wa_agent[ids[i]] = struct{}{}
  762. }
  763. }
  764. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  765. func (m *AgentMutation) ClearWaAgent() {
  766. m.clearedwa_agent = true
  767. }
  768. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  769. func (m *AgentMutation) WaAgentCleared() bool {
  770. return m.clearedwa_agent
  771. }
  772. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  773. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  774. if m.removedwa_agent == nil {
  775. m.removedwa_agent = make(map[uint64]struct{})
  776. }
  777. for i := range ids {
  778. delete(m.wa_agent, ids[i])
  779. m.removedwa_agent[ids[i]] = struct{}{}
  780. }
  781. }
  782. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  783. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  784. for id := range m.removedwa_agent {
  785. ids = append(ids, id)
  786. }
  787. return
  788. }
  789. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  790. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  791. for id := range m.wa_agent {
  792. ids = append(ids, id)
  793. }
  794. return
  795. }
  796. // ResetWaAgent resets all changes to the "wa_agent" edge.
  797. func (m *AgentMutation) ResetWaAgent() {
  798. m.wa_agent = nil
  799. m.clearedwa_agent = false
  800. m.removedwa_agent = nil
  801. }
  802. // Where appends a list predicates to the AgentMutation builder.
  803. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  804. m.predicates = append(m.predicates, ps...)
  805. }
  806. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  807. // users can use type-assertion to append predicates that do not depend on any generated package.
  808. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  809. p := make([]predicate.Agent, len(ps))
  810. for i := range ps {
  811. p[i] = ps[i]
  812. }
  813. m.Where(p...)
  814. }
  815. // Op returns the operation name.
  816. func (m *AgentMutation) Op() Op {
  817. return m.op
  818. }
  819. // SetOp allows setting the mutation operation.
  820. func (m *AgentMutation) SetOp(op Op) {
  821. m.op = op
  822. }
  823. // Type returns the node type of this mutation (Agent).
  824. func (m *AgentMutation) Type() string {
  825. return m.typ
  826. }
  827. // Fields returns all fields that were changed during this mutation. Note that in
  828. // order to get all numeric fields that were incremented/decremented, call
  829. // AddedFields().
  830. func (m *AgentMutation) Fields() []string {
  831. fields := make([]string, 0, 11)
  832. if m.created_at != nil {
  833. fields = append(fields, agent.FieldCreatedAt)
  834. }
  835. if m.updated_at != nil {
  836. fields = append(fields, agent.FieldUpdatedAt)
  837. }
  838. if m.deleted_at != nil {
  839. fields = append(fields, agent.FieldDeletedAt)
  840. }
  841. if m.name != nil {
  842. fields = append(fields, agent.FieldName)
  843. }
  844. if m.role != nil {
  845. fields = append(fields, agent.FieldRole)
  846. }
  847. if m.status != nil {
  848. fields = append(fields, agent.FieldStatus)
  849. }
  850. if m.background != nil {
  851. fields = append(fields, agent.FieldBackground)
  852. }
  853. if m.examples != nil {
  854. fields = append(fields, agent.FieldExamples)
  855. }
  856. if m.organization_id != nil {
  857. fields = append(fields, agent.FieldOrganizationID)
  858. }
  859. if m.dataset_id != nil {
  860. fields = append(fields, agent.FieldDatasetID)
  861. }
  862. if m.collection_id != nil {
  863. fields = append(fields, agent.FieldCollectionID)
  864. }
  865. return fields
  866. }
  867. // Field returns the value of a field with the given name. The second boolean
  868. // return value indicates that this field was not set, or was not defined in the
  869. // schema.
  870. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  871. switch name {
  872. case agent.FieldCreatedAt:
  873. return m.CreatedAt()
  874. case agent.FieldUpdatedAt:
  875. return m.UpdatedAt()
  876. case agent.FieldDeletedAt:
  877. return m.DeletedAt()
  878. case agent.FieldName:
  879. return m.Name()
  880. case agent.FieldRole:
  881. return m.Role()
  882. case agent.FieldStatus:
  883. return m.Status()
  884. case agent.FieldBackground:
  885. return m.Background()
  886. case agent.FieldExamples:
  887. return m.Examples()
  888. case agent.FieldOrganizationID:
  889. return m.OrganizationID()
  890. case agent.FieldDatasetID:
  891. return m.DatasetID()
  892. case agent.FieldCollectionID:
  893. return m.CollectionID()
  894. }
  895. return nil, false
  896. }
  897. // OldField returns the old value of the field from the database. An error is
  898. // returned if the mutation operation is not UpdateOne, or the query to the
  899. // database failed.
  900. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  901. switch name {
  902. case agent.FieldCreatedAt:
  903. return m.OldCreatedAt(ctx)
  904. case agent.FieldUpdatedAt:
  905. return m.OldUpdatedAt(ctx)
  906. case agent.FieldDeletedAt:
  907. return m.OldDeletedAt(ctx)
  908. case agent.FieldName:
  909. return m.OldName(ctx)
  910. case agent.FieldRole:
  911. return m.OldRole(ctx)
  912. case agent.FieldStatus:
  913. return m.OldStatus(ctx)
  914. case agent.FieldBackground:
  915. return m.OldBackground(ctx)
  916. case agent.FieldExamples:
  917. return m.OldExamples(ctx)
  918. case agent.FieldOrganizationID:
  919. return m.OldOrganizationID(ctx)
  920. case agent.FieldDatasetID:
  921. return m.OldDatasetID(ctx)
  922. case agent.FieldCollectionID:
  923. return m.OldCollectionID(ctx)
  924. }
  925. return nil, fmt.Errorf("unknown Agent field %s", name)
  926. }
  927. // SetField sets the value of a field with the given name. It returns an error if
  928. // the field is not defined in the schema, or if the type mismatched the field
  929. // type.
  930. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  931. switch name {
  932. case agent.FieldCreatedAt:
  933. v, ok := value.(time.Time)
  934. if !ok {
  935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  936. }
  937. m.SetCreatedAt(v)
  938. return nil
  939. case agent.FieldUpdatedAt:
  940. v, ok := value.(time.Time)
  941. if !ok {
  942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  943. }
  944. m.SetUpdatedAt(v)
  945. return nil
  946. case agent.FieldDeletedAt:
  947. v, ok := value.(time.Time)
  948. if !ok {
  949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  950. }
  951. m.SetDeletedAt(v)
  952. return nil
  953. case agent.FieldName:
  954. v, ok := value.(string)
  955. if !ok {
  956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  957. }
  958. m.SetName(v)
  959. return nil
  960. case agent.FieldRole:
  961. v, ok := value.(string)
  962. if !ok {
  963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  964. }
  965. m.SetRole(v)
  966. return nil
  967. case agent.FieldStatus:
  968. v, ok := value.(int)
  969. if !ok {
  970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  971. }
  972. m.SetStatus(v)
  973. return nil
  974. case agent.FieldBackground:
  975. v, ok := value.(string)
  976. if !ok {
  977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  978. }
  979. m.SetBackground(v)
  980. return nil
  981. case agent.FieldExamples:
  982. v, ok := value.(string)
  983. if !ok {
  984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  985. }
  986. m.SetExamples(v)
  987. return nil
  988. case agent.FieldOrganizationID:
  989. v, ok := value.(uint64)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetOrganizationID(v)
  994. return nil
  995. case agent.FieldDatasetID:
  996. v, ok := value.(string)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetDatasetID(v)
  1001. return nil
  1002. case agent.FieldCollectionID:
  1003. v, ok := value.(string)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetCollectionID(v)
  1008. return nil
  1009. }
  1010. return fmt.Errorf("unknown Agent field %s", name)
  1011. }
  1012. // AddedFields returns all numeric fields that were incremented/decremented during
  1013. // this mutation.
  1014. func (m *AgentMutation) AddedFields() []string {
  1015. var fields []string
  1016. if m.addstatus != nil {
  1017. fields = append(fields, agent.FieldStatus)
  1018. }
  1019. if m.addorganization_id != nil {
  1020. fields = append(fields, agent.FieldOrganizationID)
  1021. }
  1022. return fields
  1023. }
  1024. // AddedField returns the numeric value that was incremented/decremented on a field
  1025. // with the given name. The second boolean return value indicates that this field
  1026. // was not set, or was not defined in the schema.
  1027. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1028. switch name {
  1029. case agent.FieldStatus:
  1030. return m.AddedStatus()
  1031. case agent.FieldOrganizationID:
  1032. return m.AddedOrganizationID()
  1033. }
  1034. return nil, false
  1035. }
  1036. // AddField adds the value to the field with the given name. It returns an error if
  1037. // the field is not defined in the schema, or if the type mismatched the field
  1038. // type.
  1039. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1040. switch name {
  1041. case agent.FieldStatus:
  1042. v, ok := value.(int)
  1043. if !ok {
  1044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1045. }
  1046. m.AddStatus(v)
  1047. return nil
  1048. case agent.FieldOrganizationID:
  1049. v, ok := value.(int64)
  1050. if !ok {
  1051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1052. }
  1053. m.AddOrganizationID(v)
  1054. return nil
  1055. }
  1056. return fmt.Errorf("unknown Agent numeric field %s", name)
  1057. }
  1058. // ClearedFields returns all nullable fields that were cleared during this
  1059. // mutation.
  1060. func (m *AgentMutation) ClearedFields() []string {
  1061. var fields []string
  1062. if m.FieldCleared(agent.FieldDeletedAt) {
  1063. fields = append(fields, agent.FieldDeletedAt)
  1064. }
  1065. if m.FieldCleared(agent.FieldStatus) {
  1066. fields = append(fields, agent.FieldStatus)
  1067. }
  1068. if m.FieldCleared(agent.FieldBackground) {
  1069. fields = append(fields, agent.FieldBackground)
  1070. }
  1071. if m.FieldCleared(agent.FieldExamples) {
  1072. fields = append(fields, agent.FieldExamples)
  1073. }
  1074. return fields
  1075. }
  1076. // FieldCleared returns a boolean indicating if a field with the given name was
  1077. // cleared in this mutation.
  1078. func (m *AgentMutation) FieldCleared(name string) bool {
  1079. _, ok := m.clearedFields[name]
  1080. return ok
  1081. }
  1082. // ClearField clears the value of the field with the given name. It returns an
  1083. // error if the field is not defined in the schema.
  1084. func (m *AgentMutation) ClearField(name string) error {
  1085. switch name {
  1086. case agent.FieldDeletedAt:
  1087. m.ClearDeletedAt()
  1088. return nil
  1089. case agent.FieldStatus:
  1090. m.ClearStatus()
  1091. return nil
  1092. case agent.FieldBackground:
  1093. m.ClearBackground()
  1094. return nil
  1095. case agent.FieldExamples:
  1096. m.ClearExamples()
  1097. return nil
  1098. }
  1099. return fmt.Errorf("unknown Agent nullable field %s", name)
  1100. }
  1101. // ResetField resets all changes in the mutation for the field with the given name.
  1102. // It returns an error if the field is not defined in the schema.
  1103. func (m *AgentMutation) ResetField(name string) error {
  1104. switch name {
  1105. case agent.FieldCreatedAt:
  1106. m.ResetCreatedAt()
  1107. return nil
  1108. case agent.FieldUpdatedAt:
  1109. m.ResetUpdatedAt()
  1110. return nil
  1111. case agent.FieldDeletedAt:
  1112. m.ResetDeletedAt()
  1113. return nil
  1114. case agent.FieldName:
  1115. m.ResetName()
  1116. return nil
  1117. case agent.FieldRole:
  1118. m.ResetRole()
  1119. return nil
  1120. case agent.FieldStatus:
  1121. m.ResetStatus()
  1122. return nil
  1123. case agent.FieldBackground:
  1124. m.ResetBackground()
  1125. return nil
  1126. case agent.FieldExamples:
  1127. m.ResetExamples()
  1128. return nil
  1129. case agent.FieldOrganizationID:
  1130. m.ResetOrganizationID()
  1131. return nil
  1132. case agent.FieldDatasetID:
  1133. m.ResetDatasetID()
  1134. return nil
  1135. case agent.FieldCollectionID:
  1136. m.ResetCollectionID()
  1137. return nil
  1138. }
  1139. return fmt.Errorf("unknown Agent field %s", name)
  1140. }
  1141. // AddedEdges returns all edge names that were set/added in this mutation.
  1142. func (m *AgentMutation) AddedEdges() []string {
  1143. edges := make([]string, 0, 3)
  1144. if m.wx_agent != nil {
  1145. edges = append(edges, agent.EdgeWxAgent)
  1146. }
  1147. if m.token_agent != nil {
  1148. edges = append(edges, agent.EdgeTokenAgent)
  1149. }
  1150. if m.wa_agent != nil {
  1151. edges = append(edges, agent.EdgeWaAgent)
  1152. }
  1153. return edges
  1154. }
  1155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1156. // name in this mutation.
  1157. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1158. switch name {
  1159. case agent.EdgeWxAgent:
  1160. ids := make([]ent.Value, 0, len(m.wx_agent))
  1161. for id := range m.wx_agent {
  1162. ids = append(ids, id)
  1163. }
  1164. return ids
  1165. case agent.EdgeTokenAgent:
  1166. ids := make([]ent.Value, 0, len(m.token_agent))
  1167. for id := range m.token_agent {
  1168. ids = append(ids, id)
  1169. }
  1170. return ids
  1171. case agent.EdgeWaAgent:
  1172. ids := make([]ent.Value, 0, len(m.wa_agent))
  1173. for id := range m.wa_agent {
  1174. ids = append(ids, id)
  1175. }
  1176. return ids
  1177. }
  1178. return nil
  1179. }
  1180. // RemovedEdges returns all edge names that were removed in this mutation.
  1181. func (m *AgentMutation) RemovedEdges() []string {
  1182. edges := make([]string, 0, 3)
  1183. if m.removedwx_agent != nil {
  1184. edges = append(edges, agent.EdgeWxAgent)
  1185. }
  1186. if m.removedtoken_agent != nil {
  1187. edges = append(edges, agent.EdgeTokenAgent)
  1188. }
  1189. if m.removedwa_agent != nil {
  1190. edges = append(edges, agent.EdgeWaAgent)
  1191. }
  1192. return edges
  1193. }
  1194. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1195. // the given name in this mutation.
  1196. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1197. switch name {
  1198. case agent.EdgeWxAgent:
  1199. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1200. for id := range m.removedwx_agent {
  1201. ids = append(ids, id)
  1202. }
  1203. return ids
  1204. case agent.EdgeTokenAgent:
  1205. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1206. for id := range m.removedtoken_agent {
  1207. ids = append(ids, id)
  1208. }
  1209. return ids
  1210. case agent.EdgeWaAgent:
  1211. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1212. for id := range m.removedwa_agent {
  1213. ids = append(ids, id)
  1214. }
  1215. return ids
  1216. }
  1217. return nil
  1218. }
  1219. // ClearedEdges returns all edge names that were cleared in this mutation.
  1220. func (m *AgentMutation) ClearedEdges() []string {
  1221. edges := make([]string, 0, 3)
  1222. if m.clearedwx_agent {
  1223. edges = append(edges, agent.EdgeWxAgent)
  1224. }
  1225. if m.clearedtoken_agent {
  1226. edges = append(edges, agent.EdgeTokenAgent)
  1227. }
  1228. if m.clearedwa_agent {
  1229. edges = append(edges, agent.EdgeWaAgent)
  1230. }
  1231. return edges
  1232. }
  1233. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1234. // was cleared in this mutation.
  1235. func (m *AgentMutation) EdgeCleared(name string) bool {
  1236. switch name {
  1237. case agent.EdgeWxAgent:
  1238. return m.clearedwx_agent
  1239. case agent.EdgeTokenAgent:
  1240. return m.clearedtoken_agent
  1241. case agent.EdgeWaAgent:
  1242. return m.clearedwa_agent
  1243. }
  1244. return false
  1245. }
  1246. // ClearEdge clears the value of the edge with the given name. It returns an error
  1247. // if that edge is not defined in the schema.
  1248. func (m *AgentMutation) ClearEdge(name string) error {
  1249. switch name {
  1250. }
  1251. return fmt.Errorf("unknown Agent unique edge %s", name)
  1252. }
  1253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1254. // It returns an error if the edge is not defined in the schema.
  1255. func (m *AgentMutation) ResetEdge(name string) error {
  1256. switch name {
  1257. case agent.EdgeWxAgent:
  1258. m.ResetWxAgent()
  1259. return nil
  1260. case agent.EdgeTokenAgent:
  1261. m.ResetTokenAgent()
  1262. return nil
  1263. case agent.EdgeWaAgent:
  1264. m.ResetWaAgent()
  1265. return nil
  1266. }
  1267. return fmt.Errorf("unknown Agent edge %s", name)
  1268. }
  1269. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1270. type AgentBaseMutation struct {
  1271. config
  1272. op Op
  1273. typ string
  1274. id *string
  1275. q *string
  1276. a *string
  1277. chunk_index *uint64
  1278. addchunk_index *int64
  1279. indexes *[]string
  1280. appendindexes []string
  1281. dataset_id *string
  1282. collection_id *string
  1283. source_name *string
  1284. can_write *[]bool
  1285. appendcan_write []bool
  1286. is_owner *[]bool
  1287. appendis_owner []bool
  1288. clearedFields map[string]struct{}
  1289. wx_agent map[uint64]struct{}
  1290. removedwx_agent map[uint64]struct{}
  1291. clearedwx_agent bool
  1292. done bool
  1293. oldValue func(context.Context) (*AgentBase, error)
  1294. predicates []predicate.AgentBase
  1295. }
  1296. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1297. // agentbaseOption allows management of the mutation configuration using functional options.
  1298. type agentbaseOption func(*AgentBaseMutation)
  1299. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1300. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1301. m := &AgentBaseMutation{
  1302. config: c,
  1303. op: op,
  1304. typ: TypeAgentBase,
  1305. clearedFields: make(map[string]struct{}),
  1306. }
  1307. for _, opt := range opts {
  1308. opt(m)
  1309. }
  1310. return m
  1311. }
  1312. // withAgentBaseID sets the ID field of the mutation.
  1313. func withAgentBaseID(id string) agentbaseOption {
  1314. return func(m *AgentBaseMutation) {
  1315. var (
  1316. err error
  1317. once sync.Once
  1318. value *AgentBase
  1319. )
  1320. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1321. once.Do(func() {
  1322. if m.done {
  1323. err = errors.New("querying old values post mutation is not allowed")
  1324. } else {
  1325. value, err = m.Client().AgentBase.Get(ctx, id)
  1326. }
  1327. })
  1328. return value, err
  1329. }
  1330. m.id = &id
  1331. }
  1332. }
  1333. // withAgentBase sets the old AgentBase of the mutation.
  1334. func withAgentBase(node *AgentBase) agentbaseOption {
  1335. return func(m *AgentBaseMutation) {
  1336. m.oldValue = func(context.Context) (*AgentBase, error) {
  1337. return node, nil
  1338. }
  1339. m.id = &node.ID
  1340. }
  1341. }
  1342. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1343. // executed in a transaction (ent.Tx), a transactional client is returned.
  1344. func (m AgentBaseMutation) Client() *Client {
  1345. client := &Client{config: m.config}
  1346. client.init()
  1347. return client
  1348. }
  1349. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1350. // it returns an error otherwise.
  1351. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1352. if _, ok := m.driver.(*txDriver); !ok {
  1353. return nil, errors.New("ent: mutation is not running in a transaction")
  1354. }
  1355. tx := &Tx{config: m.config}
  1356. tx.init()
  1357. return tx, nil
  1358. }
  1359. // SetID sets the value of the id field. Note that this
  1360. // operation is only accepted on creation of AgentBase entities.
  1361. func (m *AgentBaseMutation) SetID(id string) {
  1362. m.id = &id
  1363. }
  1364. // ID returns the ID value in the mutation. Note that the ID is only available
  1365. // if it was provided to the builder or after it was returned from the database.
  1366. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1367. if m.id == nil {
  1368. return
  1369. }
  1370. return *m.id, true
  1371. }
  1372. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1373. // That means, if the mutation is applied within a transaction with an isolation level such
  1374. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1375. // or updated by the mutation.
  1376. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1377. switch {
  1378. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1379. id, exists := m.ID()
  1380. if exists {
  1381. return []string{id}, nil
  1382. }
  1383. fallthrough
  1384. case m.op.Is(OpUpdate | OpDelete):
  1385. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1386. default:
  1387. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1388. }
  1389. }
  1390. // SetQ sets the "q" field.
  1391. func (m *AgentBaseMutation) SetQ(s string) {
  1392. m.q = &s
  1393. }
  1394. // Q returns the value of the "q" field in the mutation.
  1395. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1396. v := m.q
  1397. if v == nil {
  1398. return
  1399. }
  1400. return *v, true
  1401. }
  1402. // OldQ returns the old "q" field's value of the AgentBase entity.
  1403. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1405. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1406. if !m.op.Is(OpUpdateOne) {
  1407. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1408. }
  1409. if m.id == nil || m.oldValue == nil {
  1410. return v, errors.New("OldQ requires an ID field in the mutation")
  1411. }
  1412. oldValue, err := m.oldValue(ctx)
  1413. if err != nil {
  1414. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1415. }
  1416. return oldValue.Q, nil
  1417. }
  1418. // ClearQ clears the value of the "q" field.
  1419. func (m *AgentBaseMutation) ClearQ() {
  1420. m.q = nil
  1421. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1422. }
  1423. // QCleared returns if the "q" field was cleared in this mutation.
  1424. func (m *AgentBaseMutation) QCleared() bool {
  1425. _, ok := m.clearedFields[agentbase.FieldQ]
  1426. return ok
  1427. }
  1428. // ResetQ resets all changes to the "q" field.
  1429. func (m *AgentBaseMutation) ResetQ() {
  1430. m.q = nil
  1431. delete(m.clearedFields, agentbase.FieldQ)
  1432. }
  1433. // SetA sets the "a" field.
  1434. func (m *AgentBaseMutation) SetA(s string) {
  1435. m.a = &s
  1436. }
  1437. // A returns the value of the "a" field in the mutation.
  1438. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1439. v := m.a
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // OldA returns the old "a" field's value of the AgentBase entity.
  1446. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1448. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1449. if !m.op.Is(OpUpdateOne) {
  1450. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1451. }
  1452. if m.id == nil || m.oldValue == nil {
  1453. return v, errors.New("OldA requires an ID field in the mutation")
  1454. }
  1455. oldValue, err := m.oldValue(ctx)
  1456. if err != nil {
  1457. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1458. }
  1459. return oldValue.A, nil
  1460. }
  1461. // ClearA clears the value of the "a" field.
  1462. func (m *AgentBaseMutation) ClearA() {
  1463. m.a = nil
  1464. m.clearedFields[agentbase.FieldA] = struct{}{}
  1465. }
  1466. // ACleared returns if the "a" field was cleared in this mutation.
  1467. func (m *AgentBaseMutation) ACleared() bool {
  1468. _, ok := m.clearedFields[agentbase.FieldA]
  1469. return ok
  1470. }
  1471. // ResetA resets all changes to the "a" field.
  1472. func (m *AgentBaseMutation) ResetA() {
  1473. m.a = nil
  1474. delete(m.clearedFields, agentbase.FieldA)
  1475. }
  1476. // SetChunkIndex sets the "chunk_index" field.
  1477. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1478. m.chunk_index = &u
  1479. m.addchunk_index = nil
  1480. }
  1481. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1482. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1483. v := m.chunk_index
  1484. if v == nil {
  1485. return
  1486. }
  1487. return *v, true
  1488. }
  1489. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1490. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1492. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1493. if !m.op.Is(OpUpdateOne) {
  1494. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1495. }
  1496. if m.id == nil || m.oldValue == nil {
  1497. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1498. }
  1499. oldValue, err := m.oldValue(ctx)
  1500. if err != nil {
  1501. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1502. }
  1503. return oldValue.ChunkIndex, nil
  1504. }
  1505. // AddChunkIndex adds u to the "chunk_index" field.
  1506. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1507. if m.addchunk_index != nil {
  1508. *m.addchunk_index += u
  1509. } else {
  1510. m.addchunk_index = &u
  1511. }
  1512. }
  1513. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1514. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1515. v := m.addchunk_index
  1516. if v == nil {
  1517. return
  1518. }
  1519. return *v, true
  1520. }
  1521. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1522. func (m *AgentBaseMutation) ResetChunkIndex() {
  1523. m.chunk_index = nil
  1524. m.addchunk_index = nil
  1525. }
  1526. // SetIndexes sets the "indexes" field.
  1527. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1528. m.indexes = &s
  1529. m.appendindexes = nil
  1530. }
  1531. // Indexes returns the value of the "indexes" field in the mutation.
  1532. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1533. v := m.indexes
  1534. if v == nil {
  1535. return
  1536. }
  1537. return *v, true
  1538. }
  1539. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1540. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1542. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1543. if !m.op.Is(OpUpdateOne) {
  1544. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1545. }
  1546. if m.id == nil || m.oldValue == nil {
  1547. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1548. }
  1549. oldValue, err := m.oldValue(ctx)
  1550. if err != nil {
  1551. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1552. }
  1553. return oldValue.Indexes, nil
  1554. }
  1555. // AppendIndexes adds s to the "indexes" field.
  1556. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1557. m.appendindexes = append(m.appendindexes, s...)
  1558. }
  1559. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1560. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1561. if len(m.appendindexes) == 0 {
  1562. return nil, false
  1563. }
  1564. return m.appendindexes, true
  1565. }
  1566. // ClearIndexes clears the value of the "indexes" field.
  1567. func (m *AgentBaseMutation) ClearIndexes() {
  1568. m.indexes = nil
  1569. m.appendindexes = nil
  1570. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1571. }
  1572. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1573. func (m *AgentBaseMutation) IndexesCleared() bool {
  1574. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1575. return ok
  1576. }
  1577. // ResetIndexes resets all changes to the "indexes" field.
  1578. func (m *AgentBaseMutation) ResetIndexes() {
  1579. m.indexes = nil
  1580. m.appendindexes = nil
  1581. delete(m.clearedFields, agentbase.FieldIndexes)
  1582. }
  1583. // SetDatasetID sets the "dataset_id" field.
  1584. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1585. m.dataset_id = &s
  1586. }
  1587. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1588. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1589. v := m.dataset_id
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1596. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1598. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1599. if !m.op.Is(OpUpdateOne) {
  1600. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1601. }
  1602. if m.id == nil || m.oldValue == nil {
  1603. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1604. }
  1605. oldValue, err := m.oldValue(ctx)
  1606. if err != nil {
  1607. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1608. }
  1609. return oldValue.DatasetID, nil
  1610. }
  1611. // ClearDatasetID clears the value of the "dataset_id" field.
  1612. func (m *AgentBaseMutation) ClearDatasetID() {
  1613. m.dataset_id = nil
  1614. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1615. }
  1616. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1617. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1618. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1619. return ok
  1620. }
  1621. // ResetDatasetID resets all changes to the "dataset_id" field.
  1622. func (m *AgentBaseMutation) ResetDatasetID() {
  1623. m.dataset_id = nil
  1624. delete(m.clearedFields, agentbase.FieldDatasetID)
  1625. }
  1626. // SetCollectionID sets the "collection_id" field.
  1627. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1628. m.collection_id = &s
  1629. }
  1630. // CollectionID returns the value of the "collection_id" field in the mutation.
  1631. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1632. v := m.collection_id
  1633. if v == nil {
  1634. return
  1635. }
  1636. return *v, true
  1637. }
  1638. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1639. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1641. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1642. if !m.op.Is(OpUpdateOne) {
  1643. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1644. }
  1645. if m.id == nil || m.oldValue == nil {
  1646. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1647. }
  1648. oldValue, err := m.oldValue(ctx)
  1649. if err != nil {
  1650. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1651. }
  1652. return oldValue.CollectionID, nil
  1653. }
  1654. // ClearCollectionID clears the value of the "collection_id" field.
  1655. func (m *AgentBaseMutation) ClearCollectionID() {
  1656. m.collection_id = nil
  1657. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1658. }
  1659. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1660. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1661. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1662. return ok
  1663. }
  1664. // ResetCollectionID resets all changes to the "collection_id" field.
  1665. func (m *AgentBaseMutation) ResetCollectionID() {
  1666. m.collection_id = nil
  1667. delete(m.clearedFields, agentbase.FieldCollectionID)
  1668. }
  1669. // SetSourceName sets the "source_name" field.
  1670. func (m *AgentBaseMutation) SetSourceName(s string) {
  1671. m.source_name = &s
  1672. }
  1673. // SourceName returns the value of the "source_name" field in the mutation.
  1674. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1675. v := m.source_name
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1682. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1684. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1685. if !m.op.Is(OpUpdateOne) {
  1686. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1687. }
  1688. if m.id == nil || m.oldValue == nil {
  1689. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1690. }
  1691. oldValue, err := m.oldValue(ctx)
  1692. if err != nil {
  1693. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1694. }
  1695. return oldValue.SourceName, nil
  1696. }
  1697. // ClearSourceName clears the value of the "source_name" field.
  1698. func (m *AgentBaseMutation) ClearSourceName() {
  1699. m.source_name = nil
  1700. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1701. }
  1702. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1703. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1704. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1705. return ok
  1706. }
  1707. // ResetSourceName resets all changes to the "source_name" field.
  1708. func (m *AgentBaseMutation) ResetSourceName() {
  1709. m.source_name = nil
  1710. delete(m.clearedFields, agentbase.FieldSourceName)
  1711. }
  1712. // SetCanWrite sets the "can_write" field.
  1713. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1714. m.can_write = &b
  1715. m.appendcan_write = nil
  1716. }
  1717. // CanWrite returns the value of the "can_write" field in the mutation.
  1718. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1719. v := m.can_write
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1726. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1738. }
  1739. return oldValue.CanWrite, nil
  1740. }
  1741. // AppendCanWrite adds b to the "can_write" field.
  1742. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1743. m.appendcan_write = append(m.appendcan_write, b...)
  1744. }
  1745. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1746. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1747. if len(m.appendcan_write) == 0 {
  1748. return nil, false
  1749. }
  1750. return m.appendcan_write, true
  1751. }
  1752. // ClearCanWrite clears the value of the "can_write" field.
  1753. func (m *AgentBaseMutation) ClearCanWrite() {
  1754. m.can_write = nil
  1755. m.appendcan_write = nil
  1756. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1757. }
  1758. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1759. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1760. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1761. return ok
  1762. }
  1763. // ResetCanWrite resets all changes to the "can_write" field.
  1764. func (m *AgentBaseMutation) ResetCanWrite() {
  1765. m.can_write = nil
  1766. m.appendcan_write = nil
  1767. delete(m.clearedFields, agentbase.FieldCanWrite)
  1768. }
  1769. // SetIsOwner sets the "is_owner" field.
  1770. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1771. m.is_owner = &b
  1772. m.appendis_owner = nil
  1773. }
  1774. // IsOwner returns the value of the "is_owner" field in the mutation.
  1775. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1776. v := m.is_owner
  1777. if v == nil {
  1778. return
  1779. }
  1780. return *v, true
  1781. }
  1782. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1783. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1785. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1786. if !m.op.Is(OpUpdateOne) {
  1787. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1788. }
  1789. if m.id == nil || m.oldValue == nil {
  1790. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1791. }
  1792. oldValue, err := m.oldValue(ctx)
  1793. if err != nil {
  1794. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1795. }
  1796. return oldValue.IsOwner, nil
  1797. }
  1798. // AppendIsOwner adds b to the "is_owner" field.
  1799. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1800. m.appendis_owner = append(m.appendis_owner, b...)
  1801. }
  1802. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1803. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1804. if len(m.appendis_owner) == 0 {
  1805. return nil, false
  1806. }
  1807. return m.appendis_owner, true
  1808. }
  1809. // ClearIsOwner clears the value of the "is_owner" field.
  1810. func (m *AgentBaseMutation) ClearIsOwner() {
  1811. m.is_owner = nil
  1812. m.appendis_owner = nil
  1813. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1814. }
  1815. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1816. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1817. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1818. return ok
  1819. }
  1820. // ResetIsOwner resets all changes to the "is_owner" field.
  1821. func (m *AgentBaseMutation) ResetIsOwner() {
  1822. m.is_owner = nil
  1823. m.appendis_owner = nil
  1824. delete(m.clearedFields, agentbase.FieldIsOwner)
  1825. }
  1826. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1827. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1828. if m.wx_agent == nil {
  1829. m.wx_agent = make(map[uint64]struct{})
  1830. }
  1831. for i := range ids {
  1832. m.wx_agent[ids[i]] = struct{}{}
  1833. }
  1834. }
  1835. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1836. func (m *AgentBaseMutation) ClearWxAgent() {
  1837. m.clearedwx_agent = true
  1838. }
  1839. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1840. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1841. return m.clearedwx_agent
  1842. }
  1843. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1844. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1845. if m.removedwx_agent == nil {
  1846. m.removedwx_agent = make(map[uint64]struct{})
  1847. }
  1848. for i := range ids {
  1849. delete(m.wx_agent, ids[i])
  1850. m.removedwx_agent[ids[i]] = struct{}{}
  1851. }
  1852. }
  1853. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1854. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1855. for id := range m.removedwx_agent {
  1856. ids = append(ids, id)
  1857. }
  1858. return
  1859. }
  1860. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1861. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1862. for id := range m.wx_agent {
  1863. ids = append(ids, id)
  1864. }
  1865. return
  1866. }
  1867. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1868. func (m *AgentBaseMutation) ResetWxAgent() {
  1869. m.wx_agent = nil
  1870. m.clearedwx_agent = false
  1871. m.removedwx_agent = nil
  1872. }
  1873. // Where appends a list predicates to the AgentBaseMutation builder.
  1874. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1875. m.predicates = append(m.predicates, ps...)
  1876. }
  1877. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1878. // users can use type-assertion to append predicates that do not depend on any generated package.
  1879. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1880. p := make([]predicate.AgentBase, len(ps))
  1881. for i := range ps {
  1882. p[i] = ps[i]
  1883. }
  1884. m.Where(p...)
  1885. }
  1886. // Op returns the operation name.
  1887. func (m *AgentBaseMutation) Op() Op {
  1888. return m.op
  1889. }
  1890. // SetOp allows setting the mutation operation.
  1891. func (m *AgentBaseMutation) SetOp(op Op) {
  1892. m.op = op
  1893. }
  1894. // Type returns the node type of this mutation (AgentBase).
  1895. func (m *AgentBaseMutation) Type() string {
  1896. return m.typ
  1897. }
  1898. // Fields returns all fields that were changed during this mutation. Note that in
  1899. // order to get all numeric fields that were incremented/decremented, call
  1900. // AddedFields().
  1901. func (m *AgentBaseMutation) Fields() []string {
  1902. fields := make([]string, 0, 9)
  1903. if m.q != nil {
  1904. fields = append(fields, agentbase.FieldQ)
  1905. }
  1906. if m.a != nil {
  1907. fields = append(fields, agentbase.FieldA)
  1908. }
  1909. if m.chunk_index != nil {
  1910. fields = append(fields, agentbase.FieldChunkIndex)
  1911. }
  1912. if m.indexes != nil {
  1913. fields = append(fields, agentbase.FieldIndexes)
  1914. }
  1915. if m.dataset_id != nil {
  1916. fields = append(fields, agentbase.FieldDatasetID)
  1917. }
  1918. if m.collection_id != nil {
  1919. fields = append(fields, agentbase.FieldCollectionID)
  1920. }
  1921. if m.source_name != nil {
  1922. fields = append(fields, agentbase.FieldSourceName)
  1923. }
  1924. if m.can_write != nil {
  1925. fields = append(fields, agentbase.FieldCanWrite)
  1926. }
  1927. if m.is_owner != nil {
  1928. fields = append(fields, agentbase.FieldIsOwner)
  1929. }
  1930. return fields
  1931. }
  1932. // Field returns the value of a field with the given name. The second boolean
  1933. // return value indicates that this field was not set, or was not defined in the
  1934. // schema.
  1935. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1936. switch name {
  1937. case agentbase.FieldQ:
  1938. return m.Q()
  1939. case agentbase.FieldA:
  1940. return m.A()
  1941. case agentbase.FieldChunkIndex:
  1942. return m.ChunkIndex()
  1943. case agentbase.FieldIndexes:
  1944. return m.Indexes()
  1945. case agentbase.FieldDatasetID:
  1946. return m.DatasetID()
  1947. case agentbase.FieldCollectionID:
  1948. return m.CollectionID()
  1949. case agentbase.FieldSourceName:
  1950. return m.SourceName()
  1951. case agentbase.FieldCanWrite:
  1952. return m.CanWrite()
  1953. case agentbase.FieldIsOwner:
  1954. return m.IsOwner()
  1955. }
  1956. return nil, false
  1957. }
  1958. // OldField returns the old value of the field from the database. An error is
  1959. // returned if the mutation operation is not UpdateOne, or the query to the
  1960. // database failed.
  1961. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1962. switch name {
  1963. case agentbase.FieldQ:
  1964. return m.OldQ(ctx)
  1965. case agentbase.FieldA:
  1966. return m.OldA(ctx)
  1967. case agentbase.FieldChunkIndex:
  1968. return m.OldChunkIndex(ctx)
  1969. case agentbase.FieldIndexes:
  1970. return m.OldIndexes(ctx)
  1971. case agentbase.FieldDatasetID:
  1972. return m.OldDatasetID(ctx)
  1973. case agentbase.FieldCollectionID:
  1974. return m.OldCollectionID(ctx)
  1975. case agentbase.FieldSourceName:
  1976. return m.OldSourceName(ctx)
  1977. case agentbase.FieldCanWrite:
  1978. return m.OldCanWrite(ctx)
  1979. case agentbase.FieldIsOwner:
  1980. return m.OldIsOwner(ctx)
  1981. }
  1982. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1983. }
  1984. // SetField sets the value of a field with the given name. It returns an error if
  1985. // the field is not defined in the schema, or if the type mismatched the field
  1986. // type.
  1987. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1988. switch name {
  1989. case agentbase.FieldQ:
  1990. v, ok := value.(string)
  1991. if !ok {
  1992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1993. }
  1994. m.SetQ(v)
  1995. return nil
  1996. case agentbase.FieldA:
  1997. v, ok := value.(string)
  1998. if !ok {
  1999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2000. }
  2001. m.SetA(v)
  2002. return nil
  2003. case agentbase.FieldChunkIndex:
  2004. v, ok := value.(uint64)
  2005. if !ok {
  2006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2007. }
  2008. m.SetChunkIndex(v)
  2009. return nil
  2010. case agentbase.FieldIndexes:
  2011. v, ok := value.([]string)
  2012. if !ok {
  2013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2014. }
  2015. m.SetIndexes(v)
  2016. return nil
  2017. case agentbase.FieldDatasetID:
  2018. v, ok := value.(string)
  2019. if !ok {
  2020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2021. }
  2022. m.SetDatasetID(v)
  2023. return nil
  2024. case agentbase.FieldCollectionID:
  2025. v, ok := value.(string)
  2026. if !ok {
  2027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2028. }
  2029. m.SetCollectionID(v)
  2030. return nil
  2031. case agentbase.FieldSourceName:
  2032. v, ok := value.(string)
  2033. if !ok {
  2034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2035. }
  2036. m.SetSourceName(v)
  2037. return nil
  2038. case agentbase.FieldCanWrite:
  2039. v, ok := value.([]bool)
  2040. if !ok {
  2041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2042. }
  2043. m.SetCanWrite(v)
  2044. return nil
  2045. case agentbase.FieldIsOwner:
  2046. v, ok := value.([]bool)
  2047. if !ok {
  2048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2049. }
  2050. m.SetIsOwner(v)
  2051. return nil
  2052. }
  2053. return fmt.Errorf("unknown AgentBase field %s", name)
  2054. }
  2055. // AddedFields returns all numeric fields that were incremented/decremented during
  2056. // this mutation.
  2057. func (m *AgentBaseMutation) AddedFields() []string {
  2058. var fields []string
  2059. if m.addchunk_index != nil {
  2060. fields = append(fields, agentbase.FieldChunkIndex)
  2061. }
  2062. return fields
  2063. }
  2064. // AddedField returns the numeric value that was incremented/decremented on a field
  2065. // with the given name. The second boolean return value indicates that this field
  2066. // was not set, or was not defined in the schema.
  2067. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2068. switch name {
  2069. case agentbase.FieldChunkIndex:
  2070. return m.AddedChunkIndex()
  2071. }
  2072. return nil, false
  2073. }
  2074. // AddField adds the value to the field with the given name. It returns an error if
  2075. // the field is not defined in the schema, or if the type mismatched the field
  2076. // type.
  2077. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2078. switch name {
  2079. case agentbase.FieldChunkIndex:
  2080. v, ok := value.(int64)
  2081. if !ok {
  2082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2083. }
  2084. m.AddChunkIndex(v)
  2085. return nil
  2086. }
  2087. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2088. }
  2089. // ClearedFields returns all nullable fields that were cleared during this
  2090. // mutation.
  2091. func (m *AgentBaseMutation) ClearedFields() []string {
  2092. var fields []string
  2093. if m.FieldCleared(agentbase.FieldQ) {
  2094. fields = append(fields, agentbase.FieldQ)
  2095. }
  2096. if m.FieldCleared(agentbase.FieldA) {
  2097. fields = append(fields, agentbase.FieldA)
  2098. }
  2099. if m.FieldCleared(agentbase.FieldIndexes) {
  2100. fields = append(fields, agentbase.FieldIndexes)
  2101. }
  2102. if m.FieldCleared(agentbase.FieldDatasetID) {
  2103. fields = append(fields, agentbase.FieldDatasetID)
  2104. }
  2105. if m.FieldCleared(agentbase.FieldCollectionID) {
  2106. fields = append(fields, agentbase.FieldCollectionID)
  2107. }
  2108. if m.FieldCleared(agentbase.FieldSourceName) {
  2109. fields = append(fields, agentbase.FieldSourceName)
  2110. }
  2111. if m.FieldCleared(agentbase.FieldCanWrite) {
  2112. fields = append(fields, agentbase.FieldCanWrite)
  2113. }
  2114. if m.FieldCleared(agentbase.FieldIsOwner) {
  2115. fields = append(fields, agentbase.FieldIsOwner)
  2116. }
  2117. return fields
  2118. }
  2119. // FieldCleared returns a boolean indicating if a field with the given name was
  2120. // cleared in this mutation.
  2121. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2122. _, ok := m.clearedFields[name]
  2123. return ok
  2124. }
  2125. // ClearField clears the value of the field with the given name. It returns an
  2126. // error if the field is not defined in the schema.
  2127. func (m *AgentBaseMutation) ClearField(name string) error {
  2128. switch name {
  2129. case agentbase.FieldQ:
  2130. m.ClearQ()
  2131. return nil
  2132. case agentbase.FieldA:
  2133. m.ClearA()
  2134. return nil
  2135. case agentbase.FieldIndexes:
  2136. m.ClearIndexes()
  2137. return nil
  2138. case agentbase.FieldDatasetID:
  2139. m.ClearDatasetID()
  2140. return nil
  2141. case agentbase.FieldCollectionID:
  2142. m.ClearCollectionID()
  2143. return nil
  2144. case agentbase.FieldSourceName:
  2145. m.ClearSourceName()
  2146. return nil
  2147. case agentbase.FieldCanWrite:
  2148. m.ClearCanWrite()
  2149. return nil
  2150. case agentbase.FieldIsOwner:
  2151. m.ClearIsOwner()
  2152. return nil
  2153. }
  2154. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2155. }
  2156. // ResetField resets all changes in the mutation for the field with the given name.
  2157. // It returns an error if the field is not defined in the schema.
  2158. func (m *AgentBaseMutation) ResetField(name string) error {
  2159. switch name {
  2160. case agentbase.FieldQ:
  2161. m.ResetQ()
  2162. return nil
  2163. case agentbase.FieldA:
  2164. m.ResetA()
  2165. return nil
  2166. case agentbase.FieldChunkIndex:
  2167. m.ResetChunkIndex()
  2168. return nil
  2169. case agentbase.FieldIndexes:
  2170. m.ResetIndexes()
  2171. return nil
  2172. case agentbase.FieldDatasetID:
  2173. m.ResetDatasetID()
  2174. return nil
  2175. case agentbase.FieldCollectionID:
  2176. m.ResetCollectionID()
  2177. return nil
  2178. case agentbase.FieldSourceName:
  2179. m.ResetSourceName()
  2180. return nil
  2181. case agentbase.FieldCanWrite:
  2182. m.ResetCanWrite()
  2183. return nil
  2184. case agentbase.FieldIsOwner:
  2185. m.ResetIsOwner()
  2186. return nil
  2187. }
  2188. return fmt.Errorf("unknown AgentBase field %s", name)
  2189. }
  2190. // AddedEdges returns all edge names that were set/added in this mutation.
  2191. func (m *AgentBaseMutation) AddedEdges() []string {
  2192. edges := make([]string, 0, 1)
  2193. if m.wx_agent != nil {
  2194. edges = append(edges, agentbase.EdgeWxAgent)
  2195. }
  2196. return edges
  2197. }
  2198. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2199. // name in this mutation.
  2200. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2201. switch name {
  2202. case agentbase.EdgeWxAgent:
  2203. ids := make([]ent.Value, 0, len(m.wx_agent))
  2204. for id := range m.wx_agent {
  2205. ids = append(ids, id)
  2206. }
  2207. return ids
  2208. }
  2209. return nil
  2210. }
  2211. // RemovedEdges returns all edge names that were removed in this mutation.
  2212. func (m *AgentBaseMutation) RemovedEdges() []string {
  2213. edges := make([]string, 0, 1)
  2214. if m.removedwx_agent != nil {
  2215. edges = append(edges, agentbase.EdgeWxAgent)
  2216. }
  2217. return edges
  2218. }
  2219. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2220. // the given name in this mutation.
  2221. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2222. switch name {
  2223. case agentbase.EdgeWxAgent:
  2224. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2225. for id := range m.removedwx_agent {
  2226. ids = append(ids, id)
  2227. }
  2228. return ids
  2229. }
  2230. return nil
  2231. }
  2232. // ClearedEdges returns all edge names that were cleared in this mutation.
  2233. func (m *AgentBaseMutation) ClearedEdges() []string {
  2234. edges := make([]string, 0, 1)
  2235. if m.clearedwx_agent {
  2236. edges = append(edges, agentbase.EdgeWxAgent)
  2237. }
  2238. return edges
  2239. }
  2240. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2241. // was cleared in this mutation.
  2242. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2243. switch name {
  2244. case agentbase.EdgeWxAgent:
  2245. return m.clearedwx_agent
  2246. }
  2247. return false
  2248. }
  2249. // ClearEdge clears the value of the edge with the given name. It returns an error
  2250. // if that edge is not defined in the schema.
  2251. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2252. switch name {
  2253. }
  2254. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2255. }
  2256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2257. // It returns an error if the edge is not defined in the schema.
  2258. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2259. switch name {
  2260. case agentbase.EdgeWxAgent:
  2261. m.ResetWxAgent()
  2262. return nil
  2263. }
  2264. return fmt.Errorf("unknown AgentBase edge %s", name)
  2265. }
  2266. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2267. type AliyunAvatarMutation struct {
  2268. config
  2269. op Op
  2270. typ string
  2271. id *uint64
  2272. created_at *time.Time
  2273. updated_at *time.Time
  2274. deleted_at *time.Time
  2275. user_id *uint64
  2276. adduser_id *int64
  2277. biz_id *string
  2278. access_key_id *string
  2279. access_key_secret *string
  2280. app_id *string
  2281. tenant_id *uint64
  2282. addtenant_id *int64
  2283. response *string
  2284. token *string
  2285. session_id *string
  2286. clearedFields map[string]struct{}
  2287. done bool
  2288. oldValue func(context.Context) (*AliyunAvatar, error)
  2289. predicates []predicate.AliyunAvatar
  2290. }
  2291. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2292. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2293. type aliyunavatarOption func(*AliyunAvatarMutation)
  2294. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2295. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2296. m := &AliyunAvatarMutation{
  2297. config: c,
  2298. op: op,
  2299. typ: TypeAliyunAvatar,
  2300. clearedFields: make(map[string]struct{}),
  2301. }
  2302. for _, opt := range opts {
  2303. opt(m)
  2304. }
  2305. return m
  2306. }
  2307. // withAliyunAvatarID sets the ID field of the mutation.
  2308. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2309. return func(m *AliyunAvatarMutation) {
  2310. var (
  2311. err error
  2312. once sync.Once
  2313. value *AliyunAvatar
  2314. )
  2315. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2316. once.Do(func() {
  2317. if m.done {
  2318. err = errors.New("querying old values post mutation is not allowed")
  2319. } else {
  2320. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2321. }
  2322. })
  2323. return value, err
  2324. }
  2325. m.id = &id
  2326. }
  2327. }
  2328. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2329. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2330. return func(m *AliyunAvatarMutation) {
  2331. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2332. return node, nil
  2333. }
  2334. m.id = &node.ID
  2335. }
  2336. }
  2337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2338. // executed in a transaction (ent.Tx), a transactional client is returned.
  2339. func (m AliyunAvatarMutation) Client() *Client {
  2340. client := &Client{config: m.config}
  2341. client.init()
  2342. return client
  2343. }
  2344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2345. // it returns an error otherwise.
  2346. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2347. if _, ok := m.driver.(*txDriver); !ok {
  2348. return nil, errors.New("ent: mutation is not running in a transaction")
  2349. }
  2350. tx := &Tx{config: m.config}
  2351. tx.init()
  2352. return tx, nil
  2353. }
  2354. // SetID sets the value of the id field. Note that this
  2355. // operation is only accepted on creation of AliyunAvatar entities.
  2356. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2357. m.id = &id
  2358. }
  2359. // ID returns the ID value in the mutation. Note that the ID is only available
  2360. // if it was provided to the builder or after it was returned from the database.
  2361. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2362. if m.id == nil {
  2363. return
  2364. }
  2365. return *m.id, true
  2366. }
  2367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2368. // That means, if the mutation is applied within a transaction with an isolation level such
  2369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2370. // or updated by the mutation.
  2371. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2372. switch {
  2373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2374. id, exists := m.ID()
  2375. if exists {
  2376. return []uint64{id}, nil
  2377. }
  2378. fallthrough
  2379. case m.op.Is(OpUpdate | OpDelete):
  2380. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2381. default:
  2382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2383. }
  2384. }
  2385. // SetCreatedAt sets the "created_at" field.
  2386. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2387. m.created_at = &t
  2388. }
  2389. // CreatedAt returns the value of the "created_at" field in the mutation.
  2390. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2391. v := m.created_at
  2392. if v == nil {
  2393. return
  2394. }
  2395. return *v, true
  2396. }
  2397. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2398. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2400. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2401. if !m.op.Is(OpUpdateOne) {
  2402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2403. }
  2404. if m.id == nil || m.oldValue == nil {
  2405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2406. }
  2407. oldValue, err := m.oldValue(ctx)
  2408. if err != nil {
  2409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2410. }
  2411. return oldValue.CreatedAt, nil
  2412. }
  2413. // ResetCreatedAt resets all changes to the "created_at" field.
  2414. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2415. m.created_at = nil
  2416. }
  2417. // SetUpdatedAt sets the "updated_at" field.
  2418. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2419. m.updated_at = &t
  2420. }
  2421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2422. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2423. v := m.updated_at
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2430. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2432. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2438. }
  2439. oldValue, err := m.oldValue(ctx)
  2440. if err != nil {
  2441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2442. }
  2443. return oldValue.UpdatedAt, nil
  2444. }
  2445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2446. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2447. m.updated_at = nil
  2448. }
  2449. // SetDeletedAt sets the "deleted_at" field.
  2450. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2451. m.deleted_at = &t
  2452. }
  2453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2454. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2455. v := m.deleted_at
  2456. if v == nil {
  2457. return
  2458. }
  2459. return *v, true
  2460. }
  2461. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2462. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2464. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2465. if !m.op.Is(OpUpdateOne) {
  2466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2467. }
  2468. if m.id == nil || m.oldValue == nil {
  2469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2470. }
  2471. oldValue, err := m.oldValue(ctx)
  2472. if err != nil {
  2473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2474. }
  2475. return oldValue.DeletedAt, nil
  2476. }
  2477. // ClearDeletedAt clears the value of the "deleted_at" field.
  2478. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2479. m.deleted_at = nil
  2480. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2481. }
  2482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2483. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2484. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2485. return ok
  2486. }
  2487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2488. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2489. m.deleted_at = nil
  2490. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2491. }
  2492. // SetUserID sets the "user_id" field.
  2493. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2494. m.user_id = &u
  2495. m.adduser_id = nil
  2496. }
  2497. // UserID returns the value of the "user_id" field in the mutation.
  2498. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2499. v := m.user_id
  2500. if v == nil {
  2501. return
  2502. }
  2503. return *v, true
  2504. }
  2505. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2506. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2508. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2509. if !m.op.Is(OpUpdateOne) {
  2510. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2511. }
  2512. if m.id == nil || m.oldValue == nil {
  2513. return v, errors.New("OldUserID requires an ID field in the mutation")
  2514. }
  2515. oldValue, err := m.oldValue(ctx)
  2516. if err != nil {
  2517. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2518. }
  2519. return oldValue.UserID, nil
  2520. }
  2521. // AddUserID adds u to the "user_id" field.
  2522. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2523. if m.adduser_id != nil {
  2524. *m.adduser_id += u
  2525. } else {
  2526. m.adduser_id = &u
  2527. }
  2528. }
  2529. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2530. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2531. v := m.adduser_id
  2532. if v == nil {
  2533. return
  2534. }
  2535. return *v, true
  2536. }
  2537. // ResetUserID resets all changes to the "user_id" field.
  2538. func (m *AliyunAvatarMutation) ResetUserID() {
  2539. m.user_id = nil
  2540. m.adduser_id = nil
  2541. }
  2542. // SetBizID sets the "biz_id" field.
  2543. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2544. m.biz_id = &s
  2545. }
  2546. // BizID returns the value of the "biz_id" field in the mutation.
  2547. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2548. v := m.biz_id
  2549. if v == nil {
  2550. return
  2551. }
  2552. return *v, true
  2553. }
  2554. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2555. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2557. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2558. if !m.op.Is(OpUpdateOne) {
  2559. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2560. }
  2561. if m.id == nil || m.oldValue == nil {
  2562. return v, errors.New("OldBizID requires an ID field in the mutation")
  2563. }
  2564. oldValue, err := m.oldValue(ctx)
  2565. if err != nil {
  2566. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2567. }
  2568. return oldValue.BizID, nil
  2569. }
  2570. // ResetBizID resets all changes to the "biz_id" field.
  2571. func (m *AliyunAvatarMutation) ResetBizID() {
  2572. m.biz_id = nil
  2573. }
  2574. // SetAccessKeyID sets the "access_key_id" field.
  2575. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2576. m.access_key_id = &s
  2577. }
  2578. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2579. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2580. v := m.access_key_id
  2581. if v == nil {
  2582. return
  2583. }
  2584. return *v, true
  2585. }
  2586. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2587. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2589. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2590. if !m.op.Is(OpUpdateOne) {
  2591. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2592. }
  2593. if m.id == nil || m.oldValue == nil {
  2594. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2595. }
  2596. oldValue, err := m.oldValue(ctx)
  2597. if err != nil {
  2598. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2599. }
  2600. return oldValue.AccessKeyID, nil
  2601. }
  2602. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2603. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2604. m.access_key_id = nil
  2605. }
  2606. // SetAccessKeySecret sets the "access_key_secret" field.
  2607. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2608. m.access_key_secret = &s
  2609. }
  2610. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2611. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2612. v := m.access_key_secret
  2613. if v == nil {
  2614. return
  2615. }
  2616. return *v, true
  2617. }
  2618. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2619. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2621. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2622. if !m.op.Is(OpUpdateOne) {
  2623. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2624. }
  2625. if m.id == nil || m.oldValue == nil {
  2626. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2627. }
  2628. oldValue, err := m.oldValue(ctx)
  2629. if err != nil {
  2630. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2631. }
  2632. return oldValue.AccessKeySecret, nil
  2633. }
  2634. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2635. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2636. m.access_key_secret = nil
  2637. }
  2638. // SetAppID sets the "app_id" field.
  2639. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2640. m.app_id = &s
  2641. }
  2642. // AppID returns the value of the "app_id" field in the mutation.
  2643. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2644. v := m.app_id
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2651. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2653. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2654. if !m.op.Is(OpUpdateOne) {
  2655. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2656. }
  2657. if m.id == nil || m.oldValue == nil {
  2658. return v, errors.New("OldAppID requires an ID field in the mutation")
  2659. }
  2660. oldValue, err := m.oldValue(ctx)
  2661. if err != nil {
  2662. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2663. }
  2664. return oldValue.AppID, nil
  2665. }
  2666. // ClearAppID clears the value of the "app_id" field.
  2667. func (m *AliyunAvatarMutation) ClearAppID() {
  2668. m.app_id = nil
  2669. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2670. }
  2671. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2672. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2673. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2674. return ok
  2675. }
  2676. // ResetAppID resets all changes to the "app_id" field.
  2677. func (m *AliyunAvatarMutation) ResetAppID() {
  2678. m.app_id = nil
  2679. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2680. }
  2681. // SetTenantID sets the "tenant_id" field.
  2682. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2683. m.tenant_id = &u
  2684. m.addtenant_id = nil
  2685. }
  2686. // TenantID returns the value of the "tenant_id" field in the mutation.
  2687. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2688. v := m.tenant_id
  2689. if v == nil {
  2690. return
  2691. }
  2692. return *v, true
  2693. }
  2694. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2695. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2697. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2698. if !m.op.Is(OpUpdateOne) {
  2699. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2700. }
  2701. if m.id == nil || m.oldValue == nil {
  2702. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2703. }
  2704. oldValue, err := m.oldValue(ctx)
  2705. if err != nil {
  2706. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2707. }
  2708. return oldValue.TenantID, nil
  2709. }
  2710. // AddTenantID adds u to the "tenant_id" field.
  2711. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2712. if m.addtenant_id != nil {
  2713. *m.addtenant_id += u
  2714. } else {
  2715. m.addtenant_id = &u
  2716. }
  2717. }
  2718. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2719. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2720. v := m.addtenant_id
  2721. if v == nil {
  2722. return
  2723. }
  2724. return *v, true
  2725. }
  2726. // ResetTenantID resets all changes to the "tenant_id" field.
  2727. func (m *AliyunAvatarMutation) ResetTenantID() {
  2728. m.tenant_id = nil
  2729. m.addtenant_id = nil
  2730. }
  2731. // SetResponse sets the "response" field.
  2732. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2733. m.response = &s
  2734. }
  2735. // Response returns the value of the "response" field in the mutation.
  2736. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2737. v := m.response
  2738. if v == nil {
  2739. return
  2740. }
  2741. return *v, true
  2742. }
  2743. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2744. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2746. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2747. if !m.op.Is(OpUpdateOne) {
  2748. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2749. }
  2750. if m.id == nil || m.oldValue == nil {
  2751. return v, errors.New("OldResponse requires an ID field in the mutation")
  2752. }
  2753. oldValue, err := m.oldValue(ctx)
  2754. if err != nil {
  2755. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2756. }
  2757. return oldValue.Response, nil
  2758. }
  2759. // ResetResponse resets all changes to the "response" field.
  2760. func (m *AliyunAvatarMutation) ResetResponse() {
  2761. m.response = nil
  2762. }
  2763. // SetToken sets the "token" field.
  2764. func (m *AliyunAvatarMutation) SetToken(s string) {
  2765. m.token = &s
  2766. }
  2767. // Token returns the value of the "token" field in the mutation.
  2768. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2769. v := m.token
  2770. if v == nil {
  2771. return
  2772. }
  2773. return *v, true
  2774. }
  2775. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2776. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2778. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2779. if !m.op.Is(OpUpdateOne) {
  2780. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2781. }
  2782. if m.id == nil || m.oldValue == nil {
  2783. return v, errors.New("OldToken requires an ID field in the mutation")
  2784. }
  2785. oldValue, err := m.oldValue(ctx)
  2786. if err != nil {
  2787. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2788. }
  2789. return oldValue.Token, nil
  2790. }
  2791. // ResetToken resets all changes to the "token" field.
  2792. func (m *AliyunAvatarMutation) ResetToken() {
  2793. m.token = nil
  2794. }
  2795. // SetSessionID sets the "session_id" field.
  2796. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2797. m.session_id = &s
  2798. }
  2799. // SessionID returns the value of the "session_id" field in the mutation.
  2800. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2801. v := m.session_id
  2802. if v == nil {
  2803. return
  2804. }
  2805. return *v, true
  2806. }
  2807. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2808. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2810. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2811. if !m.op.Is(OpUpdateOne) {
  2812. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2813. }
  2814. if m.id == nil || m.oldValue == nil {
  2815. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2816. }
  2817. oldValue, err := m.oldValue(ctx)
  2818. if err != nil {
  2819. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2820. }
  2821. return oldValue.SessionID, nil
  2822. }
  2823. // ResetSessionID resets all changes to the "session_id" field.
  2824. func (m *AliyunAvatarMutation) ResetSessionID() {
  2825. m.session_id = nil
  2826. }
  2827. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2828. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2829. m.predicates = append(m.predicates, ps...)
  2830. }
  2831. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2832. // users can use type-assertion to append predicates that do not depend on any generated package.
  2833. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2834. p := make([]predicate.AliyunAvatar, len(ps))
  2835. for i := range ps {
  2836. p[i] = ps[i]
  2837. }
  2838. m.Where(p...)
  2839. }
  2840. // Op returns the operation name.
  2841. func (m *AliyunAvatarMutation) Op() Op {
  2842. return m.op
  2843. }
  2844. // SetOp allows setting the mutation operation.
  2845. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2846. m.op = op
  2847. }
  2848. // Type returns the node type of this mutation (AliyunAvatar).
  2849. func (m *AliyunAvatarMutation) Type() string {
  2850. return m.typ
  2851. }
  2852. // Fields returns all fields that were changed during this mutation. Note that in
  2853. // order to get all numeric fields that were incremented/decremented, call
  2854. // AddedFields().
  2855. func (m *AliyunAvatarMutation) Fields() []string {
  2856. fields := make([]string, 0, 12)
  2857. if m.created_at != nil {
  2858. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2859. }
  2860. if m.updated_at != nil {
  2861. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2862. }
  2863. if m.deleted_at != nil {
  2864. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2865. }
  2866. if m.user_id != nil {
  2867. fields = append(fields, aliyunavatar.FieldUserID)
  2868. }
  2869. if m.biz_id != nil {
  2870. fields = append(fields, aliyunavatar.FieldBizID)
  2871. }
  2872. if m.access_key_id != nil {
  2873. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2874. }
  2875. if m.access_key_secret != nil {
  2876. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2877. }
  2878. if m.app_id != nil {
  2879. fields = append(fields, aliyunavatar.FieldAppID)
  2880. }
  2881. if m.tenant_id != nil {
  2882. fields = append(fields, aliyunavatar.FieldTenantID)
  2883. }
  2884. if m.response != nil {
  2885. fields = append(fields, aliyunavatar.FieldResponse)
  2886. }
  2887. if m.token != nil {
  2888. fields = append(fields, aliyunavatar.FieldToken)
  2889. }
  2890. if m.session_id != nil {
  2891. fields = append(fields, aliyunavatar.FieldSessionID)
  2892. }
  2893. return fields
  2894. }
  2895. // Field returns the value of a field with the given name. The second boolean
  2896. // return value indicates that this field was not set, or was not defined in the
  2897. // schema.
  2898. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2899. switch name {
  2900. case aliyunavatar.FieldCreatedAt:
  2901. return m.CreatedAt()
  2902. case aliyunavatar.FieldUpdatedAt:
  2903. return m.UpdatedAt()
  2904. case aliyunavatar.FieldDeletedAt:
  2905. return m.DeletedAt()
  2906. case aliyunavatar.FieldUserID:
  2907. return m.UserID()
  2908. case aliyunavatar.FieldBizID:
  2909. return m.BizID()
  2910. case aliyunavatar.FieldAccessKeyID:
  2911. return m.AccessKeyID()
  2912. case aliyunavatar.FieldAccessKeySecret:
  2913. return m.AccessKeySecret()
  2914. case aliyunavatar.FieldAppID:
  2915. return m.AppID()
  2916. case aliyunavatar.FieldTenantID:
  2917. return m.TenantID()
  2918. case aliyunavatar.FieldResponse:
  2919. return m.Response()
  2920. case aliyunavatar.FieldToken:
  2921. return m.Token()
  2922. case aliyunavatar.FieldSessionID:
  2923. return m.SessionID()
  2924. }
  2925. return nil, false
  2926. }
  2927. // OldField returns the old value of the field from the database. An error is
  2928. // returned if the mutation operation is not UpdateOne, or the query to the
  2929. // database failed.
  2930. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2931. switch name {
  2932. case aliyunavatar.FieldCreatedAt:
  2933. return m.OldCreatedAt(ctx)
  2934. case aliyunavatar.FieldUpdatedAt:
  2935. return m.OldUpdatedAt(ctx)
  2936. case aliyunavatar.FieldDeletedAt:
  2937. return m.OldDeletedAt(ctx)
  2938. case aliyunavatar.FieldUserID:
  2939. return m.OldUserID(ctx)
  2940. case aliyunavatar.FieldBizID:
  2941. return m.OldBizID(ctx)
  2942. case aliyunavatar.FieldAccessKeyID:
  2943. return m.OldAccessKeyID(ctx)
  2944. case aliyunavatar.FieldAccessKeySecret:
  2945. return m.OldAccessKeySecret(ctx)
  2946. case aliyunavatar.FieldAppID:
  2947. return m.OldAppID(ctx)
  2948. case aliyunavatar.FieldTenantID:
  2949. return m.OldTenantID(ctx)
  2950. case aliyunavatar.FieldResponse:
  2951. return m.OldResponse(ctx)
  2952. case aliyunavatar.FieldToken:
  2953. return m.OldToken(ctx)
  2954. case aliyunavatar.FieldSessionID:
  2955. return m.OldSessionID(ctx)
  2956. }
  2957. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2958. }
  2959. // SetField sets the value of a field with the given name. It returns an error if
  2960. // the field is not defined in the schema, or if the type mismatched the field
  2961. // type.
  2962. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2963. switch name {
  2964. case aliyunavatar.FieldCreatedAt:
  2965. v, ok := value.(time.Time)
  2966. if !ok {
  2967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2968. }
  2969. m.SetCreatedAt(v)
  2970. return nil
  2971. case aliyunavatar.FieldUpdatedAt:
  2972. v, ok := value.(time.Time)
  2973. if !ok {
  2974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2975. }
  2976. m.SetUpdatedAt(v)
  2977. return nil
  2978. case aliyunavatar.FieldDeletedAt:
  2979. v, ok := value.(time.Time)
  2980. if !ok {
  2981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2982. }
  2983. m.SetDeletedAt(v)
  2984. return nil
  2985. case aliyunavatar.FieldUserID:
  2986. v, ok := value.(uint64)
  2987. if !ok {
  2988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2989. }
  2990. m.SetUserID(v)
  2991. return nil
  2992. case aliyunavatar.FieldBizID:
  2993. v, ok := value.(string)
  2994. if !ok {
  2995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2996. }
  2997. m.SetBizID(v)
  2998. return nil
  2999. case aliyunavatar.FieldAccessKeyID:
  3000. v, ok := value.(string)
  3001. if !ok {
  3002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3003. }
  3004. m.SetAccessKeyID(v)
  3005. return nil
  3006. case aliyunavatar.FieldAccessKeySecret:
  3007. v, ok := value.(string)
  3008. if !ok {
  3009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3010. }
  3011. m.SetAccessKeySecret(v)
  3012. return nil
  3013. case aliyunavatar.FieldAppID:
  3014. v, ok := value.(string)
  3015. if !ok {
  3016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3017. }
  3018. m.SetAppID(v)
  3019. return nil
  3020. case aliyunavatar.FieldTenantID:
  3021. v, ok := value.(uint64)
  3022. if !ok {
  3023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3024. }
  3025. m.SetTenantID(v)
  3026. return nil
  3027. case aliyunavatar.FieldResponse:
  3028. v, ok := value.(string)
  3029. if !ok {
  3030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3031. }
  3032. m.SetResponse(v)
  3033. return nil
  3034. case aliyunavatar.FieldToken:
  3035. v, ok := value.(string)
  3036. if !ok {
  3037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3038. }
  3039. m.SetToken(v)
  3040. return nil
  3041. case aliyunavatar.FieldSessionID:
  3042. v, ok := value.(string)
  3043. if !ok {
  3044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3045. }
  3046. m.SetSessionID(v)
  3047. return nil
  3048. }
  3049. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3050. }
  3051. // AddedFields returns all numeric fields that were incremented/decremented during
  3052. // this mutation.
  3053. func (m *AliyunAvatarMutation) AddedFields() []string {
  3054. var fields []string
  3055. if m.adduser_id != nil {
  3056. fields = append(fields, aliyunavatar.FieldUserID)
  3057. }
  3058. if m.addtenant_id != nil {
  3059. fields = append(fields, aliyunavatar.FieldTenantID)
  3060. }
  3061. return fields
  3062. }
  3063. // AddedField returns the numeric value that was incremented/decremented on a field
  3064. // with the given name. The second boolean return value indicates that this field
  3065. // was not set, or was not defined in the schema.
  3066. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3067. switch name {
  3068. case aliyunavatar.FieldUserID:
  3069. return m.AddedUserID()
  3070. case aliyunavatar.FieldTenantID:
  3071. return m.AddedTenantID()
  3072. }
  3073. return nil, false
  3074. }
  3075. // AddField adds the value to the field with the given name. It returns an error if
  3076. // the field is not defined in the schema, or if the type mismatched the field
  3077. // type.
  3078. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3079. switch name {
  3080. case aliyunavatar.FieldUserID:
  3081. v, ok := value.(int64)
  3082. if !ok {
  3083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3084. }
  3085. m.AddUserID(v)
  3086. return nil
  3087. case aliyunavatar.FieldTenantID:
  3088. v, ok := value.(int64)
  3089. if !ok {
  3090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3091. }
  3092. m.AddTenantID(v)
  3093. return nil
  3094. }
  3095. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3096. }
  3097. // ClearedFields returns all nullable fields that were cleared during this
  3098. // mutation.
  3099. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3100. var fields []string
  3101. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3102. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3103. }
  3104. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3105. fields = append(fields, aliyunavatar.FieldAppID)
  3106. }
  3107. return fields
  3108. }
  3109. // FieldCleared returns a boolean indicating if a field with the given name was
  3110. // cleared in this mutation.
  3111. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3112. _, ok := m.clearedFields[name]
  3113. return ok
  3114. }
  3115. // ClearField clears the value of the field with the given name. It returns an
  3116. // error if the field is not defined in the schema.
  3117. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3118. switch name {
  3119. case aliyunavatar.FieldDeletedAt:
  3120. m.ClearDeletedAt()
  3121. return nil
  3122. case aliyunavatar.FieldAppID:
  3123. m.ClearAppID()
  3124. return nil
  3125. }
  3126. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3127. }
  3128. // ResetField resets all changes in the mutation for the field with the given name.
  3129. // It returns an error if the field is not defined in the schema.
  3130. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3131. switch name {
  3132. case aliyunavatar.FieldCreatedAt:
  3133. m.ResetCreatedAt()
  3134. return nil
  3135. case aliyunavatar.FieldUpdatedAt:
  3136. m.ResetUpdatedAt()
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. m.ResetDeletedAt()
  3140. return nil
  3141. case aliyunavatar.FieldUserID:
  3142. m.ResetUserID()
  3143. return nil
  3144. case aliyunavatar.FieldBizID:
  3145. m.ResetBizID()
  3146. return nil
  3147. case aliyunavatar.FieldAccessKeyID:
  3148. m.ResetAccessKeyID()
  3149. return nil
  3150. case aliyunavatar.FieldAccessKeySecret:
  3151. m.ResetAccessKeySecret()
  3152. return nil
  3153. case aliyunavatar.FieldAppID:
  3154. m.ResetAppID()
  3155. return nil
  3156. case aliyunavatar.FieldTenantID:
  3157. m.ResetTenantID()
  3158. return nil
  3159. case aliyunavatar.FieldResponse:
  3160. m.ResetResponse()
  3161. return nil
  3162. case aliyunavatar.FieldToken:
  3163. m.ResetToken()
  3164. return nil
  3165. case aliyunavatar.FieldSessionID:
  3166. m.ResetSessionID()
  3167. return nil
  3168. }
  3169. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3170. }
  3171. // AddedEdges returns all edge names that were set/added in this mutation.
  3172. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3173. edges := make([]string, 0, 0)
  3174. return edges
  3175. }
  3176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3177. // name in this mutation.
  3178. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3179. return nil
  3180. }
  3181. // RemovedEdges returns all edge names that were removed in this mutation.
  3182. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3183. edges := make([]string, 0, 0)
  3184. return edges
  3185. }
  3186. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3187. // the given name in this mutation.
  3188. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3189. return nil
  3190. }
  3191. // ClearedEdges returns all edge names that were cleared in this mutation.
  3192. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3193. edges := make([]string, 0, 0)
  3194. return edges
  3195. }
  3196. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3197. // was cleared in this mutation.
  3198. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3199. return false
  3200. }
  3201. // ClearEdge clears the value of the edge with the given name. It returns an error
  3202. // if that edge is not defined in the schema.
  3203. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3204. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3205. }
  3206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3207. // It returns an error if the edge is not defined in the schema.
  3208. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3209. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3210. }
  3211. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3212. type AllocAgentMutation struct {
  3213. config
  3214. op Op
  3215. typ string
  3216. id *uint64
  3217. created_at *time.Time
  3218. updated_at *time.Time
  3219. deleted_at *time.Time
  3220. user_id *string
  3221. organization_id *uint64
  3222. addorganization_id *int64
  3223. agents *[]uint64
  3224. appendagents []uint64
  3225. status *int
  3226. addstatus *int
  3227. clearedFields map[string]struct{}
  3228. done bool
  3229. oldValue func(context.Context) (*AllocAgent, error)
  3230. predicates []predicate.AllocAgent
  3231. }
  3232. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3233. // allocagentOption allows management of the mutation configuration using functional options.
  3234. type allocagentOption func(*AllocAgentMutation)
  3235. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3236. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3237. m := &AllocAgentMutation{
  3238. config: c,
  3239. op: op,
  3240. typ: TypeAllocAgent,
  3241. clearedFields: make(map[string]struct{}),
  3242. }
  3243. for _, opt := range opts {
  3244. opt(m)
  3245. }
  3246. return m
  3247. }
  3248. // withAllocAgentID sets the ID field of the mutation.
  3249. func withAllocAgentID(id uint64) allocagentOption {
  3250. return func(m *AllocAgentMutation) {
  3251. var (
  3252. err error
  3253. once sync.Once
  3254. value *AllocAgent
  3255. )
  3256. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3257. once.Do(func() {
  3258. if m.done {
  3259. err = errors.New("querying old values post mutation is not allowed")
  3260. } else {
  3261. value, err = m.Client().AllocAgent.Get(ctx, id)
  3262. }
  3263. })
  3264. return value, err
  3265. }
  3266. m.id = &id
  3267. }
  3268. }
  3269. // withAllocAgent sets the old AllocAgent of the mutation.
  3270. func withAllocAgent(node *AllocAgent) allocagentOption {
  3271. return func(m *AllocAgentMutation) {
  3272. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3273. return node, nil
  3274. }
  3275. m.id = &node.ID
  3276. }
  3277. }
  3278. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3279. // executed in a transaction (ent.Tx), a transactional client is returned.
  3280. func (m AllocAgentMutation) Client() *Client {
  3281. client := &Client{config: m.config}
  3282. client.init()
  3283. return client
  3284. }
  3285. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3286. // it returns an error otherwise.
  3287. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3288. if _, ok := m.driver.(*txDriver); !ok {
  3289. return nil, errors.New("ent: mutation is not running in a transaction")
  3290. }
  3291. tx := &Tx{config: m.config}
  3292. tx.init()
  3293. return tx, nil
  3294. }
  3295. // SetID sets the value of the id field. Note that this
  3296. // operation is only accepted on creation of AllocAgent entities.
  3297. func (m *AllocAgentMutation) SetID(id uint64) {
  3298. m.id = &id
  3299. }
  3300. // ID returns the ID value in the mutation. Note that the ID is only available
  3301. // if it was provided to the builder or after it was returned from the database.
  3302. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3303. if m.id == nil {
  3304. return
  3305. }
  3306. return *m.id, true
  3307. }
  3308. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3309. // That means, if the mutation is applied within a transaction with an isolation level such
  3310. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3311. // or updated by the mutation.
  3312. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3313. switch {
  3314. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3315. id, exists := m.ID()
  3316. if exists {
  3317. return []uint64{id}, nil
  3318. }
  3319. fallthrough
  3320. case m.op.Is(OpUpdate | OpDelete):
  3321. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3322. default:
  3323. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3324. }
  3325. }
  3326. // SetCreatedAt sets the "created_at" field.
  3327. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3328. m.created_at = &t
  3329. }
  3330. // CreatedAt returns the value of the "created_at" field in the mutation.
  3331. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3332. v := m.created_at
  3333. if v == nil {
  3334. return
  3335. }
  3336. return *v, true
  3337. }
  3338. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3339. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3341. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3342. if !m.op.Is(OpUpdateOne) {
  3343. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3344. }
  3345. if m.id == nil || m.oldValue == nil {
  3346. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3347. }
  3348. oldValue, err := m.oldValue(ctx)
  3349. if err != nil {
  3350. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3351. }
  3352. return oldValue.CreatedAt, nil
  3353. }
  3354. // ResetCreatedAt resets all changes to the "created_at" field.
  3355. func (m *AllocAgentMutation) ResetCreatedAt() {
  3356. m.created_at = nil
  3357. }
  3358. // SetUpdatedAt sets the "updated_at" field.
  3359. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3360. m.updated_at = &t
  3361. }
  3362. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3363. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3364. v := m.updated_at
  3365. if v == nil {
  3366. return
  3367. }
  3368. return *v, true
  3369. }
  3370. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3371. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3373. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3374. if !m.op.Is(OpUpdateOne) {
  3375. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3376. }
  3377. if m.id == nil || m.oldValue == nil {
  3378. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3379. }
  3380. oldValue, err := m.oldValue(ctx)
  3381. if err != nil {
  3382. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3383. }
  3384. return oldValue.UpdatedAt, nil
  3385. }
  3386. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3387. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3388. m.updated_at = nil
  3389. }
  3390. // SetDeletedAt sets the "deleted_at" field.
  3391. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3392. m.deleted_at = &t
  3393. }
  3394. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3395. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3396. v := m.deleted_at
  3397. if v == nil {
  3398. return
  3399. }
  3400. return *v, true
  3401. }
  3402. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3403. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3405. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3406. if !m.op.Is(OpUpdateOne) {
  3407. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3408. }
  3409. if m.id == nil || m.oldValue == nil {
  3410. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3411. }
  3412. oldValue, err := m.oldValue(ctx)
  3413. if err != nil {
  3414. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3415. }
  3416. return oldValue.DeletedAt, nil
  3417. }
  3418. // ClearDeletedAt clears the value of the "deleted_at" field.
  3419. func (m *AllocAgentMutation) ClearDeletedAt() {
  3420. m.deleted_at = nil
  3421. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3422. }
  3423. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3424. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3425. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3426. return ok
  3427. }
  3428. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3429. func (m *AllocAgentMutation) ResetDeletedAt() {
  3430. m.deleted_at = nil
  3431. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3432. }
  3433. // SetUserID sets the "user_id" field.
  3434. func (m *AllocAgentMutation) SetUserID(s string) {
  3435. m.user_id = &s
  3436. }
  3437. // UserID returns the value of the "user_id" field in the mutation.
  3438. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3439. v := m.user_id
  3440. if v == nil {
  3441. return
  3442. }
  3443. return *v, true
  3444. }
  3445. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3446. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3448. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3449. if !m.op.Is(OpUpdateOne) {
  3450. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3451. }
  3452. if m.id == nil || m.oldValue == nil {
  3453. return v, errors.New("OldUserID requires an ID field in the mutation")
  3454. }
  3455. oldValue, err := m.oldValue(ctx)
  3456. if err != nil {
  3457. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3458. }
  3459. return oldValue.UserID, nil
  3460. }
  3461. // ClearUserID clears the value of the "user_id" field.
  3462. func (m *AllocAgentMutation) ClearUserID() {
  3463. m.user_id = nil
  3464. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3465. }
  3466. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3467. func (m *AllocAgentMutation) UserIDCleared() bool {
  3468. _, ok := m.clearedFields[allocagent.FieldUserID]
  3469. return ok
  3470. }
  3471. // ResetUserID resets all changes to the "user_id" field.
  3472. func (m *AllocAgentMutation) ResetUserID() {
  3473. m.user_id = nil
  3474. delete(m.clearedFields, allocagent.FieldUserID)
  3475. }
  3476. // SetOrganizationID sets the "organization_id" field.
  3477. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3478. m.organization_id = &u
  3479. m.addorganization_id = nil
  3480. }
  3481. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3482. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3483. v := m.organization_id
  3484. if v == nil {
  3485. return
  3486. }
  3487. return *v, true
  3488. }
  3489. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3490. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3492. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3493. if !m.op.Is(OpUpdateOne) {
  3494. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3495. }
  3496. if m.id == nil || m.oldValue == nil {
  3497. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3498. }
  3499. oldValue, err := m.oldValue(ctx)
  3500. if err != nil {
  3501. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3502. }
  3503. return oldValue.OrganizationID, nil
  3504. }
  3505. // AddOrganizationID adds u to the "organization_id" field.
  3506. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3507. if m.addorganization_id != nil {
  3508. *m.addorganization_id += u
  3509. } else {
  3510. m.addorganization_id = &u
  3511. }
  3512. }
  3513. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3514. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3515. v := m.addorganization_id
  3516. if v == nil {
  3517. return
  3518. }
  3519. return *v, true
  3520. }
  3521. // ClearOrganizationID clears the value of the "organization_id" field.
  3522. func (m *AllocAgentMutation) ClearOrganizationID() {
  3523. m.organization_id = nil
  3524. m.addorganization_id = nil
  3525. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3526. }
  3527. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3528. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3529. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3530. return ok
  3531. }
  3532. // ResetOrganizationID resets all changes to the "organization_id" field.
  3533. func (m *AllocAgentMutation) ResetOrganizationID() {
  3534. m.organization_id = nil
  3535. m.addorganization_id = nil
  3536. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3537. }
  3538. // SetAgents sets the "agents" field.
  3539. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3540. m.agents = &u
  3541. m.appendagents = nil
  3542. }
  3543. // Agents returns the value of the "agents" field in the mutation.
  3544. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3545. v := m.agents
  3546. if v == nil {
  3547. return
  3548. }
  3549. return *v, true
  3550. }
  3551. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3552. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3554. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3555. if !m.op.Is(OpUpdateOne) {
  3556. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3557. }
  3558. if m.id == nil || m.oldValue == nil {
  3559. return v, errors.New("OldAgents requires an ID field in the mutation")
  3560. }
  3561. oldValue, err := m.oldValue(ctx)
  3562. if err != nil {
  3563. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3564. }
  3565. return oldValue.Agents, nil
  3566. }
  3567. // AppendAgents adds u to the "agents" field.
  3568. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3569. m.appendagents = append(m.appendagents, u...)
  3570. }
  3571. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3572. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3573. if len(m.appendagents) == 0 {
  3574. return nil, false
  3575. }
  3576. return m.appendagents, true
  3577. }
  3578. // ResetAgents resets all changes to the "agents" field.
  3579. func (m *AllocAgentMutation) ResetAgents() {
  3580. m.agents = nil
  3581. m.appendagents = nil
  3582. }
  3583. // SetStatus sets the "status" field.
  3584. func (m *AllocAgentMutation) SetStatus(i int) {
  3585. m.status = &i
  3586. m.addstatus = nil
  3587. }
  3588. // Status returns the value of the "status" field in the mutation.
  3589. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3590. v := m.status
  3591. if v == nil {
  3592. return
  3593. }
  3594. return *v, true
  3595. }
  3596. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3597. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3599. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3600. if !m.op.Is(OpUpdateOne) {
  3601. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3602. }
  3603. if m.id == nil || m.oldValue == nil {
  3604. return v, errors.New("OldStatus requires an ID field in the mutation")
  3605. }
  3606. oldValue, err := m.oldValue(ctx)
  3607. if err != nil {
  3608. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3609. }
  3610. return oldValue.Status, nil
  3611. }
  3612. // AddStatus adds i to the "status" field.
  3613. func (m *AllocAgentMutation) AddStatus(i int) {
  3614. if m.addstatus != nil {
  3615. *m.addstatus += i
  3616. } else {
  3617. m.addstatus = &i
  3618. }
  3619. }
  3620. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3621. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3622. v := m.addstatus
  3623. if v == nil {
  3624. return
  3625. }
  3626. return *v, true
  3627. }
  3628. // ClearStatus clears the value of the "status" field.
  3629. func (m *AllocAgentMutation) ClearStatus() {
  3630. m.status = nil
  3631. m.addstatus = nil
  3632. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3633. }
  3634. // StatusCleared returns if the "status" field was cleared in this mutation.
  3635. func (m *AllocAgentMutation) StatusCleared() bool {
  3636. _, ok := m.clearedFields[allocagent.FieldStatus]
  3637. return ok
  3638. }
  3639. // ResetStatus resets all changes to the "status" field.
  3640. func (m *AllocAgentMutation) ResetStatus() {
  3641. m.status = nil
  3642. m.addstatus = nil
  3643. delete(m.clearedFields, allocagent.FieldStatus)
  3644. }
  3645. // Where appends a list predicates to the AllocAgentMutation builder.
  3646. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3647. m.predicates = append(m.predicates, ps...)
  3648. }
  3649. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3650. // users can use type-assertion to append predicates that do not depend on any generated package.
  3651. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3652. p := make([]predicate.AllocAgent, len(ps))
  3653. for i := range ps {
  3654. p[i] = ps[i]
  3655. }
  3656. m.Where(p...)
  3657. }
  3658. // Op returns the operation name.
  3659. func (m *AllocAgentMutation) Op() Op {
  3660. return m.op
  3661. }
  3662. // SetOp allows setting the mutation operation.
  3663. func (m *AllocAgentMutation) SetOp(op Op) {
  3664. m.op = op
  3665. }
  3666. // Type returns the node type of this mutation (AllocAgent).
  3667. func (m *AllocAgentMutation) Type() string {
  3668. return m.typ
  3669. }
  3670. // Fields returns all fields that were changed during this mutation. Note that in
  3671. // order to get all numeric fields that were incremented/decremented, call
  3672. // AddedFields().
  3673. func (m *AllocAgentMutation) Fields() []string {
  3674. fields := make([]string, 0, 7)
  3675. if m.created_at != nil {
  3676. fields = append(fields, allocagent.FieldCreatedAt)
  3677. }
  3678. if m.updated_at != nil {
  3679. fields = append(fields, allocagent.FieldUpdatedAt)
  3680. }
  3681. if m.deleted_at != nil {
  3682. fields = append(fields, allocagent.FieldDeletedAt)
  3683. }
  3684. if m.user_id != nil {
  3685. fields = append(fields, allocagent.FieldUserID)
  3686. }
  3687. if m.organization_id != nil {
  3688. fields = append(fields, allocagent.FieldOrganizationID)
  3689. }
  3690. if m.agents != nil {
  3691. fields = append(fields, allocagent.FieldAgents)
  3692. }
  3693. if m.status != nil {
  3694. fields = append(fields, allocagent.FieldStatus)
  3695. }
  3696. return fields
  3697. }
  3698. // Field returns the value of a field with the given name. The second boolean
  3699. // return value indicates that this field was not set, or was not defined in the
  3700. // schema.
  3701. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3702. switch name {
  3703. case allocagent.FieldCreatedAt:
  3704. return m.CreatedAt()
  3705. case allocagent.FieldUpdatedAt:
  3706. return m.UpdatedAt()
  3707. case allocagent.FieldDeletedAt:
  3708. return m.DeletedAt()
  3709. case allocagent.FieldUserID:
  3710. return m.UserID()
  3711. case allocagent.FieldOrganizationID:
  3712. return m.OrganizationID()
  3713. case allocagent.FieldAgents:
  3714. return m.Agents()
  3715. case allocagent.FieldStatus:
  3716. return m.Status()
  3717. }
  3718. return nil, false
  3719. }
  3720. // OldField returns the old value of the field from the database. An error is
  3721. // returned if the mutation operation is not UpdateOne, or the query to the
  3722. // database failed.
  3723. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3724. switch name {
  3725. case allocagent.FieldCreatedAt:
  3726. return m.OldCreatedAt(ctx)
  3727. case allocagent.FieldUpdatedAt:
  3728. return m.OldUpdatedAt(ctx)
  3729. case allocagent.FieldDeletedAt:
  3730. return m.OldDeletedAt(ctx)
  3731. case allocagent.FieldUserID:
  3732. return m.OldUserID(ctx)
  3733. case allocagent.FieldOrganizationID:
  3734. return m.OldOrganizationID(ctx)
  3735. case allocagent.FieldAgents:
  3736. return m.OldAgents(ctx)
  3737. case allocagent.FieldStatus:
  3738. return m.OldStatus(ctx)
  3739. }
  3740. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3741. }
  3742. // SetField sets the value of a field with the given name. It returns an error if
  3743. // the field is not defined in the schema, or if the type mismatched the field
  3744. // type.
  3745. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3746. switch name {
  3747. case allocagent.FieldCreatedAt:
  3748. v, ok := value.(time.Time)
  3749. if !ok {
  3750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3751. }
  3752. m.SetCreatedAt(v)
  3753. return nil
  3754. case allocagent.FieldUpdatedAt:
  3755. v, ok := value.(time.Time)
  3756. if !ok {
  3757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3758. }
  3759. m.SetUpdatedAt(v)
  3760. return nil
  3761. case allocagent.FieldDeletedAt:
  3762. v, ok := value.(time.Time)
  3763. if !ok {
  3764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3765. }
  3766. m.SetDeletedAt(v)
  3767. return nil
  3768. case allocagent.FieldUserID:
  3769. v, ok := value.(string)
  3770. if !ok {
  3771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3772. }
  3773. m.SetUserID(v)
  3774. return nil
  3775. case allocagent.FieldOrganizationID:
  3776. v, ok := value.(uint64)
  3777. if !ok {
  3778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3779. }
  3780. m.SetOrganizationID(v)
  3781. return nil
  3782. case allocagent.FieldAgents:
  3783. v, ok := value.([]uint64)
  3784. if !ok {
  3785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3786. }
  3787. m.SetAgents(v)
  3788. return nil
  3789. case allocagent.FieldStatus:
  3790. v, ok := value.(int)
  3791. if !ok {
  3792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3793. }
  3794. m.SetStatus(v)
  3795. return nil
  3796. }
  3797. return fmt.Errorf("unknown AllocAgent field %s", name)
  3798. }
  3799. // AddedFields returns all numeric fields that were incremented/decremented during
  3800. // this mutation.
  3801. func (m *AllocAgentMutation) AddedFields() []string {
  3802. var fields []string
  3803. if m.addorganization_id != nil {
  3804. fields = append(fields, allocagent.FieldOrganizationID)
  3805. }
  3806. if m.addstatus != nil {
  3807. fields = append(fields, allocagent.FieldStatus)
  3808. }
  3809. return fields
  3810. }
  3811. // AddedField returns the numeric value that was incremented/decremented on a field
  3812. // with the given name. The second boolean return value indicates that this field
  3813. // was not set, or was not defined in the schema.
  3814. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3815. switch name {
  3816. case allocagent.FieldOrganizationID:
  3817. return m.AddedOrganizationID()
  3818. case allocagent.FieldStatus:
  3819. return m.AddedStatus()
  3820. }
  3821. return nil, false
  3822. }
  3823. // AddField adds the value to the field with the given name. It returns an error if
  3824. // the field is not defined in the schema, or if the type mismatched the field
  3825. // type.
  3826. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3827. switch name {
  3828. case allocagent.FieldOrganizationID:
  3829. v, ok := value.(int64)
  3830. if !ok {
  3831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3832. }
  3833. m.AddOrganizationID(v)
  3834. return nil
  3835. case allocagent.FieldStatus:
  3836. v, ok := value.(int)
  3837. if !ok {
  3838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3839. }
  3840. m.AddStatus(v)
  3841. return nil
  3842. }
  3843. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3844. }
  3845. // ClearedFields returns all nullable fields that were cleared during this
  3846. // mutation.
  3847. func (m *AllocAgentMutation) ClearedFields() []string {
  3848. var fields []string
  3849. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3850. fields = append(fields, allocagent.FieldDeletedAt)
  3851. }
  3852. if m.FieldCleared(allocagent.FieldUserID) {
  3853. fields = append(fields, allocagent.FieldUserID)
  3854. }
  3855. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3856. fields = append(fields, allocagent.FieldOrganizationID)
  3857. }
  3858. if m.FieldCleared(allocagent.FieldStatus) {
  3859. fields = append(fields, allocagent.FieldStatus)
  3860. }
  3861. return fields
  3862. }
  3863. // FieldCleared returns a boolean indicating if a field with the given name was
  3864. // cleared in this mutation.
  3865. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3866. _, ok := m.clearedFields[name]
  3867. return ok
  3868. }
  3869. // ClearField clears the value of the field with the given name. It returns an
  3870. // error if the field is not defined in the schema.
  3871. func (m *AllocAgentMutation) ClearField(name string) error {
  3872. switch name {
  3873. case allocagent.FieldDeletedAt:
  3874. m.ClearDeletedAt()
  3875. return nil
  3876. case allocagent.FieldUserID:
  3877. m.ClearUserID()
  3878. return nil
  3879. case allocagent.FieldOrganizationID:
  3880. m.ClearOrganizationID()
  3881. return nil
  3882. case allocagent.FieldStatus:
  3883. m.ClearStatus()
  3884. return nil
  3885. }
  3886. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3887. }
  3888. // ResetField resets all changes in the mutation for the field with the given name.
  3889. // It returns an error if the field is not defined in the schema.
  3890. func (m *AllocAgentMutation) ResetField(name string) error {
  3891. switch name {
  3892. case allocagent.FieldCreatedAt:
  3893. m.ResetCreatedAt()
  3894. return nil
  3895. case allocagent.FieldUpdatedAt:
  3896. m.ResetUpdatedAt()
  3897. return nil
  3898. case allocagent.FieldDeletedAt:
  3899. m.ResetDeletedAt()
  3900. return nil
  3901. case allocagent.FieldUserID:
  3902. m.ResetUserID()
  3903. return nil
  3904. case allocagent.FieldOrganizationID:
  3905. m.ResetOrganizationID()
  3906. return nil
  3907. case allocagent.FieldAgents:
  3908. m.ResetAgents()
  3909. return nil
  3910. case allocagent.FieldStatus:
  3911. m.ResetStatus()
  3912. return nil
  3913. }
  3914. return fmt.Errorf("unknown AllocAgent field %s", name)
  3915. }
  3916. // AddedEdges returns all edge names that were set/added in this mutation.
  3917. func (m *AllocAgentMutation) AddedEdges() []string {
  3918. edges := make([]string, 0, 0)
  3919. return edges
  3920. }
  3921. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3922. // name in this mutation.
  3923. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3924. return nil
  3925. }
  3926. // RemovedEdges returns all edge names that were removed in this mutation.
  3927. func (m *AllocAgentMutation) RemovedEdges() []string {
  3928. edges := make([]string, 0, 0)
  3929. return edges
  3930. }
  3931. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3932. // the given name in this mutation.
  3933. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3934. return nil
  3935. }
  3936. // ClearedEdges returns all edge names that were cleared in this mutation.
  3937. func (m *AllocAgentMutation) ClearedEdges() []string {
  3938. edges := make([]string, 0, 0)
  3939. return edges
  3940. }
  3941. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3942. // was cleared in this mutation.
  3943. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3944. return false
  3945. }
  3946. // ClearEdge clears the value of the edge with the given name. It returns an error
  3947. // if that edge is not defined in the schema.
  3948. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3949. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3950. }
  3951. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3952. // It returns an error if the edge is not defined in the schema.
  3953. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3954. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3955. }
  3956. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3957. type BatchMsgMutation struct {
  3958. config
  3959. op Op
  3960. typ string
  3961. id *uint64
  3962. created_at *time.Time
  3963. updated_at *time.Time
  3964. deleted_at *time.Time
  3965. status *uint8
  3966. addstatus *int8
  3967. batch_no *string
  3968. task_name *string
  3969. fromwxid *string
  3970. msg *string
  3971. tag *string
  3972. tagids *string
  3973. total *int32
  3974. addtotal *int32
  3975. success *int32
  3976. addsuccess *int32
  3977. fail *int32
  3978. addfail *int32
  3979. start_time *time.Time
  3980. stop_time *time.Time
  3981. send_time *time.Time
  3982. _type *int32
  3983. add_type *int32
  3984. organization_id *uint64
  3985. addorganization_id *int64
  3986. clearedFields map[string]struct{}
  3987. done bool
  3988. oldValue func(context.Context) (*BatchMsg, error)
  3989. predicates []predicate.BatchMsg
  3990. }
  3991. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3992. // batchmsgOption allows management of the mutation configuration using functional options.
  3993. type batchmsgOption func(*BatchMsgMutation)
  3994. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3995. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3996. m := &BatchMsgMutation{
  3997. config: c,
  3998. op: op,
  3999. typ: TypeBatchMsg,
  4000. clearedFields: make(map[string]struct{}),
  4001. }
  4002. for _, opt := range opts {
  4003. opt(m)
  4004. }
  4005. return m
  4006. }
  4007. // withBatchMsgID sets the ID field of the mutation.
  4008. func withBatchMsgID(id uint64) batchmsgOption {
  4009. return func(m *BatchMsgMutation) {
  4010. var (
  4011. err error
  4012. once sync.Once
  4013. value *BatchMsg
  4014. )
  4015. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4016. once.Do(func() {
  4017. if m.done {
  4018. err = errors.New("querying old values post mutation is not allowed")
  4019. } else {
  4020. value, err = m.Client().BatchMsg.Get(ctx, id)
  4021. }
  4022. })
  4023. return value, err
  4024. }
  4025. m.id = &id
  4026. }
  4027. }
  4028. // withBatchMsg sets the old BatchMsg of the mutation.
  4029. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4030. return func(m *BatchMsgMutation) {
  4031. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4032. return node, nil
  4033. }
  4034. m.id = &node.ID
  4035. }
  4036. }
  4037. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4038. // executed in a transaction (ent.Tx), a transactional client is returned.
  4039. func (m BatchMsgMutation) Client() *Client {
  4040. client := &Client{config: m.config}
  4041. client.init()
  4042. return client
  4043. }
  4044. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4045. // it returns an error otherwise.
  4046. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4047. if _, ok := m.driver.(*txDriver); !ok {
  4048. return nil, errors.New("ent: mutation is not running in a transaction")
  4049. }
  4050. tx := &Tx{config: m.config}
  4051. tx.init()
  4052. return tx, nil
  4053. }
  4054. // SetID sets the value of the id field. Note that this
  4055. // operation is only accepted on creation of BatchMsg entities.
  4056. func (m *BatchMsgMutation) SetID(id uint64) {
  4057. m.id = &id
  4058. }
  4059. // ID returns the ID value in the mutation. Note that the ID is only available
  4060. // if it was provided to the builder or after it was returned from the database.
  4061. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4062. if m.id == nil {
  4063. return
  4064. }
  4065. return *m.id, true
  4066. }
  4067. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4068. // That means, if the mutation is applied within a transaction with an isolation level such
  4069. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4070. // or updated by the mutation.
  4071. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4072. switch {
  4073. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4074. id, exists := m.ID()
  4075. if exists {
  4076. return []uint64{id}, nil
  4077. }
  4078. fallthrough
  4079. case m.op.Is(OpUpdate | OpDelete):
  4080. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4081. default:
  4082. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4083. }
  4084. }
  4085. // SetCreatedAt sets the "created_at" field.
  4086. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4087. m.created_at = &t
  4088. }
  4089. // CreatedAt returns the value of the "created_at" field in the mutation.
  4090. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4091. v := m.created_at
  4092. if v == nil {
  4093. return
  4094. }
  4095. return *v, true
  4096. }
  4097. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4098. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4100. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4101. if !m.op.Is(OpUpdateOne) {
  4102. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4103. }
  4104. if m.id == nil || m.oldValue == nil {
  4105. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4106. }
  4107. oldValue, err := m.oldValue(ctx)
  4108. if err != nil {
  4109. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4110. }
  4111. return oldValue.CreatedAt, nil
  4112. }
  4113. // ResetCreatedAt resets all changes to the "created_at" field.
  4114. func (m *BatchMsgMutation) ResetCreatedAt() {
  4115. m.created_at = nil
  4116. }
  4117. // SetUpdatedAt sets the "updated_at" field.
  4118. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4119. m.updated_at = &t
  4120. }
  4121. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4122. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4123. v := m.updated_at
  4124. if v == nil {
  4125. return
  4126. }
  4127. return *v, true
  4128. }
  4129. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4130. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4132. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4133. if !m.op.Is(OpUpdateOne) {
  4134. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4135. }
  4136. if m.id == nil || m.oldValue == nil {
  4137. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4138. }
  4139. oldValue, err := m.oldValue(ctx)
  4140. if err != nil {
  4141. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4142. }
  4143. return oldValue.UpdatedAt, nil
  4144. }
  4145. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4146. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4147. m.updated_at = nil
  4148. }
  4149. // SetDeletedAt sets the "deleted_at" field.
  4150. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4151. m.deleted_at = &t
  4152. }
  4153. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4154. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4155. v := m.deleted_at
  4156. if v == nil {
  4157. return
  4158. }
  4159. return *v, true
  4160. }
  4161. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4162. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4164. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4165. if !m.op.Is(OpUpdateOne) {
  4166. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4167. }
  4168. if m.id == nil || m.oldValue == nil {
  4169. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4170. }
  4171. oldValue, err := m.oldValue(ctx)
  4172. if err != nil {
  4173. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4174. }
  4175. return oldValue.DeletedAt, nil
  4176. }
  4177. // ClearDeletedAt clears the value of the "deleted_at" field.
  4178. func (m *BatchMsgMutation) ClearDeletedAt() {
  4179. m.deleted_at = nil
  4180. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4181. }
  4182. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4183. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4184. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4185. return ok
  4186. }
  4187. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4188. func (m *BatchMsgMutation) ResetDeletedAt() {
  4189. m.deleted_at = nil
  4190. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4191. }
  4192. // SetStatus sets the "status" field.
  4193. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4194. m.status = &u
  4195. m.addstatus = nil
  4196. }
  4197. // Status returns the value of the "status" field in the mutation.
  4198. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4199. v := m.status
  4200. if v == nil {
  4201. return
  4202. }
  4203. return *v, true
  4204. }
  4205. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4206. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4208. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4209. if !m.op.Is(OpUpdateOne) {
  4210. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4211. }
  4212. if m.id == nil || m.oldValue == nil {
  4213. return v, errors.New("OldStatus requires an ID field in the mutation")
  4214. }
  4215. oldValue, err := m.oldValue(ctx)
  4216. if err != nil {
  4217. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4218. }
  4219. return oldValue.Status, nil
  4220. }
  4221. // AddStatus adds u to the "status" field.
  4222. func (m *BatchMsgMutation) AddStatus(u int8) {
  4223. if m.addstatus != nil {
  4224. *m.addstatus += u
  4225. } else {
  4226. m.addstatus = &u
  4227. }
  4228. }
  4229. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4230. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4231. v := m.addstatus
  4232. if v == nil {
  4233. return
  4234. }
  4235. return *v, true
  4236. }
  4237. // ClearStatus clears the value of the "status" field.
  4238. func (m *BatchMsgMutation) ClearStatus() {
  4239. m.status = nil
  4240. m.addstatus = nil
  4241. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4242. }
  4243. // StatusCleared returns if the "status" field was cleared in this mutation.
  4244. func (m *BatchMsgMutation) StatusCleared() bool {
  4245. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4246. return ok
  4247. }
  4248. // ResetStatus resets all changes to the "status" field.
  4249. func (m *BatchMsgMutation) ResetStatus() {
  4250. m.status = nil
  4251. m.addstatus = nil
  4252. delete(m.clearedFields, batchmsg.FieldStatus)
  4253. }
  4254. // SetBatchNo sets the "batch_no" field.
  4255. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4256. m.batch_no = &s
  4257. }
  4258. // BatchNo returns the value of the "batch_no" field in the mutation.
  4259. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4260. v := m.batch_no
  4261. if v == nil {
  4262. return
  4263. }
  4264. return *v, true
  4265. }
  4266. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4267. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4269. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4270. if !m.op.Is(OpUpdateOne) {
  4271. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4272. }
  4273. if m.id == nil || m.oldValue == nil {
  4274. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4275. }
  4276. oldValue, err := m.oldValue(ctx)
  4277. if err != nil {
  4278. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4279. }
  4280. return oldValue.BatchNo, nil
  4281. }
  4282. // ClearBatchNo clears the value of the "batch_no" field.
  4283. func (m *BatchMsgMutation) ClearBatchNo() {
  4284. m.batch_no = nil
  4285. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4286. }
  4287. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4288. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4289. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4290. return ok
  4291. }
  4292. // ResetBatchNo resets all changes to the "batch_no" field.
  4293. func (m *BatchMsgMutation) ResetBatchNo() {
  4294. m.batch_no = nil
  4295. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4296. }
  4297. // SetTaskName sets the "task_name" field.
  4298. func (m *BatchMsgMutation) SetTaskName(s string) {
  4299. m.task_name = &s
  4300. }
  4301. // TaskName returns the value of the "task_name" field in the mutation.
  4302. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4303. v := m.task_name
  4304. if v == nil {
  4305. return
  4306. }
  4307. return *v, true
  4308. }
  4309. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4310. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4312. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4313. if !m.op.Is(OpUpdateOne) {
  4314. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4315. }
  4316. if m.id == nil || m.oldValue == nil {
  4317. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4318. }
  4319. oldValue, err := m.oldValue(ctx)
  4320. if err != nil {
  4321. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4322. }
  4323. return oldValue.TaskName, nil
  4324. }
  4325. // ClearTaskName clears the value of the "task_name" field.
  4326. func (m *BatchMsgMutation) ClearTaskName() {
  4327. m.task_name = nil
  4328. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4329. }
  4330. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4331. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4332. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4333. return ok
  4334. }
  4335. // ResetTaskName resets all changes to the "task_name" field.
  4336. func (m *BatchMsgMutation) ResetTaskName() {
  4337. m.task_name = nil
  4338. delete(m.clearedFields, batchmsg.FieldTaskName)
  4339. }
  4340. // SetFromwxid sets the "fromwxid" field.
  4341. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4342. m.fromwxid = &s
  4343. }
  4344. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4345. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4346. v := m.fromwxid
  4347. if v == nil {
  4348. return
  4349. }
  4350. return *v, true
  4351. }
  4352. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4353. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4355. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4356. if !m.op.Is(OpUpdateOne) {
  4357. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4358. }
  4359. if m.id == nil || m.oldValue == nil {
  4360. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4361. }
  4362. oldValue, err := m.oldValue(ctx)
  4363. if err != nil {
  4364. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4365. }
  4366. return oldValue.Fromwxid, nil
  4367. }
  4368. // ClearFromwxid clears the value of the "fromwxid" field.
  4369. func (m *BatchMsgMutation) ClearFromwxid() {
  4370. m.fromwxid = nil
  4371. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4372. }
  4373. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4374. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4375. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4376. return ok
  4377. }
  4378. // ResetFromwxid resets all changes to the "fromwxid" field.
  4379. func (m *BatchMsgMutation) ResetFromwxid() {
  4380. m.fromwxid = nil
  4381. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4382. }
  4383. // SetMsg sets the "msg" field.
  4384. func (m *BatchMsgMutation) SetMsg(s string) {
  4385. m.msg = &s
  4386. }
  4387. // Msg returns the value of the "msg" field in the mutation.
  4388. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4389. v := m.msg
  4390. if v == nil {
  4391. return
  4392. }
  4393. return *v, true
  4394. }
  4395. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4396. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4398. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4399. if !m.op.Is(OpUpdateOne) {
  4400. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4401. }
  4402. if m.id == nil || m.oldValue == nil {
  4403. return v, errors.New("OldMsg requires an ID field in the mutation")
  4404. }
  4405. oldValue, err := m.oldValue(ctx)
  4406. if err != nil {
  4407. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4408. }
  4409. return oldValue.Msg, nil
  4410. }
  4411. // ClearMsg clears the value of the "msg" field.
  4412. func (m *BatchMsgMutation) ClearMsg() {
  4413. m.msg = nil
  4414. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4415. }
  4416. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4417. func (m *BatchMsgMutation) MsgCleared() bool {
  4418. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4419. return ok
  4420. }
  4421. // ResetMsg resets all changes to the "msg" field.
  4422. func (m *BatchMsgMutation) ResetMsg() {
  4423. m.msg = nil
  4424. delete(m.clearedFields, batchmsg.FieldMsg)
  4425. }
  4426. // SetTag sets the "tag" field.
  4427. func (m *BatchMsgMutation) SetTag(s string) {
  4428. m.tag = &s
  4429. }
  4430. // Tag returns the value of the "tag" field in the mutation.
  4431. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4432. v := m.tag
  4433. if v == nil {
  4434. return
  4435. }
  4436. return *v, true
  4437. }
  4438. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4439. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4441. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4442. if !m.op.Is(OpUpdateOne) {
  4443. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4444. }
  4445. if m.id == nil || m.oldValue == nil {
  4446. return v, errors.New("OldTag requires an ID field in the mutation")
  4447. }
  4448. oldValue, err := m.oldValue(ctx)
  4449. if err != nil {
  4450. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4451. }
  4452. return oldValue.Tag, nil
  4453. }
  4454. // ClearTag clears the value of the "tag" field.
  4455. func (m *BatchMsgMutation) ClearTag() {
  4456. m.tag = nil
  4457. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4458. }
  4459. // TagCleared returns if the "tag" field was cleared in this mutation.
  4460. func (m *BatchMsgMutation) TagCleared() bool {
  4461. _, ok := m.clearedFields[batchmsg.FieldTag]
  4462. return ok
  4463. }
  4464. // ResetTag resets all changes to the "tag" field.
  4465. func (m *BatchMsgMutation) ResetTag() {
  4466. m.tag = nil
  4467. delete(m.clearedFields, batchmsg.FieldTag)
  4468. }
  4469. // SetTagids sets the "tagids" field.
  4470. func (m *BatchMsgMutation) SetTagids(s string) {
  4471. m.tagids = &s
  4472. }
  4473. // Tagids returns the value of the "tagids" field in the mutation.
  4474. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4475. v := m.tagids
  4476. if v == nil {
  4477. return
  4478. }
  4479. return *v, true
  4480. }
  4481. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4482. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4484. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4485. if !m.op.Is(OpUpdateOne) {
  4486. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4487. }
  4488. if m.id == nil || m.oldValue == nil {
  4489. return v, errors.New("OldTagids requires an ID field in the mutation")
  4490. }
  4491. oldValue, err := m.oldValue(ctx)
  4492. if err != nil {
  4493. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4494. }
  4495. return oldValue.Tagids, nil
  4496. }
  4497. // ClearTagids clears the value of the "tagids" field.
  4498. func (m *BatchMsgMutation) ClearTagids() {
  4499. m.tagids = nil
  4500. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4501. }
  4502. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4503. func (m *BatchMsgMutation) TagidsCleared() bool {
  4504. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4505. return ok
  4506. }
  4507. // ResetTagids resets all changes to the "tagids" field.
  4508. func (m *BatchMsgMutation) ResetTagids() {
  4509. m.tagids = nil
  4510. delete(m.clearedFields, batchmsg.FieldTagids)
  4511. }
  4512. // SetTotal sets the "total" field.
  4513. func (m *BatchMsgMutation) SetTotal(i int32) {
  4514. m.total = &i
  4515. m.addtotal = nil
  4516. }
  4517. // Total returns the value of the "total" field in the mutation.
  4518. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4519. v := m.total
  4520. if v == nil {
  4521. return
  4522. }
  4523. return *v, true
  4524. }
  4525. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4526. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4528. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4529. if !m.op.Is(OpUpdateOne) {
  4530. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4531. }
  4532. if m.id == nil || m.oldValue == nil {
  4533. return v, errors.New("OldTotal requires an ID field in the mutation")
  4534. }
  4535. oldValue, err := m.oldValue(ctx)
  4536. if err != nil {
  4537. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4538. }
  4539. return oldValue.Total, nil
  4540. }
  4541. // AddTotal adds i to the "total" field.
  4542. func (m *BatchMsgMutation) AddTotal(i int32) {
  4543. if m.addtotal != nil {
  4544. *m.addtotal += i
  4545. } else {
  4546. m.addtotal = &i
  4547. }
  4548. }
  4549. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4550. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4551. v := m.addtotal
  4552. if v == nil {
  4553. return
  4554. }
  4555. return *v, true
  4556. }
  4557. // ClearTotal clears the value of the "total" field.
  4558. func (m *BatchMsgMutation) ClearTotal() {
  4559. m.total = nil
  4560. m.addtotal = nil
  4561. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4562. }
  4563. // TotalCleared returns if the "total" field was cleared in this mutation.
  4564. func (m *BatchMsgMutation) TotalCleared() bool {
  4565. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4566. return ok
  4567. }
  4568. // ResetTotal resets all changes to the "total" field.
  4569. func (m *BatchMsgMutation) ResetTotal() {
  4570. m.total = nil
  4571. m.addtotal = nil
  4572. delete(m.clearedFields, batchmsg.FieldTotal)
  4573. }
  4574. // SetSuccess sets the "success" field.
  4575. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4576. m.success = &i
  4577. m.addsuccess = nil
  4578. }
  4579. // Success returns the value of the "success" field in the mutation.
  4580. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4581. v := m.success
  4582. if v == nil {
  4583. return
  4584. }
  4585. return *v, true
  4586. }
  4587. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4588. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4590. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4591. if !m.op.Is(OpUpdateOne) {
  4592. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4593. }
  4594. if m.id == nil || m.oldValue == nil {
  4595. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4596. }
  4597. oldValue, err := m.oldValue(ctx)
  4598. if err != nil {
  4599. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4600. }
  4601. return oldValue.Success, nil
  4602. }
  4603. // AddSuccess adds i to the "success" field.
  4604. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4605. if m.addsuccess != nil {
  4606. *m.addsuccess += i
  4607. } else {
  4608. m.addsuccess = &i
  4609. }
  4610. }
  4611. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4612. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4613. v := m.addsuccess
  4614. if v == nil {
  4615. return
  4616. }
  4617. return *v, true
  4618. }
  4619. // ClearSuccess clears the value of the "success" field.
  4620. func (m *BatchMsgMutation) ClearSuccess() {
  4621. m.success = nil
  4622. m.addsuccess = nil
  4623. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4624. }
  4625. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4626. func (m *BatchMsgMutation) SuccessCleared() bool {
  4627. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4628. return ok
  4629. }
  4630. // ResetSuccess resets all changes to the "success" field.
  4631. func (m *BatchMsgMutation) ResetSuccess() {
  4632. m.success = nil
  4633. m.addsuccess = nil
  4634. delete(m.clearedFields, batchmsg.FieldSuccess)
  4635. }
  4636. // SetFail sets the "fail" field.
  4637. func (m *BatchMsgMutation) SetFail(i int32) {
  4638. m.fail = &i
  4639. m.addfail = nil
  4640. }
  4641. // Fail returns the value of the "fail" field in the mutation.
  4642. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4643. v := m.fail
  4644. if v == nil {
  4645. return
  4646. }
  4647. return *v, true
  4648. }
  4649. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4650. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4652. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4653. if !m.op.Is(OpUpdateOne) {
  4654. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4655. }
  4656. if m.id == nil || m.oldValue == nil {
  4657. return v, errors.New("OldFail requires an ID field in the mutation")
  4658. }
  4659. oldValue, err := m.oldValue(ctx)
  4660. if err != nil {
  4661. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4662. }
  4663. return oldValue.Fail, nil
  4664. }
  4665. // AddFail adds i to the "fail" field.
  4666. func (m *BatchMsgMutation) AddFail(i int32) {
  4667. if m.addfail != nil {
  4668. *m.addfail += i
  4669. } else {
  4670. m.addfail = &i
  4671. }
  4672. }
  4673. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4674. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4675. v := m.addfail
  4676. if v == nil {
  4677. return
  4678. }
  4679. return *v, true
  4680. }
  4681. // ClearFail clears the value of the "fail" field.
  4682. func (m *BatchMsgMutation) ClearFail() {
  4683. m.fail = nil
  4684. m.addfail = nil
  4685. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4686. }
  4687. // FailCleared returns if the "fail" field was cleared in this mutation.
  4688. func (m *BatchMsgMutation) FailCleared() bool {
  4689. _, ok := m.clearedFields[batchmsg.FieldFail]
  4690. return ok
  4691. }
  4692. // ResetFail resets all changes to the "fail" field.
  4693. func (m *BatchMsgMutation) ResetFail() {
  4694. m.fail = nil
  4695. m.addfail = nil
  4696. delete(m.clearedFields, batchmsg.FieldFail)
  4697. }
  4698. // SetStartTime sets the "start_time" field.
  4699. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4700. m.start_time = &t
  4701. }
  4702. // StartTime returns the value of the "start_time" field in the mutation.
  4703. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4704. v := m.start_time
  4705. if v == nil {
  4706. return
  4707. }
  4708. return *v, true
  4709. }
  4710. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4711. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4713. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4714. if !m.op.Is(OpUpdateOne) {
  4715. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4716. }
  4717. if m.id == nil || m.oldValue == nil {
  4718. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4719. }
  4720. oldValue, err := m.oldValue(ctx)
  4721. if err != nil {
  4722. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4723. }
  4724. return oldValue.StartTime, nil
  4725. }
  4726. // ClearStartTime clears the value of the "start_time" field.
  4727. func (m *BatchMsgMutation) ClearStartTime() {
  4728. m.start_time = nil
  4729. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4730. }
  4731. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4732. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4733. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4734. return ok
  4735. }
  4736. // ResetStartTime resets all changes to the "start_time" field.
  4737. func (m *BatchMsgMutation) ResetStartTime() {
  4738. m.start_time = nil
  4739. delete(m.clearedFields, batchmsg.FieldStartTime)
  4740. }
  4741. // SetStopTime sets the "stop_time" field.
  4742. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4743. m.stop_time = &t
  4744. }
  4745. // StopTime returns the value of the "stop_time" field in the mutation.
  4746. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4747. v := m.stop_time
  4748. if v == nil {
  4749. return
  4750. }
  4751. return *v, true
  4752. }
  4753. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4756. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4757. if !m.op.Is(OpUpdateOne) {
  4758. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4759. }
  4760. if m.id == nil || m.oldValue == nil {
  4761. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4762. }
  4763. oldValue, err := m.oldValue(ctx)
  4764. if err != nil {
  4765. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4766. }
  4767. return oldValue.StopTime, nil
  4768. }
  4769. // ClearStopTime clears the value of the "stop_time" field.
  4770. func (m *BatchMsgMutation) ClearStopTime() {
  4771. m.stop_time = nil
  4772. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4773. }
  4774. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4775. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4776. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4777. return ok
  4778. }
  4779. // ResetStopTime resets all changes to the "stop_time" field.
  4780. func (m *BatchMsgMutation) ResetStopTime() {
  4781. m.stop_time = nil
  4782. delete(m.clearedFields, batchmsg.FieldStopTime)
  4783. }
  4784. // SetSendTime sets the "send_time" field.
  4785. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4786. m.send_time = &t
  4787. }
  4788. // SendTime returns the value of the "send_time" field in the mutation.
  4789. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4790. v := m.send_time
  4791. if v == nil {
  4792. return
  4793. }
  4794. return *v, true
  4795. }
  4796. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4797. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4799. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4800. if !m.op.Is(OpUpdateOne) {
  4801. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4802. }
  4803. if m.id == nil || m.oldValue == nil {
  4804. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4805. }
  4806. oldValue, err := m.oldValue(ctx)
  4807. if err != nil {
  4808. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4809. }
  4810. return oldValue.SendTime, nil
  4811. }
  4812. // ClearSendTime clears the value of the "send_time" field.
  4813. func (m *BatchMsgMutation) ClearSendTime() {
  4814. m.send_time = nil
  4815. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4816. }
  4817. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4818. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4819. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4820. return ok
  4821. }
  4822. // ResetSendTime resets all changes to the "send_time" field.
  4823. func (m *BatchMsgMutation) ResetSendTime() {
  4824. m.send_time = nil
  4825. delete(m.clearedFields, batchmsg.FieldSendTime)
  4826. }
  4827. // SetType sets the "type" field.
  4828. func (m *BatchMsgMutation) SetType(i int32) {
  4829. m._type = &i
  4830. m.add_type = nil
  4831. }
  4832. // GetType returns the value of the "type" field in the mutation.
  4833. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4834. v := m._type
  4835. if v == nil {
  4836. return
  4837. }
  4838. return *v, true
  4839. }
  4840. // OldType returns the old "type" field's value of the BatchMsg entity.
  4841. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4843. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4844. if !m.op.Is(OpUpdateOne) {
  4845. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4846. }
  4847. if m.id == nil || m.oldValue == nil {
  4848. return v, errors.New("OldType requires an ID field in the mutation")
  4849. }
  4850. oldValue, err := m.oldValue(ctx)
  4851. if err != nil {
  4852. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4853. }
  4854. return oldValue.Type, nil
  4855. }
  4856. // AddType adds i to the "type" field.
  4857. func (m *BatchMsgMutation) AddType(i int32) {
  4858. if m.add_type != nil {
  4859. *m.add_type += i
  4860. } else {
  4861. m.add_type = &i
  4862. }
  4863. }
  4864. // AddedType returns the value that was added to the "type" field in this mutation.
  4865. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4866. v := m.add_type
  4867. if v == nil {
  4868. return
  4869. }
  4870. return *v, true
  4871. }
  4872. // ClearType clears the value of the "type" field.
  4873. func (m *BatchMsgMutation) ClearType() {
  4874. m._type = nil
  4875. m.add_type = nil
  4876. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4877. }
  4878. // TypeCleared returns if the "type" field was cleared in this mutation.
  4879. func (m *BatchMsgMutation) TypeCleared() bool {
  4880. _, ok := m.clearedFields[batchmsg.FieldType]
  4881. return ok
  4882. }
  4883. // ResetType resets all changes to the "type" field.
  4884. func (m *BatchMsgMutation) ResetType() {
  4885. m._type = nil
  4886. m.add_type = nil
  4887. delete(m.clearedFields, batchmsg.FieldType)
  4888. }
  4889. // SetOrganizationID sets the "organization_id" field.
  4890. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4891. m.organization_id = &u
  4892. m.addorganization_id = nil
  4893. }
  4894. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4895. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4896. v := m.organization_id
  4897. if v == nil {
  4898. return
  4899. }
  4900. return *v, true
  4901. }
  4902. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4903. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4905. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4906. if !m.op.Is(OpUpdateOne) {
  4907. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4908. }
  4909. if m.id == nil || m.oldValue == nil {
  4910. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4911. }
  4912. oldValue, err := m.oldValue(ctx)
  4913. if err != nil {
  4914. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4915. }
  4916. return oldValue.OrganizationID, nil
  4917. }
  4918. // AddOrganizationID adds u to the "organization_id" field.
  4919. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4920. if m.addorganization_id != nil {
  4921. *m.addorganization_id += u
  4922. } else {
  4923. m.addorganization_id = &u
  4924. }
  4925. }
  4926. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4927. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4928. v := m.addorganization_id
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // ResetOrganizationID resets all changes to the "organization_id" field.
  4935. func (m *BatchMsgMutation) ResetOrganizationID() {
  4936. m.organization_id = nil
  4937. m.addorganization_id = nil
  4938. }
  4939. // Where appends a list predicates to the BatchMsgMutation builder.
  4940. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4941. m.predicates = append(m.predicates, ps...)
  4942. }
  4943. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4944. // users can use type-assertion to append predicates that do not depend on any generated package.
  4945. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4946. p := make([]predicate.BatchMsg, len(ps))
  4947. for i := range ps {
  4948. p[i] = ps[i]
  4949. }
  4950. m.Where(p...)
  4951. }
  4952. // Op returns the operation name.
  4953. func (m *BatchMsgMutation) Op() Op {
  4954. return m.op
  4955. }
  4956. // SetOp allows setting the mutation operation.
  4957. func (m *BatchMsgMutation) SetOp(op Op) {
  4958. m.op = op
  4959. }
  4960. // Type returns the node type of this mutation (BatchMsg).
  4961. func (m *BatchMsgMutation) Type() string {
  4962. return m.typ
  4963. }
  4964. // Fields returns all fields that were changed during this mutation. Note that in
  4965. // order to get all numeric fields that were incremented/decremented, call
  4966. // AddedFields().
  4967. func (m *BatchMsgMutation) Fields() []string {
  4968. fields := make([]string, 0, 18)
  4969. if m.created_at != nil {
  4970. fields = append(fields, batchmsg.FieldCreatedAt)
  4971. }
  4972. if m.updated_at != nil {
  4973. fields = append(fields, batchmsg.FieldUpdatedAt)
  4974. }
  4975. if m.deleted_at != nil {
  4976. fields = append(fields, batchmsg.FieldDeletedAt)
  4977. }
  4978. if m.status != nil {
  4979. fields = append(fields, batchmsg.FieldStatus)
  4980. }
  4981. if m.batch_no != nil {
  4982. fields = append(fields, batchmsg.FieldBatchNo)
  4983. }
  4984. if m.task_name != nil {
  4985. fields = append(fields, batchmsg.FieldTaskName)
  4986. }
  4987. if m.fromwxid != nil {
  4988. fields = append(fields, batchmsg.FieldFromwxid)
  4989. }
  4990. if m.msg != nil {
  4991. fields = append(fields, batchmsg.FieldMsg)
  4992. }
  4993. if m.tag != nil {
  4994. fields = append(fields, batchmsg.FieldTag)
  4995. }
  4996. if m.tagids != nil {
  4997. fields = append(fields, batchmsg.FieldTagids)
  4998. }
  4999. if m.total != nil {
  5000. fields = append(fields, batchmsg.FieldTotal)
  5001. }
  5002. if m.success != nil {
  5003. fields = append(fields, batchmsg.FieldSuccess)
  5004. }
  5005. if m.fail != nil {
  5006. fields = append(fields, batchmsg.FieldFail)
  5007. }
  5008. if m.start_time != nil {
  5009. fields = append(fields, batchmsg.FieldStartTime)
  5010. }
  5011. if m.stop_time != nil {
  5012. fields = append(fields, batchmsg.FieldStopTime)
  5013. }
  5014. if m.send_time != nil {
  5015. fields = append(fields, batchmsg.FieldSendTime)
  5016. }
  5017. if m._type != nil {
  5018. fields = append(fields, batchmsg.FieldType)
  5019. }
  5020. if m.organization_id != nil {
  5021. fields = append(fields, batchmsg.FieldOrganizationID)
  5022. }
  5023. return fields
  5024. }
  5025. // Field returns the value of a field with the given name. The second boolean
  5026. // return value indicates that this field was not set, or was not defined in the
  5027. // schema.
  5028. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5029. switch name {
  5030. case batchmsg.FieldCreatedAt:
  5031. return m.CreatedAt()
  5032. case batchmsg.FieldUpdatedAt:
  5033. return m.UpdatedAt()
  5034. case batchmsg.FieldDeletedAt:
  5035. return m.DeletedAt()
  5036. case batchmsg.FieldStatus:
  5037. return m.Status()
  5038. case batchmsg.FieldBatchNo:
  5039. return m.BatchNo()
  5040. case batchmsg.FieldTaskName:
  5041. return m.TaskName()
  5042. case batchmsg.FieldFromwxid:
  5043. return m.Fromwxid()
  5044. case batchmsg.FieldMsg:
  5045. return m.Msg()
  5046. case batchmsg.FieldTag:
  5047. return m.Tag()
  5048. case batchmsg.FieldTagids:
  5049. return m.Tagids()
  5050. case batchmsg.FieldTotal:
  5051. return m.Total()
  5052. case batchmsg.FieldSuccess:
  5053. return m.Success()
  5054. case batchmsg.FieldFail:
  5055. return m.Fail()
  5056. case batchmsg.FieldStartTime:
  5057. return m.StartTime()
  5058. case batchmsg.FieldStopTime:
  5059. return m.StopTime()
  5060. case batchmsg.FieldSendTime:
  5061. return m.SendTime()
  5062. case batchmsg.FieldType:
  5063. return m.GetType()
  5064. case batchmsg.FieldOrganizationID:
  5065. return m.OrganizationID()
  5066. }
  5067. return nil, false
  5068. }
  5069. // OldField returns the old value of the field from the database. An error is
  5070. // returned if the mutation operation is not UpdateOne, or the query to the
  5071. // database failed.
  5072. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5073. switch name {
  5074. case batchmsg.FieldCreatedAt:
  5075. return m.OldCreatedAt(ctx)
  5076. case batchmsg.FieldUpdatedAt:
  5077. return m.OldUpdatedAt(ctx)
  5078. case batchmsg.FieldDeletedAt:
  5079. return m.OldDeletedAt(ctx)
  5080. case batchmsg.FieldStatus:
  5081. return m.OldStatus(ctx)
  5082. case batchmsg.FieldBatchNo:
  5083. return m.OldBatchNo(ctx)
  5084. case batchmsg.FieldTaskName:
  5085. return m.OldTaskName(ctx)
  5086. case batchmsg.FieldFromwxid:
  5087. return m.OldFromwxid(ctx)
  5088. case batchmsg.FieldMsg:
  5089. return m.OldMsg(ctx)
  5090. case batchmsg.FieldTag:
  5091. return m.OldTag(ctx)
  5092. case batchmsg.FieldTagids:
  5093. return m.OldTagids(ctx)
  5094. case batchmsg.FieldTotal:
  5095. return m.OldTotal(ctx)
  5096. case batchmsg.FieldSuccess:
  5097. return m.OldSuccess(ctx)
  5098. case batchmsg.FieldFail:
  5099. return m.OldFail(ctx)
  5100. case batchmsg.FieldStartTime:
  5101. return m.OldStartTime(ctx)
  5102. case batchmsg.FieldStopTime:
  5103. return m.OldStopTime(ctx)
  5104. case batchmsg.FieldSendTime:
  5105. return m.OldSendTime(ctx)
  5106. case batchmsg.FieldType:
  5107. return m.OldType(ctx)
  5108. case batchmsg.FieldOrganizationID:
  5109. return m.OldOrganizationID(ctx)
  5110. }
  5111. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5112. }
  5113. // SetField sets the value of a field with the given name. It returns an error if
  5114. // the field is not defined in the schema, or if the type mismatched the field
  5115. // type.
  5116. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5117. switch name {
  5118. case batchmsg.FieldCreatedAt:
  5119. v, ok := value.(time.Time)
  5120. if !ok {
  5121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5122. }
  5123. m.SetCreatedAt(v)
  5124. return nil
  5125. case batchmsg.FieldUpdatedAt:
  5126. v, ok := value.(time.Time)
  5127. if !ok {
  5128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5129. }
  5130. m.SetUpdatedAt(v)
  5131. return nil
  5132. case batchmsg.FieldDeletedAt:
  5133. v, ok := value.(time.Time)
  5134. if !ok {
  5135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5136. }
  5137. m.SetDeletedAt(v)
  5138. return nil
  5139. case batchmsg.FieldStatus:
  5140. v, ok := value.(uint8)
  5141. if !ok {
  5142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5143. }
  5144. m.SetStatus(v)
  5145. return nil
  5146. case batchmsg.FieldBatchNo:
  5147. v, ok := value.(string)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetBatchNo(v)
  5152. return nil
  5153. case batchmsg.FieldTaskName:
  5154. v, ok := value.(string)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetTaskName(v)
  5159. return nil
  5160. case batchmsg.FieldFromwxid:
  5161. v, ok := value.(string)
  5162. if !ok {
  5163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5164. }
  5165. m.SetFromwxid(v)
  5166. return nil
  5167. case batchmsg.FieldMsg:
  5168. v, ok := value.(string)
  5169. if !ok {
  5170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5171. }
  5172. m.SetMsg(v)
  5173. return nil
  5174. case batchmsg.FieldTag:
  5175. v, ok := value.(string)
  5176. if !ok {
  5177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5178. }
  5179. m.SetTag(v)
  5180. return nil
  5181. case batchmsg.FieldTagids:
  5182. v, ok := value.(string)
  5183. if !ok {
  5184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5185. }
  5186. m.SetTagids(v)
  5187. return nil
  5188. case batchmsg.FieldTotal:
  5189. v, ok := value.(int32)
  5190. if !ok {
  5191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5192. }
  5193. m.SetTotal(v)
  5194. return nil
  5195. case batchmsg.FieldSuccess:
  5196. v, ok := value.(int32)
  5197. if !ok {
  5198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5199. }
  5200. m.SetSuccess(v)
  5201. return nil
  5202. case batchmsg.FieldFail:
  5203. v, ok := value.(int32)
  5204. if !ok {
  5205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5206. }
  5207. m.SetFail(v)
  5208. return nil
  5209. case batchmsg.FieldStartTime:
  5210. v, ok := value.(time.Time)
  5211. if !ok {
  5212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5213. }
  5214. m.SetStartTime(v)
  5215. return nil
  5216. case batchmsg.FieldStopTime:
  5217. v, ok := value.(time.Time)
  5218. if !ok {
  5219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5220. }
  5221. m.SetStopTime(v)
  5222. return nil
  5223. case batchmsg.FieldSendTime:
  5224. v, ok := value.(time.Time)
  5225. if !ok {
  5226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5227. }
  5228. m.SetSendTime(v)
  5229. return nil
  5230. case batchmsg.FieldType:
  5231. v, ok := value.(int32)
  5232. if !ok {
  5233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5234. }
  5235. m.SetType(v)
  5236. return nil
  5237. case batchmsg.FieldOrganizationID:
  5238. v, ok := value.(uint64)
  5239. if !ok {
  5240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5241. }
  5242. m.SetOrganizationID(v)
  5243. return nil
  5244. }
  5245. return fmt.Errorf("unknown BatchMsg field %s", name)
  5246. }
  5247. // AddedFields returns all numeric fields that were incremented/decremented during
  5248. // this mutation.
  5249. func (m *BatchMsgMutation) AddedFields() []string {
  5250. var fields []string
  5251. if m.addstatus != nil {
  5252. fields = append(fields, batchmsg.FieldStatus)
  5253. }
  5254. if m.addtotal != nil {
  5255. fields = append(fields, batchmsg.FieldTotal)
  5256. }
  5257. if m.addsuccess != nil {
  5258. fields = append(fields, batchmsg.FieldSuccess)
  5259. }
  5260. if m.addfail != nil {
  5261. fields = append(fields, batchmsg.FieldFail)
  5262. }
  5263. if m.add_type != nil {
  5264. fields = append(fields, batchmsg.FieldType)
  5265. }
  5266. if m.addorganization_id != nil {
  5267. fields = append(fields, batchmsg.FieldOrganizationID)
  5268. }
  5269. return fields
  5270. }
  5271. // AddedField returns the numeric value that was incremented/decremented on a field
  5272. // with the given name. The second boolean return value indicates that this field
  5273. // was not set, or was not defined in the schema.
  5274. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5275. switch name {
  5276. case batchmsg.FieldStatus:
  5277. return m.AddedStatus()
  5278. case batchmsg.FieldTotal:
  5279. return m.AddedTotal()
  5280. case batchmsg.FieldSuccess:
  5281. return m.AddedSuccess()
  5282. case batchmsg.FieldFail:
  5283. return m.AddedFail()
  5284. case batchmsg.FieldType:
  5285. return m.AddedType()
  5286. case batchmsg.FieldOrganizationID:
  5287. return m.AddedOrganizationID()
  5288. }
  5289. return nil, false
  5290. }
  5291. // AddField adds the value to the field with the given name. It returns an error if
  5292. // the field is not defined in the schema, or if the type mismatched the field
  5293. // type.
  5294. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5295. switch name {
  5296. case batchmsg.FieldStatus:
  5297. v, ok := value.(int8)
  5298. if !ok {
  5299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5300. }
  5301. m.AddStatus(v)
  5302. return nil
  5303. case batchmsg.FieldTotal:
  5304. v, ok := value.(int32)
  5305. if !ok {
  5306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5307. }
  5308. m.AddTotal(v)
  5309. return nil
  5310. case batchmsg.FieldSuccess:
  5311. v, ok := value.(int32)
  5312. if !ok {
  5313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5314. }
  5315. m.AddSuccess(v)
  5316. return nil
  5317. case batchmsg.FieldFail:
  5318. v, ok := value.(int32)
  5319. if !ok {
  5320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5321. }
  5322. m.AddFail(v)
  5323. return nil
  5324. case batchmsg.FieldType:
  5325. v, ok := value.(int32)
  5326. if !ok {
  5327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5328. }
  5329. m.AddType(v)
  5330. return nil
  5331. case batchmsg.FieldOrganizationID:
  5332. v, ok := value.(int64)
  5333. if !ok {
  5334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5335. }
  5336. m.AddOrganizationID(v)
  5337. return nil
  5338. }
  5339. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5340. }
  5341. // ClearedFields returns all nullable fields that were cleared during this
  5342. // mutation.
  5343. func (m *BatchMsgMutation) ClearedFields() []string {
  5344. var fields []string
  5345. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5346. fields = append(fields, batchmsg.FieldDeletedAt)
  5347. }
  5348. if m.FieldCleared(batchmsg.FieldStatus) {
  5349. fields = append(fields, batchmsg.FieldStatus)
  5350. }
  5351. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5352. fields = append(fields, batchmsg.FieldBatchNo)
  5353. }
  5354. if m.FieldCleared(batchmsg.FieldTaskName) {
  5355. fields = append(fields, batchmsg.FieldTaskName)
  5356. }
  5357. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5358. fields = append(fields, batchmsg.FieldFromwxid)
  5359. }
  5360. if m.FieldCleared(batchmsg.FieldMsg) {
  5361. fields = append(fields, batchmsg.FieldMsg)
  5362. }
  5363. if m.FieldCleared(batchmsg.FieldTag) {
  5364. fields = append(fields, batchmsg.FieldTag)
  5365. }
  5366. if m.FieldCleared(batchmsg.FieldTagids) {
  5367. fields = append(fields, batchmsg.FieldTagids)
  5368. }
  5369. if m.FieldCleared(batchmsg.FieldTotal) {
  5370. fields = append(fields, batchmsg.FieldTotal)
  5371. }
  5372. if m.FieldCleared(batchmsg.FieldSuccess) {
  5373. fields = append(fields, batchmsg.FieldSuccess)
  5374. }
  5375. if m.FieldCleared(batchmsg.FieldFail) {
  5376. fields = append(fields, batchmsg.FieldFail)
  5377. }
  5378. if m.FieldCleared(batchmsg.FieldStartTime) {
  5379. fields = append(fields, batchmsg.FieldStartTime)
  5380. }
  5381. if m.FieldCleared(batchmsg.FieldStopTime) {
  5382. fields = append(fields, batchmsg.FieldStopTime)
  5383. }
  5384. if m.FieldCleared(batchmsg.FieldSendTime) {
  5385. fields = append(fields, batchmsg.FieldSendTime)
  5386. }
  5387. if m.FieldCleared(batchmsg.FieldType) {
  5388. fields = append(fields, batchmsg.FieldType)
  5389. }
  5390. return fields
  5391. }
  5392. // FieldCleared returns a boolean indicating if a field with the given name was
  5393. // cleared in this mutation.
  5394. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5395. _, ok := m.clearedFields[name]
  5396. return ok
  5397. }
  5398. // ClearField clears the value of the field with the given name. It returns an
  5399. // error if the field is not defined in the schema.
  5400. func (m *BatchMsgMutation) ClearField(name string) error {
  5401. switch name {
  5402. case batchmsg.FieldDeletedAt:
  5403. m.ClearDeletedAt()
  5404. return nil
  5405. case batchmsg.FieldStatus:
  5406. m.ClearStatus()
  5407. return nil
  5408. case batchmsg.FieldBatchNo:
  5409. m.ClearBatchNo()
  5410. return nil
  5411. case batchmsg.FieldTaskName:
  5412. m.ClearTaskName()
  5413. return nil
  5414. case batchmsg.FieldFromwxid:
  5415. m.ClearFromwxid()
  5416. return nil
  5417. case batchmsg.FieldMsg:
  5418. m.ClearMsg()
  5419. return nil
  5420. case batchmsg.FieldTag:
  5421. m.ClearTag()
  5422. return nil
  5423. case batchmsg.FieldTagids:
  5424. m.ClearTagids()
  5425. return nil
  5426. case batchmsg.FieldTotal:
  5427. m.ClearTotal()
  5428. return nil
  5429. case batchmsg.FieldSuccess:
  5430. m.ClearSuccess()
  5431. return nil
  5432. case batchmsg.FieldFail:
  5433. m.ClearFail()
  5434. return nil
  5435. case batchmsg.FieldStartTime:
  5436. m.ClearStartTime()
  5437. return nil
  5438. case batchmsg.FieldStopTime:
  5439. m.ClearStopTime()
  5440. return nil
  5441. case batchmsg.FieldSendTime:
  5442. m.ClearSendTime()
  5443. return nil
  5444. case batchmsg.FieldType:
  5445. m.ClearType()
  5446. return nil
  5447. }
  5448. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5449. }
  5450. // ResetField resets all changes in the mutation for the field with the given name.
  5451. // It returns an error if the field is not defined in the schema.
  5452. func (m *BatchMsgMutation) ResetField(name string) error {
  5453. switch name {
  5454. case batchmsg.FieldCreatedAt:
  5455. m.ResetCreatedAt()
  5456. return nil
  5457. case batchmsg.FieldUpdatedAt:
  5458. m.ResetUpdatedAt()
  5459. return nil
  5460. case batchmsg.FieldDeletedAt:
  5461. m.ResetDeletedAt()
  5462. return nil
  5463. case batchmsg.FieldStatus:
  5464. m.ResetStatus()
  5465. return nil
  5466. case batchmsg.FieldBatchNo:
  5467. m.ResetBatchNo()
  5468. return nil
  5469. case batchmsg.FieldTaskName:
  5470. m.ResetTaskName()
  5471. return nil
  5472. case batchmsg.FieldFromwxid:
  5473. m.ResetFromwxid()
  5474. return nil
  5475. case batchmsg.FieldMsg:
  5476. m.ResetMsg()
  5477. return nil
  5478. case batchmsg.FieldTag:
  5479. m.ResetTag()
  5480. return nil
  5481. case batchmsg.FieldTagids:
  5482. m.ResetTagids()
  5483. return nil
  5484. case batchmsg.FieldTotal:
  5485. m.ResetTotal()
  5486. return nil
  5487. case batchmsg.FieldSuccess:
  5488. m.ResetSuccess()
  5489. return nil
  5490. case batchmsg.FieldFail:
  5491. m.ResetFail()
  5492. return nil
  5493. case batchmsg.FieldStartTime:
  5494. m.ResetStartTime()
  5495. return nil
  5496. case batchmsg.FieldStopTime:
  5497. m.ResetStopTime()
  5498. return nil
  5499. case batchmsg.FieldSendTime:
  5500. m.ResetSendTime()
  5501. return nil
  5502. case batchmsg.FieldType:
  5503. m.ResetType()
  5504. return nil
  5505. case batchmsg.FieldOrganizationID:
  5506. m.ResetOrganizationID()
  5507. return nil
  5508. }
  5509. return fmt.Errorf("unknown BatchMsg field %s", name)
  5510. }
  5511. // AddedEdges returns all edge names that were set/added in this mutation.
  5512. func (m *BatchMsgMutation) AddedEdges() []string {
  5513. edges := make([]string, 0, 0)
  5514. return edges
  5515. }
  5516. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5517. // name in this mutation.
  5518. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5519. return nil
  5520. }
  5521. // RemovedEdges returns all edge names that were removed in this mutation.
  5522. func (m *BatchMsgMutation) RemovedEdges() []string {
  5523. edges := make([]string, 0, 0)
  5524. return edges
  5525. }
  5526. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5527. // the given name in this mutation.
  5528. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5529. return nil
  5530. }
  5531. // ClearedEdges returns all edge names that were cleared in this mutation.
  5532. func (m *BatchMsgMutation) ClearedEdges() []string {
  5533. edges := make([]string, 0, 0)
  5534. return edges
  5535. }
  5536. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5537. // was cleared in this mutation.
  5538. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5539. return false
  5540. }
  5541. // ClearEdge clears the value of the edge with the given name. It returns an error
  5542. // if that edge is not defined in the schema.
  5543. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5544. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5545. }
  5546. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5547. // It returns an error if the edge is not defined in the schema.
  5548. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5549. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5550. }
  5551. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5552. type CategoryMutation struct {
  5553. config
  5554. op Op
  5555. typ string
  5556. id *uint64
  5557. created_at *time.Time
  5558. updated_at *time.Time
  5559. deleted_at *time.Time
  5560. name *string
  5561. organization_id *uint64
  5562. addorganization_id *int64
  5563. clearedFields map[string]struct{}
  5564. done bool
  5565. oldValue func(context.Context) (*Category, error)
  5566. predicates []predicate.Category
  5567. }
  5568. var _ ent.Mutation = (*CategoryMutation)(nil)
  5569. // categoryOption allows management of the mutation configuration using functional options.
  5570. type categoryOption func(*CategoryMutation)
  5571. // newCategoryMutation creates new mutation for the Category entity.
  5572. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5573. m := &CategoryMutation{
  5574. config: c,
  5575. op: op,
  5576. typ: TypeCategory,
  5577. clearedFields: make(map[string]struct{}),
  5578. }
  5579. for _, opt := range opts {
  5580. opt(m)
  5581. }
  5582. return m
  5583. }
  5584. // withCategoryID sets the ID field of the mutation.
  5585. func withCategoryID(id uint64) categoryOption {
  5586. return func(m *CategoryMutation) {
  5587. var (
  5588. err error
  5589. once sync.Once
  5590. value *Category
  5591. )
  5592. m.oldValue = func(ctx context.Context) (*Category, error) {
  5593. once.Do(func() {
  5594. if m.done {
  5595. err = errors.New("querying old values post mutation is not allowed")
  5596. } else {
  5597. value, err = m.Client().Category.Get(ctx, id)
  5598. }
  5599. })
  5600. return value, err
  5601. }
  5602. m.id = &id
  5603. }
  5604. }
  5605. // withCategory sets the old Category of the mutation.
  5606. func withCategory(node *Category) categoryOption {
  5607. return func(m *CategoryMutation) {
  5608. m.oldValue = func(context.Context) (*Category, error) {
  5609. return node, nil
  5610. }
  5611. m.id = &node.ID
  5612. }
  5613. }
  5614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5615. // executed in a transaction (ent.Tx), a transactional client is returned.
  5616. func (m CategoryMutation) Client() *Client {
  5617. client := &Client{config: m.config}
  5618. client.init()
  5619. return client
  5620. }
  5621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5622. // it returns an error otherwise.
  5623. func (m CategoryMutation) Tx() (*Tx, error) {
  5624. if _, ok := m.driver.(*txDriver); !ok {
  5625. return nil, errors.New("ent: mutation is not running in a transaction")
  5626. }
  5627. tx := &Tx{config: m.config}
  5628. tx.init()
  5629. return tx, nil
  5630. }
  5631. // SetID sets the value of the id field. Note that this
  5632. // operation is only accepted on creation of Category entities.
  5633. func (m *CategoryMutation) SetID(id uint64) {
  5634. m.id = &id
  5635. }
  5636. // ID returns the ID value in the mutation. Note that the ID is only available
  5637. // if it was provided to the builder or after it was returned from the database.
  5638. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5639. if m.id == nil {
  5640. return
  5641. }
  5642. return *m.id, true
  5643. }
  5644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5645. // That means, if the mutation is applied within a transaction with an isolation level such
  5646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5647. // or updated by the mutation.
  5648. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5649. switch {
  5650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5651. id, exists := m.ID()
  5652. if exists {
  5653. return []uint64{id}, nil
  5654. }
  5655. fallthrough
  5656. case m.op.Is(OpUpdate | OpDelete):
  5657. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5658. default:
  5659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5660. }
  5661. }
  5662. // SetCreatedAt sets the "created_at" field.
  5663. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5664. m.created_at = &t
  5665. }
  5666. // CreatedAt returns the value of the "created_at" field in the mutation.
  5667. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5668. v := m.created_at
  5669. if v == nil {
  5670. return
  5671. }
  5672. return *v, true
  5673. }
  5674. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5675. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5677. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5678. if !m.op.Is(OpUpdateOne) {
  5679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5680. }
  5681. if m.id == nil || m.oldValue == nil {
  5682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5683. }
  5684. oldValue, err := m.oldValue(ctx)
  5685. if err != nil {
  5686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5687. }
  5688. return oldValue.CreatedAt, nil
  5689. }
  5690. // ResetCreatedAt resets all changes to the "created_at" field.
  5691. func (m *CategoryMutation) ResetCreatedAt() {
  5692. m.created_at = nil
  5693. }
  5694. // SetUpdatedAt sets the "updated_at" field.
  5695. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5696. m.updated_at = &t
  5697. }
  5698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5699. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5700. v := m.updated_at
  5701. if v == nil {
  5702. return
  5703. }
  5704. return *v, true
  5705. }
  5706. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5707. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5709. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5710. if !m.op.Is(OpUpdateOne) {
  5711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5712. }
  5713. if m.id == nil || m.oldValue == nil {
  5714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5715. }
  5716. oldValue, err := m.oldValue(ctx)
  5717. if err != nil {
  5718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5719. }
  5720. return oldValue.UpdatedAt, nil
  5721. }
  5722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5723. func (m *CategoryMutation) ResetUpdatedAt() {
  5724. m.updated_at = nil
  5725. }
  5726. // SetDeletedAt sets the "deleted_at" field.
  5727. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5728. m.deleted_at = &t
  5729. }
  5730. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5731. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5732. v := m.deleted_at
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5739. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5741. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5747. }
  5748. oldValue, err := m.oldValue(ctx)
  5749. if err != nil {
  5750. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5751. }
  5752. return oldValue.DeletedAt, nil
  5753. }
  5754. // ClearDeletedAt clears the value of the "deleted_at" field.
  5755. func (m *CategoryMutation) ClearDeletedAt() {
  5756. m.deleted_at = nil
  5757. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5758. }
  5759. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5760. func (m *CategoryMutation) DeletedAtCleared() bool {
  5761. _, ok := m.clearedFields[category.FieldDeletedAt]
  5762. return ok
  5763. }
  5764. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5765. func (m *CategoryMutation) ResetDeletedAt() {
  5766. m.deleted_at = nil
  5767. delete(m.clearedFields, category.FieldDeletedAt)
  5768. }
  5769. // SetName sets the "name" field.
  5770. func (m *CategoryMutation) SetName(s string) {
  5771. m.name = &s
  5772. }
  5773. // Name returns the value of the "name" field in the mutation.
  5774. func (m *CategoryMutation) Name() (r string, exists bool) {
  5775. v := m.name
  5776. if v == nil {
  5777. return
  5778. }
  5779. return *v, true
  5780. }
  5781. // OldName returns the old "name" field's value of the Category entity.
  5782. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5784. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5785. if !m.op.Is(OpUpdateOne) {
  5786. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5787. }
  5788. if m.id == nil || m.oldValue == nil {
  5789. return v, errors.New("OldName requires an ID field in the mutation")
  5790. }
  5791. oldValue, err := m.oldValue(ctx)
  5792. if err != nil {
  5793. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5794. }
  5795. return oldValue.Name, nil
  5796. }
  5797. // ResetName resets all changes to the "name" field.
  5798. func (m *CategoryMutation) ResetName() {
  5799. m.name = nil
  5800. }
  5801. // SetOrganizationID sets the "organization_id" field.
  5802. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5803. m.organization_id = &u
  5804. m.addorganization_id = nil
  5805. }
  5806. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5807. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5808. v := m.organization_id
  5809. if v == nil {
  5810. return
  5811. }
  5812. return *v, true
  5813. }
  5814. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5815. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5817. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5818. if !m.op.Is(OpUpdateOne) {
  5819. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5820. }
  5821. if m.id == nil || m.oldValue == nil {
  5822. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5823. }
  5824. oldValue, err := m.oldValue(ctx)
  5825. if err != nil {
  5826. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5827. }
  5828. return oldValue.OrganizationID, nil
  5829. }
  5830. // AddOrganizationID adds u to the "organization_id" field.
  5831. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5832. if m.addorganization_id != nil {
  5833. *m.addorganization_id += u
  5834. } else {
  5835. m.addorganization_id = &u
  5836. }
  5837. }
  5838. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5839. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5840. v := m.addorganization_id
  5841. if v == nil {
  5842. return
  5843. }
  5844. return *v, true
  5845. }
  5846. // ResetOrganizationID resets all changes to the "organization_id" field.
  5847. func (m *CategoryMutation) ResetOrganizationID() {
  5848. m.organization_id = nil
  5849. m.addorganization_id = nil
  5850. }
  5851. // Where appends a list predicates to the CategoryMutation builder.
  5852. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5853. m.predicates = append(m.predicates, ps...)
  5854. }
  5855. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5856. // users can use type-assertion to append predicates that do not depend on any generated package.
  5857. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5858. p := make([]predicate.Category, len(ps))
  5859. for i := range ps {
  5860. p[i] = ps[i]
  5861. }
  5862. m.Where(p...)
  5863. }
  5864. // Op returns the operation name.
  5865. func (m *CategoryMutation) Op() Op {
  5866. return m.op
  5867. }
  5868. // SetOp allows setting the mutation operation.
  5869. func (m *CategoryMutation) SetOp(op Op) {
  5870. m.op = op
  5871. }
  5872. // Type returns the node type of this mutation (Category).
  5873. func (m *CategoryMutation) Type() string {
  5874. return m.typ
  5875. }
  5876. // Fields returns all fields that were changed during this mutation. Note that in
  5877. // order to get all numeric fields that were incremented/decremented, call
  5878. // AddedFields().
  5879. func (m *CategoryMutation) Fields() []string {
  5880. fields := make([]string, 0, 5)
  5881. if m.created_at != nil {
  5882. fields = append(fields, category.FieldCreatedAt)
  5883. }
  5884. if m.updated_at != nil {
  5885. fields = append(fields, category.FieldUpdatedAt)
  5886. }
  5887. if m.deleted_at != nil {
  5888. fields = append(fields, category.FieldDeletedAt)
  5889. }
  5890. if m.name != nil {
  5891. fields = append(fields, category.FieldName)
  5892. }
  5893. if m.organization_id != nil {
  5894. fields = append(fields, category.FieldOrganizationID)
  5895. }
  5896. return fields
  5897. }
  5898. // Field returns the value of a field with the given name. The second boolean
  5899. // return value indicates that this field was not set, or was not defined in the
  5900. // schema.
  5901. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5902. switch name {
  5903. case category.FieldCreatedAt:
  5904. return m.CreatedAt()
  5905. case category.FieldUpdatedAt:
  5906. return m.UpdatedAt()
  5907. case category.FieldDeletedAt:
  5908. return m.DeletedAt()
  5909. case category.FieldName:
  5910. return m.Name()
  5911. case category.FieldOrganizationID:
  5912. return m.OrganizationID()
  5913. }
  5914. return nil, false
  5915. }
  5916. // OldField returns the old value of the field from the database. An error is
  5917. // returned if the mutation operation is not UpdateOne, or the query to the
  5918. // database failed.
  5919. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5920. switch name {
  5921. case category.FieldCreatedAt:
  5922. return m.OldCreatedAt(ctx)
  5923. case category.FieldUpdatedAt:
  5924. return m.OldUpdatedAt(ctx)
  5925. case category.FieldDeletedAt:
  5926. return m.OldDeletedAt(ctx)
  5927. case category.FieldName:
  5928. return m.OldName(ctx)
  5929. case category.FieldOrganizationID:
  5930. return m.OldOrganizationID(ctx)
  5931. }
  5932. return nil, fmt.Errorf("unknown Category field %s", name)
  5933. }
  5934. // SetField sets the value of a field with the given name. It returns an error if
  5935. // the field is not defined in the schema, or if the type mismatched the field
  5936. // type.
  5937. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5938. switch name {
  5939. case category.FieldCreatedAt:
  5940. v, ok := value.(time.Time)
  5941. if !ok {
  5942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5943. }
  5944. m.SetCreatedAt(v)
  5945. return nil
  5946. case category.FieldUpdatedAt:
  5947. v, ok := value.(time.Time)
  5948. if !ok {
  5949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5950. }
  5951. m.SetUpdatedAt(v)
  5952. return nil
  5953. case category.FieldDeletedAt:
  5954. v, ok := value.(time.Time)
  5955. if !ok {
  5956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5957. }
  5958. m.SetDeletedAt(v)
  5959. return nil
  5960. case category.FieldName:
  5961. v, ok := value.(string)
  5962. if !ok {
  5963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5964. }
  5965. m.SetName(v)
  5966. return nil
  5967. case category.FieldOrganizationID:
  5968. v, ok := value.(uint64)
  5969. if !ok {
  5970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5971. }
  5972. m.SetOrganizationID(v)
  5973. return nil
  5974. }
  5975. return fmt.Errorf("unknown Category field %s", name)
  5976. }
  5977. // AddedFields returns all numeric fields that were incremented/decremented during
  5978. // this mutation.
  5979. func (m *CategoryMutation) AddedFields() []string {
  5980. var fields []string
  5981. if m.addorganization_id != nil {
  5982. fields = append(fields, category.FieldOrganizationID)
  5983. }
  5984. return fields
  5985. }
  5986. // AddedField returns the numeric value that was incremented/decremented on a field
  5987. // with the given name. The second boolean return value indicates that this field
  5988. // was not set, or was not defined in the schema.
  5989. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5990. switch name {
  5991. case category.FieldOrganizationID:
  5992. return m.AddedOrganizationID()
  5993. }
  5994. return nil, false
  5995. }
  5996. // AddField adds the value to the field with the given name. It returns an error if
  5997. // the field is not defined in the schema, or if the type mismatched the field
  5998. // type.
  5999. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6000. switch name {
  6001. case category.FieldOrganizationID:
  6002. v, ok := value.(int64)
  6003. if !ok {
  6004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6005. }
  6006. m.AddOrganizationID(v)
  6007. return nil
  6008. }
  6009. return fmt.Errorf("unknown Category numeric field %s", name)
  6010. }
  6011. // ClearedFields returns all nullable fields that were cleared during this
  6012. // mutation.
  6013. func (m *CategoryMutation) ClearedFields() []string {
  6014. var fields []string
  6015. if m.FieldCleared(category.FieldDeletedAt) {
  6016. fields = append(fields, category.FieldDeletedAt)
  6017. }
  6018. return fields
  6019. }
  6020. // FieldCleared returns a boolean indicating if a field with the given name was
  6021. // cleared in this mutation.
  6022. func (m *CategoryMutation) FieldCleared(name string) bool {
  6023. _, ok := m.clearedFields[name]
  6024. return ok
  6025. }
  6026. // ClearField clears the value of the field with the given name. It returns an
  6027. // error if the field is not defined in the schema.
  6028. func (m *CategoryMutation) ClearField(name string) error {
  6029. switch name {
  6030. case category.FieldDeletedAt:
  6031. m.ClearDeletedAt()
  6032. return nil
  6033. }
  6034. return fmt.Errorf("unknown Category nullable field %s", name)
  6035. }
  6036. // ResetField resets all changes in the mutation for the field with the given name.
  6037. // It returns an error if the field is not defined in the schema.
  6038. func (m *CategoryMutation) ResetField(name string) error {
  6039. switch name {
  6040. case category.FieldCreatedAt:
  6041. m.ResetCreatedAt()
  6042. return nil
  6043. case category.FieldUpdatedAt:
  6044. m.ResetUpdatedAt()
  6045. return nil
  6046. case category.FieldDeletedAt:
  6047. m.ResetDeletedAt()
  6048. return nil
  6049. case category.FieldName:
  6050. m.ResetName()
  6051. return nil
  6052. case category.FieldOrganizationID:
  6053. m.ResetOrganizationID()
  6054. return nil
  6055. }
  6056. return fmt.Errorf("unknown Category field %s", name)
  6057. }
  6058. // AddedEdges returns all edge names that were set/added in this mutation.
  6059. func (m *CategoryMutation) AddedEdges() []string {
  6060. edges := make([]string, 0, 0)
  6061. return edges
  6062. }
  6063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6064. // name in this mutation.
  6065. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6066. return nil
  6067. }
  6068. // RemovedEdges returns all edge names that were removed in this mutation.
  6069. func (m *CategoryMutation) RemovedEdges() []string {
  6070. edges := make([]string, 0, 0)
  6071. return edges
  6072. }
  6073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6074. // the given name in this mutation.
  6075. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6076. return nil
  6077. }
  6078. // ClearedEdges returns all edge names that were cleared in this mutation.
  6079. func (m *CategoryMutation) ClearedEdges() []string {
  6080. edges := make([]string, 0, 0)
  6081. return edges
  6082. }
  6083. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6084. // was cleared in this mutation.
  6085. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6086. return false
  6087. }
  6088. // ClearEdge clears the value of the edge with the given name. It returns an error
  6089. // if that edge is not defined in the schema.
  6090. func (m *CategoryMutation) ClearEdge(name string) error {
  6091. return fmt.Errorf("unknown Category unique edge %s", name)
  6092. }
  6093. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6094. // It returns an error if the edge is not defined in the schema.
  6095. func (m *CategoryMutation) ResetEdge(name string) error {
  6096. return fmt.Errorf("unknown Category edge %s", name)
  6097. }
  6098. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6099. type ChatRecordsMutation struct {
  6100. config
  6101. op Op
  6102. typ string
  6103. id *uint64
  6104. created_at *time.Time
  6105. updated_at *time.Time
  6106. deleted_at *time.Time
  6107. content *string
  6108. content_type *uint8
  6109. addcontent_type *int8
  6110. session_id *uint64
  6111. addsession_id *int64
  6112. user_id *uint64
  6113. adduser_id *int64
  6114. bot_id *uint64
  6115. addbot_id *int64
  6116. bot_type *uint8
  6117. addbot_type *int8
  6118. clearedFields map[string]struct{}
  6119. done bool
  6120. oldValue func(context.Context) (*ChatRecords, error)
  6121. predicates []predicate.ChatRecords
  6122. }
  6123. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6124. // chatrecordsOption allows management of the mutation configuration using functional options.
  6125. type chatrecordsOption func(*ChatRecordsMutation)
  6126. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6127. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6128. m := &ChatRecordsMutation{
  6129. config: c,
  6130. op: op,
  6131. typ: TypeChatRecords,
  6132. clearedFields: make(map[string]struct{}),
  6133. }
  6134. for _, opt := range opts {
  6135. opt(m)
  6136. }
  6137. return m
  6138. }
  6139. // withChatRecordsID sets the ID field of the mutation.
  6140. func withChatRecordsID(id uint64) chatrecordsOption {
  6141. return func(m *ChatRecordsMutation) {
  6142. var (
  6143. err error
  6144. once sync.Once
  6145. value *ChatRecords
  6146. )
  6147. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6148. once.Do(func() {
  6149. if m.done {
  6150. err = errors.New("querying old values post mutation is not allowed")
  6151. } else {
  6152. value, err = m.Client().ChatRecords.Get(ctx, id)
  6153. }
  6154. })
  6155. return value, err
  6156. }
  6157. m.id = &id
  6158. }
  6159. }
  6160. // withChatRecords sets the old ChatRecords of the mutation.
  6161. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6162. return func(m *ChatRecordsMutation) {
  6163. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6164. return node, nil
  6165. }
  6166. m.id = &node.ID
  6167. }
  6168. }
  6169. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6170. // executed in a transaction (ent.Tx), a transactional client is returned.
  6171. func (m ChatRecordsMutation) Client() *Client {
  6172. client := &Client{config: m.config}
  6173. client.init()
  6174. return client
  6175. }
  6176. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6177. // it returns an error otherwise.
  6178. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6179. if _, ok := m.driver.(*txDriver); !ok {
  6180. return nil, errors.New("ent: mutation is not running in a transaction")
  6181. }
  6182. tx := &Tx{config: m.config}
  6183. tx.init()
  6184. return tx, nil
  6185. }
  6186. // SetID sets the value of the id field. Note that this
  6187. // operation is only accepted on creation of ChatRecords entities.
  6188. func (m *ChatRecordsMutation) SetID(id uint64) {
  6189. m.id = &id
  6190. }
  6191. // ID returns the ID value in the mutation. Note that the ID is only available
  6192. // if it was provided to the builder or after it was returned from the database.
  6193. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6194. if m.id == nil {
  6195. return
  6196. }
  6197. return *m.id, true
  6198. }
  6199. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6200. // That means, if the mutation is applied within a transaction with an isolation level such
  6201. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6202. // or updated by the mutation.
  6203. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6204. switch {
  6205. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6206. id, exists := m.ID()
  6207. if exists {
  6208. return []uint64{id}, nil
  6209. }
  6210. fallthrough
  6211. case m.op.Is(OpUpdate | OpDelete):
  6212. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6213. default:
  6214. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6215. }
  6216. }
  6217. // SetCreatedAt sets the "created_at" field.
  6218. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6219. m.created_at = &t
  6220. }
  6221. // CreatedAt returns the value of the "created_at" field in the mutation.
  6222. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6223. v := m.created_at
  6224. if v == nil {
  6225. return
  6226. }
  6227. return *v, true
  6228. }
  6229. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6230. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6232. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6233. if !m.op.Is(OpUpdateOne) {
  6234. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6235. }
  6236. if m.id == nil || m.oldValue == nil {
  6237. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6238. }
  6239. oldValue, err := m.oldValue(ctx)
  6240. if err != nil {
  6241. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6242. }
  6243. return oldValue.CreatedAt, nil
  6244. }
  6245. // ResetCreatedAt resets all changes to the "created_at" field.
  6246. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6247. m.created_at = nil
  6248. }
  6249. // SetUpdatedAt sets the "updated_at" field.
  6250. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6251. m.updated_at = &t
  6252. }
  6253. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6254. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6255. v := m.updated_at
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6262. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6274. }
  6275. return oldValue.UpdatedAt, nil
  6276. }
  6277. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6278. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6279. m.updated_at = nil
  6280. }
  6281. // SetDeletedAt sets the "deleted_at" field.
  6282. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6283. m.deleted_at = &t
  6284. }
  6285. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6286. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6287. v := m.deleted_at
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6294. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6296. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6297. if !m.op.Is(OpUpdateOne) {
  6298. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6299. }
  6300. if m.id == nil || m.oldValue == nil {
  6301. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6302. }
  6303. oldValue, err := m.oldValue(ctx)
  6304. if err != nil {
  6305. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6306. }
  6307. return oldValue.DeletedAt, nil
  6308. }
  6309. // ClearDeletedAt clears the value of the "deleted_at" field.
  6310. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6311. m.deleted_at = nil
  6312. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6313. }
  6314. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6315. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6316. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6317. return ok
  6318. }
  6319. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6320. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6321. m.deleted_at = nil
  6322. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6323. }
  6324. // SetContent sets the "content" field.
  6325. func (m *ChatRecordsMutation) SetContent(s string) {
  6326. m.content = &s
  6327. }
  6328. // Content returns the value of the "content" field in the mutation.
  6329. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6330. v := m.content
  6331. if v == nil {
  6332. return
  6333. }
  6334. return *v, true
  6335. }
  6336. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6337. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6339. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6340. if !m.op.Is(OpUpdateOne) {
  6341. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6342. }
  6343. if m.id == nil || m.oldValue == nil {
  6344. return v, errors.New("OldContent requires an ID field in the mutation")
  6345. }
  6346. oldValue, err := m.oldValue(ctx)
  6347. if err != nil {
  6348. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6349. }
  6350. return oldValue.Content, nil
  6351. }
  6352. // ResetContent resets all changes to the "content" field.
  6353. func (m *ChatRecordsMutation) ResetContent() {
  6354. m.content = nil
  6355. }
  6356. // SetContentType sets the "content_type" field.
  6357. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6358. m.content_type = &u
  6359. m.addcontent_type = nil
  6360. }
  6361. // ContentType returns the value of the "content_type" field in the mutation.
  6362. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6363. v := m.content_type
  6364. if v == nil {
  6365. return
  6366. }
  6367. return *v, true
  6368. }
  6369. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6370. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6372. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6373. if !m.op.Is(OpUpdateOne) {
  6374. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6375. }
  6376. if m.id == nil || m.oldValue == nil {
  6377. return v, errors.New("OldContentType requires an ID field in the mutation")
  6378. }
  6379. oldValue, err := m.oldValue(ctx)
  6380. if err != nil {
  6381. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6382. }
  6383. return oldValue.ContentType, nil
  6384. }
  6385. // AddContentType adds u to the "content_type" field.
  6386. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6387. if m.addcontent_type != nil {
  6388. *m.addcontent_type += u
  6389. } else {
  6390. m.addcontent_type = &u
  6391. }
  6392. }
  6393. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6394. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6395. v := m.addcontent_type
  6396. if v == nil {
  6397. return
  6398. }
  6399. return *v, true
  6400. }
  6401. // ResetContentType resets all changes to the "content_type" field.
  6402. func (m *ChatRecordsMutation) ResetContentType() {
  6403. m.content_type = nil
  6404. m.addcontent_type = nil
  6405. }
  6406. // SetSessionID sets the "session_id" field.
  6407. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6408. m.session_id = &u
  6409. m.addsession_id = nil
  6410. }
  6411. // SessionID returns the value of the "session_id" field in the mutation.
  6412. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6413. v := m.session_id
  6414. if v == nil {
  6415. return
  6416. }
  6417. return *v, true
  6418. }
  6419. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6420. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6422. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6423. if !m.op.Is(OpUpdateOne) {
  6424. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6425. }
  6426. if m.id == nil || m.oldValue == nil {
  6427. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6428. }
  6429. oldValue, err := m.oldValue(ctx)
  6430. if err != nil {
  6431. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6432. }
  6433. return oldValue.SessionID, nil
  6434. }
  6435. // AddSessionID adds u to the "session_id" field.
  6436. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6437. if m.addsession_id != nil {
  6438. *m.addsession_id += u
  6439. } else {
  6440. m.addsession_id = &u
  6441. }
  6442. }
  6443. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6444. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6445. v := m.addsession_id
  6446. if v == nil {
  6447. return
  6448. }
  6449. return *v, true
  6450. }
  6451. // ResetSessionID resets all changes to the "session_id" field.
  6452. func (m *ChatRecordsMutation) ResetSessionID() {
  6453. m.session_id = nil
  6454. m.addsession_id = nil
  6455. }
  6456. // SetUserID sets the "user_id" field.
  6457. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6458. m.user_id = &u
  6459. m.adduser_id = nil
  6460. }
  6461. // UserID returns the value of the "user_id" field in the mutation.
  6462. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6463. v := m.user_id
  6464. if v == nil {
  6465. return
  6466. }
  6467. return *v, true
  6468. }
  6469. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6470. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6472. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6473. if !m.op.Is(OpUpdateOne) {
  6474. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6475. }
  6476. if m.id == nil || m.oldValue == nil {
  6477. return v, errors.New("OldUserID requires an ID field in the mutation")
  6478. }
  6479. oldValue, err := m.oldValue(ctx)
  6480. if err != nil {
  6481. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6482. }
  6483. return oldValue.UserID, nil
  6484. }
  6485. // AddUserID adds u to the "user_id" field.
  6486. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6487. if m.adduser_id != nil {
  6488. *m.adduser_id += u
  6489. } else {
  6490. m.adduser_id = &u
  6491. }
  6492. }
  6493. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6494. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6495. v := m.adduser_id
  6496. if v == nil {
  6497. return
  6498. }
  6499. return *v, true
  6500. }
  6501. // ResetUserID resets all changes to the "user_id" field.
  6502. func (m *ChatRecordsMutation) ResetUserID() {
  6503. m.user_id = nil
  6504. m.adduser_id = nil
  6505. }
  6506. // SetBotID sets the "bot_id" field.
  6507. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6508. m.bot_id = &u
  6509. m.addbot_id = nil
  6510. }
  6511. // BotID returns the value of the "bot_id" field in the mutation.
  6512. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6513. v := m.bot_id
  6514. if v == nil {
  6515. return
  6516. }
  6517. return *v, true
  6518. }
  6519. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6520. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6522. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6523. if !m.op.Is(OpUpdateOne) {
  6524. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6525. }
  6526. if m.id == nil || m.oldValue == nil {
  6527. return v, errors.New("OldBotID requires an ID field in the mutation")
  6528. }
  6529. oldValue, err := m.oldValue(ctx)
  6530. if err != nil {
  6531. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6532. }
  6533. return oldValue.BotID, nil
  6534. }
  6535. // AddBotID adds u to the "bot_id" field.
  6536. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6537. if m.addbot_id != nil {
  6538. *m.addbot_id += u
  6539. } else {
  6540. m.addbot_id = &u
  6541. }
  6542. }
  6543. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6544. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6545. v := m.addbot_id
  6546. if v == nil {
  6547. return
  6548. }
  6549. return *v, true
  6550. }
  6551. // ResetBotID resets all changes to the "bot_id" field.
  6552. func (m *ChatRecordsMutation) ResetBotID() {
  6553. m.bot_id = nil
  6554. m.addbot_id = nil
  6555. }
  6556. // SetBotType sets the "bot_type" field.
  6557. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6558. m.bot_type = &u
  6559. m.addbot_type = nil
  6560. }
  6561. // BotType returns the value of the "bot_type" field in the mutation.
  6562. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6563. v := m.bot_type
  6564. if v == nil {
  6565. return
  6566. }
  6567. return *v, true
  6568. }
  6569. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6570. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6572. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6573. if !m.op.Is(OpUpdateOne) {
  6574. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6575. }
  6576. if m.id == nil || m.oldValue == nil {
  6577. return v, errors.New("OldBotType requires an ID field in the mutation")
  6578. }
  6579. oldValue, err := m.oldValue(ctx)
  6580. if err != nil {
  6581. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6582. }
  6583. return oldValue.BotType, nil
  6584. }
  6585. // AddBotType adds u to the "bot_type" field.
  6586. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6587. if m.addbot_type != nil {
  6588. *m.addbot_type += u
  6589. } else {
  6590. m.addbot_type = &u
  6591. }
  6592. }
  6593. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6594. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6595. v := m.addbot_type
  6596. if v == nil {
  6597. return
  6598. }
  6599. return *v, true
  6600. }
  6601. // ResetBotType resets all changes to the "bot_type" field.
  6602. func (m *ChatRecordsMutation) ResetBotType() {
  6603. m.bot_type = nil
  6604. m.addbot_type = nil
  6605. }
  6606. // Where appends a list predicates to the ChatRecordsMutation builder.
  6607. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6608. m.predicates = append(m.predicates, ps...)
  6609. }
  6610. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6611. // users can use type-assertion to append predicates that do not depend on any generated package.
  6612. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6613. p := make([]predicate.ChatRecords, len(ps))
  6614. for i := range ps {
  6615. p[i] = ps[i]
  6616. }
  6617. m.Where(p...)
  6618. }
  6619. // Op returns the operation name.
  6620. func (m *ChatRecordsMutation) Op() Op {
  6621. return m.op
  6622. }
  6623. // SetOp allows setting the mutation operation.
  6624. func (m *ChatRecordsMutation) SetOp(op Op) {
  6625. m.op = op
  6626. }
  6627. // Type returns the node type of this mutation (ChatRecords).
  6628. func (m *ChatRecordsMutation) Type() string {
  6629. return m.typ
  6630. }
  6631. // Fields returns all fields that were changed during this mutation. Note that in
  6632. // order to get all numeric fields that were incremented/decremented, call
  6633. // AddedFields().
  6634. func (m *ChatRecordsMutation) Fields() []string {
  6635. fields := make([]string, 0, 9)
  6636. if m.created_at != nil {
  6637. fields = append(fields, chatrecords.FieldCreatedAt)
  6638. }
  6639. if m.updated_at != nil {
  6640. fields = append(fields, chatrecords.FieldUpdatedAt)
  6641. }
  6642. if m.deleted_at != nil {
  6643. fields = append(fields, chatrecords.FieldDeletedAt)
  6644. }
  6645. if m.content != nil {
  6646. fields = append(fields, chatrecords.FieldContent)
  6647. }
  6648. if m.content_type != nil {
  6649. fields = append(fields, chatrecords.FieldContentType)
  6650. }
  6651. if m.session_id != nil {
  6652. fields = append(fields, chatrecords.FieldSessionID)
  6653. }
  6654. if m.user_id != nil {
  6655. fields = append(fields, chatrecords.FieldUserID)
  6656. }
  6657. if m.bot_id != nil {
  6658. fields = append(fields, chatrecords.FieldBotID)
  6659. }
  6660. if m.bot_type != nil {
  6661. fields = append(fields, chatrecords.FieldBotType)
  6662. }
  6663. return fields
  6664. }
  6665. // Field returns the value of a field with the given name. The second boolean
  6666. // return value indicates that this field was not set, or was not defined in the
  6667. // schema.
  6668. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6669. switch name {
  6670. case chatrecords.FieldCreatedAt:
  6671. return m.CreatedAt()
  6672. case chatrecords.FieldUpdatedAt:
  6673. return m.UpdatedAt()
  6674. case chatrecords.FieldDeletedAt:
  6675. return m.DeletedAt()
  6676. case chatrecords.FieldContent:
  6677. return m.Content()
  6678. case chatrecords.FieldContentType:
  6679. return m.ContentType()
  6680. case chatrecords.FieldSessionID:
  6681. return m.SessionID()
  6682. case chatrecords.FieldUserID:
  6683. return m.UserID()
  6684. case chatrecords.FieldBotID:
  6685. return m.BotID()
  6686. case chatrecords.FieldBotType:
  6687. return m.BotType()
  6688. }
  6689. return nil, false
  6690. }
  6691. // OldField returns the old value of the field from the database. An error is
  6692. // returned if the mutation operation is not UpdateOne, or the query to the
  6693. // database failed.
  6694. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6695. switch name {
  6696. case chatrecords.FieldCreatedAt:
  6697. return m.OldCreatedAt(ctx)
  6698. case chatrecords.FieldUpdatedAt:
  6699. return m.OldUpdatedAt(ctx)
  6700. case chatrecords.FieldDeletedAt:
  6701. return m.OldDeletedAt(ctx)
  6702. case chatrecords.FieldContent:
  6703. return m.OldContent(ctx)
  6704. case chatrecords.FieldContentType:
  6705. return m.OldContentType(ctx)
  6706. case chatrecords.FieldSessionID:
  6707. return m.OldSessionID(ctx)
  6708. case chatrecords.FieldUserID:
  6709. return m.OldUserID(ctx)
  6710. case chatrecords.FieldBotID:
  6711. return m.OldBotID(ctx)
  6712. case chatrecords.FieldBotType:
  6713. return m.OldBotType(ctx)
  6714. }
  6715. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6716. }
  6717. // SetField sets the value of a field with the given name. It returns an error if
  6718. // the field is not defined in the schema, or if the type mismatched the field
  6719. // type.
  6720. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6721. switch name {
  6722. case chatrecords.FieldCreatedAt:
  6723. v, ok := value.(time.Time)
  6724. if !ok {
  6725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6726. }
  6727. m.SetCreatedAt(v)
  6728. return nil
  6729. case chatrecords.FieldUpdatedAt:
  6730. v, ok := value.(time.Time)
  6731. if !ok {
  6732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6733. }
  6734. m.SetUpdatedAt(v)
  6735. return nil
  6736. case chatrecords.FieldDeletedAt:
  6737. v, ok := value.(time.Time)
  6738. if !ok {
  6739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6740. }
  6741. m.SetDeletedAt(v)
  6742. return nil
  6743. case chatrecords.FieldContent:
  6744. v, ok := value.(string)
  6745. if !ok {
  6746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6747. }
  6748. m.SetContent(v)
  6749. return nil
  6750. case chatrecords.FieldContentType:
  6751. v, ok := value.(uint8)
  6752. if !ok {
  6753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6754. }
  6755. m.SetContentType(v)
  6756. return nil
  6757. case chatrecords.FieldSessionID:
  6758. v, ok := value.(uint64)
  6759. if !ok {
  6760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6761. }
  6762. m.SetSessionID(v)
  6763. return nil
  6764. case chatrecords.FieldUserID:
  6765. v, ok := value.(uint64)
  6766. if !ok {
  6767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6768. }
  6769. m.SetUserID(v)
  6770. return nil
  6771. case chatrecords.FieldBotID:
  6772. v, ok := value.(uint64)
  6773. if !ok {
  6774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6775. }
  6776. m.SetBotID(v)
  6777. return nil
  6778. case chatrecords.FieldBotType:
  6779. v, ok := value.(uint8)
  6780. if !ok {
  6781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6782. }
  6783. m.SetBotType(v)
  6784. return nil
  6785. }
  6786. return fmt.Errorf("unknown ChatRecords field %s", name)
  6787. }
  6788. // AddedFields returns all numeric fields that were incremented/decremented during
  6789. // this mutation.
  6790. func (m *ChatRecordsMutation) AddedFields() []string {
  6791. var fields []string
  6792. if m.addcontent_type != nil {
  6793. fields = append(fields, chatrecords.FieldContentType)
  6794. }
  6795. if m.addsession_id != nil {
  6796. fields = append(fields, chatrecords.FieldSessionID)
  6797. }
  6798. if m.adduser_id != nil {
  6799. fields = append(fields, chatrecords.FieldUserID)
  6800. }
  6801. if m.addbot_id != nil {
  6802. fields = append(fields, chatrecords.FieldBotID)
  6803. }
  6804. if m.addbot_type != nil {
  6805. fields = append(fields, chatrecords.FieldBotType)
  6806. }
  6807. return fields
  6808. }
  6809. // AddedField returns the numeric value that was incremented/decremented on a field
  6810. // with the given name. The second boolean return value indicates that this field
  6811. // was not set, or was not defined in the schema.
  6812. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6813. switch name {
  6814. case chatrecords.FieldContentType:
  6815. return m.AddedContentType()
  6816. case chatrecords.FieldSessionID:
  6817. return m.AddedSessionID()
  6818. case chatrecords.FieldUserID:
  6819. return m.AddedUserID()
  6820. case chatrecords.FieldBotID:
  6821. return m.AddedBotID()
  6822. case chatrecords.FieldBotType:
  6823. return m.AddedBotType()
  6824. }
  6825. return nil, false
  6826. }
  6827. // AddField adds the value to the field with the given name. It returns an error if
  6828. // the field is not defined in the schema, or if the type mismatched the field
  6829. // type.
  6830. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6831. switch name {
  6832. case chatrecords.FieldContentType:
  6833. v, ok := value.(int8)
  6834. if !ok {
  6835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6836. }
  6837. m.AddContentType(v)
  6838. return nil
  6839. case chatrecords.FieldSessionID:
  6840. v, ok := value.(int64)
  6841. if !ok {
  6842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6843. }
  6844. m.AddSessionID(v)
  6845. return nil
  6846. case chatrecords.FieldUserID:
  6847. v, ok := value.(int64)
  6848. if !ok {
  6849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6850. }
  6851. m.AddUserID(v)
  6852. return nil
  6853. case chatrecords.FieldBotID:
  6854. v, ok := value.(int64)
  6855. if !ok {
  6856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6857. }
  6858. m.AddBotID(v)
  6859. return nil
  6860. case chatrecords.FieldBotType:
  6861. v, ok := value.(int8)
  6862. if !ok {
  6863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6864. }
  6865. m.AddBotType(v)
  6866. return nil
  6867. }
  6868. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6869. }
  6870. // ClearedFields returns all nullable fields that were cleared during this
  6871. // mutation.
  6872. func (m *ChatRecordsMutation) ClearedFields() []string {
  6873. var fields []string
  6874. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6875. fields = append(fields, chatrecords.FieldDeletedAt)
  6876. }
  6877. return fields
  6878. }
  6879. // FieldCleared returns a boolean indicating if a field with the given name was
  6880. // cleared in this mutation.
  6881. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6882. _, ok := m.clearedFields[name]
  6883. return ok
  6884. }
  6885. // ClearField clears the value of the field with the given name. It returns an
  6886. // error if the field is not defined in the schema.
  6887. func (m *ChatRecordsMutation) ClearField(name string) error {
  6888. switch name {
  6889. case chatrecords.FieldDeletedAt:
  6890. m.ClearDeletedAt()
  6891. return nil
  6892. }
  6893. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6894. }
  6895. // ResetField resets all changes in the mutation for the field with the given name.
  6896. // It returns an error if the field is not defined in the schema.
  6897. func (m *ChatRecordsMutation) ResetField(name string) error {
  6898. switch name {
  6899. case chatrecords.FieldCreatedAt:
  6900. m.ResetCreatedAt()
  6901. return nil
  6902. case chatrecords.FieldUpdatedAt:
  6903. m.ResetUpdatedAt()
  6904. return nil
  6905. case chatrecords.FieldDeletedAt:
  6906. m.ResetDeletedAt()
  6907. return nil
  6908. case chatrecords.FieldContent:
  6909. m.ResetContent()
  6910. return nil
  6911. case chatrecords.FieldContentType:
  6912. m.ResetContentType()
  6913. return nil
  6914. case chatrecords.FieldSessionID:
  6915. m.ResetSessionID()
  6916. return nil
  6917. case chatrecords.FieldUserID:
  6918. m.ResetUserID()
  6919. return nil
  6920. case chatrecords.FieldBotID:
  6921. m.ResetBotID()
  6922. return nil
  6923. case chatrecords.FieldBotType:
  6924. m.ResetBotType()
  6925. return nil
  6926. }
  6927. return fmt.Errorf("unknown ChatRecords field %s", name)
  6928. }
  6929. // AddedEdges returns all edge names that were set/added in this mutation.
  6930. func (m *ChatRecordsMutation) AddedEdges() []string {
  6931. edges := make([]string, 0, 0)
  6932. return edges
  6933. }
  6934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6935. // name in this mutation.
  6936. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6937. return nil
  6938. }
  6939. // RemovedEdges returns all edge names that were removed in this mutation.
  6940. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6941. edges := make([]string, 0, 0)
  6942. return edges
  6943. }
  6944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6945. // the given name in this mutation.
  6946. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6947. return nil
  6948. }
  6949. // ClearedEdges returns all edge names that were cleared in this mutation.
  6950. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6951. edges := make([]string, 0, 0)
  6952. return edges
  6953. }
  6954. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6955. // was cleared in this mutation.
  6956. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6957. return false
  6958. }
  6959. // ClearEdge clears the value of the edge with the given name. It returns an error
  6960. // if that edge is not defined in the schema.
  6961. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6962. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6963. }
  6964. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6965. // It returns an error if the edge is not defined in the schema.
  6966. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6967. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6968. }
  6969. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6970. type ChatSessionMutation struct {
  6971. config
  6972. op Op
  6973. typ string
  6974. id *uint64
  6975. created_at *time.Time
  6976. updated_at *time.Time
  6977. deleted_at *time.Time
  6978. name *string
  6979. user_id *uint64
  6980. adduser_id *int64
  6981. bot_id *uint64
  6982. addbot_id *int64
  6983. bot_type *uint8
  6984. addbot_type *int8
  6985. clearedFields map[string]struct{}
  6986. done bool
  6987. oldValue func(context.Context) (*ChatSession, error)
  6988. predicates []predicate.ChatSession
  6989. }
  6990. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6991. // chatsessionOption allows management of the mutation configuration using functional options.
  6992. type chatsessionOption func(*ChatSessionMutation)
  6993. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6994. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6995. m := &ChatSessionMutation{
  6996. config: c,
  6997. op: op,
  6998. typ: TypeChatSession,
  6999. clearedFields: make(map[string]struct{}),
  7000. }
  7001. for _, opt := range opts {
  7002. opt(m)
  7003. }
  7004. return m
  7005. }
  7006. // withChatSessionID sets the ID field of the mutation.
  7007. func withChatSessionID(id uint64) chatsessionOption {
  7008. return func(m *ChatSessionMutation) {
  7009. var (
  7010. err error
  7011. once sync.Once
  7012. value *ChatSession
  7013. )
  7014. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7015. once.Do(func() {
  7016. if m.done {
  7017. err = errors.New("querying old values post mutation is not allowed")
  7018. } else {
  7019. value, err = m.Client().ChatSession.Get(ctx, id)
  7020. }
  7021. })
  7022. return value, err
  7023. }
  7024. m.id = &id
  7025. }
  7026. }
  7027. // withChatSession sets the old ChatSession of the mutation.
  7028. func withChatSession(node *ChatSession) chatsessionOption {
  7029. return func(m *ChatSessionMutation) {
  7030. m.oldValue = func(context.Context) (*ChatSession, error) {
  7031. return node, nil
  7032. }
  7033. m.id = &node.ID
  7034. }
  7035. }
  7036. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7037. // executed in a transaction (ent.Tx), a transactional client is returned.
  7038. func (m ChatSessionMutation) Client() *Client {
  7039. client := &Client{config: m.config}
  7040. client.init()
  7041. return client
  7042. }
  7043. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7044. // it returns an error otherwise.
  7045. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7046. if _, ok := m.driver.(*txDriver); !ok {
  7047. return nil, errors.New("ent: mutation is not running in a transaction")
  7048. }
  7049. tx := &Tx{config: m.config}
  7050. tx.init()
  7051. return tx, nil
  7052. }
  7053. // SetID sets the value of the id field. Note that this
  7054. // operation is only accepted on creation of ChatSession entities.
  7055. func (m *ChatSessionMutation) SetID(id uint64) {
  7056. m.id = &id
  7057. }
  7058. // ID returns the ID value in the mutation. Note that the ID is only available
  7059. // if it was provided to the builder or after it was returned from the database.
  7060. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7061. if m.id == nil {
  7062. return
  7063. }
  7064. return *m.id, true
  7065. }
  7066. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7067. // That means, if the mutation is applied within a transaction with an isolation level such
  7068. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7069. // or updated by the mutation.
  7070. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7071. switch {
  7072. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7073. id, exists := m.ID()
  7074. if exists {
  7075. return []uint64{id}, nil
  7076. }
  7077. fallthrough
  7078. case m.op.Is(OpUpdate | OpDelete):
  7079. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7080. default:
  7081. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7082. }
  7083. }
  7084. // SetCreatedAt sets the "created_at" field.
  7085. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7086. m.created_at = &t
  7087. }
  7088. // CreatedAt returns the value of the "created_at" field in the mutation.
  7089. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7090. v := m.created_at
  7091. if v == nil {
  7092. return
  7093. }
  7094. return *v, true
  7095. }
  7096. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7097. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7099. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7100. if !m.op.Is(OpUpdateOne) {
  7101. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7102. }
  7103. if m.id == nil || m.oldValue == nil {
  7104. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7105. }
  7106. oldValue, err := m.oldValue(ctx)
  7107. if err != nil {
  7108. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7109. }
  7110. return oldValue.CreatedAt, nil
  7111. }
  7112. // ResetCreatedAt resets all changes to the "created_at" field.
  7113. func (m *ChatSessionMutation) ResetCreatedAt() {
  7114. m.created_at = nil
  7115. }
  7116. // SetUpdatedAt sets the "updated_at" field.
  7117. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7118. m.updated_at = &t
  7119. }
  7120. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7121. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7122. v := m.updated_at
  7123. if v == nil {
  7124. return
  7125. }
  7126. return *v, true
  7127. }
  7128. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7129. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7131. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7132. if !m.op.Is(OpUpdateOne) {
  7133. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7134. }
  7135. if m.id == nil || m.oldValue == nil {
  7136. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7137. }
  7138. oldValue, err := m.oldValue(ctx)
  7139. if err != nil {
  7140. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7141. }
  7142. return oldValue.UpdatedAt, nil
  7143. }
  7144. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7145. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7146. m.updated_at = nil
  7147. }
  7148. // SetDeletedAt sets the "deleted_at" field.
  7149. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7150. m.deleted_at = &t
  7151. }
  7152. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7153. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7154. v := m.deleted_at
  7155. if v == nil {
  7156. return
  7157. }
  7158. return *v, true
  7159. }
  7160. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7161. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7163. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7164. if !m.op.Is(OpUpdateOne) {
  7165. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7166. }
  7167. if m.id == nil || m.oldValue == nil {
  7168. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7169. }
  7170. oldValue, err := m.oldValue(ctx)
  7171. if err != nil {
  7172. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7173. }
  7174. return oldValue.DeletedAt, nil
  7175. }
  7176. // ClearDeletedAt clears the value of the "deleted_at" field.
  7177. func (m *ChatSessionMutation) ClearDeletedAt() {
  7178. m.deleted_at = nil
  7179. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7180. }
  7181. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7182. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7183. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7184. return ok
  7185. }
  7186. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7187. func (m *ChatSessionMutation) ResetDeletedAt() {
  7188. m.deleted_at = nil
  7189. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7190. }
  7191. // SetName sets the "name" field.
  7192. func (m *ChatSessionMutation) SetName(s string) {
  7193. m.name = &s
  7194. }
  7195. // Name returns the value of the "name" field in the mutation.
  7196. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7197. v := m.name
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // OldName returns the old "name" field's value of the ChatSession entity.
  7204. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7206. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7207. if !m.op.Is(OpUpdateOne) {
  7208. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7209. }
  7210. if m.id == nil || m.oldValue == nil {
  7211. return v, errors.New("OldName requires an ID field in the mutation")
  7212. }
  7213. oldValue, err := m.oldValue(ctx)
  7214. if err != nil {
  7215. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7216. }
  7217. return oldValue.Name, nil
  7218. }
  7219. // ResetName resets all changes to the "name" field.
  7220. func (m *ChatSessionMutation) ResetName() {
  7221. m.name = nil
  7222. }
  7223. // SetUserID sets the "user_id" field.
  7224. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7225. m.user_id = &u
  7226. m.adduser_id = nil
  7227. }
  7228. // UserID returns the value of the "user_id" field in the mutation.
  7229. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7230. v := m.user_id
  7231. if v == nil {
  7232. return
  7233. }
  7234. return *v, true
  7235. }
  7236. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7237. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7239. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7240. if !m.op.Is(OpUpdateOne) {
  7241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7242. }
  7243. if m.id == nil || m.oldValue == nil {
  7244. return v, errors.New("OldUserID requires an ID field in the mutation")
  7245. }
  7246. oldValue, err := m.oldValue(ctx)
  7247. if err != nil {
  7248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7249. }
  7250. return oldValue.UserID, nil
  7251. }
  7252. // AddUserID adds u to the "user_id" field.
  7253. func (m *ChatSessionMutation) AddUserID(u int64) {
  7254. if m.adduser_id != nil {
  7255. *m.adduser_id += u
  7256. } else {
  7257. m.adduser_id = &u
  7258. }
  7259. }
  7260. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7261. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7262. v := m.adduser_id
  7263. if v == nil {
  7264. return
  7265. }
  7266. return *v, true
  7267. }
  7268. // ResetUserID resets all changes to the "user_id" field.
  7269. func (m *ChatSessionMutation) ResetUserID() {
  7270. m.user_id = nil
  7271. m.adduser_id = nil
  7272. }
  7273. // SetBotID sets the "bot_id" field.
  7274. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7275. m.bot_id = &u
  7276. m.addbot_id = nil
  7277. }
  7278. // BotID returns the value of the "bot_id" field in the mutation.
  7279. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7280. v := m.bot_id
  7281. if v == nil {
  7282. return
  7283. }
  7284. return *v, true
  7285. }
  7286. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7287. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7289. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7290. if !m.op.Is(OpUpdateOne) {
  7291. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7292. }
  7293. if m.id == nil || m.oldValue == nil {
  7294. return v, errors.New("OldBotID requires an ID field in the mutation")
  7295. }
  7296. oldValue, err := m.oldValue(ctx)
  7297. if err != nil {
  7298. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7299. }
  7300. return oldValue.BotID, nil
  7301. }
  7302. // AddBotID adds u to the "bot_id" field.
  7303. func (m *ChatSessionMutation) AddBotID(u int64) {
  7304. if m.addbot_id != nil {
  7305. *m.addbot_id += u
  7306. } else {
  7307. m.addbot_id = &u
  7308. }
  7309. }
  7310. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7311. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7312. v := m.addbot_id
  7313. if v == nil {
  7314. return
  7315. }
  7316. return *v, true
  7317. }
  7318. // ResetBotID resets all changes to the "bot_id" field.
  7319. func (m *ChatSessionMutation) ResetBotID() {
  7320. m.bot_id = nil
  7321. m.addbot_id = nil
  7322. }
  7323. // SetBotType sets the "bot_type" field.
  7324. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7325. m.bot_type = &u
  7326. m.addbot_type = nil
  7327. }
  7328. // BotType returns the value of the "bot_type" field in the mutation.
  7329. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7330. v := m.bot_type
  7331. if v == nil {
  7332. return
  7333. }
  7334. return *v, true
  7335. }
  7336. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7337. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7339. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7340. if !m.op.Is(OpUpdateOne) {
  7341. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7342. }
  7343. if m.id == nil || m.oldValue == nil {
  7344. return v, errors.New("OldBotType requires an ID field in the mutation")
  7345. }
  7346. oldValue, err := m.oldValue(ctx)
  7347. if err != nil {
  7348. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7349. }
  7350. return oldValue.BotType, nil
  7351. }
  7352. // AddBotType adds u to the "bot_type" field.
  7353. func (m *ChatSessionMutation) AddBotType(u int8) {
  7354. if m.addbot_type != nil {
  7355. *m.addbot_type += u
  7356. } else {
  7357. m.addbot_type = &u
  7358. }
  7359. }
  7360. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7361. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7362. v := m.addbot_type
  7363. if v == nil {
  7364. return
  7365. }
  7366. return *v, true
  7367. }
  7368. // ResetBotType resets all changes to the "bot_type" field.
  7369. func (m *ChatSessionMutation) ResetBotType() {
  7370. m.bot_type = nil
  7371. m.addbot_type = nil
  7372. }
  7373. // Where appends a list predicates to the ChatSessionMutation builder.
  7374. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7375. m.predicates = append(m.predicates, ps...)
  7376. }
  7377. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7378. // users can use type-assertion to append predicates that do not depend on any generated package.
  7379. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7380. p := make([]predicate.ChatSession, len(ps))
  7381. for i := range ps {
  7382. p[i] = ps[i]
  7383. }
  7384. m.Where(p...)
  7385. }
  7386. // Op returns the operation name.
  7387. func (m *ChatSessionMutation) Op() Op {
  7388. return m.op
  7389. }
  7390. // SetOp allows setting the mutation operation.
  7391. func (m *ChatSessionMutation) SetOp(op Op) {
  7392. m.op = op
  7393. }
  7394. // Type returns the node type of this mutation (ChatSession).
  7395. func (m *ChatSessionMutation) Type() string {
  7396. return m.typ
  7397. }
  7398. // Fields returns all fields that were changed during this mutation. Note that in
  7399. // order to get all numeric fields that were incremented/decremented, call
  7400. // AddedFields().
  7401. func (m *ChatSessionMutation) Fields() []string {
  7402. fields := make([]string, 0, 7)
  7403. if m.created_at != nil {
  7404. fields = append(fields, chatsession.FieldCreatedAt)
  7405. }
  7406. if m.updated_at != nil {
  7407. fields = append(fields, chatsession.FieldUpdatedAt)
  7408. }
  7409. if m.deleted_at != nil {
  7410. fields = append(fields, chatsession.FieldDeletedAt)
  7411. }
  7412. if m.name != nil {
  7413. fields = append(fields, chatsession.FieldName)
  7414. }
  7415. if m.user_id != nil {
  7416. fields = append(fields, chatsession.FieldUserID)
  7417. }
  7418. if m.bot_id != nil {
  7419. fields = append(fields, chatsession.FieldBotID)
  7420. }
  7421. if m.bot_type != nil {
  7422. fields = append(fields, chatsession.FieldBotType)
  7423. }
  7424. return fields
  7425. }
  7426. // Field returns the value of a field with the given name. The second boolean
  7427. // return value indicates that this field was not set, or was not defined in the
  7428. // schema.
  7429. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7430. switch name {
  7431. case chatsession.FieldCreatedAt:
  7432. return m.CreatedAt()
  7433. case chatsession.FieldUpdatedAt:
  7434. return m.UpdatedAt()
  7435. case chatsession.FieldDeletedAt:
  7436. return m.DeletedAt()
  7437. case chatsession.FieldName:
  7438. return m.Name()
  7439. case chatsession.FieldUserID:
  7440. return m.UserID()
  7441. case chatsession.FieldBotID:
  7442. return m.BotID()
  7443. case chatsession.FieldBotType:
  7444. return m.BotType()
  7445. }
  7446. return nil, false
  7447. }
  7448. // OldField returns the old value of the field from the database. An error is
  7449. // returned if the mutation operation is not UpdateOne, or the query to the
  7450. // database failed.
  7451. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7452. switch name {
  7453. case chatsession.FieldCreatedAt:
  7454. return m.OldCreatedAt(ctx)
  7455. case chatsession.FieldUpdatedAt:
  7456. return m.OldUpdatedAt(ctx)
  7457. case chatsession.FieldDeletedAt:
  7458. return m.OldDeletedAt(ctx)
  7459. case chatsession.FieldName:
  7460. return m.OldName(ctx)
  7461. case chatsession.FieldUserID:
  7462. return m.OldUserID(ctx)
  7463. case chatsession.FieldBotID:
  7464. return m.OldBotID(ctx)
  7465. case chatsession.FieldBotType:
  7466. return m.OldBotType(ctx)
  7467. }
  7468. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7469. }
  7470. // SetField sets the value of a field with the given name. It returns an error if
  7471. // the field is not defined in the schema, or if the type mismatched the field
  7472. // type.
  7473. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7474. switch name {
  7475. case chatsession.FieldCreatedAt:
  7476. v, ok := value.(time.Time)
  7477. if !ok {
  7478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7479. }
  7480. m.SetCreatedAt(v)
  7481. return nil
  7482. case chatsession.FieldUpdatedAt:
  7483. v, ok := value.(time.Time)
  7484. if !ok {
  7485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7486. }
  7487. m.SetUpdatedAt(v)
  7488. return nil
  7489. case chatsession.FieldDeletedAt:
  7490. v, ok := value.(time.Time)
  7491. if !ok {
  7492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7493. }
  7494. m.SetDeletedAt(v)
  7495. return nil
  7496. case chatsession.FieldName:
  7497. v, ok := value.(string)
  7498. if !ok {
  7499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7500. }
  7501. m.SetName(v)
  7502. return nil
  7503. case chatsession.FieldUserID:
  7504. v, ok := value.(uint64)
  7505. if !ok {
  7506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7507. }
  7508. m.SetUserID(v)
  7509. return nil
  7510. case chatsession.FieldBotID:
  7511. v, ok := value.(uint64)
  7512. if !ok {
  7513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7514. }
  7515. m.SetBotID(v)
  7516. return nil
  7517. case chatsession.FieldBotType:
  7518. v, ok := value.(uint8)
  7519. if !ok {
  7520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7521. }
  7522. m.SetBotType(v)
  7523. return nil
  7524. }
  7525. return fmt.Errorf("unknown ChatSession field %s", name)
  7526. }
  7527. // AddedFields returns all numeric fields that were incremented/decremented during
  7528. // this mutation.
  7529. func (m *ChatSessionMutation) AddedFields() []string {
  7530. var fields []string
  7531. if m.adduser_id != nil {
  7532. fields = append(fields, chatsession.FieldUserID)
  7533. }
  7534. if m.addbot_id != nil {
  7535. fields = append(fields, chatsession.FieldBotID)
  7536. }
  7537. if m.addbot_type != nil {
  7538. fields = append(fields, chatsession.FieldBotType)
  7539. }
  7540. return fields
  7541. }
  7542. // AddedField returns the numeric value that was incremented/decremented on a field
  7543. // with the given name. The second boolean return value indicates that this field
  7544. // was not set, or was not defined in the schema.
  7545. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7546. switch name {
  7547. case chatsession.FieldUserID:
  7548. return m.AddedUserID()
  7549. case chatsession.FieldBotID:
  7550. return m.AddedBotID()
  7551. case chatsession.FieldBotType:
  7552. return m.AddedBotType()
  7553. }
  7554. return nil, false
  7555. }
  7556. // AddField adds the value to the field with the given name. It returns an error if
  7557. // the field is not defined in the schema, or if the type mismatched the field
  7558. // type.
  7559. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7560. switch name {
  7561. case chatsession.FieldUserID:
  7562. v, ok := value.(int64)
  7563. if !ok {
  7564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7565. }
  7566. m.AddUserID(v)
  7567. return nil
  7568. case chatsession.FieldBotID:
  7569. v, ok := value.(int64)
  7570. if !ok {
  7571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7572. }
  7573. m.AddBotID(v)
  7574. return nil
  7575. case chatsession.FieldBotType:
  7576. v, ok := value.(int8)
  7577. if !ok {
  7578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7579. }
  7580. m.AddBotType(v)
  7581. return nil
  7582. }
  7583. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7584. }
  7585. // ClearedFields returns all nullable fields that were cleared during this
  7586. // mutation.
  7587. func (m *ChatSessionMutation) ClearedFields() []string {
  7588. var fields []string
  7589. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7590. fields = append(fields, chatsession.FieldDeletedAt)
  7591. }
  7592. return fields
  7593. }
  7594. // FieldCleared returns a boolean indicating if a field with the given name was
  7595. // cleared in this mutation.
  7596. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7597. _, ok := m.clearedFields[name]
  7598. return ok
  7599. }
  7600. // ClearField clears the value of the field with the given name. It returns an
  7601. // error if the field is not defined in the schema.
  7602. func (m *ChatSessionMutation) ClearField(name string) error {
  7603. switch name {
  7604. case chatsession.FieldDeletedAt:
  7605. m.ClearDeletedAt()
  7606. return nil
  7607. }
  7608. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7609. }
  7610. // ResetField resets all changes in the mutation for the field with the given name.
  7611. // It returns an error if the field is not defined in the schema.
  7612. func (m *ChatSessionMutation) ResetField(name string) error {
  7613. switch name {
  7614. case chatsession.FieldCreatedAt:
  7615. m.ResetCreatedAt()
  7616. return nil
  7617. case chatsession.FieldUpdatedAt:
  7618. m.ResetUpdatedAt()
  7619. return nil
  7620. case chatsession.FieldDeletedAt:
  7621. m.ResetDeletedAt()
  7622. return nil
  7623. case chatsession.FieldName:
  7624. m.ResetName()
  7625. return nil
  7626. case chatsession.FieldUserID:
  7627. m.ResetUserID()
  7628. return nil
  7629. case chatsession.FieldBotID:
  7630. m.ResetBotID()
  7631. return nil
  7632. case chatsession.FieldBotType:
  7633. m.ResetBotType()
  7634. return nil
  7635. }
  7636. return fmt.Errorf("unknown ChatSession field %s", name)
  7637. }
  7638. // AddedEdges returns all edge names that were set/added in this mutation.
  7639. func (m *ChatSessionMutation) AddedEdges() []string {
  7640. edges := make([]string, 0, 0)
  7641. return edges
  7642. }
  7643. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7644. // name in this mutation.
  7645. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7646. return nil
  7647. }
  7648. // RemovedEdges returns all edge names that were removed in this mutation.
  7649. func (m *ChatSessionMutation) RemovedEdges() []string {
  7650. edges := make([]string, 0, 0)
  7651. return edges
  7652. }
  7653. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7654. // the given name in this mutation.
  7655. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7656. return nil
  7657. }
  7658. // ClearedEdges returns all edge names that were cleared in this mutation.
  7659. func (m *ChatSessionMutation) ClearedEdges() []string {
  7660. edges := make([]string, 0, 0)
  7661. return edges
  7662. }
  7663. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7664. // was cleared in this mutation.
  7665. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7666. return false
  7667. }
  7668. // ClearEdge clears the value of the edge with the given name. It returns an error
  7669. // if that edge is not defined in the schema.
  7670. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7671. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7672. }
  7673. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7674. // It returns an error if the edge is not defined in the schema.
  7675. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7676. return fmt.Errorf("unknown ChatSession edge %s", name)
  7677. }
  7678. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7679. type ContactMutation struct {
  7680. config
  7681. op Op
  7682. typ string
  7683. id *uint64
  7684. created_at *time.Time
  7685. updated_at *time.Time
  7686. status *uint8
  7687. addstatus *int8
  7688. deleted_at *time.Time
  7689. wx_wxid *string
  7690. _type *int
  7691. add_type *int
  7692. wxid *string
  7693. account *string
  7694. nickname *string
  7695. markname *string
  7696. headimg *string
  7697. sex *int
  7698. addsex *int
  7699. starrole *string
  7700. dontseeit *int
  7701. adddontseeit *int
  7702. dontseeme *int
  7703. adddontseeme *int
  7704. lag *string
  7705. gid *string
  7706. gname *string
  7707. v3 *string
  7708. organization_id *uint64
  7709. addorganization_id *int64
  7710. clearedFields map[string]struct{}
  7711. contact_relationships map[uint64]struct{}
  7712. removedcontact_relationships map[uint64]struct{}
  7713. clearedcontact_relationships bool
  7714. contact_messages map[uint64]struct{}
  7715. removedcontact_messages map[uint64]struct{}
  7716. clearedcontact_messages bool
  7717. done bool
  7718. oldValue func(context.Context) (*Contact, error)
  7719. predicates []predicate.Contact
  7720. }
  7721. var _ ent.Mutation = (*ContactMutation)(nil)
  7722. // contactOption allows management of the mutation configuration using functional options.
  7723. type contactOption func(*ContactMutation)
  7724. // newContactMutation creates new mutation for the Contact entity.
  7725. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7726. m := &ContactMutation{
  7727. config: c,
  7728. op: op,
  7729. typ: TypeContact,
  7730. clearedFields: make(map[string]struct{}),
  7731. }
  7732. for _, opt := range opts {
  7733. opt(m)
  7734. }
  7735. return m
  7736. }
  7737. // withContactID sets the ID field of the mutation.
  7738. func withContactID(id uint64) contactOption {
  7739. return func(m *ContactMutation) {
  7740. var (
  7741. err error
  7742. once sync.Once
  7743. value *Contact
  7744. )
  7745. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7746. once.Do(func() {
  7747. if m.done {
  7748. err = errors.New("querying old values post mutation is not allowed")
  7749. } else {
  7750. value, err = m.Client().Contact.Get(ctx, id)
  7751. }
  7752. })
  7753. return value, err
  7754. }
  7755. m.id = &id
  7756. }
  7757. }
  7758. // withContact sets the old Contact of the mutation.
  7759. func withContact(node *Contact) contactOption {
  7760. return func(m *ContactMutation) {
  7761. m.oldValue = func(context.Context) (*Contact, error) {
  7762. return node, nil
  7763. }
  7764. m.id = &node.ID
  7765. }
  7766. }
  7767. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7768. // executed in a transaction (ent.Tx), a transactional client is returned.
  7769. func (m ContactMutation) Client() *Client {
  7770. client := &Client{config: m.config}
  7771. client.init()
  7772. return client
  7773. }
  7774. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7775. // it returns an error otherwise.
  7776. func (m ContactMutation) Tx() (*Tx, error) {
  7777. if _, ok := m.driver.(*txDriver); !ok {
  7778. return nil, errors.New("ent: mutation is not running in a transaction")
  7779. }
  7780. tx := &Tx{config: m.config}
  7781. tx.init()
  7782. return tx, nil
  7783. }
  7784. // SetID sets the value of the id field. Note that this
  7785. // operation is only accepted on creation of Contact entities.
  7786. func (m *ContactMutation) SetID(id uint64) {
  7787. m.id = &id
  7788. }
  7789. // ID returns the ID value in the mutation. Note that the ID is only available
  7790. // if it was provided to the builder or after it was returned from the database.
  7791. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7792. if m.id == nil {
  7793. return
  7794. }
  7795. return *m.id, true
  7796. }
  7797. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7798. // That means, if the mutation is applied within a transaction with an isolation level such
  7799. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7800. // or updated by the mutation.
  7801. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7802. switch {
  7803. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7804. id, exists := m.ID()
  7805. if exists {
  7806. return []uint64{id}, nil
  7807. }
  7808. fallthrough
  7809. case m.op.Is(OpUpdate | OpDelete):
  7810. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7811. default:
  7812. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7813. }
  7814. }
  7815. // SetCreatedAt sets the "created_at" field.
  7816. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7817. m.created_at = &t
  7818. }
  7819. // CreatedAt returns the value of the "created_at" field in the mutation.
  7820. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7821. v := m.created_at
  7822. if v == nil {
  7823. return
  7824. }
  7825. return *v, true
  7826. }
  7827. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7828. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7830. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7831. if !m.op.Is(OpUpdateOne) {
  7832. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7833. }
  7834. if m.id == nil || m.oldValue == nil {
  7835. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7836. }
  7837. oldValue, err := m.oldValue(ctx)
  7838. if err != nil {
  7839. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7840. }
  7841. return oldValue.CreatedAt, nil
  7842. }
  7843. // ResetCreatedAt resets all changes to the "created_at" field.
  7844. func (m *ContactMutation) ResetCreatedAt() {
  7845. m.created_at = nil
  7846. }
  7847. // SetUpdatedAt sets the "updated_at" field.
  7848. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7849. m.updated_at = &t
  7850. }
  7851. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7852. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7853. v := m.updated_at
  7854. if v == nil {
  7855. return
  7856. }
  7857. return *v, true
  7858. }
  7859. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7860. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7862. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7863. if !m.op.Is(OpUpdateOne) {
  7864. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7865. }
  7866. if m.id == nil || m.oldValue == nil {
  7867. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7868. }
  7869. oldValue, err := m.oldValue(ctx)
  7870. if err != nil {
  7871. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7872. }
  7873. return oldValue.UpdatedAt, nil
  7874. }
  7875. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7876. func (m *ContactMutation) ResetUpdatedAt() {
  7877. m.updated_at = nil
  7878. }
  7879. // SetStatus sets the "status" field.
  7880. func (m *ContactMutation) SetStatus(u uint8) {
  7881. m.status = &u
  7882. m.addstatus = nil
  7883. }
  7884. // Status returns the value of the "status" field in the mutation.
  7885. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7886. v := m.status
  7887. if v == nil {
  7888. return
  7889. }
  7890. return *v, true
  7891. }
  7892. // OldStatus returns the old "status" field's value of the Contact entity.
  7893. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7895. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7896. if !m.op.Is(OpUpdateOne) {
  7897. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7898. }
  7899. if m.id == nil || m.oldValue == nil {
  7900. return v, errors.New("OldStatus requires an ID field in the mutation")
  7901. }
  7902. oldValue, err := m.oldValue(ctx)
  7903. if err != nil {
  7904. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7905. }
  7906. return oldValue.Status, nil
  7907. }
  7908. // AddStatus adds u to the "status" field.
  7909. func (m *ContactMutation) AddStatus(u int8) {
  7910. if m.addstatus != nil {
  7911. *m.addstatus += u
  7912. } else {
  7913. m.addstatus = &u
  7914. }
  7915. }
  7916. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7917. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7918. v := m.addstatus
  7919. if v == nil {
  7920. return
  7921. }
  7922. return *v, true
  7923. }
  7924. // ClearStatus clears the value of the "status" field.
  7925. func (m *ContactMutation) ClearStatus() {
  7926. m.status = nil
  7927. m.addstatus = nil
  7928. m.clearedFields[contact.FieldStatus] = struct{}{}
  7929. }
  7930. // StatusCleared returns if the "status" field was cleared in this mutation.
  7931. func (m *ContactMutation) StatusCleared() bool {
  7932. _, ok := m.clearedFields[contact.FieldStatus]
  7933. return ok
  7934. }
  7935. // ResetStatus resets all changes to the "status" field.
  7936. func (m *ContactMutation) ResetStatus() {
  7937. m.status = nil
  7938. m.addstatus = nil
  7939. delete(m.clearedFields, contact.FieldStatus)
  7940. }
  7941. // SetDeletedAt sets the "deleted_at" field.
  7942. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7943. m.deleted_at = &t
  7944. }
  7945. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7946. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7947. v := m.deleted_at
  7948. if v == nil {
  7949. return
  7950. }
  7951. return *v, true
  7952. }
  7953. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7956. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7957. if !m.op.Is(OpUpdateOne) {
  7958. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7959. }
  7960. if m.id == nil || m.oldValue == nil {
  7961. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7962. }
  7963. oldValue, err := m.oldValue(ctx)
  7964. if err != nil {
  7965. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7966. }
  7967. return oldValue.DeletedAt, nil
  7968. }
  7969. // ClearDeletedAt clears the value of the "deleted_at" field.
  7970. func (m *ContactMutation) ClearDeletedAt() {
  7971. m.deleted_at = nil
  7972. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7973. }
  7974. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7975. func (m *ContactMutation) DeletedAtCleared() bool {
  7976. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7977. return ok
  7978. }
  7979. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7980. func (m *ContactMutation) ResetDeletedAt() {
  7981. m.deleted_at = nil
  7982. delete(m.clearedFields, contact.FieldDeletedAt)
  7983. }
  7984. // SetWxWxid sets the "wx_wxid" field.
  7985. func (m *ContactMutation) SetWxWxid(s string) {
  7986. m.wx_wxid = &s
  7987. }
  7988. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7989. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7990. v := m.wx_wxid
  7991. if v == nil {
  7992. return
  7993. }
  7994. return *v, true
  7995. }
  7996. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7999. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8000. if !m.op.Is(OpUpdateOne) {
  8001. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8002. }
  8003. if m.id == nil || m.oldValue == nil {
  8004. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8005. }
  8006. oldValue, err := m.oldValue(ctx)
  8007. if err != nil {
  8008. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8009. }
  8010. return oldValue.WxWxid, nil
  8011. }
  8012. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8013. func (m *ContactMutation) ResetWxWxid() {
  8014. m.wx_wxid = nil
  8015. }
  8016. // SetType sets the "type" field.
  8017. func (m *ContactMutation) SetType(i int) {
  8018. m._type = &i
  8019. m.add_type = nil
  8020. }
  8021. // GetType returns the value of the "type" field in the mutation.
  8022. func (m *ContactMutation) GetType() (r int, exists bool) {
  8023. v := m._type
  8024. if v == nil {
  8025. return
  8026. }
  8027. return *v, true
  8028. }
  8029. // OldType returns the old "type" field's value of the Contact entity.
  8030. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8032. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8033. if !m.op.Is(OpUpdateOne) {
  8034. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8035. }
  8036. if m.id == nil || m.oldValue == nil {
  8037. return v, errors.New("OldType requires an ID field in the mutation")
  8038. }
  8039. oldValue, err := m.oldValue(ctx)
  8040. if err != nil {
  8041. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8042. }
  8043. return oldValue.Type, nil
  8044. }
  8045. // AddType adds i to the "type" field.
  8046. func (m *ContactMutation) AddType(i int) {
  8047. if m.add_type != nil {
  8048. *m.add_type += i
  8049. } else {
  8050. m.add_type = &i
  8051. }
  8052. }
  8053. // AddedType returns the value that was added to the "type" field in this mutation.
  8054. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8055. v := m.add_type
  8056. if v == nil {
  8057. return
  8058. }
  8059. return *v, true
  8060. }
  8061. // ClearType clears the value of the "type" field.
  8062. func (m *ContactMutation) ClearType() {
  8063. m._type = nil
  8064. m.add_type = nil
  8065. m.clearedFields[contact.FieldType] = struct{}{}
  8066. }
  8067. // TypeCleared returns if the "type" field was cleared in this mutation.
  8068. func (m *ContactMutation) TypeCleared() bool {
  8069. _, ok := m.clearedFields[contact.FieldType]
  8070. return ok
  8071. }
  8072. // ResetType resets all changes to the "type" field.
  8073. func (m *ContactMutation) ResetType() {
  8074. m._type = nil
  8075. m.add_type = nil
  8076. delete(m.clearedFields, contact.FieldType)
  8077. }
  8078. // SetWxid sets the "wxid" field.
  8079. func (m *ContactMutation) SetWxid(s string) {
  8080. m.wxid = &s
  8081. }
  8082. // Wxid returns the value of the "wxid" field in the mutation.
  8083. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8084. v := m.wxid
  8085. if v == nil {
  8086. return
  8087. }
  8088. return *v, true
  8089. }
  8090. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8091. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8093. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8094. if !m.op.Is(OpUpdateOne) {
  8095. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8096. }
  8097. if m.id == nil || m.oldValue == nil {
  8098. return v, errors.New("OldWxid requires an ID field in the mutation")
  8099. }
  8100. oldValue, err := m.oldValue(ctx)
  8101. if err != nil {
  8102. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8103. }
  8104. return oldValue.Wxid, nil
  8105. }
  8106. // ResetWxid resets all changes to the "wxid" field.
  8107. func (m *ContactMutation) ResetWxid() {
  8108. m.wxid = nil
  8109. }
  8110. // SetAccount sets the "account" field.
  8111. func (m *ContactMutation) SetAccount(s string) {
  8112. m.account = &s
  8113. }
  8114. // Account returns the value of the "account" field in the mutation.
  8115. func (m *ContactMutation) Account() (r string, exists bool) {
  8116. v := m.account
  8117. if v == nil {
  8118. return
  8119. }
  8120. return *v, true
  8121. }
  8122. // OldAccount returns the old "account" field's value of the Contact entity.
  8123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8125. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8126. if !m.op.Is(OpUpdateOne) {
  8127. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8128. }
  8129. if m.id == nil || m.oldValue == nil {
  8130. return v, errors.New("OldAccount requires an ID field in the mutation")
  8131. }
  8132. oldValue, err := m.oldValue(ctx)
  8133. if err != nil {
  8134. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8135. }
  8136. return oldValue.Account, nil
  8137. }
  8138. // ResetAccount resets all changes to the "account" field.
  8139. func (m *ContactMutation) ResetAccount() {
  8140. m.account = nil
  8141. }
  8142. // SetNickname sets the "nickname" field.
  8143. func (m *ContactMutation) SetNickname(s string) {
  8144. m.nickname = &s
  8145. }
  8146. // Nickname returns the value of the "nickname" field in the mutation.
  8147. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8148. v := m.nickname
  8149. if v == nil {
  8150. return
  8151. }
  8152. return *v, true
  8153. }
  8154. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8157. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8158. if !m.op.Is(OpUpdateOne) {
  8159. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8160. }
  8161. if m.id == nil || m.oldValue == nil {
  8162. return v, errors.New("OldNickname requires an ID field in the mutation")
  8163. }
  8164. oldValue, err := m.oldValue(ctx)
  8165. if err != nil {
  8166. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8167. }
  8168. return oldValue.Nickname, nil
  8169. }
  8170. // ResetNickname resets all changes to the "nickname" field.
  8171. func (m *ContactMutation) ResetNickname() {
  8172. m.nickname = nil
  8173. }
  8174. // SetMarkname sets the "markname" field.
  8175. func (m *ContactMutation) SetMarkname(s string) {
  8176. m.markname = &s
  8177. }
  8178. // Markname returns the value of the "markname" field in the mutation.
  8179. func (m *ContactMutation) Markname() (r string, exists bool) {
  8180. v := m.markname
  8181. if v == nil {
  8182. return
  8183. }
  8184. return *v, true
  8185. }
  8186. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8189. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8190. if !m.op.Is(OpUpdateOne) {
  8191. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8192. }
  8193. if m.id == nil || m.oldValue == nil {
  8194. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8195. }
  8196. oldValue, err := m.oldValue(ctx)
  8197. if err != nil {
  8198. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8199. }
  8200. return oldValue.Markname, nil
  8201. }
  8202. // ResetMarkname resets all changes to the "markname" field.
  8203. func (m *ContactMutation) ResetMarkname() {
  8204. m.markname = nil
  8205. }
  8206. // SetHeadimg sets the "headimg" field.
  8207. func (m *ContactMutation) SetHeadimg(s string) {
  8208. m.headimg = &s
  8209. }
  8210. // Headimg returns the value of the "headimg" field in the mutation.
  8211. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8212. v := m.headimg
  8213. if v == nil {
  8214. return
  8215. }
  8216. return *v, true
  8217. }
  8218. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8221. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8222. if !m.op.Is(OpUpdateOne) {
  8223. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8224. }
  8225. if m.id == nil || m.oldValue == nil {
  8226. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8227. }
  8228. oldValue, err := m.oldValue(ctx)
  8229. if err != nil {
  8230. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8231. }
  8232. return oldValue.Headimg, nil
  8233. }
  8234. // ResetHeadimg resets all changes to the "headimg" field.
  8235. func (m *ContactMutation) ResetHeadimg() {
  8236. m.headimg = nil
  8237. }
  8238. // SetSex sets the "sex" field.
  8239. func (m *ContactMutation) SetSex(i int) {
  8240. m.sex = &i
  8241. m.addsex = nil
  8242. }
  8243. // Sex returns the value of the "sex" field in the mutation.
  8244. func (m *ContactMutation) Sex() (r int, exists bool) {
  8245. v := m.sex
  8246. if v == nil {
  8247. return
  8248. }
  8249. return *v, true
  8250. }
  8251. // OldSex returns the old "sex" field's value of the Contact entity.
  8252. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8254. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8255. if !m.op.Is(OpUpdateOne) {
  8256. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8257. }
  8258. if m.id == nil || m.oldValue == nil {
  8259. return v, errors.New("OldSex requires an ID field in the mutation")
  8260. }
  8261. oldValue, err := m.oldValue(ctx)
  8262. if err != nil {
  8263. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8264. }
  8265. return oldValue.Sex, nil
  8266. }
  8267. // AddSex adds i to the "sex" field.
  8268. func (m *ContactMutation) AddSex(i int) {
  8269. if m.addsex != nil {
  8270. *m.addsex += i
  8271. } else {
  8272. m.addsex = &i
  8273. }
  8274. }
  8275. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8276. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8277. v := m.addsex
  8278. if v == nil {
  8279. return
  8280. }
  8281. return *v, true
  8282. }
  8283. // ResetSex resets all changes to the "sex" field.
  8284. func (m *ContactMutation) ResetSex() {
  8285. m.sex = nil
  8286. m.addsex = nil
  8287. }
  8288. // SetStarrole sets the "starrole" field.
  8289. func (m *ContactMutation) SetStarrole(s string) {
  8290. m.starrole = &s
  8291. }
  8292. // Starrole returns the value of the "starrole" field in the mutation.
  8293. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8294. v := m.starrole
  8295. if v == nil {
  8296. return
  8297. }
  8298. return *v, true
  8299. }
  8300. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8301. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8303. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8304. if !m.op.Is(OpUpdateOne) {
  8305. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8306. }
  8307. if m.id == nil || m.oldValue == nil {
  8308. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8309. }
  8310. oldValue, err := m.oldValue(ctx)
  8311. if err != nil {
  8312. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8313. }
  8314. return oldValue.Starrole, nil
  8315. }
  8316. // ResetStarrole resets all changes to the "starrole" field.
  8317. func (m *ContactMutation) ResetStarrole() {
  8318. m.starrole = nil
  8319. }
  8320. // SetDontseeit sets the "dontseeit" field.
  8321. func (m *ContactMutation) SetDontseeit(i int) {
  8322. m.dontseeit = &i
  8323. m.adddontseeit = nil
  8324. }
  8325. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8326. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8327. v := m.dontseeit
  8328. if v == nil {
  8329. return
  8330. }
  8331. return *v, true
  8332. }
  8333. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8334. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8336. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8337. if !m.op.Is(OpUpdateOne) {
  8338. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8339. }
  8340. if m.id == nil || m.oldValue == nil {
  8341. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8342. }
  8343. oldValue, err := m.oldValue(ctx)
  8344. if err != nil {
  8345. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8346. }
  8347. return oldValue.Dontseeit, nil
  8348. }
  8349. // AddDontseeit adds i to the "dontseeit" field.
  8350. func (m *ContactMutation) AddDontseeit(i int) {
  8351. if m.adddontseeit != nil {
  8352. *m.adddontseeit += i
  8353. } else {
  8354. m.adddontseeit = &i
  8355. }
  8356. }
  8357. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8358. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8359. v := m.adddontseeit
  8360. if v == nil {
  8361. return
  8362. }
  8363. return *v, true
  8364. }
  8365. // ResetDontseeit resets all changes to the "dontseeit" field.
  8366. func (m *ContactMutation) ResetDontseeit() {
  8367. m.dontseeit = nil
  8368. m.adddontseeit = nil
  8369. }
  8370. // SetDontseeme sets the "dontseeme" field.
  8371. func (m *ContactMutation) SetDontseeme(i int) {
  8372. m.dontseeme = &i
  8373. m.adddontseeme = nil
  8374. }
  8375. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8376. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8377. v := m.dontseeme
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8384. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8386. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8392. }
  8393. oldValue, err := m.oldValue(ctx)
  8394. if err != nil {
  8395. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8396. }
  8397. return oldValue.Dontseeme, nil
  8398. }
  8399. // AddDontseeme adds i to the "dontseeme" field.
  8400. func (m *ContactMutation) AddDontseeme(i int) {
  8401. if m.adddontseeme != nil {
  8402. *m.adddontseeme += i
  8403. } else {
  8404. m.adddontseeme = &i
  8405. }
  8406. }
  8407. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8408. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8409. v := m.adddontseeme
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // ResetDontseeme resets all changes to the "dontseeme" field.
  8416. func (m *ContactMutation) ResetDontseeme() {
  8417. m.dontseeme = nil
  8418. m.adddontseeme = nil
  8419. }
  8420. // SetLag sets the "lag" field.
  8421. func (m *ContactMutation) SetLag(s string) {
  8422. m.lag = &s
  8423. }
  8424. // Lag returns the value of the "lag" field in the mutation.
  8425. func (m *ContactMutation) Lag() (r string, exists bool) {
  8426. v := m.lag
  8427. if v == nil {
  8428. return
  8429. }
  8430. return *v, true
  8431. }
  8432. // OldLag returns the old "lag" field's value of the Contact entity.
  8433. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8435. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8436. if !m.op.Is(OpUpdateOne) {
  8437. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8438. }
  8439. if m.id == nil || m.oldValue == nil {
  8440. return v, errors.New("OldLag requires an ID field in the mutation")
  8441. }
  8442. oldValue, err := m.oldValue(ctx)
  8443. if err != nil {
  8444. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8445. }
  8446. return oldValue.Lag, nil
  8447. }
  8448. // ResetLag resets all changes to the "lag" field.
  8449. func (m *ContactMutation) ResetLag() {
  8450. m.lag = nil
  8451. }
  8452. // SetGid sets the "gid" field.
  8453. func (m *ContactMutation) SetGid(s string) {
  8454. m.gid = &s
  8455. }
  8456. // Gid returns the value of the "gid" field in the mutation.
  8457. func (m *ContactMutation) Gid() (r string, exists bool) {
  8458. v := m.gid
  8459. if v == nil {
  8460. return
  8461. }
  8462. return *v, true
  8463. }
  8464. // OldGid returns the old "gid" field's value of the Contact entity.
  8465. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8467. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8468. if !m.op.Is(OpUpdateOne) {
  8469. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8470. }
  8471. if m.id == nil || m.oldValue == nil {
  8472. return v, errors.New("OldGid requires an ID field in the mutation")
  8473. }
  8474. oldValue, err := m.oldValue(ctx)
  8475. if err != nil {
  8476. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8477. }
  8478. return oldValue.Gid, nil
  8479. }
  8480. // ResetGid resets all changes to the "gid" field.
  8481. func (m *ContactMutation) ResetGid() {
  8482. m.gid = nil
  8483. }
  8484. // SetGname sets the "gname" field.
  8485. func (m *ContactMutation) SetGname(s string) {
  8486. m.gname = &s
  8487. }
  8488. // Gname returns the value of the "gname" field in the mutation.
  8489. func (m *ContactMutation) Gname() (r string, exists bool) {
  8490. v := m.gname
  8491. if v == nil {
  8492. return
  8493. }
  8494. return *v, true
  8495. }
  8496. // OldGname returns the old "gname" field's value of the Contact entity.
  8497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8499. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8500. if !m.op.Is(OpUpdateOne) {
  8501. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8502. }
  8503. if m.id == nil || m.oldValue == nil {
  8504. return v, errors.New("OldGname requires an ID field in the mutation")
  8505. }
  8506. oldValue, err := m.oldValue(ctx)
  8507. if err != nil {
  8508. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8509. }
  8510. return oldValue.Gname, nil
  8511. }
  8512. // ResetGname resets all changes to the "gname" field.
  8513. func (m *ContactMutation) ResetGname() {
  8514. m.gname = nil
  8515. }
  8516. // SetV3 sets the "v3" field.
  8517. func (m *ContactMutation) SetV3(s string) {
  8518. m.v3 = &s
  8519. }
  8520. // V3 returns the value of the "v3" field in the mutation.
  8521. func (m *ContactMutation) V3() (r string, exists bool) {
  8522. v := m.v3
  8523. if v == nil {
  8524. return
  8525. }
  8526. return *v, true
  8527. }
  8528. // OldV3 returns the old "v3" field's value of the Contact entity.
  8529. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8531. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8532. if !m.op.Is(OpUpdateOne) {
  8533. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8534. }
  8535. if m.id == nil || m.oldValue == nil {
  8536. return v, errors.New("OldV3 requires an ID field in the mutation")
  8537. }
  8538. oldValue, err := m.oldValue(ctx)
  8539. if err != nil {
  8540. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8541. }
  8542. return oldValue.V3, nil
  8543. }
  8544. // ResetV3 resets all changes to the "v3" field.
  8545. func (m *ContactMutation) ResetV3() {
  8546. m.v3 = nil
  8547. }
  8548. // SetOrganizationID sets the "organization_id" field.
  8549. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8550. m.organization_id = &u
  8551. m.addorganization_id = nil
  8552. }
  8553. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8554. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8555. v := m.organization_id
  8556. if v == nil {
  8557. return
  8558. }
  8559. return *v, true
  8560. }
  8561. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8562. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8564. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8565. if !m.op.Is(OpUpdateOne) {
  8566. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8567. }
  8568. if m.id == nil || m.oldValue == nil {
  8569. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8570. }
  8571. oldValue, err := m.oldValue(ctx)
  8572. if err != nil {
  8573. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8574. }
  8575. return oldValue.OrganizationID, nil
  8576. }
  8577. // AddOrganizationID adds u to the "organization_id" field.
  8578. func (m *ContactMutation) AddOrganizationID(u int64) {
  8579. if m.addorganization_id != nil {
  8580. *m.addorganization_id += u
  8581. } else {
  8582. m.addorganization_id = &u
  8583. }
  8584. }
  8585. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8586. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8587. v := m.addorganization_id
  8588. if v == nil {
  8589. return
  8590. }
  8591. return *v, true
  8592. }
  8593. // ClearOrganizationID clears the value of the "organization_id" field.
  8594. func (m *ContactMutation) ClearOrganizationID() {
  8595. m.organization_id = nil
  8596. m.addorganization_id = nil
  8597. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8598. }
  8599. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8600. func (m *ContactMutation) OrganizationIDCleared() bool {
  8601. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8602. return ok
  8603. }
  8604. // ResetOrganizationID resets all changes to the "organization_id" field.
  8605. func (m *ContactMutation) ResetOrganizationID() {
  8606. m.organization_id = nil
  8607. m.addorganization_id = nil
  8608. delete(m.clearedFields, contact.FieldOrganizationID)
  8609. }
  8610. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8611. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8612. if m.contact_relationships == nil {
  8613. m.contact_relationships = make(map[uint64]struct{})
  8614. }
  8615. for i := range ids {
  8616. m.contact_relationships[ids[i]] = struct{}{}
  8617. }
  8618. }
  8619. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8620. func (m *ContactMutation) ClearContactRelationships() {
  8621. m.clearedcontact_relationships = true
  8622. }
  8623. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8624. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8625. return m.clearedcontact_relationships
  8626. }
  8627. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8628. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8629. if m.removedcontact_relationships == nil {
  8630. m.removedcontact_relationships = make(map[uint64]struct{})
  8631. }
  8632. for i := range ids {
  8633. delete(m.contact_relationships, ids[i])
  8634. m.removedcontact_relationships[ids[i]] = struct{}{}
  8635. }
  8636. }
  8637. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8638. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8639. for id := range m.removedcontact_relationships {
  8640. ids = append(ids, id)
  8641. }
  8642. return
  8643. }
  8644. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8645. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8646. for id := range m.contact_relationships {
  8647. ids = append(ids, id)
  8648. }
  8649. return
  8650. }
  8651. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8652. func (m *ContactMutation) ResetContactRelationships() {
  8653. m.contact_relationships = nil
  8654. m.clearedcontact_relationships = false
  8655. m.removedcontact_relationships = nil
  8656. }
  8657. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8658. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8659. if m.contact_messages == nil {
  8660. m.contact_messages = make(map[uint64]struct{})
  8661. }
  8662. for i := range ids {
  8663. m.contact_messages[ids[i]] = struct{}{}
  8664. }
  8665. }
  8666. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8667. func (m *ContactMutation) ClearContactMessages() {
  8668. m.clearedcontact_messages = true
  8669. }
  8670. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8671. func (m *ContactMutation) ContactMessagesCleared() bool {
  8672. return m.clearedcontact_messages
  8673. }
  8674. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8675. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8676. if m.removedcontact_messages == nil {
  8677. m.removedcontact_messages = make(map[uint64]struct{})
  8678. }
  8679. for i := range ids {
  8680. delete(m.contact_messages, ids[i])
  8681. m.removedcontact_messages[ids[i]] = struct{}{}
  8682. }
  8683. }
  8684. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8685. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8686. for id := range m.removedcontact_messages {
  8687. ids = append(ids, id)
  8688. }
  8689. return
  8690. }
  8691. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8692. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8693. for id := range m.contact_messages {
  8694. ids = append(ids, id)
  8695. }
  8696. return
  8697. }
  8698. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8699. func (m *ContactMutation) ResetContactMessages() {
  8700. m.contact_messages = nil
  8701. m.clearedcontact_messages = false
  8702. m.removedcontact_messages = nil
  8703. }
  8704. // Where appends a list predicates to the ContactMutation builder.
  8705. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8706. m.predicates = append(m.predicates, ps...)
  8707. }
  8708. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8709. // users can use type-assertion to append predicates that do not depend on any generated package.
  8710. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8711. p := make([]predicate.Contact, len(ps))
  8712. for i := range ps {
  8713. p[i] = ps[i]
  8714. }
  8715. m.Where(p...)
  8716. }
  8717. // Op returns the operation name.
  8718. func (m *ContactMutation) Op() Op {
  8719. return m.op
  8720. }
  8721. // SetOp allows setting the mutation operation.
  8722. func (m *ContactMutation) SetOp(op Op) {
  8723. m.op = op
  8724. }
  8725. // Type returns the node type of this mutation (Contact).
  8726. func (m *ContactMutation) Type() string {
  8727. return m.typ
  8728. }
  8729. // Fields returns all fields that were changed during this mutation. Note that in
  8730. // order to get all numeric fields that were incremented/decremented, call
  8731. // AddedFields().
  8732. func (m *ContactMutation) Fields() []string {
  8733. fields := make([]string, 0, 20)
  8734. if m.created_at != nil {
  8735. fields = append(fields, contact.FieldCreatedAt)
  8736. }
  8737. if m.updated_at != nil {
  8738. fields = append(fields, contact.FieldUpdatedAt)
  8739. }
  8740. if m.status != nil {
  8741. fields = append(fields, contact.FieldStatus)
  8742. }
  8743. if m.deleted_at != nil {
  8744. fields = append(fields, contact.FieldDeletedAt)
  8745. }
  8746. if m.wx_wxid != nil {
  8747. fields = append(fields, contact.FieldWxWxid)
  8748. }
  8749. if m._type != nil {
  8750. fields = append(fields, contact.FieldType)
  8751. }
  8752. if m.wxid != nil {
  8753. fields = append(fields, contact.FieldWxid)
  8754. }
  8755. if m.account != nil {
  8756. fields = append(fields, contact.FieldAccount)
  8757. }
  8758. if m.nickname != nil {
  8759. fields = append(fields, contact.FieldNickname)
  8760. }
  8761. if m.markname != nil {
  8762. fields = append(fields, contact.FieldMarkname)
  8763. }
  8764. if m.headimg != nil {
  8765. fields = append(fields, contact.FieldHeadimg)
  8766. }
  8767. if m.sex != nil {
  8768. fields = append(fields, contact.FieldSex)
  8769. }
  8770. if m.starrole != nil {
  8771. fields = append(fields, contact.FieldStarrole)
  8772. }
  8773. if m.dontseeit != nil {
  8774. fields = append(fields, contact.FieldDontseeit)
  8775. }
  8776. if m.dontseeme != nil {
  8777. fields = append(fields, contact.FieldDontseeme)
  8778. }
  8779. if m.lag != nil {
  8780. fields = append(fields, contact.FieldLag)
  8781. }
  8782. if m.gid != nil {
  8783. fields = append(fields, contact.FieldGid)
  8784. }
  8785. if m.gname != nil {
  8786. fields = append(fields, contact.FieldGname)
  8787. }
  8788. if m.v3 != nil {
  8789. fields = append(fields, contact.FieldV3)
  8790. }
  8791. if m.organization_id != nil {
  8792. fields = append(fields, contact.FieldOrganizationID)
  8793. }
  8794. return fields
  8795. }
  8796. // Field returns the value of a field with the given name. The second boolean
  8797. // return value indicates that this field was not set, or was not defined in the
  8798. // schema.
  8799. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8800. switch name {
  8801. case contact.FieldCreatedAt:
  8802. return m.CreatedAt()
  8803. case contact.FieldUpdatedAt:
  8804. return m.UpdatedAt()
  8805. case contact.FieldStatus:
  8806. return m.Status()
  8807. case contact.FieldDeletedAt:
  8808. return m.DeletedAt()
  8809. case contact.FieldWxWxid:
  8810. return m.WxWxid()
  8811. case contact.FieldType:
  8812. return m.GetType()
  8813. case contact.FieldWxid:
  8814. return m.Wxid()
  8815. case contact.FieldAccount:
  8816. return m.Account()
  8817. case contact.FieldNickname:
  8818. return m.Nickname()
  8819. case contact.FieldMarkname:
  8820. return m.Markname()
  8821. case contact.FieldHeadimg:
  8822. return m.Headimg()
  8823. case contact.FieldSex:
  8824. return m.Sex()
  8825. case contact.FieldStarrole:
  8826. return m.Starrole()
  8827. case contact.FieldDontseeit:
  8828. return m.Dontseeit()
  8829. case contact.FieldDontseeme:
  8830. return m.Dontseeme()
  8831. case contact.FieldLag:
  8832. return m.Lag()
  8833. case contact.FieldGid:
  8834. return m.Gid()
  8835. case contact.FieldGname:
  8836. return m.Gname()
  8837. case contact.FieldV3:
  8838. return m.V3()
  8839. case contact.FieldOrganizationID:
  8840. return m.OrganizationID()
  8841. }
  8842. return nil, false
  8843. }
  8844. // OldField returns the old value of the field from the database. An error is
  8845. // returned if the mutation operation is not UpdateOne, or the query to the
  8846. // database failed.
  8847. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8848. switch name {
  8849. case contact.FieldCreatedAt:
  8850. return m.OldCreatedAt(ctx)
  8851. case contact.FieldUpdatedAt:
  8852. return m.OldUpdatedAt(ctx)
  8853. case contact.FieldStatus:
  8854. return m.OldStatus(ctx)
  8855. case contact.FieldDeletedAt:
  8856. return m.OldDeletedAt(ctx)
  8857. case contact.FieldWxWxid:
  8858. return m.OldWxWxid(ctx)
  8859. case contact.FieldType:
  8860. return m.OldType(ctx)
  8861. case contact.FieldWxid:
  8862. return m.OldWxid(ctx)
  8863. case contact.FieldAccount:
  8864. return m.OldAccount(ctx)
  8865. case contact.FieldNickname:
  8866. return m.OldNickname(ctx)
  8867. case contact.FieldMarkname:
  8868. return m.OldMarkname(ctx)
  8869. case contact.FieldHeadimg:
  8870. return m.OldHeadimg(ctx)
  8871. case contact.FieldSex:
  8872. return m.OldSex(ctx)
  8873. case contact.FieldStarrole:
  8874. return m.OldStarrole(ctx)
  8875. case contact.FieldDontseeit:
  8876. return m.OldDontseeit(ctx)
  8877. case contact.FieldDontseeme:
  8878. return m.OldDontseeme(ctx)
  8879. case contact.FieldLag:
  8880. return m.OldLag(ctx)
  8881. case contact.FieldGid:
  8882. return m.OldGid(ctx)
  8883. case contact.FieldGname:
  8884. return m.OldGname(ctx)
  8885. case contact.FieldV3:
  8886. return m.OldV3(ctx)
  8887. case contact.FieldOrganizationID:
  8888. return m.OldOrganizationID(ctx)
  8889. }
  8890. return nil, fmt.Errorf("unknown Contact field %s", name)
  8891. }
  8892. // SetField sets the value of a field with the given name. It returns an error if
  8893. // the field is not defined in the schema, or if the type mismatched the field
  8894. // type.
  8895. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8896. switch name {
  8897. case contact.FieldCreatedAt:
  8898. v, ok := value.(time.Time)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetCreatedAt(v)
  8903. return nil
  8904. case contact.FieldUpdatedAt:
  8905. v, ok := value.(time.Time)
  8906. if !ok {
  8907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8908. }
  8909. m.SetUpdatedAt(v)
  8910. return nil
  8911. case contact.FieldStatus:
  8912. v, ok := value.(uint8)
  8913. if !ok {
  8914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8915. }
  8916. m.SetStatus(v)
  8917. return nil
  8918. case contact.FieldDeletedAt:
  8919. v, ok := value.(time.Time)
  8920. if !ok {
  8921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8922. }
  8923. m.SetDeletedAt(v)
  8924. return nil
  8925. case contact.FieldWxWxid:
  8926. v, ok := value.(string)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.SetWxWxid(v)
  8931. return nil
  8932. case contact.FieldType:
  8933. v, ok := value.(int)
  8934. if !ok {
  8935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8936. }
  8937. m.SetType(v)
  8938. return nil
  8939. case contact.FieldWxid:
  8940. v, ok := value.(string)
  8941. if !ok {
  8942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8943. }
  8944. m.SetWxid(v)
  8945. return nil
  8946. case contact.FieldAccount:
  8947. v, ok := value.(string)
  8948. if !ok {
  8949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8950. }
  8951. m.SetAccount(v)
  8952. return nil
  8953. case contact.FieldNickname:
  8954. v, ok := value.(string)
  8955. if !ok {
  8956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8957. }
  8958. m.SetNickname(v)
  8959. return nil
  8960. case contact.FieldMarkname:
  8961. v, ok := value.(string)
  8962. if !ok {
  8963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8964. }
  8965. m.SetMarkname(v)
  8966. return nil
  8967. case contact.FieldHeadimg:
  8968. v, ok := value.(string)
  8969. if !ok {
  8970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8971. }
  8972. m.SetHeadimg(v)
  8973. return nil
  8974. case contact.FieldSex:
  8975. v, ok := value.(int)
  8976. if !ok {
  8977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8978. }
  8979. m.SetSex(v)
  8980. return nil
  8981. case contact.FieldStarrole:
  8982. v, ok := value.(string)
  8983. if !ok {
  8984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8985. }
  8986. m.SetStarrole(v)
  8987. return nil
  8988. case contact.FieldDontseeit:
  8989. v, ok := value.(int)
  8990. if !ok {
  8991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8992. }
  8993. m.SetDontseeit(v)
  8994. return nil
  8995. case contact.FieldDontseeme:
  8996. v, ok := value.(int)
  8997. if !ok {
  8998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8999. }
  9000. m.SetDontseeme(v)
  9001. return nil
  9002. case contact.FieldLag:
  9003. v, ok := value.(string)
  9004. if !ok {
  9005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9006. }
  9007. m.SetLag(v)
  9008. return nil
  9009. case contact.FieldGid:
  9010. v, ok := value.(string)
  9011. if !ok {
  9012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9013. }
  9014. m.SetGid(v)
  9015. return nil
  9016. case contact.FieldGname:
  9017. v, ok := value.(string)
  9018. if !ok {
  9019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9020. }
  9021. m.SetGname(v)
  9022. return nil
  9023. case contact.FieldV3:
  9024. v, ok := value.(string)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.SetV3(v)
  9029. return nil
  9030. case contact.FieldOrganizationID:
  9031. v, ok := value.(uint64)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.SetOrganizationID(v)
  9036. return nil
  9037. }
  9038. return fmt.Errorf("unknown Contact field %s", name)
  9039. }
  9040. // AddedFields returns all numeric fields that were incremented/decremented during
  9041. // this mutation.
  9042. func (m *ContactMutation) AddedFields() []string {
  9043. var fields []string
  9044. if m.addstatus != nil {
  9045. fields = append(fields, contact.FieldStatus)
  9046. }
  9047. if m.add_type != nil {
  9048. fields = append(fields, contact.FieldType)
  9049. }
  9050. if m.addsex != nil {
  9051. fields = append(fields, contact.FieldSex)
  9052. }
  9053. if m.adddontseeit != nil {
  9054. fields = append(fields, contact.FieldDontseeit)
  9055. }
  9056. if m.adddontseeme != nil {
  9057. fields = append(fields, contact.FieldDontseeme)
  9058. }
  9059. if m.addorganization_id != nil {
  9060. fields = append(fields, contact.FieldOrganizationID)
  9061. }
  9062. return fields
  9063. }
  9064. // AddedField returns the numeric value that was incremented/decremented on a field
  9065. // with the given name. The second boolean return value indicates that this field
  9066. // was not set, or was not defined in the schema.
  9067. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9068. switch name {
  9069. case contact.FieldStatus:
  9070. return m.AddedStatus()
  9071. case contact.FieldType:
  9072. return m.AddedType()
  9073. case contact.FieldSex:
  9074. return m.AddedSex()
  9075. case contact.FieldDontseeit:
  9076. return m.AddedDontseeit()
  9077. case contact.FieldDontseeme:
  9078. return m.AddedDontseeme()
  9079. case contact.FieldOrganizationID:
  9080. return m.AddedOrganizationID()
  9081. }
  9082. return nil, false
  9083. }
  9084. // AddField adds the value to the field with the given name. It returns an error if
  9085. // the field is not defined in the schema, or if the type mismatched the field
  9086. // type.
  9087. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9088. switch name {
  9089. case contact.FieldStatus:
  9090. v, ok := value.(int8)
  9091. if !ok {
  9092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9093. }
  9094. m.AddStatus(v)
  9095. return nil
  9096. case contact.FieldType:
  9097. v, ok := value.(int)
  9098. if !ok {
  9099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9100. }
  9101. m.AddType(v)
  9102. return nil
  9103. case contact.FieldSex:
  9104. v, ok := value.(int)
  9105. if !ok {
  9106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9107. }
  9108. m.AddSex(v)
  9109. return nil
  9110. case contact.FieldDontseeit:
  9111. v, ok := value.(int)
  9112. if !ok {
  9113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9114. }
  9115. m.AddDontseeit(v)
  9116. return nil
  9117. case contact.FieldDontseeme:
  9118. v, ok := value.(int)
  9119. if !ok {
  9120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9121. }
  9122. m.AddDontseeme(v)
  9123. return nil
  9124. case contact.FieldOrganizationID:
  9125. v, ok := value.(int64)
  9126. if !ok {
  9127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9128. }
  9129. m.AddOrganizationID(v)
  9130. return nil
  9131. }
  9132. return fmt.Errorf("unknown Contact numeric field %s", name)
  9133. }
  9134. // ClearedFields returns all nullable fields that were cleared during this
  9135. // mutation.
  9136. func (m *ContactMutation) ClearedFields() []string {
  9137. var fields []string
  9138. if m.FieldCleared(contact.FieldStatus) {
  9139. fields = append(fields, contact.FieldStatus)
  9140. }
  9141. if m.FieldCleared(contact.FieldDeletedAt) {
  9142. fields = append(fields, contact.FieldDeletedAt)
  9143. }
  9144. if m.FieldCleared(contact.FieldType) {
  9145. fields = append(fields, contact.FieldType)
  9146. }
  9147. if m.FieldCleared(contact.FieldOrganizationID) {
  9148. fields = append(fields, contact.FieldOrganizationID)
  9149. }
  9150. return fields
  9151. }
  9152. // FieldCleared returns a boolean indicating if a field with the given name was
  9153. // cleared in this mutation.
  9154. func (m *ContactMutation) FieldCleared(name string) bool {
  9155. _, ok := m.clearedFields[name]
  9156. return ok
  9157. }
  9158. // ClearField clears the value of the field with the given name. It returns an
  9159. // error if the field is not defined in the schema.
  9160. func (m *ContactMutation) ClearField(name string) error {
  9161. switch name {
  9162. case contact.FieldStatus:
  9163. m.ClearStatus()
  9164. return nil
  9165. case contact.FieldDeletedAt:
  9166. m.ClearDeletedAt()
  9167. return nil
  9168. case contact.FieldType:
  9169. m.ClearType()
  9170. return nil
  9171. case contact.FieldOrganizationID:
  9172. m.ClearOrganizationID()
  9173. return nil
  9174. }
  9175. return fmt.Errorf("unknown Contact nullable field %s", name)
  9176. }
  9177. // ResetField resets all changes in the mutation for the field with the given name.
  9178. // It returns an error if the field is not defined in the schema.
  9179. func (m *ContactMutation) ResetField(name string) error {
  9180. switch name {
  9181. case contact.FieldCreatedAt:
  9182. m.ResetCreatedAt()
  9183. return nil
  9184. case contact.FieldUpdatedAt:
  9185. m.ResetUpdatedAt()
  9186. return nil
  9187. case contact.FieldStatus:
  9188. m.ResetStatus()
  9189. return nil
  9190. case contact.FieldDeletedAt:
  9191. m.ResetDeletedAt()
  9192. return nil
  9193. case contact.FieldWxWxid:
  9194. m.ResetWxWxid()
  9195. return nil
  9196. case contact.FieldType:
  9197. m.ResetType()
  9198. return nil
  9199. case contact.FieldWxid:
  9200. m.ResetWxid()
  9201. return nil
  9202. case contact.FieldAccount:
  9203. m.ResetAccount()
  9204. return nil
  9205. case contact.FieldNickname:
  9206. m.ResetNickname()
  9207. return nil
  9208. case contact.FieldMarkname:
  9209. m.ResetMarkname()
  9210. return nil
  9211. case contact.FieldHeadimg:
  9212. m.ResetHeadimg()
  9213. return nil
  9214. case contact.FieldSex:
  9215. m.ResetSex()
  9216. return nil
  9217. case contact.FieldStarrole:
  9218. m.ResetStarrole()
  9219. return nil
  9220. case contact.FieldDontseeit:
  9221. m.ResetDontseeit()
  9222. return nil
  9223. case contact.FieldDontseeme:
  9224. m.ResetDontseeme()
  9225. return nil
  9226. case contact.FieldLag:
  9227. m.ResetLag()
  9228. return nil
  9229. case contact.FieldGid:
  9230. m.ResetGid()
  9231. return nil
  9232. case contact.FieldGname:
  9233. m.ResetGname()
  9234. return nil
  9235. case contact.FieldV3:
  9236. m.ResetV3()
  9237. return nil
  9238. case contact.FieldOrganizationID:
  9239. m.ResetOrganizationID()
  9240. return nil
  9241. }
  9242. return fmt.Errorf("unknown Contact field %s", name)
  9243. }
  9244. // AddedEdges returns all edge names that were set/added in this mutation.
  9245. func (m *ContactMutation) AddedEdges() []string {
  9246. edges := make([]string, 0, 2)
  9247. if m.contact_relationships != nil {
  9248. edges = append(edges, contact.EdgeContactRelationships)
  9249. }
  9250. if m.contact_messages != nil {
  9251. edges = append(edges, contact.EdgeContactMessages)
  9252. }
  9253. return edges
  9254. }
  9255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9256. // name in this mutation.
  9257. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9258. switch name {
  9259. case contact.EdgeContactRelationships:
  9260. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9261. for id := range m.contact_relationships {
  9262. ids = append(ids, id)
  9263. }
  9264. return ids
  9265. case contact.EdgeContactMessages:
  9266. ids := make([]ent.Value, 0, len(m.contact_messages))
  9267. for id := range m.contact_messages {
  9268. ids = append(ids, id)
  9269. }
  9270. return ids
  9271. }
  9272. return nil
  9273. }
  9274. // RemovedEdges returns all edge names that were removed in this mutation.
  9275. func (m *ContactMutation) RemovedEdges() []string {
  9276. edges := make([]string, 0, 2)
  9277. if m.removedcontact_relationships != nil {
  9278. edges = append(edges, contact.EdgeContactRelationships)
  9279. }
  9280. if m.removedcontact_messages != nil {
  9281. edges = append(edges, contact.EdgeContactMessages)
  9282. }
  9283. return edges
  9284. }
  9285. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9286. // the given name in this mutation.
  9287. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9288. switch name {
  9289. case contact.EdgeContactRelationships:
  9290. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9291. for id := range m.removedcontact_relationships {
  9292. ids = append(ids, id)
  9293. }
  9294. return ids
  9295. case contact.EdgeContactMessages:
  9296. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9297. for id := range m.removedcontact_messages {
  9298. ids = append(ids, id)
  9299. }
  9300. return ids
  9301. }
  9302. return nil
  9303. }
  9304. // ClearedEdges returns all edge names that were cleared in this mutation.
  9305. func (m *ContactMutation) ClearedEdges() []string {
  9306. edges := make([]string, 0, 2)
  9307. if m.clearedcontact_relationships {
  9308. edges = append(edges, contact.EdgeContactRelationships)
  9309. }
  9310. if m.clearedcontact_messages {
  9311. edges = append(edges, contact.EdgeContactMessages)
  9312. }
  9313. return edges
  9314. }
  9315. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9316. // was cleared in this mutation.
  9317. func (m *ContactMutation) EdgeCleared(name string) bool {
  9318. switch name {
  9319. case contact.EdgeContactRelationships:
  9320. return m.clearedcontact_relationships
  9321. case contact.EdgeContactMessages:
  9322. return m.clearedcontact_messages
  9323. }
  9324. return false
  9325. }
  9326. // ClearEdge clears the value of the edge with the given name. It returns an error
  9327. // if that edge is not defined in the schema.
  9328. func (m *ContactMutation) ClearEdge(name string) error {
  9329. switch name {
  9330. }
  9331. return fmt.Errorf("unknown Contact unique edge %s", name)
  9332. }
  9333. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9334. // It returns an error if the edge is not defined in the schema.
  9335. func (m *ContactMutation) ResetEdge(name string) error {
  9336. switch name {
  9337. case contact.EdgeContactRelationships:
  9338. m.ResetContactRelationships()
  9339. return nil
  9340. case contact.EdgeContactMessages:
  9341. m.ResetContactMessages()
  9342. return nil
  9343. }
  9344. return fmt.Errorf("unknown Contact edge %s", name)
  9345. }
  9346. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9347. type CreditBalanceMutation struct {
  9348. config
  9349. op Op
  9350. typ string
  9351. id *uint64
  9352. created_at *time.Time
  9353. updated_at *time.Time
  9354. deleted_at *time.Time
  9355. user_id *string
  9356. balance *float32
  9357. addbalance *float32
  9358. status *int
  9359. addstatus *int
  9360. organization_id *uint64
  9361. addorganization_id *int64
  9362. clearedFields map[string]struct{}
  9363. done bool
  9364. oldValue func(context.Context) (*CreditBalance, error)
  9365. predicates []predicate.CreditBalance
  9366. }
  9367. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9368. // creditbalanceOption allows management of the mutation configuration using functional options.
  9369. type creditbalanceOption func(*CreditBalanceMutation)
  9370. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9371. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9372. m := &CreditBalanceMutation{
  9373. config: c,
  9374. op: op,
  9375. typ: TypeCreditBalance,
  9376. clearedFields: make(map[string]struct{}),
  9377. }
  9378. for _, opt := range opts {
  9379. opt(m)
  9380. }
  9381. return m
  9382. }
  9383. // withCreditBalanceID sets the ID field of the mutation.
  9384. func withCreditBalanceID(id uint64) creditbalanceOption {
  9385. return func(m *CreditBalanceMutation) {
  9386. var (
  9387. err error
  9388. once sync.Once
  9389. value *CreditBalance
  9390. )
  9391. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9392. once.Do(func() {
  9393. if m.done {
  9394. err = errors.New("querying old values post mutation is not allowed")
  9395. } else {
  9396. value, err = m.Client().CreditBalance.Get(ctx, id)
  9397. }
  9398. })
  9399. return value, err
  9400. }
  9401. m.id = &id
  9402. }
  9403. }
  9404. // withCreditBalance sets the old CreditBalance of the mutation.
  9405. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9406. return func(m *CreditBalanceMutation) {
  9407. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9408. return node, nil
  9409. }
  9410. m.id = &node.ID
  9411. }
  9412. }
  9413. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9414. // executed in a transaction (ent.Tx), a transactional client is returned.
  9415. func (m CreditBalanceMutation) Client() *Client {
  9416. client := &Client{config: m.config}
  9417. client.init()
  9418. return client
  9419. }
  9420. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9421. // it returns an error otherwise.
  9422. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9423. if _, ok := m.driver.(*txDriver); !ok {
  9424. return nil, errors.New("ent: mutation is not running in a transaction")
  9425. }
  9426. tx := &Tx{config: m.config}
  9427. tx.init()
  9428. return tx, nil
  9429. }
  9430. // SetID sets the value of the id field. Note that this
  9431. // operation is only accepted on creation of CreditBalance entities.
  9432. func (m *CreditBalanceMutation) SetID(id uint64) {
  9433. m.id = &id
  9434. }
  9435. // ID returns the ID value in the mutation. Note that the ID is only available
  9436. // if it was provided to the builder or after it was returned from the database.
  9437. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9438. if m.id == nil {
  9439. return
  9440. }
  9441. return *m.id, true
  9442. }
  9443. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9444. // That means, if the mutation is applied within a transaction with an isolation level such
  9445. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9446. // or updated by the mutation.
  9447. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9448. switch {
  9449. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9450. id, exists := m.ID()
  9451. if exists {
  9452. return []uint64{id}, nil
  9453. }
  9454. fallthrough
  9455. case m.op.Is(OpUpdate | OpDelete):
  9456. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9457. default:
  9458. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9459. }
  9460. }
  9461. // SetCreatedAt sets the "created_at" field.
  9462. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9463. m.created_at = &t
  9464. }
  9465. // CreatedAt returns the value of the "created_at" field in the mutation.
  9466. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9467. v := m.created_at
  9468. if v == nil {
  9469. return
  9470. }
  9471. return *v, true
  9472. }
  9473. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9474. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9476. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9477. if !m.op.Is(OpUpdateOne) {
  9478. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9479. }
  9480. if m.id == nil || m.oldValue == nil {
  9481. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9482. }
  9483. oldValue, err := m.oldValue(ctx)
  9484. if err != nil {
  9485. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9486. }
  9487. return oldValue.CreatedAt, nil
  9488. }
  9489. // ResetCreatedAt resets all changes to the "created_at" field.
  9490. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9491. m.created_at = nil
  9492. }
  9493. // SetUpdatedAt sets the "updated_at" field.
  9494. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9495. m.updated_at = &t
  9496. }
  9497. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9498. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9499. v := m.updated_at
  9500. if v == nil {
  9501. return
  9502. }
  9503. return *v, true
  9504. }
  9505. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9506. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9508. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9509. if !m.op.Is(OpUpdateOne) {
  9510. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9511. }
  9512. if m.id == nil || m.oldValue == nil {
  9513. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9514. }
  9515. oldValue, err := m.oldValue(ctx)
  9516. if err != nil {
  9517. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9518. }
  9519. return oldValue.UpdatedAt, nil
  9520. }
  9521. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9522. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9523. m.updated_at = nil
  9524. }
  9525. // SetDeletedAt sets the "deleted_at" field.
  9526. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9527. m.deleted_at = &t
  9528. }
  9529. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9530. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9531. v := m.deleted_at
  9532. if v == nil {
  9533. return
  9534. }
  9535. return *v, true
  9536. }
  9537. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9538. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9540. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9541. if !m.op.Is(OpUpdateOne) {
  9542. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9543. }
  9544. if m.id == nil || m.oldValue == nil {
  9545. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9546. }
  9547. oldValue, err := m.oldValue(ctx)
  9548. if err != nil {
  9549. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9550. }
  9551. return oldValue.DeletedAt, nil
  9552. }
  9553. // ClearDeletedAt clears the value of the "deleted_at" field.
  9554. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9555. m.deleted_at = nil
  9556. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9557. }
  9558. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9559. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9560. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9561. return ok
  9562. }
  9563. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9564. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9565. m.deleted_at = nil
  9566. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9567. }
  9568. // SetUserID sets the "user_id" field.
  9569. func (m *CreditBalanceMutation) SetUserID(s string) {
  9570. m.user_id = &s
  9571. }
  9572. // UserID returns the value of the "user_id" field in the mutation.
  9573. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9574. v := m.user_id
  9575. if v == nil {
  9576. return
  9577. }
  9578. return *v, true
  9579. }
  9580. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9581. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9583. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9584. if !m.op.Is(OpUpdateOne) {
  9585. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9586. }
  9587. if m.id == nil || m.oldValue == nil {
  9588. return v, errors.New("OldUserID requires an ID field in the mutation")
  9589. }
  9590. oldValue, err := m.oldValue(ctx)
  9591. if err != nil {
  9592. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9593. }
  9594. return oldValue.UserID, nil
  9595. }
  9596. // ClearUserID clears the value of the "user_id" field.
  9597. func (m *CreditBalanceMutation) ClearUserID() {
  9598. m.user_id = nil
  9599. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  9600. }
  9601. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  9602. func (m *CreditBalanceMutation) UserIDCleared() bool {
  9603. _, ok := m.clearedFields[creditbalance.FieldUserID]
  9604. return ok
  9605. }
  9606. // ResetUserID resets all changes to the "user_id" field.
  9607. func (m *CreditBalanceMutation) ResetUserID() {
  9608. m.user_id = nil
  9609. delete(m.clearedFields, creditbalance.FieldUserID)
  9610. }
  9611. // SetBalance sets the "balance" field.
  9612. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9613. m.balance = &f
  9614. m.addbalance = nil
  9615. }
  9616. // Balance returns the value of the "balance" field in the mutation.
  9617. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9618. v := m.balance
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9625. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldBalance requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9637. }
  9638. return oldValue.Balance, nil
  9639. }
  9640. // AddBalance adds f to the "balance" field.
  9641. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9642. if m.addbalance != nil {
  9643. *m.addbalance += f
  9644. } else {
  9645. m.addbalance = &f
  9646. }
  9647. }
  9648. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9649. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9650. v := m.addbalance
  9651. if v == nil {
  9652. return
  9653. }
  9654. return *v, true
  9655. }
  9656. // ResetBalance resets all changes to the "balance" field.
  9657. func (m *CreditBalanceMutation) ResetBalance() {
  9658. m.balance = nil
  9659. m.addbalance = nil
  9660. }
  9661. // SetStatus sets the "status" field.
  9662. func (m *CreditBalanceMutation) SetStatus(i int) {
  9663. m.status = &i
  9664. m.addstatus = nil
  9665. }
  9666. // Status returns the value of the "status" field in the mutation.
  9667. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9668. v := m.status
  9669. if v == nil {
  9670. return
  9671. }
  9672. return *v, true
  9673. }
  9674. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9675. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9677. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9678. if !m.op.Is(OpUpdateOne) {
  9679. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9680. }
  9681. if m.id == nil || m.oldValue == nil {
  9682. return v, errors.New("OldStatus requires an ID field in the mutation")
  9683. }
  9684. oldValue, err := m.oldValue(ctx)
  9685. if err != nil {
  9686. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9687. }
  9688. return oldValue.Status, nil
  9689. }
  9690. // AddStatus adds i to the "status" field.
  9691. func (m *CreditBalanceMutation) AddStatus(i int) {
  9692. if m.addstatus != nil {
  9693. *m.addstatus += i
  9694. } else {
  9695. m.addstatus = &i
  9696. }
  9697. }
  9698. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9699. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9700. v := m.addstatus
  9701. if v == nil {
  9702. return
  9703. }
  9704. return *v, true
  9705. }
  9706. // ClearStatus clears the value of the "status" field.
  9707. func (m *CreditBalanceMutation) ClearStatus() {
  9708. m.status = nil
  9709. m.addstatus = nil
  9710. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9711. }
  9712. // StatusCleared returns if the "status" field was cleared in this mutation.
  9713. func (m *CreditBalanceMutation) StatusCleared() bool {
  9714. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9715. return ok
  9716. }
  9717. // ResetStatus resets all changes to the "status" field.
  9718. func (m *CreditBalanceMutation) ResetStatus() {
  9719. m.status = nil
  9720. m.addstatus = nil
  9721. delete(m.clearedFields, creditbalance.FieldStatus)
  9722. }
  9723. // SetOrganizationID sets the "organization_id" field.
  9724. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9725. m.organization_id = &u
  9726. m.addorganization_id = nil
  9727. }
  9728. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9729. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9730. v := m.organization_id
  9731. if v == nil {
  9732. return
  9733. }
  9734. return *v, true
  9735. }
  9736. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9737. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9739. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9740. if !m.op.Is(OpUpdateOne) {
  9741. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9742. }
  9743. if m.id == nil || m.oldValue == nil {
  9744. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9745. }
  9746. oldValue, err := m.oldValue(ctx)
  9747. if err != nil {
  9748. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9749. }
  9750. return oldValue.OrganizationID, nil
  9751. }
  9752. // AddOrganizationID adds u to the "organization_id" field.
  9753. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9754. if m.addorganization_id != nil {
  9755. *m.addorganization_id += u
  9756. } else {
  9757. m.addorganization_id = &u
  9758. }
  9759. }
  9760. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9761. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9762. v := m.addorganization_id
  9763. if v == nil {
  9764. return
  9765. }
  9766. return *v, true
  9767. }
  9768. // ClearOrganizationID clears the value of the "organization_id" field.
  9769. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9770. m.organization_id = nil
  9771. m.addorganization_id = nil
  9772. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9773. }
  9774. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9775. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9776. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9777. return ok
  9778. }
  9779. // ResetOrganizationID resets all changes to the "organization_id" field.
  9780. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9781. m.organization_id = nil
  9782. m.addorganization_id = nil
  9783. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9784. }
  9785. // Where appends a list predicates to the CreditBalanceMutation builder.
  9786. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9787. m.predicates = append(m.predicates, ps...)
  9788. }
  9789. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9790. // users can use type-assertion to append predicates that do not depend on any generated package.
  9791. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9792. p := make([]predicate.CreditBalance, len(ps))
  9793. for i := range ps {
  9794. p[i] = ps[i]
  9795. }
  9796. m.Where(p...)
  9797. }
  9798. // Op returns the operation name.
  9799. func (m *CreditBalanceMutation) Op() Op {
  9800. return m.op
  9801. }
  9802. // SetOp allows setting the mutation operation.
  9803. func (m *CreditBalanceMutation) SetOp(op Op) {
  9804. m.op = op
  9805. }
  9806. // Type returns the node type of this mutation (CreditBalance).
  9807. func (m *CreditBalanceMutation) Type() string {
  9808. return m.typ
  9809. }
  9810. // Fields returns all fields that were changed during this mutation. Note that in
  9811. // order to get all numeric fields that were incremented/decremented, call
  9812. // AddedFields().
  9813. func (m *CreditBalanceMutation) Fields() []string {
  9814. fields := make([]string, 0, 7)
  9815. if m.created_at != nil {
  9816. fields = append(fields, creditbalance.FieldCreatedAt)
  9817. }
  9818. if m.updated_at != nil {
  9819. fields = append(fields, creditbalance.FieldUpdatedAt)
  9820. }
  9821. if m.deleted_at != nil {
  9822. fields = append(fields, creditbalance.FieldDeletedAt)
  9823. }
  9824. if m.user_id != nil {
  9825. fields = append(fields, creditbalance.FieldUserID)
  9826. }
  9827. if m.balance != nil {
  9828. fields = append(fields, creditbalance.FieldBalance)
  9829. }
  9830. if m.status != nil {
  9831. fields = append(fields, creditbalance.FieldStatus)
  9832. }
  9833. if m.organization_id != nil {
  9834. fields = append(fields, creditbalance.FieldOrganizationID)
  9835. }
  9836. return fields
  9837. }
  9838. // Field returns the value of a field with the given name. The second boolean
  9839. // return value indicates that this field was not set, or was not defined in the
  9840. // schema.
  9841. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9842. switch name {
  9843. case creditbalance.FieldCreatedAt:
  9844. return m.CreatedAt()
  9845. case creditbalance.FieldUpdatedAt:
  9846. return m.UpdatedAt()
  9847. case creditbalance.FieldDeletedAt:
  9848. return m.DeletedAt()
  9849. case creditbalance.FieldUserID:
  9850. return m.UserID()
  9851. case creditbalance.FieldBalance:
  9852. return m.Balance()
  9853. case creditbalance.FieldStatus:
  9854. return m.Status()
  9855. case creditbalance.FieldOrganizationID:
  9856. return m.OrganizationID()
  9857. }
  9858. return nil, false
  9859. }
  9860. // OldField returns the old value of the field from the database. An error is
  9861. // returned if the mutation operation is not UpdateOne, or the query to the
  9862. // database failed.
  9863. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9864. switch name {
  9865. case creditbalance.FieldCreatedAt:
  9866. return m.OldCreatedAt(ctx)
  9867. case creditbalance.FieldUpdatedAt:
  9868. return m.OldUpdatedAt(ctx)
  9869. case creditbalance.FieldDeletedAt:
  9870. return m.OldDeletedAt(ctx)
  9871. case creditbalance.FieldUserID:
  9872. return m.OldUserID(ctx)
  9873. case creditbalance.FieldBalance:
  9874. return m.OldBalance(ctx)
  9875. case creditbalance.FieldStatus:
  9876. return m.OldStatus(ctx)
  9877. case creditbalance.FieldOrganizationID:
  9878. return m.OldOrganizationID(ctx)
  9879. }
  9880. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9881. }
  9882. // SetField sets the value of a field with the given name. It returns an error if
  9883. // the field is not defined in the schema, or if the type mismatched the field
  9884. // type.
  9885. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9886. switch name {
  9887. case creditbalance.FieldCreatedAt:
  9888. v, ok := value.(time.Time)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.SetCreatedAt(v)
  9893. return nil
  9894. case creditbalance.FieldUpdatedAt:
  9895. v, ok := value.(time.Time)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.SetUpdatedAt(v)
  9900. return nil
  9901. case creditbalance.FieldDeletedAt:
  9902. v, ok := value.(time.Time)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.SetDeletedAt(v)
  9907. return nil
  9908. case creditbalance.FieldUserID:
  9909. v, ok := value.(string)
  9910. if !ok {
  9911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9912. }
  9913. m.SetUserID(v)
  9914. return nil
  9915. case creditbalance.FieldBalance:
  9916. v, ok := value.(float32)
  9917. if !ok {
  9918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9919. }
  9920. m.SetBalance(v)
  9921. return nil
  9922. case creditbalance.FieldStatus:
  9923. v, ok := value.(int)
  9924. if !ok {
  9925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9926. }
  9927. m.SetStatus(v)
  9928. return nil
  9929. case creditbalance.FieldOrganizationID:
  9930. v, ok := value.(uint64)
  9931. if !ok {
  9932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9933. }
  9934. m.SetOrganizationID(v)
  9935. return nil
  9936. }
  9937. return fmt.Errorf("unknown CreditBalance field %s", name)
  9938. }
  9939. // AddedFields returns all numeric fields that were incremented/decremented during
  9940. // this mutation.
  9941. func (m *CreditBalanceMutation) AddedFields() []string {
  9942. var fields []string
  9943. if m.addbalance != nil {
  9944. fields = append(fields, creditbalance.FieldBalance)
  9945. }
  9946. if m.addstatus != nil {
  9947. fields = append(fields, creditbalance.FieldStatus)
  9948. }
  9949. if m.addorganization_id != nil {
  9950. fields = append(fields, creditbalance.FieldOrganizationID)
  9951. }
  9952. return fields
  9953. }
  9954. // AddedField returns the numeric value that was incremented/decremented on a field
  9955. // with the given name. The second boolean return value indicates that this field
  9956. // was not set, or was not defined in the schema.
  9957. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9958. switch name {
  9959. case creditbalance.FieldBalance:
  9960. return m.AddedBalance()
  9961. case creditbalance.FieldStatus:
  9962. return m.AddedStatus()
  9963. case creditbalance.FieldOrganizationID:
  9964. return m.AddedOrganizationID()
  9965. }
  9966. return nil, false
  9967. }
  9968. // AddField adds the value to the field with the given name. It returns an error if
  9969. // the field is not defined in the schema, or if the type mismatched the field
  9970. // type.
  9971. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9972. switch name {
  9973. case creditbalance.FieldBalance:
  9974. v, ok := value.(float32)
  9975. if !ok {
  9976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9977. }
  9978. m.AddBalance(v)
  9979. return nil
  9980. case creditbalance.FieldStatus:
  9981. v, ok := value.(int)
  9982. if !ok {
  9983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9984. }
  9985. m.AddStatus(v)
  9986. return nil
  9987. case creditbalance.FieldOrganizationID:
  9988. v, ok := value.(int64)
  9989. if !ok {
  9990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9991. }
  9992. m.AddOrganizationID(v)
  9993. return nil
  9994. }
  9995. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9996. }
  9997. // ClearedFields returns all nullable fields that were cleared during this
  9998. // mutation.
  9999. func (m *CreditBalanceMutation) ClearedFields() []string {
  10000. var fields []string
  10001. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10002. fields = append(fields, creditbalance.FieldDeletedAt)
  10003. }
  10004. if m.FieldCleared(creditbalance.FieldUserID) {
  10005. fields = append(fields, creditbalance.FieldUserID)
  10006. }
  10007. if m.FieldCleared(creditbalance.FieldStatus) {
  10008. fields = append(fields, creditbalance.FieldStatus)
  10009. }
  10010. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10011. fields = append(fields, creditbalance.FieldOrganizationID)
  10012. }
  10013. return fields
  10014. }
  10015. // FieldCleared returns a boolean indicating if a field with the given name was
  10016. // cleared in this mutation.
  10017. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10018. _, ok := m.clearedFields[name]
  10019. return ok
  10020. }
  10021. // ClearField clears the value of the field with the given name. It returns an
  10022. // error if the field is not defined in the schema.
  10023. func (m *CreditBalanceMutation) ClearField(name string) error {
  10024. switch name {
  10025. case creditbalance.FieldDeletedAt:
  10026. m.ClearDeletedAt()
  10027. return nil
  10028. case creditbalance.FieldUserID:
  10029. m.ClearUserID()
  10030. return nil
  10031. case creditbalance.FieldStatus:
  10032. m.ClearStatus()
  10033. return nil
  10034. case creditbalance.FieldOrganizationID:
  10035. m.ClearOrganizationID()
  10036. return nil
  10037. }
  10038. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10039. }
  10040. // ResetField resets all changes in the mutation for the field with the given name.
  10041. // It returns an error if the field is not defined in the schema.
  10042. func (m *CreditBalanceMutation) ResetField(name string) error {
  10043. switch name {
  10044. case creditbalance.FieldCreatedAt:
  10045. m.ResetCreatedAt()
  10046. return nil
  10047. case creditbalance.FieldUpdatedAt:
  10048. m.ResetUpdatedAt()
  10049. return nil
  10050. case creditbalance.FieldDeletedAt:
  10051. m.ResetDeletedAt()
  10052. return nil
  10053. case creditbalance.FieldUserID:
  10054. m.ResetUserID()
  10055. return nil
  10056. case creditbalance.FieldBalance:
  10057. m.ResetBalance()
  10058. return nil
  10059. case creditbalance.FieldStatus:
  10060. m.ResetStatus()
  10061. return nil
  10062. case creditbalance.FieldOrganizationID:
  10063. m.ResetOrganizationID()
  10064. return nil
  10065. }
  10066. return fmt.Errorf("unknown CreditBalance field %s", name)
  10067. }
  10068. // AddedEdges returns all edge names that were set/added in this mutation.
  10069. func (m *CreditBalanceMutation) AddedEdges() []string {
  10070. edges := make([]string, 0, 0)
  10071. return edges
  10072. }
  10073. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10074. // name in this mutation.
  10075. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10076. return nil
  10077. }
  10078. // RemovedEdges returns all edge names that were removed in this mutation.
  10079. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10080. edges := make([]string, 0, 0)
  10081. return edges
  10082. }
  10083. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10084. // the given name in this mutation.
  10085. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10086. return nil
  10087. }
  10088. // ClearedEdges returns all edge names that were cleared in this mutation.
  10089. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10090. edges := make([]string, 0, 0)
  10091. return edges
  10092. }
  10093. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10094. // was cleared in this mutation.
  10095. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10096. return false
  10097. }
  10098. // ClearEdge clears the value of the edge with the given name. It returns an error
  10099. // if that edge is not defined in the schema.
  10100. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10101. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10102. }
  10103. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10104. // It returns an error if the edge is not defined in the schema.
  10105. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10106. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10107. }
  10108. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10109. type CreditUsageMutation struct {
  10110. config
  10111. op Op
  10112. typ string
  10113. id *uint64
  10114. created_at *time.Time
  10115. updated_at *time.Time
  10116. deleted_at *time.Time
  10117. user_id *string
  10118. number *float32
  10119. addnumber *float32
  10120. status *int
  10121. addstatus *int
  10122. ntype *int
  10123. addntype *int
  10124. table *string
  10125. organization_id *uint64
  10126. addorganization_id *int64
  10127. nid *uint64
  10128. addnid *int64
  10129. reason *string
  10130. operator *string
  10131. clearedFields map[string]struct{}
  10132. done bool
  10133. oldValue func(context.Context) (*CreditUsage, error)
  10134. predicates []predicate.CreditUsage
  10135. }
  10136. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10137. // creditusageOption allows management of the mutation configuration using functional options.
  10138. type creditusageOption func(*CreditUsageMutation)
  10139. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10140. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10141. m := &CreditUsageMutation{
  10142. config: c,
  10143. op: op,
  10144. typ: TypeCreditUsage,
  10145. clearedFields: make(map[string]struct{}),
  10146. }
  10147. for _, opt := range opts {
  10148. opt(m)
  10149. }
  10150. return m
  10151. }
  10152. // withCreditUsageID sets the ID field of the mutation.
  10153. func withCreditUsageID(id uint64) creditusageOption {
  10154. return func(m *CreditUsageMutation) {
  10155. var (
  10156. err error
  10157. once sync.Once
  10158. value *CreditUsage
  10159. )
  10160. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10161. once.Do(func() {
  10162. if m.done {
  10163. err = errors.New("querying old values post mutation is not allowed")
  10164. } else {
  10165. value, err = m.Client().CreditUsage.Get(ctx, id)
  10166. }
  10167. })
  10168. return value, err
  10169. }
  10170. m.id = &id
  10171. }
  10172. }
  10173. // withCreditUsage sets the old CreditUsage of the mutation.
  10174. func withCreditUsage(node *CreditUsage) creditusageOption {
  10175. return func(m *CreditUsageMutation) {
  10176. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10177. return node, nil
  10178. }
  10179. m.id = &node.ID
  10180. }
  10181. }
  10182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10183. // executed in a transaction (ent.Tx), a transactional client is returned.
  10184. func (m CreditUsageMutation) Client() *Client {
  10185. client := &Client{config: m.config}
  10186. client.init()
  10187. return client
  10188. }
  10189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10190. // it returns an error otherwise.
  10191. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10192. if _, ok := m.driver.(*txDriver); !ok {
  10193. return nil, errors.New("ent: mutation is not running in a transaction")
  10194. }
  10195. tx := &Tx{config: m.config}
  10196. tx.init()
  10197. return tx, nil
  10198. }
  10199. // SetID sets the value of the id field. Note that this
  10200. // operation is only accepted on creation of CreditUsage entities.
  10201. func (m *CreditUsageMutation) SetID(id uint64) {
  10202. m.id = &id
  10203. }
  10204. // ID returns the ID value in the mutation. Note that the ID is only available
  10205. // if it was provided to the builder or after it was returned from the database.
  10206. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10207. if m.id == nil {
  10208. return
  10209. }
  10210. return *m.id, true
  10211. }
  10212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10213. // That means, if the mutation is applied within a transaction with an isolation level such
  10214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10215. // or updated by the mutation.
  10216. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10217. switch {
  10218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10219. id, exists := m.ID()
  10220. if exists {
  10221. return []uint64{id}, nil
  10222. }
  10223. fallthrough
  10224. case m.op.Is(OpUpdate | OpDelete):
  10225. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10226. default:
  10227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10228. }
  10229. }
  10230. // SetCreatedAt sets the "created_at" field.
  10231. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10232. m.created_at = &t
  10233. }
  10234. // CreatedAt returns the value of the "created_at" field in the mutation.
  10235. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10236. v := m.created_at
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10243. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10245. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10246. if !m.op.Is(OpUpdateOne) {
  10247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10248. }
  10249. if m.id == nil || m.oldValue == nil {
  10250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10251. }
  10252. oldValue, err := m.oldValue(ctx)
  10253. if err != nil {
  10254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10255. }
  10256. return oldValue.CreatedAt, nil
  10257. }
  10258. // ResetCreatedAt resets all changes to the "created_at" field.
  10259. func (m *CreditUsageMutation) ResetCreatedAt() {
  10260. m.created_at = nil
  10261. }
  10262. // SetUpdatedAt sets the "updated_at" field.
  10263. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10264. m.updated_at = &t
  10265. }
  10266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10267. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10268. v := m.updated_at
  10269. if v == nil {
  10270. return
  10271. }
  10272. return *v, true
  10273. }
  10274. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10275. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10277. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10278. if !m.op.Is(OpUpdateOne) {
  10279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10280. }
  10281. if m.id == nil || m.oldValue == nil {
  10282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10283. }
  10284. oldValue, err := m.oldValue(ctx)
  10285. if err != nil {
  10286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10287. }
  10288. return oldValue.UpdatedAt, nil
  10289. }
  10290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10291. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10292. m.updated_at = nil
  10293. }
  10294. // SetDeletedAt sets the "deleted_at" field.
  10295. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10296. m.deleted_at = &t
  10297. }
  10298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10299. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10300. v := m.deleted_at
  10301. if v == nil {
  10302. return
  10303. }
  10304. return *v, true
  10305. }
  10306. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10307. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10309. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10310. if !m.op.Is(OpUpdateOne) {
  10311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10312. }
  10313. if m.id == nil || m.oldValue == nil {
  10314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10315. }
  10316. oldValue, err := m.oldValue(ctx)
  10317. if err != nil {
  10318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10319. }
  10320. return oldValue.DeletedAt, nil
  10321. }
  10322. // ClearDeletedAt clears the value of the "deleted_at" field.
  10323. func (m *CreditUsageMutation) ClearDeletedAt() {
  10324. m.deleted_at = nil
  10325. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10326. }
  10327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10328. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10329. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10330. return ok
  10331. }
  10332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10333. func (m *CreditUsageMutation) ResetDeletedAt() {
  10334. m.deleted_at = nil
  10335. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10336. }
  10337. // SetUserID sets the "user_id" field.
  10338. func (m *CreditUsageMutation) SetUserID(s string) {
  10339. m.user_id = &s
  10340. }
  10341. // UserID returns the value of the "user_id" field in the mutation.
  10342. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10343. v := m.user_id
  10344. if v == nil {
  10345. return
  10346. }
  10347. return *v, true
  10348. }
  10349. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10350. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10352. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10353. if !m.op.Is(OpUpdateOne) {
  10354. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10355. }
  10356. if m.id == nil || m.oldValue == nil {
  10357. return v, errors.New("OldUserID requires an ID field in the mutation")
  10358. }
  10359. oldValue, err := m.oldValue(ctx)
  10360. if err != nil {
  10361. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10362. }
  10363. return oldValue.UserID, nil
  10364. }
  10365. // ResetUserID resets all changes to the "user_id" field.
  10366. func (m *CreditUsageMutation) ResetUserID() {
  10367. m.user_id = nil
  10368. }
  10369. // SetNumber sets the "number" field.
  10370. func (m *CreditUsageMutation) SetNumber(f float32) {
  10371. m.number = &f
  10372. m.addnumber = nil
  10373. }
  10374. // Number returns the value of the "number" field in the mutation.
  10375. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10376. v := m.number
  10377. if v == nil {
  10378. return
  10379. }
  10380. return *v, true
  10381. }
  10382. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10383. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10385. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10386. if !m.op.Is(OpUpdateOne) {
  10387. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10388. }
  10389. if m.id == nil || m.oldValue == nil {
  10390. return v, errors.New("OldNumber requires an ID field in the mutation")
  10391. }
  10392. oldValue, err := m.oldValue(ctx)
  10393. if err != nil {
  10394. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10395. }
  10396. return oldValue.Number, nil
  10397. }
  10398. // AddNumber adds f to the "number" field.
  10399. func (m *CreditUsageMutation) AddNumber(f float32) {
  10400. if m.addnumber != nil {
  10401. *m.addnumber += f
  10402. } else {
  10403. m.addnumber = &f
  10404. }
  10405. }
  10406. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10407. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10408. v := m.addnumber
  10409. if v == nil {
  10410. return
  10411. }
  10412. return *v, true
  10413. }
  10414. // ResetNumber resets all changes to the "number" field.
  10415. func (m *CreditUsageMutation) ResetNumber() {
  10416. m.number = nil
  10417. m.addnumber = nil
  10418. }
  10419. // SetStatus sets the "status" field.
  10420. func (m *CreditUsageMutation) SetStatus(i int) {
  10421. m.status = &i
  10422. m.addstatus = nil
  10423. }
  10424. // Status returns the value of the "status" field in the mutation.
  10425. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10426. v := m.status
  10427. if v == nil {
  10428. return
  10429. }
  10430. return *v, true
  10431. }
  10432. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10433. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10435. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10436. if !m.op.Is(OpUpdateOne) {
  10437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10438. }
  10439. if m.id == nil || m.oldValue == nil {
  10440. return v, errors.New("OldStatus requires an ID field in the mutation")
  10441. }
  10442. oldValue, err := m.oldValue(ctx)
  10443. if err != nil {
  10444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10445. }
  10446. return oldValue.Status, nil
  10447. }
  10448. // AddStatus adds i to the "status" field.
  10449. func (m *CreditUsageMutation) AddStatus(i int) {
  10450. if m.addstatus != nil {
  10451. *m.addstatus += i
  10452. } else {
  10453. m.addstatus = &i
  10454. }
  10455. }
  10456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10457. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10458. v := m.addstatus
  10459. if v == nil {
  10460. return
  10461. }
  10462. return *v, true
  10463. }
  10464. // ClearStatus clears the value of the "status" field.
  10465. func (m *CreditUsageMutation) ClearStatus() {
  10466. m.status = nil
  10467. m.addstatus = nil
  10468. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10469. }
  10470. // StatusCleared returns if the "status" field was cleared in this mutation.
  10471. func (m *CreditUsageMutation) StatusCleared() bool {
  10472. _, ok := m.clearedFields[creditusage.FieldStatus]
  10473. return ok
  10474. }
  10475. // ResetStatus resets all changes to the "status" field.
  10476. func (m *CreditUsageMutation) ResetStatus() {
  10477. m.status = nil
  10478. m.addstatus = nil
  10479. delete(m.clearedFields, creditusage.FieldStatus)
  10480. }
  10481. // SetNtype sets the "ntype" field.
  10482. func (m *CreditUsageMutation) SetNtype(i int) {
  10483. m.ntype = &i
  10484. m.addntype = nil
  10485. }
  10486. // Ntype returns the value of the "ntype" field in the mutation.
  10487. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10488. v := m.ntype
  10489. if v == nil {
  10490. return
  10491. }
  10492. return *v, true
  10493. }
  10494. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10495. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10497. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10498. if !m.op.Is(OpUpdateOne) {
  10499. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10500. }
  10501. if m.id == nil || m.oldValue == nil {
  10502. return v, errors.New("OldNtype requires an ID field in the mutation")
  10503. }
  10504. oldValue, err := m.oldValue(ctx)
  10505. if err != nil {
  10506. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10507. }
  10508. return oldValue.Ntype, nil
  10509. }
  10510. // AddNtype adds i to the "ntype" field.
  10511. func (m *CreditUsageMutation) AddNtype(i int) {
  10512. if m.addntype != nil {
  10513. *m.addntype += i
  10514. } else {
  10515. m.addntype = &i
  10516. }
  10517. }
  10518. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10519. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10520. v := m.addntype
  10521. if v == nil {
  10522. return
  10523. }
  10524. return *v, true
  10525. }
  10526. // ResetNtype resets all changes to the "ntype" field.
  10527. func (m *CreditUsageMutation) ResetNtype() {
  10528. m.ntype = nil
  10529. m.addntype = nil
  10530. }
  10531. // SetTable sets the "table" field.
  10532. func (m *CreditUsageMutation) SetTable(s string) {
  10533. m.table = &s
  10534. }
  10535. // Table returns the value of the "table" field in the mutation.
  10536. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10537. v := m.table
  10538. if v == nil {
  10539. return
  10540. }
  10541. return *v, true
  10542. }
  10543. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10544. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10546. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10547. if !m.op.Is(OpUpdateOne) {
  10548. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10549. }
  10550. if m.id == nil || m.oldValue == nil {
  10551. return v, errors.New("OldTable requires an ID field in the mutation")
  10552. }
  10553. oldValue, err := m.oldValue(ctx)
  10554. if err != nil {
  10555. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10556. }
  10557. return oldValue.Table, nil
  10558. }
  10559. // ResetTable resets all changes to the "table" field.
  10560. func (m *CreditUsageMutation) ResetTable() {
  10561. m.table = nil
  10562. }
  10563. // SetOrganizationID sets the "organization_id" field.
  10564. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10565. m.organization_id = &u
  10566. m.addorganization_id = nil
  10567. }
  10568. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10569. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10570. v := m.organization_id
  10571. if v == nil {
  10572. return
  10573. }
  10574. return *v, true
  10575. }
  10576. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10577. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10579. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10580. if !m.op.Is(OpUpdateOne) {
  10581. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10582. }
  10583. if m.id == nil || m.oldValue == nil {
  10584. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10585. }
  10586. oldValue, err := m.oldValue(ctx)
  10587. if err != nil {
  10588. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10589. }
  10590. return oldValue.OrganizationID, nil
  10591. }
  10592. // AddOrganizationID adds u to the "organization_id" field.
  10593. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10594. if m.addorganization_id != nil {
  10595. *m.addorganization_id += u
  10596. } else {
  10597. m.addorganization_id = &u
  10598. }
  10599. }
  10600. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10601. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10602. v := m.addorganization_id
  10603. if v == nil {
  10604. return
  10605. }
  10606. return *v, true
  10607. }
  10608. // ClearOrganizationID clears the value of the "organization_id" field.
  10609. func (m *CreditUsageMutation) ClearOrganizationID() {
  10610. m.organization_id = nil
  10611. m.addorganization_id = nil
  10612. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10613. }
  10614. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10615. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10616. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10617. return ok
  10618. }
  10619. // ResetOrganizationID resets all changes to the "organization_id" field.
  10620. func (m *CreditUsageMutation) ResetOrganizationID() {
  10621. m.organization_id = nil
  10622. m.addorganization_id = nil
  10623. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10624. }
  10625. // SetNid sets the "nid" field.
  10626. func (m *CreditUsageMutation) SetNid(u uint64) {
  10627. m.nid = &u
  10628. m.addnid = nil
  10629. }
  10630. // Nid returns the value of the "nid" field in the mutation.
  10631. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10632. v := m.nid
  10633. if v == nil {
  10634. return
  10635. }
  10636. return *v, true
  10637. }
  10638. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10639. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10641. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10642. if !m.op.Is(OpUpdateOne) {
  10643. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10644. }
  10645. if m.id == nil || m.oldValue == nil {
  10646. return v, errors.New("OldNid requires an ID field in the mutation")
  10647. }
  10648. oldValue, err := m.oldValue(ctx)
  10649. if err != nil {
  10650. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10651. }
  10652. return oldValue.Nid, nil
  10653. }
  10654. // AddNid adds u to the "nid" field.
  10655. func (m *CreditUsageMutation) AddNid(u int64) {
  10656. if m.addnid != nil {
  10657. *m.addnid += u
  10658. } else {
  10659. m.addnid = &u
  10660. }
  10661. }
  10662. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10663. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10664. v := m.addnid
  10665. if v == nil {
  10666. return
  10667. }
  10668. return *v, true
  10669. }
  10670. // ResetNid resets all changes to the "nid" field.
  10671. func (m *CreditUsageMutation) ResetNid() {
  10672. m.nid = nil
  10673. m.addnid = nil
  10674. }
  10675. // SetReason sets the "reason" field.
  10676. func (m *CreditUsageMutation) SetReason(s string) {
  10677. m.reason = &s
  10678. }
  10679. // Reason returns the value of the "reason" field in the mutation.
  10680. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10681. v := m.reason
  10682. if v == nil {
  10683. return
  10684. }
  10685. return *v, true
  10686. }
  10687. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10688. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10690. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10691. if !m.op.Is(OpUpdateOne) {
  10692. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10693. }
  10694. if m.id == nil || m.oldValue == nil {
  10695. return v, errors.New("OldReason requires an ID field in the mutation")
  10696. }
  10697. oldValue, err := m.oldValue(ctx)
  10698. if err != nil {
  10699. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10700. }
  10701. return oldValue.Reason, nil
  10702. }
  10703. // ResetReason resets all changes to the "reason" field.
  10704. func (m *CreditUsageMutation) ResetReason() {
  10705. m.reason = nil
  10706. }
  10707. // SetOperator sets the "operator" field.
  10708. func (m *CreditUsageMutation) SetOperator(s string) {
  10709. m.operator = &s
  10710. }
  10711. // Operator returns the value of the "operator" field in the mutation.
  10712. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10713. v := m.operator
  10714. if v == nil {
  10715. return
  10716. }
  10717. return *v, true
  10718. }
  10719. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10720. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10722. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10723. if !m.op.Is(OpUpdateOne) {
  10724. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10725. }
  10726. if m.id == nil || m.oldValue == nil {
  10727. return v, errors.New("OldOperator requires an ID field in the mutation")
  10728. }
  10729. oldValue, err := m.oldValue(ctx)
  10730. if err != nil {
  10731. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10732. }
  10733. return oldValue.Operator, nil
  10734. }
  10735. // ResetOperator resets all changes to the "operator" field.
  10736. func (m *CreditUsageMutation) ResetOperator() {
  10737. m.operator = nil
  10738. }
  10739. // Where appends a list predicates to the CreditUsageMutation builder.
  10740. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10741. m.predicates = append(m.predicates, ps...)
  10742. }
  10743. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10744. // users can use type-assertion to append predicates that do not depend on any generated package.
  10745. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10746. p := make([]predicate.CreditUsage, len(ps))
  10747. for i := range ps {
  10748. p[i] = ps[i]
  10749. }
  10750. m.Where(p...)
  10751. }
  10752. // Op returns the operation name.
  10753. func (m *CreditUsageMutation) Op() Op {
  10754. return m.op
  10755. }
  10756. // SetOp allows setting the mutation operation.
  10757. func (m *CreditUsageMutation) SetOp(op Op) {
  10758. m.op = op
  10759. }
  10760. // Type returns the node type of this mutation (CreditUsage).
  10761. func (m *CreditUsageMutation) Type() string {
  10762. return m.typ
  10763. }
  10764. // Fields returns all fields that were changed during this mutation. Note that in
  10765. // order to get all numeric fields that were incremented/decremented, call
  10766. // AddedFields().
  10767. func (m *CreditUsageMutation) Fields() []string {
  10768. fields := make([]string, 0, 12)
  10769. if m.created_at != nil {
  10770. fields = append(fields, creditusage.FieldCreatedAt)
  10771. }
  10772. if m.updated_at != nil {
  10773. fields = append(fields, creditusage.FieldUpdatedAt)
  10774. }
  10775. if m.deleted_at != nil {
  10776. fields = append(fields, creditusage.FieldDeletedAt)
  10777. }
  10778. if m.user_id != nil {
  10779. fields = append(fields, creditusage.FieldUserID)
  10780. }
  10781. if m.number != nil {
  10782. fields = append(fields, creditusage.FieldNumber)
  10783. }
  10784. if m.status != nil {
  10785. fields = append(fields, creditusage.FieldStatus)
  10786. }
  10787. if m.ntype != nil {
  10788. fields = append(fields, creditusage.FieldNtype)
  10789. }
  10790. if m.table != nil {
  10791. fields = append(fields, creditusage.FieldTable)
  10792. }
  10793. if m.organization_id != nil {
  10794. fields = append(fields, creditusage.FieldOrganizationID)
  10795. }
  10796. if m.nid != nil {
  10797. fields = append(fields, creditusage.FieldNid)
  10798. }
  10799. if m.reason != nil {
  10800. fields = append(fields, creditusage.FieldReason)
  10801. }
  10802. if m.operator != nil {
  10803. fields = append(fields, creditusage.FieldOperator)
  10804. }
  10805. return fields
  10806. }
  10807. // Field returns the value of a field with the given name. The second boolean
  10808. // return value indicates that this field was not set, or was not defined in the
  10809. // schema.
  10810. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10811. switch name {
  10812. case creditusage.FieldCreatedAt:
  10813. return m.CreatedAt()
  10814. case creditusage.FieldUpdatedAt:
  10815. return m.UpdatedAt()
  10816. case creditusage.FieldDeletedAt:
  10817. return m.DeletedAt()
  10818. case creditusage.FieldUserID:
  10819. return m.UserID()
  10820. case creditusage.FieldNumber:
  10821. return m.Number()
  10822. case creditusage.FieldStatus:
  10823. return m.Status()
  10824. case creditusage.FieldNtype:
  10825. return m.Ntype()
  10826. case creditusage.FieldTable:
  10827. return m.Table()
  10828. case creditusage.FieldOrganizationID:
  10829. return m.OrganizationID()
  10830. case creditusage.FieldNid:
  10831. return m.Nid()
  10832. case creditusage.FieldReason:
  10833. return m.Reason()
  10834. case creditusage.FieldOperator:
  10835. return m.Operator()
  10836. }
  10837. return nil, false
  10838. }
  10839. // OldField returns the old value of the field from the database. An error is
  10840. // returned if the mutation operation is not UpdateOne, or the query to the
  10841. // database failed.
  10842. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10843. switch name {
  10844. case creditusage.FieldCreatedAt:
  10845. return m.OldCreatedAt(ctx)
  10846. case creditusage.FieldUpdatedAt:
  10847. return m.OldUpdatedAt(ctx)
  10848. case creditusage.FieldDeletedAt:
  10849. return m.OldDeletedAt(ctx)
  10850. case creditusage.FieldUserID:
  10851. return m.OldUserID(ctx)
  10852. case creditusage.FieldNumber:
  10853. return m.OldNumber(ctx)
  10854. case creditusage.FieldStatus:
  10855. return m.OldStatus(ctx)
  10856. case creditusage.FieldNtype:
  10857. return m.OldNtype(ctx)
  10858. case creditusage.FieldTable:
  10859. return m.OldTable(ctx)
  10860. case creditusage.FieldOrganizationID:
  10861. return m.OldOrganizationID(ctx)
  10862. case creditusage.FieldNid:
  10863. return m.OldNid(ctx)
  10864. case creditusage.FieldReason:
  10865. return m.OldReason(ctx)
  10866. case creditusage.FieldOperator:
  10867. return m.OldOperator(ctx)
  10868. }
  10869. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10870. }
  10871. // SetField sets the value of a field with the given name. It returns an error if
  10872. // the field is not defined in the schema, or if the type mismatched the field
  10873. // type.
  10874. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10875. switch name {
  10876. case creditusage.FieldCreatedAt:
  10877. v, ok := value.(time.Time)
  10878. if !ok {
  10879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10880. }
  10881. m.SetCreatedAt(v)
  10882. return nil
  10883. case creditusage.FieldUpdatedAt:
  10884. v, ok := value.(time.Time)
  10885. if !ok {
  10886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10887. }
  10888. m.SetUpdatedAt(v)
  10889. return nil
  10890. case creditusage.FieldDeletedAt:
  10891. v, ok := value.(time.Time)
  10892. if !ok {
  10893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10894. }
  10895. m.SetDeletedAt(v)
  10896. return nil
  10897. case creditusage.FieldUserID:
  10898. v, ok := value.(string)
  10899. if !ok {
  10900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10901. }
  10902. m.SetUserID(v)
  10903. return nil
  10904. case creditusage.FieldNumber:
  10905. v, ok := value.(float32)
  10906. if !ok {
  10907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10908. }
  10909. m.SetNumber(v)
  10910. return nil
  10911. case creditusage.FieldStatus:
  10912. v, ok := value.(int)
  10913. if !ok {
  10914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10915. }
  10916. m.SetStatus(v)
  10917. return nil
  10918. case creditusage.FieldNtype:
  10919. v, ok := value.(int)
  10920. if !ok {
  10921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10922. }
  10923. m.SetNtype(v)
  10924. return nil
  10925. case creditusage.FieldTable:
  10926. v, ok := value.(string)
  10927. if !ok {
  10928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10929. }
  10930. m.SetTable(v)
  10931. return nil
  10932. case creditusage.FieldOrganizationID:
  10933. v, ok := value.(uint64)
  10934. if !ok {
  10935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10936. }
  10937. m.SetOrganizationID(v)
  10938. return nil
  10939. case creditusage.FieldNid:
  10940. v, ok := value.(uint64)
  10941. if !ok {
  10942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10943. }
  10944. m.SetNid(v)
  10945. return nil
  10946. case creditusage.FieldReason:
  10947. v, ok := value.(string)
  10948. if !ok {
  10949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10950. }
  10951. m.SetReason(v)
  10952. return nil
  10953. case creditusage.FieldOperator:
  10954. v, ok := value.(string)
  10955. if !ok {
  10956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10957. }
  10958. m.SetOperator(v)
  10959. return nil
  10960. }
  10961. return fmt.Errorf("unknown CreditUsage field %s", name)
  10962. }
  10963. // AddedFields returns all numeric fields that were incremented/decremented during
  10964. // this mutation.
  10965. func (m *CreditUsageMutation) AddedFields() []string {
  10966. var fields []string
  10967. if m.addnumber != nil {
  10968. fields = append(fields, creditusage.FieldNumber)
  10969. }
  10970. if m.addstatus != nil {
  10971. fields = append(fields, creditusage.FieldStatus)
  10972. }
  10973. if m.addntype != nil {
  10974. fields = append(fields, creditusage.FieldNtype)
  10975. }
  10976. if m.addorganization_id != nil {
  10977. fields = append(fields, creditusage.FieldOrganizationID)
  10978. }
  10979. if m.addnid != nil {
  10980. fields = append(fields, creditusage.FieldNid)
  10981. }
  10982. return fields
  10983. }
  10984. // AddedField returns the numeric value that was incremented/decremented on a field
  10985. // with the given name. The second boolean return value indicates that this field
  10986. // was not set, or was not defined in the schema.
  10987. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10988. switch name {
  10989. case creditusage.FieldNumber:
  10990. return m.AddedNumber()
  10991. case creditusage.FieldStatus:
  10992. return m.AddedStatus()
  10993. case creditusage.FieldNtype:
  10994. return m.AddedNtype()
  10995. case creditusage.FieldOrganizationID:
  10996. return m.AddedOrganizationID()
  10997. case creditusage.FieldNid:
  10998. return m.AddedNid()
  10999. }
  11000. return nil, false
  11001. }
  11002. // AddField adds the value to the field with the given name. It returns an error if
  11003. // the field is not defined in the schema, or if the type mismatched the field
  11004. // type.
  11005. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11006. switch name {
  11007. case creditusage.FieldNumber:
  11008. v, ok := value.(float32)
  11009. if !ok {
  11010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11011. }
  11012. m.AddNumber(v)
  11013. return nil
  11014. case creditusage.FieldStatus:
  11015. v, ok := value.(int)
  11016. if !ok {
  11017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11018. }
  11019. m.AddStatus(v)
  11020. return nil
  11021. case creditusage.FieldNtype:
  11022. v, ok := value.(int)
  11023. if !ok {
  11024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11025. }
  11026. m.AddNtype(v)
  11027. return nil
  11028. case creditusage.FieldOrganizationID:
  11029. v, ok := value.(int64)
  11030. if !ok {
  11031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11032. }
  11033. m.AddOrganizationID(v)
  11034. return nil
  11035. case creditusage.FieldNid:
  11036. v, ok := value.(int64)
  11037. if !ok {
  11038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11039. }
  11040. m.AddNid(v)
  11041. return nil
  11042. }
  11043. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11044. }
  11045. // ClearedFields returns all nullable fields that were cleared during this
  11046. // mutation.
  11047. func (m *CreditUsageMutation) ClearedFields() []string {
  11048. var fields []string
  11049. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11050. fields = append(fields, creditusage.FieldDeletedAt)
  11051. }
  11052. if m.FieldCleared(creditusage.FieldStatus) {
  11053. fields = append(fields, creditusage.FieldStatus)
  11054. }
  11055. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11056. fields = append(fields, creditusage.FieldOrganizationID)
  11057. }
  11058. return fields
  11059. }
  11060. // FieldCleared returns a boolean indicating if a field with the given name was
  11061. // cleared in this mutation.
  11062. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11063. _, ok := m.clearedFields[name]
  11064. return ok
  11065. }
  11066. // ClearField clears the value of the field with the given name. It returns an
  11067. // error if the field is not defined in the schema.
  11068. func (m *CreditUsageMutation) ClearField(name string) error {
  11069. switch name {
  11070. case creditusage.FieldDeletedAt:
  11071. m.ClearDeletedAt()
  11072. return nil
  11073. case creditusage.FieldStatus:
  11074. m.ClearStatus()
  11075. return nil
  11076. case creditusage.FieldOrganizationID:
  11077. m.ClearOrganizationID()
  11078. return nil
  11079. }
  11080. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11081. }
  11082. // ResetField resets all changes in the mutation for the field with the given name.
  11083. // It returns an error if the field is not defined in the schema.
  11084. func (m *CreditUsageMutation) ResetField(name string) error {
  11085. switch name {
  11086. case creditusage.FieldCreatedAt:
  11087. m.ResetCreatedAt()
  11088. return nil
  11089. case creditusage.FieldUpdatedAt:
  11090. m.ResetUpdatedAt()
  11091. return nil
  11092. case creditusage.FieldDeletedAt:
  11093. m.ResetDeletedAt()
  11094. return nil
  11095. case creditusage.FieldUserID:
  11096. m.ResetUserID()
  11097. return nil
  11098. case creditusage.FieldNumber:
  11099. m.ResetNumber()
  11100. return nil
  11101. case creditusage.FieldStatus:
  11102. m.ResetStatus()
  11103. return nil
  11104. case creditusage.FieldNtype:
  11105. m.ResetNtype()
  11106. return nil
  11107. case creditusage.FieldTable:
  11108. m.ResetTable()
  11109. return nil
  11110. case creditusage.FieldOrganizationID:
  11111. m.ResetOrganizationID()
  11112. return nil
  11113. case creditusage.FieldNid:
  11114. m.ResetNid()
  11115. return nil
  11116. case creditusage.FieldReason:
  11117. m.ResetReason()
  11118. return nil
  11119. case creditusage.FieldOperator:
  11120. m.ResetOperator()
  11121. return nil
  11122. }
  11123. return fmt.Errorf("unknown CreditUsage field %s", name)
  11124. }
  11125. // AddedEdges returns all edge names that were set/added in this mutation.
  11126. func (m *CreditUsageMutation) AddedEdges() []string {
  11127. edges := make([]string, 0, 0)
  11128. return edges
  11129. }
  11130. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11131. // name in this mutation.
  11132. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11133. return nil
  11134. }
  11135. // RemovedEdges returns all edge names that were removed in this mutation.
  11136. func (m *CreditUsageMutation) RemovedEdges() []string {
  11137. edges := make([]string, 0, 0)
  11138. return edges
  11139. }
  11140. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11141. // the given name in this mutation.
  11142. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11143. return nil
  11144. }
  11145. // ClearedEdges returns all edge names that were cleared in this mutation.
  11146. func (m *CreditUsageMutation) ClearedEdges() []string {
  11147. edges := make([]string, 0, 0)
  11148. return edges
  11149. }
  11150. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11151. // was cleared in this mutation.
  11152. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11153. return false
  11154. }
  11155. // ClearEdge clears the value of the edge with the given name. It returns an error
  11156. // if that edge is not defined in the schema.
  11157. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11158. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11159. }
  11160. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11161. // It returns an error if the edge is not defined in the schema.
  11162. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11163. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11164. }
  11165. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11166. type EmployeeMutation struct {
  11167. config
  11168. op Op
  11169. typ string
  11170. id *uint64
  11171. created_at *time.Time
  11172. updated_at *time.Time
  11173. deleted_at *time.Time
  11174. title *string
  11175. avatar *string
  11176. tags *string
  11177. hire_count *int
  11178. addhire_count *int
  11179. service_count *int
  11180. addservice_count *int
  11181. achievement_count *int
  11182. addachievement_count *int
  11183. intro *string
  11184. estimate *string
  11185. skill *string
  11186. ability_type *string
  11187. scene *string
  11188. switch_in *string
  11189. video_url *string
  11190. organization_id *uint64
  11191. addorganization_id *int64
  11192. category_id *uint64
  11193. addcategory_id *int64
  11194. api_base *string
  11195. api_key *string
  11196. ai_info *string
  11197. is_vip *int
  11198. addis_vip *int
  11199. chat_url *string
  11200. clearedFields map[string]struct{}
  11201. em_work_experiences map[uint64]struct{}
  11202. removedem_work_experiences map[uint64]struct{}
  11203. clearedem_work_experiences bool
  11204. em_tutorial map[uint64]struct{}
  11205. removedem_tutorial map[uint64]struct{}
  11206. clearedem_tutorial bool
  11207. done bool
  11208. oldValue func(context.Context) (*Employee, error)
  11209. predicates []predicate.Employee
  11210. }
  11211. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11212. // employeeOption allows management of the mutation configuration using functional options.
  11213. type employeeOption func(*EmployeeMutation)
  11214. // newEmployeeMutation creates new mutation for the Employee entity.
  11215. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11216. m := &EmployeeMutation{
  11217. config: c,
  11218. op: op,
  11219. typ: TypeEmployee,
  11220. clearedFields: make(map[string]struct{}),
  11221. }
  11222. for _, opt := range opts {
  11223. opt(m)
  11224. }
  11225. return m
  11226. }
  11227. // withEmployeeID sets the ID field of the mutation.
  11228. func withEmployeeID(id uint64) employeeOption {
  11229. return func(m *EmployeeMutation) {
  11230. var (
  11231. err error
  11232. once sync.Once
  11233. value *Employee
  11234. )
  11235. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11236. once.Do(func() {
  11237. if m.done {
  11238. err = errors.New("querying old values post mutation is not allowed")
  11239. } else {
  11240. value, err = m.Client().Employee.Get(ctx, id)
  11241. }
  11242. })
  11243. return value, err
  11244. }
  11245. m.id = &id
  11246. }
  11247. }
  11248. // withEmployee sets the old Employee of the mutation.
  11249. func withEmployee(node *Employee) employeeOption {
  11250. return func(m *EmployeeMutation) {
  11251. m.oldValue = func(context.Context) (*Employee, error) {
  11252. return node, nil
  11253. }
  11254. m.id = &node.ID
  11255. }
  11256. }
  11257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11258. // executed in a transaction (ent.Tx), a transactional client is returned.
  11259. func (m EmployeeMutation) Client() *Client {
  11260. client := &Client{config: m.config}
  11261. client.init()
  11262. return client
  11263. }
  11264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11265. // it returns an error otherwise.
  11266. func (m EmployeeMutation) Tx() (*Tx, error) {
  11267. if _, ok := m.driver.(*txDriver); !ok {
  11268. return nil, errors.New("ent: mutation is not running in a transaction")
  11269. }
  11270. tx := &Tx{config: m.config}
  11271. tx.init()
  11272. return tx, nil
  11273. }
  11274. // SetID sets the value of the id field. Note that this
  11275. // operation is only accepted on creation of Employee entities.
  11276. func (m *EmployeeMutation) SetID(id uint64) {
  11277. m.id = &id
  11278. }
  11279. // ID returns the ID value in the mutation. Note that the ID is only available
  11280. // if it was provided to the builder or after it was returned from the database.
  11281. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11282. if m.id == nil {
  11283. return
  11284. }
  11285. return *m.id, true
  11286. }
  11287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11288. // That means, if the mutation is applied within a transaction with an isolation level such
  11289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11290. // or updated by the mutation.
  11291. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11292. switch {
  11293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11294. id, exists := m.ID()
  11295. if exists {
  11296. return []uint64{id}, nil
  11297. }
  11298. fallthrough
  11299. case m.op.Is(OpUpdate | OpDelete):
  11300. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11301. default:
  11302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11303. }
  11304. }
  11305. // SetCreatedAt sets the "created_at" field.
  11306. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11307. m.created_at = &t
  11308. }
  11309. // CreatedAt returns the value of the "created_at" field in the mutation.
  11310. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11311. v := m.created_at
  11312. if v == nil {
  11313. return
  11314. }
  11315. return *v, true
  11316. }
  11317. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11318. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11320. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11321. if !m.op.Is(OpUpdateOne) {
  11322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11323. }
  11324. if m.id == nil || m.oldValue == nil {
  11325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11326. }
  11327. oldValue, err := m.oldValue(ctx)
  11328. if err != nil {
  11329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11330. }
  11331. return oldValue.CreatedAt, nil
  11332. }
  11333. // ResetCreatedAt resets all changes to the "created_at" field.
  11334. func (m *EmployeeMutation) ResetCreatedAt() {
  11335. m.created_at = nil
  11336. }
  11337. // SetUpdatedAt sets the "updated_at" field.
  11338. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11339. m.updated_at = &t
  11340. }
  11341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11342. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11343. v := m.updated_at
  11344. if v == nil {
  11345. return
  11346. }
  11347. return *v, true
  11348. }
  11349. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11350. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11352. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11353. if !m.op.Is(OpUpdateOne) {
  11354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11355. }
  11356. if m.id == nil || m.oldValue == nil {
  11357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11358. }
  11359. oldValue, err := m.oldValue(ctx)
  11360. if err != nil {
  11361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11362. }
  11363. return oldValue.UpdatedAt, nil
  11364. }
  11365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11366. func (m *EmployeeMutation) ResetUpdatedAt() {
  11367. m.updated_at = nil
  11368. }
  11369. // SetDeletedAt sets the "deleted_at" field.
  11370. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11371. m.deleted_at = &t
  11372. }
  11373. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11374. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11375. v := m.deleted_at
  11376. if v == nil {
  11377. return
  11378. }
  11379. return *v, true
  11380. }
  11381. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11382. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11384. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11385. if !m.op.Is(OpUpdateOne) {
  11386. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11387. }
  11388. if m.id == nil || m.oldValue == nil {
  11389. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11390. }
  11391. oldValue, err := m.oldValue(ctx)
  11392. if err != nil {
  11393. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11394. }
  11395. return oldValue.DeletedAt, nil
  11396. }
  11397. // ClearDeletedAt clears the value of the "deleted_at" field.
  11398. func (m *EmployeeMutation) ClearDeletedAt() {
  11399. m.deleted_at = nil
  11400. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11401. }
  11402. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11403. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11404. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11405. return ok
  11406. }
  11407. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11408. func (m *EmployeeMutation) ResetDeletedAt() {
  11409. m.deleted_at = nil
  11410. delete(m.clearedFields, employee.FieldDeletedAt)
  11411. }
  11412. // SetTitle sets the "title" field.
  11413. func (m *EmployeeMutation) SetTitle(s string) {
  11414. m.title = &s
  11415. }
  11416. // Title returns the value of the "title" field in the mutation.
  11417. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11418. v := m.title
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // OldTitle returns the old "title" field's value of the Employee entity.
  11425. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11427. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11428. if !m.op.Is(OpUpdateOne) {
  11429. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11430. }
  11431. if m.id == nil || m.oldValue == nil {
  11432. return v, errors.New("OldTitle requires an ID field in the mutation")
  11433. }
  11434. oldValue, err := m.oldValue(ctx)
  11435. if err != nil {
  11436. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11437. }
  11438. return oldValue.Title, nil
  11439. }
  11440. // ResetTitle resets all changes to the "title" field.
  11441. func (m *EmployeeMutation) ResetTitle() {
  11442. m.title = nil
  11443. }
  11444. // SetAvatar sets the "avatar" field.
  11445. func (m *EmployeeMutation) SetAvatar(s string) {
  11446. m.avatar = &s
  11447. }
  11448. // Avatar returns the value of the "avatar" field in the mutation.
  11449. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11450. v := m.avatar
  11451. if v == nil {
  11452. return
  11453. }
  11454. return *v, true
  11455. }
  11456. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11457. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11459. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11460. if !m.op.Is(OpUpdateOne) {
  11461. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11462. }
  11463. if m.id == nil || m.oldValue == nil {
  11464. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11465. }
  11466. oldValue, err := m.oldValue(ctx)
  11467. if err != nil {
  11468. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11469. }
  11470. return oldValue.Avatar, nil
  11471. }
  11472. // ResetAvatar resets all changes to the "avatar" field.
  11473. func (m *EmployeeMutation) ResetAvatar() {
  11474. m.avatar = nil
  11475. }
  11476. // SetTags sets the "tags" field.
  11477. func (m *EmployeeMutation) SetTags(s string) {
  11478. m.tags = &s
  11479. }
  11480. // Tags returns the value of the "tags" field in the mutation.
  11481. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11482. v := m.tags
  11483. if v == nil {
  11484. return
  11485. }
  11486. return *v, true
  11487. }
  11488. // OldTags returns the old "tags" field's value of the Employee entity.
  11489. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11491. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11492. if !m.op.Is(OpUpdateOne) {
  11493. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11494. }
  11495. if m.id == nil || m.oldValue == nil {
  11496. return v, errors.New("OldTags requires an ID field in the mutation")
  11497. }
  11498. oldValue, err := m.oldValue(ctx)
  11499. if err != nil {
  11500. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11501. }
  11502. return oldValue.Tags, nil
  11503. }
  11504. // ResetTags resets all changes to the "tags" field.
  11505. func (m *EmployeeMutation) ResetTags() {
  11506. m.tags = nil
  11507. }
  11508. // SetHireCount sets the "hire_count" field.
  11509. func (m *EmployeeMutation) SetHireCount(i int) {
  11510. m.hire_count = &i
  11511. m.addhire_count = nil
  11512. }
  11513. // HireCount returns the value of the "hire_count" field in the mutation.
  11514. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11515. v := m.hire_count
  11516. if v == nil {
  11517. return
  11518. }
  11519. return *v, true
  11520. }
  11521. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11522. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11524. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11525. if !m.op.Is(OpUpdateOne) {
  11526. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11527. }
  11528. if m.id == nil || m.oldValue == nil {
  11529. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11530. }
  11531. oldValue, err := m.oldValue(ctx)
  11532. if err != nil {
  11533. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11534. }
  11535. return oldValue.HireCount, nil
  11536. }
  11537. // AddHireCount adds i to the "hire_count" field.
  11538. func (m *EmployeeMutation) AddHireCount(i int) {
  11539. if m.addhire_count != nil {
  11540. *m.addhire_count += i
  11541. } else {
  11542. m.addhire_count = &i
  11543. }
  11544. }
  11545. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11546. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11547. v := m.addhire_count
  11548. if v == nil {
  11549. return
  11550. }
  11551. return *v, true
  11552. }
  11553. // ResetHireCount resets all changes to the "hire_count" field.
  11554. func (m *EmployeeMutation) ResetHireCount() {
  11555. m.hire_count = nil
  11556. m.addhire_count = nil
  11557. }
  11558. // SetServiceCount sets the "service_count" field.
  11559. func (m *EmployeeMutation) SetServiceCount(i int) {
  11560. m.service_count = &i
  11561. m.addservice_count = nil
  11562. }
  11563. // ServiceCount returns the value of the "service_count" field in the mutation.
  11564. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11565. v := m.service_count
  11566. if v == nil {
  11567. return
  11568. }
  11569. return *v, true
  11570. }
  11571. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11572. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11574. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11575. if !m.op.Is(OpUpdateOne) {
  11576. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11577. }
  11578. if m.id == nil || m.oldValue == nil {
  11579. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11580. }
  11581. oldValue, err := m.oldValue(ctx)
  11582. if err != nil {
  11583. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11584. }
  11585. return oldValue.ServiceCount, nil
  11586. }
  11587. // AddServiceCount adds i to the "service_count" field.
  11588. func (m *EmployeeMutation) AddServiceCount(i int) {
  11589. if m.addservice_count != nil {
  11590. *m.addservice_count += i
  11591. } else {
  11592. m.addservice_count = &i
  11593. }
  11594. }
  11595. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11596. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11597. v := m.addservice_count
  11598. if v == nil {
  11599. return
  11600. }
  11601. return *v, true
  11602. }
  11603. // ResetServiceCount resets all changes to the "service_count" field.
  11604. func (m *EmployeeMutation) ResetServiceCount() {
  11605. m.service_count = nil
  11606. m.addservice_count = nil
  11607. }
  11608. // SetAchievementCount sets the "achievement_count" field.
  11609. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11610. m.achievement_count = &i
  11611. m.addachievement_count = nil
  11612. }
  11613. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11614. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11615. v := m.achievement_count
  11616. if v == nil {
  11617. return
  11618. }
  11619. return *v, true
  11620. }
  11621. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11622. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11624. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11625. if !m.op.Is(OpUpdateOne) {
  11626. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11627. }
  11628. if m.id == nil || m.oldValue == nil {
  11629. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11630. }
  11631. oldValue, err := m.oldValue(ctx)
  11632. if err != nil {
  11633. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11634. }
  11635. return oldValue.AchievementCount, nil
  11636. }
  11637. // AddAchievementCount adds i to the "achievement_count" field.
  11638. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11639. if m.addachievement_count != nil {
  11640. *m.addachievement_count += i
  11641. } else {
  11642. m.addachievement_count = &i
  11643. }
  11644. }
  11645. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11646. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11647. v := m.addachievement_count
  11648. if v == nil {
  11649. return
  11650. }
  11651. return *v, true
  11652. }
  11653. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11654. func (m *EmployeeMutation) ResetAchievementCount() {
  11655. m.achievement_count = nil
  11656. m.addachievement_count = nil
  11657. }
  11658. // SetIntro sets the "intro" field.
  11659. func (m *EmployeeMutation) SetIntro(s string) {
  11660. m.intro = &s
  11661. }
  11662. // Intro returns the value of the "intro" field in the mutation.
  11663. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11664. v := m.intro
  11665. if v == nil {
  11666. return
  11667. }
  11668. return *v, true
  11669. }
  11670. // OldIntro returns the old "intro" field's value of the Employee entity.
  11671. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11673. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11674. if !m.op.Is(OpUpdateOne) {
  11675. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11676. }
  11677. if m.id == nil || m.oldValue == nil {
  11678. return v, errors.New("OldIntro requires an ID field in the mutation")
  11679. }
  11680. oldValue, err := m.oldValue(ctx)
  11681. if err != nil {
  11682. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11683. }
  11684. return oldValue.Intro, nil
  11685. }
  11686. // ResetIntro resets all changes to the "intro" field.
  11687. func (m *EmployeeMutation) ResetIntro() {
  11688. m.intro = nil
  11689. }
  11690. // SetEstimate sets the "estimate" field.
  11691. func (m *EmployeeMutation) SetEstimate(s string) {
  11692. m.estimate = &s
  11693. }
  11694. // Estimate returns the value of the "estimate" field in the mutation.
  11695. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11696. v := m.estimate
  11697. if v == nil {
  11698. return
  11699. }
  11700. return *v, true
  11701. }
  11702. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11703. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11705. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11706. if !m.op.Is(OpUpdateOne) {
  11707. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11708. }
  11709. if m.id == nil || m.oldValue == nil {
  11710. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11711. }
  11712. oldValue, err := m.oldValue(ctx)
  11713. if err != nil {
  11714. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11715. }
  11716. return oldValue.Estimate, nil
  11717. }
  11718. // ResetEstimate resets all changes to the "estimate" field.
  11719. func (m *EmployeeMutation) ResetEstimate() {
  11720. m.estimate = nil
  11721. }
  11722. // SetSkill sets the "skill" field.
  11723. func (m *EmployeeMutation) SetSkill(s string) {
  11724. m.skill = &s
  11725. }
  11726. // Skill returns the value of the "skill" field in the mutation.
  11727. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11728. v := m.skill
  11729. if v == nil {
  11730. return
  11731. }
  11732. return *v, true
  11733. }
  11734. // OldSkill returns the old "skill" field's value of the Employee entity.
  11735. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11737. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11738. if !m.op.Is(OpUpdateOne) {
  11739. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11740. }
  11741. if m.id == nil || m.oldValue == nil {
  11742. return v, errors.New("OldSkill requires an ID field in the mutation")
  11743. }
  11744. oldValue, err := m.oldValue(ctx)
  11745. if err != nil {
  11746. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11747. }
  11748. return oldValue.Skill, nil
  11749. }
  11750. // ResetSkill resets all changes to the "skill" field.
  11751. func (m *EmployeeMutation) ResetSkill() {
  11752. m.skill = nil
  11753. }
  11754. // SetAbilityType sets the "ability_type" field.
  11755. func (m *EmployeeMutation) SetAbilityType(s string) {
  11756. m.ability_type = &s
  11757. }
  11758. // AbilityType returns the value of the "ability_type" field in the mutation.
  11759. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11760. v := m.ability_type
  11761. if v == nil {
  11762. return
  11763. }
  11764. return *v, true
  11765. }
  11766. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11767. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11769. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11770. if !m.op.Is(OpUpdateOne) {
  11771. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11772. }
  11773. if m.id == nil || m.oldValue == nil {
  11774. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11775. }
  11776. oldValue, err := m.oldValue(ctx)
  11777. if err != nil {
  11778. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11779. }
  11780. return oldValue.AbilityType, nil
  11781. }
  11782. // ResetAbilityType resets all changes to the "ability_type" field.
  11783. func (m *EmployeeMutation) ResetAbilityType() {
  11784. m.ability_type = nil
  11785. }
  11786. // SetScene sets the "scene" field.
  11787. func (m *EmployeeMutation) SetScene(s string) {
  11788. m.scene = &s
  11789. }
  11790. // Scene returns the value of the "scene" field in the mutation.
  11791. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11792. v := m.scene
  11793. if v == nil {
  11794. return
  11795. }
  11796. return *v, true
  11797. }
  11798. // OldScene returns the old "scene" field's value of the Employee entity.
  11799. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11801. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11802. if !m.op.Is(OpUpdateOne) {
  11803. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11804. }
  11805. if m.id == nil || m.oldValue == nil {
  11806. return v, errors.New("OldScene requires an ID field in the mutation")
  11807. }
  11808. oldValue, err := m.oldValue(ctx)
  11809. if err != nil {
  11810. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11811. }
  11812. return oldValue.Scene, nil
  11813. }
  11814. // ResetScene resets all changes to the "scene" field.
  11815. func (m *EmployeeMutation) ResetScene() {
  11816. m.scene = nil
  11817. }
  11818. // SetSwitchIn sets the "switch_in" field.
  11819. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11820. m.switch_in = &s
  11821. }
  11822. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11823. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11824. v := m.switch_in
  11825. if v == nil {
  11826. return
  11827. }
  11828. return *v, true
  11829. }
  11830. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11833. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11834. if !m.op.Is(OpUpdateOne) {
  11835. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11836. }
  11837. if m.id == nil || m.oldValue == nil {
  11838. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11839. }
  11840. oldValue, err := m.oldValue(ctx)
  11841. if err != nil {
  11842. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11843. }
  11844. return oldValue.SwitchIn, nil
  11845. }
  11846. // ResetSwitchIn resets all changes to the "switch_in" field.
  11847. func (m *EmployeeMutation) ResetSwitchIn() {
  11848. m.switch_in = nil
  11849. }
  11850. // SetVideoURL sets the "video_url" field.
  11851. func (m *EmployeeMutation) SetVideoURL(s string) {
  11852. m.video_url = &s
  11853. }
  11854. // VideoURL returns the value of the "video_url" field in the mutation.
  11855. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11856. v := m.video_url
  11857. if v == nil {
  11858. return
  11859. }
  11860. return *v, true
  11861. }
  11862. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11863. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11865. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11866. if !m.op.Is(OpUpdateOne) {
  11867. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11868. }
  11869. if m.id == nil || m.oldValue == nil {
  11870. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11871. }
  11872. oldValue, err := m.oldValue(ctx)
  11873. if err != nil {
  11874. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11875. }
  11876. return oldValue.VideoURL, nil
  11877. }
  11878. // ResetVideoURL resets all changes to the "video_url" field.
  11879. func (m *EmployeeMutation) ResetVideoURL() {
  11880. m.video_url = nil
  11881. }
  11882. // SetOrganizationID sets the "organization_id" field.
  11883. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11884. m.organization_id = &u
  11885. m.addorganization_id = nil
  11886. }
  11887. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11888. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11889. v := m.organization_id
  11890. if v == nil {
  11891. return
  11892. }
  11893. return *v, true
  11894. }
  11895. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11898. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11899. if !m.op.Is(OpUpdateOne) {
  11900. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11901. }
  11902. if m.id == nil || m.oldValue == nil {
  11903. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11904. }
  11905. oldValue, err := m.oldValue(ctx)
  11906. if err != nil {
  11907. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11908. }
  11909. return oldValue.OrganizationID, nil
  11910. }
  11911. // AddOrganizationID adds u to the "organization_id" field.
  11912. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11913. if m.addorganization_id != nil {
  11914. *m.addorganization_id += u
  11915. } else {
  11916. m.addorganization_id = &u
  11917. }
  11918. }
  11919. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11920. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11921. v := m.addorganization_id
  11922. if v == nil {
  11923. return
  11924. }
  11925. return *v, true
  11926. }
  11927. // ResetOrganizationID resets all changes to the "organization_id" field.
  11928. func (m *EmployeeMutation) ResetOrganizationID() {
  11929. m.organization_id = nil
  11930. m.addorganization_id = nil
  11931. }
  11932. // SetCategoryID sets the "category_id" field.
  11933. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11934. m.category_id = &u
  11935. m.addcategory_id = nil
  11936. }
  11937. // CategoryID returns the value of the "category_id" field in the mutation.
  11938. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11939. v := m.category_id
  11940. if v == nil {
  11941. return
  11942. }
  11943. return *v, true
  11944. }
  11945. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11946. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11948. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11949. if !m.op.Is(OpUpdateOne) {
  11950. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11951. }
  11952. if m.id == nil || m.oldValue == nil {
  11953. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11954. }
  11955. oldValue, err := m.oldValue(ctx)
  11956. if err != nil {
  11957. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11958. }
  11959. return oldValue.CategoryID, nil
  11960. }
  11961. // AddCategoryID adds u to the "category_id" field.
  11962. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11963. if m.addcategory_id != nil {
  11964. *m.addcategory_id += u
  11965. } else {
  11966. m.addcategory_id = &u
  11967. }
  11968. }
  11969. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11970. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11971. v := m.addcategory_id
  11972. if v == nil {
  11973. return
  11974. }
  11975. return *v, true
  11976. }
  11977. // ResetCategoryID resets all changes to the "category_id" field.
  11978. func (m *EmployeeMutation) ResetCategoryID() {
  11979. m.category_id = nil
  11980. m.addcategory_id = nil
  11981. }
  11982. // SetAPIBase sets the "api_base" field.
  11983. func (m *EmployeeMutation) SetAPIBase(s string) {
  11984. m.api_base = &s
  11985. }
  11986. // APIBase returns the value of the "api_base" field in the mutation.
  11987. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11988. v := m.api_base
  11989. if v == nil {
  11990. return
  11991. }
  11992. return *v, true
  11993. }
  11994. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11995. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11997. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11998. if !m.op.Is(OpUpdateOne) {
  11999. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12000. }
  12001. if m.id == nil || m.oldValue == nil {
  12002. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12003. }
  12004. oldValue, err := m.oldValue(ctx)
  12005. if err != nil {
  12006. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12007. }
  12008. return oldValue.APIBase, nil
  12009. }
  12010. // ResetAPIBase resets all changes to the "api_base" field.
  12011. func (m *EmployeeMutation) ResetAPIBase() {
  12012. m.api_base = nil
  12013. }
  12014. // SetAPIKey sets the "api_key" field.
  12015. func (m *EmployeeMutation) SetAPIKey(s string) {
  12016. m.api_key = &s
  12017. }
  12018. // APIKey returns the value of the "api_key" field in the mutation.
  12019. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12020. v := m.api_key
  12021. if v == nil {
  12022. return
  12023. }
  12024. return *v, true
  12025. }
  12026. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12027. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12029. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12030. if !m.op.Is(OpUpdateOne) {
  12031. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12032. }
  12033. if m.id == nil || m.oldValue == nil {
  12034. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12035. }
  12036. oldValue, err := m.oldValue(ctx)
  12037. if err != nil {
  12038. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12039. }
  12040. return oldValue.APIKey, nil
  12041. }
  12042. // ResetAPIKey resets all changes to the "api_key" field.
  12043. func (m *EmployeeMutation) ResetAPIKey() {
  12044. m.api_key = nil
  12045. }
  12046. // SetAiInfo sets the "ai_info" field.
  12047. func (m *EmployeeMutation) SetAiInfo(s string) {
  12048. m.ai_info = &s
  12049. }
  12050. // AiInfo returns the value of the "ai_info" field in the mutation.
  12051. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12052. v := m.ai_info
  12053. if v == nil {
  12054. return
  12055. }
  12056. return *v, true
  12057. }
  12058. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12059. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12061. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12062. if !m.op.Is(OpUpdateOne) {
  12063. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12064. }
  12065. if m.id == nil || m.oldValue == nil {
  12066. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12067. }
  12068. oldValue, err := m.oldValue(ctx)
  12069. if err != nil {
  12070. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12071. }
  12072. return oldValue.AiInfo, nil
  12073. }
  12074. // ClearAiInfo clears the value of the "ai_info" field.
  12075. func (m *EmployeeMutation) ClearAiInfo() {
  12076. m.ai_info = nil
  12077. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12078. }
  12079. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12080. func (m *EmployeeMutation) AiInfoCleared() bool {
  12081. _, ok := m.clearedFields[employee.FieldAiInfo]
  12082. return ok
  12083. }
  12084. // ResetAiInfo resets all changes to the "ai_info" field.
  12085. func (m *EmployeeMutation) ResetAiInfo() {
  12086. m.ai_info = nil
  12087. delete(m.clearedFields, employee.FieldAiInfo)
  12088. }
  12089. // SetIsVip sets the "is_vip" field.
  12090. func (m *EmployeeMutation) SetIsVip(i int) {
  12091. m.is_vip = &i
  12092. m.addis_vip = nil
  12093. }
  12094. // IsVip returns the value of the "is_vip" field in the mutation.
  12095. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12096. v := m.is_vip
  12097. if v == nil {
  12098. return
  12099. }
  12100. return *v, true
  12101. }
  12102. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12103. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12105. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12106. if !m.op.Is(OpUpdateOne) {
  12107. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12108. }
  12109. if m.id == nil || m.oldValue == nil {
  12110. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12111. }
  12112. oldValue, err := m.oldValue(ctx)
  12113. if err != nil {
  12114. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12115. }
  12116. return oldValue.IsVip, nil
  12117. }
  12118. // AddIsVip adds i to the "is_vip" field.
  12119. func (m *EmployeeMutation) AddIsVip(i int) {
  12120. if m.addis_vip != nil {
  12121. *m.addis_vip += i
  12122. } else {
  12123. m.addis_vip = &i
  12124. }
  12125. }
  12126. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12127. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12128. v := m.addis_vip
  12129. if v == nil {
  12130. return
  12131. }
  12132. return *v, true
  12133. }
  12134. // ResetIsVip resets all changes to the "is_vip" field.
  12135. func (m *EmployeeMutation) ResetIsVip() {
  12136. m.is_vip = nil
  12137. m.addis_vip = nil
  12138. }
  12139. // SetChatURL sets the "chat_url" field.
  12140. func (m *EmployeeMutation) SetChatURL(s string) {
  12141. m.chat_url = &s
  12142. }
  12143. // ChatURL returns the value of the "chat_url" field in the mutation.
  12144. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12145. v := m.chat_url
  12146. if v == nil {
  12147. return
  12148. }
  12149. return *v, true
  12150. }
  12151. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12152. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12154. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12155. if !m.op.Is(OpUpdateOne) {
  12156. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12157. }
  12158. if m.id == nil || m.oldValue == nil {
  12159. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12160. }
  12161. oldValue, err := m.oldValue(ctx)
  12162. if err != nil {
  12163. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12164. }
  12165. return oldValue.ChatURL, nil
  12166. }
  12167. // ResetChatURL resets all changes to the "chat_url" field.
  12168. func (m *EmployeeMutation) ResetChatURL() {
  12169. m.chat_url = nil
  12170. }
  12171. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12172. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12173. if m.em_work_experiences == nil {
  12174. m.em_work_experiences = make(map[uint64]struct{})
  12175. }
  12176. for i := range ids {
  12177. m.em_work_experiences[ids[i]] = struct{}{}
  12178. }
  12179. }
  12180. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12181. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12182. m.clearedem_work_experiences = true
  12183. }
  12184. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12185. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12186. return m.clearedem_work_experiences
  12187. }
  12188. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12189. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12190. if m.removedem_work_experiences == nil {
  12191. m.removedem_work_experiences = make(map[uint64]struct{})
  12192. }
  12193. for i := range ids {
  12194. delete(m.em_work_experiences, ids[i])
  12195. m.removedem_work_experiences[ids[i]] = struct{}{}
  12196. }
  12197. }
  12198. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12199. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12200. for id := range m.removedem_work_experiences {
  12201. ids = append(ids, id)
  12202. }
  12203. return
  12204. }
  12205. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12206. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12207. for id := range m.em_work_experiences {
  12208. ids = append(ids, id)
  12209. }
  12210. return
  12211. }
  12212. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12213. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12214. m.em_work_experiences = nil
  12215. m.clearedem_work_experiences = false
  12216. m.removedem_work_experiences = nil
  12217. }
  12218. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12219. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12220. if m.em_tutorial == nil {
  12221. m.em_tutorial = make(map[uint64]struct{})
  12222. }
  12223. for i := range ids {
  12224. m.em_tutorial[ids[i]] = struct{}{}
  12225. }
  12226. }
  12227. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12228. func (m *EmployeeMutation) ClearEmTutorial() {
  12229. m.clearedem_tutorial = true
  12230. }
  12231. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12232. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12233. return m.clearedem_tutorial
  12234. }
  12235. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12236. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12237. if m.removedem_tutorial == nil {
  12238. m.removedem_tutorial = make(map[uint64]struct{})
  12239. }
  12240. for i := range ids {
  12241. delete(m.em_tutorial, ids[i])
  12242. m.removedem_tutorial[ids[i]] = struct{}{}
  12243. }
  12244. }
  12245. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12246. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12247. for id := range m.removedem_tutorial {
  12248. ids = append(ids, id)
  12249. }
  12250. return
  12251. }
  12252. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12253. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12254. for id := range m.em_tutorial {
  12255. ids = append(ids, id)
  12256. }
  12257. return
  12258. }
  12259. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12260. func (m *EmployeeMutation) ResetEmTutorial() {
  12261. m.em_tutorial = nil
  12262. m.clearedem_tutorial = false
  12263. m.removedem_tutorial = nil
  12264. }
  12265. // Where appends a list predicates to the EmployeeMutation builder.
  12266. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12267. m.predicates = append(m.predicates, ps...)
  12268. }
  12269. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12270. // users can use type-assertion to append predicates that do not depend on any generated package.
  12271. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12272. p := make([]predicate.Employee, len(ps))
  12273. for i := range ps {
  12274. p[i] = ps[i]
  12275. }
  12276. m.Where(p...)
  12277. }
  12278. // Op returns the operation name.
  12279. func (m *EmployeeMutation) Op() Op {
  12280. return m.op
  12281. }
  12282. // SetOp allows setting the mutation operation.
  12283. func (m *EmployeeMutation) SetOp(op Op) {
  12284. m.op = op
  12285. }
  12286. // Type returns the node type of this mutation (Employee).
  12287. func (m *EmployeeMutation) Type() string {
  12288. return m.typ
  12289. }
  12290. // Fields returns all fields that were changed during this mutation. Note that in
  12291. // order to get all numeric fields that were incremented/decremented, call
  12292. // AddedFields().
  12293. func (m *EmployeeMutation) Fields() []string {
  12294. fields := make([]string, 0, 23)
  12295. if m.created_at != nil {
  12296. fields = append(fields, employee.FieldCreatedAt)
  12297. }
  12298. if m.updated_at != nil {
  12299. fields = append(fields, employee.FieldUpdatedAt)
  12300. }
  12301. if m.deleted_at != nil {
  12302. fields = append(fields, employee.FieldDeletedAt)
  12303. }
  12304. if m.title != nil {
  12305. fields = append(fields, employee.FieldTitle)
  12306. }
  12307. if m.avatar != nil {
  12308. fields = append(fields, employee.FieldAvatar)
  12309. }
  12310. if m.tags != nil {
  12311. fields = append(fields, employee.FieldTags)
  12312. }
  12313. if m.hire_count != nil {
  12314. fields = append(fields, employee.FieldHireCount)
  12315. }
  12316. if m.service_count != nil {
  12317. fields = append(fields, employee.FieldServiceCount)
  12318. }
  12319. if m.achievement_count != nil {
  12320. fields = append(fields, employee.FieldAchievementCount)
  12321. }
  12322. if m.intro != nil {
  12323. fields = append(fields, employee.FieldIntro)
  12324. }
  12325. if m.estimate != nil {
  12326. fields = append(fields, employee.FieldEstimate)
  12327. }
  12328. if m.skill != nil {
  12329. fields = append(fields, employee.FieldSkill)
  12330. }
  12331. if m.ability_type != nil {
  12332. fields = append(fields, employee.FieldAbilityType)
  12333. }
  12334. if m.scene != nil {
  12335. fields = append(fields, employee.FieldScene)
  12336. }
  12337. if m.switch_in != nil {
  12338. fields = append(fields, employee.FieldSwitchIn)
  12339. }
  12340. if m.video_url != nil {
  12341. fields = append(fields, employee.FieldVideoURL)
  12342. }
  12343. if m.organization_id != nil {
  12344. fields = append(fields, employee.FieldOrganizationID)
  12345. }
  12346. if m.category_id != nil {
  12347. fields = append(fields, employee.FieldCategoryID)
  12348. }
  12349. if m.api_base != nil {
  12350. fields = append(fields, employee.FieldAPIBase)
  12351. }
  12352. if m.api_key != nil {
  12353. fields = append(fields, employee.FieldAPIKey)
  12354. }
  12355. if m.ai_info != nil {
  12356. fields = append(fields, employee.FieldAiInfo)
  12357. }
  12358. if m.is_vip != nil {
  12359. fields = append(fields, employee.FieldIsVip)
  12360. }
  12361. if m.chat_url != nil {
  12362. fields = append(fields, employee.FieldChatURL)
  12363. }
  12364. return fields
  12365. }
  12366. // Field returns the value of a field with the given name. The second boolean
  12367. // return value indicates that this field was not set, or was not defined in the
  12368. // schema.
  12369. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12370. switch name {
  12371. case employee.FieldCreatedAt:
  12372. return m.CreatedAt()
  12373. case employee.FieldUpdatedAt:
  12374. return m.UpdatedAt()
  12375. case employee.FieldDeletedAt:
  12376. return m.DeletedAt()
  12377. case employee.FieldTitle:
  12378. return m.Title()
  12379. case employee.FieldAvatar:
  12380. return m.Avatar()
  12381. case employee.FieldTags:
  12382. return m.Tags()
  12383. case employee.FieldHireCount:
  12384. return m.HireCount()
  12385. case employee.FieldServiceCount:
  12386. return m.ServiceCount()
  12387. case employee.FieldAchievementCount:
  12388. return m.AchievementCount()
  12389. case employee.FieldIntro:
  12390. return m.Intro()
  12391. case employee.FieldEstimate:
  12392. return m.Estimate()
  12393. case employee.FieldSkill:
  12394. return m.Skill()
  12395. case employee.FieldAbilityType:
  12396. return m.AbilityType()
  12397. case employee.FieldScene:
  12398. return m.Scene()
  12399. case employee.FieldSwitchIn:
  12400. return m.SwitchIn()
  12401. case employee.FieldVideoURL:
  12402. return m.VideoURL()
  12403. case employee.FieldOrganizationID:
  12404. return m.OrganizationID()
  12405. case employee.FieldCategoryID:
  12406. return m.CategoryID()
  12407. case employee.FieldAPIBase:
  12408. return m.APIBase()
  12409. case employee.FieldAPIKey:
  12410. return m.APIKey()
  12411. case employee.FieldAiInfo:
  12412. return m.AiInfo()
  12413. case employee.FieldIsVip:
  12414. return m.IsVip()
  12415. case employee.FieldChatURL:
  12416. return m.ChatURL()
  12417. }
  12418. return nil, false
  12419. }
  12420. // OldField returns the old value of the field from the database. An error is
  12421. // returned if the mutation operation is not UpdateOne, or the query to the
  12422. // database failed.
  12423. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12424. switch name {
  12425. case employee.FieldCreatedAt:
  12426. return m.OldCreatedAt(ctx)
  12427. case employee.FieldUpdatedAt:
  12428. return m.OldUpdatedAt(ctx)
  12429. case employee.FieldDeletedAt:
  12430. return m.OldDeletedAt(ctx)
  12431. case employee.FieldTitle:
  12432. return m.OldTitle(ctx)
  12433. case employee.FieldAvatar:
  12434. return m.OldAvatar(ctx)
  12435. case employee.FieldTags:
  12436. return m.OldTags(ctx)
  12437. case employee.FieldHireCount:
  12438. return m.OldHireCount(ctx)
  12439. case employee.FieldServiceCount:
  12440. return m.OldServiceCount(ctx)
  12441. case employee.FieldAchievementCount:
  12442. return m.OldAchievementCount(ctx)
  12443. case employee.FieldIntro:
  12444. return m.OldIntro(ctx)
  12445. case employee.FieldEstimate:
  12446. return m.OldEstimate(ctx)
  12447. case employee.FieldSkill:
  12448. return m.OldSkill(ctx)
  12449. case employee.FieldAbilityType:
  12450. return m.OldAbilityType(ctx)
  12451. case employee.FieldScene:
  12452. return m.OldScene(ctx)
  12453. case employee.FieldSwitchIn:
  12454. return m.OldSwitchIn(ctx)
  12455. case employee.FieldVideoURL:
  12456. return m.OldVideoURL(ctx)
  12457. case employee.FieldOrganizationID:
  12458. return m.OldOrganizationID(ctx)
  12459. case employee.FieldCategoryID:
  12460. return m.OldCategoryID(ctx)
  12461. case employee.FieldAPIBase:
  12462. return m.OldAPIBase(ctx)
  12463. case employee.FieldAPIKey:
  12464. return m.OldAPIKey(ctx)
  12465. case employee.FieldAiInfo:
  12466. return m.OldAiInfo(ctx)
  12467. case employee.FieldIsVip:
  12468. return m.OldIsVip(ctx)
  12469. case employee.FieldChatURL:
  12470. return m.OldChatURL(ctx)
  12471. }
  12472. return nil, fmt.Errorf("unknown Employee field %s", name)
  12473. }
  12474. // SetField sets the value of a field with the given name. It returns an error if
  12475. // the field is not defined in the schema, or if the type mismatched the field
  12476. // type.
  12477. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12478. switch name {
  12479. case employee.FieldCreatedAt:
  12480. v, ok := value.(time.Time)
  12481. if !ok {
  12482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12483. }
  12484. m.SetCreatedAt(v)
  12485. return nil
  12486. case employee.FieldUpdatedAt:
  12487. v, ok := value.(time.Time)
  12488. if !ok {
  12489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12490. }
  12491. m.SetUpdatedAt(v)
  12492. return nil
  12493. case employee.FieldDeletedAt:
  12494. v, ok := value.(time.Time)
  12495. if !ok {
  12496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12497. }
  12498. m.SetDeletedAt(v)
  12499. return nil
  12500. case employee.FieldTitle:
  12501. v, ok := value.(string)
  12502. if !ok {
  12503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12504. }
  12505. m.SetTitle(v)
  12506. return nil
  12507. case employee.FieldAvatar:
  12508. v, ok := value.(string)
  12509. if !ok {
  12510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12511. }
  12512. m.SetAvatar(v)
  12513. return nil
  12514. case employee.FieldTags:
  12515. v, ok := value.(string)
  12516. if !ok {
  12517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12518. }
  12519. m.SetTags(v)
  12520. return nil
  12521. case employee.FieldHireCount:
  12522. v, ok := value.(int)
  12523. if !ok {
  12524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12525. }
  12526. m.SetHireCount(v)
  12527. return nil
  12528. case employee.FieldServiceCount:
  12529. v, ok := value.(int)
  12530. if !ok {
  12531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12532. }
  12533. m.SetServiceCount(v)
  12534. return nil
  12535. case employee.FieldAchievementCount:
  12536. v, ok := value.(int)
  12537. if !ok {
  12538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12539. }
  12540. m.SetAchievementCount(v)
  12541. return nil
  12542. case employee.FieldIntro:
  12543. v, ok := value.(string)
  12544. if !ok {
  12545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12546. }
  12547. m.SetIntro(v)
  12548. return nil
  12549. case employee.FieldEstimate:
  12550. v, ok := value.(string)
  12551. if !ok {
  12552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12553. }
  12554. m.SetEstimate(v)
  12555. return nil
  12556. case employee.FieldSkill:
  12557. v, ok := value.(string)
  12558. if !ok {
  12559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12560. }
  12561. m.SetSkill(v)
  12562. return nil
  12563. case employee.FieldAbilityType:
  12564. v, ok := value.(string)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.SetAbilityType(v)
  12569. return nil
  12570. case employee.FieldScene:
  12571. v, ok := value.(string)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.SetScene(v)
  12576. return nil
  12577. case employee.FieldSwitchIn:
  12578. v, ok := value.(string)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.SetSwitchIn(v)
  12583. return nil
  12584. case employee.FieldVideoURL:
  12585. v, ok := value.(string)
  12586. if !ok {
  12587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12588. }
  12589. m.SetVideoURL(v)
  12590. return nil
  12591. case employee.FieldOrganizationID:
  12592. v, ok := value.(uint64)
  12593. if !ok {
  12594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12595. }
  12596. m.SetOrganizationID(v)
  12597. return nil
  12598. case employee.FieldCategoryID:
  12599. v, ok := value.(uint64)
  12600. if !ok {
  12601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12602. }
  12603. m.SetCategoryID(v)
  12604. return nil
  12605. case employee.FieldAPIBase:
  12606. v, ok := value.(string)
  12607. if !ok {
  12608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12609. }
  12610. m.SetAPIBase(v)
  12611. return nil
  12612. case employee.FieldAPIKey:
  12613. v, ok := value.(string)
  12614. if !ok {
  12615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12616. }
  12617. m.SetAPIKey(v)
  12618. return nil
  12619. case employee.FieldAiInfo:
  12620. v, ok := value.(string)
  12621. if !ok {
  12622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12623. }
  12624. m.SetAiInfo(v)
  12625. return nil
  12626. case employee.FieldIsVip:
  12627. v, ok := value.(int)
  12628. if !ok {
  12629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12630. }
  12631. m.SetIsVip(v)
  12632. return nil
  12633. case employee.FieldChatURL:
  12634. v, ok := value.(string)
  12635. if !ok {
  12636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12637. }
  12638. m.SetChatURL(v)
  12639. return nil
  12640. }
  12641. return fmt.Errorf("unknown Employee field %s", name)
  12642. }
  12643. // AddedFields returns all numeric fields that were incremented/decremented during
  12644. // this mutation.
  12645. func (m *EmployeeMutation) AddedFields() []string {
  12646. var fields []string
  12647. if m.addhire_count != nil {
  12648. fields = append(fields, employee.FieldHireCount)
  12649. }
  12650. if m.addservice_count != nil {
  12651. fields = append(fields, employee.FieldServiceCount)
  12652. }
  12653. if m.addachievement_count != nil {
  12654. fields = append(fields, employee.FieldAchievementCount)
  12655. }
  12656. if m.addorganization_id != nil {
  12657. fields = append(fields, employee.FieldOrganizationID)
  12658. }
  12659. if m.addcategory_id != nil {
  12660. fields = append(fields, employee.FieldCategoryID)
  12661. }
  12662. if m.addis_vip != nil {
  12663. fields = append(fields, employee.FieldIsVip)
  12664. }
  12665. return fields
  12666. }
  12667. // AddedField returns the numeric value that was incremented/decremented on a field
  12668. // with the given name. The second boolean return value indicates that this field
  12669. // was not set, or was not defined in the schema.
  12670. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12671. switch name {
  12672. case employee.FieldHireCount:
  12673. return m.AddedHireCount()
  12674. case employee.FieldServiceCount:
  12675. return m.AddedServiceCount()
  12676. case employee.FieldAchievementCount:
  12677. return m.AddedAchievementCount()
  12678. case employee.FieldOrganizationID:
  12679. return m.AddedOrganizationID()
  12680. case employee.FieldCategoryID:
  12681. return m.AddedCategoryID()
  12682. case employee.FieldIsVip:
  12683. return m.AddedIsVip()
  12684. }
  12685. return nil, false
  12686. }
  12687. // AddField adds the value to the field with the given name. It returns an error if
  12688. // the field is not defined in the schema, or if the type mismatched the field
  12689. // type.
  12690. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12691. switch name {
  12692. case employee.FieldHireCount:
  12693. v, ok := value.(int)
  12694. if !ok {
  12695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12696. }
  12697. m.AddHireCount(v)
  12698. return nil
  12699. case employee.FieldServiceCount:
  12700. v, ok := value.(int)
  12701. if !ok {
  12702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12703. }
  12704. m.AddServiceCount(v)
  12705. return nil
  12706. case employee.FieldAchievementCount:
  12707. v, ok := value.(int)
  12708. if !ok {
  12709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12710. }
  12711. m.AddAchievementCount(v)
  12712. return nil
  12713. case employee.FieldOrganizationID:
  12714. v, ok := value.(int64)
  12715. if !ok {
  12716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12717. }
  12718. m.AddOrganizationID(v)
  12719. return nil
  12720. case employee.FieldCategoryID:
  12721. v, ok := value.(int64)
  12722. if !ok {
  12723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12724. }
  12725. m.AddCategoryID(v)
  12726. return nil
  12727. case employee.FieldIsVip:
  12728. v, ok := value.(int)
  12729. if !ok {
  12730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12731. }
  12732. m.AddIsVip(v)
  12733. return nil
  12734. }
  12735. return fmt.Errorf("unknown Employee numeric field %s", name)
  12736. }
  12737. // ClearedFields returns all nullable fields that were cleared during this
  12738. // mutation.
  12739. func (m *EmployeeMutation) ClearedFields() []string {
  12740. var fields []string
  12741. if m.FieldCleared(employee.FieldDeletedAt) {
  12742. fields = append(fields, employee.FieldDeletedAt)
  12743. }
  12744. if m.FieldCleared(employee.FieldAiInfo) {
  12745. fields = append(fields, employee.FieldAiInfo)
  12746. }
  12747. return fields
  12748. }
  12749. // FieldCleared returns a boolean indicating if a field with the given name was
  12750. // cleared in this mutation.
  12751. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12752. _, ok := m.clearedFields[name]
  12753. return ok
  12754. }
  12755. // ClearField clears the value of the field with the given name. It returns an
  12756. // error if the field is not defined in the schema.
  12757. func (m *EmployeeMutation) ClearField(name string) error {
  12758. switch name {
  12759. case employee.FieldDeletedAt:
  12760. m.ClearDeletedAt()
  12761. return nil
  12762. case employee.FieldAiInfo:
  12763. m.ClearAiInfo()
  12764. return nil
  12765. }
  12766. return fmt.Errorf("unknown Employee nullable field %s", name)
  12767. }
  12768. // ResetField resets all changes in the mutation for the field with the given name.
  12769. // It returns an error if the field is not defined in the schema.
  12770. func (m *EmployeeMutation) ResetField(name string) error {
  12771. switch name {
  12772. case employee.FieldCreatedAt:
  12773. m.ResetCreatedAt()
  12774. return nil
  12775. case employee.FieldUpdatedAt:
  12776. m.ResetUpdatedAt()
  12777. return nil
  12778. case employee.FieldDeletedAt:
  12779. m.ResetDeletedAt()
  12780. return nil
  12781. case employee.FieldTitle:
  12782. m.ResetTitle()
  12783. return nil
  12784. case employee.FieldAvatar:
  12785. m.ResetAvatar()
  12786. return nil
  12787. case employee.FieldTags:
  12788. m.ResetTags()
  12789. return nil
  12790. case employee.FieldHireCount:
  12791. m.ResetHireCount()
  12792. return nil
  12793. case employee.FieldServiceCount:
  12794. m.ResetServiceCount()
  12795. return nil
  12796. case employee.FieldAchievementCount:
  12797. m.ResetAchievementCount()
  12798. return nil
  12799. case employee.FieldIntro:
  12800. m.ResetIntro()
  12801. return nil
  12802. case employee.FieldEstimate:
  12803. m.ResetEstimate()
  12804. return nil
  12805. case employee.FieldSkill:
  12806. m.ResetSkill()
  12807. return nil
  12808. case employee.FieldAbilityType:
  12809. m.ResetAbilityType()
  12810. return nil
  12811. case employee.FieldScene:
  12812. m.ResetScene()
  12813. return nil
  12814. case employee.FieldSwitchIn:
  12815. m.ResetSwitchIn()
  12816. return nil
  12817. case employee.FieldVideoURL:
  12818. m.ResetVideoURL()
  12819. return nil
  12820. case employee.FieldOrganizationID:
  12821. m.ResetOrganizationID()
  12822. return nil
  12823. case employee.FieldCategoryID:
  12824. m.ResetCategoryID()
  12825. return nil
  12826. case employee.FieldAPIBase:
  12827. m.ResetAPIBase()
  12828. return nil
  12829. case employee.FieldAPIKey:
  12830. m.ResetAPIKey()
  12831. return nil
  12832. case employee.FieldAiInfo:
  12833. m.ResetAiInfo()
  12834. return nil
  12835. case employee.FieldIsVip:
  12836. m.ResetIsVip()
  12837. return nil
  12838. case employee.FieldChatURL:
  12839. m.ResetChatURL()
  12840. return nil
  12841. }
  12842. return fmt.Errorf("unknown Employee field %s", name)
  12843. }
  12844. // AddedEdges returns all edge names that were set/added in this mutation.
  12845. func (m *EmployeeMutation) AddedEdges() []string {
  12846. edges := make([]string, 0, 2)
  12847. if m.em_work_experiences != nil {
  12848. edges = append(edges, employee.EdgeEmWorkExperiences)
  12849. }
  12850. if m.em_tutorial != nil {
  12851. edges = append(edges, employee.EdgeEmTutorial)
  12852. }
  12853. return edges
  12854. }
  12855. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12856. // name in this mutation.
  12857. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12858. switch name {
  12859. case employee.EdgeEmWorkExperiences:
  12860. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12861. for id := range m.em_work_experiences {
  12862. ids = append(ids, id)
  12863. }
  12864. return ids
  12865. case employee.EdgeEmTutorial:
  12866. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12867. for id := range m.em_tutorial {
  12868. ids = append(ids, id)
  12869. }
  12870. return ids
  12871. }
  12872. return nil
  12873. }
  12874. // RemovedEdges returns all edge names that were removed in this mutation.
  12875. func (m *EmployeeMutation) RemovedEdges() []string {
  12876. edges := make([]string, 0, 2)
  12877. if m.removedem_work_experiences != nil {
  12878. edges = append(edges, employee.EdgeEmWorkExperiences)
  12879. }
  12880. if m.removedem_tutorial != nil {
  12881. edges = append(edges, employee.EdgeEmTutorial)
  12882. }
  12883. return edges
  12884. }
  12885. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12886. // the given name in this mutation.
  12887. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12888. switch name {
  12889. case employee.EdgeEmWorkExperiences:
  12890. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12891. for id := range m.removedem_work_experiences {
  12892. ids = append(ids, id)
  12893. }
  12894. return ids
  12895. case employee.EdgeEmTutorial:
  12896. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12897. for id := range m.removedem_tutorial {
  12898. ids = append(ids, id)
  12899. }
  12900. return ids
  12901. }
  12902. return nil
  12903. }
  12904. // ClearedEdges returns all edge names that were cleared in this mutation.
  12905. func (m *EmployeeMutation) ClearedEdges() []string {
  12906. edges := make([]string, 0, 2)
  12907. if m.clearedem_work_experiences {
  12908. edges = append(edges, employee.EdgeEmWorkExperiences)
  12909. }
  12910. if m.clearedem_tutorial {
  12911. edges = append(edges, employee.EdgeEmTutorial)
  12912. }
  12913. return edges
  12914. }
  12915. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12916. // was cleared in this mutation.
  12917. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12918. switch name {
  12919. case employee.EdgeEmWorkExperiences:
  12920. return m.clearedem_work_experiences
  12921. case employee.EdgeEmTutorial:
  12922. return m.clearedem_tutorial
  12923. }
  12924. return false
  12925. }
  12926. // ClearEdge clears the value of the edge with the given name. It returns an error
  12927. // if that edge is not defined in the schema.
  12928. func (m *EmployeeMutation) ClearEdge(name string) error {
  12929. switch name {
  12930. }
  12931. return fmt.Errorf("unknown Employee unique edge %s", name)
  12932. }
  12933. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12934. // It returns an error if the edge is not defined in the schema.
  12935. func (m *EmployeeMutation) ResetEdge(name string) error {
  12936. switch name {
  12937. case employee.EdgeEmWorkExperiences:
  12938. m.ResetEmWorkExperiences()
  12939. return nil
  12940. case employee.EdgeEmTutorial:
  12941. m.ResetEmTutorial()
  12942. return nil
  12943. }
  12944. return fmt.Errorf("unknown Employee edge %s", name)
  12945. }
  12946. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12947. type EmployeeConfigMutation struct {
  12948. config
  12949. op Op
  12950. typ string
  12951. id *uint64
  12952. created_at *time.Time
  12953. updated_at *time.Time
  12954. deleted_at *time.Time
  12955. stype *string
  12956. title *string
  12957. photo *string
  12958. organization_id *uint64
  12959. addorganization_id *int64
  12960. clearedFields map[string]struct{}
  12961. done bool
  12962. oldValue func(context.Context) (*EmployeeConfig, error)
  12963. predicates []predicate.EmployeeConfig
  12964. }
  12965. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12966. // employeeconfigOption allows management of the mutation configuration using functional options.
  12967. type employeeconfigOption func(*EmployeeConfigMutation)
  12968. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12969. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12970. m := &EmployeeConfigMutation{
  12971. config: c,
  12972. op: op,
  12973. typ: TypeEmployeeConfig,
  12974. clearedFields: make(map[string]struct{}),
  12975. }
  12976. for _, opt := range opts {
  12977. opt(m)
  12978. }
  12979. return m
  12980. }
  12981. // withEmployeeConfigID sets the ID field of the mutation.
  12982. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12983. return func(m *EmployeeConfigMutation) {
  12984. var (
  12985. err error
  12986. once sync.Once
  12987. value *EmployeeConfig
  12988. )
  12989. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12990. once.Do(func() {
  12991. if m.done {
  12992. err = errors.New("querying old values post mutation is not allowed")
  12993. } else {
  12994. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12995. }
  12996. })
  12997. return value, err
  12998. }
  12999. m.id = &id
  13000. }
  13001. }
  13002. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13003. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13004. return func(m *EmployeeConfigMutation) {
  13005. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13006. return node, nil
  13007. }
  13008. m.id = &node.ID
  13009. }
  13010. }
  13011. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13012. // executed in a transaction (ent.Tx), a transactional client is returned.
  13013. func (m EmployeeConfigMutation) Client() *Client {
  13014. client := &Client{config: m.config}
  13015. client.init()
  13016. return client
  13017. }
  13018. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13019. // it returns an error otherwise.
  13020. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13021. if _, ok := m.driver.(*txDriver); !ok {
  13022. return nil, errors.New("ent: mutation is not running in a transaction")
  13023. }
  13024. tx := &Tx{config: m.config}
  13025. tx.init()
  13026. return tx, nil
  13027. }
  13028. // SetID sets the value of the id field. Note that this
  13029. // operation is only accepted on creation of EmployeeConfig entities.
  13030. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13031. m.id = &id
  13032. }
  13033. // ID returns the ID value in the mutation. Note that the ID is only available
  13034. // if it was provided to the builder or after it was returned from the database.
  13035. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13036. if m.id == nil {
  13037. return
  13038. }
  13039. return *m.id, true
  13040. }
  13041. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13042. // That means, if the mutation is applied within a transaction with an isolation level such
  13043. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13044. // or updated by the mutation.
  13045. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13046. switch {
  13047. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13048. id, exists := m.ID()
  13049. if exists {
  13050. return []uint64{id}, nil
  13051. }
  13052. fallthrough
  13053. case m.op.Is(OpUpdate | OpDelete):
  13054. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13055. default:
  13056. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13057. }
  13058. }
  13059. // SetCreatedAt sets the "created_at" field.
  13060. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13061. m.created_at = &t
  13062. }
  13063. // CreatedAt returns the value of the "created_at" field in the mutation.
  13064. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13065. v := m.created_at
  13066. if v == nil {
  13067. return
  13068. }
  13069. return *v, true
  13070. }
  13071. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13072. // If the EmployeeConfig 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 *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13075. if !m.op.Is(OpUpdateOne) {
  13076. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13077. }
  13078. if m.id == nil || m.oldValue == nil {
  13079. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  13084. }
  13085. return oldValue.CreatedAt, nil
  13086. }
  13087. // ResetCreatedAt resets all changes to the "created_at" field.
  13088. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13089. m.created_at = nil
  13090. }
  13091. // SetUpdatedAt sets the "updated_at" field.
  13092. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13093. m.updated_at = &t
  13094. }
  13095. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13096. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13097. v := m.updated_at
  13098. if v == nil {
  13099. return
  13100. }
  13101. return *v, true
  13102. }
  13103. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13104. // If the EmployeeConfig 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 *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13107. if !m.op.Is(OpUpdateOne) {
  13108. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13109. }
  13110. if m.id == nil || m.oldValue == nil {
  13111. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  13116. }
  13117. return oldValue.UpdatedAt, nil
  13118. }
  13119. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13120. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13121. m.updated_at = nil
  13122. }
  13123. // SetDeletedAt sets the "deleted_at" field.
  13124. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13125. m.deleted_at = &t
  13126. }
  13127. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13128. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13129. v := m.deleted_at
  13130. if v == nil {
  13131. return
  13132. }
  13133. return *v, true
  13134. }
  13135. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13136. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13138. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13139. if !m.op.Is(OpUpdateOne) {
  13140. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13141. }
  13142. if m.id == nil || m.oldValue == nil {
  13143. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13144. }
  13145. oldValue, err := m.oldValue(ctx)
  13146. if err != nil {
  13147. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13148. }
  13149. return oldValue.DeletedAt, nil
  13150. }
  13151. // ClearDeletedAt clears the value of the "deleted_at" field.
  13152. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13153. m.deleted_at = nil
  13154. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13155. }
  13156. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13157. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13158. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13159. return ok
  13160. }
  13161. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13162. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13163. m.deleted_at = nil
  13164. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13165. }
  13166. // SetStype sets the "stype" field.
  13167. func (m *EmployeeConfigMutation) SetStype(s string) {
  13168. m.stype = &s
  13169. }
  13170. // Stype returns the value of the "stype" field in the mutation.
  13171. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13172. v := m.stype
  13173. if v == nil {
  13174. return
  13175. }
  13176. return *v, true
  13177. }
  13178. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13179. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13181. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13182. if !m.op.Is(OpUpdateOne) {
  13183. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13184. }
  13185. if m.id == nil || m.oldValue == nil {
  13186. return v, errors.New("OldStype requires an ID field in the mutation")
  13187. }
  13188. oldValue, err := m.oldValue(ctx)
  13189. if err != nil {
  13190. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13191. }
  13192. return oldValue.Stype, nil
  13193. }
  13194. // ResetStype resets all changes to the "stype" field.
  13195. func (m *EmployeeConfigMutation) ResetStype() {
  13196. m.stype = nil
  13197. }
  13198. // SetTitle sets the "title" field.
  13199. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13200. m.title = &s
  13201. }
  13202. // Title returns the value of the "title" field in the mutation.
  13203. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13204. v := m.title
  13205. if v == nil {
  13206. return
  13207. }
  13208. return *v, true
  13209. }
  13210. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13211. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13213. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13214. if !m.op.Is(OpUpdateOne) {
  13215. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13216. }
  13217. if m.id == nil || m.oldValue == nil {
  13218. return v, errors.New("OldTitle requires an ID field in the mutation")
  13219. }
  13220. oldValue, err := m.oldValue(ctx)
  13221. if err != nil {
  13222. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13223. }
  13224. return oldValue.Title, nil
  13225. }
  13226. // ResetTitle resets all changes to the "title" field.
  13227. func (m *EmployeeConfigMutation) ResetTitle() {
  13228. m.title = nil
  13229. }
  13230. // SetPhoto sets the "photo" field.
  13231. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13232. m.photo = &s
  13233. }
  13234. // Photo returns the value of the "photo" field in the mutation.
  13235. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13236. v := m.photo
  13237. if v == nil {
  13238. return
  13239. }
  13240. return *v, true
  13241. }
  13242. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13243. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13245. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13246. if !m.op.Is(OpUpdateOne) {
  13247. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13248. }
  13249. if m.id == nil || m.oldValue == nil {
  13250. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13251. }
  13252. oldValue, err := m.oldValue(ctx)
  13253. if err != nil {
  13254. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13255. }
  13256. return oldValue.Photo, nil
  13257. }
  13258. // ResetPhoto resets all changes to the "photo" field.
  13259. func (m *EmployeeConfigMutation) ResetPhoto() {
  13260. m.photo = nil
  13261. }
  13262. // SetOrganizationID sets the "organization_id" field.
  13263. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13264. m.organization_id = &u
  13265. m.addorganization_id = nil
  13266. }
  13267. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13268. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13269. v := m.organization_id
  13270. if v == nil {
  13271. return
  13272. }
  13273. return *v, true
  13274. }
  13275. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13276. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13278. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13279. if !m.op.Is(OpUpdateOne) {
  13280. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13281. }
  13282. if m.id == nil || m.oldValue == nil {
  13283. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13284. }
  13285. oldValue, err := m.oldValue(ctx)
  13286. if err != nil {
  13287. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13288. }
  13289. return oldValue.OrganizationID, nil
  13290. }
  13291. // AddOrganizationID adds u to the "organization_id" field.
  13292. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13293. if m.addorganization_id != nil {
  13294. *m.addorganization_id += u
  13295. } else {
  13296. m.addorganization_id = &u
  13297. }
  13298. }
  13299. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13300. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13301. v := m.addorganization_id
  13302. if v == nil {
  13303. return
  13304. }
  13305. return *v, true
  13306. }
  13307. // ClearOrganizationID clears the value of the "organization_id" field.
  13308. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13309. m.organization_id = nil
  13310. m.addorganization_id = nil
  13311. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13312. }
  13313. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13314. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13315. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13316. return ok
  13317. }
  13318. // ResetOrganizationID resets all changes to the "organization_id" field.
  13319. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13320. m.organization_id = nil
  13321. m.addorganization_id = nil
  13322. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13323. }
  13324. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13325. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13326. m.predicates = append(m.predicates, ps...)
  13327. }
  13328. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13329. // users can use type-assertion to append predicates that do not depend on any generated package.
  13330. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13331. p := make([]predicate.EmployeeConfig, len(ps))
  13332. for i := range ps {
  13333. p[i] = ps[i]
  13334. }
  13335. m.Where(p...)
  13336. }
  13337. // Op returns the operation name.
  13338. func (m *EmployeeConfigMutation) Op() Op {
  13339. return m.op
  13340. }
  13341. // SetOp allows setting the mutation operation.
  13342. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13343. m.op = op
  13344. }
  13345. // Type returns the node type of this mutation (EmployeeConfig).
  13346. func (m *EmployeeConfigMutation) Type() string {
  13347. return m.typ
  13348. }
  13349. // Fields returns all fields that were changed during this mutation. Note that in
  13350. // order to get all numeric fields that were incremented/decremented, call
  13351. // AddedFields().
  13352. func (m *EmployeeConfigMutation) Fields() []string {
  13353. fields := make([]string, 0, 7)
  13354. if m.created_at != nil {
  13355. fields = append(fields, employeeconfig.FieldCreatedAt)
  13356. }
  13357. if m.updated_at != nil {
  13358. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13359. }
  13360. if m.deleted_at != nil {
  13361. fields = append(fields, employeeconfig.FieldDeletedAt)
  13362. }
  13363. if m.stype != nil {
  13364. fields = append(fields, employeeconfig.FieldStype)
  13365. }
  13366. if m.title != nil {
  13367. fields = append(fields, employeeconfig.FieldTitle)
  13368. }
  13369. if m.photo != nil {
  13370. fields = append(fields, employeeconfig.FieldPhoto)
  13371. }
  13372. if m.organization_id != nil {
  13373. fields = append(fields, employeeconfig.FieldOrganizationID)
  13374. }
  13375. return fields
  13376. }
  13377. // Field returns the value of a field with the given name. The second boolean
  13378. // return value indicates that this field was not set, or was not defined in the
  13379. // schema.
  13380. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13381. switch name {
  13382. case employeeconfig.FieldCreatedAt:
  13383. return m.CreatedAt()
  13384. case employeeconfig.FieldUpdatedAt:
  13385. return m.UpdatedAt()
  13386. case employeeconfig.FieldDeletedAt:
  13387. return m.DeletedAt()
  13388. case employeeconfig.FieldStype:
  13389. return m.Stype()
  13390. case employeeconfig.FieldTitle:
  13391. return m.Title()
  13392. case employeeconfig.FieldPhoto:
  13393. return m.Photo()
  13394. case employeeconfig.FieldOrganizationID:
  13395. return m.OrganizationID()
  13396. }
  13397. return nil, false
  13398. }
  13399. // OldField returns the old value of the field from the database. An error is
  13400. // returned if the mutation operation is not UpdateOne, or the query to the
  13401. // database failed.
  13402. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13403. switch name {
  13404. case employeeconfig.FieldCreatedAt:
  13405. return m.OldCreatedAt(ctx)
  13406. case employeeconfig.FieldUpdatedAt:
  13407. return m.OldUpdatedAt(ctx)
  13408. case employeeconfig.FieldDeletedAt:
  13409. return m.OldDeletedAt(ctx)
  13410. case employeeconfig.FieldStype:
  13411. return m.OldStype(ctx)
  13412. case employeeconfig.FieldTitle:
  13413. return m.OldTitle(ctx)
  13414. case employeeconfig.FieldPhoto:
  13415. return m.OldPhoto(ctx)
  13416. case employeeconfig.FieldOrganizationID:
  13417. return m.OldOrganizationID(ctx)
  13418. }
  13419. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13420. }
  13421. // SetField sets the value of a field with the given name. It returns an error if
  13422. // the field is not defined in the schema, or if the type mismatched the field
  13423. // type.
  13424. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13425. switch name {
  13426. case employeeconfig.FieldCreatedAt:
  13427. v, ok := value.(time.Time)
  13428. if !ok {
  13429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13430. }
  13431. m.SetCreatedAt(v)
  13432. return nil
  13433. case employeeconfig.FieldUpdatedAt:
  13434. v, ok := value.(time.Time)
  13435. if !ok {
  13436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13437. }
  13438. m.SetUpdatedAt(v)
  13439. return nil
  13440. case employeeconfig.FieldDeletedAt:
  13441. v, ok := value.(time.Time)
  13442. if !ok {
  13443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13444. }
  13445. m.SetDeletedAt(v)
  13446. return nil
  13447. case employeeconfig.FieldStype:
  13448. v, ok := value.(string)
  13449. if !ok {
  13450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13451. }
  13452. m.SetStype(v)
  13453. return nil
  13454. case employeeconfig.FieldTitle:
  13455. v, ok := value.(string)
  13456. if !ok {
  13457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13458. }
  13459. m.SetTitle(v)
  13460. return nil
  13461. case employeeconfig.FieldPhoto:
  13462. v, ok := value.(string)
  13463. if !ok {
  13464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13465. }
  13466. m.SetPhoto(v)
  13467. return nil
  13468. case employeeconfig.FieldOrganizationID:
  13469. v, ok := value.(uint64)
  13470. if !ok {
  13471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13472. }
  13473. m.SetOrganizationID(v)
  13474. return nil
  13475. }
  13476. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13477. }
  13478. // AddedFields returns all numeric fields that were incremented/decremented during
  13479. // this mutation.
  13480. func (m *EmployeeConfigMutation) AddedFields() []string {
  13481. var fields []string
  13482. if m.addorganization_id != nil {
  13483. fields = append(fields, employeeconfig.FieldOrganizationID)
  13484. }
  13485. return fields
  13486. }
  13487. // AddedField returns the numeric value that was incremented/decremented on a field
  13488. // with the given name. The second boolean return value indicates that this field
  13489. // was not set, or was not defined in the schema.
  13490. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13491. switch name {
  13492. case employeeconfig.FieldOrganizationID:
  13493. return m.AddedOrganizationID()
  13494. }
  13495. return nil, false
  13496. }
  13497. // AddField adds the value to the field with the given name. It returns an error if
  13498. // the field is not defined in the schema, or if the type mismatched the field
  13499. // type.
  13500. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13501. switch name {
  13502. case employeeconfig.FieldOrganizationID:
  13503. v, ok := value.(int64)
  13504. if !ok {
  13505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13506. }
  13507. m.AddOrganizationID(v)
  13508. return nil
  13509. }
  13510. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13511. }
  13512. // ClearedFields returns all nullable fields that were cleared during this
  13513. // mutation.
  13514. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13515. var fields []string
  13516. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13517. fields = append(fields, employeeconfig.FieldDeletedAt)
  13518. }
  13519. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13520. fields = append(fields, employeeconfig.FieldOrganizationID)
  13521. }
  13522. return fields
  13523. }
  13524. // FieldCleared returns a boolean indicating if a field with the given name was
  13525. // cleared in this mutation.
  13526. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13527. _, ok := m.clearedFields[name]
  13528. return ok
  13529. }
  13530. // ClearField clears the value of the field with the given name. It returns an
  13531. // error if the field is not defined in the schema.
  13532. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13533. switch name {
  13534. case employeeconfig.FieldDeletedAt:
  13535. m.ClearDeletedAt()
  13536. return nil
  13537. case employeeconfig.FieldOrganizationID:
  13538. m.ClearOrganizationID()
  13539. return nil
  13540. }
  13541. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13542. }
  13543. // ResetField resets all changes in the mutation for the field with the given name.
  13544. // It returns an error if the field is not defined in the schema.
  13545. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13546. switch name {
  13547. case employeeconfig.FieldCreatedAt:
  13548. m.ResetCreatedAt()
  13549. return nil
  13550. case employeeconfig.FieldUpdatedAt:
  13551. m.ResetUpdatedAt()
  13552. return nil
  13553. case employeeconfig.FieldDeletedAt:
  13554. m.ResetDeletedAt()
  13555. return nil
  13556. case employeeconfig.FieldStype:
  13557. m.ResetStype()
  13558. return nil
  13559. case employeeconfig.FieldTitle:
  13560. m.ResetTitle()
  13561. return nil
  13562. case employeeconfig.FieldPhoto:
  13563. m.ResetPhoto()
  13564. return nil
  13565. case employeeconfig.FieldOrganizationID:
  13566. m.ResetOrganizationID()
  13567. return nil
  13568. }
  13569. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13570. }
  13571. // AddedEdges returns all edge names that were set/added in this mutation.
  13572. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13573. edges := make([]string, 0, 0)
  13574. return edges
  13575. }
  13576. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13577. // name in this mutation.
  13578. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13579. return nil
  13580. }
  13581. // RemovedEdges returns all edge names that were removed in this mutation.
  13582. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13583. edges := make([]string, 0, 0)
  13584. return edges
  13585. }
  13586. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13587. // the given name in this mutation.
  13588. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13589. return nil
  13590. }
  13591. // ClearedEdges returns all edge names that were cleared in this mutation.
  13592. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13593. edges := make([]string, 0, 0)
  13594. return edges
  13595. }
  13596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13597. // was cleared in this mutation.
  13598. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13599. return false
  13600. }
  13601. // ClearEdge clears the value of the edge with the given name. It returns an error
  13602. // if that edge is not defined in the schema.
  13603. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13604. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13605. }
  13606. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13607. // It returns an error if the edge is not defined in the schema.
  13608. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13609. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13610. }
  13611. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13612. type LabelMutation struct {
  13613. config
  13614. op Op
  13615. typ string
  13616. id *uint64
  13617. created_at *time.Time
  13618. updated_at *time.Time
  13619. status *uint8
  13620. addstatus *int8
  13621. _type *int
  13622. add_type *int
  13623. name *string
  13624. from *int
  13625. addfrom *int
  13626. mode *int
  13627. addmode *int
  13628. conditions *string
  13629. organization_id *uint64
  13630. addorganization_id *int64
  13631. clearedFields map[string]struct{}
  13632. label_relationships map[uint64]struct{}
  13633. removedlabel_relationships map[uint64]struct{}
  13634. clearedlabel_relationships bool
  13635. done bool
  13636. oldValue func(context.Context) (*Label, error)
  13637. predicates []predicate.Label
  13638. }
  13639. var _ ent.Mutation = (*LabelMutation)(nil)
  13640. // labelOption allows management of the mutation configuration using functional options.
  13641. type labelOption func(*LabelMutation)
  13642. // newLabelMutation creates new mutation for the Label entity.
  13643. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13644. m := &LabelMutation{
  13645. config: c,
  13646. op: op,
  13647. typ: TypeLabel,
  13648. clearedFields: make(map[string]struct{}),
  13649. }
  13650. for _, opt := range opts {
  13651. opt(m)
  13652. }
  13653. return m
  13654. }
  13655. // withLabelID sets the ID field of the mutation.
  13656. func withLabelID(id uint64) labelOption {
  13657. return func(m *LabelMutation) {
  13658. var (
  13659. err error
  13660. once sync.Once
  13661. value *Label
  13662. )
  13663. m.oldValue = func(ctx context.Context) (*Label, error) {
  13664. once.Do(func() {
  13665. if m.done {
  13666. err = errors.New("querying old values post mutation is not allowed")
  13667. } else {
  13668. value, err = m.Client().Label.Get(ctx, id)
  13669. }
  13670. })
  13671. return value, err
  13672. }
  13673. m.id = &id
  13674. }
  13675. }
  13676. // withLabel sets the old Label of the mutation.
  13677. func withLabel(node *Label) labelOption {
  13678. return func(m *LabelMutation) {
  13679. m.oldValue = func(context.Context) (*Label, error) {
  13680. return node, nil
  13681. }
  13682. m.id = &node.ID
  13683. }
  13684. }
  13685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13686. // executed in a transaction (ent.Tx), a transactional client is returned.
  13687. func (m LabelMutation) Client() *Client {
  13688. client := &Client{config: m.config}
  13689. client.init()
  13690. return client
  13691. }
  13692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13693. // it returns an error otherwise.
  13694. func (m LabelMutation) Tx() (*Tx, error) {
  13695. if _, ok := m.driver.(*txDriver); !ok {
  13696. return nil, errors.New("ent: mutation is not running in a transaction")
  13697. }
  13698. tx := &Tx{config: m.config}
  13699. tx.init()
  13700. return tx, nil
  13701. }
  13702. // SetID sets the value of the id field. Note that this
  13703. // operation is only accepted on creation of Label entities.
  13704. func (m *LabelMutation) SetID(id uint64) {
  13705. m.id = &id
  13706. }
  13707. // ID returns the ID value in the mutation. Note that the ID is only available
  13708. // if it was provided to the builder or after it was returned from the database.
  13709. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13710. if m.id == nil {
  13711. return
  13712. }
  13713. return *m.id, true
  13714. }
  13715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13716. // That means, if the mutation is applied within a transaction with an isolation level such
  13717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13718. // or updated by the mutation.
  13719. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13720. switch {
  13721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13722. id, exists := m.ID()
  13723. if exists {
  13724. return []uint64{id}, nil
  13725. }
  13726. fallthrough
  13727. case m.op.Is(OpUpdate | OpDelete):
  13728. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13729. default:
  13730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13731. }
  13732. }
  13733. // SetCreatedAt sets the "created_at" field.
  13734. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13735. m.created_at = &t
  13736. }
  13737. // CreatedAt returns the value of the "created_at" field in the mutation.
  13738. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13739. v := m.created_at
  13740. if v == nil {
  13741. return
  13742. }
  13743. return *v, true
  13744. }
  13745. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13746. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13748. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13749. if !m.op.Is(OpUpdateOne) {
  13750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13751. }
  13752. if m.id == nil || m.oldValue == nil {
  13753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13754. }
  13755. oldValue, err := m.oldValue(ctx)
  13756. if err != nil {
  13757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13758. }
  13759. return oldValue.CreatedAt, nil
  13760. }
  13761. // ResetCreatedAt resets all changes to the "created_at" field.
  13762. func (m *LabelMutation) ResetCreatedAt() {
  13763. m.created_at = nil
  13764. }
  13765. // SetUpdatedAt sets the "updated_at" field.
  13766. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13767. m.updated_at = &t
  13768. }
  13769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13770. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13771. v := m.updated_at
  13772. if v == nil {
  13773. return
  13774. }
  13775. return *v, true
  13776. }
  13777. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13778. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13780. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13781. if !m.op.Is(OpUpdateOne) {
  13782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13783. }
  13784. if m.id == nil || m.oldValue == nil {
  13785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13786. }
  13787. oldValue, err := m.oldValue(ctx)
  13788. if err != nil {
  13789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13790. }
  13791. return oldValue.UpdatedAt, nil
  13792. }
  13793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13794. func (m *LabelMutation) ResetUpdatedAt() {
  13795. m.updated_at = nil
  13796. }
  13797. // SetStatus sets the "status" field.
  13798. func (m *LabelMutation) SetStatus(u uint8) {
  13799. m.status = &u
  13800. m.addstatus = nil
  13801. }
  13802. // Status returns the value of the "status" field in the mutation.
  13803. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13804. v := m.status
  13805. if v == nil {
  13806. return
  13807. }
  13808. return *v, true
  13809. }
  13810. // OldStatus returns the old "status" field's value of the Label entity.
  13811. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13813. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13814. if !m.op.Is(OpUpdateOne) {
  13815. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13816. }
  13817. if m.id == nil || m.oldValue == nil {
  13818. return v, errors.New("OldStatus requires an ID field in the mutation")
  13819. }
  13820. oldValue, err := m.oldValue(ctx)
  13821. if err != nil {
  13822. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13823. }
  13824. return oldValue.Status, nil
  13825. }
  13826. // AddStatus adds u to the "status" field.
  13827. func (m *LabelMutation) AddStatus(u int8) {
  13828. if m.addstatus != nil {
  13829. *m.addstatus += u
  13830. } else {
  13831. m.addstatus = &u
  13832. }
  13833. }
  13834. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13835. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13836. v := m.addstatus
  13837. if v == nil {
  13838. return
  13839. }
  13840. return *v, true
  13841. }
  13842. // ClearStatus clears the value of the "status" field.
  13843. func (m *LabelMutation) ClearStatus() {
  13844. m.status = nil
  13845. m.addstatus = nil
  13846. m.clearedFields[label.FieldStatus] = struct{}{}
  13847. }
  13848. // StatusCleared returns if the "status" field was cleared in this mutation.
  13849. func (m *LabelMutation) StatusCleared() bool {
  13850. _, ok := m.clearedFields[label.FieldStatus]
  13851. return ok
  13852. }
  13853. // ResetStatus resets all changes to the "status" field.
  13854. func (m *LabelMutation) ResetStatus() {
  13855. m.status = nil
  13856. m.addstatus = nil
  13857. delete(m.clearedFields, label.FieldStatus)
  13858. }
  13859. // SetType sets the "type" field.
  13860. func (m *LabelMutation) SetType(i int) {
  13861. m._type = &i
  13862. m.add_type = nil
  13863. }
  13864. // GetType returns the value of the "type" field in the mutation.
  13865. func (m *LabelMutation) GetType() (r int, exists bool) {
  13866. v := m._type
  13867. if v == nil {
  13868. return
  13869. }
  13870. return *v, true
  13871. }
  13872. // OldType returns the old "type" field's value of the Label entity.
  13873. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13875. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13876. if !m.op.Is(OpUpdateOne) {
  13877. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13878. }
  13879. if m.id == nil || m.oldValue == nil {
  13880. return v, errors.New("OldType requires an ID field in the mutation")
  13881. }
  13882. oldValue, err := m.oldValue(ctx)
  13883. if err != nil {
  13884. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13885. }
  13886. return oldValue.Type, nil
  13887. }
  13888. // AddType adds i to the "type" field.
  13889. func (m *LabelMutation) AddType(i int) {
  13890. if m.add_type != nil {
  13891. *m.add_type += i
  13892. } else {
  13893. m.add_type = &i
  13894. }
  13895. }
  13896. // AddedType returns the value that was added to the "type" field in this mutation.
  13897. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13898. v := m.add_type
  13899. if v == nil {
  13900. return
  13901. }
  13902. return *v, true
  13903. }
  13904. // ResetType resets all changes to the "type" field.
  13905. func (m *LabelMutation) ResetType() {
  13906. m._type = nil
  13907. m.add_type = nil
  13908. }
  13909. // SetName sets the "name" field.
  13910. func (m *LabelMutation) SetName(s string) {
  13911. m.name = &s
  13912. }
  13913. // Name returns the value of the "name" field in the mutation.
  13914. func (m *LabelMutation) Name() (r string, exists bool) {
  13915. v := m.name
  13916. if v == nil {
  13917. return
  13918. }
  13919. return *v, true
  13920. }
  13921. // OldName returns the old "name" field's value of the Label entity.
  13922. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13924. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13925. if !m.op.Is(OpUpdateOne) {
  13926. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13927. }
  13928. if m.id == nil || m.oldValue == nil {
  13929. return v, errors.New("OldName requires an ID field in the mutation")
  13930. }
  13931. oldValue, err := m.oldValue(ctx)
  13932. if err != nil {
  13933. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13934. }
  13935. return oldValue.Name, nil
  13936. }
  13937. // ResetName resets all changes to the "name" field.
  13938. func (m *LabelMutation) ResetName() {
  13939. m.name = nil
  13940. }
  13941. // SetFrom sets the "from" field.
  13942. func (m *LabelMutation) SetFrom(i int) {
  13943. m.from = &i
  13944. m.addfrom = nil
  13945. }
  13946. // From returns the value of the "from" field in the mutation.
  13947. func (m *LabelMutation) From() (r int, exists bool) {
  13948. v := m.from
  13949. if v == nil {
  13950. return
  13951. }
  13952. return *v, true
  13953. }
  13954. // OldFrom returns the old "from" field's value of the Label entity.
  13955. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13957. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13958. if !m.op.Is(OpUpdateOne) {
  13959. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13960. }
  13961. if m.id == nil || m.oldValue == nil {
  13962. return v, errors.New("OldFrom requires an ID field in the mutation")
  13963. }
  13964. oldValue, err := m.oldValue(ctx)
  13965. if err != nil {
  13966. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13967. }
  13968. return oldValue.From, nil
  13969. }
  13970. // AddFrom adds i to the "from" field.
  13971. func (m *LabelMutation) AddFrom(i int) {
  13972. if m.addfrom != nil {
  13973. *m.addfrom += i
  13974. } else {
  13975. m.addfrom = &i
  13976. }
  13977. }
  13978. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13979. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13980. v := m.addfrom
  13981. if v == nil {
  13982. return
  13983. }
  13984. return *v, true
  13985. }
  13986. // ResetFrom resets all changes to the "from" field.
  13987. func (m *LabelMutation) ResetFrom() {
  13988. m.from = nil
  13989. m.addfrom = nil
  13990. }
  13991. // SetMode sets the "mode" field.
  13992. func (m *LabelMutation) SetMode(i int) {
  13993. m.mode = &i
  13994. m.addmode = nil
  13995. }
  13996. // Mode returns the value of the "mode" field in the mutation.
  13997. func (m *LabelMutation) Mode() (r int, exists bool) {
  13998. v := m.mode
  13999. if v == nil {
  14000. return
  14001. }
  14002. return *v, true
  14003. }
  14004. // OldMode returns the old "mode" field's value of the Label entity.
  14005. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14007. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14008. if !m.op.Is(OpUpdateOne) {
  14009. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14010. }
  14011. if m.id == nil || m.oldValue == nil {
  14012. return v, errors.New("OldMode requires an ID field in the mutation")
  14013. }
  14014. oldValue, err := m.oldValue(ctx)
  14015. if err != nil {
  14016. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14017. }
  14018. return oldValue.Mode, nil
  14019. }
  14020. // AddMode adds i to the "mode" field.
  14021. func (m *LabelMutation) AddMode(i int) {
  14022. if m.addmode != nil {
  14023. *m.addmode += i
  14024. } else {
  14025. m.addmode = &i
  14026. }
  14027. }
  14028. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14029. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14030. v := m.addmode
  14031. if v == nil {
  14032. return
  14033. }
  14034. return *v, true
  14035. }
  14036. // ResetMode resets all changes to the "mode" field.
  14037. func (m *LabelMutation) ResetMode() {
  14038. m.mode = nil
  14039. m.addmode = nil
  14040. }
  14041. // SetConditions sets the "conditions" field.
  14042. func (m *LabelMutation) SetConditions(s string) {
  14043. m.conditions = &s
  14044. }
  14045. // Conditions returns the value of the "conditions" field in the mutation.
  14046. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14047. v := m.conditions
  14048. if v == nil {
  14049. return
  14050. }
  14051. return *v, true
  14052. }
  14053. // OldConditions returns the old "conditions" field's value of the Label entity.
  14054. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14056. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14057. if !m.op.Is(OpUpdateOne) {
  14058. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14059. }
  14060. if m.id == nil || m.oldValue == nil {
  14061. return v, errors.New("OldConditions requires an ID field in the mutation")
  14062. }
  14063. oldValue, err := m.oldValue(ctx)
  14064. if err != nil {
  14065. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14066. }
  14067. return oldValue.Conditions, nil
  14068. }
  14069. // ClearConditions clears the value of the "conditions" field.
  14070. func (m *LabelMutation) ClearConditions() {
  14071. m.conditions = nil
  14072. m.clearedFields[label.FieldConditions] = struct{}{}
  14073. }
  14074. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14075. func (m *LabelMutation) ConditionsCleared() bool {
  14076. _, ok := m.clearedFields[label.FieldConditions]
  14077. return ok
  14078. }
  14079. // ResetConditions resets all changes to the "conditions" field.
  14080. func (m *LabelMutation) ResetConditions() {
  14081. m.conditions = nil
  14082. delete(m.clearedFields, label.FieldConditions)
  14083. }
  14084. // SetOrganizationID sets the "organization_id" field.
  14085. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14086. m.organization_id = &u
  14087. m.addorganization_id = nil
  14088. }
  14089. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14090. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14091. v := m.organization_id
  14092. if v == nil {
  14093. return
  14094. }
  14095. return *v, true
  14096. }
  14097. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14098. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14100. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14101. if !m.op.Is(OpUpdateOne) {
  14102. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14103. }
  14104. if m.id == nil || m.oldValue == nil {
  14105. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14106. }
  14107. oldValue, err := m.oldValue(ctx)
  14108. if err != nil {
  14109. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14110. }
  14111. return oldValue.OrganizationID, nil
  14112. }
  14113. // AddOrganizationID adds u to the "organization_id" field.
  14114. func (m *LabelMutation) AddOrganizationID(u int64) {
  14115. if m.addorganization_id != nil {
  14116. *m.addorganization_id += u
  14117. } else {
  14118. m.addorganization_id = &u
  14119. }
  14120. }
  14121. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14122. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14123. v := m.addorganization_id
  14124. if v == nil {
  14125. return
  14126. }
  14127. return *v, true
  14128. }
  14129. // ClearOrganizationID clears the value of the "organization_id" field.
  14130. func (m *LabelMutation) ClearOrganizationID() {
  14131. m.organization_id = nil
  14132. m.addorganization_id = nil
  14133. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14134. }
  14135. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14136. func (m *LabelMutation) OrganizationIDCleared() bool {
  14137. _, ok := m.clearedFields[label.FieldOrganizationID]
  14138. return ok
  14139. }
  14140. // ResetOrganizationID resets all changes to the "organization_id" field.
  14141. func (m *LabelMutation) ResetOrganizationID() {
  14142. m.organization_id = nil
  14143. m.addorganization_id = nil
  14144. delete(m.clearedFields, label.FieldOrganizationID)
  14145. }
  14146. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14147. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14148. if m.label_relationships == nil {
  14149. m.label_relationships = make(map[uint64]struct{})
  14150. }
  14151. for i := range ids {
  14152. m.label_relationships[ids[i]] = struct{}{}
  14153. }
  14154. }
  14155. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14156. func (m *LabelMutation) ClearLabelRelationships() {
  14157. m.clearedlabel_relationships = true
  14158. }
  14159. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14160. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14161. return m.clearedlabel_relationships
  14162. }
  14163. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14164. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14165. if m.removedlabel_relationships == nil {
  14166. m.removedlabel_relationships = make(map[uint64]struct{})
  14167. }
  14168. for i := range ids {
  14169. delete(m.label_relationships, ids[i])
  14170. m.removedlabel_relationships[ids[i]] = struct{}{}
  14171. }
  14172. }
  14173. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14174. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14175. for id := range m.removedlabel_relationships {
  14176. ids = append(ids, id)
  14177. }
  14178. return
  14179. }
  14180. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14181. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14182. for id := range m.label_relationships {
  14183. ids = append(ids, id)
  14184. }
  14185. return
  14186. }
  14187. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14188. func (m *LabelMutation) ResetLabelRelationships() {
  14189. m.label_relationships = nil
  14190. m.clearedlabel_relationships = false
  14191. m.removedlabel_relationships = nil
  14192. }
  14193. // Where appends a list predicates to the LabelMutation builder.
  14194. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14195. m.predicates = append(m.predicates, ps...)
  14196. }
  14197. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14198. // users can use type-assertion to append predicates that do not depend on any generated package.
  14199. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14200. p := make([]predicate.Label, len(ps))
  14201. for i := range ps {
  14202. p[i] = ps[i]
  14203. }
  14204. m.Where(p...)
  14205. }
  14206. // Op returns the operation name.
  14207. func (m *LabelMutation) Op() Op {
  14208. return m.op
  14209. }
  14210. // SetOp allows setting the mutation operation.
  14211. func (m *LabelMutation) SetOp(op Op) {
  14212. m.op = op
  14213. }
  14214. // Type returns the node type of this mutation (Label).
  14215. func (m *LabelMutation) Type() string {
  14216. return m.typ
  14217. }
  14218. // Fields returns all fields that were changed during this mutation. Note that in
  14219. // order to get all numeric fields that were incremented/decremented, call
  14220. // AddedFields().
  14221. func (m *LabelMutation) Fields() []string {
  14222. fields := make([]string, 0, 9)
  14223. if m.created_at != nil {
  14224. fields = append(fields, label.FieldCreatedAt)
  14225. }
  14226. if m.updated_at != nil {
  14227. fields = append(fields, label.FieldUpdatedAt)
  14228. }
  14229. if m.status != nil {
  14230. fields = append(fields, label.FieldStatus)
  14231. }
  14232. if m._type != nil {
  14233. fields = append(fields, label.FieldType)
  14234. }
  14235. if m.name != nil {
  14236. fields = append(fields, label.FieldName)
  14237. }
  14238. if m.from != nil {
  14239. fields = append(fields, label.FieldFrom)
  14240. }
  14241. if m.mode != nil {
  14242. fields = append(fields, label.FieldMode)
  14243. }
  14244. if m.conditions != nil {
  14245. fields = append(fields, label.FieldConditions)
  14246. }
  14247. if m.organization_id != nil {
  14248. fields = append(fields, label.FieldOrganizationID)
  14249. }
  14250. return fields
  14251. }
  14252. // Field returns the value of a field with the given name. The second boolean
  14253. // return value indicates that this field was not set, or was not defined in the
  14254. // schema.
  14255. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14256. switch name {
  14257. case label.FieldCreatedAt:
  14258. return m.CreatedAt()
  14259. case label.FieldUpdatedAt:
  14260. return m.UpdatedAt()
  14261. case label.FieldStatus:
  14262. return m.Status()
  14263. case label.FieldType:
  14264. return m.GetType()
  14265. case label.FieldName:
  14266. return m.Name()
  14267. case label.FieldFrom:
  14268. return m.From()
  14269. case label.FieldMode:
  14270. return m.Mode()
  14271. case label.FieldConditions:
  14272. return m.Conditions()
  14273. case label.FieldOrganizationID:
  14274. return m.OrganizationID()
  14275. }
  14276. return nil, false
  14277. }
  14278. // OldField returns the old value of the field from the database. An error is
  14279. // returned if the mutation operation is not UpdateOne, or the query to the
  14280. // database failed.
  14281. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14282. switch name {
  14283. case label.FieldCreatedAt:
  14284. return m.OldCreatedAt(ctx)
  14285. case label.FieldUpdatedAt:
  14286. return m.OldUpdatedAt(ctx)
  14287. case label.FieldStatus:
  14288. return m.OldStatus(ctx)
  14289. case label.FieldType:
  14290. return m.OldType(ctx)
  14291. case label.FieldName:
  14292. return m.OldName(ctx)
  14293. case label.FieldFrom:
  14294. return m.OldFrom(ctx)
  14295. case label.FieldMode:
  14296. return m.OldMode(ctx)
  14297. case label.FieldConditions:
  14298. return m.OldConditions(ctx)
  14299. case label.FieldOrganizationID:
  14300. return m.OldOrganizationID(ctx)
  14301. }
  14302. return nil, fmt.Errorf("unknown Label field %s", name)
  14303. }
  14304. // SetField sets the value of a field with the given name. It returns an error if
  14305. // the field is not defined in the schema, or if the type mismatched the field
  14306. // type.
  14307. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14308. switch name {
  14309. case label.FieldCreatedAt:
  14310. v, ok := value.(time.Time)
  14311. if !ok {
  14312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14313. }
  14314. m.SetCreatedAt(v)
  14315. return nil
  14316. case label.FieldUpdatedAt:
  14317. v, ok := value.(time.Time)
  14318. if !ok {
  14319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14320. }
  14321. m.SetUpdatedAt(v)
  14322. return nil
  14323. case label.FieldStatus:
  14324. v, ok := value.(uint8)
  14325. if !ok {
  14326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14327. }
  14328. m.SetStatus(v)
  14329. return nil
  14330. case label.FieldType:
  14331. v, ok := value.(int)
  14332. if !ok {
  14333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14334. }
  14335. m.SetType(v)
  14336. return nil
  14337. case label.FieldName:
  14338. v, ok := value.(string)
  14339. if !ok {
  14340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14341. }
  14342. m.SetName(v)
  14343. return nil
  14344. case label.FieldFrom:
  14345. v, ok := value.(int)
  14346. if !ok {
  14347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14348. }
  14349. m.SetFrom(v)
  14350. return nil
  14351. case label.FieldMode:
  14352. v, ok := value.(int)
  14353. if !ok {
  14354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14355. }
  14356. m.SetMode(v)
  14357. return nil
  14358. case label.FieldConditions:
  14359. v, ok := value.(string)
  14360. if !ok {
  14361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14362. }
  14363. m.SetConditions(v)
  14364. return nil
  14365. case label.FieldOrganizationID:
  14366. v, ok := value.(uint64)
  14367. if !ok {
  14368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14369. }
  14370. m.SetOrganizationID(v)
  14371. return nil
  14372. }
  14373. return fmt.Errorf("unknown Label field %s", name)
  14374. }
  14375. // AddedFields returns all numeric fields that were incremented/decremented during
  14376. // this mutation.
  14377. func (m *LabelMutation) AddedFields() []string {
  14378. var fields []string
  14379. if m.addstatus != nil {
  14380. fields = append(fields, label.FieldStatus)
  14381. }
  14382. if m.add_type != nil {
  14383. fields = append(fields, label.FieldType)
  14384. }
  14385. if m.addfrom != nil {
  14386. fields = append(fields, label.FieldFrom)
  14387. }
  14388. if m.addmode != nil {
  14389. fields = append(fields, label.FieldMode)
  14390. }
  14391. if m.addorganization_id != nil {
  14392. fields = append(fields, label.FieldOrganizationID)
  14393. }
  14394. return fields
  14395. }
  14396. // AddedField returns the numeric value that was incremented/decremented on a field
  14397. // with the given name. The second boolean return value indicates that this field
  14398. // was not set, or was not defined in the schema.
  14399. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14400. switch name {
  14401. case label.FieldStatus:
  14402. return m.AddedStatus()
  14403. case label.FieldType:
  14404. return m.AddedType()
  14405. case label.FieldFrom:
  14406. return m.AddedFrom()
  14407. case label.FieldMode:
  14408. return m.AddedMode()
  14409. case label.FieldOrganizationID:
  14410. return m.AddedOrganizationID()
  14411. }
  14412. return nil, false
  14413. }
  14414. // AddField adds the value to the field with the given name. It returns an error if
  14415. // the field is not defined in the schema, or if the type mismatched the field
  14416. // type.
  14417. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14418. switch name {
  14419. case label.FieldStatus:
  14420. v, ok := value.(int8)
  14421. if !ok {
  14422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14423. }
  14424. m.AddStatus(v)
  14425. return nil
  14426. case label.FieldType:
  14427. v, ok := value.(int)
  14428. if !ok {
  14429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14430. }
  14431. m.AddType(v)
  14432. return nil
  14433. case label.FieldFrom:
  14434. v, ok := value.(int)
  14435. if !ok {
  14436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14437. }
  14438. m.AddFrom(v)
  14439. return nil
  14440. case label.FieldMode:
  14441. v, ok := value.(int)
  14442. if !ok {
  14443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14444. }
  14445. m.AddMode(v)
  14446. return nil
  14447. case label.FieldOrganizationID:
  14448. v, ok := value.(int64)
  14449. if !ok {
  14450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14451. }
  14452. m.AddOrganizationID(v)
  14453. return nil
  14454. }
  14455. return fmt.Errorf("unknown Label numeric field %s", name)
  14456. }
  14457. // ClearedFields returns all nullable fields that were cleared during this
  14458. // mutation.
  14459. func (m *LabelMutation) ClearedFields() []string {
  14460. var fields []string
  14461. if m.FieldCleared(label.FieldStatus) {
  14462. fields = append(fields, label.FieldStatus)
  14463. }
  14464. if m.FieldCleared(label.FieldConditions) {
  14465. fields = append(fields, label.FieldConditions)
  14466. }
  14467. if m.FieldCleared(label.FieldOrganizationID) {
  14468. fields = append(fields, label.FieldOrganizationID)
  14469. }
  14470. return fields
  14471. }
  14472. // FieldCleared returns a boolean indicating if a field with the given name was
  14473. // cleared in this mutation.
  14474. func (m *LabelMutation) FieldCleared(name string) bool {
  14475. _, ok := m.clearedFields[name]
  14476. return ok
  14477. }
  14478. // ClearField clears the value of the field with the given name. It returns an
  14479. // error if the field is not defined in the schema.
  14480. func (m *LabelMutation) ClearField(name string) error {
  14481. switch name {
  14482. case label.FieldStatus:
  14483. m.ClearStatus()
  14484. return nil
  14485. case label.FieldConditions:
  14486. m.ClearConditions()
  14487. return nil
  14488. case label.FieldOrganizationID:
  14489. m.ClearOrganizationID()
  14490. return nil
  14491. }
  14492. return fmt.Errorf("unknown Label nullable field %s", name)
  14493. }
  14494. // ResetField resets all changes in the mutation for the field with the given name.
  14495. // It returns an error if the field is not defined in the schema.
  14496. func (m *LabelMutation) ResetField(name string) error {
  14497. switch name {
  14498. case label.FieldCreatedAt:
  14499. m.ResetCreatedAt()
  14500. return nil
  14501. case label.FieldUpdatedAt:
  14502. m.ResetUpdatedAt()
  14503. return nil
  14504. case label.FieldStatus:
  14505. m.ResetStatus()
  14506. return nil
  14507. case label.FieldType:
  14508. m.ResetType()
  14509. return nil
  14510. case label.FieldName:
  14511. m.ResetName()
  14512. return nil
  14513. case label.FieldFrom:
  14514. m.ResetFrom()
  14515. return nil
  14516. case label.FieldMode:
  14517. m.ResetMode()
  14518. return nil
  14519. case label.FieldConditions:
  14520. m.ResetConditions()
  14521. return nil
  14522. case label.FieldOrganizationID:
  14523. m.ResetOrganizationID()
  14524. return nil
  14525. }
  14526. return fmt.Errorf("unknown Label field %s", name)
  14527. }
  14528. // AddedEdges returns all edge names that were set/added in this mutation.
  14529. func (m *LabelMutation) AddedEdges() []string {
  14530. edges := make([]string, 0, 1)
  14531. if m.label_relationships != nil {
  14532. edges = append(edges, label.EdgeLabelRelationships)
  14533. }
  14534. return edges
  14535. }
  14536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14537. // name in this mutation.
  14538. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14539. switch name {
  14540. case label.EdgeLabelRelationships:
  14541. ids := make([]ent.Value, 0, len(m.label_relationships))
  14542. for id := range m.label_relationships {
  14543. ids = append(ids, id)
  14544. }
  14545. return ids
  14546. }
  14547. return nil
  14548. }
  14549. // RemovedEdges returns all edge names that were removed in this mutation.
  14550. func (m *LabelMutation) RemovedEdges() []string {
  14551. edges := make([]string, 0, 1)
  14552. if m.removedlabel_relationships != nil {
  14553. edges = append(edges, label.EdgeLabelRelationships)
  14554. }
  14555. return edges
  14556. }
  14557. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14558. // the given name in this mutation.
  14559. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14560. switch name {
  14561. case label.EdgeLabelRelationships:
  14562. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14563. for id := range m.removedlabel_relationships {
  14564. ids = append(ids, id)
  14565. }
  14566. return ids
  14567. }
  14568. return nil
  14569. }
  14570. // ClearedEdges returns all edge names that were cleared in this mutation.
  14571. func (m *LabelMutation) ClearedEdges() []string {
  14572. edges := make([]string, 0, 1)
  14573. if m.clearedlabel_relationships {
  14574. edges = append(edges, label.EdgeLabelRelationships)
  14575. }
  14576. return edges
  14577. }
  14578. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14579. // was cleared in this mutation.
  14580. func (m *LabelMutation) EdgeCleared(name string) bool {
  14581. switch name {
  14582. case label.EdgeLabelRelationships:
  14583. return m.clearedlabel_relationships
  14584. }
  14585. return false
  14586. }
  14587. // ClearEdge clears the value of the edge with the given name. It returns an error
  14588. // if that edge is not defined in the schema.
  14589. func (m *LabelMutation) ClearEdge(name string) error {
  14590. switch name {
  14591. }
  14592. return fmt.Errorf("unknown Label unique edge %s", name)
  14593. }
  14594. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14595. // It returns an error if the edge is not defined in the schema.
  14596. func (m *LabelMutation) ResetEdge(name string) error {
  14597. switch name {
  14598. case label.EdgeLabelRelationships:
  14599. m.ResetLabelRelationships()
  14600. return nil
  14601. }
  14602. return fmt.Errorf("unknown Label edge %s", name)
  14603. }
  14604. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14605. type LabelRelationshipMutation struct {
  14606. config
  14607. op Op
  14608. typ string
  14609. id *uint64
  14610. created_at *time.Time
  14611. updated_at *time.Time
  14612. status *uint8
  14613. addstatus *int8
  14614. organization_id *uint64
  14615. addorganization_id *int64
  14616. clearedFields map[string]struct{}
  14617. contacts *uint64
  14618. clearedcontacts bool
  14619. labels *uint64
  14620. clearedlabels bool
  14621. done bool
  14622. oldValue func(context.Context) (*LabelRelationship, error)
  14623. predicates []predicate.LabelRelationship
  14624. }
  14625. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14626. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14627. type labelrelationshipOption func(*LabelRelationshipMutation)
  14628. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14629. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14630. m := &LabelRelationshipMutation{
  14631. config: c,
  14632. op: op,
  14633. typ: TypeLabelRelationship,
  14634. clearedFields: make(map[string]struct{}),
  14635. }
  14636. for _, opt := range opts {
  14637. opt(m)
  14638. }
  14639. return m
  14640. }
  14641. // withLabelRelationshipID sets the ID field of the mutation.
  14642. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14643. return func(m *LabelRelationshipMutation) {
  14644. var (
  14645. err error
  14646. once sync.Once
  14647. value *LabelRelationship
  14648. )
  14649. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14650. once.Do(func() {
  14651. if m.done {
  14652. err = errors.New("querying old values post mutation is not allowed")
  14653. } else {
  14654. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14655. }
  14656. })
  14657. return value, err
  14658. }
  14659. m.id = &id
  14660. }
  14661. }
  14662. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14663. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14664. return func(m *LabelRelationshipMutation) {
  14665. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14666. return node, nil
  14667. }
  14668. m.id = &node.ID
  14669. }
  14670. }
  14671. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14672. // executed in a transaction (ent.Tx), a transactional client is returned.
  14673. func (m LabelRelationshipMutation) Client() *Client {
  14674. client := &Client{config: m.config}
  14675. client.init()
  14676. return client
  14677. }
  14678. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14679. // it returns an error otherwise.
  14680. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14681. if _, ok := m.driver.(*txDriver); !ok {
  14682. return nil, errors.New("ent: mutation is not running in a transaction")
  14683. }
  14684. tx := &Tx{config: m.config}
  14685. tx.init()
  14686. return tx, nil
  14687. }
  14688. // SetID sets the value of the id field. Note that this
  14689. // operation is only accepted on creation of LabelRelationship entities.
  14690. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14691. m.id = &id
  14692. }
  14693. // ID returns the ID value in the mutation. Note that the ID is only available
  14694. // if it was provided to the builder or after it was returned from the database.
  14695. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14696. if m.id == nil {
  14697. return
  14698. }
  14699. return *m.id, true
  14700. }
  14701. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14702. // That means, if the mutation is applied within a transaction with an isolation level such
  14703. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14704. // or updated by the mutation.
  14705. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14706. switch {
  14707. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14708. id, exists := m.ID()
  14709. if exists {
  14710. return []uint64{id}, nil
  14711. }
  14712. fallthrough
  14713. case m.op.Is(OpUpdate | OpDelete):
  14714. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14715. default:
  14716. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14717. }
  14718. }
  14719. // SetCreatedAt sets the "created_at" field.
  14720. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14721. m.created_at = &t
  14722. }
  14723. // CreatedAt returns the value of the "created_at" field in the mutation.
  14724. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14725. v := m.created_at
  14726. if v == nil {
  14727. return
  14728. }
  14729. return *v, true
  14730. }
  14731. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14732. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14734. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14735. if !m.op.Is(OpUpdateOne) {
  14736. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14737. }
  14738. if m.id == nil || m.oldValue == nil {
  14739. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14740. }
  14741. oldValue, err := m.oldValue(ctx)
  14742. if err != nil {
  14743. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14744. }
  14745. return oldValue.CreatedAt, nil
  14746. }
  14747. // ResetCreatedAt resets all changes to the "created_at" field.
  14748. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14749. m.created_at = nil
  14750. }
  14751. // SetUpdatedAt sets the "updated_at" field.
  14752. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14753. m.updated_at = &t
  14754. }
  14755. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14756. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14757. v := m.updated_at
  14758. if v == nil {
  14759. return
  14760. }
  14761. return *v, true
  14762. }
  14763. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14764. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14766. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14767. if !m.op.Is(OpUpdateOne) {
  14768. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14769. }
  14770. if m.id == nil || m.oldValue == nil {
  14771. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14772. }
  14773. oldValue, err := m.oldValue(ctx)
  14774. if err != nil {
  14775. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14776. }
  14777. return oldValue.UpdatedAt, nil
  14778. }
  14779. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14780. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14781. m.updated_at = nil
  14782. }
  14783. // SetStatus sets the "status" field.
  14784. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14785. m.status = &u
  14786. m.addstatus = nil
  14787. }
  14788. // Status returns the value of the "status" field in the mutation.
  14789. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14790. v := m.status
  14791. if v == nil {
  14792. return
  14793. }
  14794. return *v, true
  14795. }
  14796. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14797. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14799. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14800. if !m.op.Is(OpUpdateOne) {
  14801. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14802. }
  14803. if m.id == nil || m.oldValue == nil {
  14804. return v, errors.New("OldStatus requires an ID field in the mutation")
  14805. }
  14806. oldValue, err := m.oldValue(ctx)
  14807. if err != nil {
  14808. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14809. }
  14810. return oldValue.Status, nil
  14811. }
  14812. // AddStatus adds u to the "status" field.
  14813. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14814. if m.addstatus != nil {
  14815. *m.addstatus += u
  14816. } else {
  14817. m.addstatus = &u
  14818. }
  14819. }
  14820. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14821. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14822. v := m.addstatus
  14823. if v == nil {
  14824. return
  14825. }
  14826. return *v, true
  14827. }
  14828. // ClearStatus clears the value of the "status" field.
  14829. func (m *LabelRelationshipMutation) ClearStatus() {
  14830. m.status = nil
  14831. m.addstatus = nil
  14832. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14833. }
  14834. // StatusCleared returns if the "status" field was cleared in this mutation.
  14835. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14836. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14837. return ok
  14838. }
  14839. // ResetStatus resets all changes to the "status" field.
  14840. func (m *LabelRelationshipMutation) ResetStatus() {
  14841. m.status = nil
  14842. m.addstatus = nil
  14843. delete(m.clearedFields, labelrelationship.FieldStatus)
  14844. }
  14845. // SetLabelID sets the "label_id" field.
  14846. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14847. m.labels = &u
  14848. }
  14849. // LabelID returns the value of the "label_id" field in the mutation.
  14850. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14851. v := m.labels
  14852. if v == nil {
  14853. return
  14854. }
  14855. return *v, true
  14856. }
  14857. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14858. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14860. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14861. if !m.op.Is(OpUpdateOne) {
  14862. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14863. }
  14864. if m.id == nil || m.oldValue == nil {
  14865. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14866. }
  14867. oldValue, err := m.oldValue(ctx)
  14868. if err != nil {
  14869. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14870. }
  14871. return oldValue.LabelID, nil
  14872. }
  14873. // ResetLabelID resets all changes to the "label_id" field.
  14874. func (m *LabelRelationshipMutation) ResetLabelID() {
  14875. m.labels = nil
  14876. }
  14877. // SetContactID sets the "contact_id" field.
  14878. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14879. m.contacts = &u
  14880. }
  14881. // ContactID returns the value of the "contact_id" field in the mutation.
  14882. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14883. v := m.contacts
  14884. if v == nil {
  14885. return
  14886. }
  14887. return *v, true
  14888. }
  14889. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14890. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14892. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14893. if !m.op.Is(OpUpdateOne) {
  14894. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14895. }
  14896. if m.id == nil || m.oldValue == nil {
  14897. return v, errors.New("OldContactID requires an ID field in the mutation")
  14898. }
  14899. oldValue, err := m.oldValue(ctx)
  14900. if err != nil {
  14901. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14902. }
  14903. return oldValue.ContactID, nil
  14904. }
  14905. // ResetContactID resets all changes to the "contact_id" field.
  14906. func (m *LabelRelationshipMutation) ResetContactID() {
  14907. m.contacts = nil
  14908. }
  14909. // SetOrganizationID sets the "organization_id" field.
  14910. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14911. m.organization_id = &u
  14912. m.addorganization_id = nil
  14913. }
  14914. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14915. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14916. v := m.organization_id
  14917. if v == nil {
  14918. return
  14919. }
  14920. return *v, true
  14921. }
  14922. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14923. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14925. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14926. if !m.op.Is(OpUpdateOne) {
  14927. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14928. }
  14929. if m.id == nil || m.oldValue == nil {
  14930. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14931. }
  14932. oldValue, err := m.oldValue(ctx)
  14933. if err != nil {
  14934. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14935. }
  14936. return oldValue.OrganizationID, nil
  14937. }
  14938. // AddOrganizationID adds u to the "organization_id" field.
  14939. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14940. if m.addorganization_id != nil {
  14941. *m.addorganization_id += u
  14942. } else {
  14943. m.addorganization_id = &u
  14944. }
  14945. }
  14946. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14947. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14948. v := m.addorganization_id
  14949. if v == nil {
  14950. return
  14951. }
  14952. return *v, true
  14953. }
  14954. // ClearOrganizationID clears the value of the "organization_id" field.
  14955. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14956. m.organization_id = nil
  14957. m.addorganization_id = nil
  14958. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14959. }
  14960. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14961. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14962. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14963. return ok
  14964. }
  14965. // ResetOrganizationID resets all changes to the "organization_id" field.
  14966. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14967. m.organization_id = nil
  14968. m.addorganization_id = nil
  14969. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14970. }
  14971. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14972. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14973. m.contacts = &id
  14974. }
  14975. // ClearContacts clears the "contacts" edge to the Contact entity.
  14976. func (m *LabelRelationshipMutation) ClearContacts() {
  14977. m.clearedcontacts = true
  14978. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14979. }
  14980. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14981. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14982. return m.clearedcontacts
  14983. }
  14984. // ContactsID returns the "contacts" edge ID in the mutation.
  14985. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14986. if m.contacts != nil {
  14987. return *m.contacts, true
  14988. }
  14989. return
  14990. }
  14991. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14992. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14993. // ContactsID instead. It exists only for internal usage by the builders.
  14994. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14995. if id := m.contacts; id != nil {
  14996. ids = append(ids, *id)
  14997. }
  14998. return
  14999. }
  15000. // ResetContacts resets all changes to the "contacts" edge.
  15001. func (m *LabelRelationshipMutation) ResetContacts() {
  15002. m.contacts = nil
  15003. m.clearedcontacts = false
  15004. }
  15005. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15006. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15007. m.labels = &id
  15008. }
  15009. // ClearLabels clears the "labels" edge to the Label entity.
  15010. func (m *LabelRelationshipMutation) ClearLabels() {
  15011. m.clearedlabels = true
  15012. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15013. }
  15014. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15015. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15016. return m.clearedlabels
  15017. }
  15018. // LabelsID returns the "labels" edge ID in the mutation.
  15019. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15020. if m.labels != nil {
  15021. return *m.labels, true
  15022. }
  15023. return
  15024. }
  15025. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15026. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15027. // LabelsID instead. It exists only for internal usage by the builders.
  15028. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15029. if id := m.labels; id != nil {
  15030. ids = append(ids, *id)
  15031. }
  15032. return
  15033. }
  15034. // ResetLabels resets all changes to the "labels" edge.
  15035. func (m *LabelRelationshipMutation) ResetLabels() {
  15036. m.labels = nil
  15037. m.clearedlabels = false
  15038. }
  15039. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15040. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15041. m.predicates = append(m.predicates, ps...)
  15042. }
  15043. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15044. // users can use type-assertion to append predicates that do not depend on any generated package.
  15045. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15046. p := make([]predicate.LabelRelationship, len(ps))
  15047. for i := range ps {
  15048. p[i] = ps[i]
  15049. }
  15050. m.Where(p...)
  15051. }
  15052. // Op returns the operation name.
  15053. func (m *LabelRelationshipMutation) Op() Op {
  15054. return m.op
  15055. }
  15056. // SetOp allows setting the mutation operation.
  15057. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15058. m.op = op
  15059. }
  15060. // Type returns the node type of this mutation (LabelRelationship).
  15061. func (m *LabelRelationshipMutation) Type() string {
  15062. return m.typ
  15063. }
  15064. // Fields returns all fields that were changed during this mutation. Note that in
  15065. // order to get all numeric fields that were incremented/decremented, call
  15066. // AddedFields().
  15067. func (m *LabelRelationshipMutation) Fields() []string {
  15068. fields := make([]string, 0, 6)
  15069. if m.created_at != nil {
  15070. fields = append(fields, labelrelationship.FieldCreatedAt)
  15071. }
  15072. if m.updated_at != nil {
  15073. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15074. }
  15075. if m.status != nil {
  15076. fields = append(fields, labelrelationship.FieldStatus)
  15077. }
  15078. if m.labels != nil {
  15079. fields = append(fields, labelrelationship.FieldLabelID)
  15080. }
  15081. if m.contacts != nil {
  15082. fields = append(fields, labelrelationship.FieldContactID)
  15083. }
  15084. if m.organization_id != nil {
  15085. fields = append(fields, labelrelationship.FieldOrganizationID)
  15086. }
  15087. return fields
  15088. }
  15089. // Field returns the value of a field with the given name. The second boolean
  15090. // return value indicates that this field was not set, or was not defined in the
  15091. // schema.
  15092. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15093. switch name {
  15094. case labelrelationship.FieldCreatedAt:
  15095. return m.CreatedAt()
  15096. case labelrelationship.FieldUpdatedAt:
  15097. return m.UpdatedAt()
  15098. case labelrelationship.FieldStatus:
  15099. return m.Status()
  15100. case labelrelationship.FieldLabelID:
  15101. return m.LabelID()
  15102. case labelrelationship.FieldContactID:
  15103. return m.ContactID()
  15104. case labelrelationship.FieldOrganizationID:
  15105. return m.OrganizationID()
  15106. }
  15107. return nil, false
  15108. }
  15109. // OldField returns the old value of the field from the database. An error is
  15110. // returned if the mutation operation is not UpdateOne, or the query to the
  15111. // database failed.
  15112. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15113. switch name {
  15114. case labelrelationship.FieldCreatedAt:
  15115. return m.OldCreatedAt(ctx)
  15116. case labelrelationship.FieldUpdatedAt:
  15117. return m.OldUpdatedAt(ctx)
  15118. case labelrelationship.FieldStatus:
  15119. return m.OldStatus(ctx)
  15120. case labelrelationship.FieldLabelID:
  15121. return m.OldLabelID(ctx)
  15122. case labelrelationship.FieldContactID:
  15123. return m.OldContactID(ctx)
  15124. case labelrelationship.FieldOrganizationID:
  15125. return m.OldOrganizationID(ctx)
  15126. }
  15127. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15128. }
  15129. // SetField sets the value of a field with the given name. It returns an error if
  15130. // the field is not defined in the schema, or if the type mismatched the field
  15131. // type.
  15132. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15133. switch name {
  15134. case labelrelationship.FieldCreatedAt:
  15135. v, ok := value.(time.Time)
  15136. if !ok {
  15137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15138. }
  15139. m.SetCreatedAt(v)
  15140. return nil
  15141. case labelrelationship.FieldUpdatedAt:
  15142. v, ok := value.(time.Time)
  15143. if !ok {
  15144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15145. }
  15146. m.SetUpdatedAt(v)
  15147. return nil
  15148. case labelrelationship.FieldStatus:
  15149. v, ok := value.(uint8)
  15150. if !ok {
  15151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15152. }
  15153. m.SetStatus(v)
  15154. return nil
  15155. case labelrelationship.FieldLabelID:
  15156. v, ok := value.(uint64)
  15157. if !ok {
  15158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15159. }
  15160. m.SetLabelID(v)
  15161. return nil
  15162. case labelrelationship.FieldContactID:
  15163. v, ok := value.(uint64)
  15164. if !ok {
  15165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15166. }
  15167. m.SetContactID(v)
  15168. return nil
  15169. case labelrelationship.FieldOrganizationID:
  15170. v, ok := value.(uint64)
  15171. if !ok {
  15172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15173. }
  15174. m.SetOrganizationID(v)
  15175. return nil
  15176. }
  15177. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15178. }
  15179. // AddedFields returns all numeric fields that were incremented/decremented during
  15180. // this mutation.
  15181. func (m *LabelRelationshipMutation) AddedFields() []string {
  15182. var fields []string
  15183. if m.addstatus != nil {
  15184. fields = append(fields, labelrelationship.FieldStatus)
  15185. }
  15186. if m.addorganization_id != nil {
  15187. fields = append(fields, labelrelationship.FieldOrganizationID)
  15188. }
  15189. return fields
  15190. }
  15191. // AddedField returns the numeric value that was incremented/decremented on a field
  15192. // with the given name. The second boolean return value indicates that this field
  15193. // was not set, or was not defined in the schema.
  15194. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15195. switch name {
  15196. case labelrelationship.FieldStatus:
  15197. return m.AddedStatus()
  15198. case labelrelationship.FieldOrganizationID:
  15199. return m.AddedOrganizationID()
  15200. }
  15201. return nil, false
  15202. }
  15203. // AddField adds the value to the field with the given name. It returns an error if
  15204. // the field is not defined in the schema, or if the type mismatched the field
  15205. // type.
  15206. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15207. switch name {
  15208. case labelrelationship.FieldStatus:
  15209. v, ok := value.(int8)
  15210. if !ok {
  15211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15212. }
  15213. m.AddStatus(v)
  15214. return nil
  15215. case labelrelationship.FieldOrganizationID:
  15216. v, ok := value.(int64)
  15217. if !ok {
  15218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15219. }
  15220. m.AddOrganizationID(v)
  15221. return nil
  15222. }
  15223. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15224. }
  15225. // ClearedFields returns all nullable fields that were cleared during this
  15226. // mutation.
  15227. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15228. var fields []string
  15229. if m.FieldCleared(labelrelationship.FieldStatus) {
  15230. fields = append(fields, labelrelationship.FieldStatus)
  15231. }
  15232. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15233. fields = append(fields, labelrelationship.FieldOrganizationID)
  15234. }
  15235. return fields
  15236. }
  15237. // FieldCleared returns a boolean indicating if a field with the given name was
  15238. // cleared in this mutation.
  15239. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15240. _, ok := m.clearedFields[name]
  15241. return ok
  15242. }
  15243. // ClearField clears the value of the field with the given name. It returns an
  15244. // error if the field is not defined in the schema.
  15245. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15246. switch name {
  15247. case labelrelationship.FieldStatus:
  15248. m.ClearStatus()
  15249. return nil
  15250. case labelrelationship.FieldOrganizationID:
  15251. m.ClearOrganizationID()
  15252. return nil
  15253. }
  15254. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15255. }
  15256. // ResetField resets all changes in the mutation for the field with the given name.
  15257. // It returns an error if the field is not defined in the schema.
  15258. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15259. switch name {
  15260. case labelrelationship.FieldCreatedAt:
  15261. m.ResetCreatedAt()
  15262. return nil
  15263. case labelrelationship.FieldUpdatedAt:
  15264. m.ResetUpdatedAt()
  15265. return nil
  15266. case labelrelationship.FieldStatus:
  15267. m.ResetStatus()
  15268. return nil
  15269. case labelrelationship.FieldLabelID:
  15270. m.ResetLabelID()
  15271. return nil
  15272. case labelrelationship.FieldContactID:
  15273. m.ResetContactID()
  15274. return nil
  15275. case labelrelationship.FieldOrganizationID:
  15276. m.ResetOrganizationID()
  15277. return nil
  15278. }
  15279. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15280. }
  15281. // AddedEdges returns all edge names that were set/added in this mutation.
  15282. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15283. edges := make([]string, 0, 2)
  15284. if m.contacts != nil {
  15285. edges = append(edges, labelrelationship.EdgeContacts)
  15286. }
  15287. if m.labels != nil {
  15288. edges = append(edges, labelrelationship.EdgeLabels)
  15289. }
  15290. return edges
  15291. }
  15292. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15293. // name in this mutation.
  15294. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15295. switch name {
  15296. case labelrelationship.EdgeContacts:
  15297. if id := m.contacts; id != nil {
  15298. return []ent.Value{*id}
  15299. }
  15300. case labelrelationship.EdgeLabels:
  15301. if id := m.labels; id != nil {
  15302. return []ent.Value{*id}
  15303. }
  15304. }
  15305. return nil
  15306. }
  15307. // RemovedEdges returns all edge names that were removed in this mutation.
  15308. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15309. edges := make([]string, 0, 2)
  15310. return edges
  15311. }
  15312. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15313. // the given name in this mutation.
  15314. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15315. return nil
  15316. }
  15317. // ClearedEdges returns all edge names that were cleared in this mutation.
  15318. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15319. edges := make([]string, 0, 2)
  15320. if m.clearedcontacts {
  15321. edges = append(edges, labelrelationship.EdgeContacts)
  15322. }
  15323. if m.clearedlabels {
  15324. edges = append(edges, labelrelationship.EdgeLabels)
  15325. }
  15326. return edges
  15327. }
  15328. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15329. // was cleared in this mutation.
  15330. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15331. switch name {
  15332. case labelrelationship.EdgeContacts:
  15333. return m.clearedcontacts
  15334. case labelrelationship.EdgeLabels:
  15335. return m.clearedlabels
  15336. }
  15337. return false
  15338. }
  15339. // ClearEdge clears the value of the edge with the given name. It returns an error
  15340. // if that edge is not defined in the schema.
  15341. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15342. switch name {
  15343. case labelrelationship.EdgeContacts:
  15344. m.ClearContacts()
  15345. return nil
  15346. case labelrelationship.EdgeLabels:
  15347. m.ClearLabels()
  15348. return nil
  15349. }
  15350. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15351. }
  15352. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15353. // It returns an error if the edge is not defined in the schema.
  15354. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15355. switch name {
  15356. case labelrelationship.EdgeContacts:
  15357. m.ResetContacts()
  15358. return nil
  15359. case labelrelationship.EdgeLabels:
  15360. m.ResetLabels()
  15361. return nil
  15362. }
  15363. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15364. }
  15365. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15366. type LabelTaggingMutation struct {
  15367. config
  15368. op Op
  15369. typ string
  15370. id *uint64
  15371. created_at *time.Time
  15372. updated_at *time.Time
  15373. status *uint8
  15374. addstatus *int8
  15375. deleted_at *time.Time
  15376. organization_id *uint64
  15377. addorganization_id *int64
  15378. _type *int
  15379. add_type *int
  15380. conditions *string
  15381. action_label_add *[]uint64
  15382. appendaction_label_add []uint64
  15383. action_label_del *[]uint64
  15384. appendaction_label_del []uint64
  15385. clearedFields map[string]struct{}
  15386. done bool
  15387. oldValue func(context.Context) (*LabelTagging, error)
  15388. predicates []predicate.LabelTagging
  15389. }
  15390. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15391. // labeltaggingOption allows management of the mutation configuration using functional options.
  15392. type labeltaggingOption func(*LabelTaggingMutation)
  15393. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15394. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15395. m := &LabelTaggingMutation{
  15396. config: c,
  15397. op: op,
  15398. typ: TypeLabelTagging,
  15399. clearedFields: make(map[string]struct{}),
  15400. }
  15401. for _, opt := range opts {
  15402. opt(m)
  15403. }
  15404. return m
  15405. }
  15406. // withLabelTaggingID sets the ID field of the mutation.
  15407. func withLabelTaggingID(id uint64) labeltaggingOption {
  15408. return func(m *LabelTaggingMutation) {
  15409. var (
  15410. err error
  15411. once sync.Once
  15412. value *LabelTagging
  15413. )
  15414. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15415. once.Do(func() {
  15416. if m.done {
  15417. err = errors.New("querying old values post mutation is not allowed")
  15418. } else {
  15419. value, err = m.Client().LabelTagging.Get(ctx, id)
  15420. }
  15421. })
  15422. return value, err
  15423. }
  15424. m.id = &id
  15425. }
  15426. }
  15427. // withLabelTagging sets the old LabelTagging of the mutation.
  15428. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15429. return func(m *LabelTaggingMutation) {
  15430. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15431. return node, nil
  15432. }
  15433. m.id = &node.ID
  15434. }
  15435. }
  15436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15437. // executed in a transaction (ent.Tx), a transactional client is returned.
  15438. func (m LabelTaggingMutation) Client() *Client {
  15439. client := &Client{config: m.config}
  15440. client.init()
  15441. return client
  15442. }
  15443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15444. // it returns an error otherwise.
  15445. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15446. if _, ok := m.driver.(*txDriver); !ok {
  15447. return nil, errors.New("ent: mutation is not running in a transaction")
  15448. }
  15449. tx := &Tx{config: m.config}
  15450. tx.init()
  15451. return tx, nil
  15452. }
  15453. // SetID sets the value of the id field. Note that this
  15454. // operation is only accepted on creation of LabelTagging entities.
  15455. func (m *LabelTaggingMutation) SetID(id uint64) {
  15456. m.id = &id
  15457. }
  15458. // ID returns the ID value in the mutation. Note that the ID is only available
  15459. // if it was provided to the builder or after it was returned from the database.
  15460. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15461. if m.id == nil {
  15462. return
  15463. }
  15464. return *m.id, true
  15465. }
  15466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15467. // That means, if the mutation is applied within a transaction with an isolation level such
  15468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15469. // or updated by the mutation.
  15470. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15471. switch {
  15472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15473. id, exists := m.ID()
  15474. if exists {
  15475. return []uint64{id}, nil
  15476. }
  15477. fallthrough
  15478. case m.op.Is(OpUpdate | OpDelete):
  15479. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15480. default:
  15481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15482. }
  15483. }
  15484. // SetCreatedAt sets the "created_at" field.
  15485. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15486. m.created_at = &t
  15487. }
  15488. // CreatedAt returns the value of the "created_at" field in the mutation.
  15489. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15490. v := m.created_at
  15491. if v == nil {
  15492. return
  15493. }
  15494. return *v, true
  15495. }
  15496. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15497. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15499. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15500. if !m.op.Is(OpUpdateOne) {
  15501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15502. }
  15503. if m.id == nil || m.oldValue == nil {
  15504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15505. }
  15506. oldValue, err := m.oldValue(ctx)
  15507. if err != nil {
  15508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15509. }
  15510. return oldValue.CreatedAt, nil
  15511. }
  15512. // ResetCreatedAt resets all changes to the "created_at" field.
  15513. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15514. m.created_at = nil
  15515. }
  15516. // SetUpdatedAt sets the "updated_at" field.
  15517. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15518. m.updated_at = &t
  15519. }
  15520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15521. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15522. v := m.updated_at
  15523. if v == nil {
  15524. return
  15525. }
  15526. return *v, true
  15527. }
  15528. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15529. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15531. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15532. if !m.op.Is(OpUpdateOne) {
  15533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15534. }
  15535. if m.id == nil || m.oldValue == nil {
  15536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15537. }
  15538. oldValue, err := m.oldValue(ctx)
  15539. if err != nil {
  15540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15541. }
  15542. return oldValue.UpdatedAt, nil
  15543. }
  15544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15545. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15546. m.updated_at = nil
  15547. }
  15548. // SetStatus sets the "status" field.
  15549. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15550. m.status = &u
  15551. m.addstatus = nil
  15552. }
  15553. // Status returns the value of the "status" field in the mutation.
  15554. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15555. v := m.status
  15556. if v == nil {
  15557. return
  15558. }
  15559. return *v, true
  15560. }
  15561. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15562. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15564. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15565. if !m.op.Is(OpUpdateOne) {
  15566. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15567. }
  15568. if m.id == nil || m.oldValue == nil {
  15569. return v, errors.New("OldStatus requires an ID field in the mutation")
  15570. }
  15571. oldValue, err := m.oldValue(ctx)
  15572. if err != nil {
  15573. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15574. }
  15575. return oldValue.Status, nil
  15576. }
  15577. // AddStatus adds u to the "status" field.
  15578. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15579. if m.addstatus != nil {
  15580. *m.addstatus += u
  15581. } else {
  15582. m.addstatus = &u
  15583. }
  15584. }
  15585. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15586. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15587. v := m.addstatus
  15588. if v == nil {
  15589. return
  15590. }
  15591. return *v, true
  15592. }
  15593. // ClearStatus clears the value of the "status" field.
  15594. func (m *LabelTaggingMutation) ClearStatus() {
  15595. m.status = nil
  15596. m.addstatus = nil
  15597. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15598. }
  15599. // StatusCleared returns if the "status" field was cleared in this mutation.
  15600. func (m *LabelTaggingMutation) StatusCleared() bool {
  15601. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15602. return ok
  15603. }
  15604. // ResetStatus resets all changes to the "status" field.
  15605. func (m *LabelTaggingMutation) ResetStatus() {
  15606. m.status = nil
  15607. m.addstatus = nil
  15608. delete(m.clearedFields, labeltagging.FieldStatus)
  15609. }
  15610. // SetDeletedAt sets the "deleted_at" field.
  15611. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15612. m.deleted_at = &t
  15613. }
  15614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15615. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15616. v := m.deleted_at
  15617. if v == nil {
  15618. return
  15619. }
  15620. return *v, true
  15621. }
  15622. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15623. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15625. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15626. if !m.op.Is(OpUpdateOne) {
  15627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15628. }
  15629. if m.id == nil || m.oldValue == nil {
  15630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15631. }
  15632. oldValue, err := m.oldValue(ctx)
  15633. if err != nil {
  15634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15635. }
  15636. return oldValue.DeletedAt, nil
  15637. }
  15638. // ClearDeletedAt clears the value of the "deleted_at" field.
  15639. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15640. m.deleted_at = nil
  15641. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15642. }
  15643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15644. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15645. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15646. return ok
  15647. }
  15648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15649. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15650. m.deleted_at = nil
  15651. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15652. }
  15653. // SetOrganizationID sets the "organization_id" field.
  15654. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15655. m.organization_id = &u
  15656. m.addorganization_id = nil
  15657. }
  15658. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15659. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15660. v := m.organization_id
  15661. if v == nil {
  15662. return
  15663. }
  15664. return *v, true
  15665. }
  15666. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15667. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15669. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15670. if !m.op.Is(OpUpdateOne) {
  15671. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15672. }
  15673. if m.id == nil || m.oldValue == nil {
  15674. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15675. }
  15676. oldValue, err := m.oldValue(ctx)
  15677. if err != nil {
  15678. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15679. }
  15680. return oldValue.OrganizationID, nil
  15681. }
  15682. // AddOrganizationID adds u to the "organization_id" field.
  15683. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15684. if m.addorganization_id != nil {
  15685. *m.addorganization_id += u
  15686. } else {
  15687. m.addorganization_id = &u
  15688. }
  15689. }
  15690. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15691. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15692. v := m.addorganization_id
  15693. if v == nil {
  15694. return
  15695. }
  15696. return *v, true
  15697. }
  15698. // ResetOrganizationID resets all changes to the "organization_id" field.
  15699. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15700. m.organization_id = nil
  15701. m.addorganization_id = nil
  15702. }
  15703. // SetType sets the "type" field.
  15704. func (m *LabelTaggingMutation) SetType(i int) {
  15705. m._type = &i
  15706. m.add_type = nil
  15707. }
  15708. // GetType returns the value of the "type" field in the mutation.
  15709. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15710. v := m._type
  15711. if v == nil {
  15712. return
  15713. }
  15714. return *v, true
  15715. }
  15716. // OldType returns the old "type" field's value of the LabelTagging entity.
  15717. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15719. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15720. if !m.op.Is(OpUpdateOne) {
  15721. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15722. }
  15723. if m.id == nil || m.oldValue == nil {
  15724. return v, errors.New("OldType requires an ID field in the mutation")
  15725. }
  15726. oldValue, err := m.oldValue(ctx)
  15727. if err != nil {
  15728. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15729. }
  15730. return oldValue.Type, nil
  15731. }
  15732. // AddType adds i to the "type" field.
  15733. func (m *LabelTaggingMutation) AddType(i int) {
  15734. if m.add_type != nil {
  15735. *m.add_type += i
  15736. } else {
  15737. m.add_type = &i
  15738. }
  15739. }
  15740. // AddedType returns the value that was added to the "type" field in this mutation.
  15741. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15742. v := m.add_type
  15743. if v == nil {
  15744. return
  15745. }
  15746. return *v, true
  15747. }
  15748. // ResetType resets all changes to the "type" field.
  15749. func (m *LabelTaggingMutation) ResetType() {
  15750. m._type = nil
  15751. m.add_type = nil
  15752. }
  15753. // SetConditions sets the "conditions" field.
  15754. func (m *LabelTaggingMutation) SetConditions(s string) {
  15755. m.conditions = &s
  15756. }
  15757. // Conditions returns the value of the "conditions" field in the mutation.
  15758. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15759. v := m.conditions
  15760. if v == nil {
  15761. return
  15762. }
  15763. return *v, true
  15764. }
  15765. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15766. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15768. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15769. if !m.op.Is(OpUpdateOne) {
  15770. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15771. }
  15772. if m.id == nil || m.oldValue == nil {
  15773. return v, errors.New("OldConditions requires an ID field in the mutation")
  15774. }
  15775. oldValue, err := m.oldValue(ctx)
  15776. if err != nil {
  15777. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15778. }
  15779. return oldValue.Conditions, nil
  15780. }
  15781. // ResetConditions resets all changes to the "conditions" field.
  15782. func (m *LabelTaggingMutation) ResetConditions() {
  15783. m.conditions = nil
  15784. }
  15785. // SetActionLabelAdd sets the "action_label_add" field.
  15786. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15787. m.action_label_add = &u
  15788. m.appendaction_label_add = nil
  15789. }
  15790. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15791. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15792. v := m.action_label_add
  15793. if v == nil {
  15794. return
  15795. }
  15796. return *v, true
  15797. }
  15798. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15799. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15801. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15802. if !m.op.Is(OpUpdateOne) {
  15803. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15804. }
  15805. if m.id == nil || m.oldValue == nil {
  15806. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15807. }
  15808. oldValue, err := m.oldValue(ctx)
  15809. if err != nil {
  15810. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15811. }
  15812. return oldValue.ActionLabelAdd, nil
  15813. }
  15814. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15815. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15816. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15817. }
  15818. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15819. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15820. if len(m.appendaction_label_add) == 0 {
  15821. return nil, false
  15822. }
  15823. return m.appendaction_label_add, true
  15824. }
  15825. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15826. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15827. m.action_label_add = nil
  15828. m.appendaction_label_add = nil
  15829. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15830. }
  15831. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15832. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15833. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15834. return ok
  15835. }
  15836. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15837. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15838. m.action_label_add = nil
  15839. m.appendaction_label_add = nil
  15840. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15841. }
  15842. // SetActionLabelDel sets the "action_label_del" field.
  15843. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15844. m.action_label_del = &u
  15845. m.appendaction_label_del = nil
  15846. }
  15847. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15848. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15849. v := m.action_label_del
  15850. if v == nil {
  15851. return
  15852. }
  15853. return *v, true
  15854. }
  15855. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15856. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15858. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15859. if !m.op.Is(OpUpdateOne) {
  15860. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15861. }
  15862. if m.id == nil || m.oldValue == nil {
  15863. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15864. }
  15865. oldValue, err := m.oldValue(ctx)
  15866. if err != nil {
  15867. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15868. }
  15869. return oldValue.ActionLabelDel, nil
  15870. }
  15871. // AppendActionLabelDel adds u to the "action_label_del" field.
  15872. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15873. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15874. }
  15875. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15876. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15877. if len(m.appendaction_label_del) == 0 {
  15878. return nil, false
  15879. }
  15880. return m.appendaction_label_del, true
  15881. }
  15882. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15883. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15884. m.action_label_del = nil
  15885. m.appendaction_label_del = nil
  15886. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15887. }
  15888. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15889. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15890. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15891. return ok
  15892. }
  15893. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15894. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15895. m.action_label_del = nil
  15896. m.appendaction_label_del = nil
  15897. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15898. }
  15899. // Where appends a list predicates to the LabelTaggingMutation builder.
  15900. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15901. m.predicates = append(m.predicates, ps...)
  15902. }
  15903. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15904. // users can use type-assertion to append predicates that do not depend on any generated package.
  15905. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15906. p := make([]predicate.LabelTagging, len(ps))
  15907. for i := range ps {
  15908. p[i] = ps[i]
  15909. }
  15910. m.Where(p...)
  15911. }
  15912. // Op returns the operation name.
  15913. func (m *LabelTaggingMutation) Op() Op {
  15914. return m.op
  15915. }
  15916. // SetOp allows setting the mutation operation.
  15917. func (m *LabelTaggingMutation) SetOp(op Op) {
  15918. m.op = op
  15919. }
  15920. // Type returns the node type of this mutation (LabelTagging).
  15921. func (m *LabelTaggingMutation) Type() string {
  15922. return m.typ
  15923. }
  15924. // Fields returns all fields that were changed during this mutation. Note that in
  15925. // order to get all numeric fields that were incremented/decremented, call
  15926. // AddedFields().
  15927. func (m *LabelTaggingMutation) Fields() []string {
  15928. fields := make([]string, 0, 9)
  15929. if m.created_at != nil {
  15930. fields = append(fields, labeltagging.FieldCreatedAt)
  15931. }
  15932. if m.updated_at != nil {
  15933. fields = append(fields, labeltagging.FieldUpdatedAt)
  15934. }
  15935. if m.status != nil {
  15936. fields = append(fields, labeltagging.FieldStatus)
  15937. }
  15938. if m.deleted_at != nil {
  15939. fields = append(fields, labeltagging.FieldDeletedAt)
  15940. }
  15941. if m.organization_id != nil {
  15942. fields = append(fields, labeltagging.FieldOrganizationID)
  15943. }
  15944. if m._type != nil {
  15945. fields = append(fields, labeltagging.FieldType)
  15946. }
  15947. if m.conditions != nil {
  15948. fields = append(fields, labeltagging.FieldConditions)
  15949. }
  15950. if m.action_label_add != nil {
  15951. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15952. }
  15953. if m.action_label_del != nil {
  15954. fields = append(fields, labeltagging.FieldActionLabelDel)
  15955. }
  15956. return fields
  15957. }
  15958. // Field returns the value of a field with the given name. The second boolean
  15959. // return value indicates that this field was not set, or was not defined in the
  15960. // schema.
  15961. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15962. switch name {
  15963. case labeltagging.FieldCreatedAt:
  15964. return m.CreatedAt()
  15965. case labeltagging.FieldUpdatedAt:
  15966. return m.UpdatedAt()
  15967. case labeltagging.FieldStatus:
  15968. return m.Status()
  15969. case labeltagging.FieldDeletedAt:
  15970. return m.DeletedAt()
  15971. case labeltagging.FieldOrganizationID:
  15972. return m.OrganizationID()
  15973. case labeltagging.FieldType:
  15974. return m.GetType()
  15975. case labeltagging.FieldConditions:
  15976. return m.Conditions()
  15977. case labeltagging.FieldActionLabelAdd:
  15978. return m.ActionLabelAdd()
  15979. case labeltagging.FieldActionLabelDel:
  15980. return m.ActionLabelDel()
  15981. }
  15982. return nil, false
  15983. }
  15984. // OldField returns the old value of the field from the database. An error is
  15985. // returned if the mutation operation is not UpdateOne, or the query to the
  15986. // database failed.
  15987. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15988. switch name {
  15989. case labeltagging.FieldCreatedAt:
  15990. return m.OldCreatedAt(ctx)
  15991. case labeltagging.FieldUpdatedAt:
  15992. return m.OldUpdatedAt(ctx)
  15993. case labeltagging.FieldStatus:
  15994. return m.OldStatus(ctx)
  15995. case labeltagging.FieldDeletedAt:
  15996. return m.OldDeletedAt(ctx)
  15997. case labeltagging.FieldOrganizationID:
  15998. return m.OldOrganizationID(ctx)
  15999. case labeltagging.FieldType:
  16000. return m.OldType(ctx)
  16001. case labeltagging.FieldConditions:
  16002. return m.OldConditions(ctx)
  16003. case labeltagging.FieldActionLabelAdd:
  16004. return m.OldActionLabelAdd(ctx)
  16005. case labeltagging.FieldActionLabelDel:
  16006. return m.OldActionLabelDel(ctx)
  16007. }
  16008. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16009. }
  16010. // SetField sets the value of a field with the given name. It returns an error if
  16011. // the field is not defined in the schema, or if the type mismatched the field
  16012. // type.
  16013. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16014. switch name {
  16015. case labeltagging.FieldCreatedAt:
  16016. v, ok := value.(time.Time)
  16017. if !ok {
  16018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16019. }
  16020. m.SetCreatedAt(v)
  16021. return nil
  16022. case labeltagging.FieldUpdatedAt:
  16023. v, ok := value.(time.Time)
  16024. if !ok {
  16025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16026. }
  16027. m.SetUpdatedAt(v)
  16028. return nil
  16029. case labeltagging.FieldStatus:
  16030. v, ok := value.(uint8)
  16031. if !ok {
  16032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16033. }
  16034. m.SetStatus(v)
  16035. return nil
  16036. case labeltagging.FieldDeletedAt:
  16037. v, ok := value.(time.Time)
  16038. if !ok {
  16039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16040. }
  16041. m.SetDeletedAt(v)
  16042. return nil
  16043. case labeltagging.FieldOrganizationID:
  16044. v, ok := value.(uint64)
  16045. if !ok {
  16046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16047. }
  16048. m.SetOrganizationID(v)
  16049. return nil
  16050. case labeltagging.FieldType:
  16051. v, ok := value.(int)
  16052. if !ok {
  16053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16054. }
  16055. m.SetType(v)
  16056. return nil
  16057. case labeltagging.FieldConditions:
  16058. v, ok := value.(string)
  16059. if !ok {
  16060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16061. }
  16062. m.SetConditions(v)
  16063. return nil
  16064. case labeltagging.FieldActionLabelAdd:
  16065. v, ok := value.([]uint64)
  16066. if !ok {
  16067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16068. }
  16069. m.SetActionLabelAdd(v)
  16070. return nil
  16071. case labeltagging.FieldActionLabelDel:
  16072. v, ok := value.([]uint64)
  16073. if !ok {
  16074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16075. }
  16076. m.SetActionLabelDel(v)
  16077. return nil
  16078. }
  16079. return fmt.Errorf("unknown LabelTagging field %s", name)
  16080. }
  16081. // AddedFields returns all numeric fields that were incremented/decremented during
  16082. // this mutation.
  16083. func (m *LabelTaggingMutation) AddedFields() []string {
  16084. var fields []string
  16085. if m.addstatus != nil {
  16086. fields = append(fields, labeltagging.FieldStatus)
  16087. }
  16088. if m.addorganization_id != nil {
  16089. fields = append(fields, labeltagging.FieldOrganizationID)
  16090. }
  16091. if m.add_type != nil {
  16092. fields = append(fields, labeltagging.FieldType)
  16093. }
  16094. return fields
  16095. }
  16096. // AddedField returns the numeric value that was incremented/decremented on a field
  16097. // with the given name. The second boolean return value indicates that this field
  16098. // was not set, or was not defined in the schema.
  16099. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16100. switch name {
  16101. case labeltagging.FieldStatus:
  16102. return m.AddedStatus()
  16103. case labeltagging.FieldOrganizationID:
  16104. return m.AddedOrganizationID()
  16105. case labeltagging.FieldType:
  16106. return m.AddedType()
  16107. }
  16108. return nil, false
  16109. }
  16110. // AddField adds the value to the field with the given name. It returns an error if
  16111. // the field is not defined in the schema, or if the type mismatched the field
  16112. // type.
  16113. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16114. switch name {
  16115. case labeltagging.FieldStatus:
  16116. v, ok := value.(int8)
  16117. if !ok {
  16118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16119. }
  16120. m.AddStatus(v)
  16121. return nil
  16122. case labeltagging.FieldOrganizationID:
  16123. v, ok := value.(int64)
  16124. if !ok {
  16125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16126. }
  16127. m.AddOrganizationID(v)
  16128. return nil
  16129. case labeltagging.FieldType:
  16130. v, ok := value.(int)
  16131. if !ok {
  16132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16133. }
  16134. m.AddType(v)
  16135. return nil
  16136. }
  16137. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16138. }
  16139. // ClearedFields returns all nullable fields that were cleared during this
  16140. // mutation.
  16141. func (m *LabelTaggingMutation) ClearedFields() []string {
  16142. var fields []string
  16143. if m.FieldCleared(labeltagging.FieldStatus) {
  16144. fields = append(fields, labeltagging.FieldStatus)
  16145. }
  16146. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16147. fields = append(fields, labeltagging.FieldDeletedAt)
  16148. }
  16149. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16150. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16151. }
  16152. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16153. fields = append(fields, labeltagging.FieldActionLabelDel)
  16154. }
  16155. return fields
  16156. }
  16157. // FieldCleared returns a boolean indicating if a field with the given name was
  16158. // cleared in this mutation.
  16159. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16160. _, ok := m.clearedFields[name]
  16161. return ok
  16162. }
  16163. // ClearField clears the value of the field with the given name. It returns an
  16164. // error if the field is not defined in the schema.
  16165. func (m *LabelTaggingMutation) ClearField(name string) error {
  16166. switch name {
  16167. case labeltagging.FieldStatus:
  16168. m.ClearStatus()
  16169. return nil
  16170. case labeltagging.FieldDeletedAt:
  16171. m.ClearDeletedAt()
  16172. return nil
  16173. case labeltagging.FieldActionLabelAdd:
  16174. m.ClearActionLabelAdd()
  16175. return nil
  16176. case labeltagging.FieldActionLabelDel:
  16177. m.ClearActionLabelDel()
  16178. return nil
  16179. }
  16180. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16181. }
  16182. // ResetField resets all changes in the mutation for the field with the given name.
  16183. // It returns an error if the field is not defined in the schema.
  16184. func (m *LabelTaggingMutation) ResetField(name string) error {
  16185. switch name {
  16186. case labeltagging.FieldCreatedAt:
  16187. m.ResetCreatedAt()
  16188. return nil
  16189. case labeltagging.FieldUpdatedAt:
  16190. m.ResetUpdatedAt()
  16191. return nil
  16192. case labeltagging.FieldStatus:
  16193. m.ResetStatus()
  16194. return nil
  16195. case labeltagging.FieldDeletedAt:
  16196. m.ResetDeletedAt()
  16197. return nil
  16198. case labeltagging.FieldOrganizationID:
  16199. m.ResetOrganizationID()
  16200. return nil
  16201. case labeltagging.FieldType:
  16202. m.ResetType()
  16203. return nil
  16204. case labeltagging.FieldConditions:
  16205. m.ResetConditions()
  16206. return nil
  16207. case labeltagging.FieldActionLabelAdd:
  16208. m.ResetActionLabelAdd()
  16209. return nil
  16210. case labeltagging.FieldActionLabelDel:
  16211. m.ResetActionLabelDel()
  16212. return nil
  16213. }
  16214. return fmt.Errorf("unknown LabelTagging field %s", name)
  16215. }
  16216. // AddedEdges returns all edge names that were set/added in this mutation.
  16217. func (m *LabelTaggingMutation) AddedEdges() []string {
  16218. edges := make([]string, 0, 0)
  16219. return edges
  16220. }
  16221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16222. // name in this mutation.
  16223. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16224. return nil
  16225. }
  16226. // RemovedEdges returns all edge names that were removed in this mutation.
  16227. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16228. edges := make([]string, 0, 0)
  16229. return edges
  16230. }
  16231. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16232. // the given name in this mutation.
  16233. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16234. return nil
  16235. }
  16236. // ClearedEdges returns all edge names that were cleared in this mutation.
  16237. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16238. edges := make([]string, 0, 0)
  16239. return edges
  16240. }
  16241. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16242. // was cleared in this mutation.
  16243. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16244. return false
  16245. }
  16246. // ClearEdge clears the value of the edge with the given name. It returns an error
  16247. // if that edge is not defined in the schema.
  16248. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16249. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16250. }
  16251. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16252. // It returns an error if the edge is not defined in the schema.
  16253. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16254. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16255. }
  16256. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16257. type MessageMutation struct {
  16258. config
  16259. op Op
  16260. typ string
  16261. id *int
  16262. wx_wxid *string
  16263. wxid *string
  16264. content *string
  16265. clearedFields map[string]struct{}
  16266. done bool
  16267. oldValue func(context.Context) (*Message, error)
  16268. predicates []predicate.Message
  16269. }
  16270. var _ ent.Mutation = (*MessageMutation)(nil)
  16271. // messageOption allows management of the mutation configuration using functional options.
  16272. type messageOption func(*MessageMutation)
  16273. // newMessageMutation creates new mutation for the Message entity.
  16274. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16275. m := &MessageMutation{
  16276. config: c,
  16277. op: op,
  16278. typ: TypeMessage,
  16279. clearedFields: make(map[string]struct{}),
  16280. }
  16281. for _, opt := range opts {
  16282. opt(m)
  16283. }
  16284. return m
  16285. }
  16286. // withMessageID sets the ID field of the mutation.
  16287. func withMessageID(id int) messageOption {
  16288. return func(m *MessageMutation) {
  16289. var (
  16290. err error
  16291. once sync.Once
  16292. value *Message
  16293. )
  16294. m.oldValue = func(ctx context.Context) (*Message, error) {
  16295. once.Do(func() {
  16296. if m.done {
  16297. err = errors.New("querying old values post mutation is not allowed")
  16298. } else {
  16299. value, err = m.Client().Message.Get(ctx, id)
  16300. }
  16301. })
  16302. return value, err
  16303. }
  16304. m.id = &id
  16305. }
  16306. }
  16307. // withMessage sets the old Message of the mutation.
  16308. func withMessage(node *Message) messageOption {
  16309. return func(m *MessageMutation) {
  16310. m.oldValue = func(context.Context) (*Message, error) {
  16311. return node, nil
  16312. }
  16313. m.id = &node.ID
  16314. }
  16315. }
  16316. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16317. // executed in a transaction (ent.Tx), a transactional client is returned.
  16318. func (m MessageMutation) Client() *Client {
  16319. client := &Client{config: m.config}
  16320. client.init()
  16321. return client
  16322. }
  16323. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16324. // it returns an error otherwise.
  16325. func (m MessageMutation) Tx() (*Tx, error) {
  16326. if _, ok := m.driver.(*txDriver); !ok {
  16327. return nil, errors.New("ent: mutation is not running in a transaction")
  16328. }
  16329. tx := &Tx{config: m.config}
  16330. tx.init()
  16331. return tx, nil
  16332. }
  16333. // ID returns the ID value in the mutation. Note that the ID is only available
  16334. // if it was provided to the builder or after it was returned from the database.
  16335. func (m *MessageMutation) ID() (id int, exists bool) {
  16336. if m.id == nil {
  16337. return
  16338. }
  16339. return *m.id, true
  16340. }
  16341. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16342. // That means, if the mutation is applied within a transaction with an isolation level such
  16343. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16344. // or updated by the mutation.
  16345. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16346. switch {
  16347. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16348. id, exists := m.ID()
  16349. if exists {
  16350. return []int{id}, nil
  16351. }
  16352. fallthrough
  16353. case m.op.Is(OpUpdate | OpDelete):
  16354. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16355. default:
  16356. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16357. }
  16358. }
  16359. // SetWxWxid sets the "wx_wxid" field.
  16360. func (m *MessageMutation) SetWxWxid(s string) {
  16361. m.wx_wxid = &s
  16362. }
  16363. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16364. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16365. v := m.wx_wxid
  16366. if v == nil {
  16367. return
  16368. }
  16369. return *v, true
  16370. }
  16371. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16372. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16374. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16375. if !m.op.Is(OpUpdateOne) {
  16376. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16377. }
  16378. if m.id == nil || m.oldValue == nil {
  16379. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16380. }
  16381. oldValue, err := m.oldValue(ctx)
  16382. if err != nil {
  16383. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16384. }
  16385. return oldValue.WxWxid, nil
  16386. }
  16387. // ClearWxWxid clears the value of the "wx_wxid" field.
  16388. func (m *MessageMutation) ClearWxWxid() {
  16389. m.wx_wxid = nil
  16390. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16391. }
  16392. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16393. func (m *MessageMutation) WxWxidCleared() bool {
  16394. _, ok := m.clearedFields[message.FieldWxWxid]
  16395. return ok
  16396. }
  16397. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16398. func (m *MessageMutation) ResetWxWxid() {
  16399. m.wx_wxid = nil
  16400. delete(m.clearedFields, message.FieldWxWxid)
  16401. }
  16402. // SetWxid sets the "wxid" field.
  16403. func (m *MessageMutation) SetWxid(s string) {
  16404. m.wxid = &s
  16405. }
  16406. // Wxid returns the value of the "wxid" field in the mutation.
  16407. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16408. v := m.wxid
  16409. if v == nil {
  16410. return
  16411. }
  16412. return *v, true
  16413. }
  16414. // OldWxid returns the old "wxid" field's value of the Message entity.
  16415. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16417. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16418. if !m.op.Is(OpUpdateOne) {
  16419. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16420. }
  16421. if m.id == nil || m.oldValue == nil {
  16422. return v, errors.New("OldWxid requires an ID field in the mutation")
  16423. }
  16424. oldValue, err := m.oldValue(ctx)
  16425. if err != nil {
  16426. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16427. }
  16428. return oldValue.Wxid, nil
  16429. }
  16430. // ResetWxid resets all changes to the "wxid" field.
  16431. func (m *MessageMutation) ResetWxid() {
  16432. m.wxid = nil
  16433. }
  16434. // SetContent sets the "content" field.
  16435. func (m *MessageMutation) SetContent(s string) {
  16436. m.content = &s
  16437. }
  16438. // Content returns the value of the "content" field in the mutation.
  16439. func (m *MessageMutation) Content() (r string, exists bool) {
  16440. v := m.content
  16441. if v == nil {
  16442. return
  16443. }
  16444. return *v, true
  16445. }
  16446. // OldContent returns the old "content" field's value of the Message entity.
  16447. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16449. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16450. if !m.op.Is(OpUpdateOne) {
  16451. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16452. }
  16453. if m.id == nil || m.oldValue == nil {
  16454. return v, errors.New("OldContent requires an ID field in the mutation")
  16455. }
  16456. oldValue, err := m.oldValue(ctx)
  16457. if err != nil {
  16458. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16459. }
  16460. return oldValue.Content, nil
  16461. }
  16462. // ResetContent resets all changes to the "content" field.
  16463. func (m *MessageMutation) ResetContent() {
  16464. m.content = nil
  16465. }
  16466. // Where appends a list predicates to the MessageMutation builder.
  16467. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16468. m.predicates = append(m.predicates, ps...)
  16469. }
  16470. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16471. // users can use type-assertion to append predicates that do not depend on any generated package.
  16472. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16473. p := make([]predicate.Message, len(ps))
  16474. for i := range ps {
  16475. p[i] = ps[i]
  16476. }
  16477. m.Where(p...)
  16478. }
  16479. // Op returns the operation name.
  16480. func (m *MessageMutation) Op() Op {
  16481. return m.op
  16482. }
  16483. // SetOp allows setting the mutation operation.
  16484. func (m *MessageMutation) SetOp(op Op) {
  16485. m.op = op
  16486. }
  16487. // Type returns the node type of this mutation (Message).
  16488. func (m *MessageMutation) Type() string {
  16489. return m.typ
  16490. }
  16491. // Fields returns all fields that were changed during this mutation. Note that in
  16492. // order to get all numeric fields that were incremented/decremented, call
  16493. // AddedFields().
  16494. func (m *MessageMutation) Fields() []string {
  16495. fields := make([]string, 0, 3)
  16496. if m.wx_wxid != nil {
  16497. fields = append(fields, message.FieldWxWxid)
  16498. }
  16499. if m.wxid != nil {
  16500. fields = append(fields, message.FieldWxid)
  16501. }
  16502. if m.content != nil {
  16503. fields = append(fields, message.FieldContent)
  16504. }
  16505. return fields
  16506. }
  16507. // Field returns the value of a field with the given name. The second boolean
  16508. // return value indicates that this field was not set, or was not defined in the
  16509. // schema.
  16510. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16511. switch name {
  16512. case message.FieldWxWxid:
  16513. return m.WxWxid()
  16514. case message.FieldWxid:
  16515. return m.Wxid()
  16516. case message.FieldContent:
  16517. return m.Content()
  16518. }
  16519. return nil, false
  16520. }
  16521. // OldField returns the old value of the field from the database. An error is
  16522. // returned if the mutation operation is not UpdateOne, or the query to the
  16523. // database failed.
  16524. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16525. switch name {
  16526. case message.FieldWxWxid:
  16527. return m.OldWxWxid(ctx)
  16528. case message.FieldWxid:
  16529. return m.OldWxid(ctx)
  16530. case message.FieldContent:
  16531. return m.OldContent(ctx)
  16532. }
  16533. return nil, fmt.Errorf("unknown Message field %s", name)
  16534. }
  16535. // SetField sets the value of a field with the given name. It returns an error if
  16536. // the field is not defined in the schema, or if the type mismatched the field
  16537. // type.
  16538. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16539. switch name {
  16540. case message.FieldWxWxid:
  16541. v, ok := value.(string)
  16542. if !ok {
  16543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16544. }
  16545. m.SetWxWxid(v)
  16546. return nil
  16547. case message.FieldWxid:
  16548. v, ok := value.(string)
  16549. if !ok {
  16550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16551. }
  16552. m.SetWxid(v)
  16553. return nil
  16554. case message.FieldContent:
  16555. v, ok := value.(string)
  16556. if !ok {
  16557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16558. }
  16559. m.SetContent(v)
  16560. return nil
  16561. }
  16562. return fmt.Errorf("unknown Message field %s", name)
  16563. }
  16564. // AddedFields returns all numeric fields that were incremented/decremented during
  16565. // this mutation.
  16566. func (m *MessageMutation) AddedFields() []string {
  16567. return nil
  16568. }
  16569. // AddedField returns the numeric value that was incremented/decremented on a field
  16570. // with the given name. The second boolean return value indicates that this field
  16571. // was not set, or was not defined in the schema.
  16572. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16573. return nil, false
  16574. }
  16575. // AddField adds the value to the field with the given name. It returns an error if
  16576. // the field is not defined in the schema, or if the type mismatched the field
  16577. // type.
  16578. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16579. switch name {
  16580. }
  16581. return fmt.Errorf("unknown Message numeric field %s", name)
  16582. }
  16583. // ClearedFields returns all nullable fields that were cleared during this
  16584. // mutation.
  16585. func (m *MessageMutation) ClearedFields() []string {
  16586. var fields []string
  16587. if m.FieldCleared(message.FieldWxWxid) {
  16588. fields = append(fields, message.FieldWxWxid)
  16589. }
  16590. return fields
  16591. }
  16592. // FieldCleared returns a boolean indicating if a field with the given name was
  16593. // cleared in this mutation.
  16594. func (m *MessageMutation) FieldCleared(name string) bool {
  16595. _, ok := m.clearedFields[name]
  16596. return ok
  16597. }
  16598. // ClearField clears the value of the field with the given name. It returns an
  16599. // error if the field is not defined in the schema.
  16600. func (m *MessageMutation) ClearField(name string) error {
  16601. switch name {
  16602. case message.FieldWxWxid:
  16603. m.ClearWxWxid()
  16604. return nil
  16605. }
  16606. return fmt.Errorf("unknown Message nullable field %s", name)
  16607. }
  16608. // ResetField resets all changes in the mutation for the field with the given name.
  16609. // It returns an error if the field is not defined in the schema.
  16610. func (m *MessageMutation) ResetField(name string) error {
  16611. switch name {
  16612. case message.FieldWxWxid:
  16613. m.ResetWxWxid()
  16614. return nil
  16615. case message.FieldWxid:
  16616. m.ResetWxid()
  16617. return nil
  16618. case message.FieldContent:
  16619. m.ResetContent()
  16620. return nil
  16621. }
  16622. return fmt.Errorf("unknown Message field %s", name)
  16623. }
  16624. // AddedEdges returns all edge names that were set/added in this mutation.
  16625. func (m *MessageMutation) AddedEdges() []string {
  16626. edges := make([]string, 0, 0)
  16627. return edges
  16628. }
  16629. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16630. // name in this mutation.
  16631. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16632. return nil
  16633. }
  16634. // RemovedEdges returns all edge names that were removed in this mutation.
  16635. func (m *MessageMutation) RemovedEdges() []string {
  16636. edges := make([]string, 0, 0)
  16637. return edges
  16638. }
  16639. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16640. // the given name in this mutation.
  16641. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16642. return nil
  16643. }
  16644. // ClearedEdges returns all edge names that were cleared in this mutation.
  16645. func (m *MessageMutation) ClearedEdges() []string {
  16646. edges := make([]string, 0, 0)
  16647. return edges
  16648. }
  16649. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16650. // was cleared in this mutation.
  16651. func (m *MessageMutation) EdgeCleared(name string) bool {
  16652. return false
  16653. }
  16654. // ClearEdge clears the value of the edge with the given name. It returns an error
  16655. // if that edge is not defined in the schema.
  16656. func (m *MessageMutation) ClearEdge(name string) error {
  16657. return fmt.Errorf("unknown Message unique edge %s", name)
  16658. }
  16659. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16660. // It returns an error if the edge is not defined in the schema.
  16661. func (m *MessageMutation) ResetEdge(name string) error {
  16662. return fmt.Errorf("unknown Message edge %s", name)
  16663. }
  16664. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16665. type MessageRecordsMutation struct {
  16666. config
  16667. op Op
  16668. typ string
  16669. id *uint64
  16670. created_at *time.Time
  16671. updated_at *time.Time
  16672. status *uint8
  16673. addstatus *int8
  16674. bot_wxid *string
  16675. contact_type *int
  16676. addcontact_type *int
  16677. contact_wxid *string
  16678. content_type *int
  16679. addcontent_type *int
  16680. content *string
  16681. meta *custom_types.Meta
  16682. error_detail *string
  16683. send_time *time.Time
  16684. source_type *int
  16685. addsource_type *int
  16686. organization_id *uint64
  16687. addorganization_id *int64
  16688. clearedFields map[string]struct{}
  16689. sop_stage *uint64
  16690. clearedsop_stage bool
  16691. sop_node *uint64
  16692. clearedsop_node bool
  16693. message_contact *uint64
  16694. clearedmessage_contact bool
  16695. done bool
  16696. oldValue func(context.Context) (*MessageRecords, error)
  16697. predicates []predicate.MessageRecords
  16698. }
  16699. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16700. // messagerecordsOption allows management of the mutation configuration using functional options.
  16701. type messagerecordsOption func(*MessageRecordsMutation)
  16702. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16703. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16704. m := &MessageRecordsMutation{
  16705. config: c,
  16706. op: op,
  16707. typ: TypeMessageRecords,
  16708. clearedFields: make(map[string]struct{}),
  16709. }
  16710. for _, opt := range opts {
  16711. opt(m)
  16712. }
  16713. return m
  16714. }
  16715. // withMessageRecordsID sets the ID field of the mutation.
  16716. func withMessageRecordsID(id uint64) messagerecordsOption {
  16717. return func(m *MessageRecordsMutation) {
  16718. var (
  16719. err error
  16720. once sync.Once
  16721. value *MessageRecords
  16722. )
  16723. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16724. once.Do(func() {
  16725. if m.done {
  16726. err = errors.New("querying old values post mutation is not allowed")
  16727. } else {
  16728. value, err = m.Client().MessageRecords.Get(ctx, id)
  16729. }
  16730. })
  16731. return value, err
  16732. }
  16733. m.id = &id
  16734. }
  16735. }
  16736. // withMessageRecords sets the old MessageRecords of the mutation.
  16737. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16738. return func(m *MessageRecordsMutation) {
  16739. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16740. return node, nil
  16741. }
  16742. m.id = &node.ID
  16743. }
  16744. }
  16745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16746. // executed in a transaction (ent.Tx), a transactional client is returned.
  16747. func (m MessageRecordsMutation) Client() *Client {
  16748. client := &Client{config: m.config}
  16749. client.init()
  16750. return client
  16751. }
  16752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16753. // it returns an error otherwise.
  16754. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16755. if _, ok := m.driver.(*txDriver); !ok {
  16756. return nil, errors.New("ent: mutation is not running in a transaction")
  16757. }
  16758. tx := &Tx{config: m.config}
  16759. tx.init()
  16760. return tx, nil
  16761. }
  16762. // SetID sets the value of the id field. Note that this
  16763. // operation is only accepted on creation of MessageRecords entities.
  16764. func (m *MessageRecordsMutation) SetID(id uint64) {
  16765. m.id = &id
  16766. }
  16767. // ID returns the ID value in the mutation. Note that the ID is only available
  16768. // if it was provided to the builder or after it was returned from the database.
  16769. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16770. if m.id == nil {
  16771. return
  16772. }
  16773. return *m.id, true
  16774. }
  16775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16776. // That means, if the mutation is applied within a transaction with an isolation level such
  16777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16778. // or updated by the mutation.
  16779. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16780. switch {
  16781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16782. id, exists := m.ID()
  16783. if exists {
  16784. return []uint64{id}, nil
  16785. }
  16786. fallthrough
  16787. case m.op.Is(OpUpdate | OpDelete):
  16788. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16789. default:
  16790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16791. }
  16792. }
  16793. // SetCreatedAt sets the "created_at" field.
  16794. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16795. m.created_at = &t
  16796. }
  16797. // CreatedAt returns the value of the "created_at" field in the mutation.
  16798. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16799. v := m.created_at
  16800. if v == nil {
  16801. return
  16802. }
  16803. return *v, true
  16804. }
  16805. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16806. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16808. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16809. if !m.op.Is(OpUpdateOne) {
  16810. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16811. }
  16812. if m.id == nil || m.oldValue == nil {
  16813. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16814. }
  16815. oldValue, err := m.oldValue(ctx)
  16816. if err != nil {
  16817. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16818. }
  16819. return oldValue.CreatedAt, nil
  16820. }
  16821. // ResetCreatedAt resets all changes to the "created_at" field.
  16822. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16823. m.created_at = nil
  16824. }
  16825. // SetUpdatedAt sets the "updated_at" field.
  16826. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16827. m.updated_at = &t
  16828. }
  16829. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16830. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16831. v := m.updated_at
  16832. if v == nil {
  16833. return
  16834. }
  16835. return *v, true
  16836. }
  16837. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16838. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16840. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16841. if !m.op.Is(OpUpdateOne) {
  16842. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16843. }
  16844. if m.id == nil || m.oldValue == nil {
  16845. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16846. }
  16847. oldValue, err := m.oldValue(ctx)
  16848. if err != nil {
  16849. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16850. }
  16851. return oldValue.UpdatedAt, nil
  16852. }
  16853. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16854. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16855. m.updated_at = nil
  16856. }
  16857. // SetStatus sets the "status" field.
  16858. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16859. m.status = &u
  16860. m.addstatus = nil
  16861. }
  16862. // Status returns the value of the "status" field in the mutation.
  16863. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16864. v := m.status
  16865. if v == nil {
  16866. return
  16867. }
  16868. return *v, true
  16869. }
  16870. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16871. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16873. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16874. if !m.op.Is(OpUpdateOne) {
  16875. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16876. }
  16877. if m.id == nil || m.oldValue == nil {
  16878. return v, errors.New("OldStatus requires an ID field in the mutation")
  16879. }
  16880. oldValue, err := m.oldValue(ctx)
  16881. if err != nil {
  16882. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16883. }
  16884. return oldValue.Status, nil
  16885. }
  16886. // AddStatus adds u to the "status" field.
  16887. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16888. if m.addstatus != nil {
  16889. *m.addstatus += u
  16890. } else {
  16891. m.addstatus = &u
  16892. }
  16893. }
  16894. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16895. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16896. v := m.addstatus
  16897. if v == nil {
  16898. return
  16899. }
  16900. return *v, true
  16901. }
  16902. // ClearStatus clears the value of the "status" field.
  16903. func (m *MessageRecordsMutation) ClearStatus() {
  16904. m.status = nil
  16905. m.addstatus = nil
  16906. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16907. }
  16908. // StatusCleared returns if the "status" field was cleared in this mutation.
  16909. func (m *MessageRecordsMutation) StatusCleared() bool {
  16910. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16911. return ok
  16912. }
  16913. // ResetStatus resets all changes to the "status" field.
  16914. func (m *MessageRecordsMutation) ResetStatus() {
  16915. m.status = nil
  16916. m.addstatus = nil
  16917. delete(m.clearedFields, messagerecords.FieldStatus)
  16918. }
  16919. // SetBotWxid sets the "bot_wxid" field.
  16920. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16921. m.bot_wxid = &s
  16922. }
  16923. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16924. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16925. v := m.bot_wxid
  16926. if v == nil {
  16927. return
  16928. }
  16929. return *v, true
  16930. }
  16931. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16932. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16934. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16935. if !m.op.Is(OpUpdateOne) {
  16936. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16937. }
  16938. if m.id == nil || m.oldValue == nil {
  16939. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16940. }
  16941. oldValue, err := m.oldValue(ctx)
  16942. if err != nil {
  16943. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16944. }
  16945. return oldValue.BotWxid, nil
  16946. }
  16947. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16948. func (m *MessageRecordsMutation) ResetBotWxid() {
  16949. m.bot_wxid = nil
  16950. }
  16951. // SetContactID sets the "contact_id" field.
  16952. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16953. m.message_contact = &u
  16954. }
  16955. // ContactID returns the value of the "contact_id" field in the mutation.
  16956. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16957. v := m.message_contact
  16958. if v == nil {
  16959. return
  16960. }
  16961. return *v, true
  16962. }
  16963. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16964. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16966. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16967. if !m.op.Is(OpUpdateOne) {
  16968. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16969. }
  16970. if m.id == nil || m.oldValue == nil {
  16971. return v, errors.New("OldContactID requires an ID field in the mutation")
  16972. }
  16973. oldValue, err := m.oldValue(ctx)
  16974. if err != nil {
  16975. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16976. }
  16977. return oldValue.ContactID, nil
  16978. }
  16979. // ClearContactID clears the value of the "contact_id" field.
  16980. func (m *MessageRecordsMutation) ClearContactID() {
  16981. m.message_contact = nil
  16982. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16983. }
  16984. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16985. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16986. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16987. return ok
  16988. }
  16989. // ResetContactID resets all changes to the "contact_id" field.
  16990. func (m *MessageRecordsMutation) ResetContactID() {
  16991. m.message_contact = nil
  16992. delete(m.clearedFields, messagerecords.FieldContactID)
  16993. }
  16994. // SetContactType sets the "contact_type" field.
  16995. func (m *MessageRecordsMutation) SetContactType(i int) {
  16996. m.contact_type = &i
  16997. m.addcontact_type = nil
  16998. }
  16999. // ContactType returns the value of the "contact_type" field in the mutation.
  17000. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17001. v := m.contact_type
  17002. if v == nil {
  17003. return
  17004. }
  17005. return *v, true
  17006. }
  17007. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17008. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17010. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17011. if !m.op.Is(OpUpdateOne) {
  17012. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17013. }
  17014. if m.id == nil || m.oldValue == nil {
  17015. return v, errors.New("OldContactType requires an ID field in the mutation")
  17016. }
  17017. oldValue, err := m.oldValue(ctx)
  17018. if err != nil {
  17019. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17020. }
  17021. return oldValue.ContactType, nil
  17022. }
  17023. // AddContactType adds i to the "contact_type" field.
  17024. func (m *MessageRecordsMutation) AddContactType(i int) {
  17025. if m.addcontact_type != nil {
  17026. *m.addcontact_type += i
  17027. } else {
  17028. m.addcontact_type = &i
  17029. }
  17030. }
  17031. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17032. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17033. v := m.addcontact_type
  17034. if v == nil {
  17035. return
  17036. }
  17037. return *v, true
  17038. }
  17039. // ResetContactType resets all changes to the "contact_type" field.
  17040. func (m *MessageRecordsMutation) ResetContactType() {
  17041. m.contact_type = nil
  17042. m.addcontact_type = nil
  17043. }
  17044. // SetContactWxid sets the "contact_wxid" field.
  17045. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17046. m.contact_wxid = &s
  17047. }
  17048. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17049. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17050. v := m.contact_wxid
  17051. if v == nil {
  17052. return
  17053. }
  17054. return *v, true
  17055. }
  17056. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17057. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17059. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17060. if !m.op.Is(OpUpdateOne) {
  17061. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17062. }
  17063. if m.id == nil || m.oldValue == nil {
  17064. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17065. }
  17066. oldValue, err := m.oldValue(ctx)
  17067. if err != nil {
  17068. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17069. }
  17070. return oldValue.ContactWxid, nil
  17071. }
  17072. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17073. func (m *MessageRecordsMutation) ResetContactWxid() {
  17074. m.contact_wxid = nil
  17075. }
  17076. // SetContentType sets the "content_type" field.
  17077. func (m *MessageRecordsMutation) SetContentType(i int) {
  17078. m.content_type = &i
  17079. m.addcontent_type = nil
  17080. }
  17081. // ContentType returns the value of the "content_type" field in the mutation.
  17082. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17083. v := m.content_type
  17084. if v == nil {
  17085. return
  17086. }
  17087. return *v, true
  17088. }
  17089. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17090. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17092. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17093. if !m.op.Is(OpUpdateOne) {
  17094. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17095. }
  17096. if m.id == nil || m.oldValue == nil {
  17097. return v, errors.New("OldContentType requires an ID field in the mutation")
  17098. }
  17099. oldValue, err := m.oldValue(ctx)
  17100. if err != nil {
  17101. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17102. }
  17103. return oldValue.ContentType, nil
  17104. }
  17105. // AddContentType adds i to the "content_type" field.
  17106. func (m *MessageRecordsMutation) AddContentType(i int) {
  17107. if m.addcontent_type != nil {
  17108. *m.addcontent_type += i
  17109. } else {
  17110. m.addcontent_type = &i
  17111. }
  17112. }
  17113. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17114. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17115. v := m.addcontent_type
  17116. if v == nil {
  17117. return
  17118. }
  17119. return *v, true
  17120. }
  17121. // ResetContentType resets all changes to the "content_type" field.
  17122. func (m *MessageRecordsMutation) ResetContentType() {
  17123. m.content_type = nil
  17124. m.addcontent_type = nil
  17125. }
  17126. // SetContent sets the "content" field.
  17127. func (m *MessageRecordsMutation) SetContent(s string) {
  17128. m.content = &s
  17129. }
  17130. // Content returns the value of the "content" field in the mutation.
  17131. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17132. v := m.content
  17133. if v == nil {
  17134. return
  17135. }
  17136. return *v, true
  17137. }
  17138. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17139. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17141. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17142. if !m.op.Is(OpUpdateOne) {
  17143. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17144. }
  17145. if m.id == nil || m.oldValue == nil {
  17146. return v, errors.New("OldContent requires an ID field in the mutation")
  17147. }
  17148. oldValue, err := m.oldValue(ctx)
  17149. if err != nil {
  17150. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17151. }
  17152. return oldValue.Content, nil
  17153. }
  17154. // ResetContent resets all changes to the "content" field.
  17155. func (m *MessageRecordsMutation) ResetContent() {
  17156. m.content = nil
  17157. }
  17158. // SetMeta sets the "meta" field.
  17159. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17160. m.meta = &ct
  17161. }
  17162. // Meta returns the value of the "meta" field in the mutation.
  17163. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17164. v := m.meta
  17165. if v == nil {
  17166. return
  17167. }
  17168. return *v, true
  17169. }
  17170. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17171. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17173. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17174. if !m.op.Is(OpUpdateOne) {
  17175. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17176. }
  17177. if m.id == nil || m.oldValue == nil {
  17178. return v, errors.New("OldMeta requires an ID field in the mutation")
  17179. }
  17180. oldValue, err := m.oldValue(ctx)
  17181. if err != nil {
  17182. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17183. }
  17184. return oldValue.Meta, nil
  17185. }
  17186. // ClearMeta clears the value of the "meta" field.
  17187. func (m *MessageRecordsMutation) ClearMeta() {
  17188. m.meta = nil
  17189. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17190. }
  17191. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17192. func (m *MessageRecordsMutation) MetaCleared() bool {
  17193. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17194. return ok
  17195. }
  17196. // ResetMeta resets all changes to the "meta" field.
  17197. func (m *MessageRecordsMutation) ResetMeta() {
  17198. m.meta = nil
  17199. delete(m.clearedFields, messagerecords.FieldMeta)
  17200. }
  17201. // SetErrorDetail sets the "error_detail" field.
  17202. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17203. m.error_detail = &s
  17204. }
  17205. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17206. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17207. v := m.error_detail
  17208. if v == nil {
  17209. return
  17210. }
  17211. return *v, true
  17212. }
  17213. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17214. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17216. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17217. if !m.op.Is(OpUpdateOne) {
  17218. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17219. }
  17220. if m.id == nil || m.oldValue == nil {
  17221. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17222. }
  17223. oldValue, err := m.oldValue(ctx)
  17224. if err != nil {
  17225. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17226. }
  17227. return oldValue.ErrorDetail, nil
  17228. }
  17229. // ResetErrorDetail resets all changes to the "error_detail" field.
  17230. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17231. m.error_detail = nil
  17232. }
  17233. // SetSendTime sets the "send_time" field.
  17234. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17235. m.send_time = &t
  17236. }
  17237. // SendTime returns the value of the "send_time" field in the mutation.
  17238. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17239. v := m.send_time
  17240. if v == nil {
  17241. return
  17242. }
  17243. return *v, true
  17244. }
  17245. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17246. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17248. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17249. if !m.op.Is(OpUpdateOne) {
  17250. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17251. }
  17252. if m.id == nil || m.oldValue == nil {
  17253. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17254. }
  17255. oldValue, err := m.oldValue(ctx)
  17256. if err != nil {
  17257. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17258. }
  17259. return oldValue.SendTime, nil
  17260. }
  17261. // ClearSendTime clears the value of the "send_time" field.
  17262. func (m *MessageRecordsMutation) ClearSendTime() {
  17263. m.send_time = nil
  17264. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17265. }
  17266. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17267. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17268. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17269. return ok
  17270. }
  17271. // ResetSendTime resets all changes to the "send_time" field.
  17272. func (m *MessageRecordsMutation) ResetSendTime() {
  17273. m.send_time = nil
  17274. delete(m.clearedFields, messagerecords.FieldSendTime)
  17275. }
  17276. // SetSourceType sets the "source_type" field.
  17277. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17278. m.source_type = &i
  17279. m.addsource_type = nil
  17280. }
  17281. // SourceType returns the value of the "source_type" field in the mutation.
  17282. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17283. v := m.source_type
  17284. if v == nil {
  17285. return
  17286. }
  17287. return *v, true
  17288. }
  17289. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17290. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17292. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17293. if !m.op.Is(OpUpdateOne) {
  17294. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17295. }
  17296. if m.id == nil || m.oldValue == nil {
  17297. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17298. }
  17299. oldValue, err := m.oldValue(ctx)
  17300. if err != nil {
  17301. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17302. }
  17303. return oldValue.SourceType, nil
  17304. }
  17305. // AddSourceType adds i to the "source_type" field.
  17306. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17307. if m.addsource_type != nil {
  17308. *m.addsource_type += i
  17309. } else {
  17310. m.addsource_type = &i
  17311. }
  17312. }
  17313. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17314. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17315. v := m.addsource_type
  17316. if v == nil {
  17317. return
  17318. }
  17319. return *v, true
  17320. }
  17321. // ResetSourceType resets all changes to the "source_type" field.
  17322. func (m *MessageRecordsMutation) ResetSourceType() {
  17323. m.source_type = nil
  17324. m.addsource_type = nil
  17325. }
  17326. // SetSourceID sets the "source_id" field.
  17327. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17328. m.sop_stage = &u
  17329. }
  17330. // SourceID returns the value of the "source_id" field in the mutation.
  17331. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17332. v := m.sop_stage
  17333. if v == nil {
  17334. return
  17335. }
  17336. return *v, true
  17337. }
  17338. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17339. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17341. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17342. if !m.op.Is(OpUpdateOne) {
  17343. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17344. }
  17345. if m.id == nil || m.oldValue == nil {
  17346. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17347. }
  17348. oldValue, err := m.oldValue(ctx)
  17349. if err != nil {
  17350. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17351. }
  17352. return oldValue.SourceID, nil
  17353. }
  17354. // ClearSourceID clears the value of the "source_id" field.
  17355. func (m *MessageRecordsMutation) ClearSourceID() {
  17356. m.sop_stage = nil
  17357. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17358. }
  17359. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17360. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17361. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17362. return ok
  17363. }
  17364. // ResetSourceID resets all changes to the "source_id" field.
  17365. func (m *MessageRecordsMutation) ResetSourceID() {
  17366. m.sop_stage = nil
  17367. delete(m.clearedFields, messagerecords.FieldSourceID)
  17368. }
  17369. // SetSubSourceID sets the "sub_source_id" field.
  17370. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17371. m.sop_node = &u
  17372. }
  17373. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17374. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17375. v := m.sop_node
  17376. if v == nil {
  17377. return
  17378. }
  17379. return *v, true
  17380. }
  17381. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17382. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17384. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17385. if !m.op.Is(OpUpdateOne) {
  17386. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17387. }
  17388. if m.id == nil || m.oldValue == nil {
  17389. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17390. }
  17391. oldValue, err := m.oldValue(ctx)
  17392. if err != nil {
  17393. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17394. }
  17395. return oldValue.SubSourceID, nil
  17396. }
  17397. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17398. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17399. m.sop_node = nil
  17400. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17401. }
  17402. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17403. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17404. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17405. return ok
  17406. }
  17407. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17408. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17409. m.sop_node = nil
  17410. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17411. }
  17412. // SetOrganizationID sets the "organization_id" field.
  17413. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17414. m.organization_id = &u
  17415. m.addorganization_id = nil
  17416. }
  17417. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17418. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17419. v := m.organization_id
  17420. if v == nil {
  17421. return
  17422. }
  17423. return *v, true
  17424. }
  17425. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17426. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17428. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17429. if !m.op.Is(OpUpdateOne) {
  17430. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17431. }
  17432. if m.id == nil || m.oldValue == nil {
  17433. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17434. }
  17435. oldValue, err := m.oldValue(ctx)
  17436. if err != nil {
  17437. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17438. }
  17439. return oldValue.OrganizationID, nil
  17440. }
  17441. // AddOrganizationID adds u to the "organization_id" field.
  17442. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17443. if m.addorganization_id != nil {
  17444. *m.addorganization_id += u
  17445. } else {
  17446. m.addorganization_id = &u
  17447. }
  17448. }
  17449. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17450. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17451. v := m.addorganization_id
  17452. if v == nil {
  17453. return
  17454. }
  17455. return *v, true
  17456. }
  17457. // ClearOrganizationID clears the value of the "organization_id" field.
  17458. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17459. m.organization_id = nil
  17460. m.addorganization_id = nil
  17461. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17462. }
  17463. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17464. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17465. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17466. return ok
  17467. }
  17468. // ResetOrganizationID resets all changes to the "organization_id" field.
  17469. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17470. m.organization_id = nil
  17471. m.addorganization_id = nil
  17472. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17473. }
  17474. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17475. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17476. m.sop_stage = &id
  17477. }
  17478. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17479. func (m *MessageRecordsMutation) ClearSopStage() {
  17480. m.clearedsop_stage = true
  17481. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17482. }
  17483. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17484. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17485. return m.SourceIDCleared() || m.clearedsop_stage
  17486. }
  17487. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17488. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17489. if m.sop_stage != nil {
  17490. return *m.sop_stage, true
  17491. }
  17492. return
  17493. }
  17494. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17495. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17496. // SopStageID instead. It exists only for internal usage by the builders.
  17497. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17498. if id := m.sop_stage; id != nil {
  17499. ids = append(ids, *id)
  17500. }
  17501. return
  17502. }
  17503. // ResetSopStage resets all changes to the "sop_stage" edge.
  17504. func (m *MessageRecordsMutation) ResetSopStage() {
  17505. m.sop_stage = nil
  17506. m.clearedsop_stage = false
  17507. }
  17508. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17509. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17510. m.sop_node = &id
  17511. }
  17512. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17513. func (m *MessageRecordsMutation) ClearSopNode() {
  17514. m.clearedsop_node = true
  17515. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17516. }
  17517. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17518. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17519. return m.SubSourceIDCleared() || m.clearedsop_node
  17520. }
  17521. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17522. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17523. if m.sop_node != nil {
  17524. return *m.sop_node, true
  17525. }
  17526. return
  17527. }
  17528. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17529. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17530. // SopNodeID instead. It exists only for internal usage by the builders.
  17531. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17532. if id := m.sop_node; id != nil {
  17533. ids = append(ids, *id)
  17534. }
  17535. return
  17536. }
  17537. // ResetSopNode resets all changes to the "sop_node" edge.
  17538. func (m *MessageRecordsMutation) ResetSopNode() {
  17539. m.sop_node = nil
  17540. m.clearedsop_node = false
  17541. }
  17542. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17543. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17544. m.message_contact = &id
  17545. }
  17546. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17547. func (m *MessageRecordsMutation) ClearMessageContact() {
  17548. m.clearedmessage_contact = true
  17549. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17550. }
  17551. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17552. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17553. return m.ContactIDCleared() || m.clearedmessage_contact
  17554. }
  17555. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17556. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17557. if m.message_contact != nil {
  17558. return *m.message_contact, true
  17559. }
  17560. return
  17561. }
  17562. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17563. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17564. // MessageContactID instead. It exists only for internal usage by the builders.
  17565. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17566. if id := m.message_contact; id != nil {
  17567. ids = append(ids, *id)
  17568. }
  17569. return
  17570. }
  17571. // ResetMessageContact resets all changes to the "message_contact" edge.
  17572. func (m *MessageRecordsMutation) ResetMessageContact() {
  17573. m.message_contact = nil
  17574. m.clearedmessage_contact = false
  17575. }
  17576. // Where appends a list predicates to the MessageRecordsMutation builder.
  17577. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17578. m.predicates = append(m.predicates, ps...)
  17579. }
  17580. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17581. // users can use type-assertion to append predicates that do not depend on any generated package.
  17582. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17583. p := make([]predicate.MessageRecords, len(ps))
  17584. for i := range ps {
  17585. p[i] = ps[i]
  17586. }
  17587. m.Where(p...)
  17588. }
  17589. // Op returns the operation name.
  17590. func (m *MessageRecordsMutation) Op() Op {
  17591. return m.op
  17592. }
  17593. // SetOp allows setting the mutation operation.
  17594. func (m *MessageRecordsMutation) SetOp(op Op) {
  17595. m.op = op
  17596. }
  17597. // Type returns the node type of this mutation (MessageRecords).
  17598. func (m *MessageRecordsMutation) Type() string {
  17599. return m.typ
  17600. }
  17601. // Fields returns all fields that were changed during this mutation. Note that in
  17602. // order to get all numeric fields that were incremented/decremented, call
  17603. // AddedFields().
  17604. func (m *MessageRecordsMutation) Fields() []string {
  17605. fields := make([]string, 0, 16)
  17606. if m.created_at != nil {
  17607. fields = append(fields, messagerecords.FieldCreatedAt)
  17608. }
  17609. if m.updated_at != nil {
  17610. fields = append(fields, messagerecords.FieldUpdatedAt)
  17611. }
  17612. if m.status != nil {
  17613. fields = append(fields, messagerecords.FieldStatus)
  17614. }
  17615. if m.bot_wxid != nil {
  17616. fields = append(fields, messagerecords.FieldBotWxid)
  17617. }
  17618. if m.message_contact != nil {
  17619. fields = append(fields, messagerecords.FieldContactID)
  17620. }
  17621. if m.contact_type != nil {
  17622. fields = append(fields, messagerecords.FieldContactType)
  17623. }
  17624. if m.contact_wxid != nil {
  17625. fields = append(fields, messagerecords.FieldContactWxid)
  17626. }
  17627. if m.content_type != nil {
  17628. fields = append(fields, messagerecords.FieldContentType)
  17629. }
  17630. if m.content != nil {
  17631. fields = append(fields, messagerecords.FieldContent)
  17632. }
  17633. if m.meta != nil {
  17634. fields = append(fields, messagerecords.FieldMeta)
  17635. }
  17636. if m.error_detail != nil {
  17637. fields = append(fields, messagerecords.FieldErrorDetail)
  17638. }
  17639. if m.send_time != nil {
  17640. fields = append(fields, messagerecords.FieldSendTime)
  17641. }
  17642. if m.source_type != nil {
  17643. fields = append(fields, messagerecords.FieldSourceType)
  17644. }
  17645. if m.sop_stage != nil {
  17646. fields = append(fields, messagerecords.FieldSourceID)
  17647. }
  17648. if m.sop_node != nil {
  17649. fields = append(fields, messagerecords.FieldSubSourceID)
  17650. }
  17651. if m.organization_id != nil {
  17652. fields = append(fields, messagerecords.FieldOrganizationID)
  17653. }
  17654. return fields
  17655. }
  17656. // Field returns the value of a field with the given name. The second boolean
  17657. // return value indicates that this field was not set, or was not defined in the
  17658. // schema.
  17659. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17660. switch name {
  17661. case messagerecords.FieldCreatedAt:
  17662. return m.CreatedAt()
  17663. case messagerecords.FieldUpdatedAt:
  17664. return m.UpdatedAt()
  17665. case messagerecords.FieldStatus:
  17666. return m.Status()
  17667. case messagerecords.FieldBotWxid:
  17668. return m.BotWxid()
  17669. case messagerecords.FieldContactID:
  17670. return m.ContactID()
  17671. case messagerecords.FieldContactType:
  17672. return m.ContactType()
  17673. case messagerecords.FieldContactWxid:
  17674. return m.ContactWxid()
  17675. case messagerecords.FieldContentType:
  17676. return m.ContentType()
  17677. case messagerecords.FieldContent:
  17678. return m.Content()
  17679. case messagerecords.FieldMeta:
  17680. return m.Meta()
  17681. case messagerecords.FieldErrorDetail:
  17682. return m.ErrorDetail()
  17683. case messagerecords.FieldSendTime:
  17684. return m.SendTime()
  17685. case messagerecords.FieldSourceType:
  17686. return m.SourceType()
  17687. case messagerecords.FieldSourceID:
  17688. return m.SourceID()
  17689. case messagerecords.FieldSubSourceID:
  17690. return m.SubSourceID()
  17691. case messagerecords.FieldOrganizationID:
  17692. return m.OrganizationID()
  17693. }
  17694. return nil, false
  17695. }
  17696. // OldField returns the old value of the field from the database. An error is
  17697. // returned if the mutation operation is not UpdateOne, or the query to the
  17698. // database failed.
  17699. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17700. switch name {
  17701. case messagerecords.FieldCreatedAt:
  17702. return m.OldCreatedAt(ctx)
  17703. case messagerecords.FieldUpdatedAt:
  17704. return m.OldUpdatedAt(ctx)
  17705. case messagerecords.FieldStatus:
  17706. return m.OldStatus(ctx)
  17707. case messagerecords.FieldBotWxid:
  17708. return m.OldBotWxid(ctx)
  17709. case messagerecords.FieldContactID:
  17710. return m.OldContactID(ctx)
  17711. case messagerecords.FieldContactType:
  17712. return m.OldContactType(ctx)
  17713. case messagerecords.FieldContactWxid:
  17714. return m.OldContactWxid(ctx)
  17715. case messagerecords.FieldContentType:
  17716. return m.OldContentType(ctx)
  17717. case messagerecords.FieldContent:
  17718. return m.OldContent(ctx)
  17719. case messagerecords.FieldMeta:
  17720. return m.OldMeta(ctx)
  17721. case messagerecords.FieldErrorDetail:
  17722. return m.OldErrorDetail(ctx)
  17723. case messagerecords.FieldSendTime:
  17724. return m.OldSendTime(ctx)
  17725. case messagerecords.FieldSourceType:
  17726. return m.OldSourceType(ctx)
  17727. case messagerecords.FieldSourceID:
  17728. return m.OldSourceID(ctx)
  17729. case messagerecords.FieldSubSourceID:
  17730. return m.OldSubSourceID(ctx)
  17731. case messagerecords.FieldOrganizationID:
  17732. return m.OldOrganizationID(ctx)
  17733. }
  17734. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17735. }
  17736. // SetField sets the value of a field with the given name. It returns an error if
  17737. // the field is not defined in the schema, or if the type mismatched the field
  17738. // type.
  17739. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17740. switch name {
  17741. case messagerecords.FieldCreatedAt:
  17742. v, ok := value.(time.Time)
  17743. if !ok {
  17744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17745. }
  17746. m.SetCreatedAt(v)
  17747. return nil
  17748. case messagerecords.FieldUpdatedAt:
  17749. v, ok := value.(time.Time)
  17750. if !ok {
  17751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17752. }
  17753. m.SetUpdatedAt(v)
  17754. return nil
  17755. case messagerecords.FieldStatus:
  17756. v, ok := value.(uint8)
  17757. if !ok {
  17758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17759. }
  17760. m.SetStatus(v)
  17761. return nil
  17762. case messagerecords.FieldBotWxid:
  17763. v, ok := value.(string)
  17764. if !ok {
  17765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17766. }
  17767. m.SetBotWxid(v)
  17768. return nil
  17769. case messagerecords.FieldContactID:
  17770. v, ok := value.(uint64)
  17771. if !ok {
  17772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17773. }
  17774. m.SetContactID(v)
  17775. return nil
  17776. case messagerecords.FieldContactType:
  17777. v, ok := value.(int)
  17778. if !ok {
  17779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17780. }
  17781. m.SetContactType(v)
  17782. return nil
  17783. case messagerecords.FieldContactWxid:
  17784. v, ok := value.(string)
  17785. if !ok {
  17786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17787. }
  17788. m.SetContactWxid(v)
  17789. return nil
  17790. case messagerecords.FieldContentType:
  17791. v, ok := value.(int)
  17792. if !ok {
  17793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17794. }
  17795. m.SetContentType(v)
  17796. return nil
  17797. case messagerecords.FieldContent:
  17798. v, ok := value.(string)
  17799. if !ok {
  17800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17801. }
  17802. m.SetContent(v)
  17803. return nil
  17804. case messagerecords.FieldMeta:
  17805. v, ok := value.(custom_types.Meta)
  17806. if !ok {
  17807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17808. }
  17809. m.SetMeta(v)
  17810. return nil
  17811. case messagerecords.FieldErrorDetail:
  17812. v, ok := value.(string)
  17813. if !ok {
  17814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17815. }
  17816. m.SetErrorDetail(v)
  17817. return nil
  17818. case messagerecords.FieldSendTime:
  17819. v, ok := value.(time.Time)
  17820. if !ok {
  17821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17822. }
  17823. m.SetSendTime(v)
  17824. return nil
  17825. case messagerecords.FieldSourceType:
  17826. v, ok := value.(int)
  17827. if !ok {
  17828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17829. }
  17830. m.SetSourceType(v)
  17831. return nil
  17832. case messagerecords.FieldSourceID:
  17833. v, ok := value.(uint64)
  17834. if !ok {
  17835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17836. }
  17837. m.SetSourceID(v)
  17838. return nil
  17839. case messagerecords.FieldSubSourceID:
  17840. v, ok := value.(uint64)
  17841. if !ok {
  17842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17843. }
  17844. m.SetSubSourceID(v)
  17845. return nil
  17846. case messagerecords.FieldOrganizationID:
  17847. v, ok := value.(uint64)
  17848. if !ok {
  17849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17850. }
  17851. m.SetOrganizationID(v)
  17852. return nil
  17853. }
  17854. return fmt.Errorf("unknown MessageRecords field %s", name)
  17855. }
  17856. // AddedFields returns all numeric fields that were incremented/decremented during
  17857. // this mutation.
  17858. func (m *MessageRecordsMutation) AddedFields() []string {
  17859. var fields []string
  17860. if m.addstatus != nil {
  17861. fields = append(fields, messagerecords.FieldStatus)
  17862. }
  17863. if m.addcontact_type != nil {
  17864. fields = append(fields, messagerecords.FieldContactType)
  17865. }
  17866. if m.addcontent_type != nil {
  17867. fields = append(fields, messagerecords.FieldContentType)
  17868. }
  17869. if m.addsource_type != nil {
  17870. fields = append(fields, messagerecords.FieldSourceType)
  17871. }
  17872. if m.addorganization_id != nil {
  17873. fields = append(fields, messagerecords.FieldOrganizationID)
  17874. }
  17875. return fields
  17876. }
  17877. // AddedField returns the numeric value that was incremented/decremented on a field
  17878. // with the given name. The second boolean return value indicates that this field
  17879. // was not set, or was not defined in the schema.
  17880. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17881. switch name {
  17882. case messagerecords.FieldStatus:
  17883. return m.AddedStatus()
  17884. case messagerecords.FieldContactType:
  17885. return m.AddedContactType()
  17886. case messagerecords.FieldContentType:
  17887. return m.AddedContentType()
  17888. case messagerecords.FieldSourceType:
  17889. return m.AddedSourceType()
  17890. case messagerecords.FieldOrganizationID:
  17891. return m.AddedOrganizationID()
  17892. }
  17893. return nil, false
  17894. }
  17895. // AddField adds the value to the field with the given name. It returns an error if
  17896. // the field is not defined in the schema, or if the type mismatched the field
  17897. // type.
  17898. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17899. switch name {
  17900. case messagerecords.FieldStatus:
  17901. v, ok := value.(int8)
  17902. if !ok {
  17903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17904. }
  17905. m.AddStatus(v)
  17906. return nil
  17907. case messagerecords.FieldContactType:
  17908. v, ok := value.(int)
  17909. if !ok {
  17910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17911. }
  17912. m.AddContactType(v)
  17913. return nil
  17914. case messagerecords.FieldContentType:
  17915. v, ok := value.(int)
  17916. if !ok {
  17917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17918. }
  17919. m.AddContentType(v)
  17920. return nil
  17921. case messagerecords.FieldSourceType:
  17922. v, ok := value.(int)
  17923. if !ok {
  17924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17925. }
  17926. m.AddSourceType(v)
  17927. return nil
  17928. case messagerecords.FieldOrganizationID:
  17929. v, ok := value.(int64)
  17930. if !ok {
  17931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17932. }
  17933. m.AddOrganizationID(v)
  17934. return nil
  17935. }
  17936. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17937. }
  17938. // ClearedFields returns all nullable fields that were cleared during this
  17939. // mutation.
  17940. func (m *MessageRecordsMutation) ClearedFields() []string {
  17941. var fields []string
  17942. if m.FieldCleared(messagerecords.FieldStatus) {
  17943. fields = append(fields, messagerecords.FieldStatus)
  17944. }
  17945. if m.FieldCleared(messagerecords.FieldContactID) {
  17946. fields = append(fields, messagerecords.FieldContactID)
  17947. }
  17948. if m.FieldCleared(messagerecords.FieldMeta) {
  17949. fields = append(fields, messagerecords.FieldMeta)
  17950. }
  17951. if m.FieldCleared(messagerecords.FieldSendTime) {
  17952. fields = append(fields, messagerecords.FieldSendTime)
  17953. }
  17954. if m.FieldCleared(messagerecords.FieldSourceID) {
  17955. fields = append(fields, messagerecords.FieldSourceID)
  17956. }
  17957. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17958. fields = append(fields, messagerecords.FieldSubSourceID)
  17959. }
  17960. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17961. fields = append(fields, messagerecords.FieldOrganizationID)
  17962. }
  17963. return fields
  17964. }
  17965. // FieldCleared returns a boolean indicating if a field with the given name was
  17966. // cleared in this mutation.
  17967. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17968. _, ok := m.clearedFields[name]
  17969. return ok
  17970. }
  17971. // ClearField clears the value of the field with the given name. It returns an
  17972. // error if the field is not defined in the schema.
  17973. func (m *MessageRecordsMutation) ClearField(name string) error {
  17974. switch name {
  17975. case messagerecords.FieldStatus:
  17976. m.ClearStatus()
  17977. return nil
  17978. case messagerecords.FieldContactID:
  17979. m.ClearContactID()
  17980. return nil
  17981. case messagerecords.FieldMeta:
  17982. m.ClearMeta()
  17983. return nil
  17984. case messagerecords.FieldSendTime:
  17985. m.ClearSendTime()
  17986. return nil
  17987. case messagerecords.FieldSourceID:
  17988. m.ClearSourceID()
  17989. return nil
  17990. case messagerecords.FieldSubSourceID:
  17991. m.ClearSubSourceID()
  17992. return nil
  17993. case messagerecords.FieldOrganizationID:
  17994. m.ClearOrganizationID()
  17995. return nil
  17996. }
  17997. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17998. }
  17999. // ResetField resets all changes in the mutation for the field with the given name.
  18000. // It returns an error if the field is not defined in the schema.
  18001. func (m *MessageRecordsMutation) ResetField(name string) error {
  18002. switch name {
  18003. case messagerecords.FieldCreatedAt:
  18004. m.ResetCreatedAt()
  18005. return nil
  18006. case messagerecords.FieldUpdatedAt:
  18007. m.ResetUpdatedAt()
  18008. return nil
  18009. case messagerecords.FieldStatus:
  18010. m.ResetStatus()
  18011. return nil
  18012. case messagerecords.FieldBotWxid:
  18013. m.ResetBotWxid()
  18014. return nil
  18015. case messagerecords.FieldContactID:
  18016. m.ResetContactID()
  18017. return nil
  18018. case messagerecords.FieldContactType:
  18019. m.ResetContactType()
  18020. return nil
  18021. case messagerecords.FieldContactWxid:
  18022. m.ResetContactWxid()
  18023. return nil
  18024. case messagerecords.FieldContentType:
  18025. m.ResetContentType()
  18026. return nil
  18027. case messagerecords.FieldContent:
  18028. m.ResetContent()
  18029. return nil
  18030. case messagerecords.FieldMeta:
  18031. m.ResetMeta()
  18032. return nil
  18033. case messagerecords.FieldErrorDetail:
  18034. m.ResetErrorDetail()
  18035. return nil
  18036. case messagerecords.FieldSendTime:
  18037. m.ResetSendTime()
  18038. return nil
  18039. case messagerecords.FieldSourceType:
  18040. m.ResetSourceType()
  18041. return nil
  18042. case messagerecords.FieldSourceID:
  18043. m.ResetSourceID()
  18044. return nil
  18045. case messagerecords.FieldSubSourceID:
  18046. m.ResetSubSourceID()
  18047. return nil
  18048. case messagerecords.FieldOrganizationID:
  18049. m.ResetOrganizationID()
  18050. return nil
  18051. }
  18052. return fmt.Errorf("unknown MessageRecords field %s", name)
  18053. }
  18054. // AddedEdges returns all edge names that were set/added in this mutation.
  18055. func (m *MessageRecordsMutation) AddedEdges() []string {
  18056. edges := make([]string, 0, 3)
  18057. if m.sop_stage != nil {
  18058. edges = append(edges, messagerecords.EdgeSopStage)
  18059. }
  18060. if m.sop_node != nil {
  18061. edges = append(edges, messagerecords.EdgeSopNode)
  18062. }
  18063. if m.message_contact != nil {
  18064. edges = append(edges, messagerecords.EdgeMessageContact)
  18065. }
  18066. return edges
  18067. }
  18068. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18069. // name in this mutation.
  18070. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18071. switch name {
  18072. case messagerecords.EdgeSopStage:
  18073. if id := m.sop_stage; id != nil {
  18074. return []ent.Value{*id}
  18075. }
  18076. case messagerecords.EdgeSopNode:
  18077. if id := m.sop_node; id != nil {
  18078. return []ent.Value{*id}
  18079. }
  18080. case messagerecords.EdgeMessageContact:
  18081. if id := m.message_contact; id != nil {
  18082. return []ent.Value{*id}
  18083. }
  18084. }
  18085. return nil
  18086. }
  18087. // RemovedEdges returns all edge names that were removed in this mutation.
  18088. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18089. edges := make([]string, 0, 3)
  18090. return edges
  18091. }
  18092. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18093. // the given name in this mutation.
  18094. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18095. return nil
  18096. }
  18097. // ClearedEdges returns all edge names that were cleared in this mutation.
  18098. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18099. edges := make([]string, 0, 3)
  18100. if m.clearedsop_stage {
  18101. edges = append(edges, messagerecords.EdgeSopStage)
  18102. }
  18103. if m.clearedsop_node {
  18104. edges = append(edges, messagerecords.EdgeSopNode)
  18105. }
  18106. if m.clearedmessage_contact {
  18107. edges = append(edges, messagerecords.EdgeMessageContact)
  18108. }
  18109. return edges
  18110. }
  18111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18112. // was cleared in this mutation.
  18113. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18114. switch name {
  18115. case messagerecords.EdgeSopStage:
  18116. return m.clearedsop_stage
  18117. case messagerecords.EdgeSopNode:
  18118. return m.clearedsop_node
  18119. case messagerecords.EdgeMessageContact:
  18120. return m.clearedmessage_contact
  18121. }
  18122. return false
  18123. }
  18124. // ClearEdge clears the value of the edge with the given name. It returns an error
  18125. // if that edge is not defined in the schema.
  18126. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18127. switch name {
  18128. case messagerecords.EdgeSopStage:
  18129. m.ClearSopStage()
  18130. return nil
  18131. case messagerecords.EdgeSopNode:
  18132. m.ClearSopNode()
  18133. return nil
  18134. case messagerecords.EdgeMessageContact:
  18135. m.ClearMessageContact()
  18136. return nil
  18137. }
  18138. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18139. }
  18140. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18141. // It returns an error if the edge is not defined in the schema.
  18142. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18143. switch name {
  18144. case messagerecords.EdgeSopStage:
  18145. m.ResetSopStage()
  18146. return nil
  18147. case messagerecords.EdgeSopNode:
  18148. m.ResetSopNode()
  18149. return nil
  18150. case messagerecords.EdgeMessageContact:
  18151. m.ResetMessageContact()
  18152. return nil
  18153. }
  18154. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18155. }
  18156. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18157. type MsgMutation struct {
  18158. config
  18159. op Op
  18160. typ string
  18161. id *uint64
  18162. created_at *time.Time
  18163. updated_at *time.Time
  18164. deleted_at *time.Time
  18165. status *uint8
  18166. addstatus *int8
  18167. fromwxid *string
  18168. toid *string
  18169. msgtype *int32
  18170. addmsgtype *int32
  18171. msg *string
  18172. batch_no *string
  18173. clearedFields map[string]struct{}
  18174. done bool
  18175. oldValue func(context.Context) (*Msg, error)
  18176. predicates []predicate.Msg
  18177. }
  18178. var _ ent.Mutation = (*MsgMutation)(nil)
  18179. // msgOption allows management of the mutation configuration using functional options.
  18180. type msgOption func(*MsgMutation)
  18181. // newMsgMutation creates new mutation for the Msg entity.
  18182. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18183. m := &MsgMutation{
  18184. config: c,
  18185. op: op,
  18186. typ: TypeMsg,
  18187. clearedFields: make(map[string]struct{}),
  18188. }
  18189. for _, opt := range opts {
  18190. opt(m)
  18191. }
  18192. return m
  18193. }
  18194. // withMsgID sets the ID field of the mutation.
  18195. func withMsgID(id uint64) msgOption {
  18196. return func(m *MsgMutation) {
  18197. var (
  18198. err error
  18199. once sync.Once
  18200. value *Msg
  18201. )
  18202. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18203. once.Do(func() {
  18204. if m.done {
  18205. err = errors.New("querying old values post mutation is not allowed")
  18206. } else {
  18207. value, err = m.Client().Msg.Get(ctx, id)
  18208. }
  18209. })
  18210. return value, err
  18211. }
  18212. m.id = &id
  18213. }
  18214. }
  18215. // withMsg sets the old Msg of the mutation.
  18216. func withMsg(node *Msg) msgOption {
  18217. return func(m *MsgMutation) {
  18218. m.oldValue = func(context.Context) (*Msg, error) {
  18219. return node, nil
  18220. }
  18221. m.id = &node.ID
  18222. }
  18223. }
  18224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18225. // executed in a transaction (ent.Tx), a transactional client is returned.
  18226. func (m MsgMutation) Client() *Client {
  18227. client := &Client{config: m.config}
  18228. client.init()
  18229. return client
  18230. }
  18231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18232. // it returns an error otherwise.
  18233. func (m MsgMutation) Tx() (*Tx, error) {
  18234. if _, ok := m.driver.(*txDriver); !ok {
  18235. return nil, errors.New("ent: mutation is not running in a transaction")
  18236. }
  18237. tx := &Tx{config: m.config}
  18238. tx.init()
  18239. return tx, nil
  18240. }
  18241. // SetID sets the value of the id field. Note that this
  18242. // operation is only accepted on creation of Msg entities.
  18243. func (m *MsgMutation) SetID(id uint64) {
  18244. m.id = &id
  18245. }
  18246. // ID returns the ID value in the mutation. Note that the ID is only available
  18247. // if it was provided to the builder or after it was returned from the database.
  18248. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18249. if m.id == nil {
  18250. return
  18251. }
  18252. return *m.id, true
  18253. }
  18254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18255. // That means, if the mutation is applied within a transaction with an isolation level such
  18256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18257. // or updated by the mutation.
  18258. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18259. switch {
  18260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18261. id, exists := m.ID()
  18262. if exists {
  18263. return []uint64{id}, nil
  18264. }
  18265. fallthrough
  18266. case m.op.Is(OpUpdate | OpDelete):
  18267. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18268. default:
  18269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18270. }
  18271. }
  18272. // SetCreatedAt sets the "created_at" field.
  18273. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18274. m.created_at = &t
  18275. }
  18276. // CreatedAt returns the value of the "created_at" field in the mutation.
  18277. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18278. v := m.created_at
  18279. if v == nil {
  18280. return
  18281. }
  18282. return *v, true
  18283. }
  18284. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18285. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18287. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18288. if !m.op.Is(OpUpdateOne) {
  18289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18290. }
  18291. if m.id == nil || m.oldValue == nil {
  18292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18293. }
  18294. oldValue, err := m.oldValue(ctx)
  18295. if err != nil {
  18296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18297. }
  18298. return oldValue.CreatedAt, nil
  18299. }
  18300. // ResetCreatedAt resets all changes to the "created_at" field.
  18301. func (m *MsgMutation) ResetCreatedAt() {
  18302. m.created_at = nil
  18303. }
  18304. // SetUpdatedAt sets the "updated_at" field.
  18305. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18306. m.updated_at = &t
  18307. }
  18308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18309. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18310. v := m.updated_at
  18311. if v == nil {
  18312. return
  18313. }
  18314. return *v, true
  18315. }
  18316. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18317. // If the Msg 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 *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18320. if !m.op.Is(OpUpdateOne) {
  18321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18322. }
  18323. if m.id == nil || m.oldValue == nil {
  18324. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  18329. }
  18330. return oldValue.UpdatedAt, nil
  18331. }
  18332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18333. func (m *MsgMutation) ResetUpdatedAt() {
  18334. m.updated_at = nil
  18335. }
  18336. // SetDeletedAt sets the "deleted_at" field.
  18337. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18338. m.deleted_at = &t
  18339. }
  18340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18341. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18342. v := m.deleted_at
  18343. if v == nil {
  18344. return
  18345. }
  18346. return *v, true
  18347. }
  18348. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18349. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18351. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18352. if !m.op.Is(OpUpdateOne) {
  18353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18354. }
  18355. if m.id == nil || m.oldValue == nil {
  18356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18357. }
  18358. oldValue, err := m.oldValue(ctx)
  18359. if err != nil {
  18360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18361. }
  18362. return oldValue.DeletedAt, nil
  18363. }
  18364. // ClearDeletedAt clears the value of the "deleted_at" field.
  18365. func (m *MsgMutation) ClearDeletedAt() {
  18366. m.deleted_at = nil
  18367. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18368. }
  18369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18370. func (m *MsgMutation) DeletedAtCleared() bool {
  18371. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18372. return ok
  18373. }
  18374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18375. func (m *MsgMutation) ResetDeletedAt() {
  18376. m.deleted_at = nil
  18377. delete(m.clearedFields, msg.FieldDeletedAt)
  18378. }
  18379. // SetStatus sets the "status" field.
  18380. func (m *MsgMutation) SetStatus(u uint8) {
  18381. m.status = &u
  18382. m.addstatus = nil
  18383. }
  18384. // Status returns the value of the "status" field in the mutation.
  18385. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18386. v := m.status
  18387. if v == nil {
  18388. return
  18389. }
  18390. return *v, true
  18391. }
  18392. // OldStatus returns the old "status" field's value of the Msg entity.
  18393. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18395. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18396. if !m.op.Is(OpUpdateOne) {
  18397. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18398. }
  18399. if m.id == nil || m.oldValue == nil {
  18400. return v, errors.New("OldStatus requires an ID field in the mutation")
  18401. }
  18402. oldValue, err := m.oldValue(ctx)
  18403. if err != nil {
  18404. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18405. }
  18406. return oldValue.Status, nil
  18407. }
  18408. // AddStatus adds u to the "status" field.
  18409. func (m *MsgMutation) AddStatus(u int8) {
  18410. if m.addstatus != nil {
  18411. *m.addstatus += u
  18412. } else {
  18413. m.addstatus = &u
  18414. }
  18415. }
  18416. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18417. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18418. v := m.addstatus
  18419. if v == nil {
  18420. return
  18421. }
  18422. return *v, true
  18423. }
  18424. // ClearStatus clears the value of the "status" field.
  18425. func (m *MsgMutation) ClearStatus() {
  18426. m.status = nil
  18427. m.addstatus = nil
  18428. m.clearedFields[msg.FieldStatus] = struct{}{}
  18429. }
  18430. // StatusCleared returns if the "status" field was cleared in this mutation.
  18431. func (m *MsgMutation) StatusCleared() bool {
  18432. _, ok := m.clearedFields[msg.FieldStatus]
  18433. return ok
  18434. }
  18435. // ResetStatus resets all changes to the "status" field.
  18436. func (m *MsgMutation) ResetStatus() {
  18437. m.status = nil
  18438. m.addstatus = nil
  18439. delete(m.clearedFields, msg.FieldStatus)
  18440. }
  18441. // SetFromwxid sets the "fromwxid" field.
  18442. func (m *MsgMutation) SetFromwxid(s string) {
  18443. m.fromwxid = &s
  18444. }
  18445. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18446. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18447. v := m.fromwxid
  18448. if v == nil {
  18449. return
  18450. }
  18451. return *v, true
  18452. }
  18453. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18454. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18456. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18457. if !m.op.Is(OpUpdateOne) {
  18458. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18459. }
  18460. if m.id == nil || m.oldValue == nil {
  18461. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18462. }
  18463. oldValue, err := m.oldValue(ctx)
  18464. if err != nil {
  18465. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18466. }
  18467. return oldValue.Fromwxid, nil
  18468. }
  18469. // ClearFromwxid clears the value of the "fromwxid" field.
  18470. func (m *MsgMutation) ClearFromwxid() {
  18471. m.fromwxid = nil
  18472. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18473. }
  18474. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18475. func (m *MsgMutation) FromwxidCleared() bool {
  18476. _, ok := m.clearedFields[msg.FieldFromwxid]
  18477. return ok
  18478. }
  18479. // ResetFromwxid resets all changes to the "fromwxid" field.
  18480. func (m *MsgMutation) ResetFromwxid() {
  18481. m.fromwxid = nil
  18482. delete(m.clearedFields, msg.FieldFromwxid)
  18483. }
  18484. // SetToid sets the "toid" field.
  18485. func (m *MsgMutation) SetToid(s string) {
  18486. m.toid = &s
  18487. }
  18488. // Toid returns the value of the "toid" field in the mutation.
  18489. func (m *MsgMutation) Toid() (r string, exists bool) {
  18490. v := m.toid
  18491. if v == nil {
  18492. return
  18493. }
  18494. return *v, true
  18495. }
  18496. // OldToid returns the old "toid" field's value of the Msg entity.
  18497. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18499. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18500. if !m.op.Is(OpUpdateOne) {
  18501. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18502. }
  18503. if m.id == nil || m.oldValue == nil {
  18504. return v, errors.New("OldToid requires an ID field in the mutation")
  18505. }
  18506. oldValue, err := m.oldValue(ctx)
  18507. if err != nil {
  18508. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18509. }
  18510. return oldValue.Toid, nil
  18511. }
  18512. // ClearToid clears the value of the "toid" field.
  18513. func (m *MsgMutation) ClearToid() {
  18514. m.toid = nil
  18515. m.clearedFields[msg.FieldToid] = struct{}{}
  18516. }
  18517. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18518. func (m *MsgMutation) ToidCleared() bool {
  18519. _, ok := m.clearedFields[msg.FieldToid]
  18520. return ok
  18521. }
  18522. // ResetToid resets all changes to the "toid" field.
  18523. func (m *MsgMutation) ResetToid() {
  18524. m.toid = nil
  18525. delete(m.clearedFields, msg.FieldToid)
  18526. }
  18527. // SetMsgtype sets the "msgtype" field.
  18528. func (m *MsgMutation) SetMsgtype(i int32) {
  18529. m.msgtype = &i
  18530. m.addmsgtype = nil
  18531. }
  18532. // Msgtype returns the value of the "msgtype" field in the mutation.
  18533. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18534. v := m.msgtype
  18535. if v == nil {
  18536. return
  18537. }
  18538. return *v, true
  18539. }
  18540. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18541. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18543. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18544. if !m.op.Is(OpUpdateOne) {
  18545. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18546. }
  18547. if m.id == nil || m.oldValue == nil {
  18548. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18549. }
  18550. oldValue, err := m.oldValue(ctx)
  18551. if err != nil {
  18552. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18553. }
  18554. return oldValue.Msgtype, nil
  18555. }
  18556. // AddMsgtype adds i to the "msgtype" field.
  18557. func (m *MsgMutation) AddMsgtype(i int32) {
  18558. if m.addmsgtype != nil {
  18559. *m.addmsgtype += i
  18560. } else {
  18561. m.addmsgtype = &i
  18562. }
  18563. }
  18564. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18565. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18566. v := m.addmsgtype
  18567. if v == nil {
  18568. return
  18569. }
  18570. return *v, true
  18571. }
  18572. // ClearMsgtype clears the value of the "msgtype" field.
  18573. func (m *MsgMutation) ClearMsgtype() {
  18574. m.msgtype = nil
  18575. m.addmsgtype = nil
  18576. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18577. }
  18578. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18579. func (m *MsgMutation) MsgtypeCleared() bool {
  18580. _, ok := m.clearedFields[msg.FieldMsgtype]
  18581. return ok
  18582. }
  18583. // ResetMsgtype resets all changes to the "msgtype" field.
  18584. func (m *MsgMutation) ResetMsgtype() {
  18585. m.msgtype = nil
  18586. m.addmsgtype = nil
  18587. delete(m.clearedFields, msg.FieldMsgtype)
  18588. }
  18589. // SetMsg sets the "msg" field.
  18590. func (m *MsgMutation) SetMsg(s string) {
  18591. m.msg = &s
  18592. }
  18593. // Msg returns the value of the "msg" field in the mutation.
  18594. func (m *MsgMutation) Msg() (r string, exists bool) {
  18595. v := m.msg
  18596. if v == nil {
  18597. return
  18598. }
  18599. return *v, true
  18600. }
  18601. // OldMsg returns the old "msg" field's value of the Msg entity.
  18602. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18604. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18605. if !m.op.Is(OpUpdateOne) {
  18606. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18607. }
  18608. if m.id == nil || m.oldValue == nil {
  18609. return v, errors.New("OldMsg requires an ID field in the mutation")
  18610. }
  18611. oldValue, err := m.oldValue(ctx)
  18612. if err != nil {
  18613. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18614. }
  18615. return oldValue.Msg, nil
  18616. }
  18617. // ClearMsg clears the value of the "msg" field.
  18618. func (m *MsgMutation) ClearMsg() {
  18619. m.msg = nil
  18620. m.clearedFields[msg.FieldMsg] = struct{}{}
  18621. }
  18622. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18623. func (m *MsgMutation) MsgCleared() bool {
  18624. _, ok := m.clearedFields[msg.FieldMsg]
  18625. return ok
  18626. }
  18627. // ResetMsg resets all changes to the "msg" field.
  18628. func (m *MsgMutation) ResetMsg() {
  18629. m.msg = nil
  18630. delete(m.clearedFields, msg.FieldMsg)
  18631. }
  18632. // SetBatchNo sets the "batch_no" field.
  18633. func (m *MsgMutation) SetBatchNo(s string) {
  18634. m.batch_no = &s
  18635. }
  18636. // BatchNo returns the value of the "batch_no" field in the mutation.
  18637. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18638. v := m.batch_no
  18639. if v == nil {
  18640. return
  18641. }
  18642. return *v, true
  18643. }
  18644. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18645. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18647. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18648. if !m.op.Is(OpUpdateOne) {
  18649. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18650. }
  18651. if m.id == nil || m.oldValue == nil {
  18652. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18653. }
  18654. oldValue, err := m.oldValue(ctx)
  18655. if err != nil {
  18656. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18657. }
  18658. return oldValue.BatchNo, nil
  18659. }
  18660. // ClearBatchNo clears the value of the "batch_no" field.
  18661. func (m *MsgMutation) ClearBatchNo() {
  18662. m.batch_no = nil
  18663. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18664. }
  18665. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18666. func (m *MsgMutation) BatchNoCleared() bool {
  18667. _, ok := m.clearedFields[msg.FieldBatchNo]
  18668. return ok
  18669. }
  18670. // ResetBatchNo resets all changes to the "batch_no" field.
  18671. func (m *MsgMutation) ResetBatchNo() {
  18672. m.batch_no = nil
  18673. delete(m.clearedFields, msg.FieldBatchNo)
  18674. }
  18675. // Where appends a list predicates to the MsgMutation builder.
  18676. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18677. m.predicates = append(m.predicates, ps...)
  18678. }
  18679. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18680. // users can use type-assertion to append predicates that do not depend on any generated package.
  18681. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18682. p := make([]predicate.Msg, len(ps))
  18683. for i := range ps {
  18684. p[i] = ps[i]
  18685. }
  18686. m.Where(p...)
  18687. }
  18688. // Op returns the operation name.
  18689. func (m *MsgMutation) Op() Op {
  18690. return m.op
  18691. }
  18692. // SetOp allows setting the mutation operation.
  18693. func (m *MsgMutation) SetOp(op Op) {
  18694. m.op = op
  18695. }
  18696. // Type returns the node type of this mutation (Msg).
  18697. func (m *MsgMutation) Type() string {
  18698. return m.typ
  18699. }
  18700. // Fields returns all fields that were changed during this mutation. Note that in
  18701. // order to get all numeric fields that were incremented/decremented, call
  18702. // AddedFields().
  18703. func (m *MsgMutation) Fields() []string {
  18704. fields := make([]string, 0, 9)
  18705. if m.created_at != nil {
  18706. fields = append(fields, msg.FieldCreatedAt)
  18707. }
  18708. if m.updated_at != nil {
  18709. fields = append(fields, msg.FieldUpdatedAt)
  18710. }
  18711. if m.deleted_at != nil {
  18712. fields = append(fields, msg.FieldDeletedAt)
  18713. }
  18714. if m.status != nil {
  18715. fields = append(fields, msg.FieldStatus)
  18716. }
  18717. if m.fromwxid != nil {
  18718. fields = append(fields, msg.FieldFromwxid)
  18719. }
  18720. if m.toid != nil {
  18721. fields = append(fields, msg.FieldToid)
  18722. }
  18723. if m.msgtype != nil {
  18724. fields = append(fields, msg.FieldMsgtype)
  18725. }
  18726. if m.msg != nil {
  18727. fields = append(fields, msg.FieldMsg)
  18728. }
  18729. if m.batch_no != nil {
  18730. fields = append(fields, msg.FieldBatchNo)
  18731. }
  18732. return fields
  18733. }
  18734. // Field returns the value of a field with the given name. The second boolean
  18735. // return value indicates that this field was not set, or was not defined in the
  18736. // schema.
  18737. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18738. switch name {
  18739. case msg.FieldCreatedAt:
  18740. return m.CreatedAt()
  18741. case msg.FieldUpdatedAt:
  18742. return m.UpdatedAt()
  18743. case msg.FieldDeletedAt:
  18744. return m.DeletedAt()
  18745. case msg.FieldStatus:
  18746. return m.Status()
  18747. case msg.FieldFromwxid:
  18748. return m.Fromwxid()
  18749. case msg.FieldToid:
  18750. return m.Toid()
  18751. case msg.FieldMsgtype:
  18752. return m.Msgtype()
  18753. case msg.FieldMsg:
  18754. return m.Msg()
  18755. case msg.FieldBatchNo:
  18756. return m.BatchNo()
  18757. }
  18758. return nil, false
  18759. }
  18760. // OldField returns the old value of the field from the database. An error is
  18761. // returned if the mutation operation is not UpdateOne, or the query to the
  18762. // database failed.
  18763. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18764. switch name {
  18765. case msg.FieldCreatedAt:
  18766. return m.OldCreatedAt(ctx)
  18767. case msg.FieldUpdatedAt:
  18768. return m.OldUpdatedAt(ctx)
  18769. case msg.FieldDeletedAt:
  18770. return m.OldDeletedAt(ctx)
  18771. case msg.FieldStatus:
  18772. return m.OldStatus(ctx)
  18773. case msg.FieldFromwxid:
  18774. return m.OldFromwxid(ctx)
  18775. case msg.FieldToid:
  18776. return m.OldToid(ctx)
  18777. case msg.FieldMsgtype:
  18778. return m.OldMsgtype(ctx)
  18779. case msg.FieldMsg:
  18780. return m.OldMsg(ctx)
  18781. case msg.FieldBatchNo:
  18782. return m.OldBatchNo(ctx)
  18783. }
  18784. return nil, fmt.Errorf("unknown Msg field %s", name)
  18785. }
  18786. // SetField sets the value of a field with the given name. It returns an error if
  18787. // the field is not defined in the schema, or if the type mismatched the field
  18788. // type.
  18789. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18790. switch name {
  18791. case msg.FieldCreatedAt:
  18792. v, ok := value.(time.Time)
  18793. if !ok {
  18794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18795. }
  18796. m.SetCreatedAt(v)
  18797. return nil
  18798. case msg.FieldUpdatedAt:
  18799. v, ok := value.(time.Time)
  18800. if !ok {
  18801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18802. }
  18803. m.SetUpdatedAt(v)
  18804. return nil
  18805. case msg.FieldDeletedAt:
  18806. v, ok := value.(time.Time)
  18807. if !ok {
  18808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18809. }
  18810. m.SetDeletedAt(v)
  18811. return nil
  18812. case msg.FieldStatus:
  18813. v, ok := value.(uint8)
  18814. if !ok {
  18815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18816. }
  18817. m.SetStatus(v)
  18818. return nil
  18819. case msg.FieldFromwxid:
  18820. v, ok := value.(string)
  18821. if !ok {
  18822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18823. }
  18824. m.SetFromwxid(v)
  18825. return nil
  18826. case msg.FieldToid:
  18827. v, ok := value.(string)
  18828. if !ok {
  18829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18830. }
  18831. m.SetToid(v)
  18832. return nil
  18833. case msg.FieldMsgtype:
  18834. v, ok := value.(int32)
  18835. if !ok {
  18836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18837. }
  18838. m.SetMsgtype(v)
  18839. return nil
  18840. case msg.FieldMsg:
  18841. v, ok := value.(string)
  18842. if !ok {
  18843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18844. }
  18845. m.SetMsg(v)
  18846. return nil
  18847. case msg.FieldBatchNo:
  18848. v, ok := value.(string)
  18849. if !ok {
  18850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18851. }
  18852. m.SetBatchNo(v)
  18853. return nil
  18854. }
  18855. return fmt.Errorf("unknown Msg field %s", name)
  18856. }
  18857. // AddedFields returns all numeric fields that were incremented/decremented during
  18858. // this mutation.
  18859. func (m *MsgMutation) AddedFields() []string {
  18860. var fields []string
  18861. if m.addstatus != nil {
  18862. fields = append(fields, msg.FieldStatus)
  18863. }
  18864. if m.addmsgtype != nil {
  18865. fields = append(fields, msg.FieldMsgtype)
  18866. }
  18867. return fields
  18868. }
  18869. // AddedField returns the numeric value that was incremented/decremented on a field
  18870. // with the given name. The second boolean return value indicates that this field
  18871. // was not set, or was not defined in the schema.
  18872. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18873. switch name {
  18874. case msg.FieldStatus:
  18875. return m.AddedStatus()
  18876. case msg.FieldMsgtype:
  18877. return m.AddedMsgtype()
  18878. }
  18879. return nil, false
  18880. }
  18881. // AddField adds the value to the field with the given name. It returns an error if
  18882. // the field is not defined in the schema, or if the type mismatched the field
  18883. // type.
  18884. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18885. switch name {
  18886. case msg.FieldStatus:
  18887. v, ok := value.(int8)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.AddStatus(v)
  18892. return nil
  18893. case msg.FieldMsgtype:
  18894. v, ok := value.(int32)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.AddMsgtype(v)
  18899. return nil
  18900. }
  18901. return fmt.Errorf("unknown Msg numeric field %s", name)
  18902. }
  18903. // ClearedFields returns all nullable fields that were cleared during this
  18904. // mutation.
  18905. func (m *MsgMutation) ClearedFields() []string {
  18906. var fields []string
  18907. if m.FieldCleared(msg.FieldDeletedAt) {
  18908. fields = append(fields, msg.FieldDeletedAt)
  18909. }
  18910. if m.FieldCleared(msg.FieldStatus) {
  18911. fields = append(fields, msg.FieldStatus)
  18912. }
  18913. if m.FieldCleared(msg.FieldFromwxid) {
  18914. fields = append(fields, msg.FieldFromwxid)
  18915. }
  18916. if m.FieldCleared(msg.FieldToid) {
  18917. fields = append(fields, msg.FieldToid)
  18918. }
  18919. if m.FieldCleared(msg.FieldMsgtype) {
  18920. fields = append(fields, msg.FieldMsgtype)
  18921. }
  18922. if m.FieldCleared(msg.FieldMsg) {
  18923. fields = append(fields, msg.FieldMsg)
  18924. }
  18925. if m.FieldCleared(msg.FieldBatchNo) {
  18926. fields = append(fields, msg.FieldBatchNo)
  18927. }
  18928. return fields
  18929. }
  18930. // FieldCleared returns a boolean indicating if a field with the given name was
  18931. // cleared in this mutation.
  18932. func (m *MsgMutation) FieldCleared(name string) bool {
  18933. _, ok := m.clearedFields[name]
  18934. return ok
  18935. }
  18936. // ClearField clears the value of the field with the given name. It returns an
  18937. // error if the field is not defined in the schema.
  18938. func (m *MsgMutation) ClearField(name string) error {
  18939. switch name {
  18940. case msg.FieldDeletedAt:
  18941. m.ClearDeletedAt()
  18942. return nil
  18943. case msg.FieldStatus:
  18944. m.ClearStatus()
  18945. return nil
  18946. case msg.FieldFromwxid:
  18947. m.ClearFromwxid()
  18948. return nil
  18949. case msg.FieldToid:
  18950. m.ClearToid()
  18951. return nil
  18952. case msg.FieldMsgtype:
  18953. m.ClearMsgtype()
  18954. return nil
  18955. case msg.FieldMsg:
  18956. m.ClearMsg()
  18957. return nil
  18958. case msg.FieldBatchNo:
  18959. m.ClearBatchNo()
  18960. return nil
  18961. }
  18962. return fmt.Errorf("unknown Msg nullable field %s", name)
  18963. }
  18964. // ResetField resets all changes in the mutation for the field with the given name.
  18965. // It returns an error if the field is not defined in the schema.
  18966. func (m *MsgMutation) ResetField(name string) error {
  18967. switch name {
  18968. case msg.FieldCreatedAt:
  18969. m.ResetCreatedAt()
  18970. return nil
  18971. case msg.FieldUpdatedAt:
  18972. m.ResetUpdatedAt()
  18973. return nil
  18974. case msg.FieldDeletedAt:
  18975. m.ResetDeletedAt()
  18976. return nil
  18977. case msg.FieldStatus:
  18978. m.ResetStatus()
  18979. return nil
  18980. case msg.FieldFromwxid:
  18981. m.ResetFromwxid()
  18982. return nil
  18983. case msg.FieldToid:
  18984. m.ResetToid()
  18985. return nil
  18986. case msg.FieldMsgtype:
  18987. m.ResetMsgtype()
  18988. return nil
  18989. case msg.FieldMsg:
  18990. m.ResetMsg()
  18991. return nil
  18992. case msg.FieldBatchNo:
  18993. m.ResetBatchNo()
  18994. return nil
  18995. }
  18996. return fmt.Errorf("unknown Msg field %s", name)
  18997. }
  18998. // AddedEdges returns all edge names that were set/added in this mutation.
  18999. func (m *MsgMutation) AddedEdges() []string {
  19000. edges := make([]string, 0, 0)
  19001. return edges
  19002. }
  19003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19004. // name in this mutation.
  19005. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19006. return nil
  19007. }
  19008. // RemovedEdges returns all edge names that were removed in this mutation.
  19009. func (m *MsgMutation) RemovedEdges() []string {
  19010. edges := make([]string, 0, 0)
  19011. return edges
  19012. }
  19013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19014. // the given name in this mutation.
  19015. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19016. return nil
  19017. }
  19018. // ClearedEdges returns all edge names that were cleared in this mutation.
  19019. func (m *MsgMutation) ClearedEdges() []string {
  19020. edges := make([]string, 0, 0)
  19021. return edges
  19022. }
  19023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19024. // was cleared in this mutation.
  19025. func (m *MsgMutation) EdgeCleared(name string) bool {
  19026. return false
  19027. }
  19028. // ClearEdge clears the value of the edge with the given name. It returns an error
  19029. // if that edge is not defined in the schema.
  19030. func (m *MsgMutation) ClearEdge(name string) error {
  19031. return fmt.Errorf("unknown Msg unique edge %s", name)
  19032. }
  19033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19034. // It returns an error if the edge is not defined in the schema.
  19035. func (m *MsgMutation) ResetEdge(name string) error {
  19036. return fmt.Errorf("unknown Msg edge %s", name)
  19037. }
  19038. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19039. type PayRechargeMutation struct {
  19040. config
  19041. op Op
  19042. typ string
  19043. id *uint64
  19044. created_at *time.Time
  19045. updated_at *time.Time
  19046. deleted_at *time.Time
  19047. user_id *string
  19048. number *float32
  19049. addnumber *float32
  19050. status *int
  19051. addstatus *int
  19052. money *float32
  19053. addmoney *float32
  19054. out_trade_no *string
  19055. organization_id *uint64
  19056. addorganization_id *int64
  19057. clearedFields map[string]struct{}
  19058. done bool
  19059. oldValue func(context.Context) (*PayRecharge, error)
  19060. predicates []predicate.PayRecharge
  19061. }
  19062. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19063. // payrechargeOption allows management of the mutation configuration using functional options.
  19064. type payrechargeOption func(*PayRechargeMutation)
  19065. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19066. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19067. m := &PayRechargeMutation{
  19068. config: c,
  19069. op: op,
  19070. typ: TypePayRecharge,
  19071. clearedFields: make(map[string]struct{}),
  19072. }
  19073. for _, opt := range opts {
  19074. opt(m)
  19075. }
  19076. return m
  19077. }
  19078. // withPayRechargeID sets the ID field of the mutation.
  19079. func withPayRechargeID(id uint64) payrechargeOption {
  19080. return func(m *PayRechargeMutation) {
  19081. var (
  19082. err error
  19083. once sync.Once
  19084. value *PayRecharge
  19085. )
  19086. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19087. once.Do(func() {
  19088. if m.done {
  19089. err = errors.New("querying old values post mutation is not allowed")
  19090. } else {
  19091. value, err = m.Client().PayRecharge.Get(ctx, id)
  19092. }
  19093. })
  19094. return value, err
  19095. }
  19096. m.id = &id
  19097. }
  19098. }
  19099. // withPayRecharge sets the old PayRecharge of the mutation.
  19100. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19101. return func(m *PayRechargeMutation) {
  19102. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19103. return node, nil
  19104. }
  19105. m.id = &node.ID
  19106. }
  19107. }
  19108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19109. // executed in a transaction (ent.Tx), a transactional client is returned.
  19110. func (m PayRechargeMutation) Client() *Client {
  19111. client := &Client{config: m.config}
  19112. client.init()
  19113. return client
  19114. }
  19115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19116. // it returns an error otherwise.
  19117. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19118. if _, ok := m.driver.(*txDriver); !ok {
  19119. return nil, errors.New("ent: mutation is not running in a transaction")
  19120. }
  19121. tx := &Tx{config: m.config}
  19122. tx.init()
  19123. return tx, nil
  19124. }
  19125. // SetID sets the value of the id field. Note that this
  19126. // operation is only accepted on creation of PayRecharge entities.
  19127. func (m *PayRechargeMutation) SetID(id uint64) {
  19128. m.id = &id
  19129. }
  19130. // ID returns the ID value in the mutation. Note that the ID is only available
  19131. // if it was provided to the builder or after it was returned from the database.
  19132. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19133. if m.id == nil {
  19134. return
  19135. }
  19136. return *m.id, true
  19137. }
  19138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19139. // That means, if the mutation is applied within a transaction with an isolation level such
  19140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19141. // or updated by the mutation.
  19142. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19143. switch {
  19144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19145. id, exists := m.ID()
  19146. if exists {
  19147. return []uint64{id}, nil
  19148. }
  19149. fallthrough
  19150. case m.op.Is(OpUpdate | OpDelete):
  19151. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19152. default:
  19153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19154. }
  19155. }
  19156. // SetCreatedAt sets the "created_at" field.
  19157. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19158. m.created_at = &t
  19159. }
  19160. // CreatedAt returns the value of the "created_at" field in the mutation.
  19161. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19162. v := m.created_at
  19163. if v == nil {
  19164. return
  19165. }
  19166. return *v, true
  19167. }
  19168. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19169. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19171. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19172. if !m.op.Is(OpUpdateOne) {
  19173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19174. }
  19175. if m.id == nil || m.oldValue == nil {
  19176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19177. }
  19178. oldValue, err := m.oldValue(ctx)
  19179. if err != nil {
  19180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19181. }
  19182. return oldValue.CreatedAt, nil
  19183. }
  19184. // ResetCreatedAt resets all changes to the "created_at" field.
  19185. func (m *PayRechargeMutation) ResetCreatedAt() {
  19186. m.created_at = nil
  19187. }
  19188. // SetUpdatedAt sets the "updated_at" field.
  19189. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19190. m.updated_at = &t
  19191. }
  19192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19193. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19194. v := m.updated_at
  19195. if v == nil {
  19196. return
  19197. }
  19198. return *v, true
  19199. }
  19200. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19201. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19203. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19204. if !m.op.Is(OpUpdateOne) {
  19205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19206. }
  19207. if m.id == nil || m.oldValue == nil {
  19208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19209. }
  19210. oldValue, err := m.oldValue(ctx)
  19211. if err != nil {
  19212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19213. }
  19214. return oldValue.UpdatedAt, nil
  19215. }
  19216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19217. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19218. m.updated_at = nil
  19219. }
  19220. // SetDeletedAt sets the "deleted_at" field.
  19221. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19222. m.deleted_at = &t
  19223. }
  19224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19225. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19226. v := m.deleted_at
  19227. if v == nil {
  19228. return
  19229. }
  19230. return *v, true
  19231. }
  19232. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19233. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19235. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19236. if !m.op.Is(OpUpdateOne) {
  19237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19238. }
  19239. if m.id == nil || m.oldValue == nil {
  19240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19241. }
  19242. oldValue, err := m.oldValue(ctx)
  19243. if err != nil {
  19244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19245. }
  19246. return oldValue.DeletedAt, nil
  19247. }
  19248. // ClearDeletedAt clears the value of the "deleted_at" field.
  19249. func (m *PayRechargeMutation) ClearDeletedAt() {
  19250. m.deleted_at = nil
  19251. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19252. }
  19253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19254. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19255. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19256. return ok
  19257. }
  19258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19259. func (m *PayRechargeMutation) ResetDeletedAt() {
  19260. m.deleted_at = nil
  19261. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19262. }
  19263. // SetUserID sets the "user_id" field.
  19264. func (m *PayRechargeMutation) SetUserID(s string) {
  19265. m.user_id = &s
  19266. }
  19267. // UserID returns the value of the "user_id" field in the mutation.
  19268. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19269. v := m.user_id
  19270. if v == nil {
  19271. return
  19272. }
  19273. return *v, true
  19274. }
  19275. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19276. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19278. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19279. if !m.op.Is(OpUpdateOne) {
  19280. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19281. }
  19282. if m.id == nil || m.oldValue == nil {
  19283. return v, errors.New("OldUserID requires an ID field in the mutation")
  19284. }
  19285. oldValue, err := m.oldValue(ctx)
  19286. if err != nil {
  19287. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19288. }
  19289. return oldValue.UserID, nil
  19290. }
  19291. // ResetUserID resets all changes to the "user_id" field.
  19292. func (m *PayRechargeMutation) ResetUserID() {
  19293. m.user_id = nil
  19294. }
  19295. // SetNumber sets the "number" field.
  19296. func (m *PayRechargeMutation) SetNumber(f float32) {
  19297. m.number = &f
  19298. m.addnumber = nil
  19299. }
  19300. // Number returns the value of the "number" field in the mutation.
  19301. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19302. v := m.number
  19303. if v == nil {
  19304. return
  19305. }
  19306. return *v, true
  19307. }
  19308. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19309. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19311. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19312. if !m.op.Is(OpUpdateOne) {
  19313. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19314. }
  19315. if m.id == nil || m.oldValue == nil {
  19316. return v, errors.New("OldNumber requires an ID field in the mutation")
  19317. }
  19318. oldValue, err := m.oldValue(ctx)
  19319. if err != nil {
  19320. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19321. }
  19322. return oldValue.Number, nil
  19323. }
  19324. // AddNumber adds f to the "number" field.
  19325. func (m *PayRechargeMutation) AddNumber(f float32) {
  19326. if m.addnumber != nil {
  19327. *m.addnumber += f
  19328. } else {
  19329. m.addnumber = &f
  19330. }
  19331. }
  19332. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19333. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19334. v := m.addnumber
  19335. if v == nil {
  19336. return
  19337. }
  19338. return *v, true
  19339. }
  19340. // ResetNumber resets all changes to the "number" field.
  19341. func (m *PayRechargeMutation) ResetNumber() {
  19342. m.number = nil
  19343. m.addnumber = nil
  19344. }
  19345. // SetStatus sets the "status" field.
  19346. func (m *PayRechargeMutation) SetStatus(i int) {
  19347. m.status = &i
  19348. m.addstatus = nil
  19349. }
  19350. // Status returns the value of the "status" field in the mutation.
  19351. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19352. v := m.status
  19353. if v == nil {
  19354. return
  19355. }
  19356. return *v, true
  19357. }
  19358. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19359. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19361. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19362. if !m.op.Is(OpUpdateOne) {
  19363. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19364. }
  19365. if m.id == nil || m.oldValue == nil {
  19366. return v, errors.New("OldStatus requires an ID field in the mutation")
  19367. }
  19368. oldValue, err := m.oldValue(ctx)
  19369. if err != nil {
  19370. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19371. }
  19372. return oldValue.Status, nil
  19373. }
  19374. // AddStatus adds i to the "status" field.
  19375. func (m *PayRechargeMutation) AddStatus(i int) {
  19376. if m.addstatus != nil {
  19377. *m.addstatus += i
  19378. } else {
  19379. m.addstatus = &i
  19380. }
  19381. }
  19382. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19383. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19384. v := m.addstatus
  19385. if v == nil {
  19386. return
  19387. }
  19388. return *v, true
  19389. }
  19390. // ClearStatus clears the value of the "status" field.
  19391. func (m *PayRechargeMutation) ClearStatus() {
  19392. m.status = nil
  19393. m.addstatus = nil
  19394. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19395. }
  19396. // StatusCleared returns if the "status" field was cleared in this mutation.
  19397. func (m *PayRechargeMutation) StatusCleared() bool {
  19398. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19399. return ok
  19400. }
  19401. // ResetStatus resets all changes to the "status" field.
  19402. func (m *PayRechargeMutation) ResetStatus() {
  19403. m.status = nil
  19404. m.addstatus = nil
  19405. delete(m.clearedFields, payrecharge.FieldStatus)
  19406. }
  19407. // SetMoney sets the "money" field.
  19408. func (m *PayRechargeMutation) SetMoney(f float32) {
  19409. m.money = &f
  19410. m.addmoney = nil
  19411. }
  19412. // Money returns the value of the "money" field in the mutation.
  19413. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19414. v := m.money
  19415. if v == nil {
  19416. return
  19417. }
  19418. return *v, true
  19419. }
  19420. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19421. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19423. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19424. if !m.op.Is(OpUpdateOne) {
  19425. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19426. }
  19427. if m.id == nil || m.oldValue == nil {
  19428. return v, errors.New("OldMoney requires an ID field in the mutation")
  19429. }
  19430. oldValue, err := m.oldValue(ctx)
  19431. if err != nil {
  19432. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19433. }
  19434. return oldValue.Money, nil
  19435. }
  19436. // AddMoney adds f to the "money" field.
  19437. func (m *PayRechargeMutation) AddMoney(f float32) {
  19438. if m.addmoney != nil {
  19439. *m.addmoney += f
  19440. } else {
  19441. m.addmoney = &f
  19442. }
  19443. }
  19444. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19445. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19446. v := m.addmoney
  19447. if v == nil {
  19448. return
  19449. }
  19450. return *v, true
  19451. }
  19452. // ClearMoney clears the value of the "money" field.
  19453. func (m *PayRechargeMutation) ClearMoney() {
  19454. m.money = nil
  19455. m.addmoney = nil
  19456. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19457. }
  19458. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19459. func (m *PayRechargeMutation) MoneyCleared() bool {
  19460. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19461. return ok
  19462. }
  19463. // ResetMoney resets all changes to the "money" field.
  19464. func (m *PayRechargeMutation) ResetMoney() {
  19465. m.money = nil
  19466. m.addmoney = nil
  19467. delete(m.clearedFields, payrecharge.FieldMoney)
  19468. }
  19469. // SetOutTradeNo sets the "out_trade_no" field.
  19470. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19471. m.out_trade_no = &s
  19472. }
  19473. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19474. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19475. v := m.out_trade_no
  19476. if v == nil {
  19477. return
  19478. }
  19479. return *v, true
  19480. }
  19481. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19482. // If the PayRecharge 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 *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19485. if !m.op.Is(OpUpdateOne) {
  19486. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19487. }
  19488. if m.id == nil || m.oldValue == nil {
  19489. return v, errors.New("OldOutTradeNo 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 OldOutTradeNo: %w", err)
  19494. }
  19495. return oldValue.OutTradeNo, nil
  19496. }
  19497. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19498. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19499. m.out_trade_no = nil
  19500. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19501. }
  19502. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19503. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19504. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19505. return ok
  19506. }
  19507. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19508. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19509. m.out_trade_no = nil
  19510. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19511. }
  19512. // SetOrganizationID sets the "organization_id" field.
  19513. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19514. m.organization_id = &u
  19515. m.addorganization_id = nil
  19516. }
  19517. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19518. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19519. v := m.organization_id
  19520. if v == nil {
  19521. return
  19522. }
  19523. return *v, true
  19524. }
  19525. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19526. // If the PayRecharge 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 *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19529. if !m.op.Is(OpUpdateOne) {
  19530. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19531. }
  19532. if m.id == nil || m.oldValue == nil {
  19533. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  19538. }
  19539. return oldValue.OrganizationID, nil
  19540. }
  19541. // AddOrganizationID adds u to the "organization_id" field.
  19542. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19543. if m.addorganization_id != nil {
  19544. *m.addorganization_id += u
  19545. } else {
  19546. m.addorganization_id = &u
  19547. }
  19548. }
  19549. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19550. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19551. v := m.addorganization_id
  19552. if v == nil {
  19553. return
  19554. }
  19555. return *v, true
  19556. }
  19557. // ResetOrganizationID resets all changes to the "organization_id" field.
  19558. func (m *PayRechargeMutation) ResetOrganizationID() {
  19559. m.organization_id = nil
  19560. m.addorganization_id = nil
  19561. }
  19562. // Where appends a list predicates to the PayRechargeMutation builder.
  19563. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19564. m.predicates = append(m.predicates, ps...)
  19565. }
  19566. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19567. // users can use type-assertion to append predicates that do not depend on any generated package.
  19568. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19569. p := make([]predicate.PayRecharge, len(ps))
  19570. for i := range ps {
  19571. p[i] = ps[i]
  19572. }
  19573. m.Where(p...)
  19574. }
  19575. // Op returns the operation name.
  19576. func (m *PayRechargeMutation) Op() Op {
  19577. return m.op
  19578. }
  19579. // SetOp allows setting the mutation operation.
  19580. func (m *PayRechargeMutation) SetOp(op Op) {
  19581. m.op = op
  19582. }
  19583. // Type returns the node type of this mutation (PayRecharge).
  19584. func (m *PayRechargeMutation) Type() string {
  19585. return m.typ
  19586. }
  19587. // Fields returns all fields that were changed during this mutation. Note that in
  19588. // order to get all numeric fields that were incremented/decremented, call
  19589. // AddedFields().
  19590. func (m *PayRechargeMutation) Fields() []string {
  19591. fields := make([]string, 0, 9)
  19592. if m.created_at != nil {
  19593. fields = append(fields, payrecharge.FieldCreatedAt)
  19594. }
  19595. if m.updated_at != nil {
  19596. fields = append(fields, payrecharge.FieldUpdatedAt)
  19597. }
  19598. if m.deleted_at != nil {
  19599. fields = append(fields, payrecharge.FieldDeletedAt)
  19600. }
  19601. if m.user_id != nil {
  19602. fields = append(fields, payrecharge.FieldUserID)
  19603. }
  19604. if m.number != nil {
  19605. fields = append(fields, payrecharge.FieldNumber)
  19606. }
  19607. if m.status != nil {
  19608. fields = append(fields, payrecharge.FieldStatus)
  19609. }
  19610. if m.money != nil {
  19611. fields = append(fields, payrecharge.FieldMoney)
  19612. }
  19613. if m.out_trade_no != nil {
  19614. fields = append(fields, payrecharge.FieldOutTradeNo)
  19615. }
  19616. if m.organization_id != nil {
  19617. fields = append(fields, payrecharge.FieldOrganizationID)
  19618. }
  19619. return fields
  19620. }
  19621. // Field returns the value of a field with the given name. The second boolean
  19622. // return value indicates that this field was not set, or was not defined in the
  19623. // schema.
  19624. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19625. switch name {
  19626. case payrecharge.FieldCreatedAt:
  19627. return m.CreatedAt()
  19628. case payrecharge.FieldUpdatedAt:
  19629. return m.UpdatedAt()
  19630. case payrecharge.FieldDeletedAt:
  19631. return m.DeletedAt()
  19632. case payrecharge.FieldUserID:
  19633. return m.UserID()
  19634. case payrecharge.FieldNumber:
  19635. return m.Number()
  19636. case payrecharge.FieldStatus:
  19637. return m.Status()
  19638. case payrecharge.FieldMoney:
  19639. return m.Money()
  19640. case payrecharge.FieldOutTradeNo:
  19641. return m.OutTradeNo()
  19642. case payrecharge.FieldOrganizationID:
  19643. return m.OrganizationID()
  19644. }
  19645. return nil, false
  19646. }
  19647. // OldField returns the old value of the field from the database. An error is
  19648. // returned if the mutation operation is not UpdateOne, or the query to the
  19649. // database failed.
  19650. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19651. switch name {
  19652. case payrecharge.FieldCreatedAt:
  19653. return m.OldCreatedAt(ctx)
  19654. case payrecharge.FieldUpdatedAt:
  19655. return m.OldUpdatedAt(ctx)
  19656. case payrecharge.FieldDeletedAt:
  19657. return m.OldDeletedAt(ctx)
  19658. case payrecharge.FieldUserID:
  19659. return m.OldUserID(ctx)
  19660. case payrecharge.FieldNumber:
  19661. return m.OldNumber(ctx)
  19662. case payrecharge.FieldStatus:
  19663. return m.OldStatus(ctx)
  19664. case payrecharge.FieldMoney:
  19665. return m.OldMoney(ctx)
  19666. case payrecharge.FieldOutTradeNo:
  19667. return m.OldOutTradeNo(ctx)
  19668. case payrecharge.FieldOrganizationID:
  19669. return m.OldOrganizationID(ctx)
  19670. }
  19671. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19672. }
  19673. // SetField sets the value of a field with the given name. It returns an error if
  19674. // the field is not defined in the schema, or if the type mismatched the field
  19675. // type.
  19676. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19677. switch name {
  19678. case payrecharge.FieldCreatedAt:
  19679. v, ok := value.(time.Time)
  19680. if !ok {
  19681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19682. }
  19683. m.SetCreatedAt(v)
  19684. return nil
  19685. case payrecharge.FieldUpdatedAt:
  19686. v, ok := value.(time.Time)
  19687. if !ok {
  19688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19689. }
  19690. m.SetUpdatedAt(v)
  19691. return nil
  19692. case payrecharge.FieldDeletedAt:
  19693. v, ok := value.(time.Time)
  19694. if !ok {
  19695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19696. }
  19697. m.SetDeletedAt(v)
  19698. return nil
  19699. case payrecharge.FieldUserID:
  19700. v, ok := value.(string)
  19701. if !ok {
  19702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19703. }
  19704. m.SetUserID(v)
  19705. return nil
  19706. case payrecharge.FieldNumber:
  19707. v, ok := value.(float32)
  19708. if !ok {
  19709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19710. }
  19711. m.SetNumber(v)
  19712. return nil
  19713. case payrecharge.FieldStatus:
  19714. v, ok := value.(int)
  19715. if !ok {
  19716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19717. }
  19718. m.SetStatus(v)
  19719. return nil
  19720. case payrecharge.FieldMoney:
  19721. v, ok := value.(float32)
  19722. if !ok {
  19723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19724. }
  19725. m.SetMoney(v)
  19726. return nil
  19727. case payrecharge.FieldOutTradeNo:
  19728. v, ok := value.(string)
  19729. if !ok {
  19730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19731. }
  19732. m.SetOutTradeNo(v)
  19733. return nil
  19734. case payrecharge.FieldOrganizationID:
  19735. v, ok := value.(uint64)
  19736. if !ok {
  19737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19738. }
  19739. m.SetOrganizationID(v)
  19740. return nil
  19741. }
  19742. return fmt.Errorf("unknown PayRecharge field %s", name)
  19743. }
  19744. // AddedFields returns all numeric fields that were incremented/decremented during
  19745. // this mutation.
  19746. func (m *PayRechargeMutation) AddedFields() []string {
  19747. var fields []string
  19748. if m.addnumber != nil {
  19749. fields = append(fields, payrecharge.FieldNumber)
  19750. }
  19751. if m.addstatus != nil {
  19752. fields = append(fields, payrecharge.FieldStatus)
  19753. }
  19754. if m.addmoney != nil {
  19755. fields = append(fields, payrecharge.FieldMoney)
  19756. }
  19757. if m.addorganization_id != nil {
  19758. fields = append(fields, payrecharge.FieldOrganizationID)
  19759. }
  19760. return fields
  19761. }
  19762. // AddedField returns the numeric value that was incremented/decremented on a field
  19763. // with the given name. The second boolean return value indicates that this field
  19764. // was not set, or was not defined in the schema.
  19765. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19766. switch name {
  19767. case payrecharge.FieldNumber:
  19768. return m.AddedNumber()
  19769. case payrecharge.FieldStatus:
  19770. return m.AddedStatus()
  19771. case payrecharge.FieldMoney:
  19772. return m.AddedMoney()
  19773. case payrecharge.FieldOrganizationID:
  19774. return m.AddedOrganizationID()
  19775. }
  19776. return nil, false
  19777. }
  19778. // AddField adds the value to the field with the given name. It returns an error if
  19779. // the field is not defined in the schema, or if the type mismatched the field
  19780. // type.
  19781. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19782. switch name {
  19783. case payrecharge.FieldNumber:
  19784. v, ok := value.(float32)
  19785. if !ok {
  19786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19787. }
  19788. m.AddNumber(v)
  19789. return nil
  19790. case payrecharge.FieldStatus:
  19791. v, ok := value.(int)
  19792. if !ok {
  19793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19794. }
  19795. m.AddStatus(v)
  19796. return nil
  19797. case payrecharge.FieldMoney:
  19798. v, ok := value.(float32)
  19799. if !ok {
  19800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19801. }
  19802. m.AddMoney(v)
  19803. return nil
  19804. case payrecharge.FieldOrganizationID:
  19805. v, ok := value.(int64)
  19806. if !ok {
  19807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19808. }
  19809. m.AddOrganizationID(v)
  19810. return nil
  19811. }
  19812. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19813. }
  19814. // ClearedFields returns all nullable fields that were cleared during this
  19815. // mutation.
  19816. func (m *PayRechargeMutation) ClearedFields() []string {
  19817. var fields []string
  19818. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19819. fields = append(fields, payrecharge.FieldDeletedAt)
  19820. }
  19821. if m.FieldCleared(payrecharge.FieldStatus) {
  19822. fields = append(fields, payrecharge.FieldStatus)
  19823. }
  19824. if m.FieldCleared(payrecharge.FieldMoney) {
  19825. fields = append(fields, payrecharge.FieldMoney)
  19826. }
  19827. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19828. fields = append(fields, payrecharge.FieldOutTradeNo)
  19829. }
  19830. return fields
  19831. }
  19832. // FieldCleared returns a boolean indicating if a field with the given name was
  19833. // cleared in this mutation.
  19834. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19835. _, ok := m.clearedFields[name]
  19836. return ok
  19837. }
  19838. // ClearField clears the value of the field with the given name. It returns an
  19839. // error if the field is not defined in the schema.
  19840. func (m *PayRechargeMutation) ClearField(name string) error {
  19841. switch name {
  19842. case payrecharge.FieldDeletedAt:
  19843. m.ClearDeletedAt()
  19844. return nil
  19845. case payrecharge.FieldStatus:
  19846. m.ClearStatus()
  19847. return nil
  19848. case payrecharge.FieldMoney:
  19849. m.ClearMoney()
  19850. return nil
  19851. case payrecharge.FieldOutTradeNo:
  19852. m.ClearOutTradeNo()
  19853. return nil
  19854. }
  19855. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19856. }
  19857. // ResetField resets all changes in the mutation for the field with the given name.
  19858. // It returns an error if the field is not defined in the schema.
  19859. func (m *PayRechargeMutation) ResetField(name string) error {
  19860. switch name {
  19861. case payrecharge.FieldCreatedAt:
  19862. m.ResetCreatedAt()
  19863. return nil
  19864. case payrecharge.FieldUpdatedAt:
  19865. m.ResetUpdatedAt()
  19866. return nil
  19867. case payrecharge.FieldDeletedAt:
  19868. m.ResetDeletedAt()
  19869. return nil
  19870. case payrecharge.FieldUserID:
  19871. m.ResetUserID()
  19872. return nil
  19873. case payrecharge.FieldNumber:
  19874. m.ResetNumber()
  19875. return nil
  19876. case payrecharge.FieldStatus:
  19877. m.ResetStatus()
  19878. return nil
  19879. case payrecharge.FieldMoney:
  19880. m.ResetMoney()
  19881. return nil
  19882. case payrecharge.FieldOutTradeNo:
  19883. m.ResetOutTradeNo()
  19884. return nil
  19885. case payrecharge.FieldOrganizationID:
  19886. m.ResetOrganizationID()
  19887. return nil
  19888. }
  19889. return fmt.Errorf("unknown PayRecharge field %s", name)
  19890. }
  19891. // AddedEdges returns all edge names that were set/added in this mutation.
  19892. func (m *PayRechargeMutation) AddedEdges() []string {
  19893. edges := make([]string, 0, 0)
  19894. return edges
  19895. }
  19896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19897. // name in this mutation.
  19898. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19899. return nil
  19900. }
  19901. // RemovedEdges returns all edge names that were removed in this mutation.
  19902. func (m *PayRechargeMutation) RemovedEdges() []string {
  19903. edges := make([]string, 0, 0)
  19904. return edges
  19905. }
  19906. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19907. // the given name in this mutation.
  19908. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19909. return nil
  19910. }
  19911. // ClearedEdges returns all edge names that were cleared in this mutation.
  19912. func (m *PayRechargeMutation) ClearedEdges() []string {
  19913. edges := make([]string, 0, 0)
  19914. return edges
  19915. }
  19916. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19917. // was cleared in this mutation.
  19918. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19919. return false
  19920. }
  19921. // ClearEdge clears the value of the edge with the given name. It returns an error
  19922. // if that edge is not defined in the schema.
  19923. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19924. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19925. }
  19926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19927. // It returns an error if the edge is not defined in the schema.
  19928. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19929. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19930. }
  19931. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19932. type ServerMutation struct {
  19933. config
  19934. op Op
  19935. typ string
  19936. id *uint64
  19937. created_at *time.Time
  19938. updated_at *time.Time
  19939. status *uint8
  19940. addstatus *int8
  19941. deleted_at *time.Time
  19942. name *string
  19943. public_ip *string
  19944. private_ip *string
  19945. admin_port *string
  19946. clearedFields map[string]struct{}
  19947. wxs map[uint64]struct{}
  19948. removedwxs map[uint64]struct{}
  19949. clearedwxs bool
  19950. done bool
  19951. oldValue func(context.Context) (*Server, error)
  19952. predicates []predicate.Server
  19953. }
  19954. var _ ent.Mutation = (*ServerMutation)(nil)
  19955. // serverOption allows management of the mutation configuration using functional options.
  19956. type serverOption func(*ServerMutation)
  19957. // newServerMutation creates new mutation for the Server entity.
  19958. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19959. m := &ServerMutation{
  19960. config: c,
  19961. op: op,
  19962. typ: TypeServer,
  19963. clearedFields: make(map[string]struct{}),
  19964. }
  19965. for _, opt := range opts {
  19966. opt(m)
  19967. }
  19968. return m
  19969. }
  19970. // withServerID sets the ID field of the mutation.
  19971. func withServerID(id uint64) serverOption {
  19972. return func(m *ServerMutation) {
  19973. var (
  19974. err error
  19975. once sync.Once
  19976. value *Server
  19977. )
  19978. m.oldValue = func(ctx context.Context) (*Server, error) {
  19979. once.Do(func() {
  19980. if m.done {
  19981. err = errors.New("querying old values post mutation is not allowed")
  19982. } else {
  19983. value, err = m.Client().Server.Get(ctx, id)
  19984. }
  19985. })
  19986. return value, err
  19987. }
  19988. m.id = &id
  19989. }
  19990. }
  19991. // withServer sets the old Server of the mutation.
  19992. func withServer(node *Server) serverOption {
  19993. return func(m *ServerMutation) {
  19994. m.oldValue = func(context.Context) (*Server, error) {
  19995. return node, nil
  19996. }
  19997. m.id = &node.ID
  19998. }
  19999. }
  20000. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20001. // executed in a transaction (ent.Tx), a transactional client is returned.
  20002. func (m ServerMutation) Client() *Client {
  20003. client := &Client{config: m.config}
  20004. client.init()
  20005. return client
  20006. }
  20007. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20008. // it returns an error otherwise.
  20009. func (m ServerMutation) Tx() (*Tx, error) {
  20010. if _, ok := m.driver.(*txDriver); !ok {
  20011. return nil, errors.New("ent: mutation is not running in a transaction")
  20012. }
  20013. tx := &Tx{config: m.config}
  20014. tx.init()
  20015. return tx, nil
  20016. }
  20017. // SetID sets the value of the id field. Note that this
  20018. // operation is only accepted on creation of Server entities.
  20019. func (m *ServerMutation) SetID(id uint64) {
  20020. m.id = &id
  20021. }
  20022. // ID returns the ID value in the mutation. Note that the ID is only available
  20023. // if it was provided to the builder or after it was returned from the database.
  20024. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20025. if m.id == nil {
  20026. return
  20027. }
  20028. return *m.id, true
  20029. }
  20030. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20031. // That means, if the mutation is applied within a transaction with an isolation level such
  20032. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20033. // or updated by the mutation.
  20034. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20035. switch {
  20036. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20037. id, exists := m.ID()
  20038. if exists {
  20039. return []uint64{id}, nil
  20040. }
  20041. fallthrough
  20042. case m.op.Is(OpUpdate | OpDelete):
  20043. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20044. default:
  20045. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20046. }
  20047. }
  20048. // SetCreatedAt sets the "created_at" field.
  20049. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20050. m.created_at = &t
  20051. }
  20052. // CreatedAt returns the value of the "created_at" field in the mutation.
  20053. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20054. v := m.created_at
  20055. if v == nil {
  20056. return
  20057. }
  20058. return *v, true
  20059. }
  20060. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20061. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20063. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20064. if !m.op.Is(OpUpdateOne) {
  20065. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20066. }
  20067. if m.id == nil || m.oldValue == nil {
  20068. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20069. }
  20070. oldValue, err := m.oldValue(ctx)
  20071. if err != nil {
  20072. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20073. }
  20074. return oldValue.CreatedAt, nil
  20075. }
  20076. // ResetCreatedAt resets all changes to the "created_at" field.
  20077. func (m *ServerMutation) ResetCreatedAt() {
  20078. m.created_at = nil
  20079. }
  20080. // SetUpdatedAt sets the "updated_at" field.
  20081. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20082. m.updated_at = &t
  20083. }
  20084. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20085. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20086. v := m.updated_at
  20087. if v == nil {
  20088. return
  20089. }
  20090. return *v, true
  20091. }
  20092. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20093. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20095. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20096. if !m.op.Is(OpUpdateOne) {
  20097. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20098. }
  20099. if m.id == nil || m.oldValue == nil {
  20100. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20101. }
  20102. oldValue, err := m.oldValue(ctx)
  20103. if err != nil {
  20104. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20105. }
  20106. return oldValue.UpdatedAt, nil
  20107. }
  20108. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20109. func (m *ServerMutation) ResetUpdatedAt() {
  20110. m.updated_at = nil
  20111. }
  20112. // SetStatus sets the "status" field.
  20113. func (m *ServerMutation) SetStatus(u uint8) {
  20114. m.status = &u
  20115. m.addstatus = nil
  20116. }
  20117. // Status returns the value of the "status" field in the mutation.
  20118. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20119. v := m.status
  20120. if v == nil {
  20121. return
  20122. }
  20123. return *v, true
  20124. }
  20125. // OldStatus returns the old "status" field's value of the Server entity.
  20126. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20128. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20129. if !m.op.Is(OpUpdateOne) {
  20130. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20131. }
  20132. if m.id == nil || m.oldValue == nil {
  20133. return v, errors.New("OldStatus requires an ID field in the mutation")
  20134. }
  20135. oldValue, err := m.oldValue(ctx)
  20136. if err != nil {
  20137. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20138. }
  20139. return oldValue.Status, nil
  20140. }
  20141. // AddStatus adds u to the "status" field.
  20142. func (m *ServerMutation) AddStatus(u int8) {
  20143. if m.addstatus != nil {
  20144. *m.addstatus += u
  20145. } else {
  20146. m.addstatus = &u
  20147. }
  20148. }
  20149. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20150. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20151. v := m.addstatus
  20152. if v == nil {
  20153. return
  20154. }
  20155. return *v, true
  20156. }
  20157. // ClearStatus clears the value of the "status" field.
  20158. func (m *ServerMutation) ClearStatus() {
  20159. m.status = nil
  20160. m.addstatus = nil
  20161. m.clearedFields[server.FieldStatus] = struct{}{}
  20162. }
  20163. // StatusCleared returns if the "status" field was cleared in this mutation.
  20164. func (m *ServerMutation) StatusCleared() bool {
  20165. _, ok := m.clearedFields[server.FieldStatus]
  20166. return ok
  20167. }
  20168. // ResetStatus resets all changes to the "status" field.
  20169. func (m *ServerMutation) ResetStatus() {
  20170. m.status = nil
  20171. m.addstatus = nil
  20172. delete(m.clearedFields, server.FieldStatus)
  20173. }
  20174. // SetDeletedAt sets the "deleted_at" field.
  20175. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20176. m.deleted_at = &t
  20177. }
  20178. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20179. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20180. v := m.deleted_at
  20181. if v == nil {
  20182. return
  20183. }
  20184. return *v, true
  20185. }
  20186. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20187. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20189. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20190. if !m.op.Is(OpUpdateOne) {
  20191. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20192. }
  20193. if m.id == nil || m.oldValue == nil {
  20194. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20195. }
  20196. oldValue, err := m.oldValue(ctx)
  20197. if err != nil {
  20198. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20199. }
  20200. return oldValue.DeletedAt, nil
  20201. }
  20202. // ClearDeletedAt clears the value of the "deleted_at" field.
  20203. func (m *ServerMutation) ClearDeletedAt() {
  20204. m.deleted_at = nil
  20205. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20206. }
  20207. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20208. func (m *ServerMutation) DeletedAtCleared() bool {
  20209. _, ok := m.clearedFields[server.FieldDeletedAt]
  20210. return ok
  20211. }
  20212. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20213. func (m *ServerMutation) ResetDeletedAt() {
  20214. m.deleted_at = nil
  20215. delete(m.clearedFields, server.FieldDeletedAt)
  20216. }
  20217. // SetName sets the "name" field.
  20218. func (m *ServerMutation) SetName(s string) {
  20219. m.name = &s
  20220. }
  20221. // Name returns the value of the "name" field in the mutation.
  20222. func (m *ServerMutation) Name() (r string, exists bool) {
  20223. v := m.name
  20224. if v == nil {
  20225. return
  20226. }
  20227. return *v, true
  20228. }
  20229. // OldName returns the old "name" field's value of the Server entity.
  20230. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20232. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20233. if !m.op.Is(OpUpdateOne) {
  20234. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20235. }
  20236. if m.id == nil || m.oldValue == nil {
  20237. return v, errors.New("OldName requires an ID field in the mutation")
  20238. }
  20239. oldValue, err := m.oldValue(ctx)
  20240. if err != nil {
  20241. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20242. }
  20243. return oldValue.Name, nil
  20244. }
  20245. // ResetName resets all changes to the "name" field.
  20246. func (m *ServerMutation) ResetName() {
  20247. m.name = nil
  20248. }
  20249. // SetPublicIP sets the "public_ip" field.
  20250. func (m *ServerMutation) SetPublicIP(s string) {
  20251. m.public_ip = &s
  20252. }
  20253. // PublicIP returns the value of the "public_ip" field in the mutation.
  20254. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20255. v := m.public_ip
  20256. if v == nil {
  20257. return
  20258. }
  20259. return *v, true
  20260. }
  20261. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20262. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20264. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20265. if !m.op.Is(OpUpdateOne) {
  20266. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20267. }
  20268. if m.id == nil || m.oldValue == nil {
  20269. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20270. }
  20271. oldValue, err := m.oldValue(ctx)
  20272. if err != nil {
  20273. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20274. }
  20275. return oldValue.PublicIP, nil
  20276. }
  20277. // ResetPublicIP resets all changes to the "public_ip" field.
  20278. func (m *ServerMutation) ResetPublicIP() {
  20279. m.public_ip = nil
  20280. }
  20281. // SetPrivateIP sets the "private_ip" field.
  20282. func (m *ServerMutation) SetPrivateIP(s string) {
  20283. m.private_ip = &s
  20284. }
  20285. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20286. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20287. v := m.private_ip
  20288. if v == nil {
  20289. return
  20290. }
  20291. return *v, true
  20292. }
  20293. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20294. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20296. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20297. if !m.op.Is(OpUpdateOne) {
  20298. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20299. }
  20300. if m.id == nil || m.oldValue == nil {
  20301. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20302. }
  20303. oldValue, err := m.oldValue(ctx)
  20304. if err != nil {
  20305. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20306. }
  20307. return oldValue.PrivateIP, nil
  20308. }
  20309. // ResetPrivateIP resets all changes to the "private_ip" field.
  20310. func (m *ServerMutation) ResetPrivateIP() {
  20311. m.private_ip = nil
  20312. }
  20313. // SetAdminPort sets the "admin_port" field.
  20314. func (m *ServerMutation) SetAdminPort(s string) {
  20315. m.admin_port = &s
  20316. }
  20317. // AdminPort returns the value of the "admin_port" field in the mutation.
  20318. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20319. v := m.admin_port
  20320. if v == nil {
  20321. return
  20322. }
  20323. return *v, true
  20324. }
  20325. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20326. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20328. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20329. if !m.op.Is(OpUpdateOne) {
  20330. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20331. }
  20332. if m.id == nil || m.oldValue == nil {
  20333. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20334. }
  20335. oldValue, err := m.oldValue(ctx)
  20336. if err != nil {
  20337. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20338. }
  20339. return oldValue.AdminPort, nil
  20340. }
  20341. // ResetAdminPort resets all changes to the "admin_port" field.
  20342. func (m *ServerMutation) ResetAdminPort() {
  20343. m.admin_port = nil
  20344. }
  20345. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20346. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20347. if m.wxs == nil {
  20348. m.wxs = make(map[uint64]struct{})
  20349. }
  20350. for i := range ids {
  20351. m.wxs[ids[i]] = struct{}{}
  20352. }
  20353. }
  20354. // ClearWxs clears the "wxs" edge to the Wx entity.
  20355. func (m *ServerMutation) ClearWxs() {
  20356. m.clearedwxs = true
  20357. }
  20358. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20359. func (m *ServerMutation) WxsCleared() bool {
  20360. return m.clearedwxs
  20361. }
  20362. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20363. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20364. if m.removedwxs == nil {
  20365. m.removedwxs = make(map[uint64]struct{})
  20366. }
  20367. for i := range ids {
  20368. delete(m.wxs, ids[i])
  20369. m.removedwxs[ids[i]] = struct{}{}
  20370. }
  20371. }
  20372. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20373. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20374. for id := range m.removedwxs {
  20375. ids = append(ids, id)
  20376. }
  20377. return
  20378. }
  20379. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20380. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20381. for id := range m.wxs {
  20382. ids = append(ids, id)
  20383. }
  20384. return
  20385. }
  20386. // ResetWxs resets all changes to the "wxs" edge.
  20387. func (m *ServerMutation) ResetWxs() {
  20388. m.wxs = nil
  20389. m.clearedwxs = false
  20390. m.removedwxs = nil
  20391. }
  20392. // Where appends a list predicates to the ServerMutation builder.
  20393. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20394. m.predicates = append(m.predicates, ps...)
  20395. }
  20396. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20397. // users can use type-assertion to append predicates that do not depend on any generated package.
  20398. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20399. p := make([]predicate.Server, len(ps))
  20400. for i := range ps {
  20401. p[i] = ps[i]
  20402. }
  20403. m.Where(p...)
  20404. }
  20405. // Op returns the operation name.
  20406. func (m *ServerMutation) Op() Op {
  20407. return m.op
  20408. }
  20409. // SetOp allows setting the mutation operation.
  20410. func (m *ServerMutation) SetOp(op Op) {
  20411. m.op = op
  20412. }
  20413. // Type returns the node type of this mutation (Server).
  20414. func (m *ServerMutation) Type() string {
  20415. return m.typ
  20416. }
  20417. // Fields returns all fields that were changed during this mutation. Note that in
  20418. // order to get all numeric fields that were incremented/decremented, call
  20419. // AddedFields().
  20420. func (m *ServerMutation) Fields() []string {
  20421. fields := make([]string, 0, 8)
  20422. if m.created_at != nil {
  20423. fields = append(fields, server.FieldCreatedAt)
  20424. }
  20425. if m.updated_at != nil {
  20426. fields = append(fields, server.FieldUpdatedAt)
  20427. }
  20428. if m.status != nil {
  20429. fields = append(fields, server.FieldStatus)
  20430. }
  20431. if m.deleted_at != nil {
  20432. fields = append(fields, server.FieldDeletedAt)
  20433. }
  20434. if m.name != nil {
  20435. fields = append(fields, server.FieldName)
  20436. }
  20437. if m.public_ip != nil {
  20438. fields = append(fields, server.FieldPublicIP)
  20439. }
  20440. if m.private_ip != nil {
  20441. fields = append(fields, server.FieldPrivateIP)
  20442. }
  20443. if m.admin_port != nil {
  20444. fields = append(fields, server.FieldAdminPort)
  20445. }
  20446. return fields
  20447. }
  20448. // Field returns the value of a field with the given name. The second boolean
  20449. // return value indicates that this field was not set, or was not defined in the
  20450. // schema.
  20451. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20452. switch name {
  20453. case server.FieldCreatedAt:
  20454. return m.CreatedAt()
  20455. case server.FieldUpdatedAt:
  20456. return m.UpdatedAt()
  20457. case server.FieldStatus:
  20458. return m.Status()
  20459. case server.FieldDeletedAt:
  20460. return m.DeletedAt()
  20461. case server.FieldName:
  20462. return m.Name()
  20463. case server.FieldPublicIP:
  20464. return m.PublicIP()
  20465. case server.FieldPrivateIP:
  20466. return m.PrivateIP()
  20467. case server.FieldAdminPort:
  20468. return m.AdminPort()
  20469. }
  20470. return nil, false
  20471. }
  20472. // OldField returns the old value of the field from the database. An error is
  20473. // returned if the mutation operation is not UpdateOne, or the query to the
  20474. // database failed.
  20475. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20476. switch name {
  20477. case server.FieldCreatedAt:
  20478. return m.OldCreatedAt(ctx)
  20479. case server.FieldUpdatedAt:
  20480. return m.OldUpdatedAt(ctx)
  20481. case server.FieldStatus:
  20482. return m.OldStatus(ctx)
  20483. case server.FieldDeletedAt:
  20484. return m.OldDeletedAt(ctx)
  20485. case server.FieldName:
  20486. return m.OldName(ctx)
  20487. case server.FieldPublicIP:
  20488. return m.OldPublicIP(ctx)
  20489. case server.FieldPrivateIP:
  20490. return m.OldPrivateIP(ctx)
  20491. case server.FieldAdminPort:
  20492. return m.OldAdminPort(ctx)
  20493. }
  20494. return nil, fmt.Errorf("unknown Server field %s", name)
  20495. }
  20496. // SetField sets the value of a field with the given name. It returns an error if
  20497. // the field is not defined in the schema, or if the type mismatched the field
  20498. // type.
  20499. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20500. switch name {
  20501. case server.FieldCreatedAt:
  20502. v, ok := value.(time.Time)
  20503. if !ok {
  20504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20505. }
  20506. m.SetCreatedAt(v)
  20507. return nil
  20508. case server.FieldUpdatedAt:
  20509. v, ok := value.(time.Time)
  20510. if !ok {
  20511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20512. }
  20513. m.SetUpdatedAt(v)
  20514. return nil
  20515. case server.FieldStatus:
  20516. v, ok := value.(uint8)
  20517. if !ok {
  20518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20519. }
  20520. m.SetStatus(v)
  20521. return nil
  20522. case server.FieldDeletedAt:
  20523. v, ok := value.(time.Time)
  20524. if !ok {
  20525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20526. }
  20527. m.SetDeletedAt(v)
  20528. return nil
  20529. case server.FieldName:
  20530. v, ok := value.(string)
  20531. if !ok {
  20532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20533. }
  20534. m.SetName(v)
  20535. return nil
  20536. case server.FieldPublicIP:
  20537. v, ok := value.(string)
  20538. if !ok {
  20539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20540. }
  20541. m.SetPublicIP(v)
  20542. return nil
  20543. case server.FieldPrivateIP:
  20544. v, ok := value.(string)
  20545. if !ok {
  20546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20547. }
  20548. m.SetPrivateIP(v)
  20549. return nil
  20550. case server.FieldAdminPort:
  20551. v, ok := value.(string)
  20552. if !ok {
  20553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20554. }
  20555. m.SetAdminPort(v)
  20556. return nil
  20557. }
  20558. return fmt.Errorf("unknown Server field %s", name)
  20559. }
  20560. // AddedFields returns all numeric fields that were incremented/decremented during
  20561. // this mutation.
  20562. func (m *ServerMutation) AddedFields() []string {
  20563. var fields []string
  20564. if m.addstatus != nil {
  20565. fields = append(fields, server.FieldStatus)
  20566. }
  20567. return fields
  20568. }
  20569. // AddedField returns the numeric value that was incremented/decremented on a field
  20570. // with the given name. The second boolean return value indicates that this field
  20571. // was not set, or was not defined in the schema.
  20572. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20573. switch name {
  20574. case server.FieldStatus:
  20575. return m.AddedStatus()
  20576. }
  20577. return nil, false
  20578. }
  20579. // AddField adds the value to the field with the given name. It returns an error if
  20580. // the field is not defined in the schema, or if the type mismatched the field
  20581. // type.
  20582. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20583. switch name {
  20584. case server.FieldStatus:
  20585. v, ok := value.(int8)
  20586. if !ok {
  20587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20588. }
  20589. m.AddStatus(v)
  20590. return nil
  20591. }
  20592. return fmt.Errorf("unknown Server numeric field %s", name)
  20593. }
  20594. // ClearedFields returns all nullable fields that were cleared during this
  20595. // mutation.
  20596. func (m *ServerMutation) ClearedFields() []string {
  20597. var fields []string
  20598. if m.FieldCleared(server.FieldStatus) {
  20599. fields = append(fields, server.FieldStatus)
  20600. }
  20601. if m.FieldCleared(server.FieldDeletedAt) {
  20602. fields = append(fields, server.FieldDeletedAt)
  20603. }
  20604. return fields
  20605. }
  20606. // FieldCleared returns a boolean indicating if a field with the given name was
  20607. // cleared in this mutation.
  20608. func (m *ServerMutation) FieldCleared(name string) bool {
  20609. _, ok := m.clearedFields[name]
  20610. return ok
  20611. }
  20612. // ClearField clears the value of the field with the given name. It returns an
  20613. // error if the field is not defined in the schema.
  20614. func (m *ServerMutation) ClearField(name string) error {
  20615. switch name {
  20616. case server.FieldStatus:
  20617. m.ClearStatus()
  20618. return nil
  20619. case server.FieldDeletedAt:
  20620. m.ClearDeletedAt()
  20621. return nil
  20622. }
  20623. return fmt.Errorf("unknown Server nullable field %s", name)
  20624. }
  20625. // ResetField resets all changes in the mutation for the field with the given name.
  20626. // It returns an error if the field is not defined in the schema.
  20627. func (m *ServerMutation) ResetField(name string) error {
  20628. switch name {
  20629. case server.FieldCreatedAt:
  20630. m.ResetCreatedAt()
  20631. return nil
  20632. case server.FieldUpdatedAt:
  20633. m.ResetUpdatedAt()
  20634. return nil
  20635. case server.FieldStatus:
  20636. m.ResetStatus()
  20637. return nil
  20638. case server.FieldDeletedAt:
  20639. m.ResetDeletedAt()
  20640. return nil
  20641. case server.FieldName:
  20642. m.ResetName()
  20643. return nil
  20644. case server.FieldPublicIP:
  20645. m.ResetPublicIP()
  20646. return nil
  20647. case server.FieldPrivateIP:
  20648. m.ResetPrivateIP()
  20649. return nil
  20650. case server.FieldAdminPort:
  20651. m.ResetAdminPort()
  20652. return nil
  20653. }
  20654. return fmt.Errorf("unknown Server field %s", name)
  20655. }
  20656. // AddedEdges returns all edge names that were set/added in this mutation.
  20657. func (m *ServerMutation) AddedEdges() []string {
  20658. edges := make([]string, 0, 1)
  20659. if m.wxs != nil {
  20660. edges = append(edges, server.EdgeWxs)
  20661. }
  20662. return edges
  20663. }
  20664. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20665. // name in this mutation.
  20666. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20667. switch name {
  20668. case server.EdgeWxs:
  20669. ids := make([]ent.Value, 0, len(m.wxs))
  20670. for id := range m.wxs {
  20671. ids = append(ids, id)
  20672. }
  20673. return ids
  20674. }
  20675. return nil
  20676. }
  20677. // RemovedEdges returns all edge names that were removed in this mutation.
  20678. func (m *ServerMutation) RemovedEdges() []string {
  20679. edges := make([]string, 0, 1)
  20680. if m.removedwxs != nil {
  20681. edges = append(edges, server.EdgeWxs)
  20682. }
  20683. return edges
  20684. }
  20685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20686. // the given name in this mutation.
  20687. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20688. switch name {
  20689. case server.EdgeWxs:
  20690. ids := make([]ent.Value, 0, len(m.removedwxs))
  20691. for id := range m.removedwxs {
  20692. ids = append(ids, id)
  20693. }
  20694. return ids
  20695. }
  20696. return nil
  20697. }
  20698. // ClearedEdges returns all edge names that were cleared in this mutation.
  20699. func (m *ServerMutation) ClearedEdges() []string {
  20700. edges := make([]string, 0, 1)
  20701. if m.clearedwxs {
  20702. edges = append(edges, server.EdgeWxs)
  20703. }
  20704. return edges
  20705. }
  20706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20707. // was cleared in this mutation.
  20708. func (m *ServerMutation) EdgeCleared(name string) bool {
  20709. switch name {
  20710. case server.EdgeWxs:
  20711. return m.clearedwxs
  20712. }
  20713. return false
  20714. }
  20715. // ClearEdge clears the value of the edge with the given name. It returns an error
  20716. // if that edge is not defined in the schema.
  20717. func (m *ServerMutation) ClearEdge(name string) error {
  20718. switch name {
  20719. }
  20720. return fmt.Errorf("unknown Server unique edge %s", name)
  20721. }
  20722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20723. // It returns an error if the edge is not defined in the schema.
  20724. func (m *ServerMutation) ResetEdge(name string) error {
  20725. switch name {
  20726. case server.EdgeWxs:
  20727. m.ResetWxs()
  20728. return nil
  20729. }
  20730. return fmt.Errorf("unknown Server edge %s", name)
  20731. }
  20732. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20733. type SopNodeMutation struct {
  20734. config
  20735. op Op
  20736. typ string
  20737. id *uint64
  20738. created_at *time.Time
  20739. updated_at *time.Time
  20740. status *uint8
  20741. addstatus *int8
  20742. deleted_at *time.Time
  20743. parent_id *uint64
  20744. addparent_id *int64
  20745. name *string
  20746. condition_type *int
  20747. addcondition_type *int
  20748. condition_list *[]string
  20749. appendcondition_list []string
  20750. no_reply_condition *uint64
  20751. addno_reply_condition *int64
  20752. no_reply_unit *string
  20753. action_message *[]custom_types.Action
  20754. appendaction_message []custom_types.Action
  20755. action_label_add *[]uint64
  20756. appendaction_label_add []uint64
  20757. action_label_del *[]uint64
  20758. appendaction_label_del []uint64
  20759. action_forward **custom_types.ActionForward
  20760. clearedFields map[string]struct{}
  20761. sop_stage *uint64
  20762. clearedsop_stage bool
  20763. node_messages map[uint64]struct{}
  20764. removednode_messages map[uint64]struct{}
  20765. clearednode_messages bool
  20766. done bool
  20767. oldValue func(context.Context) (*SopNode, error)
  20768. predicates []predicate.SopNode
  20769. }
  20770. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20771. // sopnodeOption allows management of the mutation configuration using functional options.
  20772. type sopnodeOption func(*SopNodeMutation)
  20773. // newSopNodeMutation creates new mutation for the SopNode entity.
  20774. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20775. m := &SopNodeMutation{
  20776. config: c,
  20777. op: op,
  20778. typ: TypeSopNode,
  20779. clearedFields: make(map[string]struct{}),
  20780. }
  20781. for _, opt := range opts {
  20782. opt(m)
  20783. }
  20784. return m
  20785. }
  20786. // withSopNodeID sets the ID field of the mutation.
  20787. func withSopNodeID(id uint64) sopnodeOption {
  20788. return func(m *SopNodeMutation) {
  20789. var (
  20790. err error
  20791. once sync.Once
  20792. value *SopNode
  20793. )
  20794. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20795. once.Do(func() {
  20796. if m.done {
  20797. err = errors.New("querying old values post mutation is not allowed")
  20798. } else {
  20799. value, err = m.Client().SopNode.Get(ctx, id)
  20800. }
  20801. })
  20802. return value, err
  20803. }
  20804. m.id = &id
  20805. }
  20806. }
  20807. // withSopNode sets the old SopNode of the mutation.
  20808. func withSopNode(node *SopNode) sopnodeOption {
  20809. return func(m *SopNodeMutation) {
  20810. m.oldValue = func(context.Context) (*SopNode, error) {
  20811. return node, nil
  20812. }
  20813. m.id = &node.ID
  20814. }
  20815. }
  20816. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20817. // executed in a transaction (ent.Tx), a transactional client is returned.
  20818. func (m SopNodeMutation) Client() *Client {
  20819. client := &Client{config: m.config}
  20820. client.init()
  20821. return client
  20822. }
  20823. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20824. // it returns an error otherwise.
  20825. func (m SopNodeMutation) Tx() (*Tx, error) {
  20826. if _, ok := m.driver.(*txDriver); !ok {
  20827. return nil, errors.New("ent: mutation is not running in a transaction")
  20828. }
  20829. tx := &Tx{config: m.config}
  20830. tx.init()
  20831. return tx, nil
  20832. }
  20833. // SetID sets the value of the id field. Note that this
  20834. // operation is only accepted on creation of SopNode entities.
  20835. func (m *SopNodeMutation) SetID(id uint64) {
  20836. m.id = &id
  20837. }
  20838. // ID returns the ID value in the mutation. Note that the ID is only available
  20839. // if it was provided to the builder or after it was returned from the database.
  20840. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20841. if m.id == nil {
  20842. return
  20843. }
  20844. return *m.id, true
  20845. }
  20846. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20847. // That means, if the mutation is applied within a transaction with an isolation level such
  20848. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20849. // or updated by the mutation.
  20850. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20851. switch {
  20852. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20853. id, exists := m.ID()
  20854. if exists {
  20855. return []uint64{id}, nil
  20856. }
  20857. fallthrough
  20858. case m.op.Is(OpUpdate | OpDelete):
  20859. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20860. default:
  20861. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20862. }
  20863. }
  20864. // SetCreatedAt sets the "created_at" field.
  20865. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20866. m.created_at = &t
  20867. }
  20868. // CreatedAt returns the value of the "created_at" field in the mutation.
  20869. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20870. v := m.created_at
  20871. if v == nil {
  20872. return
  20873. }
  20874. return *v, true
  20875. }
  20876. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20877. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20879. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20880. if !m.op.Is(OpUpdateOne) {
  20881. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20882. }
  20883. if m.id == nil || m.oldValue == nil {
  20884. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20885. }
  20886. oldValue, err := m.oldValue(ctx)
  20887. if err != nil {
  20888. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20889. }
  20890. return oldValue.CreatedAt, nil
  20891. }
  20892. // ResetCreatedAt resets all changes to the "created_at" field.
  20893. func (m *SopNodeMutation) ResetCreatedAt() {
  20894. m.created_at = nil
  20895. }
  20896. // SetUpdatedAt sets the "updated_at" field.
  20897. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20898. m.updated_at = &t
  20899. }
  20900. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20901. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20902. v := m.updated_at
  20903. if v == nil {
  20904. return
  20905. }
  20906. return *v, true
  20907. }
  20908. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20909. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20911. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20912. if !m.op.Is(OpUpdateOne) {
  20913. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20914. }
  20915. if m.id == nil || m.oldValue == nil {
  20916. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20917. }
  20918. oldValue, err := m.oldValue(ctx)
  20919. if err != nil {
  20920. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20921. }
  20922. return oldValue.UpdatedAt, nil
  20923. }
  20924. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20925. func (m *SopNodeMutation) ResetUpdatedAt() {
  20926. m.updated_at = nil
  20927. }
  20928. // SetStatus sets the "status" field.
  20929. func (m *SopNodeMutation) SetStatus(u uint8) {
  20930. m.status = &u
  20931. m.addstatus = nil
  20932. }
  20933. // Status returns the value of the "status" field in the mutation.
  20934. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20935. v := m.status
  20936. if v == nil {
  20937. return
  20938. }
  20939. return *v, true
  20940. }
  20941. // OldStatus returns the old "status" field's value of the SopNode entity.
  20942. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20944. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20945. if !m.op.Is(OpUpdateOne) {
  20946. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20947. }
  20948. if m.id == nil || m.oldValue == nil {
  20949. return v, errors.New("OldStatus requires an ID field in the mutation")
  20950. }
  20951. oldValue, err := m.oldValue(ctx)
  20952. if err != nil {
  20953. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20954. }
  20955. return oldValue.Status, nil
  20956. }
  20957. // AddStatus adds u to the "status" field.
  20958. func (m *SopNodeMutation) AddStatus(u int8) {
  20959. if m.addstatus != nil {
  20960. *m.addstatus += u
  20961. } else {
  20962. m.addstatus = &u
  20963. }
  20964. }
  20965. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20966. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20967. v := m.addstatus
  20968. if v == nil {
  20969. return
  20970. }
  20971. return *v, true
  20972. }
  20973. // ClearStatus clears the value of the "status" field.
  20974. func (m *SopNodeMutation) ClearStatus() {
  20975. m.status = nil
  20976. m.addstatus = nil
  20977. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20978. }
  20979. // StatusCleared returns if the "status" field was cleared in this mutation.
  20980. func (m *SopNodeMutation) StatusCleared() bool {
  20981. _, ok := m.clearedFields[sopnode.FieldStatus]
  20982. return ok
  20983. }
  20984. // ResetStatus resets all changes to the "status" field.
  20985. func (m *SopNodeMutation) ResetStatus() {
  20986. m.status = nil
  20987. m.addstatus = nil
  20988. delete(m.clearedFields, sopnode.FieldStatus)
  20989. }
  20990. // SetDeletedAt sets the "deleted_at" field.
  20991. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20992. m.deleted_at = &t
  20993. }
  20994. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20995. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20996. v := m.deleted_at
  20997. if v == nil {
  20998. return
  20999. }
  21000. return *v, true
  21001. }
  21002. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21003. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21005. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21006. if !m.op.Is(OpUpdateOne) {
  21007. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21008. }
  21009. if m.id == nil || m.oldValue == nil {
  21010. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21011. }
  21012. oldValue, err := m.oldValue(ctx)
  21013. if err != nil {
  21014. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21015. }
  21016. return oldValue.DeletedAt, nil
  21017. }
  21018. // ClearDeletedAt clears the value of the "deleted_at" field.
  21019. func (m *SopNodeMutation) ClearDeletedAt() {
  21020. m.deleted_at = nil
  21021. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21022. }
  21023. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21024. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21025. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21026. return ok
  21027. }
  21028. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21029. func (m *SopNodeMutation) ResetDeletedAt() {
  21030. m.deleted_at = nil
  21031. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21032. }
  21033. // SetStageID sets the "stage_id" field.
  21034. func (m *SopNodeMutation) SetStageID(u uint64) {
  21035. m.sop_stage = &u
  21036. }
  21037. // StageID returns the value of the "stage_id" field in the mutation.
  21038. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21039. v := m.sop_stage
  21040. if v == nil {
  21041. return
  21042. }
  21043. return *v, true
  21044. }
  21045. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21046. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21048. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21049. if !m.op.Is(OpUpdateOne) {
  21050. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21051. }
  21052. if m.id == nil || m.oldValue == nil {
  21053. return v, errors.New("OldStageID requires an ID field in the mutation")
  21054. }
  21055. oldValue, err := m.oldValue(ctx)
  21056. if err != nil {
  21057. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21058. }
  21059. return oldValue.StageID, nil
  21060. }
  21061. // ResetStageID resets all changes to the "stage_id" field.
  21062. func (m *SopNodeMutation) ResetStageID() {
  21063. m.sop_stage = nil
  21064. }
  21065. // SetParentID sets the "parent_id" field.
  21066. func (m *SopNodeMutation) SetParentID(u uint64) {
  21067. m.parent_id = &u
  21068. m.addparent_id = nil
  21069. }
  21070. // ParentID returns the value of the "parent_id" field in the mutation.
  21071. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21072. v := m.parent_id
  21073. if v == nil {
  21074. return
  21075. }
  21076. return *v, true
  21077. }
  21078. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21079. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21081. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21082. if !m.op.Is(OpUpdateOne) {
  21083. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21084. }
  21085. if m.id == nil || m.oldValue == nil {
  21086. return v, errors.New("OldParentID requires an ID field in the mutation")
  21087. }
  21088. oldValue, err := m.oldValue(ctx)
  21089. if err != nil {
  21090. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21091. }
  21092. return oldValue.ParentID, nil
  21093. }
  21094. // AddParentID adds u to the "parent_id" field.
  21095. func (m *SopNodeMutation) AddParentID(u int64) {
  21096. if m.addparent_id != nil {
  21097. *m.addparent_id += u
  21098. } else {
  21099. m.addparent_id = &u
  21100. }
  21101. }
  21102. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21103. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21104. v := m.addparent_id
  21105. if v == nil {
  21106. return
  21107. }
  21108. return *v, true
  21109. }
  21110. // ResetParentID resets all changes to the "parent_id" field.
  21111. func (m *SopNodeMutation) ResetParentID() {
  21112. m.parent_id = nil
  21113. m.addparent_id = nil
  21114. }
  21115. // SetName sets the "name" field.
  21116. func (m *SopNodeMutation) SetName(s string) {
  21117. m.name = &s
  21118. }
  21119. // Name returns the value of the "name" field in the mutation.
  21120. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21121. v := m.name
  21122. if v == nil {
  21123. return
  21124. }
  21125. return *v, true
  21126. }
  21127. // OldName returns the old "name" field's value of the SopNode entity.
  21128. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21130. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21131. if !m.op.Is(OpUpdateOne) {
  21132. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21133. }
  21134. if m.id == nil || m.oldValue == nil {
  21135. return v, errors.New("OldName requires an ID field in the mutation")
  21136. }
  21137. oldValue, err := m.oldValue(ctx)
  21138. if err != nil {
  21139. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21140. }
  21141. return oldValue.Name, nil
  21142. }
  21143. // ResetName resets all changes to the "name" field.
  21144. func (m *SopNodeMutation) ResetName() {
  21145. m.name = nil
  21146. }
  21147. // SetConditionType sets the "condition_type" field.
  21148. func (m *SopNodeMutation) SetConditionType(i int) {
  21149. m.condition_type = &i
  21150. m.addcondition_type = nil
  21151. }
  21152. // ConditionType returns the value of the "condition_type" field in the mutation.
  21153. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21154. v := m.condition_type
  21155. if v == nil {
  21156. return
  21157. }
  21158. return *v, true
  21159. }
  21160. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21161. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21163. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21164. if !m.op.Is(OpUpdateOne) {
  21165. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21166. }
  21167. if m.id == nil || m.oldValue == nil {
  21168. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21169. }
  21170. oldValue, err := m.oldValue(ctx)
  21171. if err != nil {
  21172. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21173. }
  21174. return oldValue.ConditionType, nil
  21175. }
  21176. // AddConditionType adds i to the "condition_type" field.
  21177. func (m *SopNodeMutation) AddConditionType(i int) {
  21178. if m.addcondition_type != nil {
  21179. *m.addcondition_type += i
  21180. } else {
  21181. m.addcondition_type = &i
  21182. }
  21183. }
  21184. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21185. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21186. v := m.addcondition_type
  21187. if v == nil {
  21188. return
  21189. }
  21190. return *v, true
  21191. }
  21192. // ResetConditionType resets all changes to the "condition_type" field.
  21193. func (m *SopNodeMutation) ResetConditionType() {
  21194. m.condition_type = nil
  21195. m.addcondition_type = nil
  21196. }
  21197. // SetConditionList sets the "condition_list" field.
  21198. func (m *SopNodeMutation) SetConditionList(s []string) {
  21199. m.condition_list = &s
  21200. m.appendcondition_list = nil
  21201. }
  21202. // ConditionList returns the value of the "condition_list" field in the mutation.
  21203. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21204. v := m.condition_list
  21205. if v == nil {
  21206. return
  21207. }
  21208. return *v, true
  21209. }
  21210. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21211. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21213. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21214. if !m.op.Is(OpUpdateOne) {
  21215. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21216. }
  21217. if m.id == nil || m.oldValue == nil {
  21218. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21219. }
  21220. oldValue, err := m.oldValue(ctx)
  21221. if err != nil {
  21222. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21223. }
  21224. return oldValue.ConditionList, nil
  21225. }
  21226. // AppendConditionList adds s to the "condition_list" field.
  21227. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21228. m.appendcondition_list = append(m.appendcondition_list, s...)
  21229. }
  21230. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21231. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21232. if len(m.appendcondition_list) == 0 {
  21233. return nil, false
  21234. }
  21235. return m.appendcondition_list, true
  21236. }
  21237. // ClearConditionList clears the value of the "condition_list" field.
  21238. func (m *SopNodeMutation) ClearConditionList() {
  21239. m.condition_list = nil
  21240. m.appendcondition_list = nil
  21241. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21242. }
  21243. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21244. func (m *SopNodeMutation) ConditionListCleared() bool {
  21245. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21246. return ok
  21247. }
  21248. // ResetConditionList resets all changes to the "condition_list" field.
  21249. func (m *SopNodeMutation) ResetConditionList() {
  21250. m.condition_list = nil
  21251. m.appendcondition_list = nil
  21252. delete(m.clearedFields, sopnode.FieldConditionList)
  21253. }
  21254. // SetNoReplyCondition sets the "no_reply_condition" field.
  21255. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21256. m.no_reply_condition = &u
  21257. m.addno_reply_condition = nil
  21258. }
  21259. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21260. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21261. v := m.no_reply_condition
  21262. if v == nil {
  21263. return
  21264. }
  21265. return *v, true
  21266. }
  21267. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21268. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21270. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21271. if !m.op.Is(OpUpdateOne) {
  21272. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21273. }
  21274. if m.id == nil || m.oldValue == nil {
  21275. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21276. }
  21277. oldValue, err := m.oldValue(ctx)
  21278. if err != nil {
  21279. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21280. }
  21281. return oldValue.NoReplyCondition, nil
  21282. }
  21283. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21284. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21285. if m.addno_reply_condition != nil {
  21286. *m.addno_reply_condition += u
  21287. } else {
  21288. m.addno_reply_condition = &u
  21289. }
  21290. }
  21291. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21292. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21293. v := m.addno_reply_condition
  21294. if v == nil {
  21295. return
  21296. }
  21297. return *v, true
  21298. }
  21299. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21300. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21301. m.no_reply_condition = nil
  21302. m.addno_reply_condition = nil
  21303. }
  21304. // SetNoReplyUnit sets the "no_reply_unit" field.
  21305. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21306. m.no_reply_unit = &s
  21307. }
  21308. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21309. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21310. v := m.no_reply_unit
  21311. if v == nil {
  21312. return
  21313. }
  21314. return *v, true
  21315. }
  21316. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21317. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21319. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21320. if !m.op.Is(OpUpdateOne) {
  21321. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21322. }
  21323. if m.id == nil || m.oldValue == nil {
  21324. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21325. }
  21326. oldValue, err := m.oldValue(ctx)
  21327. if err != nil {
  21328. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21329. }
  21330. return oldValue.NoReplyUnit, nil
  21331. }
  21332. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21333. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21334. m.no_reply_unit = nil
  21335. }
  21336. // SetActionMessage sets the "action_message" field.
  21337. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21338. m.action_message = &ct
  21339. m.appendaction_message = nil
  21340. }
  21341. // ActionMessage returns the value of the "action_message" field in the mutation.
  21342. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21343. v := m.action_message
  21344. if v == nil {
  21345. return
  21346. }
  21347. return *v, true
  21348. }
  21349. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21350. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21352. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21353. if !m.op.Is(OpUpdateOne) {
  21354. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21355. }
  21356. if m.id == nil || m.oldValue == nil {
  21357. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21358. }
  21359. oldValue, err := m.oldValue(ctx)
  21360. if err != nil {
  21361. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21362. }
  21363. return oldValue.ActionMessage, nil
  21364. }
  21365. // AppendActionMessage adds ct to the "action_message" field.
  21366. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21367. m.appendaction_message = append(m.appendaction_message, ct...)
  21368. }
  21369. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21370. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21371. if len(m.appendaction_message) == 0 {
  21372. return nil, false
  21373. }
  21374. return m.appendaction_message, true
  21375. }
  21376. // ClearActionMessage clears the value of the "action_message" field.
  21377. func (m *SopNodeMutation) ClearActionMessage() {
  21378. m.action_message = nil
  21379. m.appendaction_message = nil
  21380. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21381. }
  21382. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21383. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21384. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21385. return ok
  21386. }
  21387. // ResetActionMessage resets all changes to the "action_message" field.
  21388. func (m *SopNodeMutation) ResetActionMessage() {
  21389. m.action_message = nil
  21390. m.appendaction_message = nil
  21391. delete(m.clearedFields, sopnode.FieldActionMessage)
  21392. }
  21393. // SetActionLabelAdd sets the "action_label_add" field.
  21394. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21395. m.action_label_add = &u
  21396. m.appendaction_label_add = nil
  21397. }
  21398. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21399. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21400. v := m.action_label_add
  21401. if v == nil {
  21402. return
  21403. }
  21404. return *v, true
  21405. }
  21406. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21407. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21409. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21410. if !m.op.Is(OpUpdateOne) {
  21411. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21412. }
  21413. if m.id == nil || m.oldValue == nil {
  21414. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21415. }
  21416. oldValue, err := m.oldValue(ctx)
  21417. if err != nil {
  21418. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21419. }
  21420. return oldValue.ActionLabelAdd, nil
  21421. }
  21422. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21423. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21424. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21425. }
  21426. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21427. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21428. if len(m.appendaction_label_add) == 0 {
  21429. return nil, false
  21430. }
  21431. return m.appendaction_label_add, true
  21432. }
  21433. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21434. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21435. m.action_label_add = nil
  21436. m.appendaction_label_add = nil
  21437. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21438. }
  21439. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21440. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21441. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21442. return ok
  21443. }
  21444. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21445. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21446. m.action_label_add = nil
  21447. m.appendaction_label_add = nil
  21448. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21449. }
  21450. // SetActionLabelDel sets the "action_label_del" field.
  21451. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21452. m.action_label_del = &u
  21453. m.appendaction_label_del = nil
  21454. }
  21455. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21456. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21457. v := m.action_label_del
  21458. if v == nil {
  21459. return
  21460. }
  21461. return *v, true
  21462. }
  21463. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21464. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21466. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21467. if !m.op.Is(OpUpdateOne) {
  21468. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21469. }
  21470. if m.id == nil || m.oldValue == nil {
  21471. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21472. }
  21473. oldValue, err := m.oldValue(ctx)
  21474. if err != nil {
  21475. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21476. }
  21477. return oldValue.ActionLabelDel, nil
  21478. }
  21479. // AppendActionLabelDel adds u to the "action_label_del" field.
  21480. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21481. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21482. }
  21483. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21484. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21485. if len(m.appendaction_label_del) == 0 {
  21486. return nil, false
  21487. }
  21488. return m.appendaction_label_del, true
  21489. }
  21490. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21491. func (m *SopNodeMutation) ClearActionLabelDel() {
  21492. m.action_label_del = nil
  21493. m.appendaction_label_del = nil
  21494. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21495. }
  21496. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21497. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21498. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21499. return ok
  21500. }
  21501. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21502. func (m *SopNodeMutation) ResetActionLabelDel() {
  21503. m.action_label_del = nil
  21504. m.appendaction_label_del = nil
  21505. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21506. }
  21507. // SetActionForward sets the "action_forward" field.
  21508. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21509. m.action_forward = &ctf
  21510. }
  21511. // ActionForward returns the value of the "action_forward" field in the mutation.
  21512. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21513. v := m.action_forward
  21514. if v == nil {
  21515. return
  21516. }
  21517. return *v, true
  21518. }
  21519. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21520. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21522. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21523. if !m.op.Is(OpUpdateOne) {
  21524. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21525. }
  21526. if m.id == nil || m.oldValue == nil {
  21527. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21528. }
  21529. oldValue, err := m.oldValue(ctx)
  21530. if err != nil {
  21531. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21532. }
  21533. return oldValue.ActionForward, nil
  21534. }
  21535. // ClearActionForward clears the value of the "action_forward" field.
  21536. func (m *SopNodeMutation) ClearActionForward() {
  21537. m.action_forward = nil
  21538. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21539. }
  21540. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21541. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21542. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21543. return ok
  21544. }
  21545. // ResetActionForward resets all changes to the "action_forward" field.
  21546. func (m *SopNodeMutation) ResetActionForward() {
  21547. m.action_forward = nil
  21548. delete(m.clearedFields, sopnode.FieldActionForward)
  21549. }
  21550. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21551. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21552. m.sop_stage = &id
  21553. }
  21554. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21555. func (m *SopNodeMutation) ClearSopStage() {
  21556. m.clearedsop_stage = true
  21557. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21558. }
  21559. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21560. func (m *SopNodeMutation) SopStageCleared() bool {
  21561. return m.clearedsop_stage
  21562. }
  21563. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21564. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21565. if m.sop_stage != nil {
  21566. return *m.sop_stage, true
  21567. }
  21568. return
  21569. }
  21570. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21571. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21572. // SopStageID instead. It exists only for internal usage by the builders.
  21573. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21574. if id := m.sop_stage; id != nil {
  21575. ids = append(ids, *id)
  21576. }
  21577. return
  21578. }
  21579. // ResetSopStage resets all changes to the "sop_stage" edge.
  21580. func (m *SopNodeMutation) ResetSopStage() {
  21581. m.sop_stage = nil
  21582. m.clearedsop_stage = false
  21583. }
  21584. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21585. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21586. if m.node_messages == nil {
  21587. m.node_messages = make(map[uint64]struct{})
  21588. }
  21589. for i := range ids {
  21590. m.node_messages[ids[i]] = struct{}{}
  21591. }
  21592. }
  21593. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21594. func (m *SopNodeMutation) ClearNodeMessages() {
  21595. m.clearednode_messages = true
  21596. }
  21597. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21598. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21599. return m.clearednode_messages
  21600. }
  21601. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21602. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21603. if m.removednode_messages == nil {
  21604. m.removednode_messages = make(map[uint64]struct{})
  21605. }
  21606. for i := range ids {
  21607. delete(m.node_messages, ids[i])
  21608. m.removednode_messages[ids[i]] = struct{}{}
  21609. }
  21610. }
  21611. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21612. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21613. for id := range m.removednode_messages {
  21614. ids = append(ids, id)
  21615. }
  21616. return
  21617. }
  21618. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21619. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21620. for id := range m.node_messages {
  21621. ids = append(ids, id)
  21622. }
  21623. return
  21624. }
  21625. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21626. func (m *SopNodeMutation) ResetNodeMessages() {
  21627. m.node_messages = nil
  21628. m.clearednode_messages = false
  21629. m.removednode_messages = nil
  21630. }
  21631. // Where appends a list predicates to the SopNodeMutation builder.
  21632. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21633. m.predicates = append(m.predicates, ps...)
  21634. }
  21635. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21636. // users can use type-assertion to append predicates that do not depend on any generated package.
  21637. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21638. p := make([]predicate.SopNode, len(ps))
  21639. for i := range ps {
  21640. p[i] = ps[i]
  21641. }
  21642. m.Where(p...)
  21643. }
  21644. // Op returns the operation name.
  21645. func (m *SopNodeMutation) Op() Op {
  21646. return m.op
  21647. }
  21648. // SetOp allows setting the mutation operation.
  21649. func (m *SopNodeMutation) SetOp(op Op) {
  21650. m.op = op
  21651. }
  21652. // Type returns the node type of this mutation (SopNode).
  21653. func (m *SopNodeMutation) Type() string {
  21654. return m.typ
  21655. }
  21656. // Fields returns all fields that were changed during this mutation. Note that in
  21657. // order to get all numeric fields that were incremented/decremented, call
  21658. // AddedFields().
  21659. func (m *SopNodeMutation) Fields() []string {
  21660. fields := make([]string, 0, 15)
  21661. if m.created_at != nil {
  21662. fields = append(fields, sopnode.FieldCreatedAt)
  21663. }
  21664. if m.updated_at != nil {
  21665. fields = append(fields, sopnode.FieldUpdatedAt)
  21666. }
  21667. if m.status != nil {
  21668. fields = append(fields, sopnode.FieldStatus)
  21669. }
  21670. if m.deleted_at != nil {
  21671. fields = append(fields, sopnode.FieldDeletedAt)
  21672. }
  21673. if m.sop_stage != nil {
  21674. fields = append(fields, sopnode.FieldStageID)
  21675. }
  21676. if m.parent_id != nil {
  21677. fields = append(fields, sopnode.FieldParentID)
  21678. }
  21679. if m.name != nil {
  21680. fields = append(fields, sopnode.FieldName)
  21681. }
  21682. if m.condition_type != nil {
  21683. fields = append(fields, sopnode.FieldConditionType)
  21684. }
  21685. if m.condition_list != nil {
  21686. fields = append(fields, sopnode.FieldConditionList)
  21687. }
  21688. if m.no_reply_condition != nil {
  21689. fields = append(fields, sopnode.FieldNoReplyCondition)
  21690. }
  21691. if m.no_reply_unit != nil {
  21692. fields = append(fields, sopnode.FieldNoReplyUnit)
  21693. }
  21694. if m.action_message != nil {
  21695. fields = append(fields, sopnode.FieldActionMessage)
  21696. }
  21697. if m.action_label_add != nil {
  21698. fields = append(fields, sopnode.FieldActionLabelAdd)
  21699. }
  21700. if m.action_label_del != nil {
  21701. fields = append(fields, sopnode.FieldActionLabelDel)
  21702. }
  21703. if m.action_forward != nil {
  21704. fields = append(fields, sopnode.FieldActionForward)
  21705. }
  21706. return fields
  21707. }
  21708. // Field returns the value of a field with the given name. The second boolean
  21709. // return value indicates that this field was not set, or was not defined in the
  21710. // schema.
  21711. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21712. switch name {
  21713. case sopnode.FieldCreatedAt:
  21714. return m.CreatedAt()
  21715. case sopnode.FieldUpdatedAt:
  21716. return m.UpdatedAt()
  21717. case sopnode.FieldStatus:
  21718. return m.Status()
  21719. case sopnode.FieldDeletedAt:
  21720. return m.DeletedAt()
  21721. case sopnode.FieldStageID:
  21722. return m.StageID()
  21723. case sopnode.FieldParentID:
  21724. return m.ParentID()
  21725. case sopnode.FieldName:
  21726. return m.Name()
  21727. case sopnode.FieldConditionType:
  21728. return m.ConditionType()
  21729. case sopnode.FieldConditionList:
  21730. return m.ConditionList()
  21731. case sopnode.FieldNoReplyCondition:
  21732. return m.NoReplyCondition()
  21733. case sopnode.FieldNoReplyUnit:
  21734. return m.NoReplyUnit()
  21735. case sopnode.FieldActionMessage:
  21736. return m.ActionMessage()
  21737. case sopnode.FieldActionLabelAdd:
  21738. return m.ActionLabelAdd()
  21739. case sopnode.FieldActionLabelDel:
  21740. return m.ActionLabelDel()
  21741. case sopnode.FieldActionForward:
  21742. return m.ActionForward()
  21743. }
  21744. return nil, false
  21745. }
  21746. // OldField returns the old value of the field from the database. An error is
  21747. // returned if the mutation operation is not UpdateOne, or the query to the
  21748. // database failed.
  21749. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21750. switch name {
  21751. case sopnode.FieldCreatedAt:
  21752. return m.OldCreatedAt(ctx)
  21753. case sopnode.FieldUpdatedAt:
  21754. return m.OldUpdatedAt(ctx)
  21755. case sopnode.FieldStatus:
  21756. return m.OldStatus(ctx)
  21757. case sopnode.FieldDeletedAt:
  21758. return m.OldDeletedAt(ctx)
  21759. case sopnode.FieldStageID:
  21760. return m.OldStageID(ctx)
  21761. case sopnode.FieldParentID:
  21762. return m.OldParentID(ctx)
  21763. case sopnode.FieldName:
  21764. return m.OldName(ctx)
  21765. case sopnode.FieldConditionType:
  21766. return m.OldConditionType(ctx)
  21767. case sopnode.FieldConditionList:
  21768. return m.OldConditionList(ctx)
  21769. case sopnode.FieldNoReplyCondition:
  21770. return m.OldNoReplyCondition(ctx)
  21771. case sopnode.FieldNoReplyUnit:
  21772. return m.OldNoReplyUnit(ctx)
  21773. case sopnode.FieldActionMessage:
  21774. return m.OldActionMessage(ctx)
  21775. case sopnode.FieldActionLabelAdd:
  21776. return m.OldActionLabelAdd(ctx)
  21777. case sopnode.FieldActionLabelDel:
  21778. return m.OldActionLabelDel(ctx)
  21779. case sopnode.FieldActionForward:
  21780. return m.OldActionForward(ctx)
  21781. }
  21782. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21783. }
  21784. // SetField sets the value of a field with the given name. It returns an error if
  21785. // the field is not defined in the schema, or if the type mismatched the field
  21786. // type.
  21787. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21788. switch name {
  21789. case sopnode.FieldCreatedAt:
  21790. v, ok := value.(time.Time)
  21791. if !ok {
  21792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21793. }
  21794. m.SetCreatedAt(v)
  21795. return nil
  21796. case sopnode.FieldUpdatedAt:
  21797. v, ok := value.(time.Time)
  21798. if !ok {
  21799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21800. }
  21801. m.SetUpdatedAt(v)
  21802. return nil
  21803. case sopnode.FieldStatus:
  21804. v, ok := value.(uint8)
  21805. if !ok {
  21806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21807. }
  21808. m.SetStatus(v)
  21809. return nil
  21810. case sopnode.FieldDeletedAt:
  21811. v, ok := value.(time.Time)
  21812. if !ok {
  21813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21814. }
  21815. m.SetDeletedAt(v)
  21816. return nil
  21817. case sopnode.FieldStageID:
  21818. v, ok := value.(uint64)
  21819. if !ok {
  21820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21821. }
  21822. m.SetStageID(v)
  21823. return nil
  21824. case sopnode.FieldParentID:
  21825. v, ok := value.(uint64)
  21826. if !ok {
  21827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21828. }
  21829. m.SetParentID(v)
  21830. return nil
  21831. case sopnode.FieldName:
  21832. v, ok := value.(string)
  21833. if !ok {
  21834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21835. }
  21836. m.SetName(v)
  21837. return nil
  21838. case sopnode.FieldConditionType:
  21839. v, ok := value.(int)
  21840. if !ok {
  21841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21842. }
  21843. m.SetConditionType(v)
  21844. return nil
  21845. case sopnode.FieldConditionList:
  21846. v, ok := value.([]string)
  21847. if !ok {
  21848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21849. }
  21850. m.SetConditionList(v)
  21851. return nil
  21852. case sopnode.FieldNoReplyCondition:
  21853. v, ok := value.(uint64)
  21854. if !ok {
  21855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21856. }
  21857. m.SetNoReplyCondition(v)
  21858. return nil
  21859. case sopnode.FieldNoReplyUnit:
  21860. v, ok := value.(string)
  21861. if !ok {
  21862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21863. }
  21864. m.SetNoReplyUnit(v)
  21865. return nil
  21866. case sopnode.FieldActionMessage:
  21867. v, ok := value.([]custom_types.Action)
  21868. if !ok {
  21869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21870. }
  21871. m.SetActionMessage(v)
  21872. return nil
  21873. case sopnode.FieldActionLabelAdd:
  21874. v, ok := value.([]uint64)
  21875. if !ok {
  21876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21877. }
  21878. m.SetActionLabelAdd(v)
  21879. return nil
  21880. case sopnode.FieldActionLabelDel:
  21881. v, ok := value.([]uint64)
  21882. if !ok {
  21883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21884. }
  21885. m.SetActionLabelDel(v)
  21886. return nil
  21887. case sopnode.FieldActionForward:
  21888. v, ok := value.(*custom_types.ActionForward)
  21889. if !ok {
  21890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21891. }
  21892. m.SetActionForward(v)
  21893. return nil
  21894. }
  21895. return fmt.Errorf("unknown SopNode field %s", name)
  21896. }
  21897. // AddedFields returns all numeric fields that were incremented/decremented during
  21898. // this mutation.
  21899. func (m *SopNodeMutation) AddedFields() []string {
  21900. var fields []string
  21901. if m.addstatus != nil {
  21902. fields = append(fields, sopnode.FieldStatus)
  21903. }
  21904. if m.addparent_id != nil {
  21905. fields = append(fields, sopnode.FieldParentID)
  21906. }
  21907. if m.addcondition_type != nil {
  21908. fields = append(fields, sopnode.FieldConditionType)
  21909. }
  21910. if m.addno_reply_condition != nil {
  21911. fields = append(fields, sopnode.FieldNoReplyCondition)
  21912. }
  21913. return fields
  21914. }
  21915. // AddedField returns the numeric value that was incremented/decremented on a field
  21916. // with the given name. The second boolean return value indicates that this field
  21917. // was not set, or was not defined in the schema.
  21918. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21919. switch name {
  21920. case sopnode.FieldStatus:
  21921. return m.AddedStatus()
  21922. case sopnode.FieldParentID:
  21923. return m.AddedParentID()
  21924. case sopnode.FieldConditionType:
  21925. return m.AddedConditionType()
  21926. case sopnode.FieldNoReplyCondition:
  21927. return m.AddedNoReplyCondition()
  21928. }
  21929. return nil, false
  21930. }
  21931. // AddField adds the value to the field with the given name. It returns an error if
  21932. // the field is not defined in the schema, or if the type mismatched the field
  21933. // type.
  21934. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21935. switch name {
  21936. case sopnode.FieldStatus:
  21937. v, ok := value.(int8)
  21938. if !ok {
  21939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21940. }
  21941. m.AddStatus(v)
  21942. return nil
  21943. case sopnode.FieldParentID:
  21944. v, ok := value.(int64)
  21945. if !ok {
  21946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21947. }
  21948. m.AddParentID(v)
  21949. return nil
  21950. case sopnode.FieldConditionType:
  21951. v, ok := value.(int)
  21952. if !ok {
  21953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21954. }
  21955. m.AddConditionType(v)
  21956. return nil
  21957. case sopnode.FieldNoReplyCondition:
  21958. v, ok := value.(int64)
  21959. if !ok {
  21960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21961. }
  21962. m.AddNoReplyCondition(v)
  21963. return nil
  21964. }
  21965. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21966. }
  21967. // ClearedFields returns all nullable fields that were cleared during this
  21968. // mutation.
  21969. func (m *SopNodeMutation) ClearedFields() []string {
  21970. var fields []string
  21971. if m.FieldCleared(sopnode.FieldStatus) {
  21972. fields = append(fields, sopnode.FieldStatus)
  21973. }
  21974. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21975. fields = append(fields, sopnode.FieldDeletedAt)
  21976. }
  21977. if m.FieldCleared(sopnode.FieldConditionList) {
  21978. fields = append(fields, sopnode.FieldConditionList)
  21979. }
  21980. if m.FieldCleared(sopnode.FieldActionMessage) {
  21981. fields = append(fields, sopnode.FieldActionMessage)
  21982. }
  21983. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21984. fields = append(fields, sopnode.FieldActionLabelAdd)
  21985. }
  21986. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21987. fields = append(fields, sopnode.FieldActionLabelDel)
  21988. }
  21989. if m.FieldCleared(sopnode.FieldActionForward) {
  21990. fields = append(fields, sopnode.FieldActionForward)
  21991. }
  21992. return fields
  21993. }
  21994. // FieldCleared returns a boolean indicating if a field with the given name was
  21995. // cleared in this mutation.
  21996. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21997. _, ok := m.clearedFields[name]
  21998. return ok
  21999. }
  22000. // ClearField clears the value of the field with the given name. It returns an
  22001. // error if the field is not defined in the schema.
  22002. func (m *SopNodeMutation) ClearField(name string) error {
  22003. switch name {
  22004. case sopnode.FieldStatus:
  22005. m.ClearStatus()
  22006. return nil
  22007. case sopnode.FieldDeletedAt:
  22008. m.ClearDeletedAt()
  22009. return nil
  22010. case sopnode.FieldConditionList:
  22011. m.ClearConditionList()
  22012. return nil
  22013. case sopnode.FieldActionMessage:
  22014. m.ClearActionMessage()
  22015. return nil
  22016. case sopnode.FieldActionLabelAdd:
  22017. m.ClearActionLabelAdd()
  22018. return nil
  22019. case sopnode.FieldActionLabelDel:
  22020. m.ClearActionLabelDel()
  22021. return nil
  22022. case sopnode.FieldActionForward:
  22023. m.ClearActionForward()
  22024. return nil
  22025. }
  22026. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22027. }
  22028. // ResetField resets all changes in the mutation for the field with the given name.
  22029. // It returns an error if the field is not defined in the schema.
  22030. func (m *SopNodeMutation) ResetField(name string) error {
  22031. switch name {
  22032. case sopnode.FieldCreatedAt:
  22033. m.ResetCreatedAt()
  22034. return nil
  22035. case sopnode.FieldUpdatedAt:
  22036. m.ResetUpdatedAt()
  22037. return nil
  22038. case sopnode.FieldStatus:
  22039. m.ResetStatus()
  22040. return nil
  22041. case sopnode.FieldDeletedAt:
  22042. m.ResetDeletedAt()
  22043. return nil
  22044. case sopnode.FieldStageID:
  22045. m.ResetStageID()
  22046. return nil
  22047. case sopnode.FieldParentID:
  22048. m.ResetParentID()
  22049. return nil
  22050. case sopnode.FieldName:
  22051. m.ResetName()
  22052. return nil
  22053. case sopnode.FieldConditionType:
  22054. m.ResetConditionType()
  22055. return nil
  22056. case sopnode.FieldConditionList:
  22057. m.ResetConditionList()
  22058. return nil
  22059. case sopnode.FieldNoReplyCondition:
  22060. m.ResetNoReplyCondition()
  22061. return nil
  22062. case sopnode.FieldNoReplyUnit:
  22063. m.ResetNoReplyUnit()
  22064. return nil
  22065. case sopnode.FieldActionMessage:
  22066. m.ResetActionMessage()
  22067. return nil
  22068. case sopnode.FieldActionLabelAdd:
  22069. m.ResetActionLabelAdd()
  22070. return nil
  22071. case sopnode.FieldActionLabelDel:
  22072. m.ResetActionLabelDel()
  22073. return nil
  22074. case sopnode.FieldActionForward:
  22075. m.ResetActionForward()
  22076. return nil
  22077. }
  22078. return fmt.Errorf("unknown SopNode field %s", name)
  22079. }
  22080. // AddedEdges returns all edge names that were set/added in this mutation.
  22081. func (m *SopNodeMutation) AddedEdges() []string {
  22082. edges := make([]string, 0, 2)
  22083. if m.sop_stage != nil {
  22084. edges = append(edges, sopnode.EdgeSopStage)
  22085. }
  22086. if m.node_messages != nil {
  22087. edges = append(edges, sopnode.EdgeNodeMessages)
  22088. }
  22089. return edges
  22090. }
  22091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22092. // name in this mutation.
  22093. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22094. switch name {
  22095. case sopnode.EdgeSopStage:
  22096. if id := m.sop_stage; id != nil {
  22097. return []ent.Value{*id}
  22098. }
  22099. case sopnode.EdgeNodeMessages:
  22100. ids := make([]ent.Value, 0, len(m.node_messages))
  22101. for id := range m.node_messages {
  22102. ids = append(ids, id)
  22103. }
  22104. return ids
  22105. }
  22106. return nil
  22107. }
  22108. // RemovedEdges returns all edge names that were removed in this mutation.
  22109. func (m *SopNodeMutation) RemovedEdges() []string {
  22110. edges := make([]string, 0, 2)
  22111. if m.removednode_messages != nil {
  22112. edges = append(edges, sopnode.EdgeNodeMessages)
  22113. }
  22114. return edges
  22115. }
  22116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22117. // the given name in this mutation.
  22118. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22119. switch name {
  22120. case sopnode.EdgeNodeMessages:
  22121. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22122. for id := range m.removednode_messages {
  22123. ids = append(ids, id)
  22124. }
  22125. return ids
  22126. }
  22127. return nil
  22128. }
  22129. // ClearedEdges returns all edge names that were cleared in this mutation.
  22130. func (m *SopNodeMutation) ClearedEdges() []string {
  22131. edges := make([]string, 0, 2)
  22132. if m.clearedsop_stage {
  22133. edges = append(edges, sopnode.EdgeSopStage)
  22134. }
  22135. if m.clearednode_messages {
  22136. edges = append(edges, sopnode.EdgeNodeMessages)
  22137. }
  22138. return edges
  22139. }
  22140. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22141. // was cleared in this mutation.
  22142. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22143. switch name {
  22144. case sopnode.EdgeSopStage:
  22145. return m.clearedsop_stage
  22146. case sopnode.EdgeNodeMessages:
  22147. return m.clearednode_messages
  22148. }
  22149. return false
  22150. }
  22151. // ClearEdge clears the value of the edge with the given name. It returns an error
  22152. // if that edge is not defined in the schema.
  22153. func (m *SopNodeMutation) ClearEdge(name string) error {
  22154. switch name {
  22155. case sopnode.EdgeSopStage:
  22156. m.ClearSopStage()
  22157. return nil
  22158. }
  22159. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22160. }
  22161. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22162. // It returns an error if the edge is not defined in the schema.
  22163. func (m *SopNodeMutation) ResetEdge(name string) error {
  22164. switch name {
  22165. case sopnode.EdgeSopStage:
  22166. m.ResetSopStage()
  22167. return nil
  22168. case sopnode.EdgeNodeMessages:
  22169. m.ResetNodeMessages()
  22170. return nil
  22171. }
  22172. return fmt.Errorf("unknown SopNode edge %s", name)
  22173. }
  22174. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22175. type SopStageMutation struct {
  22176. config
  22177. op Op
  22178. typ string
  22179. id *uint64
  22180. created_at *time.Time
  22181. updated_at *time.Time
  22182. status *uint8
  22183. addstatus *int8
  22184. deleted_at *time.Time
  22185. name *string
  22186. condition_type *int
  22187. addcondition_type *int
  22188. condition_operator *int
  22189. addcondition_operator *int
  22190. condition_list *[]custom_types.Condition
  22191. appendcondition_list []custom_types.Condition
  22192. action_message *[]custom_types.Action
  22193. appendaction_message []custom_types.Action
  22194. action_label_add *[]uint64
  22195. appendaction_label_add []uint64
  22196. action_label_del *[]uint64
  22197. appendaction_label_del []uint64
  22198. action_forward **custom_types.ActionForward
  22199. index_sort *int
  22200. addindex_sort *int
  22201. clearedFields map[string]struct{}
  22202. sop_task *uint64
  22203. clearedsop_task bool
  22204. stage_nodes map[uint64]struct{}
  22205. removedstage_nodes map[uint64]struct{}
  22206. clearedstage_nodes bool
  22207. stage_messages map[uint64]struct{}
  22208. removedstage_messages map[uint64]struct{}
  22209. clearedstage_messages bool
  22210. done bool
  22211. oldValue func(context.Context) (*SopStage, error)
  22212. predicates []predicate.SopStage
  22213. }
  22214. var _ ent.Mutation = (*SopStageMutation)(nil)
  22215. // sopstageOption allows management of the mutation configuration using functional options.
  22216. type sopstageOption func(*SopStageMutation)
  22217. // newSopStageMutation creates new mutation for the SopStage entity.
  22218. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22219. m := &SopStageMutation{
  22220. config: c,
  22221. op: op,
  22222. typ: TypeSopStage,
  22223. clearedFields: make(map[string]struct{}),
  22224. }
  22225. for _, opt := range opts {
  22226. opt(m)
  22227. }
  22228. return m
  22229. }
  22230. // withSopStageID sets the ID field of the mutation.
  22231. func withSopStageID(id uint64) sopstageOption {
  22232. return func(m *SopStageMutation) {
  22233. var (
  22234. err error
  22235. once sync.Once
  22236. value *SopStage
  22237. )
  22238. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22239. once.Do(func() {
  22240. if m.done {
  22241. err = errors.New("querying old values post mutation is not allowed")
  22242. } else {
  22243. value, err = m.Client().SopStage.Get(ctx, id)
  22244. }
  22245. })
  22246. return value, err
  22247. }
  22248. m.id = &id
  22249. }
  22250. }
  22251. // withSopStage sets the old SopStage of the mutation.
  22252. func withSopStage(node *SopStage) sopstageOption {
  22253. return func(m *SopStageMutation) {
  22254. m.oldValue = func(context.Context) (*SopStage, error) {
  22255. return node, nil
  22256. }
  22257. m.id = &node.ID
  22258. }
  22259. }
  22260. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22261. // executed in a transaction (ent.Tx), a transactional client is returned.
  22262. func (m SopStageMutation) Client() *Client {
  22263. client := &Client{config: m.config}
  22264. client.init()
  22265. return client
  22266. }
  22267. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22268. // it returns an error otherwise.
  22269. func (m SopStageMutation) Tx() (*Tx, error) {
  22270. if _, ok := m.driver.(*txDriver); !ok {
  22271. return nil, errors.New("ent: mutation is not running in a transaction")
  22272. }
  22273. tx := &Tx{config: m.config}
  22274. tx.init()
  22275. return tx, nil
  22276. }
  22277. // SetID sets the value of the id field. Note that this
  22278. // operation is only accepted on creation of SopStage entities.
  22279. func (m *SopStageMutation) SetID(id uint64) {
  22280. m.id = &id
  22281. }
  22282. // ID returns the ID value in the mutation. Note that the ID is only available
  22283. // if it was provided to the builder or after it was returned from the database.
  22284. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22285. if m.id == nil {
  22286. return
  22287. }
  22288. return *m.id, true
  22289. }
  22290. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22291. // That means, if the mutation is applied within a transaction with an isolation level such
  22292. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22293. // or updated by the mutation.
  22294. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22295. switch {
  22296. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22297. id, exists := m.ID()
  22298. if exists {
  22299. return []uint64{id}, nil
  22300. }
  22301. fallthrough
  22302. case m.op.Is(OpUpdate | OpDelete):
  22303. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22304. default:
  22305. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22306. }
  22307. }
  22308. // SetCreatedAt sets the "created_at" field.
  22309. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22310. m.created_at = &t
  22311. }
  22312. // CreatedAt returns the value of the "created_at" field in the mutation.
  22313. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22314. v := m.created_at
  22315. if v == nil {
  22316. return
  22317. }
  22318. return *v, true
  22319. }
  22320. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22321. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22323. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22324. if !m.op.Is(OpUpdateOne) {
  22325. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22326. }
  22327. if m.id == nil || m.oldValue == nil {
  22328. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22329. }
  22330. oldValue, err := m.oldValue(ctx)
  22331. if err != nil {
  22332. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22333. }
  22334. return oldValue.CreatedAt, nil
  22335. }
  22336. // ResetCreatedAt resets all changes to the "created_at" field.
  22337. func (m *SopStageMutation) ResetCreatedAt() {
  22338. m.created_at = nil
  22339. }
  22340. // SetUpdatedAt sets the "updated_at" field.
  22341. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22342. m.updated_at = &t
  22343. }
  22344. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22345. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22346. v := m.updated_at
  22347. if v == nil {
  22348. return
  22349. }
  22350. return *v, true
  22351. }
  22352. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22353. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22355. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22356. if !m.op.Is(OpUpdateOne) {
  22357. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22358. }
  22359. if m.id == nil || m.oldValue == nil {
  22360. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22361. }
  22362. oldValue, err := m.oldValue(ctx)
  22363. if err != nil {
  22364. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22365. }
  22366. return oldValue.UpdatedAt, nil
  22367. }
  22368. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22369. func (m *SopStageMutation) ResetUpdatedAt() {
  22370. m.updated_at = nil
  22371. }
  22372. // SetStatus sets the "status" field.
  22373. func (m *SopStageMutation) SetStatus(u uint8) {
  22374. m.status = &u
  22375. m.addstatus = nil
  22376. }
  22377. // Status returns the value of the "status" field in the mutation.
  22378. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22379. v := m.status
  22380. if v == nil {
  22381. return
  22382. }
  22383. return *v, true
  22384. }
  22385. // OldStatus returns the old "status" field's value of the SopStage entity.
  22386. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22388. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22389. if !m.op.Is(OpUpdateOne) {
  22390. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22391. }
  22392. if m.id == nil || m.oldValue == nil {
  22393. return v, errors.New("OldStatus requires an ID field in the mutation")
  22394. }
  22395. oldValue, err := m.oldValue(ctx)
  22396. if err != nil {
  22397. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22398. }
  22399. return oldValue.Status, nil
  22400. }
  22401. // AddStatus adds u to the "status" field.
  22402. func (m *SopStageMutation) AddStatus(u int8) {
  22403. if m.addstatus != nil {
  22404. *m.addstatus += u
  22405. } else {
  22406. m.addstatus = &u
  22407. }
  22408. }
  22409. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22410. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22411. v := m.addstatus
  22412. if v == nil {
  22413. return
  22414. }
  22415. return *v, true
  22416. }
  22417. // ClearStatus clears the value of the "status" field.
  22418. func (m *SopStageMutation) ClearStatus() {
  22419. m.status = nil
  22420. m.addstatus = nil
  22421. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22422. }
  22423. // StatusCleared returns if the "status" field was cleared in this mutation.
  22424. func (m *SopStageMutation) StatusCleared() bool {
  22425. _, ok := m.clearedFields[sopstage.FieldStatus]
  22426. return ok
  22427. }
  22428. // ResetStatus resets all changes to the "status" field.
  22429. func (m *SopStageMutation) ResetStatus() {
  22430. m.status = nil
  22431. m.addstatus = nil
  22432. delete(m.clearedFields, sopstage.FieldStatus)
  22433. }
  22434. // SetDeletedAt sets the "deleted_at" field.
  22435. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22436. m.deleted_at = &t
  22437. }
  22438. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22439. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22440. v := m.deleted_at
  22441. if v == nil {
  22442. return
  22443. }
  22444. return *v, true
  22445. }
  22446. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22447. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22449. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22450. if !m.op.Is(OpUpdateOne) {
  22451. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22452. }
  22453. if m.id == nil || m.oldValue == nil {
  22454. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22455. }
  22456. oldValue, err := m.oldValue(ctx)
  22457. if err != nil {
  22458. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22459. }
  22460. return oldValue.DeletedAt, nil
  22461. }
  22462. // ClearDeletedAt clears the value of the "deleted_at" field.
  22463. func (m *SopStageMutation) ClearDeletedAt() {
  22464. m.deleted_at = nil
  22465. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22466. }
  22467. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22468. func (m *SopStageMutation) DeletedAtCleared() bool {
  22469. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22470. return ok
  22471. }
  22472. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22473. func (m *SopStageMutation) ResetDeletedAt() {
  22474. m.deleted_at = nil
  22475. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22476. }
  22477. // SetTaskID sets the "task_id" field.
  22478. func (m *SopStageMutation) SetTaskID(u uint64) {
  22479. m.sop_task = &u
  22480. }
  22481. // TaskID returns the value of the "task_id" field in the mutation.
  22482. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22483. v := m.sop_task
  22484. if v == nil {
  22485. return
  22486. }
  22487. return *v, true
  22488. }
  22489. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22490. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22492. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22493. if !m.op.Is(OpUpdateOne) {
  22494. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22495. }
  22496. if m.id == nil || m.oldValue == nil {
  22497. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22498. }
  22499. oldValue, err := m.oldValue(ctx)
  22500. if err != nil {
  22501. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22502. }
  22503. return oldValue.TaskID, nil
  22504. }
  22505. // ResetTaskID resets all changes to the "task_id" field.
  22506. func (m *SopStageMutation) ResetTaskID() {
  22507. m.sop_task = nil
  22508. }
  22509. // SetName sets the "name" field.
  22510. func (m *SopStageMutation) SetName(s string) {
  22511. m.name = &s
  22512. }
  22513. // Name returns the value of the "name" field in the mutation.
  22514. func (m *SopStageMutation) Name() (r string, exists bool) {
  22515. v := m.name
  22516. if v == nil {
  22517. return
  22518. }
  22519. return *v, true
  22520. }
  22521. // OldName returns the old "name" field's value of the SopStage entity.
  22522. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22524. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22525. if !m.op.Is(OpUpdateOne) {
  22526. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22527. }
  22528. if m.id == nil || m.oldValue == nil {
  22529. return v, errors.New("OldName requires an ID field in the mutation")
  22530. }
  22531. oldValue, err := m.oldValue(ctx)
  22532. if err != nil {
  22533. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22534. }
  22535. return oldValue.Name, nil
  22536. }
  22537. // ResetName resets all changes to the "name" field.
  22538. func (m *SopStageMutation) ResetName() {
  22539. m.name = nil
  22540. }
  22541. // SetConditionType sets the "condition_type" field.
  22542. func (m *SopStageMutation) SetConditionType(i int) {
  22543. m.condition_type = &i
  22544. m.addcondition_type = nil
  22545. }
  22546. // ConditionType returns the value of the "condition_type" field in the mutation.
  22547. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22548. v := m.condition_type
  22549. if v == nil {
  22550. return
  22551. }
  22552. return *v, true
  22553. }
  22554. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22555. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22557. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22558. if !m.op.Is(OpUpdateOne) {
  22559. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22560. }
  22561. if m.id == nil || m.oldValue == nil {
  22562. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22563. }
  22564. oldValue, err := m.oldValue(ctx)
  22565. if err != nil {
  22566. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22567. }
  22568. return oldValue.ConditionType, nil
  22569. }
  22570. // AddConditionType adds i to the "condition_type" field.
  22571. func (m *SopStageMutation) AddConditionType(i int) {
  22572. if m.addcondition_type != nil {
  22573. *m.addcondition_type += i
  22574. } else {
  22575. m.addcondition_type = &i
  22576. }
  22577. }
  22578. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22579. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22580. v := m.addcondition_type
  22581. if v == nil {
  22582. return
  22583. }
  22584. return *v, true
  22585. }
  22586. // ResetConditionType resets all changes to the "condition_type" field.
  22587. func (m *SopStageMutation) ResetConditionType() {
  22588. m.condition_type = nil
  22589. m.addcondition_type = nil
  22590. }
  22591. // SetConditionOperator sets the "condition_operator" field.
  22592. func (m *SopStageMutation) SetConditionOperator(i int) {
  22593. m.condition_operator = &i
  22594. m.addcondition_operator = nil
  22595. }
  22596. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22597. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22598. v := m.condition_operator
  22599. if v == nil {
  22600. return
  22601. }
  22602. return *v, true
  22603. }
  22604. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22605. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22607. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22608. if !m.op.Is(OpUpdateOne) {
  22609. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22610. }
  22611. if m.id == nil || m.oldValue == nil {
  22612. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22613. }
  22614. oldValue, err := m.oldValue(ctx)
  22615. if err != nil {
  22616. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22617. }
  22618. return oldValue.ConditionOperator, nil
  22619. }
  22620. // AddConditionOperator adds i to the "condition_operator" field.
  22621. func (m *SopStageMutation) AddConditionOperator(i int) {
  22622. if m.addcondition_operator != nil {
  22623. *m.addcondition_operator += i
  22624. } else {
  22625. m.addcondition_operator = &i
  22626. }
  22627. }
  22628. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22629. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22630. v := m.addcondition_operator
  22631. if v == nil {
  22632. return
  22633. }
  22634. return *v, true
  22635. }
  22636. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22637. func (m *SopStageMutation) ResetConditionOperator() {
  22638. m.condition_operator = nil
  22639. m.addcondition_operator = nil
  22640. }
  22641. // SetConditionList sets the "condition_list" field.
  22642. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22643. m.condition_list = &ct
  22644. m.appendcondition_list = nil
  22645. }
  22646. // ConditionList returns the value of the "condition_list" field in the mutation.
  22647. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22648. v := m.condition_list
  22649. if v == nil {
  22650. return
  22651. }
  22652. return *v, true
  22653. }
  22654. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22655. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22657. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22658. if !m.op.Is(OpUpdateOne) {
  22659. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22660. }
  22661. if m.id == nil || m.oldValue == nil {
  22662. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22663. }
  22664. oldValue, err := m.oldValue(ctx)
  22665. if err != nil {
  22666. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22667. }
  22668. return oldValue.ConditionList, nil
  22669. }
  22670. // AppendConditionList adds ct to the "condition_list" field.
  22671. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22672. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22673. }
  22674. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22675. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22676. if len(m.appendcondition_list) == 0 {
  22677. return nil, false
  22678. }
  22679. return m.appendcondition_list, true
  22680. }
  22681. // ResetConditionList resets all changes to the "condition_list" field.
  22682. func (m *SopStageMutation) ResetConditionList() {
  22683. m.condition_list = nil
  22684. m.appendcondition_list = nil
  22685. }
  22686. // SetActionMessage sets the "action_message" field.
  22687. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22688. m.action_message = &ct
  22689. m.appendaction_message = nil
  22690. }
  22691. // ActionMessage returns the value of the "action_message" field in the mutation.
  22692. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22693. v := m.action_message
  22694. if v == nil {
  22695. return
  22696. }
  22697. return *v, true
  22698. }
  22699. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22700. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22702. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22703. if !m.op.Is(OpUpdateOne) {
  22704. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22705. }
  22706. if m.id == nil || m.oldValue == nil {
  22707. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22708. }
  22709. oldValue, err := m.oldValue(ctx)
  22710. if err != nil {
  22711. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22712. }
  22713. return oldValue.ActionMessage, nil
  22714. }
  22715. // AppendActionMessage adds ct to the "action_message" field.
  22716. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22717. m.appendaction_message = append(m.appendaction_message, ct...)
  22718. }
  22719. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22720. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22721. if len(m.appendaction_message) == 0 {
  22722. return nil, false
  22723. }
  22724. return m.appendaction_message, true
  22725. }
  22726. // ClearActionMessage clears the value of the "action_message" field.
  22727. func (m *SopStageMutation) ClearActionMessage() {
  22728. m.action_message = nil
  22729. m.appendaction_message = nil
  22730. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22731. }
  22732. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22733. func (m *SopStageMutation) ActionMessageCleared() bool {
  22734. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22735. return ok
  22736. }
  22737. // ResetActionMessage resets all changes to the "action_message" field.
  22738. func (m *SopStageMutation) ResetActionMessage() {
  22739. m.action_message = nil
  22740. m.appendaction_message = nil
  22741. delete(m.clearedFields, sopstage.FieldActionMessage)
  22742. }
  22743. // SetActionLabelAdd sets the "action_label_add" field.
  22744. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22745. m.action_label_add = &u
  22746. m.appendaction_label_add = nil
  22747. }
  22748. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22749. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22750. v := m.action_label_add
  22751. if v == nil {
  22752. return
  22753. }
  22754. return *v, true
  22755. }
  22756. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22757. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22759. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22760. if !m.op.Is(OpUpdateOne) {
  22761. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22762. }
  22763. if m.id == nil || m.oldValue == nil {
  22764. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22765. }
  22766. oldValue, err := m.oldValue(ctx)
  22767. if err != nil {
  22768. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22769. }
  22770. return oldValue.ActionLabelAdd, nil
  22771. }
  22772. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22773. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22774. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22775. }
  22776. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22777. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22778. if len(m.appendaction_label_add) == 0 {
  22779. return nil, false
  22780. }
  22781. return m.appendaction_label_add, true
  22782. }
  22783. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22784. func (m *SopStageMutation) ClearActionLabelAdd() {
  22785. m.action_label_add = nil
  22786. m.appendaction_label_add = nil
  22787. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22788. }
  22789. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22790. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22791. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22792. return ok
  22793. }
  22794. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22795. func (m *SopStageMutation) ResetActionLabelAdd() {
  22796. m.action_label_add = nil
  22797. m.appendaction_label_add = nil
  22798. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22799. }
  22800. // SetActionLabelDel sets the "action_label_del" field.
  22801. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22802. m.action_label_del = &u
  22803. m.appendaction_label_del = nil
  22804. }
  22805. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22806. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22807. v := m.action_label_del
  22808. if v == nil {
  22809. return
  22810. }
  22811. return *v, true
  22812. }
  22813. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22814. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22816. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22817. if !m.op.Is(OpUpdateOne) {
  22818. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22819. }
  22820. if m.id == nil || m.oldValue == nil {
  22821. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22822. }
  22823. oldValue, err := m.oldValue(ctx)
  22824. if err != nil {
  22825. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22826. }
  22827. return oldValue.ActionLabelDel, nil
  22828. }
  22829. // AppendActionLabelDel adds u to the "action_label_del" field.
  22830. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22831. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22832. }
  22833. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22834. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22835. if len(m.appendaction_label_del) == 0 {
  22836. return nil, false
  22837. }
  22838. return m.appendaction_label_del, true
  22839. }
  22840. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22841. func (m *SopStageMutation) ClearActionLabelDel() {
  22842. m.action_label_del = nil
  22843. m.appendaction_label_del = nil
  22844. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22845. }
  22846. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22847. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22848. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22849. return ok
  22850. }
  22851. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22852. func (m *SopStageMutation) ResetActionLabelDel() {
  22853. m.action_label_del = nil
  22854. m.appendaction_label_del = nil
  22855. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22856. }
  22857. // SetActionForward sets the "action_forward" field.
  22858. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22859. m.action_forward = &ctf
  22860. }
  22861. // ActionForward returns the value of the "action_forward" field in the mutation.
  22862. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22863. v := m.action_forward
  22864. if v == nil {
  22865. return
  22866. }
  22867. return *v, true
  22868. }
  22869. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22870. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22872. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22873. if !m.op.Is(OpUpdateOne) {
  22874. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22875. }
  22876. if m.id == nil || m.oldValue == nil {
  22877. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22878. }
  22879. oldValue, err := m.oldValue(ctx)
  22880. if err != nil {
  22881. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22882. }
  22883. return oldValue.ActionForward, nil
  22884. }
  22885. // ClearActionForward clears the value of the "action_forward" field.
  22886. func (m *SopStageMutation) ClearActionForward() {
  22887. m.action_forward = nil
  22888. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22889. }
  22890. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22891. func (m *SopStageMutation) ActionForwardCleared() bool {
  22892. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22893. return ok
  22894. }
  22895. // ResetActionForward resets all changes to the "action_forward" field.
  22896. func (m *SopStageMutation) ResetActionForward() {
  22897. m.action_forward = nil
  22898. delete(m.clearedFields, sopstage.FieldActionForward)
  22899. }
  22900. // SetIndexSort sets the "index_sort" field.
  22901. func (m *SopStageMutation) SetIndexSort(i int) {
  22902. m.index_sort = &i
  22903. m.addindex_sort = nil
  22904. }
  22905. // IndexSort returns the value of the "index_sort" field in the mutation.
  22906. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22907. v := m.index_sort
  22908. if v == nil {
  22909. return
  22910. }
  22911. return *v, true
  22912. }
  22913. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22914. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22916. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22917. if !m.op.Is(OpUpdateOne) {
  22918. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22919. }
  22920. if m.id == nil || m.oldValue == nil {
  22921. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22922. }
  22923. oldValue, err := m.oldValue(ctx)
  22924. if err != nil {
  22925. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22926. }
  22927. return oldValue.IndexSort, nil
  22928. }
  22929. // AddIndexSort adds i to the "index_sort" field.
  22930. func (m *SopStageMutation) AddIndexSort(i int) {
  22931. if m.addindex_sort != nil {
  22932. *m.addindex_sort += i
  22933. } else {
  22934. m.addindex_sort = &i
  22935. }
  22936. }
  22937. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22938. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22939. v := m.addindex_sort
  22940. if v == nil {
  22941. return
  22942. }
  22943. return *v, true
  22944. }
  22945. // ClearIndexSort clears the value of the "index_sort" field.
  22946. func (m *SopStageMutation) ClearIndexSort() {
  22947. m.index_sort = nil
  22948. m.addindex_sort = nil
  22949. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22950. }
  22951. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22952. func (m *SopStageMutation) IndexSortCleared() bool {
  22953. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22954. return ok
  22955. }
  22956. // ResetIndexSort resets all changes to the "index_sort" field.
  22957. func (m *SopStageMutation) ResetIndexSort() {
  22958. m.index_sort = nil
  22959. m.addindex_sort = nil
  22960. delete(m.clearedFields, sopstage.FieldIndexSort)
  22961. }
  22962. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22963. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22964. m.sop_task = &id
  22965. }
  22966. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22967. func (m *SopStageMutation) ClearSopTask() {
  22968. m.clearedsop_task = true
  22969. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22970. }
  22971. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22972. func (m *SopStageMutation) SopTaskCleared() bool {
  22973. return m.clearedsop_task
  22974. }
  22975. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22976. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22977. if m.sop_task != nil {
  22978. return *m.sop_task, true
  22979. }
  22980. return
  22981. }
  22982. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22983. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22984. // SopTaskID instead. It exists only for internal usage by the builders.
  22985. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22986. if id := m.sop_task; id != nil {
  22987. ids = append(ids, *id)
  22988. }
  22989. return
  22990. }
  22991. // ResetSopTask resets all changes to the "sop_task" edge.
  22992. func (m *SopStageMutation) ResetSopTask() {
  22993. m.sop_task = nil
  22994. m.clearedsop_task = false
  22995. }
  22996. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22997. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22998. if m.stage_nodes == nil {
  22999. m.stage_nodes = make(map[uint64]struct{})
  23000. }
  23001. for i := range ids {
  23002. m.stage_nodes[ids[i]] = struct{}{}
  23003. }
  23004. }
  23005. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23006. func (m *SopStageMutation) ClearStageNodes() {
  23007. m.clearedstage_nodes = true
  23008. }
  23009. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23010. func (m *SopStageMutation) StageNodesCleared() bool {
  23011. return m.clearedstage_nodes
  23012. }
  23013. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23014. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23015. if m.removedstage_nodes == nil {
  23016. m.removedstage_nodes = make(map[uint64]struct{})
  23017. }
  23018. for i := range ids {
  23019. delete(m.stage_nodes, ids[i])
  23020. m.removedstage_nodes[ids[i]] = struct{}{}
  23021. }
  23022. }
  23023. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23024. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23025. for id := range m.removedstage_nodes {
  23026. ids = append(ids, id)
  23027. }
  23028. return
  23029. }
  23030. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23031. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23032. for id := range m.stage_nodes {
  23033. ids = append(ids, id)
  23034. }
  23035. return
  23036. }
  23037. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23038. func (m *SopStageMutation) ResetStageNodes() {
  23039. m.stage_nodes = nil
  23040. m.clearedstage_nodes = false
  23041. m.removedstage_nodes = nil
  23042. }
  23043. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23044. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23045. if m.stage_messages == nil {
  23046. m.stage_messages = make(map[uint64]struct{})
  23047. }
  23048. for i := range ids {
  23049. m.stage_messages[ids[i]] = struct{}{}
  23050. }
  23051. }
  23052. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23053. func (m *SopStageMutation) ClearStageMessages() {
  23054. m.clearedstage_messages = true
  23055. }
  23056. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23057. func (m *SopStageMutation) StageMessagesCleared() bool {
  23058. return m.clearedstage_messages
  23059. }
  23060. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23061. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23062. if m.removedstage_messages == nil {
  23063. m.removedstage_messages = make(map[uint64]struct{})
  23064. }
  23065. for i := range ids {
  23066. delete(m.stage_messages, ids[i])
  23067. m.removedstage_messages[ids[i]] = struct{}{}
  23068. }
  23069. }
  23070. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23071. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23072. for id := range m.removedstage_messages {
  23073. ids = append(ids, id)
  23074. }
  23075. return
  23076. }
  23077. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23078. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23079. for id := range m.stage_messages {
  23080. ids = append(ids, id)
  23081. }
  23082. return
  23083. }
  23084. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23085. func (m *SopStageMutation) ResetStageMessages() {
  23086. m.stage_messages = nil
  23087. m.clearedstage_messages = false
  23088. m.removedstage_messages = nil
  23089. }
  23090. // Where appends a list predicates to the SopStageMutation builder.
  23091. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23092. m.predicates = append(m.predicates, ps...)
  23093. }
  23094. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23095. // users can use type-assertion to append predicates that do not depend on any generated package.
  23096. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23097. p := make([]predicate.SopStage, len(ps))
  23098. for i := range ps {
  23099. p[i] = ps[i]
  23100. }
  23101. m.Where(p...)
  23102. }
  23103. // Op returns the operation name.
  23104. func (m *SopStageMutation) Op() Op {
  23105. return m.op
  23106. }
  23107. // SetOp allows setting the mutation operation.
  23108. func (m *SopStageMutation) SetOp(op Op) {
  23109. m.op = op
  23110. }
  23111. // Type returns the node type of this mutation (SopStage).
  23112. func (m *SopStageMutation) Type() string {
  23113. return m.typ
  23114. }
  23115. // Fields returns all fields that were changed during this mutation. Note that in
  23116. // order to get all numeric fields that were incremented/decremented, call
  23117. // AddedFields().
  23118. func (m *SopStageMutation) Fields() []string {
  23119. fields := make([]string, 0, 14)
  23120. if m.created_at != nil {
  23121. fields = append(fields, sopstage.FieldCreatedAt)
  23122. }
  23123. if m.updated_at != nil {
  23124. fields = append(fields, sopstage.FieldUpdatedAt)
  23125. }
  23126. if m.status != nil {
  23127. fields = append(fields, sopstage.FieldStatus)
  23128. }
  23129. if m.deleted_at != nil {
  23130. fields = append(fields, sopstage.FieldDeletedAt)
  23131. }
  23132. if m.sop_task != nil {
  23133. fields = append(fields, sopstage.FieldTaskID)
  23134. }
  23135. if m.name != nil {
  23136. fields = append(fields, sopstage.FieldName)
  23137. }
  23138. if m.condition_type != nil {
  23139. fields = append(fields, sopstage.FieldConditionType)
  23140. }
  23141. if m.condition_operator != nil {
  23142. fields = append(fields, sopstage.FieldConditionOperator)
  23143. }
  23144. if m.condition_list != nil {
  23145. fields = append(fields, sopstage.FieldConditionList)
  23146. }
  23147. if m.action_message != nil {
  23148. fields = append(fields, sopstage.FieldActionMessage)
  23149. }
  23150. if m.action_label_add != nil {
  23151. fields = append(fields, sopstage.FieldActionLabelAdd)
  23152. }
  23153. if m.action_label_del != nil {
  23154. fields = append(fields, sopstage.FieldActionLabelDel)
  23155. }
  23156. if m.action_forward != nil {
  23157. fields = append(fields, sopstage.FieldActionForward)
  23158. }
  23159. if m.index_sort != nil {
  23160. fields = append(fields, sopstage.FieldIndexSort)
  23161. }
  23162. return fields
  23163. }
  23164. // Field returns the value of a field with the given name. The second boolean
  23165. // return value indicates that this field was not set, or was not defined in the
  23166. // schema.
  23167. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23168. switch name {
  23169. case sopstage.FieldCreatedAt:
  23170. return m.CreatedAt()
  23171. case sopstage.FieldUpdatedAt:
  23172. return m.UpdatedAt()
  23173. case sopstage.FieldStatus:
  23174. return m.Status()
  23175. case sopstage.FieldDeletedAt:
  23176. return m.DeletedAt()
  23177. case sopstage.FieldTaskID:
  23178. return m.TaskID()
  23179. case sopstage.FieldName:
  23180. return m.Name()
  23181. case sopstage.FieldConditionType:
  23182. return m.ConditionType()
  23183. case sopstage.FieldConditionOperator:
  23184. return m.ConditionOperator()
  23185. case sopstage.FieldConditionList:
  23186. return m.ConditionList()
  23187. case sopstage.FieldActionMessage:
  23188. return m.ActionMessage()
  23189. case sopstage.FieldActionLabelAdd:
  23190. return m.ActionLabelAdd()
  23191. case sopstage.FieldActionLabelDel:
  23192. return m.ActionLabelDel()
  23193. case sopstage.FieldActionForward:
  23194. return m.ActionForward()
  23195. case sopstage.FieldIndexSort:
  23196. return m.IndexSort()
  23197. }
  23198. return nil, false
  23199. }
  23200. // OldField returns the old value of the field from the database. An error is
  23201. // returned if the mutation operation is not UpdateOne, or the query to the
  23202. // database failed.
  23203. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23204. switch name {
  23205. case sopstage.FieldCreatedAt:
  23206. return m.OldCreatedAt(ctx)
  23207. case sopstage.FieldUpdatedAt:
  23208. return m.OldUpdatedAt(ctx)
  23209. case sopstage.FieldStatus:
  23210. return m.OldStatus(ctx)
  23211. case sopstage.FieldDeletedAt:
  23212. return m.OldDeletedAt(ctx)
  23213. case sopstage.FieldTaskID:
  23214. return m.OldTaskID(ctx)
  23215. case sopstage.FieldName:
  23216. return m.OldName(ctx)
  23217. case sopstage.FieldConditionType:
  23218. return m.OldConditionType(ctx)
  23219. case sopstage.FieldConditionOperator:
  23220. return m.OldConditionOperator(ctx)
  23221. case sopstage.FieldConditionList:
  23222. return m.OldConditionList(ctx)
  23223. case sopstage.FieldActionMessage:
  23224. return m.OldActionMessage(ctx)
  23225. case sopstage.FieldActionLabelAdd:
  23226. return m.OldActionLabelAdd(ctx)
  23227. case sopstage.FieldActionLabelDel:
  23228. return m.OldActionLabelDel(ctx)
  23229. case sopstage.FieldActionForward:
  23230. return m.OldActionForward(ctx)
  23231. case sopstage.FieldIndexSort:
  23232. return m.OldIndexSort(ctx)
  23233. }
  23234. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23235. }
  23236. // SetField sets the value of a field with the given name. It returns an error if
  23237. // the field is not defined in the schema, or if the type mismatched the field
  23238. // type.
  23239. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23240. switch name {
  23241. case sopstage.FieldCreatedAt:
  23242. v, ok := value.(time.Time)
  23243. if !ok {
  23244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23245. }
  23246. m.SetCreatedAt(v)
  23247. return nil
  23248. case sopstage.FieldUpdatedAt:
  23249. v, ok := value.(time.Time)
  23250. if !ok {
  23251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23252. }
  23253. m.SetUpdatedAt(v)
  23254. return nil
  23255. case sopstage.FieldStatus:
  23256. v, ok := value.(uint8)
  23257. if !ok {
  23258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23259. }
  23260. m.SetStatus(v)
  23261. return nil
  23262. case sopstage.FieldDeletedAt:
  23263. v, ok := value.(time.Time)
  23264. if !ok {
  23265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23266. }
  23267. m.SetDeletedAt(v)
  23268. return nil
  23269. case sopstage.FieldTaskID:
  23270. v, ok := value.(uint64)
  23271. if !ok {
  23272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23273. }
  23274. m.SetTaskID(v)
  23275. return nil
  23276. case sopstage.FieldName:
  23277. v, ok := value.(string)
  23278. if !ok {
  23279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23280. }
  23281. m.SetName(v)
  23282. return nil
  23283. case sopstage.FieldConditionType:
  23284. v, ok := value.(int)
  23285. if !ok {
  23286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23287. }
  23288. m.SetConditionType(v)
  23289. return nil
  23290. case sopstage.FieldConditionOperator:
  23291. v, ok := value.(int)
  23292. if !ok {
  23293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23294. }
  23295. m.SetConditionOperator(v)
  23296. return nil
  23297. case sopstage.FieldConditionList:
  23298. v, ok := value.([]custom_types.Condition)
  23299. if !ok {
  23300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23301. }
  23302. m.SetConditionList(v)
  23303. return nil
  23304. case sopstage.FieldActionMessage:
  23305. v, ok := value.([]custom_types.Action)
  23306. if !ok {
  23307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23308. }
  23309. m.SetActionMessage(v)
  23310. return nil
  23311. case sopstage.FieldActionLabelAdd:
  23312. v, ok := value.([]uint64)
  23313. if !ok {
  23314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23315. }
  23316. m.SetActionLabelAdd(v)
  23317. return nil
  23318. case sopstage.FieldActionLabelDel:
  23319. v, ok := value.([]uint64)
  23320. if !ok {
  23321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23322. }
  23323. m.SetActionLabelDel(v)
  23324. return nil
  23325. case sopstage.FieldActionForward:
  23326. v, ok := value.(*custom_types.ActionForward)
  23327. if !ok {
  23328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23329. }
  23330. m.SetActionForward(v)
  23331. return nil
  23332. case sopstage.FieldIndexSort:
  23333. v, ok := value.(int)
  23334. if !ok {
  23335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23336. }
  23337. m.SetIndexSort(v)
  23338. return nil
  23339. }
  23340. return fmt.Errorf("unknown SopStage field %s", name)
  23341. }
  23342. // AddedFields returns all numeric fields that were incremented/decremented during
  23343. // this mutation.
  23344. func (m *SopStageMutation) AddedFields() []string {
  23345. var fields []string
  23346. if m.addstatus != nil {
  23347. fields = append(fields, sopstage.FieldStatus)
  23348. }
  23349. if m.addcondition_type != nil {
  23350. fields = append(fields, sopstage.FieldConditionType)
  23351. }
  23352. if m.addcondition_operator != nil {
  23353. fields = append(fields, sopstage.FieldConditionOperator)
  23354. }
  23355. if m.addindex_sort != nil {
  23356. fields = append(fields, sopstage.FieldIndexSort)
  23357. }
  23358. return fields
  23359. }
  23360. // AddedField returns the numeric value that was incremented/decremented on a field
  23361. // with the given name. The second boolean return value indicates that this field
  23362. // was not set, or was not defined in the schema.
  23363. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23364. switch name {
  23365. case sopstage.FieldStatus:
  23366. return m.AddedStatus()
  23367. case sopstage.FieldConditionType:
  23368. return m.AddedConditionType()
  23369. case sopstage.FieldConditionOperator:
  23370. return m.AddedConditionOperator()
  23371. case sopstage.FieldIndexSort:
  23372. return m.AddedIndexSort()
  23373. }
  23374. return nil, false
  23375. }
  23376. // AddField adds the value to the field with the given name. It returns an error if
  23377. // the field is not defined in the schema, or if the type mismatched the field
  23378. // type.
  23379. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23380. switch name {
  23381. case sopstage.FieldStatus:
  23382. v, ok := value.(int8)
  23383. if !ok {
  23384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23385. }
  23386. m.AddStatus(v)
  23387. return nil
  23388. case sopstage.FieldConditionType:
  23389. v, ok := value.(int)
  23390. if !ok {
  23391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23392. }
  23393. m.AddConditionType(v)
  23394. return nil
  23395. case sopstage.FieldConditionOperator:
  23396. v, ok := value.(int)
  23397. if !ok {
  23398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23399. }
  23400. m.AddConditionOperator(v)
  23401. return nil
  23402. case sopstage.FieldIndexSort:
  23403. v, ok := value.(int)
  23404. if !ok {
  23405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23406. }
  23407. m.AddIndexSort(v)
  23408. return nil
  23409. }
  23410. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23411. }
  23412. // ClearedFields returns all nullable fields that were cleared during this
  23413. // mutation.
  23414. func (m *SopStageMutation) ClearedFields() []string {
  23415. var fields []string
  23416. if m.FieldCleared(sopstage.FieldStatus) {
  23417. fields = append(fields, sopstage.FieldStatus)
  23418. }
  23419. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23420. fields = append(fields, sopstage.FieldDeletedAt)
  23421. }
  23422. if m.FieldCleared(sopstage.FieldActionMessage) {
  23423. fields = append(fields, sopstage.FieldActionMessage)
  23424. }
  23425. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23426. fields = append(fields, sopstage.FieldActionLabelAdd)
  23427. }
  23428. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23429. fields = append(fields, sopstage.FieldActionLabelDel)
  23430. }
  23431. if m.FieldCleared(sopstage.FieldActionForward) {
  23432. fields = append(fields, sopstage.FieldActionForward)
  23433. }
  23434. if m.FieldCleared(sopstage.FieldIndexSort) {
  23435. fields = append(fields, sopstage.FieldIndexSort)
  23436. }
  23437. return fields
  23438. }
  23439. // FieldCleared returns a boolean indicating if a field with the given name was
  23440. // cleared in this mutation.
  23441. func (m *SopStageMutation) FieldCleared(name string) bool {
  23442. _, ok := m.clearedFields[name]
  23443. return ok
  23444. }
  23445. // ClearField clears the value of the field with the given name. It returns an
  23446. // error if the field is not defined in the schema.
  23447. func (m *SopStageMutation) ClearField(name string) error {
  23448. switch name {
  23449. case sopstage.FieldStatus:
  23450. m.ClearStatus()
  23451. return nil
  23452. case sopstage.FieldDeletedAt:
  23453. m.ClearDeletedAt()
  23454. return nil
  23455. case sopstage.FieldActionMessage:
  23456. m.ClearActionMessage()
  23457. return nil
  23458. case sopstage.FieldActionLabelAdd:
  23459. m.ClearActionLabelAdd()
  23460. return nil
  23461. case sopstage.FieldActionLabelDel:
  23462. m.ClearActionLabelDel()
  23463. return nil
  23464. case sopstage.FieldActionForward:
  23465. m.ClearActionForward()
  23466. return nil
  23467. case sopstage.FieldIndexSort:
  23468. m.ClearIndexSort()
  23469. return nil
  23470. }
  23471. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23472. }
  23473. // ResetField resets all changes in the mutation for the field with the given name.
  23474. // It returns an error if the field is not defined in the schema.
  23475. func (m *SopStageMutation) ResetField(name string) error {
  23476. switch name {
  23477. case sopstage.FieldCreatedAt:
  23478. m.ResetCreatedAt()
  23479. return nil
  23480. case sopstage.FieldUpdatedAt:
  23481. m.ResetUpdatedAt()
  23482. return nil
  23483. case sopstage.FieldStatus:
  23484. m.ResetStatus()
  23485. return nil
  23486. case sopstage.FieldDeletedAt:
  23487. m.ResetDeletedAt()
  23488. return nil
  23489. case sopstage.FieldTaskID:
  23490. m.ResetTaskID()
  23491. return nil
  23492. case sopstage.FieldName:
  23493. m.ResetName()
  23494. return nil
  23495. case sopstage.FieldConditionType:
  23496. m.ResetConditionType()
  23497. return nil
  23498. case sopstage.FieldConditionOperator:
  23499. m.ResetConditionOperator()
  23500. return nil
  23501. case sopstage.FieldConditionList:
  23502. m.ResetConditionList()
  23503. return nil
  23504. case sopstage.FieldActionMessage:
  23505. m.ResetActionMessage()
  23506. return nil
  23507. case sopstage.FieldActionLabelAdd:
  23508. m.ResetActionLabelAdd()
  23509. return nil
  23510. case sopstage.FieldActionLabelDel:
  23511. m.ResetActionLabelDel()
  23512. return nil
  23513. case sopstage.FieldActionForward:
  23514. m.ResetActionForward()
  23515. return nil
  23516. case sopstage.FieldIndexSort:
  23517. m.ResetIndexSort()
  23518. return nil
  23519. }
  23520. return fmt.Errorf("unknown SopStage field %s", name)
  23521. }
  23522. // AddedEdges returns all edge names that were set/added in this mutation.
  23523. func (m *SopStageMutation) AddedEdges() []string {
  23524. edges := make([]string, 0, 3)
  23525. if m.sop_task != nil {
  23526. edges = append(edges, sopstage.EdgeSopTask)
  23527. }
  23528. if m.stage_nodes != nil {
  23529. edges = append(edges, sopstage.EdgeStageNodes)
  23530. }
  23531. if m.stage_messages != nil {
  23532. edges = append(edges, sopstage.EdgeStageMessages)
  23533. }
  23534. return edges
  23535. }
  23536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23537. // name in this mutation.
  23538. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23539. switch name {
  23540. case sopstage.EdgeSopTask:
  23541. if id := m.sop_task; id != nil {
  23542. return []ent.Value{*id}
  23543. }
  23544. case sopstage.EdgeStageNodes:
  23545. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23546. for id := range m.stage_nodes {
  23547. ids = append(ids, id)
  23548. }
  23549. return ids
  23550. case sopstage.EdgeStageMessages:
  23551. ids := make([]ent.Value, 0, len(m.stage_messages))
  23552. for id := range m.stage_messages {
  23553. ids = append(ids, id)
  23554. }
  23555. return ids
  23556. }
  23557. return nil
  23558. }
  23559. // RemovedEdges returns all edge names that were removed in this mutation.
  23560. func (m *SopStageMutation) RemovedEdges() []string {
  23561. edges := make([]string, 0, 3)
  23562. if m.removedstage_nodes != nil {
  23563. edges = append(edges, sopstage.EdgeStageNodes)
  23564. }
  23565. if m.removedstage_messages != nil {
  23566. edges = append(edges, sopstage.EdgeStageMessages)
  23567. }
  23568. return edges
  23569. }
  23570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23571. // the given name in this mutation.
  23572. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23573. switch name {
  23574. case sopstage.EdgeStageNodes:
  23575. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23576. for id := range m.removedstage_nodes {
  23577. ids = append(ids, id)
  23578. }
  23579. return ids
  23580. case sopstage.EdgeStageMessages:
  23581. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23582. for id := range m.removedstage_messages {
  23583. ids = append(ids, id)
  23584. }
  23585. return ids
  23586. }
  23587. return nil
  23588. }
  23589. // ClearedEdges returns all edge names that were cleared in this mutation.
  23590. func (m *SopStageMutation) ClearedEdges() []string {
  23591. edges := make([]string, 0, 3)
  23592. if m.clearedsop_task {
  23593. edges = append(edges, sopstage.EdgeSopTask)
  23594. }
  23595. if m.clearedstage_nodes {
  23596. edges = append(edges, sopstage.EdgeStageNodes)
  23597. }
  23598. if m.clearedstage_messages {
  23599. edges = append(edges, sopstage.EdgeStageMessages)
  23600. }
  23601. return edges
  23602. }
  23603. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23604. // was cleared in this mutation.
  23605. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23606. switch name {
  23607. case sopstage.EdgeSopTask:
  23608. return m.clearedsop_task
  23609. case sopstage.EdgeStageNodes:
  23610. return m.clearedstage_nodes
  23611. case sopstage.EdgeStageMessages:
  23612. return m.clearedstage_messages
  23613. }
  23614. return false
  23615. }
  23616. // ClearEdge clears the value of the edge with the given name. It returns an error
  23617. // if that edge is not defined in the schema.
  23618. func (m *SopStageMutation) ClearEdge(name string) error {
  23619. switch name {
  23620. case sopstage.EdgeSopTask:
  23621. m.ClearSopTask()
  23622. return nil
  23623. }
  23624. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23625. }
  23626. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23627. // It returns an error if the edge is not defined in the schema.
  23628. func (m *SopStageMutation) ResetEdge(name string) error {
  23629. switch name {
  23630. case sopstage.EdgeSopTask:
  23631. m.ResetSopTask()
  23632. return nil
  23633. case sopstage.EdgeStageNodes:
  23634. m.ResetStageNodes()
  23635. return nil
  23636. case sopstage.EdgeStageMessages:
  23637. m.ResetStageMessages()
  23638. return nil
  23639. }
  23640. return fmt.Errorf("unknown SopStage edge %s", name)
  23641. }
  23642. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23643. type SopTaskMutation struct {
  23644. config
  23645. op Op
  23646. typ string
  23647. id *uint64
  23648. created_at *time.Time
  23649. updated_at *time.Time
  23650. status *uint8
  23651. addstatus *int8
  23652. deleted_at *time.Time
  23653. name *string
  23654. bot_wxid_list *[]string
  23655. appendbot_wxid_list []string
  23656. _type *int
  23657. add_type *int
  23658. plan_start_time *time.Time
  23659. plan_end_time *time.Time
  23660. creator_id *string
  23661. organization_id *uint64
  23662. addorganization_id *int64
  23663. token *[]string
  23664. appendtoken []string
  23665. clearedFields map[string]struct{}
  23666. task_stages map[uint64]struct{}
  23667. removedtask_stages map[uint64]struct{}
  23668. clearedtask_stages bool
  23669. done bool
  23670. oldValue func(context.Context) (*SopTask, error)
  23671. predicates []predicate.SopTask
  23672. }
  23673. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23674. // soptaskOption allows management of the mutation configuration using functional options.
  23675. type soptaskOption func(*SopTaskMutation)
  23676. // newSopTaskMutation creates new mutation for the SopTask entity.
  23677. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23678. m := &SopTaskMutation{
  23679. config: c,
  23680. op: op,
  23681. typ: TypeSopTask,
  23682. clearedFields: make(map[string]struct{}),
  23683. }
  23684. for _, opt := range opts {
  23685. opt(m)
  23686. }
  23687. return m
  23688. }
  23689. // withSopTaskID sets the ID field of the mutation.
  23690. func withSopTaskID(id uint64) soptaskOption {
  23691. return func(m *SopTaskMutation) {
  23692. var (
  23693. err error
  23694. once sync.Once
  23695. value *SopTask
  23696. )
  23697. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23698. once.Do(func() {
  23699. if m.done {
  23700. err = errors.New("querying old values post mutation is not allowed")
  23701. } else {
  23702. value, err = m.Client().SopTask.Get(ctx, id)
  23703. }
  23704. })
  23705. return value, err
  23706. }
  23707. m.id = &id
  23708. }
  23709. }
  23710. // withSopTask sets the old SopTask of the mutation.
  23711. func withSopTask(node *SopTask) soptaskOption {
  23712. return func(m *SopTaskMutation) {
  23713. m.oldValue = func(context.Context) (*SopTask, error) {
  23714. return node, nil
  23715. }
  23716. m.id = &node.ID
  23717. }
  23718. }
  23719. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23720. // executed in a transaction (ent.Tx), a transactional client is returned.
  23721. func (m SopTaskMutation) Client() *Client {
  23722. client := &Client{config: m.config}
  23723. client.init()
  23724. return client
  23725. }
  23726. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23727. // it returns an error otherwise.
  23728. func (m SopTaskMutation) Tx() (*Tx, error) {
  23729. if _, ok := m.driver.(*txDriver); !ok {
  23730. return nil, errors.New("ent: mutation is not running in a transaction")
  23731. }
  23732. tx := &Tx{config: m.config}
  23733. tx.init()
  23734. return tx, nil
  23735. }
  23736. // SetID sets the value of the id field. Note that this
  23737. // operation is only accepted on creation of SopTask entities.
  23738. func (m *SopTaskMutation) SetID(id uint64) {
  23739. m.id = &id
  23740. }
  23741. // ID returns the ID value in the mutation. Note that the ID is only available
  23742. // if it was provided to the builder or after it was returned from the database.
  23743. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23744. if m.id == nil {
  23745. return
  23746. }
  23747. return *m.id, true
  23748. }
  23749. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23750. // That means, if the mutation is applied within a transaction with an isolation level such
  23751. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23752. // or updated by the mutation.
  23753. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23754. switch {
  23755. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23756. id, exists := m.ID()
  23757. if exists {
  23758. return []uint64{id}, nil
  23759. }
  23760. fallthrough
  23761. case m.op.Is(OpUpdate | OpDelete):
  23762. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23763. default:
  23764. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23765. }
  23766. }
  23767. // SetCreatedAt sets the "created_at" field.
  23768. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23769. m.created_at = &t
  23770. }
  23771. // CreatedAt returns the value of the "created_at" field in the mutation.
  23772. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23773. v := m.created_at
  23774. if v == nil {
  23775. return
  23776. }
  23777. return *v, true
  23778. }
  23779. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23780. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23782. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23783. if !m.op.Is(OpUpdateOne) {
  23784. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23785. }
  23786. if m.id == nil || m.oldValue == nil {
  23787. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23788. }
  23789. oldValue, err := m.oldValue(ctx)
  23790. if err != nil {
  23791. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23792. }
  23793. return oldValue.CreatedAt, nil
  23794. }
  23795. // ResetCreatedAt resets all changes to the "created_at" field.
  23796. func (m *SopTaskMutation) ResetCreatedAt() {
  23797. m.created_at = nil
  23798. }
  23799. // SetUpdatedAt sets the "updated_at" field.
  23800. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23801. m.updated_at = &t
  23802. }
  23803. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23804. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23805. v := m.updated_at
  23806. if v == nil {
  23807. return
  23808. }
  23809. return *v, true
  23810. }
  23811. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23812. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23814. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23815. if !m.op.Is(OpUpdateOne) {
  23816. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23817. }
  23818. if m.id == nil || m.oldValue == nil {
  23819. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23820. }
  23821. oldValue, err := m.oldValue(ctx)
  23822. if err != nil {
  23823. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23824. }
  23825. return oldValue.UpdatedAt, nil
  23826. }
  23827. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23828. func (m *SopTaskMutation) ResetUpdatedAt() {
  23829. m.updated_at = nil
  23830. }
  23831. // SetStatus sets the "status" field.
  23832. func (m *SopTaskMutation) SetStatus(u uint8) {
  23833. m.status = &u
  23834. m.addstatus = nil
  23835. }
  23836. // Status returns the value of the "status" field in the mutation.
  23837. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23838. v := m.status
  23839. if v == nil {
  23840. return
  23841. }
  23842. return *v, true
  23843. }
  23844. // OldStatus returns the old "status" field's value of the SopTask entity.
  23845. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23847. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23848. if !m.op.Is(OpUpdateOne) {
  23849. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23850. }
  23851. if m.id == nil || m.oldValue == nil {
  23852. return v, errors.New("OldStatus requires an ID field in the mutation")
  23853. }
  23854. oldValue, err := m.oldValue(ctx)
  23855. if err != nil {
  23856. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23857. }
  23858. return oldValue.Status, nil
  23859. }
  23860. // AddStatus adds u to the "status" field.
  23861. func (m *SopTaskMutation) AddStatus(u int8) {
  23862. if m.addstatus != nil {
  23863. *m.addstatus += u
  23864. } else {
  23865. m.addstatus = &u
  23866. }
  23867. }
  23868. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23869. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23870. v := m.addstatus
  23871. if v == nil {
  23872. return
  23873. }
  23874. return *v, true
  23875. }
  23876. // ClearStatus clears the value of the "status" field.
  23877. func (m *SopTaskMutation) ClearStatus() {
  23878. m.status = nil
  23879. m.addstatus = nil
  23880. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23881. }
  23882. // StatusCleared returns if the "status" field was cleared in this mutation.
  23883. func (m *SopTaskMutation) StatusCleared() bool {
  23884. _, ok := m.clearedFields[soptask.FieldStatus]
  23885. return ok
  23886. }
  23887. // ResetStatus resets all changes to the "status" field.
  23888. func (m *SopTaskMutation) ResetStatus() {
  23889. m.status = nil
  23890. m.addstatus = nil
  23891. delete(m.clearedFields, soptask.FieldStatus)
  23892. }
  23893. // SetDeletedAt sets the "deleted_at" field.
  23894. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23895. m.deleted_at = &t
  23896. }
  23897. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23898. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23899. v := m.deleted_at
  23900. if v == nil {
  23901. return
  23902. }
  23903. return *v, true
  23904. }
  23905. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23906. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23908. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23909. if !m.op.Is(OpUpdateOne) {
  23910. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23911. }
  23912. if m.id == nil || m.oldValue == nil {
  23913. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23914. }
  23915. oldValue, err := m.oldValue(ctx)
  23916. if err != nil {
  23917. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23918. }
  23919. return oldValue.DeletedAt, nil
  23920. }
  23921. // ClearDeletedAt clears the value of the "deleted_at" field.
  23922. func (m *SopTaskMutation) ClearDeletedAt() {
  23923. m.deleted_at = nil
  23924. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23925. }
  23926. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23927. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23928. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23929. return ok
  23930. }
  23931. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23932. func (m *SopTaskMutation) ResetDeletedAt() {
  23933. m.deleted_at = nil
  23934. delete(m.clearedFields, soptask.FieldDeletedAt)
  23935. }
  23936. // SetName sets the "name" field.
  23937. func (m *SopTaskMutation) SetName(s string) {
  23938. m.name = &s
  23939. }
  23940. // Name returns the value of the "name" field in the mutation.
  23941. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23942. v := m.name
  23943. if v == nil {
  23944. return
  23945. }
  23946. return *v, true
  23947. }
  23948. // OldName returns the old "name" field's value of the SopTask entity.
  23949. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23951. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23952. if !m.op.Is(OpUpdateOne) {
  23953. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23954. }
  23955. if m.id == nil || m.oldValue == nil {
  23956. return v, errors.New("OldName requires an ID field in the mutation")
  23957. }
  23958. oldValue, err := m.oldValue(ctx)
  23959. if err != nil {
  23960. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23961. }
  23962. return oldValue.Name, nil
  23963. }
  23964. // ResetName resets all changes to the "name" field.
  23965. func (m *SopTaskMutation) ResetName() {
  23966. m.name = nil
  23967. }
  23968. // SetBotWxidList sets the "bot_wxid_list" field.
  23969. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23970. m.bot_wxid_list = &s
  23971. m.appendbot_wxid_list = nil
  23972. }
  23973. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23974. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23975. v := m.bot_wxid_list
  23976. if v == nil {
  23977. return
  23978. }
  23979. return *v, true
  23980. }
  23981. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23982. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23984. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23985. if !m.op.Is(OpUpdateOne) {
  23986. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23987. }
  23988. if m.id == nil || m.oldValue == nil {
  23989. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23990. }
  23991. oldValue, err := m.oldValue(ctx)
  23992. if err != nil {
  23993. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23994. }
  23995. return oldValue.BotWxidList, nil
  23996. }
  23997. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23998. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23999. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24000. }
  24001. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24002. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24003. if len(m.appendbot_wxid_list) == 0 {
  24004. return nil, false
  24005. }
  24006. return m.appendbot_wxid_list, true
  24007. }
  24008. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24009. func (m *SopTaskMutation) ClearBotWxidList() {
  24010. m.bot_wxid_list = nil
  24011. m.appendbot_wxid_list = nil
  24012. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24013. }
  24014. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24015. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24016. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24017. return ok
  24018. }
  24019. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24020. func (m *SopTaskMutation) ResetBotWxidList() {
  24021. m.bot_wxid_list = nil
  24022. m.appendbot_wxid_list = nil
  24023. delete(m.clearedFields, soptask.FieldBotWxidList)
  24024. }
  24025. // SetType sets the "type" field.
  24026. func (m *SopTaskMutation) SetType(i int) {
  24027. m._type = &i
  24028. m.add_type = nil
  24029. }
  24030. // GetType returns the value of the "type" field in the mutation.
  24031. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24032. v := m._type
  24033. if v == nil {
  24034. return
  24035. }
  24036. return *v, true
  24037. }
  24038. // OldType returns the old "type" field's value of the SopTask entity.
  24039. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24041. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24042. if !m.op.Is(OpUpdateOne) {
  24043. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24044. }
  24045. if m.id == nil || m.oldValue == nil {
  24046. return v, errors.New("OldType requires an ID field in the mutation")
  24047. }
  24048. oldValue, err := m.oldValue(ctx)
  24049. if err != nil {
  24050. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24051. }
  24052. return oldValue.Type, nil
  24053. }
  24054. // AddType adds i to the "type" field.
  24055. func (m *SopTaskMutation) AddType(i int) {
  24056. if m.add_type != nil {
  24057. *m.add_type += i
  24058. } else {
  24059. m.add_type = &i
  24060. }
  24061. }
  24062. // AddedType returns the value that was added to the "type" field in this mutation.
  24063. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24064. v := m.add_type
  24065. if v == nil {
  24066. return
  24067. }
  24068. return *v, true
  24069. }
  24070. // ResetType resets all changes to the "type" field.
  24071. func (m *SopTaskMutation) ResetType() {
  24072. m._type = nil
  24073. m.add_type = nil
  24074. }
  24075. // SetPlanStartTime sets the "plan_start_time" field.
  24076. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24077. m.plan_start_time = &t
  24078. }
  24079. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24080. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24081. v := m.plan_start_time
  24082. if v == nil {
  24083. return
  24084. }
  24085. return *v, true
  24086. }
  24087. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24088. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24090. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24091. if !m.op.Is(OpUpdateOne) {
  24092. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24093. }
  24094. if m.id == nil || m.oldValue == nil {
  24095. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24096. }
  24097. oldValue, err := m.oldValue(ctx)
  24098. if err != nil {
  24099. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24100. }
  24101. return oldValue.PlanStartTime, nil
  24102. }
  24103. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24104. func (m *SopTaskMutation) ClearPlanStartTime() {
  24105. m.plan_start_time = nil
  24106. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24107. }
  24108. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24109. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24110. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24111. return ok
  24112. }
  24113. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24114. func (m *SopTaskMutation) ResetPlanStartTime() {
  24115. m.plan_start_time = nil
  24116. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24117. }
  24118. // SetPlanEndTime sets the "plan_end_time" field.
  24119. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24120. m.plan_end_time = &t
  24121. }
  24122. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24123. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24124. v := m.plan_end_time
  24125. if v == nil {
  24126. return
  24127. }
  24128. return *v, true
  24129. }
  24130. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24131. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24133. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24134. if !m.op.Is(OpUpdateOne) {
  24135. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24136. }
  24137. if m.id == nil || m.oldValue == nil {
  24138. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24139. }
  24140. oldValue, err := m.oldValue(ctx)
  24141. if err != nil {
  24142. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24143. }
  24144. return oldValue.PlanEndTime, nil
  24145. }
  24146. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24147. func (m *SopTaskMutation) ClearPlanEndTime() {
  24148. m.plan_end_time = nil
  24149. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24150. }
  24151. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24152. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24153. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24154. return ok
  24155. }
  24156. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24157. func (m *SopTaskMutation) ResetPlanEndTime() {
  24158. m.plan_end_time = nil
  24159. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24160. }
  24161. // SetCreatorID sets the "creator_id" field.
  24162. func (m *SopTaskMutation) SetCreatorID(s string) {
  24163. m.creator_id = &s
  24164. }
  24165. // CreatorID returns the value of the "creator_id" field in the mutation.
  24166. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24167. v := m.creator_id
  24168. if v == nil {
  24169. return
  24170. }
  24171. return *v, true
  24172. }
  24173. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24174. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24176. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24177. if !m.op.Is(OpUpdateOne) {
  24178. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24179. }
  24180. if m.id == nil || m.oldValue == nil {
  24181. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24182. }
  24183. oldValue, err := m.oldValue(ctx)
  24184. if err != nil {
  24185. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24186. }
  24187. return oldValue.CreatorID, nil
  24188. }
  24189. // ClearCreatorID clears the value of the "creator_id" field.
  24190. func (m *SopTaskMutation) ClearCreatorID() {
  24191. m.creator_id = nil
  24192. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24193. }
  24194. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24195. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24196. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24197. return ok
  24198. }
  24199. // ResetCreatorID resets all changes to the "creator_id" field.
  24200. func (m *SopTaskMutation) ResetCreatorID() {
  24201. m.creator_id = nil
  24202. delete(m.clearedFields, soptask.FieldCreatorID)
  24203. }
  24204. // SetOrganizationID sets the "organization_id" field.
  24205. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24206. m.organization_id = &u
  24207. m.addorganization_id = nil
  24208. }
  24209. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24210. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24211. v := m.organization_id
  24212. if v == nil {
  24213. return
  24214. }
  24215. return *v, true
  24216. }
  24217. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24218. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24220. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24221. if !m.op.Is(OpUpdateOne) {
  24222. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24223. }
  24224. if m.id == nil || m.oldValue == nil {
  24225. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24226. }
  24227. oldValue, err := m.oldValue(ctx)
  24228. if err != nil {
  24229. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24230. }
  24231. return oldValue.OrganizationID, nil
  24232. }
  24233. // AddOrganizationID adds u to the "organization_id" field.
  24234. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24235. if m.addorganization_id != nil {
  24236. *m.addorganization_id += u
  24237. } else {
  24238. m.addorganization_id = &u
  24239. }
  24240. }
  24241. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24242. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24243. v := m.addorganization_id
  24244. if v == nil {
  24245. return
  24246. }
  24247. return *v, true
  24248. }
  24249. // ClearOrganizationID clears the value of the "organization_id" field.
  24250. func (m *SopTaskMutation) ClearOrganizationID() {
  24251. m.organization_id = nil
  24252. m.addorganization_id = nil
  24253. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24254. }
  24255. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24256. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24257. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24258. return ok
  24259. }
  24260. // ResetOrganizationID resets all changes to the "organization_id" field.
  24261. func (m *SopTaskMutation) ResetOrganizationID() {
  24262. m.organization_id = nil
  24263. m.addorganization_id = nil
  24264. delete(m.clearedFields, soptask.FieldOrganizationID)
  24265. }
  24266. // SetToken sets the "token" field.
  24267. func (m *SopTaskMutation) SetToken(s []string) {
  24268. m.token = &s
  24269. m.appendtoken = nil
  24270. }
  24271. // Token returns the value of the "token" field in the mutation.
  24272. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24273. v := m.token
  24274. if v == nil {
  24275. return
  24276. }
  24277. return *v, true
  24278. }
  24279. // OldToken returns the old "token" field's value of the SopTask entity.
  24280. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24282. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24283. if !m.op.Is(OpUpdateOne) {
  24284. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24285. }
  24286. if m.id == nil || m.oldValue == nil {
  24287. return v, errors.New("OldToken requires an ID field in the mutation")
  24288. }
  24289. oldValue, err := m.oldValue(ctx)
  24290. if err != nil {
  24291. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24292. }
  24293. return oldValue.Token, nil
  24294. }
  24295. // AppendToken adds s to the "token" field.
  24296. func (m *SopTaskMutation) AppendToken(s []string) {
  24297. m.appendtoken = append(m.appendtoken, s...)
  24298. }
  24299. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24300. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24301. if len(m.appendtoken) == 0 {
  24302. return nil, false
  24303. }
  24304. return m.appendtoken, true
  24305. }
  24306. // ClearToken clears the value of the "token" field.
  24307. func (m *SopTaskMutation) ClearToken() {
  24308. m.token = nil
  24309. m.appendtoken = nil
  24310. m.clearedFields[soptask.FieldToken] = struct{}{}
  24311. }
  24312. // TokenCleared returns if the "token" field was cleared in this mutation.
  24313. func (m *SopTaskMutation) TokenCleared() bool {
  24314. _, ok := m.clearedFields[soptask.FieldToken]
  24315. return ok
  24316. }
  24317. // ResetToken resets all changes to the "token" field.
  24318. func (m *SopTaskMutation) ResetToken() {
  24319. m.token = nil
  24320. m.appendtoken = nil
  24321. delete(m.clearedFields, soptask.FieldToken)
  24322. }
  24323. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24324. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24325. if m.task_stages == nil {
  24326. m.task_stages = make(map[uint64]struct{})
  24327. }
  24328. for i := range ids {
  24329. m.task_stages[ids[i]] = struct{}{}
  24330. }
  24331. }
  24332. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24333. func (m *SopTaskMutation) ClearTaskStages() {
  24334. m.clearedtask_stages = true
  24335. }
  24336. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24337. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24338. return m.clearedtask_stages
  24339. }
  24340. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24341. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24342. if m.removedtask_stages == nil {
  24343. m.removedtask_stages = make(map[uint64]struct{})
  24344. }
  24345. for i := range ids {
  24346. delete(m.task_stages, ids[i])
  24347. m.removedtask_stages[ids[i]] = struct{}{}
  24348. }
  24349. }
  24350. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24351. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24352. for id := range m.removedtask_stages {
  24353. ids = append(ids, id)
  24354. }
  24355. return
  24356. }
  24357. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24358. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24359. for id := range m.task_stages {
  24360. ids = append(ids, id)
  24361. }
  24362. return
  24363. }
  24364. // ResetTaskStages resets all changes to the "task_stages" edge.
  24365. func (m *SopTaskMutation) ResetTaskStages() {
  24366. m.task_stages = nil
  24367. m.clearedtask_stages = false
  24368. m.removedtask_stages = nil
  24369. }
  24370. // Where appends a list predicates to the SopTaskMutation builder.
  24371. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24372. m.predicates = append(m.predicates, ps...)
  24373. }
  24374. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24375. // users can use type-assertion to append predicates that do not depend on any generated package.
  24376. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24377. p := make([]predicate.SopTask, len(ps))
  24378. for i := range ps {
  24379. p[i] = ps[i]
  24380. }
  24381. m.Where(p...)
  24382. }
  24383. // Op returns the operation name.
  24384. func (m *SopTaskMutation) Op() Op {
  24385. return m.op
  24386. }
  24387. // SetOp allows setting the mutation operation.
  24388. func (m *SopTaskMutation) SetOp(op Op) {
  24389. m.op = op
  24390. }
  24391. // Type returns the node type of this mutation (SopTask).
  24392. func (m *SopTaskMutation) Type() string {
  24393. return m.typ
  24394. }
  24395. // Fields returns all fields that were changed during this mutation. Note that in
  24396. // order to get all numeric fields that were incremented/decremented, call
  24397. // AddedFields().
  24398. func (m *SopTaskMutation) Fields() []string {
  24399. fields := make([]string, 0, 12)
  24400. if m.created_at != nil {
  24401. fields = append(fields, soptask.FieldCreatedAt)
  24402. }
  24403. if m.updated_at != nil {
  24404. fields = append(fields, soptask.FieldUpdatedAt)
  24405. }
  24406. if m.status != nil {
  24407. fields = append(fields, soptask.FieldStatus)
  24408. }
  24409. if m.deleted_at != nil {
  24410. fields = append(fields, soptask.FieldDeletedAt)
  24411. }
  24412. if m.name != nil {
  24413. fields = append(fields, soptask.FieldName)
  24414. }
  24415. if m.bot_wxid_list != nil {
  24416. fields = append(fields, soptask.FieldBotWxidList)
  24417. }
  24418. if m._type != nil {
  24419. fields = append(fields, soptask.FieldType)
  24420. }
  24421. if m.plan_start_time != nil {
  24422. fields = append(fields, soptask.FieldPlanStartTime)
  24423. }
  24424. if m.plan_end_time != nil {
  24425. fields = append(fields, soptask.FieldPlanEndTime)
  24426. }
  24427. if m.creator_id != nil {
  24428. fields = append(fields, soptask.FieldCreatorID)
  24429. }
  24430. if m.organization_id != nil {
  24431. fields = append(fields, soptask.FieldOrganizationID)
  24432. }
  24433. if m.token != nil {
  24434. fields = append(fields, soptask.FieldToken)
  24435. }
  24436. return fields
  24437. }
  24438. // Field returns the value of a field with the given name. The second boolean
  24439. // return value indicates that this field was not set, or was not defined in the
  24440. // schema.
  24441. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24442. switch name {
  24443. case soptask.FieldCreatedAt:
  24444. return m.CreatedAt()
  24445. case soptask.FieldUpdatedAt:
  24446. return m.UpdatedAt()
  24447. case soptask.FieldStatus:
  24448. return m.Status()
  24449. case soptask.FieldDeletedAt:
  24450. return m.DeletedAt()
  24451. case soptask.FieldName:
  24452. return m.Name()
  24453. case soptask.FieldBotWxidList:
  24454. return m.BotWxidList()
  24455. case soptask.FieldType:
  24456. return m.GetType()
  24457. case soptask.FieldPlanStartTime:
  24458. return m.PlanStartTime()
  24459. case soptask.FieldPlanEndTime:
  24460. return m.PlanEndTime()
  24461. case soptask.FieldCreatorID:
  24462. return m.CreatorID()
  24463. case soptask.FieldOrganizationID:
  24464. return m.OrganizationID()
  24465. case soptask.FieldToken:
  24466. return m.Token()
  24467. }
  24468. return nil, false
  24469. }
  24470. // OldField returns the old value of the field from the database. An error is
  24471. // returned if the mutation operation is not UpdateOne, or the query to the
  24472. // database failed.
  24473. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24474. switch name {
  24475. case soptask.FieldCreatedAt:
  24476. return m.OldCreatedAt(ctx)
  24477. case soptask.FieldUpdatedAt:
  24478. return m.OldUpdatedAt(ctx)
  24479. case soptask.FieldStatus:
  24480. return m.OldStatus(ctx)
  24481. case soptask.FieldDeletedAt:
  24482. return m.OldDeletedAt(ctx)
  24483. case soptask.FieldName:
  24484. return m.OldName(ctx)
  24485. case soptask.FieldBotWxidList:
  24486. return m.OldBotWxidList(ctx)
  24487. case soptask.FieldType:
  24488. return m.OldType(ctx)
  24489. case soptask.FieldPlanStartTime:
  24490. return m.OldPlanStartTime(ctx)
  24491. case soptask.FieldPlanEndTime:
  24492. return m.OldPlanEndTime(ctx)
  24493. case soptask.FieldCreatorID:
  24494. return m.OldCreatorID(ctx)
  24495. case soptask.FieldOrganizationID:
  24496. return m.OldOrganizationID(ctx)
  24497. case soptask.FieldToken:
  24498. return m.OldToken(ctx)
  24499. }
  24500. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24501. }
  24502. // SetField sets the value of a field with the given name. It returns an error if
  24503. // the field is not defined in the schema, or if the type mismatched the field
  24504. // type.
  24505. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24506. switch name {
  24507. case soptask.FieldCreatedAt:
  24508. v, ok := value.(time.Time)
  24509. if !ok {
  24510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24511. }
  24512. m.SetCreatedAt(v)
  24513. return nil
  24514. case soptask.FieldUpdatedAt:
  24515. v, ok := value.(time.Time)
  24516. if !ok {
  24517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24518. }
  24519. m.SetUpdatedAt(v)
  24520. return nil
  24521. case soptask.FieldStatus:
  24522. v, ok := value.(uint8)
  24523. if !ok {
  24524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24525. }
  24526. m.SetStatus(v)
  24527. return nil
  24528. case soptask.FieldDeletedAt:
  24529. v, ok := value.(time.Time)
  24530. if !ok {
  24531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24532. }
  24533. m.SetDeletedAt(v)
  24534. return nil
  24535. case soptask.FieldName:
  24536. v, ok := value.(string)
  24537. if !ok {
  24538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24539. }
  24540. m.SetName(v)
  24541. return nil
  24542. case soptask.FieldBotWxidList:
  24543. v, ok := value.([]string)
  24544. if !ok {
  24545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24546. }
  24547. m.SetBotWxidList(v)
  24548. return nil
  24549. case soptask.FieldType:
  24550. v, ok := value.(int)
  24551. if !ok {
  24552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24553. }
  24554. m.SetType(v)
  24555. return nil
  24556. case soptask.FieldPlanStartTime:
  24557. v, ok := value.(time.Time)
  24558. if !ok {
  24559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24560. }
  24561. m.SetPlanStartTime(v)
  24562. return nil
  24563. case soptask.FieldPlanEndTime:
  24564. v, ok := value.(time.Time)
  24565. if !ok {
  24566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24567. }
  24568. m.SetPlanEndTime(v)
  24569. return nil
  24570. case soptask.FieldCreatorID:
  24571. v, ok := value.(string)
  24572. if !ok {
  24573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24574. }
  24575. m.SetCreatorID(v)
  24576. return nil
  24577. case soptask.FieldOrganizationID:
  24578. v, ok := value.(uint64)
  24579. if !ok {
  24580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24581. }
  24582. m.SetOrganizationID(v)
  24583. return nil
  24584. case soptask.FieldToken:
  24585. v, ok := value.([]string)
  24586. if !ok {
  24587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24588. }
  24589. m.SetToken(v)
  24590. return nil
  24591. }
  24592. return fmt.Errorf("unknown SopTask field %s", name)
  24593. }
  24594. // AddedFields returns all numeric fields that were incremented/decremented during
  24595. // this mutation.
  24596. func (m *SopTaskMutation) AddedFields() []string {
  24597. var fields []string
  24598. if m.addstatus != nil {
  24599. fields = append(fields, soptask.FieldStatus)
  24600. }
  24601. if m.add_type != nil {
  24602. fields = append(fields, soptask.FieldType)
  24603. }
  24604. if m.addorganization_id != nil {
  24605. fields = append(fields, soptask.FieldOrganizationID)
  24606. }
  24607. return fields
  24608. }
  24609. // AddedField returns the numeric value that was incremented/decremented on a field
  24610. // with the given name. The second boolean return value indicates that this field
  24611. // was not set, or was not defined in the schema.
  24612. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24613. switch name {
  24614. case soptask.FieldStatus:
  24615. return m.AddedStatus()
  24616. case soptask.FieldType:
  24617. return m.AddedType()
  24618. case soptask.FieldOrganizationID:
  24619. return m.AddedOrganizationID()
  24620. }
  24621. return nil, false
  24622. }
  24623. // AddField adds the value to the field with the given name. It returns an error if
  24624. // the field is not defined in the schema, or if the type mismatched the field
  24625. // type.
  24626. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24627. switch name {
  24628. case soptask.FieldStatus:
  24629. v, ok := value.(int8)
  24630. if !ok {
  24631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24632. }
  24633. m.AddStatus(v)
  24634. return nil
  24635. case soptask.FieldType:
  24636. v, ok := value.(int)
  24637. if !ok {
  24638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24639. }
  24640. m.AddType(v)
  24641. return nil
  24642. case soptask.FieldOrganizationID:
  24643. v, ok := value.(int64)
  24644. if !ok {
  24645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24646. }
  24647. m.AddOrganizationID(v)
  24648. return nil
  24649. }
  24650. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24651. }
  24652. // ClearedFields returns all nullable fields that were cleared during this
  24653. // mutation.
  24654. func (m *SopTaskMutation) ClearedFields() []string {
  24655. var fields []string
  24656. if m.FieldCleared(soptask.FieldStatus) {
  24657. fields = append(fields, soptask.FieldStatus)
  24658. }
  24659. if m.FieldCleared(soptask.FieldDeletedAt) {
  24660. fields = append(fields, soptask.FieldDeletedAt)
  24661. }
  24662. if m.FieldCleared(soptask.FieldBotWxidList) {
  24663. fields = append(fields, soptask.FieldBotWxidList)
  24664. }
  24665. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24666. fields = append(fields, soptask.FieldPlanStartTime)
  24667. }
  24668. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24669. fields = append(fields, soptask.FieldPlanEndTime)
  24670. }
  24671. if m.FieldCleared(soptask.FieldCreatorID) {
  24672. fields = append(fields, soptask.FieldCreatorID)
  24673. }
  24674. if m.FieldCleared(soptask.FieldOrganizationID) {
  24675. fields = append(fields, soptask.FieldOrganizationID)
  24676. }
  24677. if m.FieldCleared(soptask.FieldToken) {
  24678. fields = append(fields, soptask.FieldToken)
  24679. }
  24680. return fields
  24681. }
  24682. // FieldCleared returns a boolean indicating if a field with the given name was
  24683. // cleared in this mutation.
  24684. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24685. _, ok := m.clearedFields[name]
  24686. return ok
  24687. }
  24688. // ClearField clears the value of the field with the given name. It returns an
  24689. // error if the field is not defined in the schema.
  24690. func (m *SopTaskMutation) ClearField(name string) error {
  24691. switch name {
  24692. case soptask.FieldStatus:
  24693. m.ClearStatus()
  24694. return nil
  24695. case soptask.FieldDeletedAt:
  24696. m.ClearDeletedAt()
  24697. return nil
  24698. case soptask.FieldBotWxidList:
  24699. m.ClearBotWxidList()
  24700. return nil
  24701. case soptask.FieldPlanStartTime:
  24702. m.ClearPlanStartTime()
  24703. return nil
  24704. case soptask.FieldPlanEndTime:
  24705. m.ClearPlanEndTime()
  24706. return nil
  24707. case soptask.FieldCreatorID:
  24708. m.ClearCreatorID()
  24709. return nil
  24710. case soptask.FieldOrganizationID:
  24711. m.ClearOrganizationID()
  24712. return nil
  24713. case soptask.FieldToken:
  24714. m.ClearToken()
  24715. return nil
  24716. }
  24717. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24718. }
  24719. // ResetField resets all changes in the mutation for the field with the given name.
  24720. // It returns an error if the field is not defined in the schema.
  24721. func (m *SopTaskMutation) ResetField(name string) error {
  24722. switch name {
  24723. case soptask.FieldCreatedAt:
  24724. m.ResetCreatedAt()
  24725. return nil
  24726. case soptask.FieldUpdatedAt:
  24727. m.ResetUpdatedAt()
  24728. return nil
  24729. case soptask.FieldStatus:
  24730. m.ResetStatus()
  24731. return nil
  24732. case soptask.FieldDeletedAt:
  24733. m.ResetDeletedAt()
  24734. return nil
  24735. case soptask.FieldName:
  24736. m.ResetName()
  24737. return nil
  24738. case soptask.FieldBotWxidList:
  24739. m.ResetBotWxidList()
  24740. return nil
  24741. case soptask.FieldType:
  24742. m.ResetType()
  24743. return nil
  24744. case soptask.FieldPlanStartTime:
  24745. m.ResetPlanStartTime()
  24746. return nil
  24747. case soptask.FieldPlanEndTime:
  24748. m.ResetPlanEndTime()
  24749. return nil
  24750. case soptask.FieldCreatorID:
  24751. m.ResetCreatorID()
  24752. return nil
  24753. case soptask.FieldOrganizationID:
  24754. m.ResetOrganizationID()
  24755. return nil
  24756. case soptask.FieldToken:
  24757. m.ResetToken()
  24758. return nil
  24759. }
  24760. return fmt.Errorf("unknown SopTask field %s", name)
  24761. }
  24762. // AddedEdges returns all edge names that were set/added in this mutation.
  24763. func (m *SopTaskMutation) AddedEdges() []string {
  24764. edges := make([]string, 0, 1)
  24765. if m.task_stages != nil {
  24766. edges = append(edges, soptask.EdgeTaskStages)
  24767. }
  24768. return edges
  24769. }
  24770. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24771. // name in this mutation.
  24772. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24773. switch name {
  24774. case soptask.EdgeTaskStages:
  24775. ids := make([]ent.Value, 0, len(m.task_stages))
  24776. for id := range m.task_stages {
  24777. ids = append(ids, id)
  24778. }
  24779. return ids
  24780. }
  24781. return nil
  24782. }
  24783. // RemovedEdges returns all edge names that were removed in this mutation.
  24784. func (m *SopTaskMutation) RemovedEdges() []string {
  24785. edges := make([]string, 0, 1)
  24786. if m.removedtask_stages != nil {
  24787. edges = append(edges, soptask.EdgeTaskStages)
  24788. }
  24789. return edges
  24790. }
  24791. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24792. // the given name in this mutation.
  24793. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24794. switch name {
  24795. case soptask.EdgeTaskStages:
  24796. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24797. for id := range m.removedtask_stages {
  24798. ids = append(ids, id)
  24799. }
  24800. return ids
  24801. }
  24802. return nil
  24803. }
  24804. // ClearedEdges returns all edge names that were cleared in this mutation.
  24805. func (m *SopTaskMutation) ClearedEdges() []string {
  24806. edges := make([]string, 0, 1)
  24807. if m.clearedtask_stages {
  24808. edges = append(edges, soptask.EdgeTaskStages)
  24809. }
  24810. return edges
  24811. }
  24812. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24813. // was cleared in this mutation.
  24814. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24815. switch name {
  24816. case soptask.EdgeTaskStages:
  24817. return m.clearedtask_stages
  24818. }
  24819. return false
  24820. }
  24821. // ClearEdge clears the value of the edge with the given name. It returns an error
  24822. // if that edge is not defined in the schema.
  24823. func (m *SopTaskMutation) ClearEdge(name string) error {
  24824. switch name {
  24825. }
  24826. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24827. }
  24828. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24829. // It returns an error if the edge is not defined in the schema.
  24830. func (m *SopTaskMutation) ResetEdge(name string) error {
  24831. switch name {
  24832. case soptask.EdgeTaskStages:
  24833. m.ResetTaskStages()
  24834. return nil
  24835. }
  24836. return fmt.Errorf("unknown SopTask edge %s", name)
  24837. }
  24838. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24839. type TokenMutation struct {
  24840. config
  24841. op Op
  24842. typ string
  24843. id *uint64
  24844. created_at *time.Time
  24845. updated_at *time.Time
  24846. deleted_at *time.Time
  24847. expire_at *time.Time
  24848. token *string
  24849. mac *string
  24850. organization_id *uint64
  24851. addorganization_id *int64
  24852. custom_agent_base *string
  24853. custom_agent_key *string
  24854. openai_base *string
  24855. openai_key *string
  24856. clearedFields map[string]struct{}
  24857. agent *uint64
  24858. clearedagent bool
  24859. done bool
  24860. oldValue func(context.Context) (*Token, error)
  24861. predicates []predicate.Token
  24862. }
  24863. var _ ent.Mutation = (*TokenMutation)(nil)
  24864. // tokenOption allows management of the mutation configuration using functional options.
  24865. type tokenOption func(*TokenMutation)
  24866. // newTokenMutation creates new mutation for the Token entity.
  24867. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24868. m := &TokenMutation{
  24869. config: c,
  24870. op: op,
  24871. typ: TypeToken,
  24872. clearedFields: make(map[string]struct{}),
  24873. }
  24874. for _, opt := range opts {
  24875. opt(m)
  24876. }
  24877. return m
  24878. }
  24879. // withTokenID sets the ID field of the mutation.
  24880. func withTokenID(id uint64) tokenOption {
  24881. return func(m *TokenMutation) {
  24882. var (
  24883. err error
  24884. once sync.Once
  24885. value *Token
  24886. )
  24887. m.oldValue = func(ctx context.Context) (*Token, error) {
  24888. once.Do(func() {
  24889. if m.done {
  24890. err = errors.New("querying old values post mutation is not allowed")
  24891. } else {
  24892. value, err = m.Client().Token.Get(ctx, id)
  24893. }
  24894. })
  24895. return value, err
  24896. }
  24897. m.id = &id
  24898. }
  24899. }
  24900. // withToken sets the old Token of the mutation.
  24901. func withToken(node *Token) tokenOption {
  24902. return func(m *TokenMutation) {
  24903. m.oldValue = func(context.Context) (*Token, error) {
  24904. return node, nil
  24905. }
  24906. m.id = &node.ID
  24907. }
  24908. }
  24909. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24910. // executed in a transaction (ent.Tx), a transactional client is returned.
  24911. func (m TokenMutation) Client() *Client {
  24912. client := &Client{config: m.config}
  24913. client.init()
  24914. return client
  24915. }
  24916. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24917. // it returns an error otherwise.
  24918. func (m TokenMutation) Tx() (*Tx, error) {
  24919. if _, ok := m.driver.(*txDriver); !ok {
  24920. return nil, errors.New("ent: mutation is not running in a transaction")
  24921. }
  24922. tx := &Tx{config: m.config}
  24923. tx.init()
  24924. return tx, nil
  24925. }
  24926. // SetID sets the value of the id field. Note that this
  24927. // operation is only accepted on creation of Token entities.
  24928. func (m *TokenMutation) SetID(id uint64) {
  24929. m.id = &id
  24930. }
  24931. // ID returns the ID value in the mutation. Note that the ID is only available
  24932. // if it was provided to the builder or after it was returned from the database.
  24933. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24934. if m.id == nil {
  24935. return
  24936. }
  24937. return *m.id, true
  24938. }
  24939. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24940. // That means, if the mutation is applied within a transaction with an isolation level such
  24941. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24942. // or updated by the mutation.
  24943. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24944. switch {
  24945. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24946. id, exists := m.ID()
  24947. if exists {
  24948. return []uint64{id}, nil
  24949. }
  24950. fallthrough
  24951. case m.op.Is(OpUpdate | OpDelete):
  24952. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24953. default:
  24954. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24955. }
  24956. }
  24957. // SetCreatedAt sets the "created_at" field.
  24958. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24959. m.created_at = &t
  24960. }
  24961. // CreatedAt returns the value of the "created_at" field in the mutation.
  24962. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24963. v := m.created_at
  24964. if v == nil {
  24965. return
  24966. }
  24967. return *v, true
  24968. }
  24969. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24970. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24972. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24973. if !m.op.Is(OpUpdateOne) {
  24974. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24975. }
  24976. if m.id == nil || m.oldValue == nil {
  24977. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24978. }
  24979. oldValue, err := m.oldValue(ctx)
  24980. if err != nil {
  24981. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24982. }
  24983. return oldValue.CreatedAt, nil
  24984. }
  24985. // ResetCreatedAt resets all changes to the "created_at" field.
  24986. func (m *TokenMutation) ResetCreatedAt() {
  24987. m.created_at = nil
  24988. }
  24989. // SetUpdatedAt sets the "updated_at" field.
  24990. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24991. m.updated_at = &t
  24992. }
  24993. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24994. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24995. v := m.updated_at
  24996. if v == nil {
  24997. return
  24998. }
  24999. return *v, true
  25000. }
  25001. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25002. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25004. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25005. if !m.op.Is(OpUpdateOne) {
  25006. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25007. }
  25008. if m.id == nil || m.oldValue == nil {
  25009. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25010. }
  25011. oldValue, err := m.oldValue(ctx)
  25012. if err != nil {
  25013. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25014. }
  25015. return oldValue.UpdatedAt, nil
  25016. }
  25017. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25018. func (m *TokenMutation) ResetUpdatedAt() {
  25019. m.updated_at = nil
  25020. }
  25021. // SetDeletedAt sets the "deleted_at" field.
  25022. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25023. m.deleted_at = &t
  25024. }
  25025. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25026. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25027. v := m.deleted_at
  25028. if v == nil {
  25029. return
  25030. }
  25031. return *v, true
  25032. }
  25033. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25034. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25036. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25037. if !m.op.Is(OpUpdateOne) {
  25038. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25039. }
  25040. if m.id == nil || m.oldValue == nil {
  25041. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25042. }
  25043. oldValue, err := m.oldValue(ctx)
  25044. if err != nil {
  25045. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25046. }
  25047. return oldValue.DeletedAt, nil
  25048. }
  25049. // ClearDeletedAt clears the value of the "deleted_at" field.
  25050. func (m *TokenMutation) ClearDeletedAt() {
  25051. m.deleted_at = nil
  25052. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25053. }
  25054. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25055. func (m *TokenMutation) DeletedAtCleared() bool {
  25056. _, ok := m.clearedFields[token.FieldDeletedAt]
  25057. return ok
  25058. }
  25059. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25060. func (m *TokenMutation) ResetDeletedAt() {
  25061. m.deleted_at = nil
  25062. delete(m.clearedFields, token.FieldDeletedAt)
  25063. }
  25064. // SetExpireAt sets the "expire_at" field.
  25065. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25066. m.expire_at = &t
  25067. }
  25068. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25069. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25070. v := m.expire_at
  25071. if v == nil {
  25072. return
  25073. }
  25074. return *v, true
  25075. }
  25076. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25077. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25079. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25080. if !m.op.Is(OpUpdateOne) {
  25081. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25082. }
  25083. if m.id == nil || m.oldValue == nil {
  25084. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25085. }
  25086. oldValue, err := m.oldValue(ctx)
  25087. if err != nil {
  25088. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25089. }
  25090. return oldValue.ExpireAt, nil
  25091. }
  25092. // ClearExpireAt clears the value of the "expire_at" field.
  25093. func (m *TokenMutation) ClearExpireAt() {
  25094. m.expire_at = nil
  25095. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25096. }
  25097. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25098. func (m *TokenMutation) ExpireAtCleared() bool {
  25099. _, ok := m.clearedFields[token.FieldExpireAt]
  25100. return ok
  25101. }
  25102. // ResetExpireAt resets all changes to the "expire_at" field.
  25103. func (m *TokenMutation) ResetExpireAt() {
  25104. m.expire_at = nil
  25105. delete(m.clearedFields, token.FieldExpireAt)
  25106. }
  25107. // SetToken sets the "token" field.
  25108. func (m *TokenMutation) SetToken(s string) {
  25109. m.token = &s
  25110. }
  25111. // Token returns the value of the "token" field in the mutation.
  25112. func (m *TokenMutation) Token() (r string, exists bool) {
  25113. v := m.token
  25114. if v == nil {
  25115. return
  25116. }
  25117. return *v, true
  25118. }
  25119. // OldToken returns the old "token" field's value of the Token entity.
  25120. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25122. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25123. if !m.op.Is(OpUpdateOne) {
  25124. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25125. }
  25126. if m.id == nil || m.oldValue == nil {
  25127. return v, errors.New("OldToken requires an ID field in the mutation")
  25128. }
  25129. oldValue, err := m.oldValue(ctx)
  25130. if err != nil {
  25131. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25132. }
  25133. return oldValue.Token, nil
  25134. }
  25135. // ClearToken clears the value of the "token" field.
  25136. func (m *TokenMutation) ClearToken() {
  25137. m.token = nil
  25138. m.clearedFields[token.FieldToken] = struct{}{}
  25139. }
  25140. // TokenCleared returns if the "token" field was cleared in this mutation.
  25141. func (m *TokenMutation) TokenCleared() bool {
  25142. _, ok := m.clearedFields[token.FieldToken]
  25143. return ok
  25144. }
  25145. // ResetToken resets all changes to the "token" field.
  25146. func (m *TokenMutation) ResetToken() {
  25147. m.token = nil
  25148. delete(m.clearedFields, token.FieldToken)
  25149. }
  25150. // SetMAC sets the "mac" field.
  25151. func (m *TokenMutation) SetMAC(s string) {
  25152. m.mac = &s
  25153. }
  25154. // MAC returns the value of the "mac" field in the mutation.
  25155. func (m *TokenMutation) MAC() (r string, exists bool) {
  25156. v := m.mac
  25157. if v == nil {
  25158. return
  25159. }
  25160. return *v, true
  25161. }
  25162. // OldMAC returns the old "mac" field's value of the Token entity.
  25163. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25165. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25166. if !m.op.Is(OpUpdateOne) {
  25167. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25168. }
  25169. if m.id == nil || m.oldValue == nil {
  25170. return v, errors.New("OldMAC requires an ID field in the mutation")
  25171. }
  25172. oldValue, err := m.oldValue(ctx)
  25173. if err != nil {
  25174. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25175. }
  25176. return oldValue.MAC, nil
  25177. }
  25178. // ClearMAC clears the value of the "mac" field.
  25179. func (m *TokenMutation) ClearMAC() {
  25180. m.mac = nil
  25181. m.clearedFields[token.FieldMAC] = struct{}{}
  25182. }
  25183. // MACCleared returns if the "mac" field was cleared in this mutation.
  25184. func (m *TokenMutation) MACCleared() bool {
  25185. _, ok := m.clearedFields[token.FieldMAC]
  25186. return ok
  25187. }
  25188. // ResetMAC resets all changes to the "mac" field.
  25189. func (m *TokenMutation) ResetMAC() {
  25190. m.mac = nil
  25191. delete(m.clearedFields, token.FieldMAC)
  25192. }
  25193. // SetOrganizationID sets the "organization_id" field.
  25194. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25195. m.organization_id = &u
  25196. m.addorganization_id = nil
  25197. }
  25198. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25199. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25200. v := m.organization_id
  25201. if v == nil {
  25202. return
  25203. }
  25204. return *v, true
  25205. }
  25206. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25207. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25209. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25210. if !m.op.Is(OpUpdateOne) {
  25211. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25212. }
  25213. if m.id == nil || m.oldValue == nil {
  25214. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25215. }
  25216. oldValue, err := m.oldValue(ctx)
  25217. if err != nil {
  25218. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25219. }
  25220. return oldValue.OrganizationID, nil
  25221. }
  25222. // AddOrganizationID adds u to the "organization_id" field.
  25223. func (m *TokenMutation) AddOrganizationID(u int64) {
  25224. if m.addorganization_id != nil {
  25225. *m.addorganization_id += u
  25226. } else {
  25227. m.addorganization_id = &u
  25228. }
  25229. }
  25230. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25231. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25232. v := m.addorganization_id
  25233. if v == nil {
  25234. return
  25235. }
  25236. return *v, true
  25237. }
  25238. // ResetOrganizationID resets all changes to the "organization_id" field.
  25239. func (m *TokenMutation) ResetOrganizationID() {
  25240. m.organization_id = nil
  25241. m.addorganization_id = nil
  25242. }
  25243. // SetAgentID sets the "agent_id" field.
  25244. func (m *TokenMutation) SetAgentID(u uint64) {
  25245. m.agent = &u
  25246. }
  25247. // AgentID returns the value of the "agent_id" field in the mutation.
  25248. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25249. v := m.agent
  25250. if v == nil {
  25251. return
  25252. }
  25253. return *v, true
  25254. }
  25255. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25256. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25258. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25259. if !m.op.Is(OpUpdateOne) {
  25260. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25261. }
  25262. if m.id == nil || m.oldValue == nil {
  25263. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25264. }
  25265. oldValue, err := m.oldValue(ctx)
  25266. if err != nil {
  25267. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25268. }
  25269. return oldValue.AgentID, nil
  25270. }
  25271. // ResetAgentID resets all changes to the "agent_id" field.
  25272. func (m *TokenMutation) ResetAgentID() {
  25273. m.agent = nil
  25274. }
  25275. // SetCustomAgentBase sets the "custom_agent_base" field.
  25276. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25277. m.custom_agent_base = &s
  25278. }
  25279. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25280. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25281. v := m.custom_agent_base
  25282. if v == nil {
  25283. return
  25284. }
  25285. return *v, true
  25286. }
  25287. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25290. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25291. if !m.op.Is(OpUpdateOne) {
  25292. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25293. }
  25294. if m.id == nil || m.oldValue == nil {
  25295. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25296. }
  25297. oldValue, err := m.oldValue(ctx)
  25298. if err != nil {
  25299. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25300. }
  25301. return oldValue.CustomAgentBase, nil
  25302. }
  25303. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25304. func (m *TokenMutation) ClearCustomAgentBase() {
  25305. m.custom_agent_base = nil
  25306. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25307. }
  25308. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25309. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25310. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25311. return ok
  25312. }
  25313. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25314. func (m *TokenMutation) ResetCustomAgentBase() {
  25315. m.custom_agent_base = nil
  25316. delete(m.clearedFields, token.FieldCustomAgentBase)
  25317. }
  25318. // SetCustomAgentKey sets the "custom_agent_key" field.
  25319. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25320. m.custom_agent_key = &s
  25321. }
  25322. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25323. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25324. v := m.custom_agent_key
  25325. if v == nil {
  25326. return
  25327. }
  25328. return *v, true
  25329. }
  25330. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25331. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25333. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25334. if !m.op.Is(OpUpdateOne) {
  25335. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25336. }
  25337. if m.id == nil || m.oldValue == nil {
  25338. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25339. }
  25340. oldValue, err := m.oldValue(ctx)
  25341. if err != nil {
  25342. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25343. }
  25344. return oldValue.CustomAgentKey, nil
  25345. }
  25346. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25347. func (m *TokenMutation) ClearCustomAgentKey() {
  25348. m.custom_agent_key = nil
  25349. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25350. }
  25351. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25352. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25353. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25354. return ok
  25355. }
  25356. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25357. func (m *TokenMutation) ResetCustomAgentKey() {
  25358. m.custom_agent_key = nil
  25359. delete(m.clearedFields, token.FieldCustomAgentKey)
  25360. }
  25361. // SetOpenaiBase sets the "openai_base" field.
  25362. func (m *TokenMutation) SetOpenaiBase(s string) {
  25363. m.openai_base = &s
  25364. }
  25365. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25366. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25367. v := m.openai_base
  25368. if v == nil {
  25369. return
  25370. }
  25371. return *v, true
  25372. }
  25373. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25374. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25376. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25377. if !m.op.Is(OpUpdateOne) {
  25378. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25379. }
  25380. if m.id == nil || m.oldValue == nil {
  25381. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25382. }
  25383. oldValue, err := m.oldValue(ctx)
  25384. if err != nil {
  25385. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25386. }
  25387. return oldValue.OpenaiBase, nil
  25388. }
  25389. // ClearOpenaiBase clears the value of the "openai_base" field.
  25390. func (m *TokenMutation) ClearOpenaiBase() {
  25391. m.openai_base = nil
  25392. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25393. }
  25394. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25395. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25396. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25397. return ok
  25398. }
  25399. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25400. func (m *TokenMutation) ResetOpenaiBase() {
  25401. m.openai_base = nil
  25402. delete(m.clearedFields, token.FieldOpenaiBase)
  25403. }
  25404. // SetOpenaiKey sets the "openai_key" field.
  25405. func (m *TokenMutation) SetOpenaiKey(s string) {
  25406. m.openai_key = &s
  25407. }
  25408. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25409. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25410. v := m.openai_key
  25411. if v == nil {
  25412. return
  25413. }
  25414. return *v, true
  25415. }
  25416. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25419. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25420. if !m.op.Is(OpUpdateOne) {
  25421. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25422. }
  25423. if m.id == nil || m.oldValue == nil {
  25424. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25425. }
  25426. oldValue, err := m.oldValue(ctx)
  25427. if err != nil {
  25428. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25429. }
  25430. return oldValue.OpenaiKey, nil
  25431. }
  25432. // ClearOpenaiKey clears the value of the "openai_key" field.
  25433. func (m *TokenMutation) ClearOpenaiKey() {
  25434. m.openai_key = nil
  25435. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25436. }
  25437. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25438. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25439. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25440. return ok
  25441. }
  25442. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25443. func (m *TokenMutation) ResetOpenaiKey() {
  25444. m.openai_key = nil
  25445. delete(m.clearedFields, token.FieldOpenaiKey)
  25446. }
  25447. // ClearAgent clears the "agent" edge to the Agent entity.
  25448. func (m *TokenMutation) ClearAgent() {
  25449. m.clearedagent = true
  25450. m.clearedFields[token.FieldAgentID] = struct{}{}
  25451. }
  25452. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25453. func (m *TokenMutation) AgentCleared() bool {
  25454. return m.clearedagent
  25455. }
  25456. // AgentIDs returns the "agent" edge IDs in the mutation.
  25457. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25458. // AgentID instead. It exists only for internal usage by the builders.
  25459. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25460. if id := m.agent; id != nil {
  25461. ids = append(ids, *id)
  25462. }
  25463. return
  25464. }
  25465. // ResetAgent resets all changes to the "agent" edge.
  25466. func (m *TokenMutation) ResetAgent() {
  25467. m.agent = nil
  25468. m.clearedagent = false
  25469. }
  25470. // Where appends a list predicates to the TokenMutation builder.
  25471. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25472. m.predicates = append(m.predicates, ps...)
  25473. }
  25474. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25475. // users can use type-assertion to append predicates that do not depend on any generated package.
  25476. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25477. p := make([]predicate.Token, len(ps))
  25478. for i := range ps {
  25479. p[i] = ps[i]
  25480. }
  25481. m.Where(p...)
  25482. }
  25483. // Op returns the operation name.
  25484. func (m *TokenMutation) Op() Op {
  25485. return m.op
  25486. }
  25487. // SetOp allows setting the mutation operation.
  25488. func (m *TokenMutation) SetOp(op Op) {
  25489. m.op = op
  25490. }
  25491. // Type returns the node type of this mutation (Token).
  25492. func (m *TokenMutation) Type() string {
  25493. return m.typ
  25494. }
  25495. // Fields returns all fields that were changed during this mutation. Note that in
  25496. // order to get all numeric fields that were incremented/decremented, call
  25497. // AddedFields().
  25498. func (m *TokenMutation) Fields() []string {
  25499. fields := make([]string, 0, 12)
  25500. if m.created_at != nil {
  25501. fields = append(fields, token.FieldCreatedAt)
  25502. }
  25503. if m.updated_at != nil {
  25504. fields = append(fields, token.FieldUpdatedAt)
  25505. }
  25506. if m.deleted_at != nil {
  25507. fields = append(fields, token.FieldDeletedAt)
  25508. }
  25509. if m.expire_at != nil {
  25510. fields = append(fields, token.FieldExpireAt)
  25511. }
  25512. if m.token != nil {
  25513. fields = append(fields, token.FieldToken)
  25514. }
  25515. if m.mac != nil {
  25516. fields = append(fields, token.FieldMAC)
  25517. }
  25518. if m.organization_id != nil {
  25519. fields = append(fields, token.FieldOrganizationID)
  25520. }
  25521. if m.agent != nil {
  25522. fields = append(fields, token.FieldAgentID)
  25523. }
  25524. if m.custom_agent_base != nil {
  25525. fields = append(fields, token.FieldCustomAgentBase)
  25526. }
  25527. if m.custom_agent_key != nil {
  25528. fields = append(fields, token.FieldCustomAgentKey)
  25529. }
  25530. if m.openai_base != nil {
  25531. fields = append(fields, token.FieldOpenaiBase)
  25532. }
  25533. if m.openai_key != nil {
  25534. fields = append(fields, token.FieldOpenaiKey)
  25535. }
  25536. return fields
  25537. }
  25538. // Field returns the value of a field with the given name. The second boolean
  25539. // return value indicates that this field was not set, or was not defined in the
  25540. // schema.
  25541. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25542. switch name {
  25543. case token.FieldCreatedAt:
  25544. return m.CreatedAt()
  25545. case token.FieldUpdatedAt:
  25546. return m.UpdatedAt()
  25547. case token.FieldDeletedAt:
  25548. return m.DeletedAt()
  25549. case token.FieldExpireAt:
  25550. return m.ExpireAt()
  25551. case token.FieldToken:
  25552. return m.Token()
  25553. case token.FieldMAC:
  25554. return m.MAC()
  25555. case token.FieldOrganizationID:
  25556. return m.OrganizationID()
  25557. case token.FieldAgentID:
  25558. return m.AgentID()
  25559. case token.FieldCustomAgentBase:
  25560. return m.CustomAgentBase()
  25561. case token.FieldCustomAgentKey:
  25562. return m.CustomAgentKey()
  25563. case token.FieldOpenaiBase:
  25564. return m.OpenaiBase()
  25565. case token.FieldOpenaiKey:
  25566. return m.OpenaiKey()
  25567. }
  25568. return nil, false
  25569. }
  25570. // OldField returns the old value of the field from the database. An error is
  25571. // returned if the mutation operation is not UpdateOne, or the query to the
  25572. // database failed.
  25573. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25574. switch name {
  25575. case token.FieldCreatedAt:
  25576. return m.OldCreatedAt(ctx)
  25577. case token.FieldUpdatedAt:
  25578. return m.OldUpdatedAt(ctx)
  25579. case token.FieldDeletedAt:
  25580. return m.OldDeletedAt(ctx)
  25581. case token.FieldExpireAt:
  25582. return m.OldExpireAt(ctx)
  25583. case token.FieldToken:
  25584. return m.OldToken(ctx)
  25585. case token.FieldMAC:
  25586. return m.OldMAC(ctx)
  25587. case token.FieldOrganizationID:
  25588. return m.OldOrganizationID(ctx)
  25589. case token.FieldAgentID:
  25590. return m.OldAgentID(ctx)
  25591. case token.FieldCustomAgentBase:
  25592. return m.OldCustomAgentBase(ctx)
  25593. case token.FieldCustomAgentKey:
  25594. return m.OldCustomAgentKey(ctx)
  25595. case token.FieldOpenaiBase:
  25596. return m.OldOpenaiBase(ctx)
  25597. case token.FieldOpenaiKey:
  25598. return m.OldOpenaiKey(ctx)
  25599. }
  25600. return nil, fmt.Errorf("unknown Token field %s", name)
  25601. }
  25602. // SetField sets the value of a field with the given name. It returns an error if
  25603. // the field is not defined in the schema, or if the type mismatched the field
  25604. // type.
  25605. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25606. switch name {
  25607. case token.FieldCreatedAt:
  25608. v, ok := value.(time.Time)
  25609. if !ok {
  25610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25611. }
  25612. m.SetCreatedAt(v)
  25613. return nil
  25614. case token.FieldUpdatedAt:
  25615. v, ok := value.(time.Time)
  25616. if !ok {
  25617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25618. }
  25619. m.SetUpdatedAt(v)
  25620. return nil
  25621. case token.FieldDeletedAt:
  25622. v, ok := value.(time.Time)
  25623. if !ok {
  25624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25625. }
  25626. m.SetDeletedAt(v)
  25627. return nil
  25628. case token.FieldExpireAt:
  25629. v, ok := value.(time.Time)
  25630. if !ok {
  25631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25632. }
  25633. m.SetExpireAt(v)
  25634. return nil
  25635. case token.FieldToken:
  25636. v, ok := value.(string)
  25637. if !ok {
  25638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25639. }
  25640. m.SetToken(v)
  25641. return nil
  25642. case token.FieldMAC:
  25643. v, ok := value.(string)
  25644. if !ok {
  25645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25646. }
  25647. m.SetMAC(v)
  25648. return nil
  25649. case token.FieldOrganizationID:
  25650. v, ok := value.(uint64)
  25651. if !ok {
  25652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25653. }
  25654. m.SetOrganizationID(v)
  25655. return nil
  25656. case token.FieldAgentID:
  25657. v, ok := value.(uint64)
  25658. if !ok {
  25659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25660. }
  25661. m.SetAgentID(v)
  25662. return nil
  25663. case token.FieldCustomAgentBase:
  25664. v, ok := value.(string)
  25665. if !ok {
  25666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25667. }
  25668. m.SetCustomAgentBase(v)
  25669. return nil
  25670. case token.FieldCustomAgentKey:
  25671. v, ok := value.(string)
  25672. if !ok {
  25673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25674. }
  25675. m.SetCustomAgentKey(v)
  25676. return nil
  25677. case token.FieldOpenaiBase:
  25678. v, ok := value.(string)
  25679. if !ok {
  25680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25681. }
  25682. m.SetOpenaiBase(v)
  25683. return nil
  25684. case token.FieldOpenaiKey:
  25685. v, ok := value.(string)
  25686. if !ok {
  25687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25688. }
  25689. m.SetOpenaiKey(v)
  25690. return nil
  25691. }
  25692. return fmt.Errorf("unknown Token field %s", name)
  25693. }
  25694. // AddedFields returns all numeric fields that were incremented/decremented during
  25695. // this mutation.
  25696. func (m *TokenMutation) AddedFields() []string {
  25697. var fields []string
  25698. if m.addorganization_id != nil {
  25699. fields = append(fields, token.FieldOrganizationID)
  25700. }
  25701. return fields
  25702. }
  25703. // AddedField returns the numeric value that was incremented/decremented on a field
  25704. // with the given name. The second boolean return value indicates that this field
  25705. // was not set, or was not defined in the schema.
  25706. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25707. switch name {
  25708. case token.FieldOrganizationID:
  25709. return m.AddedOrganizationID()
  25710. }
  25711. return nil, false
  25712. }
  25713. // AddField adds the value to the field with the given name. It returns an error if
  25714. // the field is not defined in the schema, or if the type mismatched the field
  25715. // type.
  25716. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25717. switch name {
  25718. case token.FieldOrganizationID:
  25719. v, ok := value.(int64)
  25720. if !ok {
  25721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25722. }
  25723. m.AddOrganizationID(v)
  25724. return nil
  25725. }
  25726. return fmt.Errorf("unknown Token numeric field %s", name)
  25727. }
  25728. // ClearedFields returns all nullable fields that were cleared during this
  25729. // mutation.
  25730. func (m *TokenMutation) ClearedFields() []string {
  25731. var fields []string
  25732. if m.FieldCleared(token.FieldDeletedAt) {
  25733. fields = append(fields, token.FieldDeletedAt)
  25734. }
  25735. if m.FieldCleared(token.FieldExpireAt) {
  25736. fields = append(fields, token.FieldExpireAt)
  25737. }
  25738. if m.FieldCleared(token.FieldToken) {
  25739. fields = append(fields, token.FieldToken)
  25740. }
  25741. if m.FieldCleared(token.FieldMAC) {
  25742. fields = append(fields, token.FieldMAC)
  25743. }
  25744. if m.FieldCleared(token.FieldCustomAgentBase) {
  25745. fields = append(fields, token.FieldCustomAgentBase)
  25746. }
  25747. if m.FieldCleared(token.FieldCustomAgentKey) {
  25748. fields = append(fields, token.FieldCustomAgentKey)
  25749. }
  25750. if m.FieldCleared(token.FieldOpenaiBase) {
  25751. fields = append(fields, token.FieldOpenaiBase)
  25752. }
  25753. if m.FieldCleared(token.FieldOpenaiKey) {
  25754. fields = append(fields, token.FieldOpenaiKey)
  25755. }
  25756. return fields
  25757. }
  25758. // FieldCleared returns a boolean indicating if a field with the given name was
  25759. // cleared in this mutation.
  25760. func (m *TokenMutation) FieldCleared(name string) bool {
  25761. _, ok := m.clearedFields[name]
  25762. return ok
  25763. }
  25764. // ClearField clears the value of the field with the given name. It returns an
  25765. // error if the field is not defined in the schema.
  25766. func (m *TokenMutation) ClearField(name string) error {
  25767. switch name {
  25768. case token.FieldDeletedAt:
  25769. m.ClearDeletedAt()
  25770. return nil
  25771. case token.FieldExpireAt:
  25772. m.ClearExpireAt()
  25773. return nil
  25774. case token.FieldToken:
  25775. m.ClearToken()
  25776. return nil
  25777. case token.FieldMAC:
  25778. m.ClearMAC()
  25779. return nil
  25780. case token.FieldCustomAgentBase:
  25781. m.ClearCustomAgentBase()
  25782. return nil
  25783. case token.FieldCustomAgentKey:
  25784. m.ClearCustomAgentKey()
  25785. return nil
  25786. case token.FieldOpenaiBase:
  25787. m.ClearOpenaiBase()
  25788. return nil
  25789. case token.FieldOpenaiKey:
  25790. m.ClearOpenaiKey()
  25791. return nil
  25792. }
  25793. return fmt.Errorf("unknown Token nullable field %s", name)
  25794. }
  25795. // ResetField resets all changes in the mutation for the field with the given name.
  25796. // It returns an error if the field is not defined in the schema.
  25797. func (m *TokenMutation) ResetField(name string) error {
  25798. switch name {
  25799. case token.FieldCreatedAt:
  25800. m.ResetCreatedAt()
  25801. return nil
  25802. case token.FieldUpdatedAt:
  25803. m.ResetUpdatedAt()
  25804. return nil
  25805. case token.FieldDeletedAt:
  25806. m.ResetDeletedAt()
  25807. return nil
  25808. case token.FieldExpireAt:
  25809. m.ResetExpireAt()
  25810. return nil
  25811. case token.FieldToken:
  25812. m.ResetToken()
  25813. return nil
  25814. case token.FieldMAC:
  25815. m.ResetMAC()
  25816. return nil
  25817. case token.FieldOrganizationID:
  25818. m.ResetOrganizationID()
  25819. return nil
  25820. case token.FieldAgentID:
  25821. m.ResetAgentID()
  25822. return nil
  25823. case token.FieldCustomAgentBase:
  25824. m.ResetCustomAgentBase()
  25825. return nil
  25826. case token.FieldCustomAgentKey:
  25827. m.ResetCustomAgentKey()
  25828. return nil
  25829. case token.FieldOpenaiBase:
  25830. m.ResetOpenaiBase()
  25831. return nil
  25832. case token.FieldOpenaiKey:
  25833. m.ResetOpenaiKey()
  25834. return nil
  25835. }
  25836. return fmt.Errorf("unknown Token field %s", name)
  25837. }
  25838. // AddedEdges returns all edge names that were set/added in this mutation.
  25839. func (m *TokenMutation) AddedEdges() []string {
  25840. edges := make([]string, 0, 1)
  25841. if m.agent != nil {
  25842. edges = append(edges, token.EdgeAgent)
  25843. }
  25844. return edges
  25845. }
  25846. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25847. // name in this mutation.
  25848. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25849. switch name {
  25850. case token.EdgeAgent:
  25851. if id := m.agent; id != nil {
  25852. return []ent.Value{*id}
  25853. }
  25854. }
  25855. return nil
  25856. }
  25857. // RemovedEdges returns all edge names that were removed in this mutation.
  25858. func (m *TokenMutation) RemovedEdges() []string {
  25859. edges := make([]string, 0, 1)
  25860. return edges
  25861. }
  25862. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25863. // the given name in this mutation.
  25864. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25865. return nil
  25866. }
  25867. // ClearedEdges returns all edge names that were cleared in this mutation.
  25868. func (m *TokenMutation) ClearedEdges() []string {
  25869. edges := make([]string, 0, 1)
  25870. if m.clearedagent {
  25871. edges = append(edges, token.EdgeAgent)
  25872. }
  25873. return edges
  25874. }
  25875. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25876. // was cleared in this mutation.
  25877. func (m *TokenMutation) EdgeCleared(name string) bool {
  25878. switch name {
  25879. case token.EdgeAgent:
  25880. return m.clearedagent
  25881. }
  25882. return false
  25883. }
  25884. // ClearEdge clears the value of the edge with the given name. It returns an error
  25885. // if that edge is not defined in the schema.
  25886. func (m *TokenMutation) ClearEdge(name string) error {
  25887. switch name {
  25888. case token.EdgeAgent:
  25889. m.ClearAgent()
  25890. return nil
  25891. }
  25892. return fmt.Errorf("unknown Token unique edge %s", name)
  25893. }
  25894. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25895. // It returns an error if the edge is not defined in the schema.
  25896. func (m *TokenMutation) ResetEdge(name string) error {
  25897. switch name {
  25898. case token.EdgeAgent:
  25899. m.ResetAgent()
  25900. return nil
  25901. }
  25902. return fmt.Errorf("unknown Token edge %s", name)
  25903. }
  25904. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25905. type TutorialMutation struct {
  25906. config
  25907. op Op
  25908. typ string
  25909. id *uint64
  25910. created_at *time.Time
  25911. updated_at *time.Time
  25912. deleted_at *time.Time
  25913. index *int
  25914. addindex *int
  25915. title *string
  25916. content *string
  25917. organization_id *uint64
  25918. addorganization_id *int64
  25919. clearedFields map[string]struct{}
  25920. employee *uint64
  25921. clearedemployee bool
  25922. done bool
  25923. oldValue func(context.Context) (*Tutorial, error)
  25924. predicates []predicate.Tutorial
  25925. }
  25926. var _ ent.Mutation = (*TutorialMutation)(nil)
  25927. // tutorialOption allows management of the mutation configuration using functional options.
  25928. type tutorialOption func(*TutorialMutation)
  25929. // newTutorialMutation creates new mutation for the Tutorial entity.
  25930. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25931. m := &TutorialMutation{
  25932. config: c,
  25933. op: op,
  25934. typ: TypeTutorial,
  25935. clearedFields: make(map[string]struct{}),
  25936. }
  25937. for _, opt := range opts {
  25938. opt(m)
  25939. }
  25940. return m
  25941. }
  25942. // withTutorialID sets the ID field of the mutation.
  25943. func withTutorialID(id uint64) tutorialOption {
  25944. return func(m *TutorialMutation) {
  25945. var (
  25946. err error
  25947. once sync.Once
  25948. value *Tutorial
  25949. )
  25950. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25951. once.Do(func() {
  25952. if m.done {
  25953. err = errors.New("querying old values post mutation is not allowed")
  25954. } else {
  25955. value, err = m.Client().Tutorial.Get(ctx, id)
  25956. }
  25957. })
  25958. return value, err
  25959. }
  25960. m.id = &id
  25961. }
  25962. }
  25963. // withTutorial sets the old Tutorial of the mutation.
  25964. func withTutorial(node *Tutorial) tutorialOption {
  25965. return func(m *TutorialMutation) {
  25966. m.oldValue = func(context.Context) (*Tutorial, error) {
  25967. return node, nil
  25968. }
  25969. m.id = &node.ID
  25970. }
  25971. }
  25972. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25973. // executed in a transaction (ent.Tx), a transactional client is returned.
  25974. func (m TutorialMutation) Client() *Client {
  25975. client := &Client{config: m.config}
  25976. client.init()
  25977. return client
  25978. }
  25979. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25980. // it returns an error otherwise.
  25981. func (m TutorialMutation) Tx() (*Tx, error) {
  25982. if _, ok := m.driver.(*txDriver); !ok {
  25983. return nil, errors.New("ent: mutation is not running in a transaction")
  25984. }
  25985. tx := &Tx{config: m.config}
  25986. tx.init()
  25987. return tx, nil
  25988. }
  25989. // SetID sets the value of the id field. Note that this
  25990. // operation is only accepted on creation of Tutorial entities.
  25991. func (m *TutorialMutation) SetID(id uint64) {
  25992. m.id = &id
  25993. }
  25994. // ID returns the ID value in the mutation. Note that the ID is only available
  25995. // if it was provided to the builder or after it was returned from the database.
  25996. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25997. if m.id == nil {
  25998. return
  25999. }
  26000. return *m.id, true
  26001. }
  26002. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26003. // That means, if the mutation is applied within a transaction with an isolation level such
  26004. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26005. // or updated by the mutation.
  26006. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26007. switch {
  26008. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26009. id, exists := m.ID()
  26010. if exists {
  26011. return []uint64{id}, nil
  26012. }
  26013. fallthrough
  26014. case m.op.Is(OpUpdate | OpDelete):
  26015. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26016. default:
  26017. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26018. }
  26019. }
  26020. // SetCreatedAt sets the "created_at" field.
  26021. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26022. m.created_at = &t
  26023. }
  26024. // CreatedAt returns the value of the "created_at" field in the mutation.
  26025. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26026. v := m.created_at
  26027. if v == nil {
  26028. return
  26029. }
  26030. return *v, true
  26031. }
  26032. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26033. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26035. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26036. if !m.op.Is(OpUpdateOne) {
  26037. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26038. }
  26039. if m.id == nil || m.oldValue == nil {
  26040. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26041. }
  26042. oldValue, err := m.oldValue(ctx)
  26043. if err != nil {
  26044. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26045. }
  26046. return oldValue.CreatedAt, nil
  26047. }
  26048. // ResetCreatedAt resets all changes to the "created_at" field.
  26049. func (m *TutorialMutation) ResetCreatedAt() {
  26050. m.created_at = nil
  26051. }
  26052. // SetUpdatedAt sets the "updated_at" field.
  26053. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26054. m.updated_at = &t
  26055. }
  26056. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26057. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26058. v := m.updated_at
  26059. if v == nil {
  26060. return
  26061. }
  26062. return *v, true
  26063. }
  26064. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26065. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26067. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26068. if !m.op.Is(OpUpdateOne) {
  26069. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26070. }
  26071. if m.id == nil || m.oldValue == nil {
  26072. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26073. }
  26074. oldValue, err := m.oldValue(ctx)
  26075. if err != nil {
  26076. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26077. }
  26078. return oldValue.UpdatedAt, nil
  26079. }
  26080. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26081. func (m *TutorialMutation) ResetUpdatedAt() {
  26082. m.updated_at = nil
  26083. }
  26084. // SetDeletedAt sets the "deleted_at" field.
  26085. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26086. m.deleted_at = &t
  26087. }
  26088. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26089. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26090. v := m.deleted_at
  26091. if v == nil {
  26092. return
  26093. }
  26094. return *v, true
  26095. }
  26096. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26097. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26099. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26100. if !m.op.Is(OpUpdateOne) {
  26101. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26102. }
  26103. if m.id == nil || m.oldValue == nil {
  26104. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26105. }
  26106. oldValue, err := m.oldValue(ctx)
  26107. if err != nil {
  26108. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26109. }
  26110. return oldValue.DeletedAt, nil
  26111. }
  26112. // ClearDeletedAt clears the value of the "deleted_at" field.
  26113. func (m *TutorialMutation) ClearDeletedAt() {
  26114. m.deleted_at = nil
  26115. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26116. }
  26117. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26118. func (m *TutorialMutation) DeletedAtCleared() bool {
  26119. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26120. return ok
  26121. }
  26122. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26123. func (m *TutorialMutation) ResetDeletedAt() {
  26124. m.deleted_at = nil
  26125. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26126. }
  26127. // SetEmployeeID sets the "employee_id" field.
  26128. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26129. m.employee = &u
  26130. }
  26131. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26132. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26133. v := m.employee
  26134. if v == nil {
  26135. return
  26136. }
  26137. return *v, true
  26138. }
  26139. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26140. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26142. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26143. if !m.op.Is(OpUpdateOne) {
  26144. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26145. }
  26146. if m.id == nil || m.oldValue == nil {
  26147. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26148. }
  26149. oldValue, err := m.oldValue(ctx)
  26150. if err != nil {
  26151. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26152. }
  26153. return oldValue.EmployeeID, nil
  26154. }
  26155. // ResetEmployeeID resets all changes to the "employee_id" field.
  26156. func (m *TutorialMutation) ResetEmployeeID() {
  26157. m.employee = nil
  26158. }
  26159. // SetIndex sets the "index" field.
  26160. func (m *TutorialMutation) SetIndex(i int) {
  26161. m.index = &i
  26162. m.addindex = nil
  26163. }
  26164. // Index returns the value of the "index" field in the mutation.
  26165. func (m *TutorialMutation) Index() (r int, exists bool) {
  26166. v := m.index
  26167. if v == nil {
  26168. return
  26169. }
  26170. return *v, true
  26171. }
  26172. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26173. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26175. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26176. if !m.op.Is(OpUpdateOne) {
  26177. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26178. }
  26179. if m.id == nil || m.oldValue == nil {
  26180. return v, errors.New("OldIndex requires an ID field in the mutation")
  26181. }
  26182. oldValue, err := m.oldValue(ctx)
  26183. if err != nil {
  26184. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26185. }
  26186. return oldValue.Index, nil
  26187. }
  26188. // AddIndex adds i to the "index" field.
  26189. func (m *TutorialMutation) AddIndex(i int) {
  26190. if m.addindex != nil {
  26191. *m.addindex += i
  26192. } else {
  26193. m.addindex = &i
  26194. }
  26195. }
  26196. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26197. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26198. v := m.addindex
  26199. if v == nil {
  26200. return
  26201. }
  26202. return *v, true
  26203. }
  26204. // ResetIndex resets all changes to the "index" field.
  26205. func (m *TutorialMutation) ResetIndex() {
  26206. m.index = nil
  26207. m.addindex = nil
  26208. }
  26209. // SetTitle sets the "title" field.
  26210. func (m *TutorialMutation) SetTitle(s string) {
  26211. m.title = &s
  26212. }
  26213. // Title returns the value of the "title" field in the mutation.
  26214. func (m *TutorialMutation) Title() (r string, exists bool) {
  26215. v := m.title
  26216. if v == nil {
  26217. return
  26218. }
  26219. return *v, true
  26220. }
  26221. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26222. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26224. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26225. if !m.op.Is(OpUpdateOne) {
  26226. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26227. }
  26228. if m.id == nil || m.oldValue == nil {
  26229. return v, errors.New("OldTitle requires an ID field in the mutation")
  26230. }
  26231. oldValue, err := m.oldValue(ctx)
  26232. if err != nil {
  26233. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26234. }
  26235. return oldValue.Title, nil
  26236. }
  26237. // ResetTitle resets all changes to the "title" field.
  26238. func (m *TutorialMutation) ResetTitle() {
  26239. m.title = nil
  26240. }
  26241. // SetContent sets the "content" field.
  26242. func (m *TutorialMutation) SetContent(s string) {
  26243. m.content = &s
  26244. }
  26245. // Content returns the value of the "content" field in the mutation.
  26246. func (m *TutorialMutation) Content() (r string, exists bool) {
  26247. v := m.content
  26248. if v == nil {
  26249. return
  26250. }
  26251. return *v, true
  26252. }
  26253. // OldContent returns the old "content" field's value of the Tutorial entity.
  26254. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26256. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26257. if !m.op.Is(OpUpdateOne) {
  26258. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26259. }
  26260. if m.id == nil || m.oldValue == nil {
  26261. return v, errors.New("OldContent requires an ID field in the mutation")
  26262. }
  26263. oldValue, err := m.oldValue(ctx)
  26264. if err != nil {
  26265. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26266. }
  26267. return oldValue.Content, nil
  26268. }
  26269. // ResetContent resets all changes to the "content" field.
  26270. func (m *TutorialMutation) ResetContent() {
  26271. m.content = nil
  26272. }
  26273. // SetOrganizationID sets the "organization_id" field.
  26274. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26275. m.organization_id = &u
  26276. m.addorganization_id = nil
  26277. }
  26278. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26279. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26280. v := m.organization_id
  26281. if v == nil {
  26282. return
  26283. }
  26284. return *v, true
  26285. }
  26286. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26287. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26289. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26290. if !m.op.Is(OpUpdateOne) {
  26291. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26292. }
  26293. if m.id == nil || m.oldValue == nil {
  26294. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26295. }
  26296. oldValue, err := m.oldValue(ctx)
  26297. if err != nil {
  26298. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26299. }
  26300. return oldValue.OrganizationID, nil
  26301. }
  26302. // AddOrganizationID adds u to the "organization_id" field.
  26303. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26304. if m.addorganization_id != nil {
  26305. *m.addorganization_id += u
  26306. } else {
  26307. m.addorganization_id = &u
  26308. }
  26309. }
  26310. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26311. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26312. v := m.addorganization_id
  26313. if v == nil {
  26314. return
  26315. }
  26316. return *v, true
  26317. }
  26318. // ResetOrganizationID resets all changes to the "organization_id" field.
  26319. func (m *TutorialMutation) ResetOrganizationID() {
  26320. m.organization_id = nil
  26321. m.addorganization_id = nil
  26322. }
  26323. // ClearEmployee clears the "employee" edge to the Employee entity.
  26324. func (m *TutorialMutation) ClearEmployee() {
  26325. m.clearedemployee = true
  26326. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26327. }
  26328. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26329. func (m *TutorialMutation) EmployeeCleared() bool {
  26330. return m.clearedemployee
  26331. }
  26332. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26333. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26334. // EmployeeID instead. It exists only for internal usage by the builders.
  26335. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26336. if id := m.employee; id != nil {
  26337. ids = append(ids, *id)
  26338. }
  26339. return
  26340. }
  26341. // ResetEmployee resets all changes to the "employee" edge.
  26342. func (m *TutorialMutation) ResetEmployee() {
  26343. m.employee = nil
  26344. m.clearedemployee = false
  26345. }
  26346. // Where appends a list predicates to the TutorialMutation builder.
  26347. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26348. m.predicates = append(m.predicates, ps...)
  26349. }
  26350. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26351. // users can use type-assertion to append predicates that do not depend on any generated package.
  26352. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26353. p := make([]predicate.Tutorial, len(ps))
  26354. for i := range ps {
  26355. p[i] = ps[i]
  26356. }
  26357. m.Where(p...)
  26358. }
  26359. // Op returns the operation name.
  26360. func (m *TutorialMutation) Op() Op {
  26361. return m.op
  26362. }
  26363. // SetOp allows setting the mutation operation.
  26364. func (m *TutorialMutation) SetOp(op Op) {
  26365. m.op = op
  26366. }
  26367. // Type returns the node type of this mutation (Tutorial).
  26368. func (m *TutorialMutation) Type() string {
  26369. return m.typ
  26370. }
  26371. // Fields returns all fields that were changed during this mutation. Note that in
  26372. // order to get all numeric fields that were incremented/decremented, call
  26373. // AddedFields().
  26374. func (m *TutorialMutation) Fields() []string {
  26375. fields := make([]string, 0, 8)
  26376. if m.created_at != nil {
  26377. fields = append(fields, tutorial.FieldCreatedAt)
  26378. }
  26379. if m.updated_at != nil {
  26380. fields = append(fields, tutorial.FieldUpdatedAt)
  26381. }
  26382. if m.deleted_at != nil {
  26383. fields = append(fields, tutorial.FieldDeletedAt)
  26384. }
  26385. if m.employee != nil {
  26386. fields = append(fields, tutorial.FieldEmployeeID)
  26387. }
  26388. if m.index != nil {
  26389. fields = append(fields, tutorial.FieldIndex)
  26390. }
  26391. if m.title != nil {
  26392. fields = append(fields, tutorial.FieldTitle)
  26393. }
  26394. if m.content != nil {
  26395. fields = append(fields, tutorial.FieldContent)
  26396. }
  26397. if m.organization_id != nil {
  26398. fields = append(fields, tutorial.FieldOrganizationID)
  26399. }
  26400. return fields
  26401. }
  26402. // Field returns the value of a field with the given name. The second boolean
  26403. // return value indicates that this field was not set, or was not defined in the
  26404. // schema.
  26405. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26406. switch name {
  26407. case tutorial.FieldCreatedAt:
  26408. return m.CreatedAt()
  26409. case tutorial.FieldUpdatedAt:
  26410. return m.UpdatedAt()
  26411. case tutorial.FieldDeletedAt:
  26412. return m.DeletedAt()
  26413. case tutorial.FieldEmployeeID:
  26414. return m.EmployeeID()
  26415. case tutorial.FieldIndex:
  26416. return m.Index()
  26417. case tutorial.FieldTitle:
  26418. return m.Title()
  26419. case tutorial.FieldContent:
  26420. return m.Content()
  26421. case tutorial.FieldOrganizationID:
  26422. return m.OrganizationID()
  26423. }
  26424. return nil, false
  26425. }
  26426. // OldField returns the old value of the field from the database. An error is
  26427. // returned if the mutation operation is not UpdateOne, or the query to the
  26428. // database failed.
  26429. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26430. switch name {
  26431. case tutorial.FieldCreatedAt:
  26432. return m.OldCreatedAt(ctx)
  26433. case tutorial.FieldUpdatedAt:
  26434. return m.OldUpdatedAt(ctx)
  26435. case tutorial.FieldDeletedAt:
  26436. return m.OldDeletedAt(ctx)
  26437. case tutorial.FieldEmployeeID:
  26438. return m.OldEmployeeID(ctx)
  26439. case tutorial.FieldIndex:
  26440. return m.OldIndex(ctx)
  26441. case tutorial.FieldTitle:
  26442. return m.OldTitle(ctx)
  26443. case tutorial.FieldContent:
  26444. return m.OldContent(ctx)
  26445. case tutorial.FieldOrganizationID:
  26446. return m.OldOrganizationID(ctx)
  26447. }
  26448. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26449. }
  26450. // SetField sets the value of a field with the given name. It returns an error if
  26451. // the field is not defined in the schema, or if the type mismatched the field
  26452. // type.
  26453. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26454. switch name {
  26455. case tutorial.FieldCreatedAt:
  26456. v, ok := value.(time.Time)
  26457. if !ok {
  26458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26459. }
  26460. m.SetCreatedAt(v)
  26461. return nil
  26462. case tutorial.FieldUpdatedAt:
  26463. v, ok := value.(time.Time)
  26464. if !ok {
  26465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26466. }
  26467. m.SetUpdatedAt(v)
  26468. return nil
  26469. case tutorial.FieldDeletedAt:
  26470. v, ok := value.(time.Time)
  26471. if !ok {
  26472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26473. }
  26474. m.SetDeletedAt(v)
  26475. return nil
  26476. case tutorial.FieldEmployeeID:
  26477. v, ok := value.(uint64)
  26478. if !ok {
  26479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26480. }
  26481. m.SetEmployeeID(v)
  26482. return nil
  26483. case tutorial.FieldIndex:
  26484. v, ok := value.(int)
  26485. if !ok {
  26486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26487. }
  26488. m.SetIndex(v)
  26489. return nil
  26490. case tutorial.FieldTitle:
  26491. v, ok := value.(string)
  26492. if !ok {
  26493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26494. }
  26495. m.SetTitle(v)
  26496. return nil
  26497. case tutorial.FieldContent:
  26498. v, ok := value.(string)
  26499. if !ok {
  26500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26501. }
  26502. m.SetContent(v)
  26503. return nil
  26504. case tutorial.FieldOrganizationID:
  26505. v, ok := value.(uint64)
  26506. if !ok {
  26507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26508. }
  26509. m.SetOrganizationID(v)
  26510. return nil
  26511. }
  26512. return fmt.Errorf("unknown Tutorial field %s", name)
  26513. }
  26514. // AddedFields returns all numeric fields that were incremented/decremented during
  26515. // this mutation.
  26516. func (m *TutorialMutation) AddedFields() []string {
  26517. var fields []string
  26518. if m.addindex != nil {
  26519. fields = append(fields, tutorial.FieldIndex)
  26520. }
  26521. if m.addorganization_id != nil {
  26522. fields = append(fields, tutorial.FieldOrganizationID)
  26523. }
  26524. return fields
  26525. }
  26526. // AddedField returns the numeric value that was incremented/decremented on a field
  26527. // with the given name. The second boolean return value indicates that this field
  26528. // was not set, or was not defined in the schema.
  26529. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26530. switch name {
  26531. case tutorial.FieldIndex:
  26532. return m.AddedIndex()
  26533. case tutorial.FieldOrganizationID:
  26534. return m.AddedOrganizationID()
  26535. }
  26536. return nil, false
  26537. }
  26538. // AddField adds the value to the field with the given name. It returns an error if
  26539. // the field is not defined in the schema, or if the type mismatched the field
  26540. // type.
  26541. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26542. switch name {
  26543. case tutorial.FieldIndex:
  26544. v, ok := value.(int)
  26545. if !ok {
  26546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26547. }
  26548. m.AddIndex(v)
  26549. return nil
  26550. case tutorial.FieldOrganizationID:
  26551. v, ok := value.(int64)
  26552. if !ok {
  26553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26554. }
  26555. m.AddOrganizationID(v)
  26556. return nil
  26557. }
  26558. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26559. }
  26560. // ClearedFields returns all nullable fields that were cleared during this
  26561. // mutation.
  26562. func (m *TutorialMutation) ClearedFields() []string {
  26563. var fields []string
  26564. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26565. fields = append(fields, tutorial.FieldDeletedAt)
  26566. }
  26567. return fields
  26568. }
  26569. // FieldCleared returns a boolean indicating if a field with the given name was
  26570. // cleared in this mutation.
  26571. func (m *TutorialMutation) FieldCleared(name string) bool {
  26572. _, ok := m.clearedFields[name]
  26573. return ok
  26574. }
  26575. // ClearField clears the value of the field with the given name. It returns an
  26576. // error if the field is not defined in the schema.
  26577. func (m *TutorialMutation) ClearField(name string) error {
  26578. switch name {
  26579. case tutorial.FieldDeletedAt:
  26580. m.ClearDeletedAt()
  26581. return nil
  26582. }
  26583. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26584. }
  26585. // ResetField resets all changes in the mutation for the field with the given name.
  26586. // It returns an error if the field is not defined in the schema.
  26587. func (m *TutorialMutation) ResetField(name string) error {
  26588. switch name {
  26589. case tutorial.FieldCreatedAt:
  26590. m.ResetCreatedAt()
  26591. return nil
  26592. case tutorial.FieldUpdatedAt:
  26593. m.ResetUpdatedAt()
  26594. return nil
  26595. case tutorial.FieldDeletedAt:
  26596. m.ResetDeletedAt()
  26597. return nil
  26598. case tutorial.FieldEmployeeID:
  26599. m.ResetEmployeeID()
  26600. return nil
  26601. case tutorial.FieldIndex:
  26602. m.ResetIndex()
  26603. return nil
  26604. case tutorial.FieldTitle:
  26605. m.ResetTitle()
  26606. return nil
  26607. case tutorial.FieldContent:
  26608. m.ResetContent()
  26609. return nil
  26610. case tutorial.FieldOrganizationID:
  26611. m.ResetOrganizationID()
  26612. return nil
  26613. }
  26614. return fmt.Errorf("unknown Tutorial field %s", name)
  26615. }
  26616. // AddedEdges returns all edge names that were set/added in this mutation.
  26617. func (m *TutorialMutation) AddedEdges() []string {
  26618. edges := make([]string, 0, 1)
  26619. if m.employee != nil {
  26620. edges = append(edges, tutorial.EdgeEmployee)
  26621. }
  26622. return edges
  26623. }
  26624. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26625. // name in this mutation.
  26626. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26627. switch name {
  26628. case tutorial.EdgeEmployee:
  26629. if id := m.employee; id != nil {
  26630. return []ent.Value{*id}
  26631. }
  26632. }
  26633. return nil
  26634. }
  26635. // RemovedEdges returns all edge names that were removed in this mutation.
  26636. func (m *TutorialMutation) RemovedEdges() []string {
  26637. edges := make([]string, 0, 1)
  26638. return edges
  26639. }
  26640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26641. // the given name in this mutation.
  26642. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26643. return nil
  26644. }
  26645. // ClearedEdges returns all edge names that were cleared in this mutation.
  26646. func (m *TutorialMutation) ClearedEdges() []string {
  26647. edges := make([]string, 0, 1)
  26648. if m.clearedemployee {
  26649. edges = append(edges, tutorial.EdgeEmployee)
  26650. }
  26651. return edges
  26652. }
  26653. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26654. // was cleared in this mutation.
  26655. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26656. switch name {
  26657. case tutorial.EdgeEmployee:
  26658. return m.clearedemployee
  26659. }
  26660. return false
  26661. }
  26662. // ClearEdge clears the value of the edge with the given name. It returns an error
  26663. // if that edge is not defined in the schema.
  26664. func (m *TutorialMutation) ClearEdge(name string) error {
  26665. switch name {
  26666. case tutorial.EdgeEmployee:
  26667. m.ClearEmployee()
  26668. return nil
  26669. }
  26670. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26671. }
  26672. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26673. // It returns an error if the edge is not defined in the schema.
  26674. func (m *TutorialMutation) ResetEdge(name string) error {
  26675. switch name {
  26676. case tutorial.EdgeEmployee:
  26677. m.ResetEmployee()
  26678. return nil
  26679. }
  26680. return fmt.Errorf("unknown Tutorial edge %s", name)
  26681. }
  26682. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26683. type UsageDetailMutation struct {
  26684. config
  26685. op Op
  26686. typ string
  26687. id *uint64
  26688. created_at *time.Time
  26689. updated_at *time.Time
  26690. status *uint8
  26691. addstatus *int8
  26692. _type *int
  26693. add_type *int
  26694. bot_id *string
  26695. receiver_id *string
  26696. app *int
  26697. addapp *int
  26698. session_id *uint64
  26699. addsession_id *int64
  26700. request *string
  26701. response *string
  26702. original_data *custom_types.OriginalData
  26703. total_tokens *uint64
  26704. addtotal_tokens *int64
  26705. prompt_tokens *uint64
  26706. addprompt_tokens *int64
  26707. completion_tokens *uint64
  26708. addcompletion_tokens *int64
  26709. organization_id *uint64
  26710. addorganization_id *int64
  26711. clearedFields map[string]struct{}
  26712. done bool
  26713. oldValue func(context.Context) (*UsageDetail, error)
  26714. predicates []predicate.UsageDetail
  26715. }
  26716. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26717. // usagedetailOption allows management of the mutation configuration using functional options.
  26718. type usagedetailOption func(*UsageDetailMutation)
  26719. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26720. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26721. m := &UsageDetailMutation{
  26722. config: c,
  26723. op: op,
  26724. typ: TypeUsageDetail,
  26725. clearedFields: make(map[string]struct{}),
  26726. }
  26727. for _, opt := range opts {
  26728. opt(m)
  26729. }
  26730. return m
  26731. }
  26732. // withUsageDetailID sets the ID field of the mutation.
  26733. func withUsageDetailID(id uint64) usagedetailOption {
  26734. return func(m *UsageDetailMutation) {
  26735. var (
  26736. err error
  26737. once sync.Once
  26738. value *UsageDetail
  26739. )
  26740. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26741. once.Do(func() {
  26742. if m.done {
  26743. err = errors.New("querying old values post mutation is not allowed")
  26744. } else {
  26745. value, err = m.Client().UsageDetail.Get(ctx, id)
  26746. }
  26747. })
  26748. return value, err
  26749. }
  26750. m.id = &id
  26751. }
  26752. }
  26753. // withUsageDetail sets the old UsageDetail of the mutation.
  26754. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26755. return func(m *UsageDetailMutation) {
  26756. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26757. return node, nil
  26758. }
  26759. m.id = &node.ID
  26760. }
  26761. }
  26762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26763. // executed in a transaction (ent.Tx), a transactional client is returned.
  26764. func (m UsageDetailMutation) Client() *Client {
  26765. client := &Client{config: m.config}
  26766. client.init()
  26767. return client
  26768. }
  26769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26770. // it returns an error otherwise.
  26771. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26772. if _, ok := m.driver.(*txDriver); !ok {
  26773. return nil, errors.New("ent: mutation is not running in a transaction")
  26774. }
  26775. tx := &Tx{config: m.config}
  26776. tx.init()
  26777. return tx, nil
  26778. }
  26779. // SetID sets the value of the id field. Note that this
  26780. // operation is only accepted on creation of UsageDetail entities.
  26781. func (m *UsageDetailMutation) SetID(id uint64) {
  26782. m.id = &id
  26783. }
  26784. // ID returns the ID value in the mutation. Note that the ID is only available
  26785. // if it was provided to the builder or after it was returned from the database.
  26786. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26787. if m.id == nil {
  26788. return
  26789. }
  26790. return *m.id, true
  26791. }
  26792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26793. // That means, if the mutation is applied within a transaction with an isolation level such
  26794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26795. // or updated by the mutation.
  26796. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26797. switch {
  26798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26799. id, exists := m.ID()
  26800. if exists {
  26801. return []uint64{id}, nil
  26802. }
  26803. fallthrough
  26804. case m.op.Is(OpUpdate | OpDelete):
  26805. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26806. default:
  26807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26808. }
  26809. }
  26810. // SetCreatedAt sets the "created_at" field.
  26811. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26812. m.created_at = &t
  26813. }
  26814. // CreatedAt returns the value of the "created_at" field in the mutation.
  26815. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26816. v := m.created_at
  26817. if v == nil {
  26818. return
  26819. }
  26820. return *v, true
  26821. }
  26822. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26823. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26825. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26826. if !m.op.Is(OpUpdateOne) {
  26827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26828. }
  26829. if m.id == nil || m.oldValue == nil {
  26830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26831. }
  26832. oldValue, err := m.oldValue(ctx)
  26833. if err != nil {
  26834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26835. }
  26836. return oldValue.CreatedAt, nil
  26837. }
  26838. // ResetCreatedAt resets all changes to the "created_at" field.
  26839. func (m *UsageDetailMutation) ResetCreatedAt() {
  26840. m.created_at = nil
  26841. }
  26842. // SetUpdatedAt sets the "updated_at" field.
  26843. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26844. m.updated_at = &t
  26845. }
  26846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26847. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26848. v := m.updated_at
  26849. if v == nil {
  26850. return
  26851. }
  26852. return *v, true
  26853. }
  26854. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26855. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26857. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26858. if !m.op.Is(OpUpdateOne) {
  26859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26860. }
  26861. if m.id == nil || m.oldValue == nil {
  26862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26863. }
  26864. oldValue, err := m.oldValue(ctx)
  26865. if err != nil {
  26866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26867. }
  26868. return oldValue.UpdatedAt, nil
  26869. }
  26870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26871. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26872. m.updated_at = nil
  26873. }
  26874. // SetStatus sets the "status" field.
  26875. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26876. m.status = &u
  26877. m.addstatus = nil
  26878. }
  26879. // Status returns the value of the "status" field in the mutation.
  26880. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26881. v := m.status
  26882. if v == nil {
  26883. return
  26884. }
  26885. return *v, true
  26886. }
  26887. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26888. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26890. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26891. if !m.op.Is(OpUpdateOne) {
  26892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26893. }
  26894. if m.id == nil || m.oldValue == nil {
  26895. return v, errors.New("OldStatus requires an ID field in the mutation")
  26896. }
  26897. oldValue, err := m.oldValue(ctx)
  26898. if err != nil {
  26899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26900. }
  26901. return oldValue.Status, nil
  26902. }
  26903. // AddStatus adds u to the "status" field.
  26904. func (m *UsageDetailMutation) AddStatus(u int8) {
  26905. if m.addstatus != nil {
  26906. *m.addstatus += u
  26907. } else {
  26908. m.addstatus = &u
  26909. }
  26910. }
  26911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26912. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26913. v := m.addstatus
  26914. if v == nil {
  26915. return
  26916. }
  26917. return *v, true
  26918. }
  26919. // ClearStatus clears the value of the "status" field.
  26920. func (m *UsageDetailMutation) ClearStatus() {
  26921. m.status = nil
  26922. m.addstatus = nil
  26923. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26924. }
  26925. // StatusCleared returns if the "status" field was cleared in this mutation.
  26926. func (m *UsageDetailMutation) StatusCleared() bool {
  26927. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26928. return ok
  26929. }
  26930. // ResetStatus resets all changes to the "status" field.
  26931. func (m *UsageDetailMutation) ResetStatus() {
  26932. m.status = nil
  26933. m.addstatus = nil
  26934. delete(m.clearedFields, usagedetail.FieldStatus)
  26935. }
  26936. // SetType sets the "type" field.
  26937. func (m *UsageDetailMutation) SetType(i int) {
  26938. m._type = &i
  26939. m.add_type = nil
  26940. }
  26941. // GetType returns the value of the "type" field in the mutation.
  26942. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26943. v := m._type
  26944. if v == nil {
  26945. return
  26946. }
  26947. return *v, true
  26948. }
  26949. // OldType returns the old "type" field's value of the UsageDetail entity.
  26950. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26952. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26953. if !m.op.Is(OpUpdateOne) {
  26954. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26955. }
  26956. if m.id == nil || m.oldValue == nil {
  26957. return v, errors.New("OldType requires an ID field in the mutation")
  26958. }
  26959. oldValue, err := m.oldValue(ctx)
  26960. if err != nil {
  26961. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26962. }
  26963. return oldValue.Type, nil
  26964. }
  26965. // AddType adds i to the "type" field.
  26966. func (m *UsageDetailMutation) AddType(i int) {
  26967. if m.add_type != nil {
  26968. *m.add_type += i
  26969. } else {
  26970. m.add_type = &i
  26971. }
  26972. }
  26973. // AddedType returns the value that was added to the "type" field in this mutation.
  26974. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26975. v := m.add_type
  26976. if v == nil {
  26977. return
  26978. }
  26979. return *v, true
  26980. }
  26981. // ClearType clears the value of the "type" field.
  26982. func (m *UsageDetailMutation) ClearType() {
  26983. m._type = nil
  26984. m.add_type = nil
  26985. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26986. }
  26987. // TypeCleared returns if the "type" field was cleared in this mutation.
  26988. func (m *UsageDetailMutation) TypeCleared() bool {
  26989. _, ok := m.clearedFields[usagedetail.FieldType]
  26990. return ok
  26991. }
  26992. // ResetType resets all changes to the "type" field.
  26993. func (m *UsageDetailMutation) ResetType() {
  26994. m._type = nil
  26995. m.add_type = nil
  26996. delete(m.clearedFields, usagedetail.FieldType)
  26997. }
  26998. // SetBotID sets the "bot_id" field.
  26999. func (m *UsageDetailMutation) SetBotID(s string) {
  27000. m.bot_id = &s
  27001. }
  27002. // BotID returns the value of the "bot_id" field in the mutation.
  27003. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27004. v := m.bot_id
  27005. if v == nil {
  27006. return
  27007. }
  27008. return *v, true
  27009. }
  27010. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27011. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27013. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27014. if !m.op.Is(OpUpdateOne) {
  27015. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27016. }
  27017. if m.id == nil || m.oldValue == nil {
  27018. return v, errors.New("OldBotID requires an ID field in the mutation")
  27019. }
  27020. oldValue, err := m.oldValue(ctx)
  27021. if err != nil {
  27022. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27023. }
  27024. return oldValue.BotID, nil
  27025. }
  27026. // ResetBotID resets all changes to the "bot_id" field.
  27027. func (m *UsageDetailMutation) ResetBotID() {
  27028. m.bot_id = nil
  27029. }
  27030. // SetReceiverID sets the "receiver_id" field.
  27031. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27032. m.receiver_id = &s
  27033. }
  27034. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27035. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27036. v := m.receiver_id
  27037. if v == nil {
  27038. return
  27039. }
  27040. return *v, true
  27041. }
  27042. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27043. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27045. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27046. if !m.op.Is(OpUpdateOne) {
  27047. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27048. }
  27049. if m.id == nil || m.oldValue == nil {
  27050. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27051. }
  27052. oldValue, err := m.oldValue(ctx)
  27053. if err != nil {
  27054. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27055. }
  27056. return oldValue.ReceiverID, nil
  27057. }
  27058. // ResetReceiverID resets all changes to the "receiver_id" field.
  27059. func (m *UsageDetailMutation) ResetReceiverID() {
  27060. m.receiver_id = nil
  27061. }
  27062. // SetApp sets the "app" field.
  27063. func (m *UsageDetailMutation) SetApp(i int) {
  27064. m.app = &i
  27065. m.addapp = nil
  27066. }
  27067. // App returns the value of the "app" field in the mutation.
  27068. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27069. v := m.app
  27070. if v == nil {
  27071. return
  27072. }
  27073. return *v, true
  27074. }
  27075. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27076. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27078. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27079. if !m.op.Is(OpUpdateOne) {
  27080. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27081. }
  27082. if m.id == nil || m.oldValue == nil {
  27083. return v, errors.New("OldApp requires an ID field in the mutation")
  27084. }
  27085. oldValue, err := m.oldValue(ctx)
  27086. if err != nil {
  27087. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27088. }
  27089. return oldValue.App, nil
  27090. }
  27091. // AddApp adds i to the "app" field.
  27092. func (m *UsageDetailMutation) AddApp(i int) {
  27093. if m.addapp != nil {
  27094. *m.addapp += i
  27095. } else {
  27096. m.addapp = &i
  27097. }
  27098. }
  27099. // AddedApp returns the value that was added to the "app" field in this mutation.
  27100. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27101. v := m.addapp
  27102. if v == nil {
  27103. return
  27104. }
  27105. return *v, true
  27106. }
  27107. // ClearApp clears the value of the "app" field.
  27108. func (m *UsageDetailMutation) ClearApp() {
  27109. m.app = nil
  27110. m.addapp = nil
  27111. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27112. }
  27113. // AppCleared returns if the "app" field was cleared in this mutation.
  27114. func (m *UsageDetailMutation) AppCleared() bool {
  27115. _, ok := m.clearedFields[usagedetail.FieldApp]
  27116. return ok
  27117. }
  27118. // ResetApp resets all changes to the "app" field.
  27119. func (m *UsageDetailMutation) ResetApp() {
  27120. m.app = nil
  27121. m.addapp = nil
  27122. delete(m.clearedFields, usagedetail.FieldApp)
  27123. }
  27124. // SetSessionID sets the "session_id" field.
  27125. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27126. m.session_id = &u
  27127. m.addsession_id = nil
  27128. }
  27129. // SessionID returns the value of the "session_id" field in the mutation.
  27130. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27131. v := m.session_id
  27132. if v == nil {
  27133. return
  27134. }
  27135. return *v, true
  27136. }
  27137. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27138. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27140. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27141. if !m.op.Is(OpUpdateOne) {
  27142. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27143. }
  27144. if m.id == nil || m.oldValue == nil {
  27145. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27146. }
  27147. oldValue, err := m.oldValue(ctx)
  27148. if err != nil {
  27149. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27150. }
  27151. return oldValue.SessionID, nil
  27152. }
  27153. // AddSessionID adds u to the "session_id" field.
  27154. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27155. if m.addsession_id != nil {
  27156. *m.addsession_id += u
  27157. } else {
  27158. m.addsession_id = &u
  27159. }
  27160. }
  27161. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27162. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27163. v := m.addsession_id
  27164. if v == nil {
  27165. return
  27166. }
  27167. return *v, true
  27168. }
  27169. // ClearSessionID clears the value of the "session_id" field.
  27170. func (m *UsageDetailMutation) ClearSessionID() {
  27171. m.session_id = nil
  27172. m.addsession_id = nil
  27173. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27174. }
  27175. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27176. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27177. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27178. return ok
  27179. }
  27180. // ResetSessionID resets all changes to the "session_id" field.
  27181. func (m *UsageDetailMutation) ResetSessionID() {
  27182. m.session_id = nil
  27183. m.addsession_id = nil
  27184. delete(m.clearedFields, usagedetail.FieldSessionID)
  27185. }
  27186. // SetRequest sets the "request" field.
  27187. func (m *UsageDetailMutation) SetRequest(s string) {
  27188. m.request = &s
  27189. }
  27190. // Request returns the value of the "request" field in the mutation.
  27191. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27192. v := m.request
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27199. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27201. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27202. if !m.op.Is(OpUpdateOne) {
  27203. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27204. }
  27205. if m.id == nil || m.oldValue == nil {
  27206. return v, errors.New("OldRequest requires an ID field in the mutation")
  27207. }
  27208. oldValue, err := m.oldValue(ctx)
  27209. if err != nil {
  27210. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27211. }
  27212. return oldValue.Request, nil
  27213. }
  27214. // ResetRequest resets all changes to the "request" field.
  27215. func (m *UsageDetailMutation) ResetRequest() {
  27216. m.request = nil
  27217. }
  27218. // SetResponse sets the "response" field.
  27219. func (m *UsageDetailMutation) SetResponse(s string) {
  27220. m.response = &s
  27221. }
  27222. // Response returns the value of the "response" field in the mutation.
  27223. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27224. v := m.response
  27225. if v == nil {
  27226. return
  27227. }
  27228. return *v, true
  27229. }
  27230. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27231. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27233. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27234. if !m.op.Is(OpUpdateOne) {
  27235. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27236. }
  27237. if m.id == nil || m.oldValue == nil {
  27238. return v, errors.New("OldResponse requires an ID field in the mutation")
  27239. }
  27240. oldValue, err := m.oldValue(ctx)
  27241. if err != nil {
  27242. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27243. }
  27244. return oldValue.Response, nil
  27245. }
  27246. // ResetResponse resets all changes to the "response" field.
  27247. func (m *UsageDetailMutation) ResetResponse() {
  27248. m.response = nil
  27249. }
  27250. // SetOriginalData sets the "original_data" field.
  27251. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27252. m.original_data = &ctd
  27253. }
  27254. // OriginalData returns the value of the "original_data" field in the mutation.
  27255. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27256. v := m.original_data
  27257. if v == nil {
  27258. return
  27259. }
  27260. return *v, true
  27261. }
  27262. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27263. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27265. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27266. if !m.op.Is(OpUpdateOne) {
  27267. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27268. }
  27269. if m.id == nil || m.oldValue == nil {
  27270. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27271. }
  27272. oldValue, err := m.oldValue(ctx)
  27273. if err != nil {
  27274. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27275. }
  27276. return oldValue.OriginalData, nil
  27277. }
  27278. // ResetOriginalData resets all changes to the "original_data" field.
  27279. func (m *UsageDetailMutation) ResetOriginalData() {
  27280. m.original_data = nil
  27281. }
  27282. // SetTotalTokens sets the "total_tokens" field.
  27283. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27284. m.total_tokens = &u
  27285. m.addtotal_tokens = nil
  27286. }
  27287. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27288. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27289. v := m.total_tokens
  27290. if v == nil {
  27291. return
  27292. }
  27293. return *v, true
  27294. }
  27295. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27296. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27298. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27299. if !m.op.Is(OpUpdateOne) {
  27300. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27301. }
  27302. if m.id == nil || m.oldValue == nil {
  27303. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27304. }
  27305. oldValue, err := m.oldValue(ctx)
  27306. if err != nil {
  27307. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27308. }
  27309. return oldValue.TotalTokens, nil
  27310. }
  27311. // AddTotalTokens adds u to the "total_tokens" field.
  27312. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27313. if m.addtotal_tokens != nil {
  27314. *m.addtotal_tokens += u
  27315. } else {
  27316. m.addtotal_tokens = &u
  27317. }
  27318. }
  27319. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27320. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27321. v := m.addtotal_tokens
  27322. if v == nil {
  27323. return
  27324. }
  27325. return *v, true
  27326. }
  27327. // ClearTotalTokens clears the value of the "total_tokens" field.
  27328. func (m *UsageDetailMutation) ClearTotalTokens() {
  27329. m.total_tokens = nil
  27330. m.addtotal_tokens = nil
  27331. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27332. }
  27333. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27334. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27335. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27336. return ok
  27337. }
  27338. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27339. func (m *UsageDetailMutation) ResetTotalTokens() {
  27340. m.total_tokens = nil
  27341. m.addtotal_tokens = nil
  27342. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27343. }
  27344. // SetPromptTokens sets the "prompt_tokens" field.
  27345. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27346. m.prompt_tokens = &u
  27347. m.addprompt_tokens = nil
  27348. }
  27349. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27350. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27351. v := m.prompt_tokens
  27352. if v == nil {
  27353. return
  27354. }
  27355. return *v, true
  27356. }
  27357. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27358. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27360. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27361. if !m.op.Is(OpUpdateOne) {
  27362. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27363. }
  27364. if m.id == nil || m.oldValue == nil {
  27365. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27366. }
  27367. oldValue, err := m.oldValue(ctx)
  27368. if err != nil {
  27369. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27370. }
  27371. return oldValue.PromptTokens, nil
  27372. }
  27373. // AddPromptTokens adds u to the "prompt_tokens" field.
  27374. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27375. if m.addprompt_tokens != nil {
  27376. *m.addprompt_tokens += u
  27377. } else {
  27378. m.addprompt_tokens = &u
  27379. }
  27380. }
  27381. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27382. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27383. v := m.addprompt_tokens
  27384. if v == nil {
  27385. return
  27386. }
  27387. return *v, true
  27388. }
  27389. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27390. func (m *UsageDetailMutation) ClearPromptTokens() {
  27391. m.prompt_tokens = nil
  27392. m.addprompt_tokens = nil
  27393. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27394. }
  27395. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27396. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27397. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27398. return ok
  27399. }
  27400. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27401. func (m *UsageDetailMutation) ResetPromptTokens() {
  27402. m.prompt_tokens = nil
  27403. m.addprompt_tokens = nil
  27404. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27405. }
  27406. // SetCompletionTokens sets the "completion_tokens" field.
  27407. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27408. m.completion_tokens = &u
  27409. m.addcompletion_tokens = nil
  27410. }
  27411. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27412. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27413. v := m.completion_tokens
  27414. if v == nil {
  27415. return
  27416. }
  27417. return *v, true
  27418. }
  27419. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27420. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27422. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27423. if !m.op.Is(OpUpdateOne) {
  27424. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27425. }
  27426. if m.id == nil || m.oldValue == nil {
  27427. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27428. }
  27429. oldValue, err := m.oldValue(ctx)
  27430. if err != nil {
  27431. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27432. }
  27433. return oldValue.CompletionTokens, nil
  27434. }
  27435. // AddCompletionTokens adds u to the "completion_tokens" field.
  27436. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27437. if m.addcompletion_tokens != nil {
  27438. *m.addcompletion_tokens += u
  27439. } else {
  27440. m.addcompletion_tokens = &u
  27441. }
  27442. }
  27443. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27444. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27445. v := m.addcompletion_tokens
  27446. if v == nil {
  27447. return
  27448. }
  27449. return *v, true
  27450. }
  27451. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27452. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27453. m.completion_tokens = nil
  27454. m.addcompletion_tokens = nil
  27455. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27456. }
  27457. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27458. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27459. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27460. return ok
  27461. }
  27462. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27463. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27464. m.completion_tokens = nil
  27465. m.addcompletion_tokens = nil
  27466. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27467. }
  27468. // SetOrganizationID sets the "organization_id" field.
  27469. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27470. m.organization_id = &u
  27471. m.addorganization_id = nil
  27472. }
  27473. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27474. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27475. v := m.organization_id
  27476. if v == nil {
  27477. return
  27478. }
  27479. return *v, true
  27480. }
  27481. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27482. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27484. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27485. if !m.op.Is(OpUpdateOne) {
  27486. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27487. }
  27488. if m.id == nil || m.oldValue == nil {
  27489. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27490. }
  27491. oldValue, err := m.oldValue(ctx)
  27492. if err != nil {
  27493. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27494. }
  27495. return oldValue.OrganizationID, nil
  27496. }
  27497. // AddOrganizationID adds u to the "organization_id" field.
  27498. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27499. if m.addorganization_id != nil {
  27500. *m.addorganization_id += u
  27501. } else {
  27502. m.addorganization_id = &u
  27503. }
  27504. }
  27505. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27506. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27507. v := m.addorganization_id
  27508. if v == nil {
  27509. return
  27510. }
  27511. return *v, true
  27512. }
  27513. // ClearOrganizationID clears the value of the "organization_id" field.
  27514. func (m *UsageDetailMutation) ClearOrganizationID() {
  27515. m.organization_id = nil
  27516. m.addorganization_id = nil
  27517. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27518. }
  27519. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27520. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27521. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27522. return ok
  27523. }
  27524. // ResetOrganizationID resets all changes to the "organization_id" field.
  27525. func (m *UsageDetailMutation) ResetOrganizationID() {
  27526. m.organization_id = nil
  27527. m.addorganization_id = nil
  27528. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27529. }
  27530. // Where appends a list predicates to the UsageDetailMutation builder.
  27531. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27532. m.predicates = append(m.predicates, ps...)
  27533. }
  27534. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27535. // users can use type-assertion to append predicates that do not depend on any generated package.
  27536. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27537. p := make([]predicate.UsageDetail, len(ps))
  27538. for i := range ps {
  27539. p[i] = ps[i]
  27540. }
  27541. m.Where(p...)
  27542. }
  27543. // Op returns the operation name.
  27544. func (m *UsageDetailMutation) Op() Op {
  27545. return m.op
  27546. }
  27547. // SetOp allows setting the mutation operation.
  27548. func (m *UsageDetailMutation) SetOp(op Op) {
  27549. m.op = op
  27550. }
  27551. // Type returns the node type of this mutation (UsageDetail).
  27552. func (m *UsageDetailMutation) Type() string {
  27553. return m.typ
  27554. }
  27555. // Fields returns all fields that were changed during this mutation. Note that in
  27556. // order to get all numeric fields that were incremented/decremented, call
  27557. // AddedFields().
  27558. func (m *UsageDetailMutation) Fields() []string {
  27559. fields := make([]string, 0, 15)
  27560. if m.created_at != nil {
  27561. fields = append(fields, usagedetail.FieldCreatedAt)
  27562. }
  27563. if m.updated_at != nil {
  27564. fields = append(fields, usagedetail.FieldUpdatedAt)
  27565. }
  27566. if m.status != nil {
  27567. fields = append(fields, usagedetail.FieldStatus)
  27568. }
  27569. if m._type != nil {
  27570. fields = append(fields, usagedetail.FieldType)
  27571. }
  27572. if m.bot_id != nil {
  27573. fields = append(fields, usagedetail.FieldBotID)
  27574. }
  27575. if m.receiver_id != nil {
  27576. fields = append(fields, usagedetail.FieldReceiverID)
  27577. }
  27578. if m.app != nil {
  27579. fields = append(fields, usagedetail.FieldApp)
  27580. }
  27581. if m.session_id != nil {
  27582. fields = append(fields, usagedetail.FieldSessionID)
  27583. }
  27584. if m.request != nil {
  27585. fields = append(fields, usagedetail.FieldRequest)
  27586. }
  27587. if m.response != nil {
  27588. fields = append(fields, usagedetail.FieldResponse)
  27589. }
  27590. if m.original_data != nil {
  27591. fields = append(fields, usagedetail.FieldOriginalData)
  27592. }
  27593. if m.total_tokens != nil {
  27594. fields = append(fields, usagedetail.FieldTotalTokens)
  27595. }
  27596. if m.prompt_tokens != nil {
  27597. fields = append(fields, usagedetail.FieldPromptTokens)
  27598. }
  27599. if m.completion_tokens != nil {
  27600. fields = append(fields, usagedetail.FieldCompletionTokens)
  27601. }
  27602. if m.organization_id != nil {
  27603. fields = append(fields, usagedetail.FieldOrganizationID)
  27604. }
  27605. return fields
  27606. }
  27607. // Field returns the value of a field with the given name. The second boolean
  27608. // return value indicates that this field was not set, or was not defined in the
  27609. // schema.
  27610. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27611. switch name {
  27612. case usagedetail.FieldCreatedAt:
  27613. return m.CreatedAt()
  27614. case usagedetail.FieldUpdatedAt:
  27615. return m.UpdatedAt()
  27616. case usagedetail.FieldStatus:
  27617. return m.Status()
  27618. case usagedetail.FieldType:
  27619. return m.GetType()
  27620. case usagedetail.FieldBotID:
  27621. return m.BotID()
  27622. case usagedetail.FieldReceiverID:
  27623. return m.ReceiverID()
  27624. case usagedetail.FieldApp:
  27625. return m.App()
  27626. case usagedetail.FieldSessionID:
  27627. return m.SessionID()
  27628. case usagedetail.FieldRequest:
  27629. return m.Request()
  27630. case usagedetail.FieldResponse:
  27631. return m.Response()
  27632. case usagedetail.FieldOriginalData:
  27633. return m.OriginalData()
  27634. case usagedetail.FieldTotalTokens:
  27635. return m.TotalTokens()
  27636. case usagedetail.FieldPromptTokens:
  27637. return m.PromptTokens()
  27638. case usagedetail.FieldCompletionTokens:
  27639. return m.CompletionTokens()
  27640. case usagedetail.FieldOrganizationID:
  27641. return m.OrganizationID()
  27642. }
  27643. return nil, false
  27644. }
  27645. // OldField returns the old value of the field from the database. An error is
  27646. // returned if the mutation operation is not UpdateOne, or the query to the
  27647. // database failed.
  27648. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27649. switch name {
  27650. case usagedetail.FieldCreatedAt:
  27651. return m.OldCreatedAt(ctx)
  27652. case usagedetail.FieldUpdatedAt:
  27653. return m.OldUpdatedAt(ctx)
  27654. case usagedetail.FieldStatus:
  27655. return m.OldStatus(ctx)
  27656. case usagedetail.FieldType:
  27657. return m.OldType(ctx)
  27658. case usagedetail.FieldBotID:
  27659. return m.OldBotID(ctx)
  27660. case usagedetail.FieldReceiverID:
  27661. return m.OldReceiverID(ctx)
  27662. case usagedetail.FieldApp:
  27663. return m.OldApp(ctx)
  27664. case usagedetail.FieldSessionID:
  27665. return m.OldSessionID(ctx)
  27666. case usagedetail.FieldRequest:
  27667. return m.OldRequest(ctx)
  27668. case usagedetail.FieldResponse:
  27669. return m.OldResponse(ctx)
  27670. case usagedetail.FieldOriginalData:
  27671. return m.OldOriginalData(ctx)
  27672. case usagedetail.FieldTotalTokens:
  27673. return m.OldTotalTokens(ctx)
  27674. case usagedetail.FieldPromptTokens:
  27675. return m.OldPromptTokens(ctx)
  27676. case usagedetail.FieldCompletionTokens:
  27677. return m.OldCompletionTokens(ctx)
  27678. case usagedetail.FieldOrganizationID:
  27679. return m.OldOrganizationID(ctx)
  27680. }
  27681. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27682. }
  27683. // SetField sets the value of a field with the given name. It returns an error if
  27684. // the field is not defined in the schema, or if the type mismatched the field
  27685. // type.
  27686. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27687. switch name {
  27688. case usagedetail.FieldCreatedAt:
  27689. v, ok := value.(time.Time)
  27690. if !ok {
  27691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27692. }
  27693. m.SetCreatedAt(v)
  27694. return nil
  27695. case usagedetail.FieldUpdatedAt:
  27696. v, ok := value.(time.Time)
  27697. if !ok {
  27698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27699. }
  27700. m.SetUpdatedAt(v)
  27701. return nil
  27702. case usagedetail.FieldStatus:
  27703. v, ok := value.(uint8)
  27704. if !ok {
  27705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27706. }
  27707. m.SetStatus(v)
  27708. return nil
  27709. case usagedetail.FieldType:
  27710. v, ok := value.(int)
  27711. if !ok {
  27712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27713. }
  27714. m.SetType(v)
  27715. return nil
  27716. case usagedetail.FieldBotID:
  27717. v, ok := value.(string)
  27718. if !ok {
  27719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27720. }
  27721. m.SetBotID(v)
  27722. return nil
  27723. case usagedetail.FieldReceiverID:
  27724. v, ok := value.(string)
  27725. if !ok {
  27726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27727. }
  27728. m.SetReceiverID(v)
  27729. return nil
  27730. case usagedetail.FieldApp:
  27731. v, ok := value.(int)
  27732. if !ok {
  27733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27734. }
  27735. m.SetApp(v)
  27736. return nil
  27737. case usagedetail.FieldSessionID:
  27738. v, ok := value.(uint64)
  27739. if !ok {
  27740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27741. }
  27742. m.SetSessionID(v)
  27743. return nil
  27744. case usagedetail.FieldRequest:
  27745. v, ok := value.(string)
  27746. if !ok {
  27747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27748. }
  27749. m.SetRequest(v)
  27750. return nil
  27751. case usagedetail.FieldResponse:
  27752. v, ok := value.(string)
  27753. if !ok {
  27754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27755. }
  27756. m.SetResponse(v)
  27757. return nil
  27758. case usagedetail.FieldOriginalData:
  27759. v, ok := value.(custom_types.OriginalData)
  27760. if !ok {
  27761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27762. }
  27763. m.SetOriginalData(v)
  27764. return nil
  27765. case usagedetail.FieldTotalTokens:
  27766. v, ok := value.(uint64)
  27767. if !ok {
  27768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27769. }
  27770. m.SetTotalTokens(v)
  27771. return nil
  27772. case usagedetail.FieldPromptTokens:
  27773. v, ok := value.(uint64)
  27774. if !ok {
  27775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27776. }
  27777. m.SetPromptTokens(v)
  27778. return nil
  27779. case usagedetail.FieldCompletionTokens:
  27780. v, ok := value.(uint64)
  27781. if !ok {
  27782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27783. }
  27784. m.SetCompletionTokens(v)
  27785. return nil
  27786. case usagedetail.FieldOrganizationID:
  27787. v, ok := value.(uint64)
  27788. if !ok {
  27789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27790. }
  27791. m.SetOrganizationID(v)
  27792. return nil
  27793. }
  27794. return fmt.Errorf("unknown UsageDetail field %s", name)
  27795. }
  27796. // AddedFields returns all numeric fields that were incremented/decremented during
  27797. // this mutation.
  27798. func (m *UsageDetailMutation) AddedFields() []string {
  27799. var fields []string
  27800. if m.addstatus != nil {
  27801. fields = append(fields, usagedetail.FieldStatus)
  27802. }
  27803. if m.add_type != nil {
  27804. fields = append(fields, usagedetail.FieldType)
  27805. }
  27806. if m.addapp != nil {
  27807. fields = append(fields, usagedetail.FieldApp)
  27808. }
  27809. if m.addsession_id != nil {
  27810. fields = append(fields, usagedetail.FieldSessionID)
  27811. }
  27812. if m.addtotal_tokens != nil {
  27813. fields = append(fields, usagedetail.FieldTotalTokens)
  27814. }
  27815. if m.addprompt_tokens != nil {
  27816. fields = append(fields, usagedetail.FieldPromptTokens)
  27817. }
  27818. if m.addcompletion_tokens != nil {
  27819. fields = append(fields, usagedetail.FieldCompletionTokens)
  27820. }
  27821. if m.addorganization_id != nil {
  27822. fields = append(fields, usagedetail.FieldOrganizationID)
  27823. }
  27824. return fields
  27825. }
  27826. // AddedField returns the numeric value that was incremented/decremented on a field
  27827. // with the given name. The second boolean return value indicates that this field
  27828. // was not set, or was not defined in the schema.
  27829. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27830. switch name {
  27831. case usagedetail.FieldStatus:
  27832. return m.AddedStatus()
  27833. case usagedetail.FieldType:
  27834. return m.AddedType()
  27835. case usagedetail.FieldApp:
  27836. return m.AddedApp()
  27837. case usagedetail.FieldSessionID:
  27838. return m.AddedSessionID()
  27839. case usagedetail.FieldTotalTokens:
  27840. return m.AddedTotalTokens()
  27841. case usagedetail.FieldPromptTokens:
  27842. return m.AddedPromptTokens()
  27843. case usagedetail.FieldCompletionTokens:
  27844. return m.AddedCompletionTokens()
  27845. case usagedetail.FieldOrganizationID:
  27846. return m.AddedOrganizationID()
  27847. }
  27848. return nil, false
  27849. }
  27850. // AddField adds the value to the field with the given name. It returns an error if
  27851. // the field is not defined in the schema, or if the type mismatched the field
  27852. // type.
  27853. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27854. switch name {
  27855. case usagedetail.FieldStatus:
  27856. v, ok := value.(int8)
  27857. if !ok {
  27858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27859. }
  27860. m.AddStatus(v)
  27861. return nil
  27862. case usagedetail.FieldType:
  27863. v, ok := value.(int)
  27864. if !ok {
  27865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27866. }
  27867. m.AddType(v)
  27868. return nil
  27869. case usagedetail.FieldApp:
  27870. v, ok := value.(int)
  27871. if !ok {
  27872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27873. }
  27874. m.AddApp(v)
  27875. return nil
  27876. case usagedetail.FieldSessionID:
  27877. v, ok := value.(int64)
  27878. if !ok {
  27879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27880. }
  27881. m.AddSessionID(v)
  27882. return nil
  27883. case usagedetail.FieldTotalTokens:
  27884. v, ok := value.(int64)
  27885. if !ok {
  27886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27887. }
  27888. m.AddTotalTokens(v)
  27889. return nil
  27890. case usagedetail.FieldPromptTokens:
  27891. v, ok := value.(int64)
  27892. if !ok {
  27893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27894. }
  27895. m.AddPromptTokens(v)
  27896. return nil
  27897. case usagedetail.FieldCompletionTokens:
  27898. v, ok := value.(int64)
  27899. if !ok {
  27900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27901. }
  27902. m.AddCompletionTokens(v)
  27903. return nil
  27904. case usagedetail.FieldOrganizationID:
  27905. v, ok := value.(int64)
  27906. if !ok {
  27907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27908. }
  27909. m.AddOrganizationID(v)
  27910. return nil
  27911. }
  27912. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27913. }
  27914. // ClearedFields returns all nullable fields that were cleared during this
  27915. // mutation.
  27916. func (m *UsageDetailMutation) ClearedFields() []string {
  27917. var fields []string
  27918. if m.FieldCleared(usagedetail.FieldStatus) {
  27919. fields = append(fields, usagedetail.FieldStatus)
  27920. }
  27921. if m.FieldCleared(usagedetail.FieldType) {
  27922. fields = append(fields, usagedetail.FieldType)
  27923. }
  27924. if m.FieldCleared(usagedetail.FieldApp) {
  27925. fields = append(fields, usagedetail.FieldApp)
  27926. }
  27927. if m.FieldCleared(usagedetail.FieldSessionID) {
  27928. fields = append(fields, usagedetail.FieldSessionID)
  27929. }
  27930. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27931. fields = append(fields, usagedetail.FieldTotalTokens)
  27932. }
  27933. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27934. fields = append(fields, usagedetail.FieldPromptTokens)
  27935. }
  27936. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27937. fields = append(fields, usagedetail.FieldCompletionTokens)
  27938. }
  27939. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27940. fields = append(fields, usagedetail.FieldOrganizationID)
  27941. }
  27942. return fields
  27943. }
  27944. // FieldCleared returns a boolean indicating if a field with the given name was
  27945. // cleared in this mutation.
  27946. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27947. _, ok := m.clearedFields[name]
  27948. return ok
  27949. }
  27950. // ClearField clears the value of the field with the given name. It returns an
  27951. // error if the field is not defined in the schema.
  27952. func (m *UsageDetailMutation) ClearField(name string) error {
  27953. switch name {
  27954. case usagedetail.FieldStatus:
  27955. m.ClearStatus()
  27956. return nil
  27957. case usagedetail.FieldType:
  27958. m.ClearType()
  27959. return nil
  27960. case usagedetail.FieldApp:
  27961. m.ClearApp()
  27962. return nil
  27963. case usagedetail.FieldSessionID:
  27964. m.ClearSessionID()
  27965. return nil
  27966. case usagedetail.FieldTotalTokens:
  27967. m.ClearTotalTokens()
  27968. return nil
  27969. case usagedetail.FieldPromptTokens:
  27970. m.ClearPromptTokens()
  27971. return nil
  27972. case usagedetail.FieldCompletionTokens:
  27973. m.ClearCompletionTokens()
  27974. return nil
  27975. case usagedetail.FieldOrganizationID:
  27976. m.ClearOrganizationID()
  27977. return nil
  27978. }
  27979. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27980. }
  27981. // ResetField resets all changes in the mutation for the field with the given name.
  27982. // It returns an error if the field is not defined in the schema.
  27983. func (m *UsageDetailMutation) ResetField(name string) error {
  27984. switch name {
  27985. case usagedetail.FieldCreatedAt:
  27986. m.ResetCreatedAt()
  27987. return nil
  27988. case usagedetail.FieldUpdatedAt:
  27989. m.ResetUpdatedAt()
  27990. return nil
  27991. case usagedetail.FieldStatus:
  27992. m.ResetStatus()
  27993. return nil
  27994. case usagedetail.FieldType:
  27995. m.ResetType()
  27996. return nil
  27997. case usagedetail.FieldBotID:
  27998. m.ResetBotID()
  27999. return nil
  28000. case usagedetail.FieldReceiverID:
  28001. m.ResetReceiverID()
  28002. return nil
  28003. case usagedetail.FieldApp:
  28004. m.ResetApp()
  28005. return nil
  28006. case usagedetail.FieldSessionID:
  28007. m.ResetSessionID()
  28008. return nil
  28009. case usagedetail.FieldRequest:
  28010. m.ResetRequest()
  28011. return nil
  28012. case usagedetail.FieldResponse:
  28013. m.ResetResponse()
  28014. return nil
  28015. case usagedetail.FieldOriginalData:
  28016. m.ResetOriginalData()
  28017. return nil
  28018. case usagedetail.FieldTotalTokens:
  28019. m.ResetTotalTokens()
  28020. return nil
  28021. case usagedetail.FieldPromptTokens:
  28022. m.ResetPromptTokens()
  28023. return nil
  28024. case usagedetail.FieldCompletionTokens:
  28025. m.ResetCompletionTokens()
  28026. return nil
  28027. case usagedetail.FieldOrganizationID:
  28028. m.ResetOrganizationID()
  28029. return nil
  28030. }
  28031. return fmt.Errorf("unknown UsageDetail field %s", name)
  28032. }
  28033. // AddedEdges returns all edge names that were set/added in this mutation.
  28034. func (m *UsageDetailMutation) AddedEdges() []string {
  28035. edges := make([]string, 0, 0)
  28036. return edges
  28037. }
  28038. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28039. // name in this mutation.
  28040. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28041. return nil
  28042. }
  28043. // RemovedEdges returns all edge names that were removed in this mutation.
  28044. func (m *UsageDetailMutation) RemovedEdges() []string {
  28045. edges := make([]string, 0, 0)
  28046. return edges
  28047. }
  28048. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28049. // the given name in this mutation.
  28050. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28051. return nil
  28052. }
  28053. // ClearedEdges returns all edge names that were cleared in this mutation.
  28054. func (m *UsageDetailMutation) ClearedEdges() []string {
  28055. edges := make([]string, 0, 0)
  28056. return edges
  28057. }
  28058. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28059. // was cleared in this mutation.
  28060. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28061. return false
  28062. }
  28063. // ClearEdge clears the value of the edge with the given name. It returns an error
  28064. // if that edge is not defined in the schema.
  28065. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28066. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28067. }
  28068. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28069. // It returns an error if the edge is not defined in the schema.
  28070. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28071. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28072. }
  28073. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28074. type UsageStatisticDayMutation struct {
  28075. config
  28076. op Op
  28077. typ string
  28078. id *uint64
  28079. created_at *time.Time
  28080. updated_at *time.Time
  28081. status *uint8
  28082. addstatus *int8
  28083. deleted_at *time.Time
  28084. addtime *uint64
  28085. addaddtime *int64
  28086. _type *int
  28087. add_type *int
  28088. bot_id *string
  28089. organization_id *uint64
  28090. addorganization_id *int64
  28091. ai_response *uint64
  28092. addai_response *int64
  28093. sop_run *uint64
  28094. addsop_run *int64
  28095. total_friend *uint64
  28096. addtotal_friend *int64
  28097. total_group *uint64
  28098. addtotal_group *int64
  28099. account_balance *uint64
  28100. addaccount_balance *int64
  28101. consume_token *uint64
  28102. addconsume_token *int64
  28103. active_user *uint64
  28104. addactive_user *int64
  28105. new_user *int64
  28106. addnew_user *int64
  28107. label_dist *[]custom_types.LabelDist
  28108. appendlabel_dist []custom_types.LabelDist
  28109. clearedFields map[string]struct{}
  28110. done bool
  28111. oldValue func(context.Context) (*UsageStatisticDay, error)
  28112. predicates []predicate.UsageStatisticDay
  28113. }
  28114. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28115. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28116. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28117. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28118. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28119. m := &UsageStatisticDayMutation{
  28120. config: c,
  28121. op: op,
  28122. typ: TypeUsageStatisticDay,
  28123. clearedFields: make(map[string]struct{}),
  28124. }
  28125. for _, opt := range opts {
  28126. opt(m)
  28127. }
  28128. return m
  28129. }
  28130. // withUsageStatisticDayID sets the ID field of the mutation.
  28131. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28132. return func(m *UsageStatisticDayMutation) {
  28133. var (
  28134. err error
  28135. once sync.Once
  28136. value *UsageStatisticDay
  28137. )
  28138. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28139. once.Do(func() {
  28140. if m.done {
  28141. err = errors.New("querying old values post mutation is not allowed")
  28142. } else {
  28143. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28144. }
  28145. })
  28146. return value, err
  28147. }
  28148. m.id = &id
  28149. }
  28150. }
  28151. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28152. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28153. return func(m *UsageStatisticDayMutation) {
  28154. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28155. return node, nil
  28156. }
  28157. m.id = &node.ID
  28158. }
  28159. }
  28160. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28161. // executed in a transaction (ent.Tx), a transactional client is returned.
  28162. func (m UsageStatisticDayMutation) Client() *Client {
  28163. client := &Client{config: m.config}
  28164. client.init()
  28165. return client
  28166. }
  28167. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28168. // it returns an error otherwise.
  28169. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28170. if _, ok := m.driver.(*txDriver); !ok {
  28171. return nil, errors.New("ent: mutation is not running in a transaction")
  28172. }
  28173. tx := &Tx{config: m.config}
  28174. tx.init()
  28175. return tx, nil
  28176. }
  28177. // SetID sets the value of the id field. Note that this
  28178. // operation is only accepted on creation of UsageStatisticDay entities.
  28179. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28180. m.id = &id
  28181. }
  28182. // ID returns the ID value in the mutation. Note that the ID is only available
  28183. // if it was provided to the builder or after it was returned from the database.
  28184. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28185. if m.id == nil {
  28186. return
  28187. }
  28188. return *m.id, true
  28189. }
  28190. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28191. // That means, if the mutation is applied within a transaction with an isolation level such
  28192. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28193. // or updated by the mutation.
  28194. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28195. switch {
  28196. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28197. id, exists := m.ID()
  28198. if exists {
  28199. return []uint64{id}, nil
  28200. }
  28201. fallthrough
  28202. case m.op.Is(OpUpdate | OpDelete):
  28203. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28204. default:
  28205. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28206. }
  28207. }
  28208. // SetCreatedAt sets the "created_at" field.
  28209. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28210. m.created_at = &t
  28211. }
  28212. // CreatedAt returns the value of the "created_at" field in the mutation.
  28213. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28214. v := m.created_at
  28215. if v == nil {
  28216. return
  28217. }
  28218. return *v, true
  28219. }
  28220. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28221. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28223. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28224. if !m.op.Is(OpUpdateOne) {
  28225. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28226. }
  28227. if m.id == nil || m.oldValue == nil {
  28228. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28229. }
  28230. oldValue, err := m.oldValue(ctx)
  28231. if err != nil {
  28232. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28233. }
  28234. return oldValue.CreatedAt, nil
  28235. }
  28236. // ResetCreatedAt resets all changes to the "created_at" field.
  28237. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28238. m.created_at = nil
  28239. }
  28240. // SetUpdatedAt sets the "updated_at" field.
  28241. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28242. m.updated_at = &t
  28243. }
  28244. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28245. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28246. v := m.updated_at
  28247. if v == nil {
  28248. return
  28249. }
  28250. return *v, true
  28251. }
  28252. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28253. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28255. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28256. if !m.op.Is(OpUpdateOne) {
  28257. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28258. }
  28259. if m.id == nil || m.oldValue == nil {
  28260. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28261. }
  28262. oldValue, err := m.oldValue(ctx)
  28263. if err != nil {
  28264. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28265. }
  28266. return oldValue.UpdatedAt, nil
  28267. }
  28268. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28269. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28270. m.updated_at = nil
  28271. }
  28272. // SetStatus sets the "status" field.
  28273. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28274. m.status = &u
  28275. m.addstatus = nil
  28276. }
  28277. // Status returns the value of the "status" field in the mutation.
  28278. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28279. v := m.status
  28280. if v == nil {
  28281. return
  28282. }
  28283. return *v, true
  28284. }
  28285. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28286. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28288. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28289. if !m.op.Is(OpUpdateOne) {
  28290. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28291. }
  28292. if m.id == nil || m.oldValue == nil {
  28293. return v, errors.New("OldStatus requires an ID field in the mutation")
  28294. }
  28295. oldValue, err := m.oldValue(ctx)
  28296. if err != nil {
  28297. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28298. }
  28299. return oldValue.Status, nil
  28300. }
  28301. // AddStatus adds u to the "status" field.
  28302. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28303. if m.addstatus != nil {
  28304. *m.addstatus += u
  28305. } else {
  28306. m.addstatus = &u
  28307. }
  28308. }
  28309. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28310. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28311. v := m.addstatus
  28312. if v == nil {
  28313. return
  28314. }
  28315. return *v, true
  28316. }
  28317. // ClearStatus clears the value of the "status" field.
  28318. func (m *UsageStatisticDayMutation) ClearStatus() {
  28319. m.status = nil
  28320. m.addstatus = nil
  28321. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28322. }
  28323. // StatusCleared returns if the "status" field was cleared in this mutation.
  28324. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28325. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28326. return ok
  28327. }
  28328. // ResetStatus resets all changes to the "status" field.
  28329. func (m *UsageStatisticDayMutation) ResetStatus() {
  28330. m.status = nil
  28331. m.addstatus = nil
  28332. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28333. }
  28334. // SetDeletedAt sets the "deleted_at" field.
  28335. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28336. m.deleted_at = &t
  28337. }
  28338. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28339. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28340. v := m.deleted_at
  28341. if v == nil {
  28342. return
  28343. }
  28344. return *v, true
  28345. }
  28346. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28347. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28349. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28350. if !m.op.Is(OpUpdateOne) {
  28351. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28352. }
  28353. if m.id == nil || m.oldValue == nil {
  28354. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28355. }
  28356. oldValue, err := m.oldValue(ctx)
  28357. if err != nil {
  28358. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28359. }
  28360. return oldValue.DeletedAt, nil
  28361. }
  28362. // ClearDeletedAt clears the value of the "deleted_at" field.
  28363. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28364. m.deleted_at = nil
  28365. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28366. }
  28367. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28368. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28369. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28370. return ok
  28371. }
  28372. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28373. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28374. m.deleted_at = nil
  28375. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28376. }
  28377. // SetAddtime sets the "addtime" field.
  28378. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28379. m.addtime = &u
  28380. m.addaddtime = nil
  28381. }
  28382. // Addtime returns the value of the "addtime" field in the mutation.
  28383. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28384. v := m.addtime
  28385. if v == nil {
  28386. return
  28387. }
  28388. return *v, true
  28389. }
  28390. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28391. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28393. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28394. if !m.op.Is(OpUpdateOne) {
  28395. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28396. }
  28397. if m.id == nil || m.oldValue == nil {
  28398. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28399. }
  28400. oldValue, err := m.oldValue(ctx)
  28401. if err != nil {
  28402. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28403. }
  28404. return oldValue.Addtime, nil
  28405. }
  28406. // AddAddtime adds u to the "addtime" field.
  28407. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28408. if m.addaddtime != nil {
  28409. *m.addaddtime += u
  28410. } else {
  28411. m.addaddtime = &u
  28412. }
  28413. }
  28414. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28415. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28416. v := m.addaddtime
  28417. if v == nil {
  28418. return
  28419. }
  28420. return *v, true
  28421. }
  28422. // ResetAddtime resets all changes to the "addtime" field.
  28423. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28424. m.addtime = nil
  28425. m.addaddtime = nil
  28426. }
  28427. // SetType sets the "type" field.
  28428. func (m *UsageStatisticDayMutation) SetType(i int) {
  28429. m._type = &i
  28430. m.add_type = nil
  28431. }
  28432. // GetType returns the value of the "type" field in the mutation.
  28433. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28434. v := m._type
  28435. if v == nil {
  28436. return
  28437. }
  28438. return *v, true
  28439. }
  28440. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28441. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28443. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28444. if !m.op.Is(OpUpdateOne) {
  28445. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28446. }
  28447. if m.id == nil || m.oldValue == nil {
  28448. return v, errors.New("OldType requires an ID field in the mutation")
  28449. }
  28450. oldValue, err := m.oldValue(ctx)
  28451. if err != nil {
  28452. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28453. }
  28454. return oldValue.Type, nil
  28455. }
  28456. // AddType adds i to the "type" field.
  28457. func (m *UsageStatisticDayMutation) AddType(i int) {
  28458. if m.add_type != nil {
  28459. *m.add_type += i
  28460. } else {
  28461. m.add_type = &i
  28462. }
  28463. }
  28464. // AddedType returns the value that was added to the "type" field in this mutation.
  28465. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28466. v := m.add_type
  28467. if v == nil {
  28468. return
  28469. }
  28470. return *v, true
  28471. }
  28472. // ResetType resets all changes to the "type" field.
  28473. func (m *UsageStatisticDayMutation) ResetType() {
  28474. m._type = nil
  28475. m.add_type = nil
  28476. }
  28477. // SetBotID sets the "bot_id" field.
  28478. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28479. m.bot_id = &s
  28480. }
  28481. // BotID returns the value of the "bot_id" field in the mutation.
  28482. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28483. v := m.bot_id
  28484. if v == nil {
  28485. return
  28486. }
  28487. return *v, true
  28488. }
  28489. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28490. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28492. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28493. if !m.op.Is(OpUpdateOne) {
  28494. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28495. }
  28496. if m.id == nil || m.oldValue == nil {
  28497. return v, errors.New("OldBotID requires an ID field in the mutation")
  28498. }
  28499. oldValue, err := m.oldValue(ctx)
  28500. if err != nil {
  28501. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28502. }
  28503. return oldValue.BotID, nil
  28504. }
  28505. // ClearBotID clears the value of the "bot_id" field.
  28506. func (m *UsageStatisticDayMutation) ClearBotID() {
  28507. m.bot_id = nil
  28508. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28509. }
  28510. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28511. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28512. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28513. return ok
  28514. }
  28515. // ResetBotID resets all changes to the "bot_id" field.
  28516. func (m *UsageStatisticDayMutation) ResetBotID() {
  28517. m.bot_id = nil
  28518. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28519. }
  28520. // SetOrganizationID sets the "organization_id" field.
  28521. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28522. m.organization_id = &u
  28523. m.addorganization_id = nil
  28524. }
  28525. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28526. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28527. v := m.organization_id
  28528. if v == nil {
  28529. return
  28530. }
  28531. return *v, true
  28532. }
  28533. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28534. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28536. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28537. if !m.op.Is(OpUpdateOne) {
  28538. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28539. }
  28540. if m.id == nil || m.oldValue == nil {
  28541. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28542. }
  28543. oldValue, err := m.oldValue(ctx)
  28544. if err != nil {
  28545. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28546. }
  28547. return oldValue.OrganizationID, nil
  28548. }
  28549. // AddOrganizationID adds u to the "organization_id" field.
  28550. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28551. if m.addorganization_id != nil {
  28552. *m.addorganization_id += u
  28553. } else {
  28554. m.addorganization_id = &u
  28555. }
  28556. }
  28557. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28558. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28559. v := m.addorganization_id
  28560. if v == nil {
  28561. return
  28562. }
  28563. return *v, true
  28564. }
  28565. // ClearOrganizationID clears the value of the "organization_id" field.
  28566. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28567. m.organization_id = nil
  28568. m.addorganization_id = nil
  28569. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28570. }
  28571. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28572. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28573. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28574. return ok
  28575. }
  28576. // ResetOrganizationID resets all changes to the "organization_id" field.
  28577. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28578. m.organization_id = nil
  28579. m.addorganization_id = nil
  28580. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28581. }
  28582. // SetAiResponse sets the "ai_response" field.
  28583. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28584. m.ai_response = &u
  28585. m.addai_response = nil
  28586. }
  28587. // AiResponse returns the value of the "ai_response" field in the mutation.
  28588. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28589. v := m.ai_response
  28590. if v == nil {
  28591. return
  28592. }
  28593. return *v, true
  28594. }
  28595. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28596. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28598. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28599. if !m.op.Is(OpUpdateOne) {
  28600. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28601. }
  28602. if m.id == nil || m.oldValue == nil {
  28603. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28604. }
  28605. oldValue, err := m.oldValue(ctx)
  28606. if err != nil {
  28607. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28608. }
  28609. return oldValue.AiResponse, nil
  28610. }
  28611. // AddAiResponse adds u to the "ai_response" field.
  28612. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28613. if m.addai_response != nil {
  28614. *m.addai_response += u
  28615. } else {
  28616. m.addai_response = &u
  28617. }
  28618. }
  28619. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28620. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28621. v := m.addai_response
  28622. if v == nil {
  28623. return
  28624. }
  28625. return *v, true
  28626. }
  28627. // ResetAiResponse resets all changes to the "ai_response" field.
  28628. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28629. m.ai_response = nil
  28630. m.addai_response = nil
  28631. }
  28632. // SetSopRun sets the "sop_run" field.
  28633. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28634. m.sop_run = &u
  28635. m.addsop_run = nil
  28636. }
  28637. // SopRun returns the value of the "sop_run" field in the mutation.
  28638. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28639. v := m.sop_run
  28640. if v == nil {
  28641. return
  28642. }
  28643. return *v, true
  28644. }
  28645. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28646. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28648. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28649. if !m.op.Is(OpUpdateOne) {
  28650. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28651. }
  28652. if m.id == nil || m.oldValue == nil {
  28653. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28654. }
  28655. oldValue, err := m.oldValue(ctx)
  28656. if err != nil {
  28657. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28658. }
  28659. return oldValue.SopRun, nil
  28660. }
  28661. // AddSopRun adds u to the "sop_run" field.
  28662. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28663. if m.addsop_run != nil {
  28664. *m.addsop_run += u
  28665. } else {
  28666. m.addsop_run = &u
  28667. }
  28668. }
  28669. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28670. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28671. v := m.addsop_run
  28672. if v == nil {
  28673. return
  28674. }
  28675. return *v, true
  28676. }
  28677. // ResetSopRun resets all changes to the "sop_run" field.
  28678. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28679. m.sop_run = nil
  28680. m.addsop_run = nil
  28681. }
  28682. // SetTotalFriend sets the "total_friend" field.
  28683. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28684. m.total_friend = &u
  28685. m.addtotal_friend = nil
  28686. }
  28687. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28688. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28689. v := m.total_friend
  28690. if v == nil {
  28691. return
  28692. }
  28693. return *v, true
  28694. }
  28695. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28696. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28698. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28699. if !m.op.Is(OpUpdateOne) {
  28700. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28701. }
  28702. if m.id == nil || m.oldValue == nil {
  28703. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28704. }
  28705. oldValue, err := m.oldValue(ctx)
  28706. if err != nil {
  28707. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28708. }
  28709. return oldValue.TotalFriend, nil
  28710. }
  28711. // AddTotalFriend adds u to the "total_friend" field.
  28712. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28713. if m.addtotal_friend != nil {
  28714. *m.addtotal_friend += u
  28715. } else {
  28716. m.addtotal_friend = &u
  28717. }
  28718. }
  28719. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28720. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28721. v := m.addtotal_friend
  28722. if v == nil {
  28723. return
  28724. }
  28725. return *v, true
  28726. }
  28727. // ResetTotalFriend resets all changes to the "total_friend" field.
  28728. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28729. m.total_friend = nil
  28730. m.addtotal_friend = nil
  28731. }
  28732. // SetTotalGroup sets the "total_group" field.
  28733. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28734. m.total_group = &u
  28735. m.addtotal_group = nil
  28736. }
  28737. // TotalGroup returns the value of the "total_group" field in the mutation.
  28738. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28739. v := m.total_group
  28740. if v == nil {
  28741. return
  28742. }
  28743. return *v, true
  28744. }
  28745. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28746. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28748. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28749. if !m.op.Is(OpUpdateOne) {
  28750. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28751. }
  28752. if m.id == nil || m.oldValue == nil {
  28753. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28754. }
  28755. oldValue, err := m.oldValue(ctx)
  28756. if err != nil {
  28757. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28758. }
  28759. return oldValue.TotalGroup, nil
  28760. }
  28761. // AddTotalGroup adds u to the "total_group" field.
  28762. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28763. if m.addtotal_group != nil {
  28764. *m.addtotal_group += u
  28765. } else {
  28766. m.addtotal_group = &u
  28767. }
  28768. }
  28769. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28770. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28771. v := m.addtotal_group
  28772. if v == nil {
  28773. return
  28774. }
  28775. return *v, true
  28776. }
  28777. // ResetTotalGroup resets all changes to the "total_group" field.
  28778. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28779. m.total_group = nil
  28780. m.addtotal_group = nil
  28781. }
  28782. // SetAccountBalance sets the "account_balance" field.
  28783. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28784. m.account_balance = &u
  28785. m.addaccount_balance = nil
  28786. }
  28787. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28788. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28789. v := m.account_balance
  28790. if v == nil {
  28791. return
  28792. }
  28793. return *v, true
  28794. }
  28795. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28796. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28798. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28799. if !m.op.Is(OpUpdateOne) {
  28800. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28801. }
  28802. if m.id == nil || m.oldValue == nil {
  28803. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28804. }
  28805. oldValue, err := m.oldValue(ctx)
  28806. if err != nil {
  28807. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28808. }
  28809. return oldValue.AccountBalance, nil
  28810. }
  28811. // AddAccountBalance adds u to the "account_balance" field.
  28812. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28813. if m.addaccount_balance != nil {
  28814. *m.addaccount_balance += u
  28815. } else {
  28816. m.addaccount_balance = &u
  28817. }
  28818. }
  28819. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28820. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28821. v := m.addaccount_balance
  28822. if v == nil {
  28823. return
  28824. }
  28825. return *v, true
  28826. }
  28827. // ResetAccountBalance resets all changes to the "account_balance" field.
  28828. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28829. m.account_balance = nil
  28830. m.addaccount_balance = nil
  28831. }
  28832. // SetConsumeToken sets the "consume_token" field.
  28833. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28834. m.consume_token = &u
  28835. m.addconsume_token = nil
  28836. }
  28837. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28838. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28839. v := m.consume_token
  28840. if v == nil {
  28841. return
  28842. }
  28843. return *v, true
  28844. }
  28845. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28846. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28848. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28849. if !m.op.Is(OpUpdateOne) {
  28850. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28851. }
  28852. if m.id == nil || m.oldValue == nil {
  28853. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28854. }
  28855. oldValue, err := m.oldValue(ctx)
  28856. if err != nil {
  28857. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28858. }
  28859. return oldValue.ConsumeToken, nil
  28860. }
  28861. // AddConsumeToken adds u to the "consume_token" field.
  28862. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28863. if m.addconsume_token != nil {
  28864. *m.addconsume_token += u
  28865. } else {
  28866. m.addconsume_token = &u
  28867. }
  28868. }
  28869. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28870. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28871. v := m.addconsume_token
  28872. if v == nil {
  28873. return
  28874. }
  28875. return *v, true
  28876. }
  28877. // ResetConsumeToken resets all changes to the "consume_token" field.
  28878. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28879. m.consume_token = nil
  28880. m.addconsume_token = nil
  28881. }
  28882. // SetActiveUser sets the "active_user" field.
  28883. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28884. m.active_user = &u
  28885. m.addactive_user = nil
  28886. }
  28887. // ActiveUser returns the value of the "active_user" field in the mutation.
  28888. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28889. v := m.active_user
  28890. if v == nil {
  28891. return
  28892. }
  28893. return *v, true
  28894. }
  28895. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28896. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28898. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28899. if !m.op.Is(OpUpdateOne) {
  28900. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28901. }
  28902. if m.id == nil || m.oldValue == nil {
  28903. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28904. }
  28905. oldValue, err := m.oldValue(ctx)
  28906. if err != nil {
  28907. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28908. }
  28909. return oldValue.ActiveUser, nil
  28910. }
  28911. // AddActiveUser adds u to the "active_user" field.
  28912. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28913. if m.addactive_user != nil {
  28914. *m.addactive_user += u
  28915. } else {
  28916. m.addactive_user = &u
  28917. }
  28918. }
  28919. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28920. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28921. v := m.addactive_user
  28922. if v == nil {
  28923. return
  28924. }
  28925. return *v, true
  28926. }
  28927. // ResetActiveUser resets all changes to the "active_user" field.
  28928. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28929. m.active_user = nil
  28930. m.addactive_user = nil
  28931. }
  28932. // SetNewUser sets the "new_user" field.
  28933. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28934. m.new_user = &i
  28935. m.addnew_user = nil
  28936. }
  28937. // NewUser returns the value of the "new_user" field in the mutation.
  28938. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28939. v := m.new_user
  28940. if v == nil {
  28941. return
  28942. }
  28943. return *v, true
  28944. }
  28945. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28946. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28948. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28949. if !m.op.Is(OpUpdateOne) {
  28950. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28951. }
  28952. if m.id == nil || m.oldValue == nil {
  28953. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28954. }
  28955. oldValue, err := m.oldValue(ctx)
  28956. if err != nil {
  28957. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28958. }
  28959. return oldValue.NewUser, nil
  28960. }
  28961. // AddNewUser adds i to the "new_user" field.
  28962. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28963. if m.addnew_user != nil {
  28964. *m.addnew_user += i
  28965. } else {
  28966. m.addnew_user = &i
  28967. }
  28968. }
  28969. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28970. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28971. v := m.addnew_user
  28972. if v == nil {
  28973. return
  28974. }
  28975. return *v, true
  28976. }
  28977. // ResetNewUser resets all changes to the "new_user" field.
  28978. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28979. m.new_user = nil
  28980. m.addnew_user = nil
  28981. }
  28982. // SetLabelDist sets the "label_dist" field.
  28983. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28984. m.label_dist = &ctd
  28985. m.appendlabel_dist = nil
  28986. }
  28987. // LabelDist returns the value of the "label_dist" field in the mutation.
  28988. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28989. v := m.label_dist
  28990. if v == nil {
  28991. return
  28992. }
  28993. return *v, true
  28994. }
  28995. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28996. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28998. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28999. if !m.op.Is(OpUpdateOne) {
  29000. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29001. }
  29002. if m.id == nil || m.oldValue == nil {
  29003. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29004. }
  29005. oldValue, err := m.oldValue(ctx)
  29006. if err != nil {
  29007. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29008. }
  29009. return oldValue.LabelDist, nil
  29010. }
  29011. // AppendLabelDist adds ctd to the "label_dist" field.
  29012. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29013. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29014. }
  29015. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29016. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29017. if len(m.appendlabel_dist) == 0 {
  29018. return nil, false
  29019. }
  29020. return m.appendlabel_dist, true
  29021. }
  29022. // ResetLabelDist resets all changes to the "label_dist" field.
  29023. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29024. m.label_dist = nil
  29025. m.appendlabel_dist = nil
  29026. }
  29027. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29028. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29029. m.predicates = append(m.predicates, ps...)
  29030. }
  29031. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29032. // users can use type-assertion to append predicates that do not depend on any generated package.
  29033. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29034. p := make([]predicate.UsageStatisticDay, len(ps))
  29035. for i := range ps {
  29036. p[i] = ps[i]
  29037. }
  29038. m.Where(p...)
  29039. }
  29040. // Op returns the operation name.
  29041. func (m *UsageStatisticDayMutation) Op() Op {
  29042. return m.op
  29043. }
  29044. // SetOp allows setting the mutation operation.
  29045. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29046. m.op = op
  29047. }
  29048. // Type returns the node type of this mutation (UsageStatisticDay).
  29049. func (m *UsageStatisticDayMutation) Type() string {
  29050. return m.typ
  29051. }
  29052. // Fields returns all fields that were changed during this mutation. Note that in
  29053. // order to get all numeric fields that were incremented/decremented, call
  29054. // AddedFields().
  29055. func (m *UsageStatisticDayMutation) Fields() []string {
  29056. fields := make([]string, 0, 17)
  29057. if m.created_at != nil {
  29058. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29059. }
  29060. if m.updated_at != nil {
  29061. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29062. }
  29063. if m.status != nil {
  29064. fields = append(fields, usagestatisticday.FieldStatus)
  29065. }
  29066. if m.deleted_at != nil {
  29067. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29068. }
  29069. if m.addtime != nil {
  29070. fields = append(fields, usagestatisticday.FieldAddtime)
  29071. }
  29072. if m._type != nil {
  29073. fields = append(fields, usagestatisticday.FieldType)
  29074. }
  29075. if m.bot_id != nil {
  29076. fields = append(fields, usagestatisticday.FieldBotID)
  29077. }
  29078. if m.organization_id != nil {
  29079. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29080. }
  29081. if m.ai_response != nil {
  29082. fields = append(fields, usagestatisticday.FieldAiResponse)
  29083. }
  29084. if m.sop_run != nil {
  29085. fields = append(fields, usagestatisticday.FieldSopRun)
  29086. }
  29087. if m.total_friend != nil {
  29088. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29089. }
  29090. if m.total_group != nil {
  29091. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29092. }
  29093. if m.account_balance != nil {
  29094. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29095. }
  29096. if m.consume_token != nil {
  29097. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29098. }
  29099. if m.active_user != nil {
  29100. fields = append(fields, usagestatisticday.FieldActiveUser)
  29101. }
  29102. if m.new_user != nil {
  29103. fields = append(fields, usagestatisticday.FieldNewUser)
  29104. }
  29105. if m.label_dist != nil {
  29106. fields = append(fields, usagestatisticday.FieldLabelDist)
  29107. }
  29108. return fields
  29109. }
  29110. // Field returns the value of a field with the given name. The second boolean
  29111. // return value indicates that this field was not set, or was not defined in the
  29112. // schema.
  29113. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29114. switch name {
  29115. case usagestatisticday.FieldCreatedAt:
  29116. return m.CreatedAt()
  29117. case usagestatisticday.FieldUpdatedAt:
  29118. return m.UpdatedAt()
  29119. case usagestatisticday.FieldStatus:
  29120. return m.Status()
  29121. case usagestatisticday.FieldDeletedAt:
  29122. return m.DeletedAt()
  29123. case usagestatisticday.FieldAddtime:
  29124. return m.Addtime()
  29125. case usagestatisticday.FieldType:
  29126. return m.GetType()
  29127. case usagestatisticday.FieldBotID:
  29128. return m.BotID()
  29129. case usagestatisticday.FieldOrganizationID:
  29130. return m.OrganizationID()
  29131. case usagestatisticday.FieldAiResponse:
  29132. return m.AiResponse()
  29133. case usagestatisticday.FieldSopRun:
  29134. return m.SopRun()
  29135. case usagestatisticday.FieldTotalFriend:
  29136. return m.TotalFriend()
  29137. case usagestatisticday.FieldTotalGroup:
  29138. return m.TotalGroup()
  29139. case usagestatisticday.FieldAccountBalance:
  29140. return m.AccountBalance()
  29141. case usagestatisticday.FieldConsumeToken:
  29142. return m.ConsumeToken()
  29143. case usagestatisticday.FieldActiveUser:
  29144. return m.ActiveUser()
  29145. case usagestatisticday.FieldNewUser:
  29146. return m.NewUser()
  29147. case usagestatisticday.FieldLabelDist:
  29148. return m.LabelDist()
  29149. }
  29150. return nil, false
  29151. }
  29152. // OldField returns the old value of the field from the database. An error is
  29153. // returned if the mutation operation is not UpdateOne, or the query to the
  29154. // database failed.
  29155. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29156. switch name {
  29157. case usagestatisticday.FieldCreatedAt:
  29158. return m.OldCreatedAt(ctx)
  29159. case usagestatisticday.FieldUpdatedAt:
  29160. return m.OldUpdatedAt(ctx)
  29161. case usagestatisticday.FieldStatus:
  29162. return m.OldStatus(ctx)
  29163. case usagestatisticday.FieldDeletedAt:
  29164. return m.OldDeletedAt(ctx)
  29165. case usagestatisticday.FieldAddtime:
  29166. return m.OldAddtime(ctx)
  29167. case usagestatisticday.FieldType:
  29168. return m.OldType(ctx)
  29169. case usagestatisticday.FieldBotID:
  29170. return m.OldBotID(ctx)
  29171. case usagestatisticday.FieldOrganizationID:
  29172. return m.OldOrganizationID(ctx)
  29173. case usagestatisticday.FieldAiResponse:
  29174. return m.OldAiResponse(ctx)
  29175. case usagestatisticday.FieldSopRun:
  29176. return m.OldSopRun(ctx)
  29177. case usagestatisticday.FieldTotalFriend:
  29178. return m.OldTotalFriend(ctx)
  29179. case usagestatisticday.FieldTotalGroup:
  29180. return m.OldTotalGroup(ctx)
  29181. case usagestatisticday.FieldAccountBalance:
  29182. return m.OldAccountBalance(ctx)
  29183. case usagestatisticday.FieldConsumeToken:
  29184. return m.OldConsumeToken(ctx)
  29185. case usagestatisticday.FieldActiveUser:
  29186. return m.OldActiveUser(ctx)
  29187. case usagestatisticday.FieldNewUser:
  29188. return m.OldNewUser(ctx)
  29189. case usagestatisticday.FieldLabelDist:
  29190. return m.OldLabelDist(ctx)
  29191. }
  29192. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29193. }
  29194. // SetField sets the value of a field with the given name. It returns an error if
  29195. // the field is not defined in the schema, or if the type mismatched the field
  29196. // type.
  29197. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29198. switch name {
  29199. case usagestatisticday.FieldCreatedAt:
  29200. v, ok := value.(time.Time)
  29201. if !ok {
  29202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29203. }
  29204. m.SetCreatedAt(v)
  29205. return nil
  29206. case usagestatisticday.FieldUpdatedAt:
  29207. v, ok := value.(time.Time)
  29208. if !ok {
  29209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29210. }
  29211. m.SetUpdatedAt(v)
  29212. return nil
  29213. case usagestatisticday.FieldStatus:
  29214. v, ok := value.(uint8)
  29215. if !ok {
  29216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29217. }
  29218. m.SetStatus(v)
  29219. return nil
  29220. case usagestatisticday.FieldDeletedAt:
  29221. v, ok := value.(time.Time)
  29222. if !ok {
  29223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29224. }
  29225. m.SetDeletedAt(v)
  29226. return nil
  29227. case usagestatisticday.FieldAddtime:
  29228. v, ok := value.(uint64)
  29229. if !ok {
  29230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29231. }
  29232. m.SetAddtime(v)
  29233. return nil
  29234. case usagestatisticday.FieldType:
  29235. v, ok := value.(int)
  29236. if !ok {
  29237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29238. }
  29239. m.SetType(v)
  29240. return nil
  29241. case usagestatisticday.FieldBotID:
  29242. v, ok := value.(string)
  29243. if !ok {
  29244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29245. }
  29246. m.SetBotID(v)
  29247. return nil
  29248. case usagestatisticday.FieldOrganizationID:
  29249. v, ok := value.(uint64)
  29250. if !ok {
  29251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29252. }
  29253. m.SetOrganizationID(v)
  29254. return nil
  29255. case usagestatisticday.FieldAiResponse:
  29256. v, ok := value.(uint64)
  29257. if !ok {
  29258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29259. }
  29260. m.SetAiResponse(v)
  29261. return nil
  29262. case usagestatisticday.FieldSopRun:
  29263. v, ok := value.(uint64)
  29264. if !ok {
  29265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29266. }
  29267. m.SetSopRun(v)
  29268. return nil
  29269. case usagestatisticday.FieldTotalFriend:
  29270. v, ok := value.(uint64)
  29271. if !ok {
  29272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29273. }
  29274. m.SetTotalFriend(v)
  29275. return nil
  29276. case usagestatisticday.FieldTotalGroup:
  29277. v, ok := value.(uint64)
  29278. if !ok {
  29279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29280. }
  29281. m.SetTotalGroup(v)
  29282. return nil
  29283. case usagestatisticday.FieldAccountBalance:
  29284. v, ok := value.(uint64)
  29285. if !ok {
  29286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29287. }
  29288. m.SetAccountBalance(v)
  29289. return nil
  29290. case usagestatisticday.FieldConsumeToken:
  29291. v, ok := value.(uint64)
  29292. if !ok {
  29293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29294. }
  29295. m.SetConsumeToken(v)
  29296. return nil
  29297. case usagestatisticday.FieldActiveUser:
  29298. v, ok := value.(uint64)
  29299. if !ok {
  29300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29301. }
  29302. m.SetActiveUser(v)
  29303. return nil
  29304. case usagestatisticday.FieldNewUser:
  29305. v, ok := value.(int64)
  29306. if !ok {
  29307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29308. }
  29309. m.SetNewUser(v)
  29310. return nil
  29311. case usagestatisticday.FieldLabelDist:
  29312. v, ok := value.([]custom_types.LabelDist)
  29313. if !ok {
  29314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29315. }
  29316. m.SetLabelDist(v)
  29317. return nil
  29318. }
  29319. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29320. }
  29321. // AddedFields returns all numeric fields that were incremented/decremented during
  29322. // this mutation.
  29323. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29324. var fields []string
  29325. if m.addstatus != nil {
  29326. fields = append(fields, usagestatisticday.FieldStatus)
  29327. }
  29328. if m.addaddtime != nil {
  29329. fields = append(fields, usagestatisticday.FieldAddtime)
  29330. }
  29331. if m.add_type != nil {
  29332. fields = append(fields, usagestatisticday.FieldType)
  29333. }
  29334. if m.addorganization_id != nil {
  29335. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29336. }
  29337. if m.addai_response != nil {
  29338. fields = append(fields, usagestatisticday.FieldAiResponse)
  29339. }
  29340. if m.addsop_run != nil {
  29341. fields = append(fields, usagestatisticday.FieldSopRun)
  29342. }
  29343. if m.addtotal_friend != nil {
  29344. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29345. }
  29346. if m.addtotal_group != nil {
  29347. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29348. }
  29349. if m.addaccount_balance != nil {
  29350. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29351. }
  29352. if m.addconsume_token != nil {
  29353. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29354. }
  29355. if m.addactive_user != nil {
  29356. fields = append(fields, usagestatisticday.FieldActiveUser)
  29357. }
  29358. if m.addnew_user != nil {
  29359. fields = append(fields, usagestatisticday.FieldNewUser)
  29360. }
  29361. return fields
  29362. }
  29363. // AddedField returns the numeric value that was incremented/decremented on a field
  29364. // with the given name. The second boolean return value indicates that this field
  29365. // was not set, or was not defined in the schema.
  29366. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29367. switch name {
  29368. case usagestatisticday.FieldStatus:
  29369. return m.AddedStatus()
  29370. case usagestatisticday.FieldAddtime:
  29371. return m.AddedAddtime()
  29372. case usagestatisticday.FieldType:
  29373. return m.AddedType()
  29374. case usagestatisticday.FieldOrganizationID:
  29375. return m.AddedOrganizationID()
  29376. case usagestatisticday.FieldAiResponse:
  29377. return m.AddedAiResponse()
  29378. case usagestatisticday.FieldSopRun:
  29379. return m.AddedSopRun()
  29380. case usagestatisticday.FieldTotalFriend:
  29381. return m.AddedTotalFriend()
  29382. case usagestatisticday.FieldTotalGroup:
  29383. return m.AddedTotalGroup()
  29384. case usagestatisticday.FieldAccountBalance:
  29385. return m.AddedAccountBalance()
  29386. case usagestatisticday.FieldConsumeToken:
  29387. return m.AddedConsumeToken()
  29388. case usagestatisticday.FieldActiveUser:
  29389. return m.AddedActiveUser()
  29390. case usagestatisticday.FieldNewUser:
  29391. return m.AddedNewUser()
  29392. }
  29393. return nil, false
  29394. }
  29395. // AddField adds the value to the field with the given name. It returns an error if
  29396. // the field is not defined in the schema, or if the type mismatched the field
  29397. // type.
  29398. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29399. switch name {
  29400. case usagestatisticday.FieldStatus:
  29401. v, ok := value.(int8)
  29402. if !ok {
  29403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29404. }
  29405. m.AddStatus(v)
  29406. return nil
  29407. case usagestatisticday.FieldAddtime:
  29408. v, ok := value.(int64)
  29409. if !ok {
  29410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29411. }
  29412. m.AddAddtime(v)
  29413. return nil
  29414. case usagestatisticday.FieldType:
  29415. v, ok := value.(int)
  29416. if !ok {
  29417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29418. }
  29419. m.AddType(v)
  29420. return nil
  29421. case usagestatisticday.FieldOrganizationID:
  29422. v, ok := value.(int64)
  29423. if !ok {
  29424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29425. }
  29426. m.AddOrganizationID(v)
  29427. return nil
  29428. case usagestatisticday.FieldAiResponse:
  29429. v, ok := value.(int64)
  29430. if !ok {
  29431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29432. }
  29433. m.AddAiResponse(v)
  29434. return nil
  29435. case usagestatisticday.FieldSopRun:
  29436. v, ok := value.(int64)
  29437. if !ok {
  29438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29439. }
  29440. m.AddSopRun(v)
  29441. return nil
  29442. case usagestatisticday.FieldTotalFriend:
  29443. v, ok := value.(int64)
  29444. if !ok {
  29445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29446. }
  29447. m.AddTotalFriend(v)
  29448. return nil
  29449. case usagestatisticday.FieldTotalGroup:
  29450. v, ok := value.(int64)
  29451. if !ok {
  29452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29453. }
  29454. m.AddTotalGroup(v)
  29455. return nil
  29456. case usagestatisticday.FieldAccountBalance:
  29457. v, ok := value.(int64)
  29458. if !ok {
  29459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29460. }
  29461. m.AddAccountBalance(v)
  29462. return nil
  29463. case usagestatisticday.FieldConsumeToken:
  29464. v, ok := value.(int64)
  29465. if !ok {
  29466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29467. }
  29468. m.AddConsumeToken(v)
  29469. return nil
  29470. case usagestatisticday.FieldActiveUser:
  29471. v, ok := value.(int64)
  29472. if !ok {
  29473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29474. }
  29475. m.AddActiveUser(v)
  29476. return nil
  29477. case usagestatisticday.FieldNewUser:
  29478. v, ok := value.(int64)
  29479. if !ok {
  29480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29481. }
  29482. m.AddNewUser(v)
  29483. return nil
  29484. }
  29485. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29486. }
  29487. // ClearedFields returns all nullable fields that were cleared during this
  29488. // mutation.
  29489. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29490. var fields []string
  29491. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29492. fields = append(fields, usagestatisticday.FieldStatus)
  29493. }
  29494. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29495. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29496. }
  29497. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29498. fields = append(fields, usagestatisticday.FieldBotID)
  29499. }
  29500. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29501. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29502. }
  29503. return fields
  29504. }
  29505. // FieldCleared returns a boolean indicating if a field with the given name was
  29506. // cleared in this mutation.
  29507. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29508. _, ok := m.clearedFields[name]
  29509. return ok
  29510. }
  29511. // ClearField clears the value of the field with the given name. It returns an
  29512. // error if the field is not defined in the schema.
  29513. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29514. switch name {
  29515. case usagestatisticday.FieldStatus:
  29516. m.ClearStatus()
  29517. return nil
  29518. case usagestatisticday.FieldDeletedAt:
  29519. m.ClearDeletedAt()
  29520. return nil
  29521. case usagestatisticday.FieldBotID:
  29522. m.ClearBotID()
  29523. return nil
  29524. case usagestatisticday.FieldOrganizationID:
  29525. m.ClearOrganizationID()
  29526. return nil
  29527. }
  29528. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29529. }
  29530. // ResetField resets all changes in the mutation for the field with the given name.
  29531. // It returns an error if the field is not defined in the schema.
  29532. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29533. switch name {
  29534. case usagestatisticday.FieldCreatedAt:
  29535. m.ResetCreatedAt()
  29536. return nil
  29537. case usagestatisticday.FieldUpdatedAt:
  29538. m.ResetUpdatedAt()
  29539. return nil
  29540. case usagestatisticday.FieldStatus:
  29541. m.ResetStatus()
  29542. return nil
  29543. case usagestatisticday.FieldDeletedAt:
  29544. m.ResetDeletedAt()
  29545. return nil
  29546. case usagestatisticday.FieldAddtime:
  29547. m.ResetAddtime()
  29548. return nil
  29549. case usagestatisticday.FieldType:
  29550. m.ResetType()
  29551. return nil
  29552. case usagestatisticday.FieldBotID:
  29553. m.ResetBotID()
  29554. return nil
  29555. case usagestatisticday.FieldOrganizationID:
  29556. m.ResetOrganizationID()
  29557. return nil
  29558. case usagestatisticday.FieldAiResponse:
  29559. m.ResetAiResponse()
  29560. return nil
  29561. case usagestatisticday.FieldSopRun:
  29562. m.ResetSopRun()
  29563. return nil
  29564. case usagestatisticday.FieldTotalFriend:
  29565. m.ResetTotalFriend()
  29566. return nil
  29567. case usagestatisticday.FieldTotalGroup:
  29568. m.ResetTotalGroup()
  29569. return nil
  29570. case usagestatisticday.FieldAccountBalance:
  29571. m.ResetAccountBalance()
  29572. return nil
  29573. case usagestatisticday.FieldConsumeToken:
  29574. m.ResetConsumeToken()
  29575. return nil
  29576. case usagestatisticday.FieldActiveUser:
  29577. m.ResetActiveUser()
  29578. return nil
  29579. case usagestatisticday.FieldNewUser:
  29580. m.ResetNewUser()
  29581. return nil
  29582. case usagestatisticday.FieldLabelDist:
  29583. m.ResetLabelDist()
  29584. return nil
  29585. }
  29586. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29587. }
  29588. // AddedEdges returns all edge names that were set/added in this mutation.
  29589. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29590. edges := make([]string, 0, 0)
  29591. return edges
  29592. }
  29593. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29594. // name in this mutation.
  29595. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29596. return nil
  29597. }
  29598. // RemovedEdges returns all edge names that were removed in this mutation.
  29599. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29600. edges := make([]string, 0, 0)
  29601. return edges
  29602. }
  29603. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29604. // the given name in this mutation.
  29605. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29606. return nil
  29607. }
  29608. // ClearedEdges returns all edge names that were cleared in this mutation.
  29609. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29610. edges := make([]string, 0, 0)
  29611. return edges
  29612. }
  29613. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29614. // was cleared in this mutation.
  29615. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29616. return false
  29617. }
  29618. // ClearEdge clears the value of the edge with the given name. It returns an error
  29619. // if that edge is not defined in the schema.
  29620. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29621. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29622. }
  29623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29624. // It returns an error if the edge is not defined in the schema.
  29625. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29626. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29627. }
  29628. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29629. type UsageStatisticHourMutation struct {
  29630. config
  29631. op Op
  29632. typ string
  29633. id *uint64
  29634. created_at *time.Time
  29635. updated_at *time.Time
  29636. status *uint8
  29637. addstatus *int8
  29638. deleted_at *time.Time
  29639. addtime *uint64
  29640. addaddtime *int64
  29641. _type *int
  29642. add_type *int
  29643. bot_id *string
  29644. organization_id *uint64
  29645. addorganization_id *int64
  29646. ai_response *uint64
  29647. addai_response *int64
  29648. sop_run *uint64
  29649. addsop_run *int64
  29650. total_friend *uint64
  29651. addtotal_friend *int64
  29652. total_group *uint64
  29653. addtotal_group *int64
  29654. account_balance *uint64
  29655. addaccount_balance *int64
  29656. consume_token *uint64
  29657. addconsume_token *int64
  29658. active_user *uint64
  29659. addactive_user *int64
  29660. new_user *int64
  29661. addnew_user *int64
  29662. label_dist *[]custom_types.LabelDist
  29663. appendlabel_dist []custom_types.LabelDist
  29664. clearedFields map[string]struct{}
  29665. done bool
  29666. oldValue func(context.Context) (*UsageStatisticHour, error)
  29667. predicates []predicate.UsageStatisticHour
  29668. }
  29669. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29670. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29671. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29672. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29673. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29674. m := &UsageStatisticHourMutation{
  29675. config: c,
  29676. op: op,
  29677. typ: TypeUsageStatisticHour,
  29678. clearedFields: make(map[string]struct{}),
  29679. }
  29680. for _, opt := range opts {
  29681. opt(m)
  29682. }
  29683. return m
  29684. }
  29685. // withUsageStatisticHourID sets the ID field of the mutation.
  29686. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29687. return func(m *UsageStatisticHourMutation) {
  29688. var (
  29689. err error
  29690. once sync.Once
  29691. value *UsageStatisticHour
  29692. )
  29693. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29694. once.Do(func() {
  29695. if m.done {
  29696. err = errors.New("querying old values post mutation is not allowed")
  29697. } else {
  29698. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29699. }
  29700. })
  29701. return value, err
  29702. }
  29703. m.id = &id
  29704. }
  29705. }
  29706. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29707. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29708. return func(m *UsageStatisticHourMutation) {
  29709. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29710. return node, nil
  29711. }
  29712. m.id = &node.ID
  29713. }
  29714. }
  29715. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29716. // executed in a transaction (ent.Tx), a transactional client is returned.
  29717. func (m UsageStatisticHourMutation) Client() *Client {
  29718. client := &Client{config: m.config}
  29719. client.init()
  29720. return client
  29721. }
  29722. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29723. // it returns an error otherwise.
  29724. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29725. if _, ok := m.driver.(*txDriver); !ok {
  29726. return nil, errors.New("ent: mutation is not running in a transaction")
  29727. }
  29728. tx := &Tx{config: m.config}
  29729. tx.init()
  29730. return tx, nil
  29731. }
  29732. // SetID sets the value of the id field. Note that this
  29733. // operation is only accepted on creation of UsageStatisticHour entities.
  29734. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29735. m.id = &id
  29736. }
  29737. // ID returns the ID value in the mutation. Note that the ID is only available
  29738. // if it was provided to the builder or after it was returned from the database.
  29739. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29740. if m.id == nil {
  29741. return
  29742. }
  29743. return *m.id, true
  29744. }
  29745. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29746. // That means, if the mutation is applied within a transaction with an isolation level such
  29747. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29748. // or updated by the mutation.
  29749. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29750. switch {
  29751. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29752. id, exists := m.ID()
  29753. if exists {
  29754. return []uint64{id}, nil
  29755. }
  29756. fallthrough
  29757. case m.op.Is(OpUpdate | OpDelete):
  29758. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29759. default:
  29760. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29761. }
  29762. }
  29763. // SetCreatedAt sets the "created_at" field.
  29764. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29765. m.created_at = &t
  29766. }
  29767. // CreatedAt returns the value of the "created_at" field in the mutation.
  29768. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29769. v := m.created_at
  29770. if v == nil {
  29771. return
  29772. }
  29773. return *v, true
  29774. }
  29775. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29776. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29778. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29779. if !m.op.Is(OpUpdateOne) {
  29780. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29781. }
  29782. if m.id == nil || m.oldValue == nil {
  29783. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29784. }
  29785. oldValue, err := m.oldValue(ctx)
  29786. if err != nil {
  29787. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29788. }
  29789. return oldValue.CreatedAt, nil
  29790. }
  29791. // ResetCreatedAt resets all changes to the "created_at" field.
  29792. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29793. m.created_at = nil
  29794. }
  29795. // SetUpdatedAt sets the "updated_at" field.
  29796. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29797. m.updated_at = &t
  29798. }
  29799. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29800. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29801. v := m.updated_at
  29802. if v == nil {
  29803. return
  29804. }
  29805. return *v, true
  29806. }
  29807. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29808. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29810. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29811. if !m.op.Is(OpUpdateOne) {
  29812. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29813. }
  29814. if m.id == nil || m.oldValue == nil {
  29815. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29816. }
  29817. oldValue, err := m.oldValue(ctx)
  29818. if err != nil {
  29819. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29820. }
  29821. return oldValue.UpdatedAt, nil
  29822. }
  29823. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29824. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29825. m.updated_at = nil
  29826. }
  29827. // SetStatus sets the "status" field.
  29828. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29829. m.status = &u
  29830. m.addstatus = nil
  29831. }
  29832. // Status returns the value of the "status" field in the mutation.
  29833. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29834. v := m.status
  29835. if v == nil {
  29836. return
  29837. }
  29838. return *v, true
  29839. }
  29840. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29841. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29843. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29844. if !m.op.Is(OpUpdateOne) {
  29845. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29846. }
  29847. if m.id == nil || m.oldValue == nil {
  29848. return v, errors.New("OldStatus requires an ID field in the mutation")
  29849. }
  29850. oldValue, err := m.oldValue(ctx)
  29851. if err != nil {
  29852. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29853. }
  29854. return oldValue.Status, nil
  29855. }
  29856. // AddStatus adds u to the "status" field.
  29857. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29858. if m.addstatus != nil {
  29859. *m.addstatus += u
  29860. } else {
  29861. m.addstatus = &u
  29862. }
  29863. }
  29864. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29865. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29866. v := m.addstatus
  29867. if v == nil {
  29868. return
  29869. }
  29870. return *v, true
  29871. }
  29872. // ClearStatus clears the value of the "status" field.
  29873. func (m *UsageStatisticHourMutation) ClearStatus() {
  29874. m.status = nil
  29875. m.addstatus = nil
  29876. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29877. }
  29878. // StatusCleared returns if the "status" field was cleared in this mutation.
  29879. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29880. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29881. return ok
  29882. }
  29883. // ResetStatus resets all changes to the "status" field.
  29884. func (m *UsageStatisticHourMutation) ResetStatus() {
  29885. m.status = nil
  29886. m.addstatus = nil
  29887. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29888. }
  29889. // SetDeletedAt sets the "deleted_at" field.
  29890. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29891. m.deleted_at = &t
  29892. }
  29893. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29894. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29895. v := m.deleted_at
  29896. if v == nil {
  29897. return
  29898. }
  29899. return *v, true
  29900. }
  29901. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29902. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29904. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29905. if !m.op.Is(OpUpdateOne) {
  29906. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29907. }
  29908. if m.id == nil || m.oldValue == nil {
  29909. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29910. }
  29911. oldValue, err := m.oldValue(ctx)
  29912. if err != nil {
  29913. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29914. }
  29915. return oldValue.DeletedAt, nil
  29916. }
  29917. // ClearDeletedAt clears the value of the "deleted_at" field.
  29918. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29919. m.deleted_at = nil
  29920. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29921. }
  29922. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29923. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29924. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29925. return ok
  29926. }
  29927. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29928. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29929. m.deleted_at = nil
  29930. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29931. }
  29932. // SetAddtime sets the "addtime" field.
  29933. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29934. m.addtime = &u
  29935. m.addaddtime = nil
  29936. }
  29937. // Addtime returns the value of the "addtime" field in the mutation.
  29938. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29939. v := m.addtime
  29940. if v == nil {
  29941. return
  29942. }
  29943. return *v, true
  29944. }
  29945. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29946. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29948. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29949. if !m.op.Is(OpUpdateOne) {
  29950. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29951. }
  29952. if m.id == nil || m.oldValue == nil {
  29953. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29954. }
  29955. oldValue, err := m.oldValue(ctx)
  29956. if err != nil {
  29957. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29958. }
  29959. return oldValue.Addtime, nil
  29960. }
  29961. // AddAddtime adds u to the "addtime" field.
  29962. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29963. if m.addaddtime != nil {
  29964. *m.addaddtime += u
  29965. } else {
  29966. m.addaddtime = &u
  29967. }
  29968. }
  29969. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29970. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29971. v := m.addaddtime
  29972. if v == nil {
  29973. return
  29974. }
  29975. return *v, true
  29976. }
  29977. // ResetAddtime resets all changes to the "addtime" field.
  29978. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29979. m.addtime = nil
  29980. m.addaddtime = nil
  29981. }
  29982. // SetType sets the "type" field.
  29983. func (m *UsageStatisticHourMutation) SetType(i int) {
  29984. m._type = &i
  29985. m.add_type = nil
  29986. }
  29987. // GetType returns the value of the "type" field in the mutation.
  29988. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29989. v := m._type
  29990. if v == nil {
  29991. return
  29992. }
  29993. return *v, true
  29994. }
  29995. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29996. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29998. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29999. if !m.op.Is(OpUpdateOne) {
  30000. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30001. }
  30002. if m.id == nil || m.oldValue == nil {
  30003. return v, errors.New("OldType requires an ID field in the mutation")
  30004. }
  30005. oldValue, err := m.oldValue(ctx)
  30006. if err != nil {
  30007. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30008. }
  30009. return oldValue.Type, nil
  30010. }
  30011. // AddType adds i to the "type" field.
  30012. func (m *UsageStatisticHourMutation) AddType(i int) {
  30013. if m.add_type != nil {
  30014. *m.add_type += i
  30015. } else {
  30016. m.add_type = &i
  30017. }
  30018. }
  30019. // AddedType returns the value that was added to the "type" field in this mutation.
  30020. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30021. v := m.add_type
  30022. if v == nil {
  30023. return
  30024. }
  30025. return *v, true
  30026. }
  30027. // ResetType resets all changes to the "type" field.
  30028. func (m *UsageStatisticHourMutation) ResetType() {
  30029. m._type = nil
  30030. m.add_type = nil
  30031. }
  30032. // SetBotID sets the "bot_id" field.
  30033. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30034. m.bot_id = &s
  30035. }
  30036. // BotID returns the value of the "bot_id" field in the mutation.
  30037. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30038. v := m.bot_id
  30039. if v == nil {
  30040. return
  30041. }
  30042. return *v, true
  30043. }
  30044. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30045. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30047. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30048. if !m.op.Is(OpUpdateOne) {
  30049. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30050. }
  30051. if m.id == nil || m.oldValue == nil {
  30052. return v, errors.New("OldBotID requires an ID field in the mutation")
  30053. }
  30054. oldValue, err := m.oldValue(ctx)
  30055. if err != nil {
  30056. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30057. }
  30058. return oldValue.BotID, nil
  30059. }
  30060. // ClearBotID clears the value of the "bot_id" field.
  30061. func (m *UsageStatisticHourMutation) ClearBotID() {
  30062. m.bot_id = nil
  30063. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30064. }
  30065. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30066. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30067. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30068. return ok
  30069. }
  30070. // ResetBotID resets all changes to the "bot_id" field.
  30071. func (m *UsageStatisticHourMutation) ResetBotID() {
  30072. m.bot_id = nil
  30073. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30074. }
  30075. // SetOrganizationID sets the "organization_id" field.
  30076. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30077. m.organization_id = &u
  30078. m.addorganization_id = nil
  30079. }
  30080. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30081. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30082. v := m.organization_id
  30083. if v == nil {
  30084. return
  30085. }
  30086. return *v, true
  30087. }
  30088. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30089. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30091. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30092. if !m.op.Is(OpUpdateOne) {
  30093. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30094. }
  30095. if m.id == nil || m.oldValue == nil {
  30096. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30097. }
  30098. oldValue, err := m.oldValue(ctx)
  30099. if err != nil {
  30100. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30101. }
  30102. return oldValue.OrganizationID, nil
  30103. }
  30104. // AddOrganizationID adds u to the "organization_id" field.
  30105. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30106. if m.addorganization_id != nil {
  30107. *m.addorganization_id += u
  30108. } else {
  30109. m.addorganization_id = &u
  30110. }
  30111. }
  30112. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30113. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30114. v := m.addorganization_id
  30115. if v == nil {
  30116. return
  30117. }
  30118. return *v, true
  30119. }
  30120. // ClearOrganizationID clears the value of the "organization_id" field.
  30121. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30122. m.organization_id = nil
  30123. m.addorganization_id = nil
  30124. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30125. }
  30126. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30127. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30128. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30129. return ok
  30130. }
  30131. // ResetOrganizationID resets all changes to the "organization_id" field.
  30132. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30133. m.organization_id = nil
  30134. m.addorganization_id = nil
  30135. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30136. }
  30137. // SetAiResponse sets the "ai_response" field.
  30138. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30139. m.ai_response = &u
  30140. m.addai_response = nil
  30141. }
  30142. // AiResponse returns the value of the "ai_response" field in the mutation.
  30143. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30144. v := m.ai_response
  30145. if v == nil {
  30146. return
  30147. }
  30148. return *v, true
  30149. }
  30150. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30151. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30153. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30154. if !m.op.Is(OpUpdateOne) {
  30155. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30156. }
  30157. if m.id == nil || m.oldValue == nil {
  30158. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30159. }
  30160. oldValue, err := m.oldValue(ctx)
  30161. if err != nil {
  30162. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30163. }
  30164. return oldValue.AiResponse, nil
  30165. }
  30166. // AddAiResponse adds u to the "ai_response" field.
  30167. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30168. if m.addai_response != nil {
  30169. *m.addai_response += u
  30170. } else {
  30171. m.addai_response = &u
  30172. }
  30173. }
  30174. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30175. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30176. v := m.addai_response
  30177. if v == nil {
  30178. return
  30179. }
  30180. return *v, true
  30181. }
  30182. // ResetAiResponse resets all changes to the "ai_response" field.
  30183. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30184. m.ai_response = nil
  30185. m.addai_response = nil
  30186. }
  30187. // SetSopRun sets the "sop_run" field.
  30188. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30189. m.sop_run = &u
  30190. m.addsop_run = nil
  30191. }
  30192. // SopRun returns the value of the "sop_run" field in the mutation.
  30193. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30194. v := m.sop_run
  30195. if v == nil {
  30196. return
  30197. }
  30198. return *v, true
  30199. }
  30200. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30201. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30203. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30204. if !m.op.Is(OpUpdateOne) {
  30205. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30206. }
  30207. if m.id == nil || m.oldValue == nil {
  30208. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30209. }
  30210. oldValue, err := m.oldValue(ctx)
  30211. if err != nil {
  30212. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30213. }
  30214. return oldValue.SopRun, nil
  30215. }
  30216. // AddSopRun adds u to the "sop_run" field.
  30217. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30218. if m.addsop_run != nil {
  30219. *m.addsop_run += u
  30220. } else {
  30221. m.addsop_run = &u
  30222. }
  30223. }
  30224. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30225. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30226. v := m.addsop_run
  30227. if v == nil {
  30228. return
  30229. }
  30230. return *v, true
  30231. }
  30232. // ResetSopRun resets all changes to the "sop_run" field.
  30233. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30234. m.sop_run = nil
  30235. m.addsop_run = nil
  30236. }
  30237. // SetTotalFriend sets the "total_friend" field.
  30238. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30239. m.total_friend = &u
  30240. m.addtotal_friend = nil
  30241. }
  30242. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30243. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30244. v := m.total_friend
  30245. if v == nil {
  30246. return
  30247. }
  30248. return *v, true
  30249. }
  30250. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30251. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30253. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30254. if !m.op.Is(OpUpdateOne) {
  30255. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30256. }
  30257. if m.id == nil || m.oldValue == nil {
  30258. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30259. }
  30260. oldValue, err := m.oldValue(ctx)
  30261. if err != nil {
  30262. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30263. }
  30264. return oldValue.TotalFriend, nil
  30265. }
  30266. // AddTotalFriend adds u to the "total_friend" field.
  30267. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30268. if m.addtotal_friend != nil {
  30269. *m.addtotal_friend += u
  30270. } else {
  30271. m.addtotal_friend = &u
  30272. }
  30273. }
  30274. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30275. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30276. v := m.addtotal_friend
  30277. if v == nil {
  30278. return
  30279. }
  30280. return *v, true
  30281. }
  30282. // ResetTotalFriend resets all changes to the "total_friend" field.
  30283. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30284. m.total_friend = nil
  30285. m.addtotal_friend = nil
  30286. }
  30287. // SetTotalGroup sets the "total_group" field.
  30288. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30289. m.total_group = &u
  30290. m.addtotal_group = nil
  30291. }
  30292. // TotalGroup returns the value of the "total_group" field in the mutation.
  30293. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30294. v := m.total_group
  30295. if v == nil {
  30296. return
  30297. }
  30298. return *v, true
  30299. }
  30300. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30301. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30303. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30304. if !m.op.Is(OpUpdateOne) {
  30305. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30306. }
  30307. if m.id == nil || m.oldValue == nil {
  30308. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30309. }
  30310. oldValue, err := m.oldValue(ctx)
  30311. if err != nil {
  30312. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30313. }
  30314. return oldValue.TotalGroup, nil
  30315. }
  30316. // AddTotalGroup adds u to the "total_group" field.
  30317. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30318. if m.addtotal_group != nil {
  30319. *m.addtotal_group += u
  30320. } else {
  30321. m.addtotal_group = &u
  30322. }
  30323. }
  30324. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30325. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30326. v := m.addtotal_group
  30327. if v == nil {
  30328. return
  30329. }
  30330. return *v, true
  30331. }
  30332. // ResetTotalGroup resets all changes to the "total_group" field.
  30333. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30334. m.total_group = nil
  30335. m.addtotal_group = nil
  30336. }
  30337. // SetAccountBalance sets the "account_balance" field.
  30338. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30339. m.account_balance = &u
  30340. m.addaccount_balance = nil
  30341. }
  30342. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30343. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30344. v := m.account_balance
  30345. if v == nil {
  30346. return
  30347. }
  30348. return *v, true
  30349. }
  30350. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30351. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30353. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30354. if !m.op.Is(OpUpdateOne) {
  30355. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30356. }
  30357. if m.id == nil || m.oldValue == nil {
  30358. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30359. }
  30360. oldValue, err := m.oldValue(ctx)
  30361. if err != nil {
  30362. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30363. }
  30364. return oldValue.AccountBalance, nil
  30365. }
  30366. // AddAccountBalance adds u to the "account_balance" field.
  30367. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30368. if m.addaccount_balance != nil {
  30369. *m.addaccount_balance += u
  30370. } else {
  30371. m.addaccount_balance = &u
  30372. }
  30373. }
  30374. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30375. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30376. v := m.addaccount_balance
  30377. if v == nil {
  30378. return
  30379. }
  30380. return *v, true
  30381. }
  30382. // ResetAccountBalance resets all changes to the "account_balance" field.
  30383. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30384. m.account_balance = nil
  30385. m.addaccount_balance = nil
  30386. }
  30387. // SetConsumeToken sets the "consume_token" field.
  30388. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30389. m.consume_token = &u
  30390. m.addconsume_token = nil
  30391. }
  30392. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30393. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30394. v := m.consume_token
  30395. if v == nil {
  30396. return
  30397. }
  30398. return *v, true
  30399. }
  30400. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30401. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30403. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30404. if !m.op.Is(OpUpdateOne) {
  30405. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30406. }
  30407. if m.id == nil || m.oldValue == nil {
  30408. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30409. }
  30410. oldValue, err := m.oldValue(ctx)
  30411. if err != nil {
  30412. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30413. }
  30414. return oldValue.ConsumeToken, nil
  30415. }
  30416. // AddConsumeToken adds u to the "consume_token" field.
  30417. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30418. if m.addconsume_token != nil {
  30419. *m.addconsume_token += u
  30420. } else {
  30421. m.addconsume_token = &u
  30422. }
  30423. }
  30424. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30425. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30426. v := m.addconsume_token
  30427. if v == nil {
  30428. return
  30429. }
  30430. return *v, true
  30431. }
  30432. // ResetConsumeToken resets all changes to the "consume_token" field.
  30433. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30434. m.consume_token = nil
  30435. m.addconsume_token = nil
  30436. }
  30437. // SetActiveUser sets the "active_user" field.
  30438. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30439. m.active_user = &u
  30440. m.addactive_user = nil
  30441. }
  30442. // ActiveUser returns the value of the "active_user" field in the mutation.
  30443. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30444. v := m.active_user
  30445. if v == nil {
  30446. return
  30447. }
  30448. return *v, true
  30449. }
  30450. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30451. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30453. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30454. if !m.op.Is(OpUpdateOne) {
  30455. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30456. }
  30457. if m.id == nil || m.oldValue == nil {
  30458. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30459. }
  30460. oldValue, err := m.oldValue(ctx)
  30461. if err != nil {
  30462. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30463. }
  30464. return oldValue.ActiveUser, nil
  30465. }
  30466. // AddActiveUser adds u to the "active_user" field.
  30467. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30468. if m.addactive_user != nil {
  30469. *m.addactive_user += u
  30470. } else {
  30471. m.addactive_user = &u
  30472. }
  30473. }
  30474. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30475. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30476. v := m.addactive_user
  30477. if v == nil {
  30478. return
  30479. }
  30480. return *v, true
  30481. }
  30482. // ResetActiveUser resets all changes to the "active_user" field.
  30483. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30484. m.active_user = nil
  30485. m.addactive_user = nil
  30486. }
  30487. // SetNewUser sets the "new_user" field.
  30488. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30489. m.new_user = &i
  30490. m.addnew_user = nil
  30491. }
  30492. // NewUser returns the value of the "new_user" field in the mutation.
  30493. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30494. v := m.new_user
  30495. if v == nil {
  30496. return
  30497. }
  30498. return *v, true
  30499. }
  30500. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30501. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30503. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30504. if !m.op.Is(OpUpdateOne) {
  30505. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30506. }
  30507. if m.id == nil || m.oldValue == nil {
  30508. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30509. }
  30510. oldValue, err := m.oldValue(ctx)
  30511. if err != nil {
  30512. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30513. }
  30514. return oldValue.NewUser, nil
  30515. }
  30516. // AddNewUser adds i to the "new_user" field.
  30517. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30518. if m.addnew_user != nil {
  30519. *m.addnew_user += i
  30520. } else {
  30521. m.addnew_user = &i
  30522. }
  30523. }
  30524. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30525. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30526. v := m.addnew_user
  30527. if v == nil {
  30528. return
  30529. }
  30530. return *v, true
  30531. }
  30532. // ResetNewUser resets all changes to the "new_user" field.
  30533. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30534. m.new_user = nil
  30535. m.addnew_user = nil
  30536. }
  30537. // SetLabelDist sets the "label_dist" field.
  30538. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30539. m.label_dist = &ctd
  30540. m.appendlabel_dist = nil
  30541. }
  30542. // LabelDist returns the value of the "label_dist" field in the mutation.
  30543. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30544. v := m.label_dist
  30545. if v == nil {
  30546. return
  30547. }
  30548. return *v, true
  30549. }
  30550. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30551. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30553. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30554. if !m.op.Is(OpUpdateOne) {
  30555. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30556. }
  30557. if m.id == nil || m.oldValue == nil {
  30558. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30559. }
  30560. oldValue, err := m.oldValue(ctx)
  30561. if err != nil {
  30562. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30563. }
  30564. return oldValue.LabelDist, nil
  30565. }
  30566. // AppendLabelDist adds ctd to the "label_dist" field.
  30567. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30568. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30569. }
  30570. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30571. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30572. if len(m.appendlabel_dist) == 0 {
  30573. return nil, false
  30574. }
  30575. return m.appendlabel_dist, true
  30576. }
  30577. // ResetLabelDist resets all changes to the "label_dist" field.
  30578. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30579. m.label_dist = nil
  30580. m.appendlabel_dist = nil
  30581. }
  30582. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30583. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30584. m.predicates = append(m.predicates, ps...)
  30585. }
  30586. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30587. // users can use type-assertion to append predicates that do not depend on any generated package.
  30588. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30589. p := make([]predicate.UsageStatisticHour, len(ps))
  30590. for i := range ps {
  30591. p[i] = ps[i]
  30592. }
  30593. m.Where(p...)
  30594. }
  30595. // Op returns the operation name.
  30596. func (m *UsageStatisticHourMutation) Op() Op {
  30597. return m.op
  30598. }
  30599. // SetOp allows setting the mutation operation.
  30600. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30601. m.op = op
  30602. }
  30603. // Type returns the node type of this mutation (UsageStatisticHour).
  30604. func (m *UsageStatisticHourMutation) Type() string {
  30605. return m.typ
  30606. }
  30607. // Fields returns all fields that were changed during this mutation. Note that in
  30608. // order to get all numeric fields that were incremented/decremented, call
  30609. // AddedFields().
  30610. func (m *UsageStatisticHourMutation) Fields() []string {
  30611. fields := make([]string, 0, 17)
  30612. if m.created_at != nil {
  30613. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30614. }
  30615. if m.updated_at != nil {
  30616. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30617. }
  30618. if m.status != nil {
  30619. fields = append(fields, usagestatistichour.FieldStatus)
  30620. }
  30621. if m.deleted_at != nil {
  30622. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30623. }
  30624. if m.addtime != nil {
  30625. fields = append(fields, usagestatistichour.FieldAddtime)
  30626. }
  30627. if m._type != nil {
  30628. fields = append(fields, usagestatistichour.FieldType)
  30629. }
  30630. if m.bot_id != nil {
  30631. fields = append(fields, usagestatistichour.FieldBotID)
  30632. }
  30633. if m.organization_id != nil {
  30634. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30635. }
  30636. if m.ai_response != nil {
  30637. fields = append(fields, usagestatistichour.FieldAiResponse)
  30638. }
  30639. if m.sop_run != nil {
  30640. fields = append(fields, usagestatistichour.FieldSopRun)
  30641. }
  30642. if m.total_friend != nil {
  30643. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30644. }
  30645. if m.total_group != nil {
  30646. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30647. }
  30648. if m.account_balance != nil {
  30649. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30650. }
  30651. if m.consume_token != nil {
  30652. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30653. }
  30654. if m.active_user != nil {
  30655. fields = append(fields, usagestatistichour.FieldActiveUser)
  30656. }
  30657. if m.new_user != nil {
  30658. fields = append(fields, usagestatistichour.FieldNewUser)
  30659. }
  30660. if m.label_dist != nil {
  30661. fields = append(fields, usagestatistichour.FieldLabelDist)
  30662. }
  30663. return fields
  30664. }
  30665. // Field returns the value of a field with the given name. The second boolean
  30666. // return value indicates that this field was not set, or was not defined in the
  30667. // schema.
  30668. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30669. switch name {
  30670. case usagestatistichour.FieldCreatedAt:
  30671. return m.CreatedAt()
  30672. case usagestatistichour.FieldUpdatedAt:
  30673. return m.UpdatedAt()
  30674. case usagestatistichour.FieldStatus:
  30675. return m.Status()
  30676. case usagestatistichour.FieldDeletedAt:
  30677. return m.DeletedAt()
  30678. case usagestatistichour.FieldAddtime:
  30679. return m.Addtime()
  30680. case usagestatistichour.FieldType:
  30681. return m.GetType()
  30682. case usagestatistichour.FieldBotID:
  30683. return m.BotID()
  30684. case usagestatistichour.FieldOrganizationID:
  30685. return m.OrganizationID()
  30686. case usagestatistichour.FieldAiResponse:
  30687. return m.AiResponse()
  30688. case usagestatistichour.FieldSopRun:
  30689. return m.SopRun()
  30690. case usagestatistichour.FieldTotalFriend:
  30691. return m.TotalFriend()
  30692. case usagestatistichour.FieldTotalGroup:
  30693. return m.TotalGroup()
  30694. case usagestatistichour.FieldAccountBalance:
  30695. return m.AccountBalance()
  30696. case usagestatistichour.FieldConsumeToken:
  30697. return m.ConsumeToken()
  30698. case usagestatistichour.FieldActiveUser:
  30699. return m.ActiveUser()
  30700. case usagestatistichour.FieldNewUser:
  30701. return m.NewUser()
  30702. case usagestatistichour.FieldLabelDist:
  30703. return m.LabelDist()
  30704. }
  30705. return nil, false
  30706. }
  30707. // OldField returns the old value of the field from the database. An error is
  30708. // returned if the mutation operation is not UpdateOne, or the query to the
  30709. // database failed.
  30710. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30711. switch name {
  30712. case usagestatistichour.FieldCreatedAt:
  30713. return m.OldCreatedAt(ctx)
  30714. case usagestatistichour.FieldUpdatedAt:
  30715. return m.OldUpdatedAt(ctx)
  30716. case usagestatistichour.FieldStatus:
  30717. return m.OldStatus(ctx)
  30718. case usagestatistichour.FieldDeletedAt:
  30719. return m.OldDeletedAt(ctx)
  30720. case usagestatistichour.FieldAddtime:
  30721. return m.OldAddtime(ctx)
  30722. case usagestatistichour.FieldType:
  30723. return m.OldType(ctx)
  30724. case usagestatistichour.FieldBotID:
  30725. return m.OldBotID(ctx)
  30726. case usagestatistichour.FieldOrganizationID:
  30727. return m.OldOrganizationID(ctx)
  30728. case usagestatistichour.FieldAiResponse:
  30729. return m.OldAiResponse(ctx)
  30730. case usagestatistichour.FieldSopRun:
  30731. return m.OldSopRun(ctx)
  30732. case usagestatistichour.FieldTotalFriend:
  30733. return m.OldTotalFriend(ctx)
  30734. case usagestatistichour.FieldTotalGroup:
  30735. return m.OldTotalGroup(ctx)
  30736. case usagestatistichour.FieldAccountBalance:
  30737. return m.OldAccountBalance(ctx)
  30738. case usagestatistichour.FieldConsumeToken:
  30739. return m.OldConsumeToken(ctx)
  30740. case usagestatistichour.FieldActiveUser:
  30741. return m.OldActiveUser(ctx)
  30742. case usagestatistichour.FieldNewUser:
  30743. return m.OldNewUser(ctx)
  30744. case usagestatistichour.FieldLabelDist:
  30745. return m.OldLabelDist(ctx)
  30746. }
  30747. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30748. }
  30749. // SetField sets the value of a field with the given name. It returns an error if
  30750. // the field is not defined in the schema, or if the type mismatched the field
  30751. // type.
  30752. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30753. switch name {
  30754. case usagestatistichour.FieldCreatedAt:
  30755. v, ok := value.(time.Time)
  30756. if !ok {
  30757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30758. }
  30759. m.SetCreatedAt(v)
  30760. return nil
  30761. case usagestatistichour.FieldUpdatedAt:
  30762. v, ok := value.(time.Time)
  30763. if !ok {
  30764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30765. }
  30766. m.SetUpdatedAt(v)
  30767. return nil
  30768. case usagestatistichour.FieldStatus:
  30769. v, ok := value.(uint8)
  30770. if !ok {
  30771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30772. }
  30773. m.SetStatus(v)
  30774. return nil
  30775. case usagestatistichour.FieldDeletedAt:
  30776. v, ok := value.(time.Time)
  30777. if !ok {
  30778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30779. }
  30780. m.SetDeletedAt(v)
  30781. return nil
  30782. case usagestatistichour.FieldAddtime:
  30783. v, ok := value.(uint64)
  30784. if !ok {
  30785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30786. }
  30787. m.SetAddtime(v)
  30788. return nil
  30789. case usagestatistichour.FieldType:
  30790. v, ok := value.(int)
  30791. if !ok {
  30792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30793. }
  30794. m.SetType(v)
  30795. return nil
  30796. case usagestatistichour.FieldBotID:
  30797. v, ok := value.(string)
  30798. if !ok {
  30799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30800. }
  30801. m.SetBotID(v)
  30802. return nil
  30803. case usagestatistichour.FieldOrganizationID:
  30804. v, ok := value.(uint64)
  30805. if !ok {
  30806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30807. }
  30808. m.SetOrganizationID(v)
  30809. return nil
  30810. case usagestatistichour.FieldAiResponse:
  30811. v, ok := value.(uint64)
  30812. if !ok {
  30813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30814. }
  30815. m.SetAiResponse(v)
  30816. return nil
  30817. case usagestatistichour.FieldSopRun:
  30818. v, ok := value.(uint64)
  30819. if !ok {
  30820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30821. }
  30822. m.SetSopRun(v)
  30823. return nil
  30824. case usagestatistichour.FieldTotalFriend:
  30825. v, ok := value.(uint64)
  30826. if !ok {
  30827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30828. }
  30829. m.SetTotalFriend(v)
  30830. return nil
  30831. case usagestatistichour.FieldTotalGroup:
  30832. v, ok := value.(uint64)
  30833. if !ok {
  30834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30835. }
  30836. m.SetTotalGroup(v)
  30837. return nil
  30838. case usagestatistichour.FieldAccountBalance:
  30839. v, ok := value.(uint64)
  30840. if !ok {
  30841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30842. }
  30843. m.SetAccountBalance(v)
  30844. return nil
  30845. case usagestatistichour.FieldConsumeToken:
  30846. v, ok := value.(uint64)
  30847. if !ok {
  30848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30849. }
  30850. m.SetConsumeToken(v)
  30851. return nil
  30852. case usagestatistichour.FieldActiveUser:
  30853. v, ok := value.(uint64)
  30854. if !ok {
  30855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30856. }
  30857. m.SetActiveUser(v)
  30858. return nil
  30859. case usagestatistichour.FieldNewUser:
  30860. v, ok := value.(int64)
  30861. if !ok {
  30862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30863. }
  30864. m.SetNewUser(v)
  30865. return nil
  30866. case usagestatistichour.FieldLabelDist:
  30867. v, ok := value.([]custom_types.LabelDist)
  30868. if !ok {
  30869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30870. }
  30871. m.SetLabelDist(v)
  30872. return nil
  30873. }
  30874. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30875. }
  30876. // AddedFields returns all numeric fields that were incremented/decremented during
  30877. // this mutation.
  30878. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30879. var fields []string
  30880. if m.addstatus != nil {
  30881. fields = append(fields, usagestatistichour.FieldStatus)
  30882. }
  30883. if m.addaddtime != nil {
  30884. fields = append(fields, usagestatistichour.FieldAddtime)
  30885. }
  30886. if m.add_type != nil {
  30887. fields = append(fields, usagestatistichour.FieldType)
  30888. }
  30889. if m.addorganization_id != nil {
  30890. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30891. }
  30892. if m.addai_response != nil {
  30893. fields = append(fields, usagestatistichour.FieldAiResponse)
  30894. }
  30895. if m.addsop_run != nil {
  30896. fields = append(fields, usagestatistichour.FieldSopRun)
  30897. }
  30898. if m.addtotal_friend != nil {
  30899. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30900. }
  30901. if m.addtotal_group != nil {
  30902. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30903. }
  30904. if m.addaccount_balance != nil {
  30905. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30906. }
  30907. if m.addconsume_token != nil {
  30908. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30909. }
  30910. if m.addactive_user != nil {
  30911. fields = append(fields, usagestatistichour.FieldActiveUser)
  30912. }
  30913. if m.addnew_user != nil {
  30914. fields = append(fields, usagestatistichour.FieldNewUser)
  30915. }
  30916. return fields
  30917. }
  30918. // AddedField returns the numeric value that was incremented/decremented on a field
  30919. // with the given name. The second boolean return value indicates that this field
  30920. // was not set, or was not defined in the schema.
  30921. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30922. switch name {
  30923. case usagestatistichour.FieldStatus:
  30924. return m.AddedStatus()
  30925. case usagestatistichour.FieldAddtime:
  30926. return m.AddedAddtime()
  30927. case usagestatistichour.FieldType:
  30928. return m.AddedType()
  30929. case usagestatistichour.FieldOrganizationID:
  30930. return m.AddedOrganizationID()
  30931. case usagestatistichour.FieldAiResponse:
  30932. return m.AddedAiResponse()
  30933. case usagestatistichour.FieldSopRun:
  30934. return m.AddedSopRun()
  30935. case usagestatistichour.FieldTotalFriend:
  30936. return m.AddedTotalFriend()
  30937. case usagestatistichour.FieldTotalGroup:
  30938. return m.AddedTotalGroup()
  30939. case usagestatistichour.FieldAccountBalance:
  30940. return m.AddedAccountBalance()
  30941. case usagestatistichour.FieldConsumeToken:
  30942. return m.AddedConsumeToken()
  30943. case usagestatistichour.FieldActiveUser:
  30944. return m.AddedActiveUser()
  30945. case usagestatistichour.FieldNewUser:
  30946. return m.AddedNewUser()
  30947. }
  30948. return nil, false
  30949. }
  30950. // AddField adds the value to the field with the given name. It returns an error if
  30951. // the field is not defined in the schema, or if the type mismatched the field
  30952. // type.
  30953. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30954. switch name {
  30955. case usagestatistichour.FieldStatus:
  30956. v, ok := value.(int8)
  30957. if !ok {
  30958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30959. }
  30960. m.AddStatus(v)
  30961. return nil
  30962. case usagestatistichour.FieldAddtime:
  30963. v, ok := value.(int64)
  30964. if !ok {
  30965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30966. }
  30967. m.AddAddtime(v)
  30968. return nil
  30969. case usagestatistichour.FieldType:
  30970. v, ok := value.(int)
  30971. if !ok {
  30972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30973. }
  30974. m.AddType(v)
  30975. return nil
  30976. case usagestatistichour.FieldOrganizationID:
  30977. v, ok := value.(int64)
  30978. if !ok {
  30979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30980. }
  30981. m.AddOrganizationID(v)
  30982. return nil
  30983. case usagestatistichour.FieldAiResponse:
  30984. v, ok := value.(int64)
  30985. if !ok {
  30986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30987. }
  30988. m.AddAiResponse(v)
  30989. return nil
  30990. case usagestatistichour.FieldSopRun:
  30991. v, ok := value.(int64)
  30992. if !ok {
  30993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30994. }
  30995. m.AddSopRun(v)
  30996. return nil
  30997. case usagestatistichour.FieldTotalFriend:
  30998. v, ok := value.(int64)
  30999. if !ok {
  31000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31001. }
  31002. m.AddTotalFriend(v)
  31003. return nil
  31004. case usagestatistichour.FieldTotalGroup:
  31005. v, ok := value.(int64)
  31006. if !ok {
  31007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31008. }
  31009. m.AddTotalGroup(v)
  31010. return nil
  31011. case usagestatistichour.FieldAccountBalance:
  31012. v, ok := value.(int64)
  31013. if !ok {
  31014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31015. }
  31016. m.AddAccountBalance(v)
  31017. return nil
  31018. case usagestatistichour.FieldConsumeToken:
  31019. v, ok := value.(int64)
  31020. if !ok {
  31021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31022. }
  31023. m.AddConsumeToken(v)
  31024. return nil
  31025. case usagestatistichour.FieldActiveUser:
  31026. v, ok := value.(int64)
  31027. if !ok {
  31028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31029. }
  31030. m.AddActiveUser(v)
  31031. return nil
  31032. case usagestatistichour.FieldNewUser:
  31033. v, ok := value.(int64)
  31034. if !ok {
  31035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31036. }
  31037. m.AddNewUser(v)
  31038. return nil
  31039. }
  31040. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31041. }
  31042. // ClearedFields returns all nullable fields that were cleared during this
  31043. // mutation.
  31044. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31045. var fields []string
  31046. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31047. fields = append(fields, usagestatistichour.FieldStatus)
  31048. }
  31049. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31050. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31051. }
  31052. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31053. fields = append(fields, usagestatistichour.FieldBotID)
  31054. }
  31055. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31056. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31057. }
  31058. return fields
  31059. }
  31060. // FieldCleared returns a boolean indicating if a field with the given name was
  31061. // cleared in this mutation.
  31062. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31063. _, ok := m.clearedFields[name]
  31064. return ok
  31065. }
  31066. // ClearField clears the value of the field with the given name. It returns an
  31067. // error if the field is not defined in the schema.
  31068. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31069. switch name {
  31070. case usagestatistichour.FieldStatus:
  31071. m.ClearStatus()
  31072. return nil
  31073. case usagestatistichour.FieldDeletedAt:
  31074. m.ClearDeletedAt()
  31075. return nil
  31076. case usagestatistichour.FieldBotID:
  31077. m.ClearBotID()
  31078. return nil
  31079. case usagestatistichour.FieldOrganizationID:
  31080. m.ClearOrganizationID()
  31081. return nil
  31082. }
  31083. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31084. }
  31085. // ResetField resets all changes in the mutation for the field with the given name.
  31086. // It returns an error if the field is not defined in the schema.
  31087. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31088. switch name {
  31089. case usagestatistichour.FieldCreatedAt:
  31090. m.ResetCreatedAt()
  31091. return nil
  31092. case usagestatistichour.FieldUpdatedAt:
  31093. m.ResetUpdatedAt()
  31094. return nil
  31095. case usagestatistichour.FieldStatus:
  31096. m.ResetStatus()
  31097. return nil
  31098. case usagestatistichour.FieldDeletedAt:
  31099. m.ResetDeletedAt()
  31100. return nil
  31101. case usagestatistichour.FieldAddtime:
  31102. m.ResetAddtime()
  31103. return nil
  31104. case usagestatistichour.FieldType:
  31105. m.ResetType()
  31106. return nil
  31107. case usagestatistichour.FieldBotID:
  31108. m.ResetBotID()
  31109. return nil
  31110. case usagestatistichour.FieldOrganizationID:
  31111. m.ResetOrganizationID()
  31112. return nil
  31113. case usagestatistichour.FieldAiResponse:
  31114. m.ResetAiResponse()
  31115. return nil
  31116. case usagestatistichour.FieldSopRun:
  31117. m.ResetSopRun()
  31118. return nil
  31119. case usagestatistichour.FieldTotalFriend:
  31120. m.ResetTotalFriend()
  31121. return nil
  31122. case usagestatistichour.FieldTotalGroup:
  31123. m.ResetTotalGroup()
  31124. return nil
  31125. case usagestatistichour.FieldAccountBalance:
  31126. m.ResetAccountBalance()
  31127. return nil
  31128. case usagestatistichour.FieldConsumeToken:
  31129. m.ResetConsumeToken()
  31130. return nil
  31131. case usagestatistichour.FieldActiveUser:
  31132. m.ResetActiveUser()
  31133. return nil
  31134. case usagestatistichour.FieldNewUser:
  31135. m.ResetNewUser()
  31136. return nil
  31137. case usagestatistichour.FieldLabelDist:
  31138. m.ResetLabelDist()
  31139. return nil
  31140. }
  31141. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31142. }
  31143. // AddedEdges returns all edge names that were set/added in this mutation.
  31144. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31145. edges := make([]string, 0, 0)
  31146. return edges
  31147. }
  31148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31149. // name in this mutation.
  31150. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31151. return nil
  31152. }
  31153. // RemovedEdges returns all edge names that were removed in this mutation.
  31154. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31155. edges := make([]string, 0, 0)
  31156. return edges
  31157. }
  31158. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31159. // the given name in this mutation.
  31160. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31161. return nil
  31162. }
  31163. // ClearedEdges returns all edge names that were cleared in this mutation.
  31164. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31165. edges := make([]string, 0, 0)
  31166. return edges
  31167. }
  31168. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31169. // was cleared in this mutation.
  31170. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31171. return false
  31172. }
  31173. // ClearEdge clears the value of the edge with the given name. It returns an error
  31174. // if that edge is not defined in the schema.
  31175. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31176. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31177. }
  31178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31179. // It returns an error if the edge is not defined in the schema.
  31180. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31181. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31182. }
  31183. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31184. type UsageStatisticMonthMutation struct {
  31185. config
  31186. op Op
  31187. typ string
  31188. id *uint64
  31189. created_at *time.Time
  31190. updated_at *time.Time
  31191. status *uint8
  31192. addstatus *int8
  31193. deleted_at *time.Time
  31194. addtime *uint64
  31195. addaddtime *int64
  31196. _type *int
  31197. add_type *int
  31198. bot_id *string
  31199. organization_id *uint64
  31200. addorganization_id *int64
  31201. ai_response *uint64
  31202. addai_response *int64
  31203. sop_run *uint64
  31204. addsop_run *int64
  31205. total_friend *uint64
  31206. addtotal_friend *int64
  31207. total_group *uint64
  31208. addtotal_group *int64
  31209. account_balance *uint64
  31210. addaccount_balance *int64
  31211. consume_token *uint64
  31212. addconsume_token *int64
  31213. active_user *uint64
  31214. addactive_user *int64
  31215. new_user *int64
  31216. addnew_user *int64
  31217. label_dist *[]custom_types.LabelDist
  31218. appendlabel_dist []custom_types.LabelDist
  31219. clearedFields map[string]struct{}
  31220. done bool
  31221. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31222. predicates []predicate.UsageStatisticMonth
  31223. }
  31224. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31225. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31226. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31227. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31228. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31229. m := &UsageStatisticMonthMutation{
  31230. config: c,
  31231. op: op,
  31232. typ: TypeUsageStatisticMonth,
  31233. clearedFields: make(map[string]struct{}),
  31234. }
  31235. for _, opt := range opts {
  31236. opt(m)
  31237. }
  31238. return m
  31239. }
  31240. // withUsageStatisticMonthID sets the ID field of the mutation.
  31241. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31242. return func(m *UsageStatisticMonthMutation) {
  31243. var (
  31244. err error
  31245. once sync.Once
  31246. value *UsageStatisticMonth
  31247. )
  31248. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31249. once.Do(func() {
  31250. if m.done {
  31251. err = errors.New("querying old values post mutation is not allowed")
  31252. } else {
  31253. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31254. }
  31255. })
  31256. return value, err
  31257. }
  31258. m.id = &id
  31259. }
  31260. }
  31261. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31262. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31263. return func(m *UsageStatisticMonthMutation) {
  31264. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31265. return node, nil
  31266. }
  31267. m.id = &node.ID
  31268. }
  31269. }
  31270. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31271. // executed in a transaction (ent.Tx), a transactional client is returned.
  31272. func (m UsageStatisticMonthMutation) Client() *Client {
  31273. client := &Client{config: m.config}
  31274. client.init()
  31275. return client
  31276. }
  31277. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31278. // it returns an error otherwise.
  31279. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31280. if _, ok := m.driver.(*txDriver); !ok {
  31281. return nil, errors.New("ent: mutation is not running in a transaction")
  31282. }
  31283. tx := &Tx{config: m.config}
  31284. tx.init()
  31285. return tx, nil
  31286. }
  31287. // SetID sets the value of the id field. Note that this
  31288. // operation is only accepted on creation of UsageStatisticMonth entities.
  31289. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31290. m.id = &id
  31291. }
  31292. // ID returns the ID value in the mutation. Note that the ID is only available
  31293. // if it was provided to the builder or after it was returned from the database.
  31294. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31295. if m.id == nil {
  31296. return
  31297. }
  31298. return *m.id, true
  31299. }
  31300. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31301. // That means, if the mutation is applied within a transaction with an isolation level such
  31302. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31303. // or updated by the mutation.
  31304. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31305. switch {
  31306. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31307. id, exists := m.ID()
  31308. if exists {
  31309. return []uint64{id}, nil
  31310. }
  31311. fallthrough
  31312. case m.op.Is(OpUpdate | OpDelete):
  31313. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31314. default:
  31315. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31316. }
  31317. }
  31318. // SetCreatedAt sets the "created_at" field.
  31319. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31320. m.created_at = &t
  31321. }
  31322. // CreatedAt returns the value of the "created_at" field in the mutation.
  31323. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31324. v := m.created_at
  31325. if v == nil {
  31326. return
  31327. }
  31328. return *v, true
  31329. }
  31330. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31331. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31333. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31334. if !m.op.Is(OpUpdateOne) {
  31335. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31336. }
  31337. if m.id == nil || m.oldValue == nil {
  31338. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31339. }
  31340. oldValue, err := m.oldValue(ctx)
  31341. if err != nil {
  31342. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31343. }
  31344. return oldValue.CreatedAt, nil
  31345. }
  31346. // ResetCreatedAt resets all changes to the "created_at" field.
  31347. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31348. m.created_at = nil
  31349. }
  31350. // SetUpdatedAt sets the "updated_at" field.
  31351. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31352. m.updated_at = &t
  31353. }
  31354. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31355. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31356. v := m.updated_at
  31357. if v == nil {
  31358. return
  31359. }
  31360. return *v, true
  31361. }
  31362. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31363. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31365. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31366. if !m.op.Is(OpUpdateOne) {
  31367. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31368. }
  31369. if m.id == nil || m.oldValue == nil {
  31370. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31371. }
  31372. oldValue, err := m.oldValue(ctx)
  31373. if err != nil {
  31374. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31375. }
  31376. return oldValue.UpdatedAt, nil
  31377. }
  31378. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31379. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31380. m.updated_at = nil
  31381. }
  31382. // SetStatus sets the "status" field.
  31383. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31384. m.status = &u
  31385. m.addstatus = nil
  31386. }
  31387. // Status returns the value of the "status" field in the mutation.
  31388. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31389. v := m.status
  31390. if v == nil {
  31391. return
  31392. }
  31393. return *v, true
  31394. }
  31395. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31396. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31398. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31399. if !m.op.Is(OpUpdateOne) {
  31400. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31401. }
  31402. if m.id == nil || m.oldValue == nil {
  31403. return v, errors.New("OldStatus requires an ID field in the mutation")
  31404. }
  31405. oldValue, err := m.oldValue(ctx)
  31406. if err != nil {
  31407. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31408. }
  31409. return oldValue.Status, nil
  31410. }
  31411. // AddStatus adds u to the "status" field.
  31412. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31413. if m.addstatus != nil {
  31414. *m.addstatus += u
  31415. } else {
  31416. m.addstatus = &u
  31417. }
  31418. }
  31419. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31420. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31421. v := m.addstatus
  31422. if v == nil {
  31423. return
  31424. }
  31425. return *v, true
  31426. }
  31427. // ClearStatus clears the value of the "status" field.
  31428. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31429. m.status = nil
  31430. m.addstatus = nil
  31431. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31432. }
  31433. // StatusCleared returns if the "status" field was cleared in this mutation.
  31434. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31435. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31436. return ok
  31437. }
  31438. // ResetStatus resets all changes to the "status" field.
  31439. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31440. m.status = nil
  31441. m.addstatus = nil
  31442. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31443. }
  31444. // SetDeletedAt sets the "deleted_at" field.
  31445. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31446. m.deleted_at = &t
  31447. }
  31448. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31449. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31450. v := m.deleted_at
  31451. if v == nil {
  31452. return
  31453. }
  31454. return *v, true
  31455. }
  31456. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31457. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31459. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31460. if !m.op.Is(OpUpdateOne) {
  31461. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31462. }
  31463. if m.id == nil || m.oldValue == nil {
  31464. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31465. }
  31466. oldValue, err := m.oldValue(ctx)
  31467. if err != nil {
  31468. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31469. }
  31470. return oldValue.DeletedAt, nil
  31471. }
  31472. // ClearDeletedAt clears the value of the "deleted_at" field.
  31473. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31474. m.deleted_at = nil
  31475. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31476. }
  31477. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31478. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31479. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31480. return ok
  31481. }
  31482. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31483. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31484. m.deleted_at = nil
  31485. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31486. }
  31487. // SetAddtime sets the "addtime" field.
  31488. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31489. m.addtime = &u
  31490. m.addaddtime = nil
  31491. }
  31492. // Addtime returns the value of the "addtime" field in the mutation.
  31493. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31494. v := m.addtime
  31495. if v == nil {
  31496. return
  31497. }
  31498. return *v, true
  31499. }
  31500. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31501. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31503. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31504. if !m.op.Is(OpUpdateOne) {
  31505. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31506. }
  31507. if m.id == nil || m.oldValue == nil {
  31508. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31509. }
  31510. oldValue, err := m.oldValue(ctx)
  31511. if err != nil {
  31512. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31513. }
  31514. return oldValue.Addtime, nil
  31515. }
  31516. // AddAddtime adds u to the "addtime" field.
  31517. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31518. if m.addaddtime != nil {
  31519. *m.addaddtime += u
  31520. } else {
  31521. m.addaddtime = &u
  31522. }
  31523. }
  31524. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31525. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31526. v := m.addaddtime
  31527. if v == nil {
  31528. return
  31529. }
  31530. return *v, true
  31531. }
  31532. // ResetAddtime resets all changes to the "addtime" field.
  31533. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31534. m.addtime = nil
  31535. m.addaddtime = nil
  31536. }
  31537. // SetType sets the "type" field.
  31538. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31539. m._type = &i
  31540. m.add_type = nil
  31541. }
  31542. // GetType returns the value of the "type" field in the mutation.
  31543. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31544. v := m._type
  31545. if v == nil {
  31546. return
  31547. }
  31548. return *v, true
  31549. }
  31550. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31551. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31553. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31554. if !m.op.Is(OpUpdateOne) {
  31555. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31556. }
  31557. if m.id == nil || m.oldValue == nil {
  31558. return v, errors.New("OldType requires an ID field in the mutation")
  31559. }
  31560. oldValue, err := m.oldValue(ctx)
  31561. if err != nil {
  31562. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31563. }
  31564. return oldValue.Type, nil
  31565. }
  31566. // AddType adds i to the "type" field.
  31567. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31568. if m.add_type != nil {
  31569. *m.add_type += i
  31570. } else {
  31571. m.add_type = &i
  31572. }
  31573. }
  31574. // AddedType returns the value that was added to the "type" field in this mutation.
  31575. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31576. v := m.add_type
  31577. if v == nil {
  31578. return
  31579. }
  31580. return *v, true
  31581. }
  31582. // ResetType resets all changes to the "type" field.
  31583. func (m *UsageStatisticMonthMutation) ResetType() {
  31584. m._type = nil
  31585. m.add_type = nil
  31586. }
  31587. // SetBotID sets the "bot_id" field.
  31588. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31589. m.bot_id = &s
  31590. }
  31591. // BotID returns the value of the "bot_id" field in the mutation.
  31592. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31593. v := m.bot_id
  31594. if v == nil {
  31595. return
  31596. }
  31597. return *v, true
  31598. }
  31599. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31600. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31602. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31603. if !m.op.Is(OpUpdateOne) {
  31604. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31605. }
  31606. if m.id == nil || m.oldValue == nil {
  31607. return v, errors.New("OldBotID requires an ID field in the mutation")
  31608. }
  31609. oldValue, err := m.oldValue(ctx)
  31610. if err != nil {
  31611. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31612. }
  31613. return oldValue.BotID, nil
  31614. }
  31615. // ClearBotID clears the value of the "bot_id" field.
  31616. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31617. m.bot_id = nil
  31618. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31619. }
  31620. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31621. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31622. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31623. return ok
  31624. }
  31625. // ResetBotID resets all changes to the "bot_id" field.
  31626. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31627. m.bot_id = nil
  31628. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31629. }
  31630. // SetOrganizationID sets the "organization_id" field.
  31631. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31632. m.organization_id = &u
  31633. m.addorganization_id = nil
  31634. }
  31635. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31636. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31637. v := m.organization_id
  31638. if v == nil {
  31639. return
  31640. }
  31641. return *v, true
  31642. }
  31643. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31644. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31646. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31647. if !m.op.Is(OpUpdateOne) {
  31648. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31649. }
  31650. if m.id == nil || m.oldValue == nil {
  31651. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31652. }
  31653. oldValue, err := m.oldValue(ctx)
  31654. if err != nil {
  31655. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31656. }
  31657. return oldValue.OrganizationID, nil
  31658. }
  31659. // AddOrganizationID adds u to the "organization_id" field.
  31660. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31661. if m.addorganization_id != nil {
  31662. *m.addorganization_id += u
  31663. } else {
  31664. m.addorganization_id = &u
  31665. }
  31666. }
  31667. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31668. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31669. v := m.addorganization_id
  31670. if v == nil {
  31671. return
  31672. }
  31673. return *v, true
  31674. }
  31675. // ClearOrganizationID clears the value of the "organization_id" field.
  31676. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31677. m.organization_id = nil
  31678. m.addorganization_id = nil
  31679. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31680. }
  31681. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31682. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31683. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31684. return ok
  31685. }
  31686. // ResetOrganizationID resets all changes to the "organization_id" field.
  31687. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31688. m.organization_id = nil
  31689. m.addorganization_id = nil
  31690. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31691. }
  31692. // SetAiResponse sets the "ai_response" field.
  31693. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31694. m.ai_response = &u
  31695. m.addai_response = nil
  31696. }
  31697. // AiResponse returns the value of the "ai_response" field in the mutation.
  31698. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31699. v := m.ai_response
  31700. if v == nil {
  31701. return
  31702. }
  31703. return *v, true
  31704. }
  31705. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31706. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31708. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31709. if !m.op.Is(OpUpdateOne) {
  31710. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31711. }
  31712. if m.id == nil || m.oldValue == nil {
  31713. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31714. }
  31715. oldValue, err := m.oldValue(ctx)
  31716. if err != nil {
  31717. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31718. }
  31719. return oldValue.AiResponse, nil
  31720. }
  31721. // AddAiResponse adds u to the "ai_response" field.
  31722. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31723. if m.addai_response != nil {
  31724. *m.addai_response += u
  31725. } else {
  31726. m.addai_response = &u
  31727. }
  31728. }
  31729. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31730. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31731. v := m.addai_response
  31732. if v == nil {
  31733. return
  31734. }
  31735. return *v, true
  31736. }
  31737. // ResetAiResponse resets all changes to the "ai_response" field.
  31738. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31739. m.ai_response = nil
  31740. m.addai_response = nil
  31741. }
  31742. // SetSopRun sets the "sop_run" field.
  31743. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31744. m.sop_run = &u
  31745. m.addsop_run = nil
  31746. }
  31747. // SopRun returns the value of the "sop_run" field in the mutation.
  31748. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31749. v := m.sop_run
  31750. if v == nil {
  31751. return
  31752. }
  31753. return *v, true
  31754. }
  31755. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31756. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31758. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31759. if !m.op.Is(OpUpdateOne) {
  31760. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31761. }
  31762. if m.id == nil || m.oldValue == nil {
  31763. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31764. }
  31765. oldValue, err := m.oldValue(ctx)
  31766. if err != nil {
  31767. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31768. }
  31769. return oldValue.SopRun, nil
  31770. }
  31771. // AddSopRun adds u to the "sop_run" field.
  31772. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31773. if m.addsop_run != nil {
  31774. *m.addsop_run += u
  31775. } else {
  31776. m.addsop_run = &u
  31777. }
  31778. }
  31779. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31780. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31781. v := m.addsop_run
  31782. if v == nil {
  31783. return
  31784. }
  31785. return *v, true
  31786. }
  31787. // ResetSopRun resets all changes to the "sop_run" field.
  31788. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31789. m.sop_run = nil
  31790. m.addsop_run = nil
  31791. }
  31792. // SetTotalFriend sets the "total_friend" field.
  31793. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31794. m.total_friend = &u
  31795. m.addtotal_friend = nil
  31796. }
  31797. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31798. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31799. v := m.total_friend
  31800. if v == nil {
  31801. return
  31802. }
  31803. return *v, true
  31804. }
  31805. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31806. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31808. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31809. if !m.op.Is(OpUpdateOne) {
  31810. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31811. }
  31812. if m.id == nil || m.oldValue == nil {
  31813. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31814. }
  31815. oldValue, err := m.oldValue(ctx)
  31816. if err != nil {
  31817. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31818. }
  31819. return oldValue.TotalFriend, nil
  31820. }
  31821. // AddTotalFriend adds u to the "total_friend" field.
  31822. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31823. if m.addtotal_friend != nil {
  31824. *m.addtotal_friend += u
  31825. } else {
  31826. m.addtotal_friend = &u
  31827. }
  31828. }
  31829. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31830. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31831. v := m.addtotal_friend
  31832. if v == nil {
  31833. return
  31834. }
  31835. return *v, true
  31836. }
  31837. // ResetTotalFriend resets all changes to the "total_friend" field.
  31838. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31839. m.total_friend = nil
  31840. m.addtotal_friend = nil
  31841. }
  31842. // SetTotalGroup sets the "total_group" field.
  31843. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31844. m.total_group = &u
  31845. m.addtotal_group = nil
  31846. }
  31847. // TotalGroup returns the value of the "total_group" field in the mutation.
  31848. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31849. v := m.total_group
  31850. if v == nil {
  31851. return
  31852. }
  31853. return *v, true
  31854. }
  31855. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31856. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31858. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31859. if !m.op.Is(OpUpdateOne) {
  31860. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31861. }
  31862. if m.id == nil || m.oldValue == nil {
  31863. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31864. }
  31865. oldValue, err := m.oldValue(ctx)
  31866. if err != nil {
  31867. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31868. }
  31869. return oldValue.TotalGroup, nil
  31870. }
  31871. // AddTotalGroup adds u to the "total_group" field.
  31872. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31873. if m.addtotal_group != nil {
  31874. *m.addtotal_group += u
  31875. } else {
  31876. m.addtotal_group = &u
  31877. }
  31878. }
  31879. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31880. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31881. v := m.addtotal_group
  31882. if v == nil {
  31883. return
  31884. }
  31885. return *v, true
  31886. }
  31887. // ResetTotalGroup resets all changes to the "total_group" field.
  31888. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31889. m.total_group = nil
  31890. m.addtotal_group = nil
  31891. }
  31892. // SetAccountBalance sets the "account_balance" field.
  31893. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31894. m.account_balance = &u
  31895. m.addaccount_balance = nil
  31896. }
  31897. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31898. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31899. v := m.account_balance
  31900. if v == nil {
  31901. return
  31902. }
  31903. return *v, true
  31904. }
  31905. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31906. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31908. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31909. if !m.op.Is(OpUpdateOne) {
  31910. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31911. }
  31912. if m.id == nil || m.oldValue == nil {
  31913. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31914. }
  31915. oldValue, err := m.oldValue(ctx)
  31916. if err != nil {
  31917. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31918. }
  31919. return oldValue.AccountBalance, nil
  31920. }
  31921. // AddAccountBalance adds u to the "account_balance" field.
  31922. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31923. if m.addaccount_balance != nil {
  31924. *m.addaccount_balance += u
  31925. } else {
  31926. m.addaccount_balance = &u
  31927. }
  31928. }
  31929. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31930. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31931. v := m.addaccount_balance
  31932. if v == nil {
  31933. return
  31934. }
  31935. return *v, true
  31936. }
  31937. // ResetAccountBalance resets all changes to the "account_balance" field.
  31938. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31939. m.account_balance = nil
  31940. m.addaccount_balance = nil
  31941. }
  31942. // SetConsumeToken sets the "consume_token" field.
  31943. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31944. m.consume_token = &u
  31945. m.addconsume_token = nil
  31946. }
  31947. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31948. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31949. v := m.consume_token
  31950. if v == nil {
  31951. return
  31952. }
  31953. return *v, true
  31954. }
  31955. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31956. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31958. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31959. if !m.op.Is(OpUpdateOne) {
  31960. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31961. }
  31962. if m.id == nil || m.oldValue == nil {
  31963. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31964. }
  31965. oldValue, err := m.oldValue(ctx)
  31966. if err != nil {
  31967. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31968. }
  31969. return oldValue.ConsumeToken, nil
  31970. }
  31971. // AddConsumeToken adds u to the "consume_token" field.
  31972. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31973. if m.addconsume_token != nil {
  31974. *m.addconsume_token += u
  31975. } else {
  31976. m.addconsume_token = &u
  31977. }
  31978. }
  31979. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31980. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31981. v := m.addconsume_token
  31982. if v == nil {
  31983. return
  31984. }
  31985. return *v, true
  31986. }
  31987. // ResetConsumeToken resets all changes to the "consume_token" field.
  31988. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31989. m.consume_token = nil
  31990. m.addconsume_token = nil
  31991. }
  31992. // SetActiveUser sets the "active_user" field.
  31993. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31994. m.active_user = &u
  31995. m.addactive_user = nil
  31996. }
  31997. // ActiveUser returns the value of the "active_user" field in the mutation.
  31998. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31999. v := m.active_user
  32000. if v == nil {
  32001. return
  32002. }
  32003. return *v, true
  32004. }
  32005. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32006. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32008. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32009. if !m.op.Is(OpUpdateOne) {
  32010. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32011. }
  32012. if m.id == nil || m.oldValue == nil {
  32013. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32014. }
  32015. oldValue, err := m.oldValue(ctx)
  32016. if err != nil {
  32017. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32018. }
  32019. return oldValue.ActiveUser, nil
  32020. }
  32021. // AddActiveUser adds u to the "active_user" field.
  32022. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32023. if m.addactive_user != nil {
  32024. *m.addactive_user += u
  32025. } else {
  32026. m.addactive_user = &u
  32027. }
  32028. }
  32029. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32030. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32031. v := m.addactive_user
  32032. if v == nil {
  32033. return
  32034. }
  32035. return *v, true
  32036. }
  32037. // ResetActiveUser resets all changes to the "active_user" field.
  32038. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32039. m.active_user = nil
  32040. m.addactive_user = nil
  32041. }
  32042. // SetNewUser sets the "new_user" field.
  32043. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32044. m.new_user = &i
  32045. m.addnew_user = nil
  32046. }
  32047. // NewUser returns the value of the "new_user" field in the mutation.
  32048. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32049. v := m.new_user
  32050. if v == nil {
  32051. return
  32052. }
  32053. return *v, true
  32054. }
  32055. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32056. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32058. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32059. if !m.op.Is(OpUpdateOne) {
  32060. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32061. }
  32062. if m.id == nil || m.oldValue == nil {
  32063. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32064. }
  32065. oldValue, err := m.oldValue(ctx)
  32066. if err != nil {
  32067. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32068. }
  32069. return oldValue.NewUser, nil
  32070. }
  32071. // AddNewUser adds i to the "new_user" field.
  32072. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32073. if m.addnew_user != nil {
  32074. *m.addnew_user += i
  32075. } else {
  32076. m.addnew_user = &i
  32077. }
  32078. }
  32079. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32080. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32081. v := m.addnew_user
  32082. if v == nil {
  32083. return
  32084. }
  32085. return *v, true
  32086. }
  32087. // ResetNewUser resets all changes to the "new_user" field.
  32088. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32089. m.new_user = nil
  32090. m.addnew_user = nil
  32091. }
  32092. // SetLabelDist sets the "label_dist" field.
  32093. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32094. m.label_dist = &ctd
  32095. m.appendlabel_dist = nil
  32096. }
  32097. // LabelDist returns the value of the "label_dist" field in the mutation.
  32098. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32099. v := m.label_dist
  32100. if v == nil {
  32101. return
  32102. }
  32103. return *v, true
  32104. }
  32105. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32106. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32108. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32109. if !m.op.Is(OpUpdateOne) {
  32110. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32111. }
  32112. if m.id == nil || m.oldValue == nil {
  32113. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32114. }
  32115. oldValue, err := m.oldValue(ctx)
  32116. if err != nil {
  32117. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32118. }
  32119. return oldValue.LabelDist, nil
  32120. }
  32121. // AppendLabelDist adds ctd to the "label_dist" field.
  32122. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32123. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32124. }
  32125. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32126. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32127. if len(m.appendlabel_dist) == 0 {
  32128. return nil, false
  32129. }
  32130. return m.appendlabel_dist, true
  32131. }
  32132. // ResetLabelDist resets all changes to the "label_dist" field.
  32133. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32134. m.label_dist = nil
  32135. m.appendlabel_dist = nil
  32136. }
  32137. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32138. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32139. m.predicates = append(m.predicates, ps...)
  32140. }
  32141. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32142. // users can use type-assertion to append predicates that do not depend on any generated package.
  32143. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32144. p := make([]predicate.UsageStatisticMonth, len(ps))
  32145. for i := range ps {
  32146. p[i] = ps[i]
  32147. }
  32148. m.Where(p...)
  32149. }
  32150. // Op returns the operation name.
  32151. func (m *UsageStatisticMonthMutation) Op() Op {
  32152. return m.op
  32153. }
  32154. // SetOp allows setting the mutation operation.
  32155. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32156. m.op = op
  32157. }
  32158. // Type returns the node type of this mutation (UsageStatisticMonth).
  32159. func (m *UsageStatisticMonthMutation) Type() string {
  32160. return m.typ
  32161. }
  32162. // Fields returns all fields that were changed during this mutation. Note that in
  32163. // order to get all numeric fields that were incremented/decremented, call
  32164. // AddedFields().
  32165. func (m *UsageStatisticMonthMutation) Fields() []string {
  32166. fields := make([]string, 0, 17)
  32167. if m.created_at != nil {
  32168. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32169. }
  32170. if m.updated_at != nil {
  32171. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32172. }
  32173. if m.status != nil {
  32174. fields = append(fields, usagestatisticmonth.FieldStatus)
  32175. }
  32176. if m.deleted_at != nil {
  32177. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32178. }
  32179. if m.addtime != nil {
  32180. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32181. }
  32182. if m._type != nil {
  32183. fields = append(fields, usagestatisticmonth.FieldType)
  32184. }
  32185. if m.bot_id != nil {
  32186. fields = append(fields, usagestatisticmonth.FieldBotID)
  32187. }
  32188. if m.organization_id != nil {
  32189. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32190. }
  32191. if m.ai_response != nil {
  32192. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32193. }
  32194. if m.sop_run != nil {
  32195. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32196. }
  32197. if m.total_friend != nil {
  32198. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32199. }
  32200. if m.total_group != nil {
  32201. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32202. }
  32203. if m.account_balance != nil {
  32204. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32205. }
  32206. if m.consume_token != nil {
  32207. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32208. }
  32209. if m.active_user != nil {
  32210. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32211. }
  32212. if m.new_user != nil {
  32213. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32214. }
  32215. if m.label_dist != nil {
  32216. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32217. }
  32218. return fields
  32219. }
  32220. // Field returns the value of a field with the given name. The second boolean
  32221. // return value indicates that this field was not set, or was not defined in the
  32222. // schema.
  32223. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32224. switch name {
  32225. case usagestatisticmonth.FieldCreatedAt:
  32226. return m.CreatedAt()
  32227. case usagestatisticmonth.FieldUpdatedAt:
  32228. return m.UpdatedAt()
  32229. case usagestatisticmonth.FieldStatus:
  32230. return m.Status()
  32231. case usagestatisticmonth.FieldDeletedAt:
  32232. return m.DeletedAt()
  32233. case usagestatisticmonth.FieldAddtime:
  32234. return m.Addtime()
  32235. case usagestatisticmonth.FieldType:
  32236. return m.GetType()
  32237. case usagestatisticmonth.FieldBotID:
  32238. return m.BotID()
  32239. case usagestatisticmonth.FieldOrganizationID:
  32240. return m.OrganizationID()
  32241. case usagestatisticmonth.FieldAiResponse:
  32242. return m.AiResponse()
  32243. case usagestatisticmonth.FieldSopRun:
  32244. return m.SopRun()
  32245. case usagestatisticmonth.FieldTotalFriend:
  32246. return m.TotalFriend()
  32247. case usagestatisticmonth.FieldTotalGroup:
  32248. return m.TotalGroup()
  32249. case usagestatisticmonth.FieldAccountBalance:
  32250. return m.AccountBalance()
  32251. case usagestatisticmonth.FieldConsumeToken:
  32252. return m.ConsumeToken()
  32253. case usagestatisticmonth.FieldActiveUser:
  32254. return m.ActiveUser()
  32255. case usagestatisticmonth.FieldNewUser:
  32256. return m.NewUser()
  32257. case usagestatisticmonth.FieldLabelDist:
  32258. return m.LabelDist()
  32259. }
  32260. return nil, false
  32261. }
  32262. // OldField returns the old value of the field from the database. An error is
  32263. // returned if the mutation operation is not UpdateOne, or the query to the
  32264. // database failed.
  32265. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32266. switch name {
  32267. case usagestatisticmonth.FieldCreatedAt:
  32268. return m.OldCreatedAt(ctx)
  32269. case usagestatisticmonth.FieldUpdatedAt:
  32270. return m.OldUpdatedAt(ctx)
  32271. case usagestatisticmonth.FieldStatus:
  32272. return m.OldStatus(ctx)
  32273. case usagestatisticmonth.FieldDeletedAt:
  32274. return m.OldDeletedAt(ctx)
  32275. case usagestatisticmonth.FieldAddtime:
  32276. return m.OldAddtime(ctx)
  32277. case usagestatisticmonth.FieldType:
  32278. return m.OldType(ctx)
  32279. case usagestatisticmonth.FieldBotID:
  32280. return m.OldBotID(ctx)
  32281. case usagestatisticmonth.FieldOrganizationID:
  32282. return m.OldOrganizationID(ctx)
  32283. case usagestatisticmonth.FieldAiResponse:
  32284. return m.OldAiResponse(ctx)
  32285. case usagestatisticmonth.FieldSopRun:
  32286. return m.OldSopRun(ctx)
  32287. case usagestatisticmonth.FieldTotalFriend:
  32288. return m.OldTotalFriend(ctx)
  32289. case usagestatisticmonth.FieldTotalGroup:
  32290. return m.OldTotalGroup(ctx)
  32291. case usagestatisticmonth.FieldAccountBalance:
  32292. return m.OldAccountBalance(ctx)
  32293. case usagestatisticmonth.FieldConsumeToken:
  32294. return m.OldConsumeToken(ctx)
  32295. case usagestatisticmonth.FieldActiveUser:
  32296. return m.OldActiveUser(ctx)
  32297. case usagestatisticmonth.FieldNewUser:
  32298. return m.OldNewUser(ctx)
  32299. case usagestatisticmonth.FieldLabelDist:
  32300. return m.OldLabelDist(ctx)
  32301. }
  32302. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32303. }
  32304. // SetField sets the value of a field with the given name. It returns an error if
  32305. // the field is not defined in the schema, or if the type mismatched the field
  32306. // type.
  32307. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32308. switch name {
  32309. case usagestatisticmonth.FieldCreatedAt:
  32310. v, ok := value.(time.Time)
  32311. if !ok {
  32312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32313. }
  32314. m.SetCreatedAt(v)
  32315. return nil
  32316. case usagestatisticmonth.FieldUpdatedAt:
  32317. v, ok := value.(time.Time)
  32318. if !ok {
  32319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32320. }
  32321. m.SetUpdatedAt(v)
  32322. return nil
  32323. case usagestatisticmonth.FieldStatus:
  32324. v, ok := value.(uint8)
  32325. if !ok {
  32326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32327. }
  32328. m.SetStatus(v)
  32329. return nil
  32330. case usagestatisticmonth.FieldDeletedAt:
  32331. v, ok := value.(time.Time)
  32332. if !ok {
  32333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32334. }
  32335. m.SetDeletedAt(v)
  32336. return nil
  32337. case usagestatisticmonth.FieldAddtime:
  32338. v, ok := value.(uint64)
  32339. if !ok {
  32340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32341. }
  32342. m.SetAddtime(v)
  32343. return nil
  32344. case usagestatisticmonth.FieldType:
  32345. v, ok := value.(int)
  32346. if !ok {
  32347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32348. }
  32349. m.SetType(v)
  32350. return nil
  32351. case usagestatisticmonth.FieldBotID:
  32352. v, ok := value.(string)
  32353. if !ok {
  32354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32355. }
  32356. m.SetBotID(v)
  32357. return nil
  32358. case usagestatisticmonth.FieldOrganizationID:
  32359. v, ok := value.(uint64)
  32360. if !ok {
  32361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32362. }
  32363. m.SetOrganizationID(v)
  32364. return nil
  32365. case usagestatisticmonth.FieldAiResponse:
  32366. v, ok := value.(uint64)
  32367. if !ok {
  32368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32369. }
  32370. m.SetAiResponse(v)
  32371. return nil
  32372. case usagestatisticmonth.FieldSopRun:
  32373. v, ok := value.(uint64)
  32374. if !ok {
  32375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32376. }
  32377. m.SetSopRun(v)
  32378. return nil
  32379. case usagestatisticmonth.FieldTotalFriend:
  32380. v, ok := value.(uint64)
  32381. if !ok {
  32382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32383. }
  32384. m.SetTotalFriend(v)
  32385. return nil
  32386. case usagestatisticmonth.FieldTotalGroup:
  32387. v, ok := value.(uint64)
  32388. if !ok {
  32389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32390. }
  32391. m.SetTotalGroup(v)
  32392. return nil
  32393. case usagestatisticmonth.FieldAccountBalance:
  32394. v, ok := value.(uint64)
  32395. if !ok {
  32396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32397. }
  32398. m.SetAccountBalance(v)
  32399. return nil
  32400. case usagestatisticmonth.FieldConsumeToken:
  32401. v, ok := value.(uint64)
  32402. if !ok {
  32403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32404. }
  32405. m.SetConsumeToken(v)
  32406. return nil
  32407. case usagestatisticmonth.FieldActiveUser:
  32408. v, ok := value.(uint64)
  32409. if !ok {
  32410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32411. }
  32412. m.SetActiveUser(v)
  32413. return nil
  32414. case usagestatisticmonth.FieldNewUser:
  32415. v, ok := value.(int64)
  32416. if !ok {
  32417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32418. }
  32419. m.SetNewUser(v)
  32420. return nil
  32421. case usagestatisticmonth.FieldLabelDist:
  32422. v, ok := value.([]custom_types.LabelDist)
  32423. if !ok {
  32424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32425. }
  32426. m.SetLabelDist(v)
  32427. return nil
  32428. }
  32429. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32430. }
  32431. // AddedFields returns all numeric fields that were incremented/decremented during
  32432. // this mutation.
  32433. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32434. var fields []string
  32435. if m.addstatus != nil {
  32436. fields = append(fields, usagestatisticmonth.FieldStatus)
  32437. }
  32438. if m.addaddtime != nil {
  32439. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32440. }
  32441. if m.add_type != nil {
  32442. fields = append(fields, usagestatisticmonth.FieldType)
  32443. }
  32444. if m.addorganization_id != nil {
  32445. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32446. }
  32447. if m.addai_response != nil {
  32448. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32449. }
  32450. if m.addsop_run != nil {
  32451. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32452. }
  32453. if m.addtotal_friend != nil {
  32454. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32455. }
  32456. if m.addtotal_group != nil {
  32457. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32458. }
  32459. if m.addaccount_balance != nil {
  32460. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32461. }
  32462. if m.addconsume_token != nil {
  32463. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32464. }
  32465. if m.addactive_user != nil {
  32466. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32467. }
  32468. if m.addnew_user != nil {
  32469. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32470. }
  32471. return fields
  32472. }
  32473. // AddedField returns the numeric value that was incremented/decremented on a field
  32474. // with the given name. The second boolean return value indicates that this field
  32475. // was not set, or was not defined in the schema.
  32476. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32477. switch name {
  32478. case usagestatisticmonth.FieldStatus:
  32479. return m.AddedStatus()
  32480. case usagestatisticmonth.FieldAddtime:
  32481. return m.AddedAddtime()
  32482. case usagestatisticmonth.FieldType:
  32483. return m.AddedType()
  32484. case usagestatisticmonth.FieldOrganizationID:
  32485. return m.AddedOrganizationID()
  32486. case usagestatisticmonth.FieldAiResponse:
  32487. return m.AddedAiResponse()
  32488. case usagestatisticmonth.FieldSopRun:
  32489. return m.AddedSopRun()
  32490. case usagestatisticmonth.FieldTotalFriend:
  32491. return m.AddedTotalFriend()
  32492. case usagestatisticmonth.FieldTotalGroup:
  32493. return m.AddedTotalGroup()
  32494. case usagestatisticmonth.FieldAccountBalance:
  32495. return m.AddedAccountBalance()
  32496. case usagestatisticmonth.FieldConsumeToken:
  32497. return m.AddedConsumeToken()
  32498. case usagestatisticmonth.FieldActiveUser:
  32499. return m.AddedActiveUser()
  32500. case usagestatisticmonth.FieldNewUser:
  32501. return m.AddedNewUser()
  32502. }
  32503. return nil, false
  32504. }
  32505. // AddField adds the value to the field with the given name. It returns an error if
  32506. // the field is not defined in the schema, or if the type mismatched the field
  32507. // type.
  32508. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32509. switch name {
  32510. case usagestatisticmonth.FieldStatus:
  32511. v, ok := value.(int8)
  32512. if !ok {
  32513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32514. }
  32515. m.AddStatus(v)
  32516. return nil
  32517. case usagestatisticmonth.FieldAddtime:
  32518. v, ok := value.(int64)
  32519. if !ok {
  32520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32521. }
  32522. m.AddAddtime(v)
  32523. return nil
  32524. case usagestatisticmonth.FieldType:
  32525. v, ok := value.(int)
  32526. if !ok {
  32527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32528. }
  32529. m.AddType(v)
  32530. return nil
  32531. case usagestatisticmonth.FieldOrganizationID:
  32532. v, ok := value.(int64)
  32533. if !ok {
  32534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32535. }
  32536. m.AddOrganizationID(v)
  32537. return nil
  32538. case usagestatisticmonth.FieldAiResponse:
  32539. v, ok := value.(int64)
  32540. if !ok {
  32541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32542. }
  32543. m.AddAiResponse(v)
  32544. return nil
  32545. case usagestatisticmonth.FieldSopRun:
  32546. v, ok := value.(int64)
  32547. if !ok {
  32548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32549. }
  32550. m.AddSopRun(v)
  32551. return nil
  32552. case usagestatisticmonth.FieldTotalFriend:
  32553. v, ok := value.(int64)
  32554. if !ok {
  32555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32556. }
  32557. m.AddTotalFriend(v)
  32558. return nil
  32559. case usagestatisticmonth.FieldTotalGroup:
  32560. v, ok := value.(int64)
  32561. if !ok {
  32562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32563. }
  32564. m.AddTotalGroup(v)
  32565. return nil
  32566. case usagestatisticmonth.FieldAccountBalance:
  32567. v, ok := value.(int64)
  32568. if !ok {
  32569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32570. }
  32571. m.AddAccountBalance(v)
  32572. return nil
  32573. case usagestatisticmonth.FieldConsumeToken:
  32574. v, ok := value.(int64)
  32575. if !ok {
  32576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32577. }
  32578. m.AddConsumeToken(v)
  32579. return nil
  32580. case usagestatisticmonth.FieldActiveUser:
  32581. v, ok := value.(int64)
  32582. if !ok {
  32583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32584. }
  32585. m.AddActiveUser(v)
  32586. return nil
  32587. case usagestatisticmonth.FieldNewUser:
  32588. v, ok := value.(int64)
  32589. if !ok {
  32590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32591. }
  32592. m.AddNewUser(v)
  32593. return nil
  32594. }
  32595. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32596. }
  32597. // ClearedFields returns all nullable fields that were cleared during this
  32598. // mutation.
  32599. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32600. var fields []string
  32601. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32602. fields = append(fields, usagestatisticmonth.FieldStatus)
  32603. }
  32604. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32605. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32606. }
  32607. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32608. fields = append(fields, usagestatisticmonth.FieldBotID)
  32609. }
  32610. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32611. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32612. }
  32613. return fields
  32614. }
  32615. // FieldCleared returns a boolean indicating if a field with the given name was
  32616. // cleared in this mutation.
  32617. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32618. _, ok := m.clearedFields[name]
  32619. return ok
  32620. }
  32621. // ClearField clears the value of the field with the given name. It returns an
  32622. // error if the field is not defined in the schema.
  32623. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32624. switch name {
  32625. case usagestatisticmonth.FieldStatus:
  32626. m.ClearStatus()
  32627. return nil
  32628. case usagestatisticmonth.FieldDeletedAt:
  32629. m.ClearDeletedAt()
  32630. return nil
  32631. case usagestatisticmonth.FieldBotID:
  32632. m.ClearBotID()
  32633. return nil
  32634. case usagestatisticmonth.FieldOrganizationID:
  32635. m.ClearOrganizationID()
  32636. return nil
  32637. }
  32638. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32639. }
  32640. // ResetField resets all changes in the mutation for the field with the given name.
  32641. // It returns an error if the field is not defined in the schema.
  32642. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32643. switch name {
  32644. case usagestatisticmonth.FieldCreatedAt:
  32645. m.ResetCreatedAt()
  32646. return nil
  32647. case usagestatisticmonth.FieldUpdatedAt:
  32648. m.ResetUpdatedAt()
  32649. return nil
  32650. case usagestatisticmonth.FieldStatus:
  32651. m.ResetStatus()
  32652. return nil
  32653. case usagestatisticmonth.FieldDeletedAt:
  32654. m.ResetDeletedAt()
  32655. return nil
  32656. case usagestatisticmonth.FieldAddtime:
  32657. m.ResetAddtime()
  32658. return nil
  32659. case usagestatisticmonth.FieldType:
  32660. m.ResetType()
  32661. return nil
  32662. case usagestatisticmonth.FieldBotID:
  32663. m.ResetBotID()
  32664. return nil
  32665. case usagestatisticmonth.FieldOrganizationID:
  32666. m.ResetOrganizationID()
  32667. return nil
  32668. case usagestatisticmonth.FieldAiResponse:
  32669. m.ResetAiResponse()
  32670. return nil
  32671. case usagestatisticmonth.FieldSopRun:
  32672. m.ResetSopRun()
  32673. return nil
  32674. case usagestatisticmonth.FieldTotalFriend:
  32675. m.ResetTotalFriend()
  32676. return nil
  32677. case usagestatisticmonth.FieldTotalGroup:
  32678. m.ResetTotalGroup()
  32679. return nil
  32680. case usagestatisticmonth.FieldAccountBalance:
  32681. m.ResetAccountBalance()
  32682. return nil
  32683. case usagestatisticmonth.FieldConsumeToken:
  32684. m.ResetConsumeToken()
  32685. return nil
  32686. case usagestatisticmonth.FieldActiveUser:
  32687. m.ResetActiveUser()
  32688. return nil
  32689. case usagestatisticmonth.FieldNewUser:
  32690. m.ResetNewUser()
  32691. return nil
  32692. case usagestatisticmonth.FieldLabelDist:
  32693. m.ResetLabelDist()
  32694. return nil
  32695. }
  32696. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32697. }
  32698. // AddedEdges returns all edge names that were set/added in this mutation.
  32699. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32700. edges := make([]string, 0, 0)
  32701. return edges
  32702. }
  32703. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32704. // name in this mutation.
  32705. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32706. return nil
  32707. }
  32708. // RemovedEdges returns all edge names that were removed in this mutation.
  32709. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32710. edges := make([]string, 0, 0)
  32711. return edges
  32712. }
  32713. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32714. // the given name in this mutation.
  32715. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32716. return nil
  32717. }
  32718. // ClearedEdges returns all edge names that were cleared in this mutation.
  32719. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32720. edges := make([]string, 0, 0)
  32721. return edges
  32722. }
  32723. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32724. // was cleared in this mutation.
  32725. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32726. return false
  32727. }
  32728. // ClearEdge clears the value of the edge with the given name. It returns an error
  32729. // if that edge is not defined in the schema.
  32730. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32731. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32732. }
  32733. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32734. // It returns an error if the edge is not defined in the schema.
  32735. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32736. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32737. }
  32738. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32739. type UsageTotalMutation struct {
  32740. config
  32741. op Op
  32742. typ string
  32743. id *uint64
  32744. created_at *time.Time
  32745. updated_at *time.Time
  32746. status *uint8
  32747. addstatus *int8
  32748. _type *int
  32749. add_type *int
  32750. bot_id *string
  32751. total_tokens *uint64
  32752. addtotal_tokens *int64
  32753. start_index *uint64
  32754. addstart_index *int64
  32755. end_index *uint64
  32756. addend_index *int64
  32757. organization_id *uint64
  32758. addorganization_id *int64
  32759. clearedFields map[string]struct{}
  32760. done bool
  32761. oldValue func(context.Context) (*UsageTotal, error)
  32762. predicates []predicate.UsageTotal
  32763. }
  32764. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32765. // usagetotalOption allows management of the mutation configuration using functional options.
  32766. type usagetotalOption func(*UsageTotalMutation)
  32767. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32768. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32769. m := &UsageTotalMutation{
  32770. config: c,
  32771. op: op,
  32772. typ: TypeUsageTotal,
  32773. clearedFields: make(map[string]struct{}),
  32774. }
  32775. for _, opt := range opts {
  32776. opt(m)
  32777. }
  32778. return m
  32779. }
  32780. // withUsageTotalID sets the ID field of the mutation.
  32781. func withUsageTotalID(id uint64) usagetotalOption {
  32782. return func(m *UsageTotalMutation) {
  32783. var (
  32784. err error
  32785. once sync.Once
  32786. value *UsageTotal
  32787. )
  32788. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32789. once.Do(func() {
  32790. if m.done {
  32791. err = errors.New("querying old values post mutation is not allowed")
  32792. } else {
  32793. value, err = m.Client().UsageTotal.Get(ctx, id)
  32794. }
  32795. })
  32796. return value, err
  32797. }
  32798. m.id = &id
  32799. }
  32800. }
  32801. // withUsageTotal sets the old UsageTotal of the mutation.
  32802. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32803. return func(m *UsageTotalMutation) {
  32804. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32805. return node, nil
  32806. }
  32807. m.id = &node.ID
  32808. }
  32809. }
  32810. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32811. // executed in a transaction (ent.Tx), a transactional client is returned.
  32812. func (m UsageTotalMutation) Client() *Client {
  32813. client := &Client{config: m.config}
  32814. client.init()
  32815. return client
  32816. }
  32817. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32818. // it returns an error otherwise.
  32819. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32820. if _, ok := m.driver.(*txDriver); !ok {
  32821. return nil, errors.New("ent: mutation is not running in a transaction")
  32822. }
  32823. tx := &Tx{config: m.config}
  32824. tx.init()
  32825. return tx, nil
  32826. }
  32827. // SetID sets the value of the id field. Note that this
  32828. // operation is only accepted on creation of UsageTotal entities.
  32829. func (m *UsageTotalMutation) SetID(id uint64) {
  32830. m.id = &id
  32831. }
  32832. // ID returns the ID value in the mutation. Note that the ID is only available
  32833. // if it was provided to the builder or after it was returned from the database.
  32834. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32835. if m.id == nil {
  32836. return
  32837. }
  32838. return *m.id, true
  32839. }
  32840. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32841. // That means, if the mutation is applied within a transaction with an isolation level such
  32842. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32843. // or updated by the mutation.
  32844. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32845. switch {
  32846. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32847. id, exists := m.ID()
  32848. if exists {
  32849. return []uint64{id}, nil
  32850. }
  32851. fallthrough
  32852. case m.op.Is(OpUpdate | OpDelete):
  32853. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32854. default:
  32855. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32856. }
  32857. }
  32858. // SetCreatedAt sets the "created_at" field.
  32859. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32860. m.created_at = &t
  32861. }
  32862. // CreatedAt returns the value of the "created_at" field in the mutation.
  32863. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32864. v := m.created_at
  32865. if v == nil {
  32866. return
  32867. }
  32868. return *v, true
  32869. }
  32870. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32871. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32873. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32874. if !m.op.Is(OpUpdateOne) {
  32875. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32876. }
  32877. if m.id == nil || m.oldValue == nil {
  32878. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32879. }
  32880. oldValue, err := m.oldValue(ctx)
  32881. if err != nil {
  32882. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32883. }
  32884. return oldValue.CreatedAt, nil
  32885. }
  32886. // ResetCreatedAt resets all changes to the "created_at" field.
  32887. func (m *UsageTotalMutation) ResetCreatedAt() {
  32888. m.created_at = nil
  32889. }
  32890. // SetUpdatedAt sets the "updated_at" field.
  32891. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32892. m.updated_at = &t
  32893. }
  32894. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32895. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32896. v := m.updated_at
  32897. if v == nil {
  32898. return
  32899. }
  32900. return *v, true
  32901. }
  32902. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32903. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32905. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32906. if !m.op.Is(OpUpdateOne) {
  32907. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32908. }
  32909. if m.id == nil || m.oldValue == nil {
  32910. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32911. }
  32912. oldValue, err := m.oldValue(ctx)
  32913. if err != nil {
  32914. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32915. }
  32916. return oldValue.UpdatedAt, nil
  32917. }
  32918. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32919. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32920. m.updated_at = nil
  32921. }
  32922. // SetStatus sets the "status" field.
  32923. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32924. m.status = &u
  32925. m.addstatus = nil
  32926. }
  32927. // Status returns the value of the "status" field in the mutation.
  32928. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32929. v := m.status
  32930. if v == nil {
  32931. return
  32932. }
  32933. return *v, true
  32934. }
  32935. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32936. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32938. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32939. if !m.op.Is(OpUpdateOne) {
  32940. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32941. }
  32942. if m.id == nil || m.oldValue == nil {
  32943. return v, errors.New("OldStatus requires an ID field in the mutation")
  32944. }
  32945. oldValue, err := m.oldValue(ctx)
  32946. if err != nil {
  32947. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32948. }
  32949. return oldValue.Status, nil
  32950. }
  32951. // AddStatus adds u to the "status" field.
  32952. func (m *UsageTotalMutation) AddStatus(u int8) {
  32953. if m.addstatus != nil {
  32954. *m.addstatus += u
  32955. } else {
  32956. m.addstatus = &u
  32957. }
  32958. }
  32959. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32960. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32961. v := m.addstatus
  32962. if v == nil {
  32963. return
  32964. }
  32965. return *v, true
  32966. }
  32967. // ClearStatus clears the value of the "status" field.
  32968. func (m *UsageTotalMutation) ClearStatus() {
  32969. m.status = nil
  32970. m.addstatus = nil
  32971. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32972. }
  32973. // StatusCleared returns if the "status" field was cleared in this mutation.
  32974. func (m *UsageTotalMutation) StatusCleared() bool {
  32975. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32976. return ok
  32977. }
  32978. // ResetStatus resets all changes to the "status" field.
  32979. func (m *UsageTotalMutation) ResetStatus() {
  32980. m.status = nil
  32981. m.addstatus = nil
  32982. delete(m.clearedFields, usagetotal.FieldStatus)
  32983. }
  32984. // SetType sets the "type" field.
  32985. func (m *UsageTotalMutation) SetType(i int) {
  32986. m._type = &i
  32987. m.add_type = nil
  32988. }
  32989. // GetType returns the value of the "type" field in the mutation.
  32990. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32991. v := m._type
  32992. if v == nil {
  32993. return
  32994. }
  32995. return *v, true
  32996. }
  32997. // OldType returns the old "type" field's value of the UsageTotal entity.
  32998. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33000. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33001. if !m.op.Is(OpUpdateOne) {
  33002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33003. }
  33004. if m.id == nil || m.oldValue == nil {
  33005. return v, errors.New("OldType requires an ID field in the mutation")
  33006. }
  33007. oldValue, err := m.oldValue(ctx)
  33008. if err != nil {
  33009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33010. }
  33011. return oldValue.Type, nil
  33012. }
  33013. // AddType adds i to the "type" field.
  33014. func (m *UsageTotalMutation) AddType(i int) {
  33015. if m.add_type != nil {
  33016. *m.add_type += i
  33017. } else {
  33018. m.add_type = &i
  33019. }
  33020. }
  33021. // AddedType returns the value that was added to the "type" field in this mutation.
  33022. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33023. v := m.add_type
  33024. if v == nil {
  33025. return
  33026. }
  33027. return *v, true
  33028. }
  33029. // ClearType clears the value of the "type" field.
  33030. func (m *UsageTotalMutation) ClearType() {
  33031. m._type = nil
  33032. m.add_type = nil
  33033. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33034. }
  33035. // TypeCleared returns if the "type" field was cleared in this mutation.
  33036. func (m *UsageTotalMutation) TypeCleared() bool {
  33037. _, ok := m.clearedFields[usagetotal.FieldType]
  33038. return ok
  33039. }
  33040. // ResetType resets all changes to the "type" field.
  33041. func (m *UsageTotalMutation) ResetType() {
  33042. m._type = nil
  33043. m.add_type = nil
  33044. delete(m.clearedFields, usagetotal.FieldType)
  33045. }
  33046. // SetBotID sets the "bot_id" field.
  33047. func (m *UsageTotalMutation) SetBotID(s string) {
  33048. m.bot_id = &s
  33049. }
  33050. // BotID returns the value of the "bot_id" field in the mutation.
  33051. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33052. v := m.bot_id
  33053. if v == nil {
  33054. return
  33055. }
  33056. return *v, true
  33057. }
  33058. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33059. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33061. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33062. if !m.op.Is(OpUpdateOne) {
  33063. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33064. }
  33065. if m.id == nil || m.oldValue == nil {
  33066. return v, errors.New("OldBotID requires an ID field in the mutation")
  33067. }
  33068. oldValue, err := m.oldValue(ctx)
  33069. if err != nil {
  33070. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33071. }
  33072. return oldValue.BotID, nil
  33073. }
  33074. // ResetBotID resets all changes to the "bot_id" field.
  33075. func (m *UsageTotalMutation) ResetBotID() {
  33076. m.bot_id = nil
  33077. }
  33078. // SetTotalTokens sets the "total_tokens" field.
  33079. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33080. m.total_tokens = &u
  33081. m.addtotal_tokens = nil
  33082. }
  33083. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33084. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33085. v := m.total_tokens
  33086. if v == nil {
  33087. return
  33088. }
  33089. return *v, true
  33090. }
  33091. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33092. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33094. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33095. if !m.op.Is(OpUpdateOne) {
  33096. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33097. }
  33098. if m.id == nil || m.oldValue == nil {
  33099. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33100. }
  33101. oldValue, err := m.oldValue(ctx)
  33102. if err != nil {
  33103. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33104. }
  33105. return oldValue.TotalTokens, nil
  33106. }
  33107. // AddTotalTokens adds u to the "total_tokens" field.
  33108. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33109. if m.addtotal_tokens != nil {
  33110. *m.addtotal_tokens += u
  33111. } else {
  33112. m.addtotal_tokens = &u
  33113. }
  33114. }
  33115. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33116. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33117. v := m.addtotal_tokens
  33118. if v == nil {
  33119. return
  33120. }
  33121. return *v, true
  33122. }
  33123. // ClearTotalTokens clears the value of the "total_tokens" field.
  33124. func (m *UsageTotalMutation) ClearTotalTokens() {
  33125. m.total_tokens = nil
  33126. m.addtotal_tokens = nil
  33127. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33128. }
  33129. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33130. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33131. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33132. return ok
  33133. }
  33134. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33135. func (m *UsageTotalMutation) ResetTotalTokens() {
  33136. m.total_tokens = nil
  33137. m.addtotal_tokens = nil
  33138. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33139. }
  33140. // SetStartIndex sets the "start_index" field.
  33141. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33142. m.start_index = &u
  33143. m.addstart_index = nil
  33144. }
  33145. // StartIndex returns the value of the "start_index" field in the mutation.
  33146. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33147. v := m.start_index
  33148. if v == nil {
  33149. return
  33150. }
  33151. return *v, true
  33152. }
  33153. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33154. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33156. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33157. if !m.op.Is(OpUpdateOne) {
  33158. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33159. }
  33160. if m.id == nil || m.oldValue == nil {
  33161. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33162. }
  33163. oldValue, err := m.oldValue(ctx)
  33164. if err != nil {
  33165. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33166. }
  33167. return oldValue.StartIndex, nil
  33168. }
  33169. // AddStartIndex adds u to the "start_index" field.
  33170. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33171. if m.addstart_index != nil {
  33172. *m.addstart_index += u
  33173. } else {
  33174. m.addstart_index = &u
  33175. }
  33176. }
  33177. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33178. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33179. v := m.addstart_index
  33180. if v == nil {
  33181. return
  33182. }
  33183. return *v, true
  33184. }
  33185. // ClearStartIndex clears the value of the "start_index" field.
  33186. func (m *UsageTotalMutation) ClearStartIndex() {
  33187. m.start_index = nil
  33188. m.addstart_index = nil
  33189. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33190. }
  33191. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33192. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33193. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33194. return ok
  33195. }
  33196. // ResetStartIndex resets all changes to the "start_index" field.
  33197. func (m *UsageTotalMutation) ResetStartIndex() {
  33198. m.start_index = nil
  33199. m.addstart_index = nil
  33200. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33201. }
  33202. // SetEndIndex sets the "end_index" field.
  33203. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33204. m.end_index = &u
  33205. m.addend_index = nil
  33206. }
  33207. // EndIndex returns the value of the "end_index" field in the mutation.
  33208. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33209. v := m.end_index
  33210. if v == nil {
  33211. return
  33212. }
  33213. return *v, true
  33214. }
  33215. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33216. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33218. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33219. if !m.op.Is(OpUpdateOne) {
  33220. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33221. }
  33222. if m.id == nil || m.oldValue == nil {
  33223. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33224. }
  33225. oldValue, err := m.oldValue(ctx)
  33226. if err != nil {
  33227. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33228. }
  33229. return oldValue.EndIndex, nil
  33230. }
  33231. // AddEndIndex adds u to the "end_index" field.
  33232. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33233. if m.addend_index != nil {
  33234. *m.addend_index += u
  33235. } else {
  33236. m.addend_index = &u
  33237. }
  33238. }
  33239. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33240. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33241. v := m.addend_index
  33242. if v == nil {
  33243. return
  33244. }
  33245. return *v, true
  33246. }
  33247. // ClearEndIndex clears the value of the "end_index" field.
  33248. func (m *UsageTotalMutation) ClearEndIndex() {
  33249. m.end_index = nil
  33250. m.addend_index = nil
  33251. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33252. }
  33253. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33254. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33255. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33256. return ok
  33257. }
  33258. // ResetEndIndex resets all changes to the "end_index" field.
  33259. func (m *UsageTotalMutation) ResetEndIndex() {
  33260. m.end_index = nil
  33261. m.addend_index = nil
  33262. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33263. }
  33264. // SetOrganizationID sets the "organization_id" field.
  33265. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33266. m.organization_id = &u
  33267. m.addorganization_id = nil
  33268. }
  33269. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33270. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33271. v := m.organization_id
  33272. if v == nil {
  33273. return
  33274. }
  33275. return *v, true
  33276. }
  33277. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33278. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33280. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33281. if !m.op.Is(OpUpdateOne) {
  33282. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33283. }
  33284. if m.id == nil || m.oldValue == nil {
  33285. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33286. }
  33287. oldValue, err := m.oldValue(ctx)
  33288. if err != nil {
  33289. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33290. }
  33291. return oldValue.OrganizationID, nil
  33292. }
  33293. // AddOrganizationID adds u to the "organization_id" field.
  33294. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33295. if m.addorganization_id != nil {
  33296. *m.addorganization_id += u
  33297. } else {
  33298. m.addorganization_id = &u
  33299. }
  33300. }
  33301. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33302. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33303. v := m.addorganization_id
  33304. if v == nil {
  33305. return
  33306. }
  33307. return *v, true
  33308. }
  33309. // ClearOrganizationID clears the value of the "organization_id" field.
  33310. func (m *UsageTotalMutation) ClearOrganizationID() {
  33311. m.organization_id = nil
  33312. m.addorganization_id = nil
  33313. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33314. }
  33315. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33316. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33317. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33318. return ok
  33319. }
  33320. // ResetOrganizationID resets all changes to the "organization_id" field.
  33321. func (m *UsageTotalMutation) ResetOrganizationID() {
  33322. m.organization_id = nil
  33323. m.addorganization_id = nil
  33324. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33325. }
  33326. // Where appends a list predicates to the UsageTotalMutation builder.
  33327. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33328. m.predicates = append(m.predicates, ps...)
  33329. }
  33330. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33331. // users can use type-assertion to append predicates that do not depend on any generated package.
  33332. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33333. p := make([]predicate.UsageTotal, len(ps))
  33334. for i := range ps {
  33335. p[i] = ps[i]
  33336. }
  33337. m.Where(p...)
  33338. }
  33339. // Op returns the operation name.
  33340. func (m *UsageTotalMutation) Op() Op {
  33341. return m.op
  33342. }
  33343. // SetOp allows setting the mutation operation.
  33344. func (m *UsageTotalMutation) SetOp(op Op) {
  33345. m.op = op
  33346. }
  33347. // Type returns the node type of this mutation (UsageTotal).
  33348. func (m *UsageTotalMutation) Type() string {
  33349. return m.typ
  33350. }
  33351. // Fields returns all fields that were changed during this mutation. Note that in
  33352. // order to get all numeric fields that were incremented/decremented, call
  33353. // AddedFields().
  33354. func (m *UsageTotalMutation) Fields() []string {
  33355. fields := make([]string, 0, 9)
  33356. if m.created_at != nil {
  33357. fields = append(fields, usagetotal.FieldCreatedAt)
  33358. }
  33359. if m.updated_at != nil {
  33360. fields = append(fields, usagetotal.FieldUpdatedAt)
  33361. }
  33362. if m.status != nil {
  33363. fields = append(fields, usagetotal.FieldStatus)
  33364. }
  33365. if m._type != nil {
  33366. fields = append(fields, usagetotal.FieldType)
  33367. }
  33368. if m.bot_id != nil {
  33369. fields = append(fields, usagetotal.FieldBotID)
  33370. }
  33371. if m.total_tokens != nil {
  33372. fields = append(fields, usagetotal.FieldTotalTokens)
  33373. }
  33374. if m.start_index != nil {
  33375. fields = append(fields, usagetotal.FieldStartIndex)
  33376. }
  33377. if m.end_index != nil {
  33378. fields = append(fields, usagetotal.FieldEndIndex)
  33379. }
  33380. if m.organization_id != nil {
  33381. fields = append(fields, usagetotal.FieldOrganizationID)
  33382. }
  33383. return fields
  33384. }
  33385. // Field returns the value of a field with the given name. The second boolean
  33386. // return value indicates that this field was not set, or was not defined in the
  33387. // schema.
  33388. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33389. switch name {
  33390. case usagetotal.FieldCreatedAt:
  33391. return m.CreatedAt()
  33392. case usagetotal.FieldUpdatedAt:
  33393. return m.UpdatedAt()
  33394. case usagetotal.FieldStatus:
  33395. return m.Status()
  33396. case usagetotal.FieldType:
  33397. return m.GetType()
  33398. case usagetotal.FieldBotID:
  33399. return m.BotID()
  33400. case usagetotal.FieldTotalTokens:
  33401. return m.TotalTokens()
  33402. case usagetotal.FieldStartIndex:
  33403. return m.StartIndex()
  33404. case usagetotal.FieldEndIndex:
  33405. return m.EndIndex()
  33406. case usagetotal.FieldOrganizationID:
  33407. return m.OrganizationID()
  33408. }
  33409. return nil, false
  33410. }
  33411. // OldField returns the old value of the field from the database. An error is
  33412. // returned if the mutation operation is not UpdateOne, or the query to the
  33413. // database failed.
  33414. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33415. switch name {
  33416. case usagetotal.FieldCreatedAt:
  33417. return m.OldCreatedAt(ctx)
  33418. case usagetotal.FieldUpdatedAt:
  33419. return m.OldUpdatedAt(ctx)
  33420. case usagetotal.FieldStatus:
  33421. return m.OldStatus(ctx)
  33422. case usagetotal.FieldType:
  33423. return m.OldType(ctx)
  33424. case usagetotal.FieldBotID:
  33425. return m.OldBotID(ctx)
  33426. case usagetotal.FieldTotalTokens:
  33427. return m.OldTotalTokens(ctx)
  33428. case usagetotal.FieldStartIndex:
  33429. return m.OldStartIndex(ctx)
  33430. case usagetotal.FieldEndIndex:
  33431. return m.OldEndIndex(ctx)
  33432. case usagetotal.FieldOrganizationID:
  33433. return m.OldOrganizationID(ctx)
  33434. }
  33435. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33436. }
  33437. // SetField sets the value of a field with the given name. It returns an error if
  33438. // the field is not defined in the schema, or if the type mismatched the field
  33439. // type.
  33440. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33441. switch name {
  33442. case usagetotal.FieldCreatedAt:
  33443. v, ok := value.(time.Time)
  33444. if !ok {
  33445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33446. }
  33447. m.SetCreatedAt(v)
  33448. return nil
  33449. case usagetotal.FieldUpdatedAt:
  33450. v, ok := value.(time.Time)
  33451. if !ok {
  33452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33453. }
  33454. m.SetUpdatedAt(v)
  33455. return nil
  33456. case usagetotal.FieldStatus:
  33457. v, ok := value.(uint8)
  33458. if !ok {
  33459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33460. }
  33461. m.SetStatus(v)
  33462. return nil
  33463. case usagetotal.FieldType:
  33464. v, ok := value.(int)
  33465. if !ok {
  33466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33467. }
  33468. m.SetType(v)
  33469. return nil
  33470. case usagetotal.FieldBotID:
  33471. v, ok := value.(string)
  33472. if !ok {
  33473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33474. }
  33475. m.SetBotID(v)
  33476. return nil
  33477. case usagetotal.FieldTotalTokens:
  33478. v, ok := value.(uint64)
  33479. if !ok {
  33480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33481. }
  33482. m.SetTotalTokens(v)
  33483. return nil
  33484. case usagetotal.FieldStartIndex:
  33485. v, ok := value.(uint64)
  33486. if !ok {
  33487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33488. }
  33489. m.SetStartIndex(v)
  33490. return nil
  33491. case usagetotal.FieldEndIndex:
  33492. v, ok := value.(uint64)
  33493. if !ok {
  33494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33495. }
  33496. m.SetEndIndex(v)
  33497. return nil
  33498. case usagetotal.FieldOrganizationID:
  33499. v, ok := value.(uint64)
  33500. if !ok {
  33501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33502. }
  33503. m.SetOrganizationID(v)
  33504. return nil
  33505. }
  33506. return fmt.Errorf("unknown UsageTotal field %s", name)
  33507. }
  33508. // AddedFields returns all numeric fields that were incremented/decremented during
  33509. // this mutation.
  33510. func (m *UsageTotalMutation) AddedFields() []string {
  33511. var fields []string
  33512. if m.addstatus != nil {
  33513. fields = append(fields, usagetotal.FieldStatus)
  33514. }
  33515. if m.add_type != nil {
  33516. fields = append(fields, usagetotal.FieldType)
  33517. }
  33518. if m.addtotal_tokens != nil {
  33519. fields = append(fields, usagetotal.FieldTotalTokens)
  33520. }
  33521. if m.addstart_index != nil {
  33522. fields = append(fields, usagetotal.FieldStartIndex)
  33523. }
  33524. if m.addend_index != nil {
  33525. fields = append(fields, usagetotal.FieldEndIndex)
  33526. }
  33527. if m.addorganization_id != nil {
  33528. fields = append(fields, usagetotal.FieldOrganizationID)
  33529. }
  33530. return fields
  33531. }
  33532. // AddedField returns the numeric value that was incremented/decremented on a field
  33533. // with the given name. The second boolean return value indicates that this field
  33534. // was not set, or was not defined in the schema.
  33535. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33536. switch name {
  33537. case usagetotal.FieldStatus:
  33538. return m.AddedStatus()
  33539. case usagetotal.FieldType:
  33540. return m.AddedType()
  33541. case usagetotal.FieldTotalTokens:
  33542. return m.AddedTotalTokens()
  33543. case usagetotal.FieldStartIndex:
  33544. return m.AddedStartIndex()
  33545. case usagetotal.FieldEndIndex:
  33546. return m.AddedEndIndex()
  33547. case usagetotal.FieldOrganizationID:
  33548. return m.AddedOrganizationID()
  33549. }
  33550. return nil, false
  33551. }
  33552. // AddField adds the value to the field with the given name. It returns an error if
  33553. // the field is not defined in the schema, or if the type mismatched the field
  33554. // type.
  33555. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33556. switch name {
  33557. case usagetotal.FieldStatus:
  33558. v, ok := value.(int8)
  33559. if !ok {
  33560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33561. }
  33562. m.AddStatus(v)
  33563. return nil
  33564. case usagetotal.FieldType:
  33565. v, ok := value.(int)
  33566. if !ok {
  33567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33568. }
  33569. m.AddType(v)
  33570. return nil
  33571. case usagetotal.FieldTotalTokens:
  33572. v, ok := value.(int64)
  33573. if !ok {
  33574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33575. }
  33576. m.AddTotalTokens(v)
  33577. return nil
  33578. case usagetotal.FieldStartIndex:
  33579. v, ok := value.(int64)
  33580. if !ok {
  33581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33582. }
  33583. m.AddStartIndex(v)
  33584. return nil
  33585. case usagetotal.FieldEndIndex:
  33586. v, ok := value.(int64)
  33587. if !ok {
  33588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33589. }
  33590. m.AddEndIndex(v)
  33591. return nil
  33592. case usagetotal.FieldOrganizationID:
  33593. v, ok := value.(int64)
  33594. if !ok {
  33595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33596. }
  33597. m.AddOrganizationID(v)
  33598. return nil
  33599. }
  33600. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33601. }
  33602. // ClearedFields returns all nullable fields that were cleared during this
  33603. // mutation.
  33604. func (m *UsageTotalMutation) ClearedFields() []string {
  33605. var fields []string
  33606. if m.FieldCleared(usagetotal.FieldStatus) {
  33607. fields = append(fields, usagetotal.FieldStatus)
  33608. }
  33609. if m.FieldCleared(usagetotal.FieldType) {
  33610. fields = append(fields, usagetotal.FieldType)
  33611. }
  33612. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33613. fields = append(fields, usagetotal.FieldTotalTokens)
  33614. }
  33615. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33616. fields = append(fields, usagetotal.FieldStartIndex)
  33617. }
  33618. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33619. fields = append(fields, usagetotal.FieldEndIndex)
  33620. }
  33621. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33622. fields = append(fields, usagetotal.FieldOrganizationID)
  33623. }
  33624. return fields
  33625. }
  33626. // FieldCleared returns a boolean indicating if a field with the given name was
  33627. // cleared in this mutation.
  33628. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33629. _, ok := m.clearedFields[name]
  33630. return ok
  33631. }
  33632. // ClearField clears the value of the field with the given name. It returns an
  33633. // error if the field is not defined in the schema.
  33634. func (m *UsageTotalMutation) ClearField(name string) error {
  33635. switch name {
  33636. case usagetotal.FieldStatus:
  33637. m.ClearStatus()
  33638. return nil
  33639. case usagetotal.FieldType:
  33640. m.ClearType()
  33641. return nil
  33642. case usagetotal.FieldTotalTokens:
  33643. m.ClearTotalTokens()
  33644. return nil
  33645. case usagetotal.FieldStartIndex:
  33646. m.ClearStartIndex()
  33647. return nil
  33648. case usagetotal.FieldEndIndex:
  33649. m.ClearEndIndex()
  33650. return nil
  33651. case usagetotal.FieldOrganizationID:
  33652. m.ClearOrganizationID()
  33653. return nil
  33654. }
  33655. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33656. }
  33657. // ResetField resets all changes in the mutation for the field with the given name.
  33658. // It returns an error if the field is not defined in the schema.
  33659. func (m *UsageTotalMutation) ResetField(name string) error {
  33660. switch name {
  33661. case usagetotal.FieldCreatedAt:
  33662. m.ResetCreatedAt()
  33663. return nil
  33664. case usagetotal.FieldUpdatedAt:
  33665. m.ResetUpdatedAt()
  33666. return nil
  33667. case usagetotal.FieldStatus:
  33668. m.ResetStatus()
  33669. return nil
  33670. case usagetotal.FieldType:
  33671. m.ResetType()
  33672. return nil
  33673. case usagetotal.FieldBotID:
  33674. m.ResetBotID()
  33675. return nil
  33676. case usagetotal.FieldTotalTokens:
  33677. m.ResetTotalTokens()
  33678. return nil
  33679. case usagetotal.FieldStartIndex:
  33680. m.ResetStartIndex()
  33681. return nil
  33682. case usagetotal.FieldEndIndex:
  33683. m.ResetEndIndex()
  33684. return nil
  33685. case usagetotal.FieldOrganizationID:
  33686. m.ResetOrganizationID()
  33687. return nil
  33688. }
  33689. return fmt.Errorf("unknown UsageTotal field %s", name)
  33690. }
  33691. // AddedEdges returns all edge names that were set/added in this mutation.
  33692. func (m *UsageTotalMutation) AddedEdges() []string {
  33693. edges := make([]string, 0, 0)
  33694. return edges
  33695. }
  33696. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33697. // name in this mutation.
  33698. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33699. return nil
  33700. }
  33701. // RemovedEdges returns all edge names that were removed in this mutation.
  33702. func (m *UsageTotalMutation) RemovedEdges() []string {
  33703. edges := make([]string, 0, 0)
  33704. return edges
  33705. }
  33706. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33707. // the given name in this mutation.
  33708. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33709. return nil
  33710. }
  33711. // ClearedEdges returns all edge names that were cleared in this mutation.
  33712. func (m *UsageTotalMutation) ClearedEdges() []string {
  33713. edges := make([]string, 0, 0)
  33714. return edges
  33715. }
  33716. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33717. // was cleared in this mutation.
  33718. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33719. return false
  33720. }
  33721. // ClearEdge clears the value of the edge with the given name. It returns an error
  33722. // if that edge is not defined in the schema.
  33723. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33724. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33725. }
  33726. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33727. // It returns an error if the edge is not defined in the schema.
  33728. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33729. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33730. }
  33731. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33732. type WhatsappMutation struct {
  33733. config
  33734. op Op
  33735. typ string
  33736. id *uint64
  33737. created_at *time.Time
  33738. updated_at *time.Time
  33739. status *uint8
  33740. addstatus *int8
  33741. deleted_at *time.Time
  33742. ak *string
  33743. sk *string
  33744. callback *string
  33745. account *string
  33746. nickname *string
  33747. phone *string
  33748. organization_id *uint64
  33749. addorganization_id *int64
  33750. api_base *string
  33751. api_key *string
  33752. allow_list *[]string
  33753. appendallow_list []string
  33754. group_allow_list *[]string
  33755. appendgroup_allow_list []string
  33756. block_list *[]string
  33757. appendblock_list []string
  33758. group_block_list *[]string
  33759. appendgroup_block_list []string
  33760. clearedFields map[string]struct{}
  33761. agent *uint64
  33762. clearedagent bool
  33763. done bool
  33764. oldValue func(context.Context) (*Whatsapp, error)
  33765. predicates []predicate.Whatsapp
  33766. }
  33767. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33768. // whatsappOption allows management of the mutation configuration using functional options.
  33769. type whatsappOption func(*WhatsappMutation)
  33770. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33771. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33772. m := &WhatsappMutation{
  33773. config: c,
  33774. op: op,
  33775. typ: TypeWhatsapp,
  33776. clearedFields: make(map[string]struct{}),
  33777. }
  33778. for _, opt := range opts {
  33779. opt(m)
  33780. }
  33781. return m
  33782. }
  33783. // withWhatsappID sets the ID field of the mutation.
  33784. func withWhatsappID(id uint64) whatsappOption {
  33785. return func(m *WhatsappMutation) {
  33786. var (
  33787. err error
  33788. once sync.Once
  33789. value *Whatsapp
  33790. )
  33791. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33792. once.Do(func() {
  33793. if m.done {
  33794. err = errors.New("querying old values post mutation is not allowed")
  33795. } else {
  33796. value, err = m.Client().Whatsapp.Get(ctx, id)
  33797. }
  33798. })
  33799. return value, err
  33800. }
  33801. m.id = &id
  33802. }
  33803. }
  33804. // withWhatsapp sets the old Whatsapp of the mutation.
  33805. func withWhatsapp(node *Whatsapp) whatsappOption {
  33806. return func(m *WhatsappMutation) {
  33807. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33808. return node, nil
  33809. }
  33810. m.id = &node.ID
  33811. }
  33812. }
  33813. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33814. // executed in a transaction (ent.Tx), a transactional client is returned.
  33815. func (m WhatsappMutation) Client() *Client {
  33816. client := &Client{config: m.config}
  33817. client.init()
  33818. return client
  33819. }
  33820. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33821. // it returns an error otherwise.
  33822. func (m WhatsappMutation) Tx() (*Tx, error) {
  33823. if _, ok := m.driver.(*txDriver); !ok {
  33824. return nil, errors.New("ent: mutation is not running in a transaction")
  33825. }
  33826. tx := &Tx{config: m.config}
  33827. tx.init()
  33828. return tx, nil
  33829. }
  33830. // SetID sets the value of the id field. Note that this
  33831. // operation is only accepted on creation of Whatsapp entities.
  33832. func (m *WhatsappMutation) SetID(id uint64) {
  33833. m.id = &id
  33834. }
  33835. // ID returns the ID value in the mutation. Note that the ID is only available
  33836. // if it was provided to the builder or after it was returned from the database.
  33837. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33838. if m.id == nil {
  33839. return
  33840. }
  33841. return *m.id, true
  33842. }
  33843. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33844. // That means, if the mutation is applied within a transaction with an isolation level such
  33845. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33846. // or updated by the mutation.
  33847. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33848. switch {
  33849. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33850. id, exists := m.ID()
  33851. if exists {
  33852. return []uint64{id}, nil
  33853. }
  33854. fallthrough
  33855. case m.op.Is(OpUpdate | OpDelete):
  33856. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33857. default:
  33858. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33859. }
  33860. }
  33861. // SetCreatedAt sets the "created_at" field.
  33862. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33863. m.created_at = &t
  33864. }
  33865. // CreatedAt returns the value of the "created_at" field in the mutation.
  33866. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33867. v := m.created_at
  33868. if v == nil {
  33869. return
  33870. }
  33871. return *v, true
  33872. }
  33873. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33874. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33876. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33877. if !m.op.Is(OpUpdateOne) {
  33878. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33879. }
  33880. if m.id == nil || m.oldValue == nil {
  33881. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33882. }
  33883. oldValue, err := m.oldValue(ctx)
  33884. if err != nil {
  33885. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33886. }
  33887. return oldValue.CreatedAt, nil
  33888. }
  33889. // ResetCreatedAt resets all changes to the "created_at" field.
  33890. func (m *WhatsappMutation) ResetCreatedAt() {
  33891. m.created_at = nil
  33892. }
  33893. // SetUpdatedAt sets the "updated_at" field.
  33894. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33895. m.updated_at = &t
  33896. }
  33897. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33898. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33899. v := m.updated_at
  33900. if v == nil {
  33901. return
  33902. }
  33903. return *v, true
  33904. }
  33905. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33906. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33908. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33909. if !m.op.Is(OpUpdateOne) {
  33910. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33911. }
  33912. if m.id == nil || m.oldValue == nil {
  33913. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33914. }
  33915. oldValue, err := m.oldValue(ctx)
  33916. if err != nil {
  33917. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33918. }
  33919. return oldValue.UpdatedAt, nil
  33920. }
  33921. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33922. func (m *WhatsappMutation) ResetUpdatedAt() {
  33923. m.updated_at = nil
  33924. }
  33925. // SetStatus sets the "status" field.
  33926. func (m *WhatsappMutation) SetStatus(u uint8) {
  33927. m.status = &u
  33928. m.addstatus = nil
  33929. }
  33930. // Status returns the value of the "status" field in the mutation.
  33931. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33932. v := m.status
  33933. if v == nil {
  33934. return
  33935. }
  33936. return *v, true
  33937. }
  33938. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33939. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33941. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33942. if !m.op.Is(OpUpdateOne) {
  33943. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33944. }
  33945. if m.id == nil || m.oldValue == nil {
  33946. return v, errors.New("OldStatus requires an ID field in the mutation")
  33947. }
  33948. oldValue, err := m.oldValue(ctx)
  33949. if err != nil {
  33950. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33951. }
  33952. return oldValue.Status, nil
  33953. }
  33954. // AddStatus adds u to the "status" field.
  33955. func (m *WhatsappMutation) AddStatus(u int8) {
  33956. if m.addstatus != nil {
  33957. *m.addstatus += u
  33958. } else {
  33959. m.addstatus = &u
  33960. }
  33961. }
  33962. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33963. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33964. v := m.addstatus
  33965. if v == nil {
  33966. return
  33967. }
  33968. return *v, true
  33969. }
  33970. // ClearStatus clears the value of the "status" field.
  33971. func (m *WhatsappMutation) ClearStatus() {
  33972. m.status = nil
  33973. m.addstatus = nil
  33974. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33975. }
  33976. // StatusCleared returns if the "status" field was cleared in this mutation.
  33977. func (m *WhatsappMutation) StatusCleared() bool {
  33978. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33979. return ok
  33980. }
  33981. // ResetStatus resets all changes to the "status" field.
  33982. func (m *WhatsappMutation) ResetStatus() {
  33983. m.status = nil
  33984. m.addstatus = nil
  33985. delete(m.clearedFields, whatsapp.FieldStatus)
  33986. }
  33987. // SetDeletedAt sets the "deleted_at" field.
  33988. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33989. m.deleted_at = &t
  33990. }
  33991. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33992. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33993. v := m.deleted_at
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  34000. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34012. }
  34013. return oldValue.DeletedAt, nil
  34014. }
  34015. // ClearDeletedAt clears the value of the "deleted_at" field.
  34016. func (m *WhatsappMutation) ClearDeletedAt() {
  34017. m.deleted_at = nil
  34018. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34019. }
  34020. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34021. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34022. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34023. return ok
  34024. }
  34025. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34026. func (m *WhatsappMutation) ResetDeletedAt() {
  34027. m.deleted_at = nil
  34028. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34029. }
  34030. // SetAk sets the "ak" field.
  34031. func (m *WhatsappMutation) SetAk(s string) {
  34032. m.ak = &s
  34033. }
  34034. // Ak returns the value of the "ak" field in the mutation.
  34035. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  34036. v := m.ak
  34037. if v == nil {
  34038. return
  34039. }
  34040. return *v, true
  34041. }
  34042. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  34043. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34045. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  34046. if !m.op.Is(OpUpdateOne) {
  34047. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  34048. }
  34049. if m.id == nil || m.oldValue == nil {
  34050. return v, errors.New("OldAk requires an ID field in the mutation")
  34051. }
  34052. oldValue, err := m.oldValue(ctx)
  34053. if err != nil {
  34054. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  34055. }
  34056. return oldValue.Ak, nil
  34057. }
  34058. // ClearAk clears the value of the "ak" field.
  34059. func (m *WhatsappMutation) ClearAk() {
  34060. m.ak = nil
  34061. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  34062. }
  34063. // AkCleared returns if the "ak" field was cleared in this mutation.
  34064. func (m *WhatsappMutation) AkCleared() bool {
  34065. _, ok := m.clearedFields[whatsapp.FieldAk]
  34066. return ok
  34067. }
  34068. // ResetAk resets all changes to the "ak" field.
  34069. func (m *WhatsappMutation) ResetAk() {
  34070. m.ak = nil
  34071. delete(m.clearedFields, whatsapp.FieldAk)
  34072. }
  34073. // SetSk sets the "sk" field.
  34074. func (m *WhatsappMutation) SetSk(s string) {
  34075. m.sk = &s
  34076. }
  34077. // Sk returns the value of the "sk" field in the mutation.
  34078. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  34079. v := m.sk
  34080. if v == nil {
  34081. return
  34082. }
  34083. return *v, true
  34084. }
  34085. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  34086. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34088. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  34089. if !m.op.Is(OpUpdateOne) {
  34090. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  34091. }
  34092. if m.id == nil || m.oldValue == nil {
  34093. return v, errors.New("OldSk requires an ID field in the mutation")
  34094. }
  34095. oldValue, err := m.oldValue(ctx)
  34096. if err != nil {
  34097. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  34098. }
  34099. return oldValue.Sk, nil
  34100. }
  34101. // ResetSk resets all changes to the "sk" field.
  34102. func (m *WhatsappMutation) ResetSk() {
  34103. m.sk = nil
  34104. }
  34105. // SetCallback sets the "callback" field.
  34106. func (m *WhatsappMutation) SetCallback(s string) {
  34107. m.callback = &s
  34108. }
  34109. // Callback returns the value of the "callback" field in the mutation.
  34110. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34111. v := m.callback
  34112. if v == nil {
  34113. return
  34114. }
  34115. return *v, true
  34116. }
  34117. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34118. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34120. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34121. if !m.op.Is(OpUpdateOne) {
  34122. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34123. }
  34124. if m.id == nil || m.oldValue == nil {
  34125. return v, errors.New("OldCallback requires an ID field in the mutation")
  34126. }
  34127. oldValue, err := m.oldValue(ctx)
  34128. if err != nil {
  34129. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34130. }
  34131. return oldValue.Callback, nil
  34132. }
  34133. // ClearCallback clears the value of the "callback" field.
  34134. func (m *WhatsappMutation) ClearCallback() {
  34135. m.callback = nil
  34136. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34137. }
  34138. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34139. func (m *WhatsappMutation) CallbackCleared() bool {
  34140. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34141. return ok
  34142. }
  34143. // ResetCallback resets all changes to the "callback" field.
  34144. func (m *WhatsappMutation) ResetCallback() {
  34145. m.callback = nil
  34146. delete(m.clearedFields, whatsapp.FieldCallback)
  34147. }
  34148. // SetAccount sets the "account" field.
  34149. func (m *WhatsappMutation) SetAccount(s string) {
  34150. m.account = &s
  34151. }
  34152. // Account returns the value of the "account" field in the mutation.
  34153. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34154. v := m.account
  34155. if v == nil {
  34156. return
  34157. }
  34158. return *v, true
  34159. }
  34160. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34161. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34163. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34164. if !m.op.Is(OpUpdateOne) {
  34165. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34166. }
  34167. if m.id == nil || m.oldValue == nil {
  34168. return v, errors.New("OldAccount requires an ID field in the mutation")
  34169. }
  34170. oldValue, err := m.oldValue(ctx)
  34171. if err != nil {
  34172. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34173. }
  34174. return oldValue.Account, nil
  34175. }
  34176. // ClearAccount clears the value of the "account" field.
  34177. func (m *WhatsappMutation) ClearAccount() {
  34178. m.account = nil
  34179. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34180. }
  34181. // AccountCleared returns if the "account" field was cleared in this mutation.
  34182. func (m *WhatsappMutation) AccountCleared() bool {
  34183. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34184. return ok
  34185. }
  34186. // ResetAccount resets all changes to the "account" field.
  34187. func (m *WhatsappMutation) ResetAccount() {
  34188. m.account = nil
  34189. delete(m.clearedFields, whatsapp.FieldAccount)
  34190. }
  34191. // SetNickname sets the "nickname" field.
  34192. func (m *WhatsappMutation) SetNickname(s string) {
  34193. m.nickname = &s
  34194. }
  34195. // Nickname returns the value of the "nickname" field in the mutation.
  34196. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34197. v := m.nickname
  34198. if v == nil {
  34199. return
  34200. }
  34201. return *v, true
  34202. }
  34203. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34204. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34206. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34207. if !m.op.Is(OpUpdateOne) {
  34208. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34209. }
  34210. if m.id == nil || m.oldValue == nil {
  34211. return v, errors.New("OldNickname requires an ID field in the mutation")
  34212. }
  34213. oldValue, err := m.oldValue(ctx)
  34214. if err != nil {
  34215. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34216. }
  34217. return oldValue.Nickname, nil
  34218. }
  34219. // ResetNickname resets all changes to the "nickname" field.
  34220. func (m *WhatsappMutation) ResetNickname() {
  34221. m.nickname = nil
  34222. }
  34223. // SetPhone sets the "phone" field.
  34224. func (m *WhatsappMutation) SetPhone(s string) {
  34225. m.phone = &s
  34226. }
  34227. // Phone returns the value of the "phone" field in the mutation.
  34228. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34229. v := m.phone
  34230. if v == nil {
  34231. return
  34232. }
  34233. return *v, true
  34234. }
  34235. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34236. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34238. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34239. if !m.op.Is(OpUpdateOne) {
  34240. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34241. }
  34242. if m.id == nil || m.oldValue == nil {
  34243. return v, errors.New("OldPhone requires an ID field in the mutation")
  34244. }
  34245. oldValue, err := m.oldValue(ctx)
  34246. if err != nil {
  34247. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34248. }
  34249. return oldValue.Phone, nil
  34250. }
  34251. // ResetPhone resets all changes to the "phone" field.
  34252. func (m *WhatsappMutation) ResetPhone() {
  34253. m.phone = nil
  34254. }
  34255. // SetOrganizationID sets the "organization_id" field.
  34256. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34257. m.organization_id = &u
  34258. m.addorganization_id = nil
  34259. }
  34260. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34261. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34262. v := m.organization_id
  34263. if v == nil {
  34264. return
  34265. }
  34266. return *v, true
  34267. }
  34268. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34269. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34271. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34272. if !m.op.Is(OpUpdateOne) {
  34273. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34274. }
  34275. if m.id == nil || m.oldValue == nil {
  34276. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34277. }
  34278. oldValue, err := m.oldValue(ctx)
  34279. if err != nil {
  34280. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34281. }
  34282. return oldValue.OrganizationID, nil
  34283. }
  34284. // AddOrganizationID adds u to the "organization_id" field.
  34285. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34286. if m.addorganization_id != nil {
  34287. *m.addorganization_id += u
  34288. } else {
  34289. m.addorganization_id = &u
  34290. }
  34291. }
  34292. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34293. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34294. v := m.addorganization_id
  34295. if v == nil {
  34296. return
  34297. }
  34298. return *v, true
  34299. }
  34300. // ClearOrganizationID clears the value of the "organization_id" field.
  34301. func (m *WhatsappMutation) ClearOrganizationID() {
  34302. m.organization_id = nil
  34303. m.addorganization_id = nil
  34304. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34305. }
  34306. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34307. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34308. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34309. return ok
  34310. }
  34311. // ResetOrganizationID resets all changes to the "organization_id" field.
  34312. func (m *WhatsappMutation) ResetOrganizationID() {
  34313. m.organization_id = nil
  34314. m.addorganization_id = nil
  34315. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34316. }
  34317. // SetAgentID sets the "agent_id" field.
  34318. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34319. m.agent = &u
  34320. }
  34321. // AgentID returns the value of the "agent_id" field in the mutation.
  34322. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34323. v := m.agent
  34324. if v == nil {
  34325. return
  34326. }
  34327. return *v, true
  34328. }
  34329. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34330. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34332. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34333. if !m.op.Is(OpUpdateOne) {
  34334. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34335. }
  34336. if m.id == nil || m.oldValue == nil {
  34337. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34338. }
  34339. oldValue, err := m.oldValue(ctx)
  34340. if err != nil {
  34341. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34342. }
  34343. return oldValue.AgentID, nil
  34344. }
  34345. // ResetAgentID resets all changes to the "agent_id" field.
  34346. func (m *WhatsappMutation) ResetAgentID() {
  34347. m.agent = nil
  34348. }
  34349. // SetAPIBase sets the "api_base" field.
  34350. func (m *WhatsappMutation) SetAPIBase(s string) {
  34351. m.api_base = &s
  34352. }
  34353. // APIBase returns the value of the "api_base" field in the mutation.
  34354. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34355. v := m.api_base
  34356. if v == nil {
  34357. return
  34358. }
  34359. return *v, true
  34360. }
  34361. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34362. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34364. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34365. if !m.op.Is(OpUpdateOne) {
  34366. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34367. }
  34368. if m.id == nil || m.oldValue == nil {
  34369. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34370. }
  34371. oldValue, err := m.oldValue(ctx)
  34372. if err != nil {
  34373. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34374. }
  34375. return oldValue.APIBase, nil
  34376. }
  34377. // ClearAPIBase clears the value of the "api_base" field.
  34378. func (m *WhatsappMutation) ClearAPIBase() {
  34379. m.api_base = nil
  34380. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34381. }
  34382. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34383. func (m *WhatsappMutation) APIBaseCleared() bool {
  34384. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34385. return ok
  34386. }
  34387. // ResetAPIBase resets all changes to the "api_base" field.
  34388. func (m *WhatsappMutation) ResetAPIBase() {
  34389. m.api_base = nil
  34390. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34391. }
  34392. // SetAPIKey sets the "api_key" field.
  34393. func (m *WhatsappMutation) SetAPIKey(s string) {
  34394. m.api_key = &s
  34395. }
  34396. // APIKey returns the value of the "api_key" field in the mutation.
  34397. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34398. v := m.api_key
  34399. if v == nil {
  34400. return
  34401. }
  34402. return *v, true
  34403. }
  34404. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34405. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34407. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34408. if !m.op.Is(OpUpdateOne) {
  34409. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34410. }
  34411. if m.id == nil || m.oldValue == nil {
  34412. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34413. }
  34414. oldValue, err := m.oldValue(ctx)
  34415. if err != nil {
  34416. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34417. }
  34418. return oldValue.APIKey, nil
  34419. }
  34420. // ClearAPIKey clears the value of the "api_key" field.
  34421. func (m *WhatsappMutation) ClearAPIKey() {
  34422. m.api_key = nil
  34423. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34424. }
  34425. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34426. func (m *WhatsappMutation) APIKeyCleared() bool {
  34427. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34428. return ok
  34429. }
  34430. // ResetAPIKey resets all changes to the "api_key" field.
  34431. func (m *WhatsappMutation) ResetAPIKey() {
  34432. m.api_key = nil
  34433. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34434. }
  34435. // SetAllowList sets the "allow_list" field.
  34436. func (m *WhatsappMutation) SetAllowList(s []string) {
  34437. m.allow_list = &s
  34438. m.appendallow_list = nil
  34439. }
  34440. // AllowList returns the value of the "allow_list" field in the mutation.
  34441. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34442. v := m.allow_list
  34443. if v == nil {
  34444. return
  34445. }
  34446. return *v, true
  34447. }
  34448. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34449. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34451. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34452. if !m.op.Is(OpUpdateOne) {
  34453. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34454. }
  34455. if m.id == nil || m.oldValue == nil {
  34456. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34457. }
  34458. oldValue, err := m.oldValue(ctx)
  34459. if err != nil {
  34460. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34461. }
  34462. return oldValue.AllowList, nil
  34463. }
  34464. // AppendAllowList adds s to the "allow_list" field.
  34465. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34466. m.appendallow_list = append(m.appendallow_list, s...)
  34467. }
  34468. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34469. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34470. if len(m.appendallow_list) == 0 {
  34471. return nil, false
  34472. }
  34473. return m.appendallow_list, true
  34474. }
  34475. // ClearAllowList clears the value of the "allow_list" field.
  34476. func (m *WhatsappMutation) ClearAllowList() {
  34477. m.allow_list = nil
  34478. m.appendallow_list = nil
  34479. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34480. }
  34481. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34482. func (m *WhatsappMutation) AllowListCleared() bool {
  34483. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34484. return ok
  34485. }
  34486. // ResetAllowList resets all changes to the "allow_list" field.
  34487. func (m *WhatsappMutation) ResetAllowList() {
  34488. m.allow_list = nil
  34489. m.appendallow_list = nil
  34490. delete(m.clearedFields, whatsapp.FieldAllowList)
  34491. }
  34492. // SetGroupAllowList sets the "group_allow_list" field.
  34493. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34494. m.group_allow_list = &s
  34495. m.appendgroup_allow_list = nil
  34496. }
  34497. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34498. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34499. v := m.group_allow_list
  34500. if v == nil {
  34501. return
  34502. }
  34503. return *v, true
  34504. }
  34505. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34506. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34508. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34509. if !m.op.Is(OpUpdateOne) {
  34510. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34511. }
  34512. if m.id == nil || m.oldValue == nil {
  34513. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34514. }
  34515. oldValue, err := m.oldValue(ctx)
  34516. if err != nil {
  34517. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34518. }
  34519. return oldValue.GroupAllowList, nil
  34520. }
  34521. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34522. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34523. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34524. }
  34525. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34526. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34527. if len(m.appendgroup_allow_list) == 0 {
  34528. return nil, false
  34529. }
  34530. return m.appendgroup_allow_list, true
  34531. }
  34532. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34533. func (m *WhatsappMutation) ClearGroupAllowList() {
  34534. m.group_allow_list = nil
  34535. m.appendgroup_allow_list = nil
  34536. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34537. }
  34538. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34539. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34540. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34541. return ok
  34542. }
  34543. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34544. func (m *WhatsappMutation) ResetGroupAllowList() {
  34545. m.group_allow_list = nil
  34546. m.appendgroup_allow_list = nil
  34547. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34548. }
  34549. // SetBlockList sets the "block_list" field.
  34550. func (m *WhatsappMutation) SetBlockList(s []string) {
  34551. m.block_list = &s
  34552. m.appendblock_list = nil
  34553. }
  34554. // BlockList returns the value of the "block_list" field in the mutation.
  34555. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34556. v := m.block_list
  34557. if v == nil {
  34558. return
  34559. }
  34560. return *v, true
  34561. }
  34562. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34563. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34565. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34566. if !m.op.Is(OpUpdateOne) {
  34567. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34568. }
  34569. if m.id == nil || m.oldValue == nil {
  34570. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34571. }
  34572. oldValue, err := m.oldValue(ctx)
  34573. if err != nil {
  34574. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34575. }
  34576. return oldValue.BlockList, nil
  34577. }
  34578. // AppendBlockList adds s to the "block_list" field.
  34579. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34580. m.appendblock_list = append(m.appendblock_list, s...)
  34581. }
  34582. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34583. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34584. if len(m.appendblock_list) == 0 {
  34585. return nil, false
  34586. }
  34587. return m.appendblock_list, true
  34588. }
  34589. // ClearBlockList clears the value of the "block_list" field.
  34590. func (m *WhatsappMutation) ClearBlockList() {
  34591. m.block_list = nil
  34592. m.appendblock_list = nil
  34593. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34594. }
  34595. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34596. func (m *WhatsappMutation) BlockListCleared() bool {
  34597. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34598. return ok
  34599. }
  34600. // ResetBlockList resets all changes to the "block_list" field.
  34601. func (m *WhatsappMutation) ResetBlockList() {
  34602. m.block_list = nil
  34603. m.appendblock_list = nil
  34604. delete(m.clearedFields, whatsapp.FieldBlockList)
  34605. }
  34606. // SetGroupBlockList sets the "group_block_list" field.
  34607. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34608. m.group_block_list = &s
  34609. m.appendgroup_block_list = nil
  34610. }
  34611. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34612. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34613. v := m.group_block_list
  34614. if v == nil {
  34615. return
  34616. }
  34617. return *v, true
  34618. }
  34619. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34620. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34622. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34623. if !m.op.Is(OpUpdateOne) {
  34624. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34625. }
  34626. if m.id == nil || m.oldValue == nil {
  34627. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34628. }
  34629. oldValue, err := m.oldValue(ctx)
  34630. if err != nil {
  34631. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34632. }
  34633. return oldValue.GroupBlockList, nil
  34634. }
  34635. // AppendGroupBlockList adds s to the "group_block_list" field.
  34636. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34637. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34638. }
  34639. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34640. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34641. if len(m.appendgroup_block_list) == 0 {
  34642. return nil, false
  34643. }
  34644. return m.appendgroup_block_list, true
  34645. }
  34646. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34647. func (m *WhatsappMutation) ClearGroupBlockList() {
  34648. m.group_block_list = nil
  34649. m.appendgroup_block_list = nil
  34650. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34651. }
  34652. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34653. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34654. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34655. return ok
  34656. }
  34657. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34658. func (m *WhatsappMutation) ResetGroupBlockList() {
  34659. m.group_block_list = nil
  34660. m.appendgroup_block_list = nil
  34661. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34662. }
  34663. // ClearAgent clears the "agent" edge to the Agent entity.
  34664. func (m *WhatsappMutation) ClearAgent() {
  34665. m.clearedagent = true
  34666. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34667. }
  34668. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34669. func (m *WhatsappMutation) AgentCleared() bool {
  34670. return m.clearedagent
  34671. }
  34672. // AgentIDs returns the "agent" edge IDs in the mutation.
  34673. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34674. // AgentID instead. It exists only for internal usage by the builders.
  34675. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34676. if id := m.agent; id != nil {
  34677. ids = append(ids, *id)
  34678. }
  34679. return
  34680. }
  34681. // ResetAgent resets all changes to the "agent" edge.
  34682. func (m *WhatsappMutation) ResetAgent() {
  34683. m.agent = nil
  34684. m.clearedagent = false
  34685. }
  34686. // Where appends a list predicates to the WhatsappMutation builder.
  34687. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34688. m.predicates = append(m.predicates, ps...)
  34689. }
  34690. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34691. // users can use type-assertion to append predicates that do not depend on any generated package.
  34692. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34693. p := make([]predicate.Whatsapp, len(ps))
  34694. for i := range ps {
  34695. p[i] = ps[i]
  34696. }
  34697. m.Where(p...)
  34698. }
  34699. // Op returns the operation name.
  34700. func (m *WhatsappMutation) Op() Op {
  34701. return m.op
  34702. }
  34703. // SetOp allows setting the mutation operation.
  34704. func (m *WhatsappMutation) SetOp(op Op) {
  34705. m.op = op
  34706. }
  34707. // Type returns the node type of this mutation (Whatsapp).
  34708. func (m *WhatsappMutation) Type() string {
  34709. return m.typ
  34710. }
  34711. // Fields returns all fields that were changed during this mutation. Note that in
  34712. // order to get all numeric fields that were incremented/decremented, call
  34713. // AddedFields().
  34714. func (m *WhatsappMutation) Fields() []string {
  34715. fields := make([]string, 0, 18)
  34716. if m.created_at != nil {
  34717. fields = append(fields, whatsapp.FieldCreatedAt)
  34718. }
  34719. if m.updated_at != nil {
  34720. fields = append(fields, whatsapp.FieldUpdatedAt)
  34721. }
  34722. if m.status != nil {
  34723. fields = append(fields, whatsapp.FieldStatus)
  34724. }
  34725. if m.deleted_at != nil {
  34726. fields = append(fields, whatsapp.FieldDeletedAt)
  34727. }
  34728. if m.ak != nil {
  34729. fields = append(fields, whatsapp.FieldAk)
  34730. }
  34731. if m.sk != nil {
  34732. fields = append(fields, whatsapp.FieldSk)
  34733. }
  34734. if m.callback != nil {
  34735. fields = append(fields, whatsapp.FieldCallback)
  34736. }
  34737. if m.account != nil {
  34738. fields = append(fields, whatsapp.FieldAccount)
  34739. }
  34740. if m.nickname != nil {
  34741. fields = append(fields, whatsapp.FieldNickname)
  34742. }
  34743. if m.phone != nil {
  34744. fields = append(fields, whatsapp.FieldPhone)
  34745. }
  34746. if m.organization_id != nil {
  34747. fields = append(fields, whatsapp.FieldOrganizationID)
  34748. }
  34749. if m.agent != nil {
  34750. fields = append(fields, whatsapp.FieldAgentID)
  34751. }
  34752. if m.api_base != nil {
  34753. fields = append(fields, whatsapp.FieldAPIBase)
  34754. }
  34755. if m.api_key != nil {
  34756. fields = append(fields, whatsapp.FieldAPIKey)
  34757. }
  34758. if m.allow_list != nil {
  34759. fields = append(fields, whatsapp.FieldAllowList)
  34760. }
  34761. if m.group_allow_list != nil {
  34762. fields = append(fields, whatsapp.FieldGroupAllowList)
  34763. }
  34764. if m.block_list != nil {
  34765. fields = append(fields, whatsapp.FieldBlockList)
  34766. }
  34767. if m.group_block_list != nil {
  34768. fields = append(fields, whatsapp.FieldGroupBlockList)
  34769. }
  34770. return fields
  34771. }
  34772. // Field returns the value of a field with the given name. The second boolean
  34773. // return value indicates that this field was not set, or was not defined in the
  34774. // schema.
  34775. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34776. switch name {
  34777. case whatsapp.FieldCreatedAt:
  34778. return m.CreatedAt()
  34779. case whatsapp.FieldUpdatedAt:
  34780. return m.UpdatedAt()
  34781. case whatsapp.FieldStatus:
  34782. return m.Status()
  34783. case whatsapp.FieldDeletedAt:
  34784. return m.DeletedAt()
  34785. case whatsapp.FieldAk:
  34786. return m.Ak()
  34787. case whatsapp.FieldSk:
  34788. return m.Sk()
  34789. case whatsapp.FieldCallback:
  34790. return m.Callback()
  34791. case whatsapp.FieldAccount:
  34792. return m.Account()
  34793. case whatsapp.FieldNickname:
  34794. return m.Nickname()
  34795. case whatsapp.FieldPhone:
  34796. return m.Phone()
  34797. case whatsapp.FieldOrganizationID:
  34798. return m.OrganizationID()
  34799. case whatsapp.FieldAgentID:
  34800. return m.AgentID()
  34801. case whatsapp.FieldAPIBase:
  34802. return m.APIBase()
  34803. case whatsapp.FieldAPIKey:
  34804. return m.APIKey()
  34805. case whatsapp.FieldAllowList:
  34806. return m.AllowList()
  34807. case whatsapp.FieldGroupAllowList:
  34808. return m.GroupAllowList()
  34809. case whatsapp.FieldBlockList:
  34810. return m.BlockList()
  34811. case whatsapp.FieldGroupBlockList:
  34812. return m.GroupBlockList()
  34813. }
  34814. return nil, false
  34815. }
  34816. // OldField returns the old value of the field from the database. An error is
  34817. // returned if the mutation operation is not UpdateOne, or the query to the
  34818. // database failed.
  34819. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34820. switch name {
  34821. case whatsapp.FieldCreatedAt:
  34822. return m.OldCreatedAt(ctx)
  34823. case whatsapp.FieldUpdatedAt:
  34824. return m.OldUpdatedAt(ctx)
  34825. case whatsapp.FieldStatus:
  34826. return m.OldStatus(ctx)
  34827. case whatsapp.FieldDeletedAt:
  34828. return m.OldDeletedAt(ctx)
  34829. case whatsapp.FieldAk:
  34830. return m.OldAk(ctx)
  34831. case whatsapp.FieldSk:
  34832. return m.OldSk(ctx)
  34833. case whatsapp.FieldCallback:
  34834. return m.OldCallback(ctx)
  34835. case whatsapp.FieldAccount:
  34836. return m.OldAccount(ctx)
  34837. case whatsapp.FieldNickname:
  34838. return m.OldNickname(ctx)
  34839. case whatsapp.FieldPhone:
  34840. return m.OldPhone(ctx)
  34841. case whatsapp.FieldOrganizationID:
  34842. return m.OldOrganizationID(ctx)
  34843. case whatsapp.FieldAgentID:
  34844. return m.OldAgentID(ctx)
  34845. case whatsapp.FieldAPIBase:
  34846. return m.OldAPIBase(ctx)
  34847. case whatsapp.FieldAPIKey:
  34848. return m.OldAPIKey(ctx)
  34849. case whatsapp.FieldAllowList:
  34850. return m.OldAllowList(ctx)
  34851. case whatsapp.FieldGroupAllowList:
  34852. return m.OldGroupAllowList(ctx)
  34853. case whatsapp.FieldBlockList:
  34854. return m.OldBlockList(ctx)
  34855. case whatsapp.FieldGroupBlockList:
  34856. return m.OldGroupBlockList(ctx)
  34857. }
  34858. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34859. }
  34860. // SetField sets the value of a field with the given name. It returns an error if
  34861. // the field is not defined in the schema, or if the type mismatched the field
  34862. // type.
  34863. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34864. switch name {
  34865. case whatsapp.FieldCreatedAt:
  34866. v, ok := value.(time.Time)
  34867. if !ok {
  34868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34869. }
  34870. m.SetCreatedAt(v)
  34871. return nil
  34872. case whatsapp.FieldUpdatedAt:
  34873. v, ok := value.(time.Time)
  34874. if !ok {
  34875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34876. }
  34877. m.SetUpdatedAt(v)
  34878. return nil
  34879. case whatsapp.FieldStatus:
  34880. v, ok := value.(uint8)
  34881. if !ok {
  34882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34883. }
  34884. m.SetStatus(v)
  34885. return nil
  34886. case whatsapp.FieldDeletedAt:
  34887. v, ok := value.(time.Time)
  34888. if !ok {
  34889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34890. }
  34891. m.SetDeletedAt(v)
  34892. return nil
  34893. case whatsapp.FieldAk:
  34894. v, ok := value.(string)
  34895. if !ok {
  34896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34897. }
  34898. m.SetAk(v)
  34899. return nil
  34900. case whatsapp.FieldSk:
  34901. v, ok := value.(string)
  34902. if !ok {
  34903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34904. }
  34905. m.SetSk(v)
  34906. return nil
  34907. case whatsapp.FieldCallback:
  34908. v, ok := value.(string)
  34909. if !ok {
  34910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34911. }
  34912. m.SetCallback(v)
  34913. return nil
  34914. case whatsapp.FieldAccount:
  34915. v, ok := value.(string)
  34916. if !ok {
  34917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34918. }
  34919. m.SetAccount(v)
  34920. return nil
  34921. case whatsapp.FieldNickname:
  34922. v, ok := value.(string)
  34923. if !ok {
  34924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34925. }
  34926. m.SetNickname(v)
  34927. return nil
  34928. case whatsapp.FieldPhone:
  34929. v, ok := value.(string)
  34930. if !ok {
  34931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34932. }
  34933. m.SetPhone(v)
  34934. return nil
  34935. case whatsapp.FieldOrganizationID:
  34936. v, ok := value.(uint64)
  34937. if !ok {
  34938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34939. }
  34940. m.SetOrganizationID(v)
  34941. return nil
  34942. case whatsapp.FieldAgentID:
  34943. v, ok := value.(uint64)
  34944. if !ok {
  34945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34946. }
  34947. m.SetAgentID(v)
  34948. return nil
  34949. case whatsapp.FieldAPIBase:
  34950. v, ok := value.(string)
  34951. if !ok {
  34952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34953. }
  34954. m.SetAPIBase(v)
  34955. return nil
  34956. case whatsapp.FieldAPIKey:
  34957. v, ok := value.(string)
  34958. if !ok {
  34959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34960. }
  34961. m.SetAPIKey(v)
  34962. return nil
  34963. case whatsapp.FieldAllowList:
  34964. v, ok := value.([]string)
  34965. if !ok {
  34966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34967. }
  34968. m.SetAllowList(v)
  34969. return nil
  34970. case whatsapp.FieldGroupAllowList:
  34971. v, ok := value.([]string)
  34972. if !ok {
  34973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34974. }
  34975. m.SetGroupAllowList(v)
  34976. return nil
  34977. case whatsapp.FieldBlockList:
  34978. v, ok := value.([]string)
  34979. if !ok {
  34980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34981. }
  34982. m.SetBlockList(v)
  34983. return nil
  34984. case whatsapp.FieldGroupBlockList:
  34985. v, ok := value.([]string)
  34986. if !ok {
  34987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34988. }
  34989. m.SetGroupBlockList(v)
  34990. return nil
  34991. }
  34992. return fmt.Errorf("unknown Whatsapp field %s", name)
  34993. }
  34994. // AddedFields returns all numeric fields that were incremented/decremented during
  34995. // this mutation.
  34996. func (m *WhatsappMutation) AddedFields() []string {
  34997. var fields []string
  34998. if m.addstatus != nil {
  34999. fields = append(fields, whatsapp.FieldStatus)
  35000. }
  35001. if m.addorganization_id != nil {
  35002. fields = append(fields, whatsapp.FieldOrganizationID)
  35003. }
  35004. return fields
  35005. }
  35006. // AddedField returns the numeric value that was incremented/decremented on a field
  35007. // with the given name. The second boolean return value indicates that this field
  35008. // was not set, or was not defined in the schema.
  35009. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  35010. switch name {
  35011. case whatsapp.FieldStatus:
  35012. return m.AddedStatus()
  35013. case whatsapp.FieldOrganizationID:
  35014. return m.AddedOrganizationID()
  35015. }
  35016. return nil, false
  35017. }
  35018. // AddField adds the value to the field with the given name. It returns an error if
  35019. // the field is not defined in the schema, or if the type mismatched the field
  35020. // type.
  35021. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35022. switch name {
  35023. case whatsapp.FieldStatus:
  35024. v, ok := value.(int8)
  35025. if !ok {
  35026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35027. }
  35028. m.AddStatus(v)
  35029. return nil
  35030. case whatsapp.FieldOrganizationID:
  35031. v, ok := value.(int64)
  35032. if !ok {
  35033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35034. }
  35035. m.AddOrganizationID(v)
  35036. return nil
  35037. }
  35038. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35039. }
  35040. // ClearedFields returns all nullable fields that were cleared during this
  35041. // mutation.
  35042. func (m *WhatsappMutation) ClearedFields() []string {
  35043. var fields []string
  35044. if m.FieldCleared(whatsapp.FieldStatus) {
  35045. fields = append(fields, whatsapp.FieldStatus)
  35046. }
  35047. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35048. fields = append(fields, whatsapp.FieldDeletedAt)
  35049. }
  35050. if m.FieldCleared(whatsapp.FieldAk) {
  35051. fields = append(fields, whatsapp.FieldAk)
  35052. }
  35053. if m.FieldCleared(whatsapp.FieldCallback) {
  35054. fields = append(fields, whatsapp.FieldCallback)
  35055. }
  35056. if m.FieldCleared(whatsapp.FieldAccount) {
  35057. fields = append(fields, whatsapp.FieldAccount)
  35058. }
  35059. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35060. fields = append(fields, whatsapp.FieldOrganizationID)
  35061. }
  35062. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35063. fields = append(fields, whatsapp.FieldAPIBase)
  35064. }
  35065. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35066. fields = append(fields, whatsapp.FieldAPIKey)
  35067. }
  35068. if m.FieldCleared(whatsapp.FieldAllowList) {
  35069. fields = append(fields, whatsapp.FieldAllowList)
  35070. }
  35071. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35072. fields = append(fields, whatsapp.FieldGroupAllowList)
  35073. }
  35074. if m.FieldCleared(whatsapp.FieldBlockList) {
  35075. fields = append(fields, whatsapp.FieldBlockList)
  35076. }
  35077. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35078. fields = append(fields, whatsapp.FieldGroupBlockList)
  35079. }
  35080. return fields
  35081. }
  35082. // FieldCleared returns a boolean indicating if a field with the given name was
  35083. // cleared in this mutation.
  35084. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35085. _, ok := m.clearedFields[name]
  35086. return ok
  35087. }
  35088. // ClearField clears the value of the field with the given name. It returns an
  35089. // error if the field is not defined in the schema.
  35090. func (m *WhatsappMutation) ClearField(name string) error {
  35091. switch name {
  35092. case whatsapp.FieldStatus:
  35093. m.ClearStatus()
  35094. return nil
  35095. case whatsapp.FieldDeletedAt:
  35096. m.ClearDeletedAt()
  35097. return nil
  35098. case whatsapp.FieldAk:
  35099. m.ClearAk()
  35100. return nil
  35101. case whatsapp.FieldCallback:
  35102. m.ClearCallback()
  35103. return nil
  35104. case whatsapp.FieldAccount:
  35105. m.ClearAccount()
  35106. return nil
  35107. case whatsapp.FieldOrganizationID:
  35108. m.ClearOrganizationID()
  35109. return nil
  35110. case whatsapp.FieldAPIBase:
  35111. m.ClearAPIBase()
  35112. return nil
  35113. case whatsapp.FieldAPIKey:
  35114. m.ClearAPIKey()
  35115. return nil
  35116. case whatsapp.FieldAllowList:
  35117. m.ClearAllowList()
  35118. return nil
  35119. case whatsapp.FieldGroupAllowList:
  35120. m.ClearGroupAllowList()
  35121. return nil
  35122. case whatsapp.FieldBlockList:
  35123. m.ClearBlockList()
  35124. return nil
  35125. case whatsapp.FieldGroupBlockList:
  35126. m.ClearGroupBlockList()
  35127. return nil
  35128. }
  35129. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35130. }
  35131. // ResetField resets all changes in the mutation for the field with the given name.
  35132. // It returns an error if the field is not defined in the schema.
  35133. func (m *WhatsappMutation) ResetField(name string) error {
  35134. switch name {
  35135. case whatsapp.FieldCreatedAt:
  35136. m.ResetCreatedAt()
  35137. return nil
  35138. case whatsapp.FieldUpdatedAt:
  35139. m.ResetUpdatedAt()
  35140. return nil
  35141. case whatsapp.FieldStatus:
  35142. m.ResetStatus()
  35143. return nil
  35144. case whatsapp.FieldDeletedAt:
  35145. m.ResetDeletedAt()
  35146. return nil
  35147. case whatsapp.FieldAk:
  35148. m.ResetAk()
  35149. return nil
  35150. case whatsapp.FieldSk:
  35151. m.ResetSk()
  35152. return nil
  35153. case whatsapp.FieldCallback:
  35154. m.ResetCallback()
  35155. return nil
  35156. case whatsapp.FieldAccount:
  35157. m.ResetAccount()
  35158. return nil
  35159. case whatsapp.FieldNickname:
  35160. m.ResetNickname()
  35161. return nil
  35162. case whatsapp.FieldPhone:
  35163. m.ResetPhone()
  35164. return nil
  35165. case whatsapp.FieldOrganizationID:
  35166. m.ResetOrganizationID()
  35167. return nil
  35168. case whatsapp.FieldAgentID:
  35169. m.ResetAgentID()
  35170. return nil
  35171. case whatsapp.FieldAPIBase:
  35172. m.ResetAPIBase()
  35173. return nil
  35174. case whatsapp.FieldAPIKey:
  35175. m.ResetAPIKey()
  35176. return nil
  35177. case whatsapp.FieldAllowList:
  35178. m.ResetAllowList()
  35179. return nil
  35180. case whatsapp.FieldGroupAllowList:
  35181. m.ResetGroupAllowList()
  35182. return nil
  35183. case whatsapp.FieldBlockList:
  35184. m.ResetBlockList()
  35185. return nil
  35186. case whatsapp.FieldGroupBlockList:
  35187. m.ResetGroupBlockList()
  35188. return nil
  35189. }
  35190. return fmt.Errorf("unknown Whatsapp field %s", name)
  35191. }
  35192. // AddedEdges returns all edge names that were set/added in this mutation.
  35193. func (m *WhatsappMutation) AddedEdges() []string {
  35194. edges := make([]string, 0, 1)
  35195. if m.agent != nil {
  35196. edges = append(edges, whatsapp.EdgeAgent)
  35197. }
  35198. return edges
  35199. }
  35200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35201. // name in this mutation.
  35202. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35203. switch name {
  35204. case whatsapp.EdgeAgent:
  35205. if id := m.agent; id != nil {
  35206. return []ent.Value{*id}
  35207. }
  35208. }
  35209. return nil
  35210. }
  35211. // RemovedEdges returns all edge names that were removed in this mutation.
  35212. func (m *WhatsappMutation) RemovedEdges() []string {
  35213. edges := make([]string, 0, 1)
  35214. return edges
  35215. }
  35216. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35217. // the given name in this mutation.
  35218. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35219. return nil
  35220. }
  35221. // ClearedEdges returns all edge names that were cleared in this mutation.
  35222. func (m *WhatsappMutation) ClearedEdges() []string {
  35223. edges := make([]string, 0, 1)
  35224. if m.clearedagent {
  35225. edges = append(edges, whatsapp.EdgeAgent)
  35226. }
  35227. return edges
  35228. }
  35229. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35230. // was cleared in this mutation.
  35231. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35232. switch name {
  35233. case whatsapp.EdgeAgent:
  35234. return m.clearedagent
  35235. }
  35236. return false
  35237. }
  35238. // ClearEdge clears the value of the edge with the given name. It returns an error
  35239. // if that edge is not defined in the schema.
  35240. func (m *WhatsappMutation) ClearEdge(name string) error {
  35241. switch name {
  35242. case whatsapp.EdgeAgent:
  35243. m.ClearAgent()
  35244. return nil
  35245. }
  35246. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35247. }
  35248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35249. // It returns an error if the edge is not defined in the schema.
  35250. func (m *WhatsappMutation) ResetEdge(name string) error {
  35251. switch name {
  35252. case whatsapp.EdgeAgent:
  35253. m.ResetAgent()
  35254. return nil
  35255. }
  35256. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35257. }
  35258. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35259. type WorkExperienceMutation struct {
  35260. config
  35261. op Op
  35262. typ string
  35263. id *uint64
  35264. created_at *time.Time
  35265. updated_at *time.Time
  35266. deleted_at *time.Time
  35267. start_date *time.Time
  35268. end_date *time.Time
  35269. company *string
  35270. experience *string
  35271. organization_id *uint64
  35272. addorganization_id *int64
  35273. clearedFields map[string]struct{}
  35274. employee *uint64
  35275. clearedemployee bool
  35276. done bool
  35277. oldValue func(context.Context) (*WorkExperience, error)
  35278. predicates []predicate.WorkExperience
  35279. }
  35280. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35281. // workexperienceOption allows management of the mutation configuration using functional options.
  35282. type workexperienceOption func(*WorkExperienceMutation)
  35283. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35284. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35285. m := &WorkExperienceMutation{
  35286. config: c,
  35287. op: op,
  35288. typ: TypeWorkExperience,
  35289. clearedFields: make(map[string]struct{}),
  35290. }
  35291. for _, opt := range opts {
  35292. opt(m)
  35293. }
  35294. return m
  35295. }
  35296. // withWorkExperienceID sets the ID field of the mutation.
  35297. func withWorkExperienceID(id uint64) workexperienceOption {
  35298. return func(m *WorkExperienceMutation) {
  35299. var (
  35300. err error
  35301. once sync.Once
  35302. value *WorkExperience
  35303. )
  35304. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35305. once.Do(func() {
  35306. if m.done {
  35307. err = errors.New("querying old values post mutation is not allowed")
  35308. } else {
  35309. value, err = m.Client().WorkExperience.Get(ctx, id)
  35310. }
  35311. })
  35312. return value, err
  35313. }
  35314. m.id = &id
  35315. }
  35316. }
  35317. // withWorkExperience sets the old WorkExperience of the mutation.
  35318. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35319. return func(m *WorkExperienceMutation) {
  35320. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35321. return node, nil
  35322. }
  35323. m.id = &node.ID
  35324. }
  35325. }
  35326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35327. // executed in a transaction (ent.Tx), a transactional client is returned.
  35328. func (m WorkExperienceMutation) Client() *Client {
  35329. client := &Client{config: m.config}
  35330. client.init()
  35331. return client
  35332. }
  35333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35334. // it returns an error otherwise.
  35335. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35336. if _, ok := m.driver.(*txDriver); !ok {
  35337. return nil, errors.New("ent: mutation is not running in a transaction")
  35338. }
  35339. tx := &Tx{config: m.config}
  35340. tx.init()
  35341. return tx, nil
  35342. }
  35343. // SetID sets the value of the id field. Note that this
  35344. // operation is only accepted on creation of WorkExperience entities.
  35345. func (m *WorkExperienceMutation) SetID(id uint64) {
  35346. m.id = &id
  35347. }
  35348. // ID returns the ID value in the mutation. Note that the ID is only available
  35349. // if it was provided to the builder or after it was returned from the database.
  35350. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35351. if m.id == nil {
  35352. return
  35353. }
  35354. return *m.id, true
  35355. }
  35356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35357. // That means, if the mutation is applied within a transaction with an isolation level such
  35358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35359. // or updated by the mutation.
  35360. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35361. switch {
  35362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35363. id, exists := m.ID()
  35364. if exists {
  35365. return []uint64{id}, nil
  35366. }
  35367. fallthrough
  35368. case m.op.Is(OpUpdate | OpDelete):
  35369. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35370. default:
  35371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35372. }
  35373. }
  35374. // SetCreatedAt sets the "created_at" field.
  35375. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35376. m.created_at = &t
  35377. }
  35378. // CreatedAt returns the value of the "created_at" field in the mutation.
  35379. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35380. v := m.created_at
  35381. if v == nil {
  35382. return
  35383. }
  35384. return *v, true
  35385. }
  35386. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35387. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35389. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35390. if !m.op.Is(OpUpdateOne) {
  35391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35392. }
  35393. if m.id == nil || m.oldValue == nil {
  35394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35395. }
  35396. oldValue, err := m.oldValue(ctx)
  35397. if err != nil {
  35398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35399. }
  35400. return oldValue.CreatedAt, nil
  35401. }
  35402. // ResetCreatedAt resets all changes to the "created_at" field.
  35403. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35404. m.created_at = nil
  35405. }
  35406. // SetUpdatedAt sets the "updated_at" field.
  35407. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35408. m.updated_at = &t
  35409. }
  35410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35411. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35412. v := m.updated_at
  35413. if v == nil {
  35414. return
  35415. }
  35416. return *v, true
  35417. }
  35418. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35419. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35421. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35422. if !m.op.Is(OpUpdateOne) {
  35423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35424. }
  35425. if m.id == nil || m.oldValue == nil {
  35426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35427. }
  35428. oldValue, err := m.oldValue(ctx)
  35429. if err != nil {
  35430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35431. }
  35432. return oldValue.UpdatedAt, nil
  35433. }
  35434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35435. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35436. m.updated_at = nil
  35437. }
  35438. // SetDeletedAt sets the "deleted_at" field.
  35439. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35440. m.deleted_at = &t
  35441. }
  35442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35443. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35444. v := m.deleted_at
  35445. if v == nil {
  35446. return
  35447. }
  35448. return *v, true
  35449. }
  35450. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35451. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35453. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35454. if !m.op.Is(OpUpdateOne) {
  35455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35456. }
  35457. if m.id == nil || m.oldValue == nil {
  35458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35459. }
  35460. oldValue, err := m.oldValue(ctx)
  35461. if err != nil {
  35462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35463. }
  35464. return oldValue.DeletedAt, nil
  35465. }
  35466. // ClearDeletedAt clears the value of the "deleted_at" field.
  35467. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35468. m.deleted_at = nil
  35469. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35470. }
  35471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35472. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35473. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35474. return ok
  35475. }
  35476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35477. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35478. m.deleted_at = nil
  35479. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35480. }
  35481. // SetEmployeeID sets the "employee_id" field.
  35482. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35483. m.employee = &u
  35484. }
  35485. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35486. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35487. v := m.employee
  35488. if v == nil {
  35489. return
  35490. }
  35491. return *v, true
  35492. }
  35493. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35494. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35496. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35497. if !m.op.Is(OpUpdateOne) {
  35498. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35499. }
  35500. if m.id == nil || m.oldValue == nil {
  35501. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35502. }
  35503. oldValue, err := m.oldValue(ctx)
  35504. if err != nil {
  35505. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35506. }
  35507. return oldValue.EmployeeID, nil
  35508. }
  35509. // ResetEmployeeID resets all changes to the "employee_id" field.
  35510. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35511. m.employee = nil
  35512. }
  35513. // SetStartDate sets the "start_date" field.
  35514. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35515. m.start_date = &t
  35516. }
  35517. // StartDate returns the value of the "start_date" field in the mutation.
  35518. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35519. v := m.start_date
  35520. if v == nil {
  35521. return
  35522. }
  35523. return *v, true
  35524. }
  35525. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35526. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35528. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35529. if !m.op.Is(OpUpdateOne) {
  35530. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35531. }
  35532. if m.id == nil || m.oldValue == nil {
  35533. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35534. }
  35535. oldValue, err := m.oldValue(ctx)
  35536. if err != nil {
  35537. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35538. }
  35539. return oldValue.StartDate, nil
  35540. }
  35541. // ResetStartDate resets all changes to the "start_date" field.
  35542. func (m *WorkExperienceMutation) ResetStartDate() {
  35543. m.start_date = nil
  35544. }
  35545. // SetEndDate sets the "end_date" field.
  35546. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35547. m.end_date = &t
  35548. }
  35549. // EndDate returns the value of the "end_date" field in the mutation.
  35550. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35551. v := m.end_date
  35552. if v == nil {
  35553. return
  35554. }
  35555. return *v, true
  35556. }
  35557. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35558. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35560. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35561. if !m.op.Is(OpUpdateOne) {
  35562. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35563. }
  35564. if m.id == nil || m.oldValue == nil {
  35565. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35566. }
  35567. oldValue, err := m.oldValue(ctx)
  35568. if err != nil {
  35569. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35570. }
  35571. return oldValue.EndDate, nil
  35572. }
  35573. // ResetEndDate resets all changes to the "end_date" field.
  35574. func (m *WorkExperienceMutation) ResetEndDate() {
  35575. m.end_date = nil
  35576. }
  35577. // SetCompany sets the "company" field.
  35578. func (m *WorkExperienceMutation) SetCompany(s string) {
  35579. m.company = &s
  35580. }
  35581. // Company returns the value of the "company" field in the mutation.
  35582. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35583. v := m.company
  35584. if v == nil {
  35585. return
  35586. }
  35587. return *v, true
  35588. }
  35589. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35590. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35592. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35593. if !m.op.Is(OpUpdateOne) {
  35594. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35595. }
  35596. if m.id == nil || m.oldValue == nil {
  35597. return v, errors.New("OldCompany requires an ID field in the mutation")
  35598. }
  35599. oldValue, err := m.oldValue(ctx)
  35600. if err != nil {
  35601. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35602. }
  35603. return oldValue.Company, nil
  35604. }
  35605. // ResetCompany resets all changes to the "company" field.
  35606. func (m *WorkExperienceMutation) ResetCompany() {
  35607. m.company = nil
  35608. }
  35609. // SetExperience sets the "experience" field.
  35610. func (m *WorkExperienceMutation) SetExperience(s string) {
  35611. m.experience = &s
  35612. }
  35613. // Experience returns the value of the "experience" field in the mutation.
  35614. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35615. v := m.experience
  35616. if v == nil {
  35617. return
  35618. }
  35619. return *v, true
  35620. }
  35621. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35622. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35624. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35625. if !m.op.Is(OpUpdateOne) {
  35626. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35627. }
  35628. if m.id == nil || m.oldValue == nil {
  35629. return v, errors.New("OldExperience requires an ID field in the mutation")
  35630. }
  35631. oldValue, err := m.oldValue(ctx)
  35632. if err != nil {
  35633. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35634. }
  35635. return oldValue.Experience, nil
  35636. }
  35637. // ResetExperience resets all changes to the "experience" field.
  35638. func (m *WorkExperienceMutation) ResetExperience() {
  35639. m.experience = nil
  35640. }
  35641. // SetOrganizationID sets the "organization_id" field.
  35642. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35643. m.organization_id = &u
  35644. m.addorganization_id = nil
  35645. }
  35646. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35647. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35648. v := m.organization_id
  35649. if v == nil {
  35650. return
  35651. }
  35652. return *v, true
  35653. }
  35654. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  35655. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35657. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35658. if !m.op.Is(OpUpdateOne) {
  35659. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35660. }
  35661. if m.id == nil || m.oldValue == nil {
  35662. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35663. }
  35664. oldValue, err := m.oldValue(ctx)
  35665. if err != nil {
  35666. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35667. }
  35668. return oldValue.OrganizationID, nil
  35669. }
  35670. // AddOrganizationID adds u to the "organization_id" field.
  35671. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35672. if m.addorganization_id != nil {
  35673. *m.addorganization_id += u
  35674. } else {
  35675. m.addorganization_id = &u
  35676. }
  35677. }
  35678. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35679. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35680. v := m.addorganization_id
  35681. if v == nil {
  35682. return
  35683. }
  35684. return *v, true
  35685. }
  35686. // ResetOrganizationID resets all changes to the "organization_id" field.
  35687. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35688. m.organization_id = nil
  35689. m.addorganization_id = nil
  35690. }
  35691. // ClearEmployee clears the "employee" edge to the Employee entity.
  35692. func (m *WorkExperienceMutation) ClearEmployee() {
  35693. m.clearedemployee = true
  35694. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35695. }
  35696. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35697. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35698. return m.clearedemployee
  35699. }
  35700. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35701. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35702. // EmployeeID instead. It exists only for internal usage by the builders.
  35703. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35704. if id := m.employee; id != nil {
  35705. ids = append(ids, *id)
  35706. }
  35707. return
  35708. }
  35709. // ResetEmployee resets all changes to the "employee" edge.
  35710. func (m *WorkExperienceMutation) ResetEmployee() {
  35711. m.employee = nil
  35712. m.clearedemployee = false
  35713. }
  35714. // Where appends a list predicates to the WorkExperienceMutation builder.
  35715. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35716. m.predicates = append(m.predicates, ps...)
  35717. }
  35718. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35719. // users can use type-assertion to append predicates that do not depend on any generated package.
  35720. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35721. p := make([]predicate.WorkExperience, len(ps))
  35722. for i := range ps {
  35723. p[i] = ps[i]
  35724. }
  35725. m.Where(p...)
  35726. }
  35727. // Op returns the operation name.
  35728. func (m *WorkExperienceMutation) Op() Op {
  35729. return m.op
  35730. }
  35731. // SetOp allows setting the mutation operation.
  35732. func (m *WorkExperienceMutation) SetOp(op Op) {
  35733. m.op = op
  35734. }
  35735. // Type returns the node type of this mutation (WorkExperience).
  35736. func (m *WorkExperienceMutation) Type() string {
  35737. return m.typ
  35738. }
  35739. // Fields returns all fields that were changed during this mutation. Note that in
  35740. // order to get all numeric fields that were incremented/decremented, call
  35741. // AddedFields().
  35742. func (m *WorkExperienceMutation) Fields() []string {
  35743. fields := make([]string, 0, 9)
  35744. if m.created_at != nil {
  35745. fields = append(fields, workexperience.FieldCreatedAt)
  35746. }
  35747. if m.updated_at != nil {
  35748. fields = append(fields, workexperience.FieldUpdatedAt)
  35749. }
  35750. if m.deleted_at != nil {
  35751. fields = append(fields, workexperience.FieldDeletedAt)
  35752. }
  35753. if m.employee != nil {
  35754. fields = append(fields, workexperience.FieldEmployeeID)
  35755. }
  35756. if m.start_date != nil {
  35757. fields = append(fields, workexperience.FieldStartDate)
  35758. }
  35759. if m.end_date != nil {
  35760. fields = append(fields, workexperience.FieldEndDate)
  35761. }
  35762. if m.company != nil {
  35763. fields = append(fields, workexperience.FieldCompany)
  35764. }
  35765. if m.experience != nil {
  35766. fields = append(fields, workexperience.FieldExperience)
  35767. }
  35768. if m.organization_id != nil {
  35769. fields = append(fields, workexperience.FieldOrganizationID)
  35770. }
  35771. return fields
  35772. }
  35773. // Field returns the value of a field with the given name. The second boolean
  35774. // return value indicates that this field was not set, or was not defined in the
  35775. // schema.
  35776. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35777. switch name {
  35778. case workexperience.FieldCreatedAt:
  35779. return m.CreatedAt()
  35780. case workexperience.FieldUpdatedAt:
  35781. return m.UpdatedAt()
  35782. case workexperience.FieldDeletedAt:
  35783. return m.DeletedAt()
  35784. case workexperience.FieldEmployeeID:
  35785. return m.EmployeeID()
  35786. case workexperience.FieldStartDate:
  35787. return m.StartDate()
  35788. case workexperience.FieldEndDate:
  35789. return m.EndDate()
  35790. case workexperience.FieldCompany:
  35791. return m.Company()
  35792. case workexperience.FieldExperience:
  35793. return m.Experience()
  35794. case workexperience.FieldOrganizationID:
  35795. return m.OrganizationID()
  35796. }
  35797. return nil, false
  35798. }
  35799. // OldField returns the old value of the field from the database. An error is
  35800. // returned if the mutation operation is not UpdateOne, or the query to the
  35801. // database failed.
  35802. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35803. switch name {
  35804. case workexperience.FieldCreatedAt:
  35805. return m.OldCreatedAt(ctx)
  35806. case workexperience.FieldUpdatedAt:
  35807. return m.OldUpdatedAt(ctx)
  35808. case workexperience.FieldDeletedAt:
  35809. return m.OldDeletedAt(ctx)
  35810. case workexperience.FieldEmployeeID:
  35811. return m.OldEmployeeID(ctx)
  35812. case workexperience.FieldStartDate:
  35813. return m.OldStartDate(ctx)
  35814. case workexperience.FieldEndDate:
  35815. return m.OldEndDate(ctx)
  35816. case workexperience.FieldCompany:
  35817. return m.OldCompany(ctx)
  35818. case workexperience.FieldExperience:
  35819. return m.OldExperience(ctx)
  35820. case workexperience.FieldOrganizationID:
  35821. return m.OldOrganizationID(ctx)
  35822. }
  35823. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35824. }
  35825. // SetField sets the value of a field with the given name. It returns an error if
  35826. // the field is not defined in the schema, or if the type mismatched the field
  35827. // type.
  35828. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35829. switch name {
  35830. case workexperience.FieldCreatedAt:
  35831. v, ok := value.(time.Time)
  35832. if !ok {
  35833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35834. }
  35835. m.SetCreatedAt(v)
  35836. return nil
  35837. case workexperience.FieldUpdatedAt:
  35838. v, ok := value.(time.Time)
  35839. if !ok {
  35840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35841. }
  35842. m.SetUpdatedAt(v)
  35843. return nil
  35844. case workexperience.FieldDeletedAt:
  35845. v, ok := value.(time.Time)
  35846. if !ok {
  35847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35848. }
  35849. m.SetDeletedAt(v)
  35850. return nil
  35851. case workexperience.FieldEmployeeID:
  35852. v, ok := value.(uint64)
  35853. if !ok {
  35854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35855. }
  35856. m.SetEmployeeID(v)
  35857. return nil
  35858. case workexperience.FieldStartDate:
  35859. v, ok := value.(time.Time)
  35860. if !ok {
  35861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35862. }
  35863. m.SetStartDate(v)
  35864. return nil
  35865. case workexperience.FieldEndDate:
  35866. v, ok := value.(time.Time)
  35867. if !ok {
  35868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35869. }
  35870. m.SetEndDate(v)
  35871. return nil
  35872. case workexperience.FieldCompany:
  35873. v, ok := value.(string)
  35874. if !ok {
  35875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35876. }
  35877. m.SetCompany(v)
  35878. return nil
  35879. case workexperience.FieldExperience:
  35880. v, ok := value.(string)
  35881. if !ok {
  35882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35883. }
  35884. m.SetExperience(v)
  35885. return nil
  35886. case workexperience.FieldOrganizationID:
  35887. v, ok := value.(uint64)
  35888. if !ok {
  35889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35890. }
  35891. m.SetOrganizationID(v)
  35892. return nil
  35893. }
  35894. return fmt.Errorf("unknown WorkExperience field %s", name)
  35895. }
  35896. // AddedFields returns all numeric fields that were incremented/decremented during
  35897. // this mutation.
  35898. func (m *WorkExperienceMutation) AddedFields() []string {
  35899. var fields []string
  35900. if m.addorganization_id != nil {
  35901. fields = append(fields, workexperience.FieldOrganizationID)
  35902. }
  35903. return fields
  35904. }
  35905. // AddedField returns the numeric value that was incremented/decremented on a field
  35906. // with the given name. The second boolean return value indicates that this field
  35907. // was not set, or was not defined in the schema.
  35908. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35909. switch name {
  35910. case workexperience.FieldOrganizationID:
  35911. return m.AddedOrganizationID()
  35912. }
  35913. return nil, false
  35914. }
  35915. // AddField adds the value to the field with the given name. It returns an error if
  35916. // the field is not defined in the schema, or if the type mismatched the field
  35917. // type.
  35918. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35919. switch name {
  35920. case workexperience.FieldOrganizationID:
  35921. v, ok := value.(int64)
  35922. if !ok {
  35923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35924. }
  35925. m.AddOrganizationID(v)
  35926. return nil
  35927. }
  35928. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35929. }
  35930. // ClearedFields returns all nullable fields that were cleared during this
  35931. // mutation.
  35932. func (m *WorkExperienceMutation) ClearedFields() []string {
  35933. var fields []string
  35934. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35935. fields = append(fields, workexperience.FieldDeletedAt)
  35936. }
  35937. return fields
  35938. }
  35939. // FieldCleared returns a boolean indicating if a field with the given name was
  35940. // cleared in this mutation.
  35941. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35942. _, ok := m.clearedFields[name]
  35943. return ok
  35944. }
  35945. // ClearField clears the value of the field with the given name. It returns an
  35946. // error if the field is not defined in the schema.
  35947. func (m *WorkExperienceMutation) ClearField(name string) error {
  35948. switch name {
  35949. case workexperience.FieldDeletedAt:
  35950. m.ClearDeletedAt()
  35951. return nil
  35952. }
  35953. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35954. }
  35955. // ResetField resets all changes in the mutation for the field with the given name.
  35956. // It returns an error if the field is not defined in the schema.
  35957. func (m *WorkExperienceMutation) ResetField(name string) error {
  35958. switch name {
  35959. case workexperience.FieldCreatedAt:
  35960. m.ResetCreatedAt()
  35961. return nil
  35962. case workexperience.FieldUpdatedAt:
  35963. m.ResetUpdatedAt()
  35964. return nil
  35965. case workexperience.FieldDeletedAt:
  35966. m.ResetDeletedAt()
  35967. return nil
  35968. case workexperience.FieldEmployeeID:
  35969. m.ResetEmployeeID()
  35970. return nil
  35971. case workexperience.FieldStartDate:
  35972. m.ResetStartDate()
  35973. return nil
  35974. case workexperience.FieldEndDate:
  35975. m.ResetEndDate()
  35976. return nil
  35977. case workexperience.FieldCompany:
  35978. m.ResetCompany()
  35979. return nil
  35980. case workexperience.FieldExperience:
  35981. m.ResetExperience()
  35982. return nil
  35983. case workexperience.FieldOrganizationID:
  35984. m.ResetOrganizationID()
  35985. return nil
  35986. }
  35987. return fmt.Errorf("unknown WorkExperience field %s", name)
  35988. }
  35989. // AddedEdges returns all edge names that were set/added in this mutation.
  35990. func (m *WorkExperienceMutation) AddedEdges() []string {
  35991. edges := make([]string, 0, 1)
  35992. if m.employee != nil {
  35993. edges = append(edges, workexperience.EdgeEmployee)
  35994. }
  35995. return edges
  35996. }
  35997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35998. // name in this mutation.
  35999. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  36000. switch name {
  36001. case workexperience.EdgeEmployee:
  36002. if id := m.employee; id != nil {
  36003. return []ent.Value{*id}
  36004. }
  36005. }
  36006. return nil
  36007. }
  36008. // RemovedEdges returns all edge names that were removed in this mutation.
  36009. func (m *WorkExperienceMutation) RemovedEdges() []string {
  36010. edges := make([]string, 0, 1)
  36011. return edges
  36012. }
  36013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36014. // the given name in this mutation.
  36015. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  36016. return nil
  36017. }
  36018. // ClearedEdges returns all edge names that were cleared in this mutation.
  36019. func (m *WorkExperienceMutation) ClearedEdges() []string {
  36020. edges := make([]string, 0, 1)
  36021. if m.clearedemployee {
  36022. edges = append(edges, workexperience.EdgeEmployee)
  36023. }
  36024. return edges
  36025. }
  36026. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36027. // was cleared in this mutation.
  36028. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  36029. switch name {
  36030. case workexperience.EdgeEmployee:
  36031. return m.clearedemployee
  36032. }
  36033. return false
  36034. }
  36035. // ClearEdge clears the value of the edge with the given name. It returns an error
  36036. // if that edge is not defined in the schema.
  36037. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  36038. switch name {
  36039. case workexperience.EdgeEmployee:
  36040. m.ClearEmployee()
  36041. return nil
  36042. }
  36043. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  36044. }
  36045. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36046. // It returns an error if the edge is not defined in the schema.
  36047. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  36048. switch name {
  36049. case workexperience.EdgeEmployee:
  36050. m.ResetEmployee()
  36051. return nil
  36052. }
  36053. return fmt.Errorf("unknown WorkExperience edge %s", name)
  36054. }
  36055. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  36056. type WpChatroomMutation struct {
  36057. config
  36058. op Op
  36059. typ string
  36060. id *uint64
  36061. created_at *time.Time
  36062. updated_at *time.Time
  36063. status *uint8
  36064. addstatus *int8
  36065. wx_wxid *string
  36066. chatroom_id *string
  36067. nickname *string
  36068. owner *string
  36069. avatar *string
  36070. member_list *[]string
  36071. appendmember_list []string
  36072. clearedFields map[string]struct{}
  36073. done bool
  36074. oldValue func(context.Context) (*WpChatroom, error)
  36075. predicates []predicate.WpChatroom
  36076. }
  36077. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  36078. // wpchatroomOption allows management of the mutation configuration using functional options.
  36079. type wpchatroomOption func(*WpChatroomMutation)
  36080. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  36081. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  36082. m := &WpChatroomMutation{
  36083. config: c,
  36084. op: op,
  36085. typ: TypeWpChatroom,
  36086. clearedFields: make(map[string]struct{}),
  36087. }
  36088. for _, opt := range opts {
  36089. opt(m)
  36090. }
  36091. return m
  36092. }
  36093. // withWpChatroomID sets the ID field of the mutation.
  36094. func withWpChatroomID(id uint64) wpchatroomOption {
  36095. return func(m *WpChatroomMutation) {
  36096. var (
  36097. err error
  36098. once sync.Once
  36099. value *WpChatroom
  36100. )
  36101. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  36102. once.Do(func() {
  36103. if m.done {
  36104. err = errors.New("querying old values post mutation is not allowed")
  36105. } else {
  36106. value, err = m.Client().WpChatroom.Get(ctx, id)
  36107. }
  36108. })
  36109. return value, err
  36110. }
  36111. m.id = &id
  36112. }
  36113. }
  36114. // withWpChatroom sets the old WpChatroom of the mutation.
  36115. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  36116. return func(m *WpChatroomMutation) {
  36117. m.oldValue = func(context.Context) (*WpChatroom, error) {
  36118. return node, nil
  36119. }
  36120. m.id = &node.ID
  36121. }
  36122. }
  36123. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36124. // executed in a transaction (ent.Tx), a transactional client is returned.
  36125. func (m WpChatroomMutation) Client() *Client {
  36126. client := &Client{config: m.config}
  36127. client.init()
  36128. return client
  36129. }
  36130. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36131. // it returns an error otherwise.
  36132. func (m WpChatroomMutation) Tx() (*Tx, error) {
  36133. if _, ok := m.driver.(*txDriver); !ok {
  36134. return nil, errors.New("ent: mutation is not running in a transaction")
  36135. }
  36136. tx := &Tx{config: m.config}
  36137. tx.init()
  36138. return tx, nil
  36139. }
  36140. // SetID sets the value of the id field. Note that this
  36141. // operation is only accepted on creation of WpChatroom entities.
  36142. func (m *WpChatroomMutation) SetID(id uint64) {
  36143. m.id = &id
  36144. }
  36145. // ID returns the ID value in the mutation. Note that the ID is only available
  36146. // if it was provided to the builder or after it was returned from the database.
  36147. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  36148. if m.id == nil {
  36149. return
  36150. }
  36151. return *m.id, true
  36152. }
  36153. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36154. // That means, if the mutation is applied within a transaction with an isolation level such
  36155. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36156. // or updated by the mutation.
  36157. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  36158. switch {
  36159. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36160. id, exists := m.ID()
  36161. if exists {
  36162. return []uint64{id}, nil
  36163. }
  36164. fallthrough
  36165. case m.op.Is(OpUpdate | OpDelete):
  36166. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  36167. default:
  36168. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36169. }
  36170. }
  36171. // SetCreatedAt sets the "created_at" field.
  36172. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  36173. m.created_at = &t
  36174. }
  36175. // CreatedAt returns the value of the "created_at" field in the mutation.
  36176. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  36177. v := m.created_at
  36178. if v == nil {
  36179. return
  36180. }
  36181. return *v, true
  36182. }
  36183. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  36184. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36186. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36187. if !m.op.Is(OpUpdateOne) {
  36188. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36189. }
  36190. if m.id == nil || m.oldValue == nil {
  36191. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36192. }
  36193. oldValue, err := m.oldValue(ctx)
  36194. if err != nil {
  36195. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36196. }
  36197. return oldValue.CreatedAt, nil
  36198. }
  36199. // ResetCreatedAt resets all changes to the "created_at" field.
  36200. func (m *WpChatroomMutation) ResetCreatedAt() {
  36201. m.created_at = nil
  36202. }
  36203. // SetUpdatedAt sets the "updated_at" field.
  36204. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  36205. m.updated_at = &t
  36206. }
  36207. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36208. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  36209. v := m.updated_at
  36210. if v == nil {
  36211. return
  36212. }
  36213. return *v, true
  36214. }
  36215. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  36216. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36218. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36219. if !m.op.Is(OpUpdateOne) {
  36220. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36221. }
  36222. if m.id == nil || m.oldValue == nil {
  36223. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36224. }
  36225. oldValue, err := m.oldValue(ctx)
  36226. if err != nil {
  36227. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36228. }
  36229. return oldValue.UpdatedAt, nil
  36230. }
  36231. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36232. func (m *WpChatroomMutation) ResetUpdatedAt() {
  36233. m.updated_at = nil
  36234. }
  36235. // SetStatus sets the "status" field.
  36236. func (m *WpChatroomMutation) SetStatus(u uint8) {
  36237. m.status = &u
  36238. m.addstatus = nil
  36239. }
  36240. // Status returns the value of the "status" field in the mutation.
  36241. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  36242. v := m.status
  36243. if v == nil {
  36244. return
  36245. }
  36246. return *v, true
  36247. }
  36248. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  36249. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36251. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36252. if !m.op.Is(OpUpdateOne) {
  36253. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36254. }
  36255. if m.id == nil || m.oldValue == nil {
  36256. return v, errors.New("OldStatus requires an ID field in the mutation")
  36257. }
  36258. oldValue, err := m.oldValue(ctx)
  36259. if err != nil {
  36260. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36261. }
  36262. return oldValue.Status, nil
  36263. }
  36264. // AddStatus adds u to the "status" field.
  36265. func (m *WpChatroomMutation) AddStatus(u int8) {
  36266. if m.addstatus != nil {
  36267. *m.addstatus += u
  36268. } else {
  36269. m.addstatus = &u
  36270. }
  36271. }
  36272. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36273. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36274. v := m.addstatus
  36275. if v == nil {
  36276. return
  36277. }
  36278. return *v, true
  36279. }
  36280. // ClearStatus clears the value of the "status" field.
  36281. func (m *WpChatroomMutation) ClearStatus() {
  36282. m.status = nil
  36283. m.addstatus = nil
  36284. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36285. }
  36286. // StatusCleared returns if the "status" field was cleared in this mutation.
  36287. func (m *WpChatroomMutation) StatusCleared() bool {
  36288. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36289. return ok
  36290. }
  36291. // ResetStatus resets all changes to the "status" field.
  36292. func (m *WpChatroomMutation) ResetStatus() {
  36293. m.status = nil
  36294. m.addstatus = nil
  36295. delete(m.clearedFields, wpchatroom.FieldStatus)
  36296. }
  36297. // SetWxWxid sets the "wx_wxid" field.
  36298. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36299. m.wx_wxid = &s
  36300. }
  36301. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36302. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36303. v := m.wx_wxid
  36304. if v == nil {
  36305. return
  36306. }
  36307. return *v, true
  36308. }
  36309. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36310. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36312. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36313. if !m.op.Is(OpUpdateOne) {
  36314. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36315. }
  36316. if m.id == nil || m.oldValue == nil {
  36317. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36318. }
  36319. oldValue, err := m.oldValue(ctx)
  36320. if err != nil {
  36321. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36322. }
  36323. return oldValue.WxWxid, nil
  36324. }
  36325. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36326. func (m *WpChatroomMutation) ResetWxWxid() {
  36327. m.wx_wxid = nil
  36328. }
  36329. // SetChatroomID sets the "chatroom_id" field.
  36330. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36331. m.chatroom_id = &s
  36332. }
  36333. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36334. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36335. v := m.chatroom_id
  36336. if v == nil {
  36337. return
  36338. }
  36339. return *v, true
  36340. }
  36341. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36342. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36344. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36345. if !m.op.Is(OpUpdateOne) {
  36346. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36347. }
  36348. if m.id == nil || m.oldValue == nil {
  36349. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36350. }
  36351. oldValue, err := m.oldValue(ctx)
  36352. if err != nil {
  36353. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36354. }
  36355. return oldValue.ChatroomID, nil
  36356. }
  36357. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36358. func (m *WpChatroomMutation) ResetChatroomID() {
  36359. m.chatroom_id = nil
  36360. }
  36361. // SetNickname sets the "nickname" field.
  36362. func (m *WpChatroomMutation) SetNickname(s string) {
  36363. m.nickname = &s
  36364. }
  36365. // Nickname returns the value of the "nickname" field in the mutation.
  36366. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36367. v := m.nickname
  36368. if v == nil {
  36369. return
  36370. }
  36371. return *v, true
  36372. }
  36373. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36374. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36376. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36377. if !m.op.Is(OpUpdateOne) {
  36378. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36379. }
  36380. if m.id == nil || m.oldValue == nil {
  36381. return v, errors.New("OldNickname requires an ID field in the mutation")
  36382. }
  36383. oldValue, err := m.oldValue(ctx)
  36384. if err != nil {
  36385. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36386. }
  36387. return oldValue.Nickname, nil
  36388. }
  36389. // ResetNickname resets all changes to the "nickname" field.
  36390. func (m *WpChatroomMutation) ResetNickname() {
  36391. m.nickname = nil
  36392. }
  36393. // SetOwner sets the "owner" field.
  36394. func (m *WpChatroomMutation) SetOwner(s string) {
  36395. m.owner = &s
  36396. }
  36397. // Owner returns the value of the "owner" field in the mutation.
  36398. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36399. v := m.owner
  36400. if v == nil {
  36401. return
  36402. }
  36403. return *v, true
  36404. }
  36405. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36406. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36408. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36409. if !m.op.Is(OpUpdateOne) {
  36410. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36411. }
  36412. if m.id == nil || m.oldValue == nil {
  36413. return v, errors.New("OldOwner requires an ID field in the mutation")
  36414. }
  36415. oldValue, err := m.oldValue(ctx)
  36416. if err != nil {
  36417. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36418. }
  36419. return oldValue.Owner, nil
  36420. }
  36421. // ResetOwner resets all changes to the "owner" field.
  36422. func (m *WpChatroomMutation) ResetOwner() {
  36423. m.owner = nil
  36424. }
  36425. // SetAvatar sets the "avatar" field.
  36426. func (m *WpChatroomMutation) SetAvatar(s string) {
  36427. m.avatar = &s
  36428. }
  36429. // Avatar returns the value of the "avatar" field in the mutation.
  36430. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36431. v := m.avatar
  36432. if v == nil {
  36433. return
  36434. }
  36435. return *v, true
  36436. }
  36437. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36438. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36440. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36441. if !m.op.Is(OpUpdateOne) {
  36442. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36443. }
  36444. if m.id == nil || m.oldValue == nil {
  36445. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36446. }
  36447. oldValue, err := m.oldValue(ctx)
  36448. if err != nil {
  36449. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36450. }
  36451. return oldValue.Avatar, nil
  36452. }
  36453. // ResetAvatar resets all changes to the "avatar" field.
  36454. func (m *WpChatroomMutation) ResetAvatar() {
  36455. m.avatar = nil
  36456. }
  36457. // SetMemberList sets the "member_list" field.
  36458. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36459. m.member_list = &s
  36460. m.appendmember_list = nil
  36461. }
  36462. // MemberList returns the value of the "member_list" field in the mutation.
  36463. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36464. v := m.member_list
  36465. if v == nil {
  36466. return
  36467. }
  36468. return *v, true
  36469. }
  36470. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  36471. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36473. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  36474. if !m.op.Is(OpUpdateOne) {
  36475. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36476. }
  36477. if m.id == nil || m.oldValue == nil {
  36478. return v, errors.New("OldMemberList requires an ID field in the mutation")
  36479. }
  36480. oldValue, err := m.oldValue(ctx)
  36481. if err != nil {
  36482. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  36483. }
  36484. return oldValue.MemberList, nil
  36485. }
  36486. // AppendMemberList adds s to the "member_list" field.
  36487. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36488. m.appendmember_list = append(m.appendmember_list, s...)
  36489. }
  36490. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36491. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36492. if len(m.appendmember_list) == 0 {
  36493. return nil, false
  36494. }
  36495. return m.appendmember_list, true
  36496. }
  36497. // ResetMemberList resets all changes to the "member_list" field.
  36498. func (m *WpChatroomMutation) ResetMemberList() {
  36499. m.member_list = nil
  36500. m.appendmember_list = nil
  36501. }
  36502. // Where appends a list predicates to the WpChatroomMutation builder.
  36503. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36504. m.predicates = append(m.predicates, ps...)
  36505. }
  36506. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36507. // users can use type-assertion to append predicates that do not depend on any generated package.
  36508. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36509. p := make([]predicate.WpChatroom, len(ps))
  36510. for i := range ps {
  36511. p[i] = ps[i]
  36512. }
  36513. m.Where(p...)
  36514. }
  36515. // Op returns the operation name.
  36516. func (m *WpChatroomMutation) Op() Op {
  36517. return m.op
  36518. }
  36519. // SetOp allows setting the mutation operation.
  36520. func (m *WpChatroomMutation) SetOp(op Op) {
  36521. m.op = op
  36522. }
  36523. // Type returns the node type of this mutation (WpChatroom).
  36524. func (m *WpChatroomMutation) Type() string {
  36525. return m.typ
  36526. }
  36527. // Fields returns all fields that were changed during this mutation. Note that in
  36528. // order to get all numeric fields that were incremented/decremented, call
  36529. // AddedFields().
  36530. func (m *WpChatroomMutation) Fields() []string {
  36531. fields := make([]string, 0, 9)
  36532. if m.created_at != nil {
  36533. fields = append(fields, wpchatroom.FieldCreatedAt)
  36534. }
  36535. if m.updated_at != nil {
  36536. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36537. }
  36538. if m.status != nil {
  36539. fields = append(fields, wpchatroom.FieldStatus)
  36540. }
  36541. if m.wx_wxid != nil {
  36542. fields = append(fields, wpchatroom.FieldWxWxid)
  36543. }
  36544. if m.chatroom_id != nil {
  36545. fields = append(fields, wpchatroom.FieldChatroomID)
  36546. }
  36547. if m.nickname != nil {
  36548. fields = append(fields, wpchatroom.FieldNickname)
  36549. }
  36550. if m.owner != nil {
  36551. fields = append(fields, wpchatroom.FieldOwner)
  36552. }
  36553. if m.avatar != nil {
  36554. fields = append(fields, wpchatroom.FieldAvatar)
  36555. }
  36556. if m.member_list != nil {
  36557. fields = append(fields, wpchatroom.FieldMemberList)
  36558. }
  36559. return fields
  36560. }
  36561. // Field returns the value of a field with the given name. The second boolean
  36562. // return value indicates that this field was not set, or was not defined in the
  36563. // schema.
  36564. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36565. switch name {
  36566. case wpchatroom.FieldCreatedAt:
  36567. return m.CreatedAt()
  36568. case wpchatroom.FieldUpdatedAt:
  36569. return m.UpdatedAt()
  36570. case wpchatroom.FieldStatus:
  36571. return m.Status()
  36572. case wpchatroom.FieldWxWxid:
  36573. return m.WxWxid()
  36574. case wpchatroom.FieldChatroomID:
  36575. return m.ChatroomID()
  36576. case wpchatroom.FieldNickname:
  36577. return m.Nickname()
  36578. case wpchatroom.FieldOwner:
  36579. return m.Owner()
  36580. case wpchatroom.FieldAvatar:
  36581. return m.Avatar()
  36582. case wpchatroom.FieldMemberList:
  36583. return m.MemberList()
  36584. }
  36585. return nil, false
  36586. }
  36587. // OldField returns the old value of the field from the database. An error is
  36588. // returned if the mutation operation is not UpdateOne, or the query to the
  36589. // database failed.
  36590. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36591. switch name {
  36592. case wpchatroom.FieldCreatedAt:
  36593. return m.OldCreatedAt(ctx)
  36594. case wpchatroom.FieldUpdatedAt:
  36595. return m.OldUpdatedAt(ctx)
  36596. case wpchatroom.FieldStatus:
  36597. return m.OldStatus(ctx)
  36598. case wpchatroom.FieldWxWxid:
  36599. return m.OldWxWxid(ctx)
  36600. case wpchatroom.FieldChatroomID:
  36601. return m.OldChatroomID(ctx)
  36602. case wpchatroom.FieldNickname:
  36603. return m.OldNickname(ctx)
  36604. case wpchatroom.FieldOwner:
  36605. return m.OldOwner(ctx)
  36606. case wpchatroom.FieldAvatar:
  36607. return m.OldAvatar(ctx)
  36608. case wpchatroom.FieldMemberList:
  36609. return m.OldMemberList(ctx)
  36610. }
  36611. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36612. }
  36613. // SetField sets the value of a field with the given name. It returns an error if
  36614. // the field is not defined in the schema, or if the type mismatched the field
  36615. // type.
  36616. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36617. switch name {
  36618. case wpchatroom.FieldCreatedAt:
  36619. v, ok := value.(time.Time)
  36620. if !ok {
  36621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36622. }
  36623. m.SetCreatedAt(v)
  36624. return nil
  36625. case wpchatroom.FieldUpdatedAt:
  36626. v, ok := value.(time.Time)
  36627. if !ok {
  36628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36629. }
  36630. m.SetUpdatedAt(v)
  36631. return nil
  36632. case wpchatroom.FieldStatus:
  36633. v, ok := value.(uint8)
  36634. if !ok {
  36635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36636. }
  36637. m.SetStatus(v)
  36638. return nil
  36639. case wpchatroom.FieldWxWxid:
  36640. v, ok := value.(string)
  36641. if !ok {
  36642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36643. }
  36644. m.SetWxWxid(v)
  36645. return nil
  36646. case wpchatroom.FieldChatroomID:
  36647. v, ok := value.(string)
  36648. if !ok {
  36649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36650. }
  36651. m.SetChatroomID(v)
  36652. return nil
  36653. case wpchatroom.FieldNickname:
  36654. v, ok := value.(string)
  36655. if !ok {
  36656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36657. }
  36658. m.SetNickname(v)
  36659. return nil
  36660. case wpchatroom.FieldOwner:
  36661. v, ok := value.(string)
  36662. if !ok {
  36663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36664. }
  36665. m.SetOwner(v)
  36666. return nil
  36667. case wpchatroom.FieldAvatar:
  36668. v, ok := value.(string)
  36669. if !ok {
  36670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36671. }
  36672. m.SetAvatar(v)
  36673. return nil
  36674. case wpchatroom.FieldMemberList:
  36675. v, ok := value.([]string)
  36676. if !ok {
  36677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36678. }
  36679. m.SetMemberList(v)
  36680. return nil
  36681. }
  36682. return fmt.Errorf("unknown WpChatroom field %s", name)
  36683. }
  36684. // AddedFields returns all numeric fields that were incremented/decremented during
  36685. // this mutation.
  36686. func (m *WpChatroomMutation) AddedFields() []string {
  36687. var fields []string
  36688. if m.addstatus != nil {
  36689. fields = append(fields, wpchatroom.FieldStatus)
  36690. }
  36691. return fields
  36692. }
  36693. // AddedField returns the numeric value that was incremented/decremented on a field
  36694. // with the given name. The second boolean return value indicates that this field
  36695. // was not set, or was not defined in the schema.
  36696. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36697. switch name {
  36698. case wpchatroom.FieldStatus:
  36699. return m.AddedStatus()
  36700. }
  36701. return nil, false
  36702. }
  36703. // AddField adds the value to the field with the given name. It returns an error if
  36704. // the field is not defined in the schema, or if the type mismatched the field
  36705. // type.
  36706. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36707. switch name {
  36708. case wpchatroom.FieldStatus:
  36709. v, ok := value.(int8)
  36710. if !ok {
  36711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36712. }
  36713. m.AddStatus(v)
  36714. return nil
  36715. }
  36716. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36717. }
  36718. // ClearedFields returns all nullable fields that were cleared during this
  36719. // mutation.
  36720. func (m *WpChatroomMutation) ClearedFields() []string {
  36721. var fields []string
  36722. if m.FieldCleared(wpchatroom.FieldStatus) {
  36723. fields = append(fields, wpchatroom.FieldStatus)
  36724. }
  36725. return fields
  36726. }
  36727. // FieldCleared returns a boolean indicating if a field with the given name was
  36728. // cleared in this mutation.
  36729. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36730. _, ok := m.clearedFields[name]
  36731. return ok
  36732. }
  36733. // ClearField clears the value of the field with the given name. It returns an
  36734. // error if the field is not defined in the schema.
  36735. func (m *WpChatroomMutation) ClearField(name string) error {
  36736. switch name {
  36737. case wpchatroom.FieldStatus:
  36738. m.ClearStatus()
  36739. return nil
  36740. }
  36741. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36742. }
  36743. // ResetField resets all changes in the mutation for the field with the given name.
  36744. // It returns an error if the field is not defined in the schema.
  36745. func (m *WpChatroomMutation) ResetField(name string) error {
  36746. switch name {
  36747. case wpchatroom.FieldCreatedAt:
  36748. m.ResetCreatedAt()
  36749. return nil
  36750. case wpchatroom.FieldUpdatedAt:
  36751. m.ResetUpdatedAt()
  36752. return nil
  36753. case wpchatroom.FieldStatus:
  36754. m.ResetStatus()
  36755. return nil
  36756. case wpchatroom.FieldWxWxid:
  36757. m.ResetWxWxid()
  36758. return nil
  36759. case wpchatroom.FieldChatroomID:
  36760. m.ResetChatroomID()
  36761. return nil
  36762. case wpchatroom.FieldNickname:
  36763. m.ResetNickname()
  36764. return nil
  36765. case wpchatroom.FieldOwner:
  36766. m.ResetOwner()
  36767. return nil
  36768. case wpchatroom.FieldAvatar:
  36769. m.ResetAvatar()
  36770. return nil
  36771. case wpchatroom.FieldMemberList:
  36772. m.ResetMemberList()
  36773. return nil
  36774. }
  36775. return fmt.Errorf("unknown WpChatroom field %s", name)
  36776. }
  36777. // AddedEdges returns all edge names that were set/added in this mutation.
  36778. func (m *WpChatroomMutation) AddedEdges() []string {
  36779. edges := make([]string, 0, 0)
  36780. return edges
  36781. }
  36782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36783. // name in this mutation.
  36784. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36785. return nil
  36786. }
  36787. // RemovedEdges returns all edge names that were removed in this mutation.
  36788. func (m *WpChatroomMutation) RemovedEdges() []string {
  36789. edges := make([]string, 0, 0)
  36790. return edges
  36791. }
  36792. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36793. // the given name in this mutation.
  36794. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36795. return nil
  36796. }
  36797. // ClearedEdges returns all edge names that were cleared in this mutation.
  36798. func (m *WpChatroomMutation) ClearedEdges() []string {
  36799. edges := make([]string, 0, 0)
  36800. return edges
  36801. }
  36802. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36803. // was cleared in this mutation.
  36804. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36805. return false
  36806. }
  36807. // ClearEdge clears the value of the edge with the given name. It returns an error
  36808. // if that edge is not defined in the schema.
  36809. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36810. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36811. }
  36812. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36813. // It returns an error if the edge is not defined in the schema.
  36814. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36815. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36816. }
  36817. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36818. type WpChatroomMemberMutation struct {
  36819. config
  36820. op Op
  36821. typ string
  36822. id *uint64
  36823. created_at *time.Time
  36824. updated_at *time.Time
  36825. status *uint8
  36826. addstatus *int8
  36827. wx_wxid *string
  36828. wxid *string
  36829. nickname *string
  36830. avatar *string
  36831. clearedFields map[string]struct{}
  36832. done bool
  36833. oldValue func(context.Context) (*WpChatroomMember, error)
  36834. predicates []predicate.WpChatroomMember
  36835. }
  36836. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36837. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36838. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36839. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36840. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36841. m := &WpChatroomMemberMutation{
  36842. config: c,
  36843. op: op,
  36844. typ: TypeWpChatroomMember,
  36845. clearedFields: make(map[string]struct{}),
  36846. }
  36847. for _, opt := range opts {
  36848. opt(m)
  36849. }
  36850. return m
  36851. }
  36852. // withWpChatroomMemberID sets the ID field of the mutation.
  36853. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36854. return func(m *WpChatroomMemberMutation) {
  36855. var (
  36856. err error
  36857. once sync.Once
  36858. value *WpChatroomMember
  36859. )
  36860. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36861. once.Do(func() {
  36862. if m.done {
  36863. err = errors.New("querying old values post mutation is not allowed")
  36864. } else {
  36865. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36866. }
  36867. })
  36868. return value, err
  36869. }
  36870. m.id = &id
  36871. }
  36872. }
  36873. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36874. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36875. return func(m *WpChatroomMemberMutation) {
  36876. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36877. return node, nil
  36878. }
  36879. m.id = &node.ID
  36880. }
  36881. }
  36882. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36883. // executed in a transaction (ent.Tx), a transactional client is returned.
  36884. func (m WpChatroomMemberMutation) Client() *Client {
  36885. client := &Client{config: m.config}
  36886. client.init()
  36887. return client
  36888. }
  36889. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36890. // it returns an error otherwise.
  36891. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36892. if _, ok := m.driver.(*txDriver); !ok {
  36893. return nil, errors.New("ent: mutation is not running in a transaction")
  36894. }
  36895. tx := &Tx{config: m.config}
  36896. tx.init()
  36897. return tx, nil
  36898. }
  36899. // SetID sets the value of the id field. Note that this
  36900. // operation is only accepted on creation of WpChatroomMember entities.
  36901. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36902. m.id = &id
  36903. }
  36904. // ID returns the ID value in the mutation. Note that the ID is only available
  36905. // if it was provided to the builder or after it was returned from the database.
  36906. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36907. if m.id == nil {
  36908. return
  36909. }
  36910. return *m.id, true
  36911. }
  36912. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36913. // That means, if the mutation is applied within a transaction with an isolation level such
  36914. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36915. // or updated by the mutation.
  36916. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36917. switch {
  36918. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36919. id, exists := m.ID()
  36920. if exists {
  36921. return []uint64{id}, nil
  36922. }
  36923. fallthrough
  36924. case m.op.Is(OpUpdate | OpDelete):
  36925. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36926. default:
  36927. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36928. }
  36929. }
  36930. // SetCreatedAt sets the "created_at" field.
  36931. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36932. m.created_at = &t
  36933. }
  36934. // CreatedAt returns the value of the "created_at" field in the mutation.
  36935. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36936. v := m.created_at
  36937. if v == nil {
  36938. return
  36939. }
  36940. return *v, true
  36941. }
  36942. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36943. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36945. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36946. if !m.op.Is(OpUpdateOne) {
  36947. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36948. }
  36949. if m.id == nil || m.oldValue == nil {
  36950. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36951. }
  36952. oldValue, err := m.oldValue(ctx)
  36953. if err != nil {
  36954. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36955. }
  36956. return oldValue.CreatedAt, nil
  36957. }
  36958. // ResetCreatedAt resets all changes to the "created_at" field.
  36959. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36960. m.created_at = nil
  36961. }
  36962. // SetUpdatedAt sets the "updated_at" field.
  36963. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36964. m.updated_at = &t
  36965. }
  36966. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36967. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36968. v := m.updated_at
  36969. if v == nil {
  36970. return
  36971. }
  36972. return *v, true
  36973. }
  36974. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36975. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36977. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36978. if !m.op.Is(OpUpdateOne) {
  36979. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36980. }
  36981. if m.id == nil || m.oldValue == nil {
  36982. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36983. }
  36984. oldValue, err := m.oldValue(ctx)
  36985. if err != nil {
  36986. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36987. }
  36988. return oldValue.UpdatedAt, nil
  36989. }
  36990. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36991. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36992. m.updated_at = nil
  36993. }
  36994. // SetStatus sets the "status" field.
  36995. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36996. m.status = &u
  36997. m.addstatus = nil
  36998. }
  36999. // Status returns the value of the "status" field in the mutation.
  37000. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  37001. v := m.status
  37002. if v == nil {
  37003. return
  37004. }
  37005. return *v, true
  37006. }
  37007. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  37008. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37010. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37011. if !m.op.Is(OpUpdateOne) {
  37012. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37013. }
  37014. if m.id == nil || m.oldValue == nil {
  37015. return v, errors.New("OldStatus requires an ID field in the mutation")
  37016. }
  37017. oldValue, err := m.oldValue(ctx)
  37018. if err != nil {
  37019. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37020. }
  37021. return oldValue.Status, nil
  37022. }
  37023. // AddStatus adds u to the "status" field.
  37024. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  37025. if m.addstatus != nil {
  37026. *m.addstatus += u
  37027. } else {
  37028. m.addstatus = &u
  37029. }
  37030. }
  37031. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37032. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  37033. v := m.addstatus
  37034. if v == nil {
  37035. return
  37036. }
  37037. return *v, true
  37038. }
  37039. // ClearStatus clears the value of the "status" field.
  37040. func (m *WpChatroomMemberMutation) ClearStatus() {
  37041. m.status = nil
  37042. m.addstatus = nil
  37043. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  37044. }
  37045. // StatusCleared returns if the "status" field was cleared in this mutation.
  37046. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  37047. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  37048. return ok
  37049. }
  37050. // ResetStatus resets all changes to the "status" field.
  37051. func (m *WpChatroomMemberMutation) ResetStatus() {
  37052. m.status = nil
  37053. m.addstatus = nil
  37054. delete(m.clearedFields, wpchatroommember.FieldStatus)
  37055. }
  37056. // SetWxWxid sets the "wx_wxid" field.
  37057. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  37058. m.wx_wxid = &s
  37059. }
  37060. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37061. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  37062. v := m.wx_wxid
  37063. if v == nil {
  37064. return
  37065. }
  37066. return *v, true
  37067. }
  37068. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  37069. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37071. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37072. if !m.op.Is(OpUpdateOne) {
  37073. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37074. }
  37075. if m.id == nil || m.oldValue == nil {
  37076. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37077. }
  37078. oldValue, err := m.oldValue(ctx)
  37079. if err != nil {
  37080. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37081. }
  37082. return oldValue.WxWxid, nil
  37083. }
  37084. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37085. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  37086. m.wx_wxid = nil
  37087. }
  37088. // SetWxid sets the "wxid" field.
  37089. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  37090. m.wxid = &s
  37091. }
  37092. // Wxid returns the value of the "wxid" field in the mutation.
  37093. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  37094. v := m.wxid
  37095. if v == nil {
  37096. return
  37097. }
  37098. return *v, true
  37099. }
  37100. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  37101. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37103. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  37104. if !m.op.Is(OpUpdateOne) {
  37105. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37106. }
  37107. if m.id == nil || m.oldValue == nil {
  37108. return v, errors.New("OldWxid requires an ID field in the mutation")
  37109. }
  37110. oldValue, err := m.oldValue(ctx)
  37111. if err != nil {
  37112. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37113. }
  37114. return oldValue.Wxid, nil
  37115. }
  37116. // ResetWxid resets all changes to the "wxid" field.
  37117. func (m *WpChatroomMemberMutation) ResetWxid() {
  37118. m.wxid = nil
  37119. }
  37120. // SetNickname sets the "nickname" field.
  37121. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  37122. m.nickname = &s
  37123. }
  37124. // Nickname returns the value of the "nickname" field in the mutation.
  37125. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  37126. v := m.nickname
  37127. if v == nil {
  37128. return
  37129. }
  37130. return *v, true
  37131. }
  37132. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  37133. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37135. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  37136. if !m.op.Is(OpUpdateOne) {
  37137. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37138. }
  37139. if m.id == nil || m.oldValue == nil {
  37140. return v, errors.New("OldNickname requires an ID field in the mutation")
  37141. }
  37142. oldValue, err := m.oldValue(ctx)
  37143. if err != nil {
  37144. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37145. }
  37146. return oldValue.Nickname, nil
  37147. }
  37148. // ResetNickname resets all changes to the "nickname" field.
  37149. func (m *WpChatroomMemberMutation) ResetNickname() {
  37150. m.nickname = nil
  37151. }
  37152. // SetAvatar sets the "avatar" field.
  37153. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  37154. m.avatar = &s
  37155. }
  37156. // Avatar returns the value of the "avatar" field in the mutation.
  37157. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  37158. v := m.avatar
  37159. if v == nil {
  37160. return
  37161. }
  37162. return *v, true
  37163. }
  37164. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  37165. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37167. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37168. if !m.op.Is(OpUpdateOne) {
  37169. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37170. }
  37171. if m.id == nil || m.oldValue == nil {
  37172. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37173. }
  37174. oldValue, err := m.oldValue(ctx)
  37175. if err != nil {
  37176. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37177. }
  37178. return oldValue.Avatar, nil
  37179. }
  37180. // ResetAvatar resets all changes to the "avatar" field.
  37181. func (m *WpChatroomMemberMutation) ResetAvatar() {
  37182. m.avatar = nil
  37183. }
  37184. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  37185. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  37186. m.predicates = append(m.predicates, ps...)
  37187. }
  37188. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  37189. // users can use type-assertion to append predicates that do not depend on any generated package.
  37190. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  37191. p := make([]predicate.WpChatroomMember, len(ps))
  37192. for i := range ps {
  37193. p[i] = ps[i]
  37194. }
  37195. m.Where(p...)
  37196. }
  37197. // Op returns the operation name.
  37198. func (m *WpChatroomMemberMutation) Op() Op {
  37199. return m.op
  37200. }
  37201. // SetOp allows setting the mutation operation.
  37202. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  37203. m.op = op
  37204. }
  37205. // Type returns the node type of this mutation (WpChatroomMember).
  37206. func (m *WpChatroomMemberMutation) Type() string {
  37207. return m.typ
  37208. }
  37209. // Fields returns all fields that were changed during this mutation. Note that in
  37210. // order to get all numeric fields that were incremented/decremented, call
  37211. // AddedFields().
  37212. func (m *WpChatroomMemberMutation) Fields() []string {
  37213. fields := make([]string, 0, 7)
  37214. if m.created_at != nil {
  37215. fields = append(fields, wpchatroommember.FieldCreatedAt)
  37216. }
  37217. if m.updated_at != nil {
  37218. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  37219. }
  37220. if m.status != nil {
  37221. fields = append(fields, wpchatroommember.FieldStatus)
  37222. }
  37223. if m.wx_wxid != nil {
  37224. fields = append(fields, wpchatroommember.FieldWxWxid)
  37225. }
  37226. if m.wxid != nil {
  37227. fields = append(fields, wpchatroommember.FieldWxid)
  37228. }
  37229. if m.nickname != nil {
  37230. fields = append(fields, wpchatroommember.FieldNickname)
  37231. }
  37232. if m.avatar != nil {
  37233. fields = append(fields, wpchatroommember.FieldAvatar)
  37234. }
  37235. return fields
  37236. }
  37237. // Field returns the value of a field with the given name. The second boolean
  37238. // return value indicates that this field was not set, or was not defined in the
  37239. // schema.
  37240. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  37241. switch name {
  37242. case wpchatroommember.FieldCreatedAt:
  37243. return m.CreatedAt()
  37244. case wpchatroommember.FieldUpdatedAt:
  37245. return m.UpdatedAt()
  37246. case wpchatroommember.FieldStatus:
  37247. return m.Status()
  37248. case wpchatroommember.FieldWxWxid:
  37249. return m.WxWxid()
  37250. case wpchatroommember.FieldWxid:
  37251. return m.Wxid()
  37252. case wpchatroommember.FieldNickname:
  37253. return m.Nickname()
  37254. case wpchatroommember.FieldAvatar:
  37255. return m.Avatar()
  37256. }
  37257. return nil, false
  37258. }
  37259. // OldField returns the old value of the field from the database. An error is
  37260. // returned if the mutation operation is not UpdateOne, or the query to the
  37261. // database failed.
  37262. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37263. switch name {
  37264. case wpchatroommember.FieldCreatedAt:
  37265. return m.OldCreatedAt(ctx)
  37266. case wpchatroommember.FieldUpdatedAt:
  37267. return m.OldUpdatedAt(ctx)
  37268. case wpchatroommember.FieldStatus:
  37269. return m.OldStatus(ctx)
  37270. case wpchatroommember.FieldWxWxid:
  37271. return m.OldWxWxid(ctx)
  37272. case wpchatroommember.FieldWxid:
  37273. return m.OldWxid(ctx)
  37274. case wpchatroommember.FieldNickname:
  37275. return m.OldNickname(ctx)
  37276. case wpchatroommember.FieldAvatar:
  37277. return m.OldAvatar(ctx)
  37278. }
  37279. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37280. }
  37281. // SetField sets the value of a field with the given name. It returns an error if
  37282. // the field is not defined in the schema, or if the type mismatched the field
  37283. // type.
  37284. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37285. switch name {
  37286. case wpchatroommember.FieldCreatedAt:
  37287. v, ok := value.(time.Time)
  37288. if !ok {
  37289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37290. }
  37291. m.SetCreatedAt(v)
  37292. return nil
  37293. case wpchatroommember.FieldUpdatedAt:
  37294. v, ok := value.(time.Time)
  37295. if !ok {
  37296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37297. }
  37298. m.SetUpdatedAt(v)
  37299. return nil
  37300. case wpchatroommember.FieldStatus:
  37301. v, ok := value.(uint8)
  37302. if !ok {
  37303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37304. }
  37305. m.SetStatus(v)
  37306. return nil
  37307. case wpchatroommember.FieldWxWxid:
  37308. v, ok := value.(string)
  37309. if !ok {
  37310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37311. }
  37312. m.SetWxWxid(v)
  37313. return nil
  37314. case wpchatroommember.FieldWxid:
  37315. v, ok := value.(string)
  37316. if !ok {
  37317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37318. }
  37319. m.SetWxid(v)
  37320. return nil
  37321. case wpchatroommember.FieldNickname:
  37322. v, ok := value.(string)
  37323. if !ok {
  37324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37325. }
  37326. m.SetNickname(v)
  37327. return nil
  37328. case wpchatroommember.FieldAvatar:
  37329. v, ok := value.(string)
  37330. if !ok {
  37331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37332. }
  37333. m.SetAvatar(v)
  37334. return nil
  37335. }
  37336. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37337. }
  37338. // AddedFields returns all numeric fields that were incremented/decremented during
  37339. // this mutation.
  37340. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37341. var fields []string
  37342. if m.addstatus != nil {
  37343. fields = append(fields, wpchatroommember.FieldStatus)
  37344. }
  37345. return fields
  37346. }
  37347. // AddedField returns the numeric value that was incremented/decremented on a field
  37348. // with the given name. The second boolean return value indicates that this field
  37349. // was not set, or was not defined in the schema.
  37350. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37351. switch name {
  37352. case wpchatroommember.FieldStatus:
  37353. return m.AddedStatus()
  37354. }
  37355. return nil, false
  37356. }
  37357. // AddField adds the value to the field with the given name. It returns an error if
  37358. // the field is not defined in the schema, or if the type mismatched the field
  37359. // type.
  37360. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37361. switch name {
  37362. case wpchatroommember.FieldStatus:
  37363. v, ok := value.(int8)
  37364. if !ok {
  37365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37366. }
  37367. m.AddStatus(v)
  37368. return nil
  37369. }
  37370. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37371. }
  37372. // ClearedFields returns all nullable fields that were cleared during this
  37373. // mutation.
  37374. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37375. var fields []string
  37376. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37377. fields = append(fields, wpchatroommember.FieldStatus)
  37378. }
  37379. return fields
  37380. }
  37381. // FieldCleared returns a boolean indicating if a field with the given name was
  37382. // cleared in this mutation.
  37383. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37384. _, ok := m.clearedFields[name]
  37385. return ok
  37386. }
  37387. // ClearField clears the value of the field with the given name. It returns an
  37388. // error if the field is not defined in the schema.
  37389. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37390. switch name {
  37391. case wpchatroommember.FieldStatus:
  37392. m.ClearStatus()
  37393. return nil
  37394. }
  37395. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37396. }
  37397. // ResetField resets all changes in the mutation for the field with the given name.
  37398. // It returns an error if the field is not defined in the schema.
  37399. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37400. switch name {
  37401. case wpchatroommember.FieldCreatedAt:
  37402. m.ResetCreatedAt()
  37403. return nil
  37404. case wpchatroommember.FieldUpdatedAt:
  37405. m.ResetUpdatedAt()
  37406. return nil
  37407. case wpchatroommember.FieldStatus:
  37408. m.ResetStatus()
  37409. return nil
  37410. case wpchatroommember.FieldWxWxid:
  37411. m.ResetWxWxid()
  37412. return nil
  37413. case wpchatroommember.FieldWxid:
  37414. m.ResetWxid()
  37415. return nil
  37416. case wpchatroommember.FieldNickname:
  37417. m.ResetNickname()
  37418. return nil
  37419. case wpchatroommember.FieldAvatar:
  37420. m.ResetAvatar()
  37421. return nil
  37422. }
  37423. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37424. }
  37425. // AddedEdges returns all edge names that were set/added in this mutation.
  37426. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37427. edges := make([]string, 0, 0)
  37428. return edges
  37429. }
  37430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37431. // name in this mutation.
  37432. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37433. return nil
  37434. }
  37435. // RemovedEdges returns all edge names that were removed in this mutation.
  37436. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37437. edges := make([]string, 0, 0)
  37438. return edges
  37439. }
  37440. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37441. // the given name in this mutation.
  37442. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37443. return nil
  37444. }
  37445. // ClearedEdges returns all edge names that were cleared in this mutation.
  37446. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37447. edges := make([]string, 0, 0)
  37448. return edges
  37449. }
  37450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37451. // was cleared in this mutation.
  37452. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37453. return false
  37454. }
  37455. // ClearEdge clears the value of the edge with the given name. It returns an error
  37456. // if that edge is not defined in the schema.
  37457. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37458. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37459. }
  37460. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37461. // It returns an error if the edge is not defined in the schema.
  37462. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37463. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37464. }
  37465. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37466. type WxMutation struct {
  37467. config
  37468. op Op
  37469. typ string
  37470. id *uint64
  37471. created_at *time.Time
  37472. updated_at *time.Time
  37473. status *uint8
  37474. addstatus *int8
  37475. deleted_at *time.Time
  37476. port *string
  37477. process_id *string
  37478. callback *string
  37479. wxid *string
  37480. account *string
  37481. nickname *string
  37482. tel *string
  37483. head_big *string
  37484. organization_id *uint64
  37485. addorganization_id *int64
  37486. api_base *string
  37487. api_key *string
  37488. allow_list *[]string
  37489. appendallow_list []string
  37490. group_allow_list *[]string
  37491. appendgroup_allow_list []string
  37492. block_list *[]string
  37493. appendblock_list []string
  37494. group_block_list *[]string
  37495. appendgroup_block_list []string
  37496. clearedFields map[string]struct{}
  37497. server *uint64
  37498. clearedserver bool
  37499. agent *uint64
  37500. clearedagent bool
  37501. done bool
  37502. oldValue func(context.Context) (*Wx, error)
  37503. predicates []predicate.Wx
  37504. }
  37505. var _ ent.Mutation = (*WxMutation)(nil)
  37506. // wxOption allows management of the mutation configuration using functional options.
  37507. type wxOption func(*WxMutation)
  37508. // newWxMutation creates new mutation for the Wx entity.
  37509. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37510. m := &WxMutation{
  37511. config: c,
  37512. op: op,
  37513. typ: TypeWx,
  37514. clearedFields: make(map[string]struct{}),
  37515. }
  37516. for _, opt := range opts {
  37517. opt(m)
  37518. }
  37519. return m
  37520. }
  37521. // withWxID sets the ID field of the mutation.
  37522. func withWxID(id uint64) wxOption {
  37523. return func(m *WxMutation) {
  37524. var (
  37525. err error
  37526. once sync.Once
  37527. value *Wx
  37528. )
  37529. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37530. once.Do(func() {
  37531. if m.done {
  37532. err = errors.New("querying old values post mutation is not allowed")
  37533. } else {
  37534. value, err = m.Client().Wx.Get(ctx, id)
  37535. }
  37536. })
  37537. return value, err
  37538. }
  37539. m.id = &id
  37540. }
  37541. }
  37542. // withWx sets the old Wx of the mutation.
  37543. func withWx(node *Wx) wxOption {
  37544. return func(m *WxMutation) {
  37545. m.oldValue = func(context.Context) (*Wx, error) {
  37546. return node, nil
  37547. }
  37548. m.id = &node.ID
  37549. }
  37550. }
  37551. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37552. // executed in a transaction (ent.Tx), a transactional client is returned.
  37553. func (m WxMutation) Client() *Client {
  37554. client := &Client{config: m.config}
  37555. client.init()
  37556. return client
  37557. }
  37558. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37559. // it returns an error otherwise.
  37560. func (m WxMutation) Tx() (*Tx, error) {
  37561. if _, ok := m.driver.(*txDriver); !ok {
  37562. return nil, errors.New("ent: mutation is not running in a transaction")
  37563. }
  37564. tx := &Tx{config: m.config}
  37565. tx.init()
  37566. return tx, nil
  37567. }
  37568. // SetID sets the value of the id field. Note that this
  37569. // operation is only accepted on creation of Wx entities.
  37570. func (m *WxMutation) SetID(id uint64) {
  37571. m.id = &id
  37572. }
  37573. // ID returns the ID value in the mutation. Note that the ID is only available
  37574. // if it was provided to the builder or after it was returned from the database.
  37575. func (m *WxMutation) ID() (id uint64, exists bool) {
  37576. if m.id == nil {
  37577. return
  37578. }
  37579. return *m.id, true
  37580. }
  37581. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37582. // That means, if the mutation is applied within a transaction with an isolation level such
  37583. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37584. // or updated by the mutation.
  37585. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37586. switch {
  37587. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37588. id, exists := m.ID()
  37589. if exists {
  37590. return []uint64{id}, nil
  37591. }
  37592. fallthrough
  37593. case m.op.Is(OpUpdate | OpDelete):
  37594. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37595. default:
  37596. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37597. }
  37598. }
  37599. // SetCreatedAt sets the "created_at" field.
  37600. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37601. m.created_at = &t
  37602. }
  37603. // CreatedAt returns the value of the "created_at" field in the mutation.
  37604. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37605. v := m.created_at
  37606. if v == nil {
  37607. return
  37608. }
  37609. return *v, true
  37610. }
  37611. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37612. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37614. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37615. if !m.op.Is(OpUpdateOne) {
  37616. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37617. }
  37618. if m.id == nil || m.oldValue == nil {
  37619. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37620. }
  37621. oldValue, err := m.oldValue(ctx)
  37622. if err != nil {
  37623. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37624. }
  37625. return oldValue.CreatedAt, nil
  37626. }
  37627. // ResetCreatedAt resets all changes to the "created_at" field.
  37628. func (m *WxMutation) ResetCreatedAt() {
  37629. m.created_at = nil
  37630. }
  37631. // SetUpdatedAt sets the "updated_at" field.
  37632. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37633. m.updated_at = &t
  37634. }
  37635. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37636. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37637. v := m.updated_at
  37638. if v == nil {
  37639. return
  37640. }
  37641. return *v, true
  37642. }
  37643. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37646. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37647. if !m.op.Is(OpUpdateOne) {
  37648. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37649. }
  37650. if m.id == nil || m.oldValue == nil {
  37651. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37652. }
  37653. oldValue, err := m.oldValue(ctx)
  37654. if err != nil {
  37655. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37656. }
  37657. return oldValue.UpdatedAt, nil
  37658. }
  37659. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37660. func (m *WxMutation) ResetUpdatedAt() {
  37661. m.updated_at = nil
  37662. }
  37663. // SetStatus sets the "status" field.
  37664. func (m *WxMutation) SetStatus(u uint8) {
  37665. m.status = &u
  37666. m.addstatus = nil
  37667. }
  37668. // Status returns the value of the "status" field in the mutation.
  37669. func (m *WxMutation) Status() (r uint8, exists bool) {
  37670. v := m.status
  37671. if v == nil {
  37672. return
  37673. }
  37674. return *v, true
  37675. }
  37676. // OldStatus returns the old "status" field's value of the Wx entity.
  37677. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37679. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37680. if !m.op.Is(OpUpdateOne) {
  37681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37682. }
  37683. if m.id == nil || m.oldValue == nil {
  37684. return v, errors.New("OldStatus requires an ID field in the mutation")
  37685. }
  37686. oldValue, err := m.oldValue(ctx)
  37687. if err != nil {
  37688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37689. }
  37690. return oldValue.Status, nil
  37691. }
  37692. // AddStatus adds u to the "status" field.
  37693. func (m *WxMutation) AddStatus(u int8) {
  37694. if m.addstatus != nil {
  37695. *m.addstatus += u
  37696. } else {
  37697. m.addstatus = &u
  37698. }
  37699. }
  37700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37701. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37702. v := m.addstatus
  37703. if v == nil {
  37704. return
  37705. }
  37706. return *v, true
  37707. }
  37708. // ClearStatus clears the value of the "status" field.
  37709. func (m *WxMutation) ClearStatus() {
  37710. m.status = nil
  37711. m.addstatus = nil
  37712. m.clearedFields[wx.FieldStatus] = struct{}{}
  37713. }
  37714. // StatusCleared returns if the "status" field was cleared in this mutation.
  37715. func (m *WxMutation) StatusCleared() bool {
  37716. _, ok := m.clearedFields[wx.FieldStatus]
  37717. return ok
  37718. }
  37719. // ResetStatus resets all changes to the "status" field.
  37720. func (m *WxMutation) ResetStatus() {
  37721. m.status = nil
  37722. m.addstatus = nil
  37723. delete(m.clearedFields, wx.FieldStatus)
  37724. }
  37725. // SetDeletedAt sets the "deleted_at" field.
  37726. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37727. m.deleted_at = &t
  37728. }
  37729. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37730. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37731. v := m.deleted_at
  37732. if v == nil {
  37733. return
  37734. }
  37735. return *v, true
  37736. }
  37737. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37738. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37740. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37741. if !m.op.Is(OpUpdateOne) {
  37742. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37743. }
  37744. if m.id == nil || m.oldValue == nil {
  37745. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37746. }
  37747. oldValue, err := m.oldValue(ctx)
  37748. if err != nil {
  37749. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37750. }
  37751. return oldValue.DeletedAt, nil
  37752. }
  37753. // ClearDeletedAt clears the value of the "deleted_at" field.
  37754. func (m *WxMutation) ClearDeletedAt() {
  37755. m.deleted_at = nil
  37756. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37757. }
  37758. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37759. func (m *WxMutation) DeletedAtCleared() bool {
  37760. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37761. return ok
  37762. }
  37763. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37764. func (m *WxMutation) ResetDeletedAt() {
  37765. m.deleted_at = nil
  37766. delete(m.clearedFields, wx.FieldDeletedAt)
  37767. }
  37768. // SetServerID sets the "server_id" field.
  37769. func (m *WxMutation) SetServerID(u uint64) {
  37770. m.server = &u
  37771. }
  37772. // ServerID returns the value of the "server_id" field in the mutation.
  37773. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37774. v := m.server
  37775. if v == nil {
  37776. return
  37777. }
  37778. return *v, true
  37779. }
  37780. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37781. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37783. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37784. if !m.op.Is(OpUpdateOne) {
  37785. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37786. }
  37787. if m.id == nil || m.oldValue == nil {
  37788. return v, errors.New("OldServerID requires an ID field in the mutation")
  37789. }
  37790. oldValue, err := m.oldValue(ctx)
  37791. if err != nil {
  37792. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37793. }
  37794. return oldValue.ServerID, nil
  37795. }
  37796. // ClearServerID clears the value of the "server_id" field.
  37797. func (m *WxMutation) ClearServerID() {
  37798. m.server = nil
  37799. m.clearedFields[wx.FieldServerID] = struct{}{}
  37800. }
  37801. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37802. func (m *WxMutation) ServerIDCleared() bool {
  37803. _, ok := m.clearedFields[wx.FieldServerID]
  37804. return ok
  37805. }
  37806. // ResetServerID resets all changes to the "server_id" field.
  37807. func (m *WxMutation) ResetServerID() {
  37808. m.server = nil
  37809. delete(m.clearedFields, wx.FieldServerID)
  37810. }
  37811. // SetPort sets the "port" field.
  37812. func (m *WxMutation) SetPort(s string) {
  37813. m.port = &s
  37814. }
  37815. // Port returns the value of the "port" field in the mutation.
  37816. func (m *WxMutation) Port() (r string, exists bool) {
  37817. v := m.port
  37818. if v == nil {
  37819. return
  37820. }
  37821. return *v, true
  37822. }
  37823. // OldPort returns the old "port" field's value of the Wx entity.
  37824. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37826. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37827. if !m.op.Is(OpUpdateOne) {
  37828. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37829. }
  37830. if m.id == nil || m.oldValue == nil {
  37831. return v, errors.New("OldPort requires an ID field in the mutation")
  37832. }
  37833. oldValue, err := m.oldValue(ctx)
  37834. if err != nil {
  37835. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37836. }
  37837. return oldValue.Port, nil
  37838. }
  37839. // ResetPort resets all changes to the "port" field.
  37840. func (m *WxMutation) ResetPort() {
  37841. m.port = nil
  37842. }
  37843. // SetProcessID sets the "process_id" field.
  37844. func (m *WxMutation) SetProcessID(s string) {
  37845. m.process_id = &s
  37846. }
  37847. // ProcessID returns the value of the "process_id" field in the mutation.
  37848. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37849. v := m.process_id
  37850. if v == nil {
  37851. return
  37852. }
  37853. return *v, true
  37854. }
  37855. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37856. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37858. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37859. if !m.op.Is(OpUpdateOne) {
  37860. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37861. }
  37862. if m.id == nil || m.oldValue == nil {
  37863. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37864. }
  37865. oldValue, err := m.oldValue(ctx)
  37866. if err != nil {
  37867. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37868. }
  37869. return oldValue.ProcessID, nil
  37870. }
  37871. // ResetProcessID resets all changes to the "process_id" field.
  37872. func (m *WxMutation) ResetProcessID() {
  37873. m.process_id = nil
  37874. }
  37875. // SetCallback sets the "callback" field.
  37876. func (m *WxMutation) SetCallback(s string) {
  37877. m.callback = &s
  37878. }
  37879. // Callback returns the value of the "callback" field in the mutation.
  37880. func (m *WxMutation) Callback() (r string, exists bool) {
  37881. v := m.callback
  37882. if v == nil {
  37883. return
  37884. }
  37885. return *v, true
  37886. }
  37887. // OldCallback returns the old "callback" field's value of the Wx entity.
  37888. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37890. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37891. if !m.op.Is(OpUpdateOne) {
  37892. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37893. }
  37894. if m.id == nil || m.oldValue == nil {
  37895. return v, errors.New("OldCallback requires an ID field in the mutation")
  37896. }
  37897. oldValue, err := m.oldValue(ctx)
  37898. if err != nil {
  37899. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37900. }
  37901. return oldValue.Callback, nil
  37902. }
  37903. // ResetCallback resets all changes to the "callback" field.
  37904. func (m *WxMutation) ResetCallback() {
  37905. m.callback = nil
  37906. }
  37907. // SetWxid sets the "wxid" field.
  37908. func (m *WxMutation) SetWxid(s string) {
  37909. m.wxid = &s
  37910. }
  37911. // Wxid returns the value of the "wxid" field in the mutation.
  37912. func (m *WxMutation) Wxid() (r string, exists bool) {
  37913. v := m.wxid
  37914. if v == nil {
  37915. return
  37916. }
  37917. return *v, true
  37918. }
  37919. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37920. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37922. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37923. if !m.op.Is(OpUpdateOne) {
  37924. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37925. }
  37926. if m.id == nil || m.oldValue == nil {
  37927. return v, errors.New("OldWxid requires an ID field in the mutation")
  37928. }
  37929. oldValue, err := m.oldValue(ctx)
  37930. if err != nil {
  37931. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37932. }
  37933. return oldValue.Wxid, nil
  37934. }
  37935. // ResetWxid resets all changes to the "wxid" field.
  37936. func (m *WxMutation) ResetWxid() {
  37937. m.wxid = nil
  37938. }
  37939. // SetAccount sets the "account" field.
  37940. func (m *WxMutation) SetAccount(s string) {
  37941. m.account = &s
  37942. }
  37943. // Account returns the value of the "account" field in the mutation.
  37944. func (m *WxMutation) Account() (r string, exists bool) {
  37945. v := m.account
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldAccount returns the old "account" field's value of the Wx entity.
  37952. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldAccount requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37964. }
  37965. return oldValue.Account, nil
  37966. }
  37967. // ResetAccount resets all changes to the "account" field.
  37968. func (m *WxMutation) ResetAccount() {
  37969. m.account = nil
  37970. }
  37971. // SetNickname sets the "nickname" field.
  37972. func (m *WxMutation) SetNickname(s string) {
  37973. m.nickname = &s
  37974. }
  37975. // Nickname returns the value of the "nickname" field in the mutation.
  37976. func (m *WxMutation) Nickname() (r string, exists bool) {
  37977. v := m.nickname
  37978. if v == nil {
  37979. return
  37980. }
  37981. return *v, true
  37982. }
  37983. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37984. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37986. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37987. if !m.op.Is(OpUpdateOne) {
  37988. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37989. }
  37990. if m.id == nil || m.oldValue == nil {
  37991. return v, errors.New("OldNickname requires an ID field in the mutation")
  37992. }
  37993. oldValue, err := m.oldValue(ctx)
  37994. if err != nil {
  37995. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37996. }
  37997. return oldValue.Nickname, nil
  37998. }
  37999. // ResetNickname resets all changes to the "nickname" field.
  38000. func (m *WxMutation) ResetNickname() {
  38001. m.nickname = nil
  38002. }
  38003. // SetTel sets the "tel" field.
  38004. func (m *WxMutation) SetTel(s string) {
  38005. m.tel = &s
  38006. }
  38007. // Tel returns the value of the "tel" field in the mutation.
  38008. func (m *WxMutation) Tel() (r string, exists bool) {
  38009. v := m.tel
  38010. if v == nil {
  38011. return
  38012. }
  38013. return *v, true
  38014. }
  38015. // OldTel returns the old "tel" field's value of the Wx entity.
  38016. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38018. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  38019. if !m.op.Is(OpUpdateOne) {
  38020. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  38021. }
  38022. if m.id == nil || m.oldValue == nil {
  38023. return v, errors.New("OldTel requires an ID field in the mutation")
  38024. }
  38025. oldValue, err := m.oldValue(ctx)
  38026. if err != nil {
  38027. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  38028. }
  38029. return oldValue.Tel, nil
  38030. }
  38031. // ResetTel resets all changes to the "tel" field.
  38032. func (m *WxMutation) ResetTel() {
  38033. m.tel = nil
  38034. }
  38035. // SetHeadBig sets the "head_big" field.
  38036. func (m *WxMutation) SetHeadBig(s string) {
  38037. m.head_big = &s
  38038. }
  38039. // HeadBig returns the value of the "head_big" field in the mutation.
  38040. func (m *WxMutation) HeadBig() (r string, exists bool) {
  38041. v := m.head_big
  38042. if v == nil {
  38043. return
  38044. }
  38045. return *v, true
  38046. }
  38047. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  38048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38050. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  38051. if !m.op.Is(OpUpdateOne) {
  38052. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  38053. }
  38054. if m.id == nil || m.oldValue == nil {
  38055. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  38056. }
  38057. oldValue, err := m.oldValue(ctx)
  38058. if err != nil {
  38059. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  38060. }
  38061. return oldValue.HeadBig, nil
  38062. }
  38063. // ResetHeadBig resets all changes to the "head_big" field.
  38064. func (m *WxMutation) ResetHeadBig() {
  38065. m.head_big = nil
  38066. }
  38067. // SetOrganizationID sets the "organization_id" field.
  38068. func (m *WxMutation) SetOrganizationID(u uint64) {
  38069. m.organization_id = &u
  38070. m.addorganization_id = nil
  38071. }
  38072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38073. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  38074. v := m.organization_id
  38075. if v == nil {
  38076. return
  38077. }
  38078. return *v, true
  38079. }
  38080. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  38081. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38083. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38084. if !m.op.Is(OpUpdateOne) {
  38085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38086. }
  38087. if m.id == nil || m.oldValue == nil {
  38088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38089. }
  38090. oldValue, err := m.oldValue(ctx)
  38091. if err != nil {
  38092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38093. }
  38094. return oldValue.OrganizationID, nil
  38095. }
  38096. // AddOrganizationID adds u to the "organization_id" field.
  38097. func (m *WxMutation) AddOrganizationID(u int64) {
  38098. if m.addorganization_id != nil {
  38099. *m.addorganization_id += u
  38100. } else {
  38101. m.addorganization_id = &u
  38102. }
  38103. }
  38104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38105. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  38106. v := m.addorganization_id
  38107. if v == nil {
  38108. return
  38109. }
  38110. return *v, true
  38111. }
  38112. // ClearOrganizationID clears the value of the "organization_id" field.
  38113. func (m *WxMutation) ClearOrganizationID() {
  38114. m.organization_id = nil
  38115. m.addorganization_id = nil
  38116. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  38117. }
  38118. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38119. func (m *WxMutation) OrganizationIDCleared() bool {
  38120. _, ok := m.clearedFields[wx.FieldOrganizationID]
  38121. return ok
  38122. }
  38123. // ResetOrganizationID resets all changes to the "organization_id" field.
  38124. func (m *WxMutation) ResetOrganizationID() {
  38125. m.organization_id = nil
  38126. m.addorganization_id = nil
  38127. delete(m.clearedFields, wx.FieldOrganizationID)
  38128. }
  38129. // SetAgentID sets the "agent_id" field.
  38130. func (m *WxMutation) SetAgentID(u uint64) {
  38131. m.agent = &u
  38132. }
  38133. // AgentID returns the value of the "agent_id" field in the mutation.
  38134. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  38135. v := m.agent
  38136. if v == nil {
  38137. return
  38138. }
  38139. return *v, true
  38140. }
  38141. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  38142. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38144. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38145. if !m.op.Is(OpUpdateOne) {
  38146. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38147. }
  38148. if m.id == nil || m.oldValue == nil {
  38149. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38150. }
  38151. oldValue, err := m.oldValue(ctx)
  38152. if err != nil {
  38153. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38154. }
  38155. return oldValue.AgentID, nil
  38156. }
  38157. // ResetAgentID resets all changes to the "agent_id" field.
  38158. func (m *WxMutation) ResetAgentID() {
  38159. m.agent = nil
  38160. }
  38161. // SetAPIBase sets the "api_base" field.
  38162. func (m *WxMutation) SetAPIBase(s string) {
  38163. m.api_base = &s
  38164. }
  38165. // APIBase returns the value of the "api_base" field in the mutation.
  38166. func (m *WxMutation) APIBase() (r string, exists bool) {
  38167. v := m.api_base
  38168. if v == nil {
  38169. return
  38170. }
  38171. return *v, true
  38172. }
  38173. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  38174. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38176. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38177. if !m.op.Is(OpUpdateOne) {
  38178. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38179. }
  38180. if m.id == nil || m.oldValue == nil {
  38181. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38182. }
  38183. oldValue, err := m.oldValue(ctx)
  38184. if err != nil {
  38185. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38186. }
  38187. return oldValue.APIBase, nil
  38188. }
  38189. // ClearAPIBase clears the value of the "api_base" field.
  38190. func (m *WxMutation) ClearAPIBase() {
  38191. m.api_base = nil
  38192. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  38193. }
  38194. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38195. func (m *WxMutation) APIBaseCleared() bool {
  38196. _, ok := m.clearedFields[wx.FieldAPIBase]
  38197. return ok
  38198. }
  38199. // ResetAPIBase resets all changes to the "api_base" field.
  38200. func (m *WxMutation) ResetAPIBase() {
  38201. m.api_base = nil
  38202. delete(m.clearedFields, wx.FieldAPIBase)
  38203. }
  38204. // SetAPIKey sets the "api_key" field.
  38205. func (m *WxMutation) SetAPIKey(s string) {
  38206. m.api_key = &s
  38207. }
  38208. // APIKey returns the value of the "api_key" field in the mutation.
  38209. func (m *WxMutation) APIKey() (r string, exists bool) {
  38210. v := m.api_key
  38211. if v == nil {
  38212. return
  38213. }
  38214. return *v, true
  38215. }
  38216. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  38217. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38219. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38220. if !m.op.Is(OpUpdateOne) {
  38221. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38222. }
  38223. if m.id == nil || m.oldValue == nil {
  38224. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38225. }
  38226. oldValue, err := m.oldValue(ctx)
  38227. if err != nil {
  38228. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38229. }
  38230. return oldValue.APIKey, nil
  38231. }
  38232. // ClearAPIKey clears the value of the "api_key" field.
  38233. func (m *WxMutation) ClearAPIKey() {
  38234. m.api_key = nil
  38235. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  38236. }
  38237. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38238. func (m *WxMutation) APIKeyCleared() bool {
  38239. _, ok := m.clearedFields[wx.FieldAPIKey]
  38240. return ok
  38241. }
  38242. // ResetAPIKey resets all changes to the "api_key" field.
  38243. func (m *WxMutation) ResetAPIKey() {
  38244. m.api_key = nil
  38245. delete(m.clearedFields, wx.FieldAPIKey)
  38246. }
  38247. // SetAllowList sets the "allow_list" field.
  38248. func (m *WxMutation) SetAllowList(s []string) {
  38249. m.allow_list = &s
  38250. m.appendallow_list = nil
  38251. }
  38252. // AllowList returns the value of the "allow_list" field in the mutation.
  38253. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38254. v := m.allow_list
  38255. if v == nil {
  38256. return
  38257. }
  38258. return *v, true
  38259. }
  38260. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38261. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38263. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38264. if !m.op.Is(OpUpdateOne) {
  38265. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38266. }
  38267. if m.id == nil || m.oldValue == nil {
  38268. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38269. }
  38270. oldValue, err := m.oldValue(ctx)
  38271. if err != nil {
  38272. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38273. }
  38274. return oldValue.AllowList, nil
  38275. }
  38276. // AppendAllowList adds s to the "allow_list" field.
  38277. func (m *WxMutation) AppendAllowList(s []string) {
  38278. m.appendallow_list = append(m.appendallow_list, s...)
  38279. }
  38280. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38281. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38282. if len(m.appendallow_list) == 0 {
  38283. return nil, false
  38284. }
  38285. return m.appendallow_list, true
  38286. }
  38287. // ResetAllowList resets all changes to the "allow_list" field.
  38288. func (m *WxMutation) ResetAllowList() {
  38289. m.allow_list = nil
  38290. m.appendallow_list = nil
  38291. }
  38292. // SetGroupAllowList sets the "group_allow_list" field.
  38293. func (m *WxMutation) SetGroupAllowList(s []string) {
  38294. m.group_allow_list = &s
  38295. m.appendgroup_allow_list = nil
  38296. }
  38297. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38298. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38299. v := m.group_allow_list
  38300. if v == nil {
  38301. return
  38302. }
  38303. return *v, true
  38304. }
  38305. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38306. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38308. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38309. if !m.op.Is(OpUpdateOne) {
  38310. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38311. }
  38312. if m.id == nil || m.oldValue == nil {
  38313. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38314. }
  38315. oldValue, err := m.oldValue(ctx)
  38316. if err != nil {
  38317. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38318. }
  38319. return oldValue.GroupAllowList, nil
  38320. }
  38321. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38322. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38323. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38324. }
  38325. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38326. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38327. if len(m.appendgroup_allow_list) == 0 {
  38328. return nil, false
  38329. }
  38330. return m.appendgroup_allow_list, true
  38331. }
  38332. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38333. func (m *WxMutation) ResetGroupAllowList() {
  38334. m.group_allow_list = nil
  38335. m.appendgroup_allow_list = nil
  38336. }
  38337. // SetBlockList sets the "block_list" field.
  38338. func (m *WxMutation) SetBlockList(s []string) {
  38339. m.block_list = &s
  38340. m.appendblock_list = nil
  38341. }
  38342. // BlockList returns the value of the "block_list" field in the mutation.
  38343. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38344. v := m.block_list
  38345. if v == nil {
  38346. return
  38347. }
  38348. return *v, true
  38349. }
  38350. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38351. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38353. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38354. if !m.op.Is(OpUpdateOne) {
  38355. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38356. }
  38357. if m.id == nil || m.oldValue == nil {
  38358. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38359. }
  38360. oldValue, err := m.oldValue(ctx)
  38361. if err != nil {
  38362. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38363. }
  38364. return oldValue.BlockList, nil
  38365. }
  38366. // AppendBlockList adds s to the "block_list" field.
  38367. func (m *WxMutation) AppendBlockList(s []string) {
  38368. m.appendblock_list = append(m.appendblock_list, s...)
  38369. }
  38370. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38371. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38372. if len(m.appendblock_list) == 0 {
  38373. return nil, false
  38374. }
  38375. return m.appendblock_list, true
  38376. }
  38377. // ResetBlockList resets all changes to the "block_list" field.
  38378. func (m *WxMutation) ResetBlockList() {
  38379. m.block_list = nil
  38380. m.appendblock_list = nil
  38381. }
  38382. // SetGroupBlockList sets the "group_block_list" field.
  38383. func (m *WxMutation) SetGroupBlockList(s []string) {
  38384. m.group_block_list = &s
  38385. m.appendgroup_block_list = nil
  38386. }
  38387. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38388. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38389. v := m.group_block_list
  38390. if v == nil {
  38391. return
  38392. }
  38393. return *v, true
  38394. }
  38395. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38396. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38398. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38399. if !m.op.Is(OpUpdateOne) {
  38400. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38401. }
  38402. if m.id == nil || m.oldValue == nil {
  38403. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38404. }
  38405. oldValue, err := m.oldValue(ctx)
  38406. if err != nil {
  38407. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38408. }
  38409. return oldValue.GroupBlockList, nil
  38410. }
  38411. // AppendGroupBlockList adds s to the "group_block_list" field.
  38412. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38413. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38414. }
  38415. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38416. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38417. if len(m.appendgroup_block_list) == 0 {
  38418. return nil, false
  38419. }
  38420. return m.appendgroup_block_list, true
  38421. }
  38422. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38423. func (m *WxMutation) ResetGroupBlockList() {
  38424. m.group_block_list = nil
  38425. m.appendgroup_block_list = nil
  38426. }
  38427. // ClearServer clears the "server" edge to the Server entity.
  38428. func (m *WxMutation) ClearServer() {
  38429. m.clearedserver = true
  38430. m.clearedFields[wx.FieldServerID] = struct{}{}
  38431. }
  38432. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38433. func (m *WxMutation) ServerCleared() bool {
  38434. return m.ServerIDCleared() || m.clearedserver
  38435. }
  38436. // ServerIDs returns the "server" edge IDs in the mutation.
  38437. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38438. // ServerID instead. It exists only for internal usage by the builders.
  38439. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38440. if id := m.server; id != nil {
  38441. ids = append(ids, *id)
  38442. }
  38443. return
  38444. }
  38445. // ResetServer resets all changes to the "server" edge.
  38446. func (m *WxMutation) ResetServer() {
  38447. m.server = nil
  38448. m.clearedserver = false
  38449. }
  38450. // ClearAgent clears the "agent" edge to the Agent entity.
  38451. func (m *WxMutation) ClearAgent() {
  38452. m.clearedagent = true
  38453. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38454. }
  38455. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38456. func (m *WxMutation) AgentCleared() bool {
  38457. return m.clearedagent
  38458. }
  38459. // AgentIDs returns the "agent" edge IDs in the mutation.
  38460. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38461. // AgentID instead. It exists only for internal usage by the builders.
  38462. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38463. if id := m.agent; id != nil {
  38464. ids = append(ids, *id)
  38465. }
  38466. return
  38467. }
  38468. // ResetAgent resets all changes to the "agent" edge.
  38469. func (m *WxMutation) ResetAgent() {
  38470. m.agent = nil
  38471. m.clearedagent = false
  38472. }
  38473. // Where appends a list predicates to the WxMutation builder.
  38474. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38475. m.predicates = append(m.predicates, ps...)
  38476. }
  38477. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38478. // users can use type-assertion to append predicates that do not depend on any generated package.
  38479. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38480. p := make([]predicate.Wx, len(ps))
  38481. for i := range ps {
  38482. p[i] = ps[i]
  38483. }
  38484. m.Where(p...)
  38485. }
  38486. // Op returns the operation name.
  38487. func (m *WxMutation) Op() Op {
  38488. return m.op
  38489. }
  38490. // SetOp allows setting the mutation operation.
  38491. func (m *WxMutation) SetOp(op Op) {
  38492. m.op = op
  38493. }
  38494. // Type returns the node type of this mutation (Wx).
  38495. func (m *WxMutation) Type() string {
  38496. return m.typ
  38497. }
  38498. // Fields returns all fields that were changed during this mutation. Note that in
  38499. // order to get all numeric fields that were incremented/decremented, call
  38500. // AddedFields().
  38501. func (m *WxMutation) Fields() []string {
  38502. fields := make([]string, 0, 21)
  38503. if m.created_at != nil {
  38504. fields = append(fields, wx.FieldCreatedAt)
  38505. }
  38506. if m.updated_at != nil {
  38507. fields = append(fields, wx.FieldUpdatedAt)
  38508. }
  38509. if m.status != nil {
  38510. fields = append(fields, wx.FieldStatus)
  38511. }
  38512. if m.deleted_at != nil {
  38513. fields = append(fields, wx.FieldDeletedAt)
  38514. }
  38515. if m.server != nil {
  38516. fields = append(fields, wx.FieldServerID)
  38517. }
  38518. if m.port != nil {
  38519. fields = append(fields, wx.FieldPort)
  38520. }
  38521. if m.process_id != nil {
  38522. fields = append(fields, wx.FieldProcessID)
  38523. }
  38524. if m.callback != nil {
  38525. fields = append(fields, wx.FieldCallback)
  38526. }
  38527. if m.wxid != nil {
  38528. fields = append(fields, wx.FieldWxid)
  38529. }
  38530. if m.account != nil {
  38531. fields = append(fields, wx.FieldAccount)
  38532. }
  38533. if m.nickname != nil {
  38534. fields = append(fields, wx.FieldNickname)
  38535. }
  38536. if m.tel != nil {
  38537. fields = append(fields, wx.FieldTel)
  38538. }
  38539. if m.head_big != nil {
  38540. fields = append(fields, wx.FieldHeadBig)
  38541. }
  38542. if m.organization_id != nil {
  38543. fields = append(fields, wx.FieldOrganizationID)
  38544. }
  38545. if m.agent != nil {
  38546. fields = append(fields, wx.FieldAgentID)
  38547. }
  38548. if m.api_base != nil {
  38549. fields = append(fields, wx.FieldAPIBase)
  38550. }
  38551. if m.api_key != nil {
  38552. fields = append(fields, wx.FieldAPIKey)
  38553. }
  38554. if m.allow_list != nil {
  38555. fields = append(fields, wx.FieldAllowList)
  38556. }
  38557. if m.group_allow_list != nil {
  38558. fields = append(fields, wx.FieldGroupAllowList)
  38559. }
  38560. if m.block_list != nil {
  38561. fields = append(fields, wx.FieldBlockList)
  38562. }
  38563. if m.group_block_list != nil {
  38564. fields = append(fields, wx.FieldGroupBlockList)
  38565. }
  38566. return fields
  38567. }
  38568. // Field returns the value of a field with the given name. The second boolean
  38569. // return value indicates that this field was not set, or was not defined in the
  38570. // schema.
  38571. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38572. switch name {
  38573. case wx.FieldCreatedAt:
  38574. return m.CreatedAt()
  38575. case wx.FieldUpdatedAt:
  38576. return m.UpdatedAt()
  38577. case wx.FieldStatus:
  38578. return m.Status()
  38579. case wx.FieldDeletedAt:
  38580. return m.DeletedAt()
  38581. case wx.FieldServerID:
  38582. return m.ServerID()
  38583. case wx.FieldPort:
  38584. return m.Port()
  38585. case wx.FieldProcessID:
  38586. return m.ProcessID()
  38587. case wx.FieldCallback:
  38588. return m.Callback()
  38589. case wx.FieldWxid:
  38590. return m.Wxid()
  38591. case wx.FieldAccount:
  38592. return m.Account()
  38593. case wx.FieldNickname:
  38594. return m.Nickname()
  38595. case wx.FieldTel:
  38596. return m.Tel()
  38597. case wx.FieldHeadBig:
  38598. return m.HeadBig()
  38599. case wx.FieldOrganizationID:
  38600. return m.OrganizationID()
  38601. case wx.FieldAgentID:
  38602. return m.AgentID()
  38603. case wx.FieldAPIBase:
  38604. return m.APIBase()
  38605. case wx.FieldAPIKey:
  38606. return m.APIKey()
  38607. case wx.FieldAllowList:
  38608. return m.AllowList()
  38609. case wx.FieldGroupAllowList:
  38610. return m.GroupAllowList()
  38611. case wx.FieldBlockList:
  38612. return m.BlockList()
  38613. case wx.FieldGroupBlockList:
  38614. return m.GroupBlockList()
  38615. }
  38616. return nil, false
  38617. }
  38618. // OldField returns the old value of the field from the database. An error is
  38619. // returned if the mutation operation is not UpdateOne, or the query to the
  38620. // database failed.
  38621. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38622. switch name {
  38623. case wx.FieldCreatedAt:
  38624. return m.OldCreatedAt(ctx)
  38625. case wx.FieldUpdatedAt:
  38626. return m.OldUpdatedAt(ctx)
  38627. case wx.FieldStatus:
  38628. return m.OldStatus(ctx)
  38629. case wx.FieldDeletedAt:
  38630. return m.OldDeletedAt(ctx)
  38631. case wx.FieldServerID:
  38632. return m.OldServerID(ctx)
  38633. case wx.FieldPort:
  38634. return m.OldPort(ctx)
  38635. case wx.FieldProcessID:
  38636. return m.OldProcessID(ctx)
  38637. case wx.FieldCallback:
  38638. return m.OldCallback(ctx)
  38639. case wx.FieldWxid:
  38640. return m.OldWxid(ctx)
  38641. case wx.FieldAccount:
  38642. return m.OldAccount(ctx)
  38643. case wx.FieldNickname:
  38644. return m.OldNickname(ctx)
  38645. case wx.FieldTel:
  38646. return m.OldTel(ctx)
  38647. case wx.FieldHeadBig:
  38648. return m.OldHeadBig(ctx)
  38649. case wx.FieldOrganizationID:
  38650. return m.OldOrganizationID(ctx)
  38651. case wx.FieldAgentID:
  38652. return m.OldAgentID(ctx)
  38653. case wx.FieldAPIBase:
  38654. return m.OldAPIBase(ctx)
  38655. case wx.FieldAPIKey:
  38656. return m.OldAPIKey(ctx)
  38657. case wx.FieldAllowList:
  38658. return m.OldAllowList(ctx)
  38659. case wx.FieldGroupAllowList:
  38660. return m.OldGroupAllowList(ctx)
  38661. case wx.FieldBlockList:
  38662. return m.OldBlockList(ctx)
  38663. case wx.FieldGroupBlockList:
  38664. return m.OldGroupBlockList(ctx)
  38665. }
  38666. return nil, fmt.Errorf("unknown Wx field %s", name)
  38667. }
  38668. // SetField sets the value of a field with the given name. It returns an error if
  38669. // the field is not defined in the schema, or if the type mismatched the field
  38670. // type.
  38671. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38672. switch name {
  38673. case wx.FieldCreatedAt:
  38674. v, ok := value.(time.Time)
  38675. if !ok {
  38676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38677. }
  38678. m.SetCreatedAt(v)
  38679. return nil
  38680. case wx.FieldUpdatedAt:
  38681. v, ok := value.(time.Time)
  38682. if !ok {
  38683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38684. }
  38685. m.SetUpdatedAt(v)
  38686. return nil
  38687. case wx.FieldStatus:
  38688. v, ok := value.(uint8)
  38689. if !ok {
  38690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38691. }
  38692. m.SetStatus(v)
  38693. return nil
  38694. case wx.FieldDeletedAt:
  38695. v, ok := value.(time.Time)
  38696. if !ok {
  38697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38698. }
  38699. m.SetDeletedAt(v)
  38700. return nil
  38701. case wx.FieldServerID:
  38702. v, ok := value.(uint64)
  38703. if !ok {
  38704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38705. }
  38706. m.SetServerID(v)
  38707. return nil
  38708. case wx.FieldPort:
  38709. v, ok := value.(string)
  38710. if !ok {
  38711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38712. }
  38713. m.SetPort(v)
  38714. return nil
  38715. case wx.FieldProcessID:
  38716. v, ok := value.(string)
  38717. if !ok {
  38718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38719. }
  38720. m.SetProcessID(v)
  38721. return nil
  38722. case wx.FieldCallback:
  38723. v, ok := value.(string)
  38724. if !ok {
  38725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38726. }
  38727. m.SetCallback(v)
  38728. return nil
  38729. case wx.FieldWxid:
  38730. v, ok := value.(string)
  38731. if !ok {
  38732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38733. }
  38734. m.SetWxid(v)
  38735. return nil
  38736. case wx.FieldAccount:
  38737. v, ok := value.(string)
  38738. if !ok {
  38739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38740. }
  38741. m.SetAccount(v)
  38742. return nil
  38743. case wx.FieldNickname:
  38744. v, ok := value.(string)
  38745. if !ok {
  38746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38747. }
  38748. m.SetNickname(v)
  38749. return nil
  38750. case wx.FieldTel:
  38751. v, ok := value.(string)
  38752. if !ok {
  38753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38754. }
  38755. m.SetTel(v)
  38756. return nil
  38757. case wx.FieldHeadBig:
  38758. v, ok := value.(string)
  38759. if !ok {
  38760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38761. }
  38762. m.SetHeadBig(v)
  38763. return nil
  38764. case wx.FieldOrganizationID:
  38765. v, ok := value.(uint64)
  38766. if !ok {
  38767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38768. }
  38769. m.SetOrganizationID(v)
  38770. return nil
  38771. case wx.FieldAgentID:
  38772. v, ok := value.(uint64)
  38773. if !ok {
  38774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38775. }
  38776. m.SetAgentID(v)
  38777. return nil
  38778. case wx.FieldAPIBase:
  38779. v, ok := value.(string)
  38780. if !ok {
  38781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38782. }
  38783. m.SetAPIBase(v)
  38784. return nil
  38785. case wx.FieldAPIKey:
  38786. v, ok := value.(string)
  38787. if !ok {
  38788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38789. }
  38790. m.SetAPIKey(v)
  38791. return nil
  38792. case wx.FieldAllowList:
  38793. v, ok := value.([]string)
  38794. if !ok {
  38795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38796. }
  38797. m.SetAllowList(v)
  38798. return nil
  38799. case wx.FieldGroupAllowList:
  38800. v, ok := value.([]string)
  38801. if !ok {
  38802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38803. }
  38804. m.SetGroupAllowList(v)
  38805. return nil
  38806. case wx.FieldBlockList:
  38807. v, ok := value.([]string)
  38808. if !ok {
  38809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38810. }
  38811. m.SetBlockList(v)
  38812. return nil
  38813. case wx.FieldGroupBlockList:
  38814. v, ok := value.([]string)
  38815. if !ok {
  38816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38817. }
  38818. m.SetGroupBlockList(v)
  38819. return nil
  38820. }
  38821. return fmt.Errorf("unknown Wx field %s", name)
  38822. }
  38823. // AddedFields returns all numeric fields that were incremented/decremented during
  38824. // this mutation.
  38825. func (m *WxMutation) AddedFields() []string {
  38826. var fields []string
  38827. if m.addstatus != nil {
  38828. fields = append(fields, wx.FieldStatus)
  38829. }
  38830. if m.addorganization_id != nil {
  38831. fields = append(fields, wx.FieldOrganizationID)
  38832. }
  38833. return fields
  38834. }
  38835. // AddedField returns the numeric value that was incremented/decremented on a field
  38836. // with the given name. The second boolean return value indicates that this field
  38837. // was not set, or was not defined in the schema.
  38838. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38839. switch name {
  38840. case wx.FieldStatus:
  38841. return m.AddedStatus()
  38842. case wx.FieldOrganizationID:
  38843. return m.AddedOrganizationID()
  38844. }
  38845. return nil, false
  38846. }
  38847. // AddField adds the value to the field with the given name. It returns an error if
  38848. // the field is not defined in the schema, or if the type mismatched the field
  38849. // type.
  38850. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38851. switch name {
  38852. case wx.FieldStatus:
  38853. v, ok := value.(int8)
  38854. if !ok {
  38855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38856. }
  38857. m.AddStatus(v)
  38858. return nil
  38859. case wx.FieldOrganizationID:
  38860. v, ok := value.(int64)
  38861. if !ok {
  38862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38863. }
  38864. m.AddOrganizationID(v)
  38865. return nil
  38866. }
  38867. return fmt.Errorf("unknown Wx numeric field %s", name)
  38868. }
  38869. // ClearedFields returns all nullable fields that were cleared during this
  38870. // mutation.
  38871. func (m *WxMutation) ClearedFields() []string {
  38872. var fields []string
  38873. if m.FieldCleared(wx.FieldStatus) {
  38874. fields = append(fields, wx.FieldStatus)
  38875. }
  38876. if m.FieldCleared(wx.FieldDeletedAt) {
  38877. fields = append(fields, wx.FieldDeletedAt)
  38878. }
  38879. if m.FieldCleared(wx.FieldServerID) {
  38880. fields = append(fields, wx.FieldServerID)
  38881. }
  38882. if m.FieldCleared(wx.FieldOrganizationID) {
  38883. fields = append(fields, wx.FieldOrganizationID)
  38884. }
  38885. if m.FieldCleared(wx.FieldAPIBase) {
  38886. fields = append(fields, wx.FieldAPIBase)
  38887. }
  38888. if m.FieldCleared(wx.FieldAPIKey) {
  38889. fields = append(fields, wx.FieldAPIKey)
  38890. }
  38891. return fields
  38892. }
  38893. // FieldCleared returns a boolean indicating if a field with the given name was
  38894. // cleared in this mutation.
  38895. func (m *WxMutation) FieldCleared(name string) bool {
  38896. _, ok := m.clearedFields[name]
  38897. return ok
  38898. }
  38899. // ClearField clears the value of the field with the given name. It returns an
  38900. // error if the field is not defined in the schema.
  38901. func (m *WxMutation) ClearField(name string) error {
  38902. switch name {
  38903. case wx.FieldStatus:
  38904. m.ClearStatus()
  38905. return nil
  38906. case wx.FieldDeletedAt:
  38907. m.ClearDeletedAt()
  38908. return nil
  38909. case wx.FieldServerID:
  38910. m.ClearServerID()
  38911. return nil
  38912. case wx.FieldOrganizationID:
  38913. m.ClearOrganizationID()
  38914. return nil
  38915. case wx.FieldAPIBase:
  38916. m.ClearAPIBase()
  38917. return nil
  38918. case wx.FieldAPIKey:
  38919. m.ClearAPIKey()
  38920. return nil
  38921. }
  38922. return fmt.Errorf("unknown Wx nullable field %s", name)
  38923. }
  38924. // ResetField resets all changes in the mutation for the field with the given name.
  38925. // It returns an error if the field is not defined in the schema.
  38926. func (m *WxMutation) ResetField(name string) error {
  38927. switch name {
  38928. case wx.FieldCreatedAt:
  38929. m.ResetCreatedAt()
  38930. return nil
  38931. case wx.FieldUpdatedAt:
  38932. m.ResetUpdatedAt()
  38933. return nil
  38934. case wx.FieldStatus:
  38935. m.ResetStatus()
  38936. return nil
  38937. case wx.FieldDeletedAt:
  38938. m.ResetDeletedAt()
  38939. return nil
  38940. case wx.FieldServerID:
  38941. m.ResetServerID()
  38942. return nil
  38943. case wx.FieldPort:
  38944. m.ResetPort()
  38945. return nil
  38946. case wx.FieldProcessID:
  38947. m.ResetProcessID()
  38948. return nil
  38949. case wx.FieldCallback:
  38950. m.ResetCallback()
  38951. return nil
  38952. case wx.FieldWxid:
  38953. m.ResetWxid()
  38954. return nil
  38955. case wx.FieldAccount:
  38956. m.ResetAccount()
  38957. return nil
  38958. case wx.FieldNickname:
  38959. m.ResetNickname()
  38960. return nil
  38961. case wx.FieldTel:
  38962. m.ResetTel()
  38963. return nil
  38964. case wx.FieldHeadBig:
  38965. m.ResetHeadBig()
  38966. return nil
  38967. case wx.FieldOrganizationID:
  38968. m.ResetOrganizationID()
  38969. return nil
  38970. case wx.FieldAgentID:
  38971. m.ResetAgentID()
  38972. return nil
  38973. case wx.FieldAPIBase:
  38974. m.ResetAPIBase()
  38975. return nil
  38976. case wx.FieldAPIKey:
  38977. m.ResetAPIKey()
  38978. return nil
  38979. case wx.FieldAllowList:
  38980. m.ResetAllowList()
  38981. return nil
  38982. case wx.FieldGroupAllowList:
  38983. m.ResetGroupAllowList()
  38984. return nil
  38985. case wx.FieldBlockList:
  38986. m.ResetBlockList()
  38987. return nil
  38988. case wx.FieldGroupBlockList:
  38989. m.ResetGroupBlockList()
  38990. return nil
  38991. }
  38992. return fmt.Errorf("unknown Wx field %s", name)
  38993. }
  38994. // AddedEdges returns all edge names that were set/added in this mutation.
  38995. func (m *WxMutation) AddedEdges() []string {
  38996. edges := make([]string, 0, 2)
  38997. if m.server != nil {
  38998. edges = append(edges, wx.EdgeServer)
  38999. }
  39000. if m.agent != nil {
  39001. edges = append(edges, wx.EdgeAgent)
  39002. }
  39003. return edges
  39004. }
  39005. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39006. // name in this mutation.
  39007. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  39008. switch name {
  39009. case wx.EdgeServer:
  39010. if id := m.server; id != nil {
  39011. return []ent.Value{*id}
  39012. }
  39013. case wx.EdgeAgent:
  39014. if id := m.agent; id != nil {
  39015. return []ent.Value{*id}
  39016. }
  39017. }
  39018. return nil
  39019. }
  39020. // RemovedEdges returns all edge names that were removed in this mutation.
  39021. func (m *WxMutation) RemovedEdges() []string {
  39022. edges := make([]string, 0, 2)
  39023. return edges
  39024. }
  39025. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39026. // the given name in this mutation.
  39027. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  39028. return nil
  39029. }
  39030. // ClearedEdges returns all edge names that were cleared in this mutation.
  39031. func (m *WxMutation) ClearedEdges() []string {
  39032. edges := make([]string, 0, 2)
  39033. if m.clearedserver {
  39034. edges = append(edges, wx.EdgeServer)
  39035. }
  39036. if m.clearedagent {
  39037. edges = append(edges, wx.EdgeAgent)
  39038. }
  39039. return edges
  39040. }
  39041. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39042. // was cleared in this mutation.
  39043. func (m *WxMutation) EdgeCleared(name string) bool {
  39044. switch name {
  39045. case wx.EdgeServer:
  39046. return m.clearedserver
  39047. case wx.EdgeAgent:
  39048. return m.clearedagent
  39049. }
  39050. return false
  39051. }
  39052. // ClearEdge clears the value of the edge with the given name. It returns an error
  39053. // if that edge is not defined in the schema.
  39054. func (m *WxMutation) ClearEdge(name string) error {
  39055. switch name {
  39056. case wx.EdgeServer:
  39057. m.ClearServer()
  39058. return nil
  39059. case wx.EdgeAgent:
  39060. m.ClearAgent()
  39061. return nil
  39062. }
  39063. return fmt.Errorf("unknown Wx unique edge %s", name)
  39064. }
  39065. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39066. // It returns an error if the edge is not defined in the schema.
  39067. func (m *WxMutation) ResetEdge(name string) error {
  39068. switch name {
  39069. case wx.EdgeServer:
  39070. m.ResetServer()
  39071. return nil
  39072. case wx.EdgeAgent:
  39073. m.ResetAgent()
  39074. return nil
  39075. }
  39076. return fmt.Errorf("unknown Wx edge %s", name)
  39077. }
  39078. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  39079. type WxCardMutation struct {
  39080. config
  39081. op Op
  39082. typ string
  39083. id *uint64
  39084. created_at *time.Time
  39085. updated_at *time.Time
  39086. deleted_at *time.Time
  39087. user_id *uint64
  39088. adduser_id *int64
  39089. wx_user_id *uint64
  39090. addwx_user_id *int64
  39091. avatar *string
  39092. logo *string
  39093. name *string
  39094. company *string
  39095. address *string
  39096. phone *string
  39097. official_account *string
  39098. wechat_account *string
  39099. email *string
  39100. api_base *string
  39101. api_key *string
  39102. ai_info *string
  39103. intro *string
  39104. clearedFields map[string]struct{}
  39105. done bool
  39106. oldValue func(context.Context) (*WxCard, error)
  39107. predicates []predicate.WxCard
  39108. }
  39109. var _ ent.Mutation = (*WxCardMutation)(nil)
  39110. // wxcardOption allows management of the mutation configuration using functional options.
  39111. type wxcardOption func(*WxCardMutation)
  39112. // newWxCardMutation creates new mutation for the WxCard entity.
  39113. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  39114. m := &WxCardMutation{
  39115. config: c,
  39116. op: op,
  39117. typ: TypeWxCard,
  39118. clearedFields: make(map[string]struct{}),
  39119. }
  39120. for _, opt := range opts {
  39121. opt(m)
  39122. }
  39123. return m
  39124. }
  39125. // withWxCardID sets the ID field of the mutation.
  39126. func withWxCardID(id uint64) wxcardOption {
  39127. return func(m *WxCardMutation) {
  39128. var (
  39129. err error
  39130. once sync.Once
  39131. value *WxCard
  39132. )
  39133. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  39134. once.Do(func() {
  39135. if m.done {
  39136. err = errors.New("querying old values post mutation is not allowed")
  39137. } else {
  39138. value, err = m.Client().WxCard.Get(ctx, id)
  39139. }
  39140. })
  39141. return value, err
  39142. }
  39143. m.id = &id
  39144. }
  39145. }
  39146. // withWxCard sets the old WxCard of the mutation.
  39147. func withWxCard(node *WxCard) wxcardOption {
  39148. return func(m *WxCardMutation) {
  39149. m.oldValue = func(context.Context) (*WxCard, error) {
  39150. return node, nil
  39151. }
  39152. m.id = &node.ID
  39153. }
  39154. }
  39155. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39156. // executed in a transaction (ent.Tx), a transactional client is returned.
  39157. func (m WxCardMutation) Client() *Client {
  39158. client := &Client{config: m.config}
  39159. client.init()
  39160. return client
  39161. }
  39162. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39163. // it returns an error otherwise.
  39164. func (m WxCardMutation) Tx() (*Tx, error) {
  39165. if _, ok := m.driver.(*txDriver); !ok {
  39166. return nil, errors.New("ent: mutation is not running in a transaction")
  39167. }
  39168. tx := &Tx{config: m.config}
  39169. tx.init()
  39170. return tx, nil
  39171. }
  39172. // SetID sets the value of the id field. Note that this
  39173. // operation is only accepted on creation of WxCard entities.
  39174. func (m *WxCardMutation) SetID(id uint64) {
  39175. m.id = &id
  39176. }
  39177. // ID returns the ID value in the mutation. Note that the ID is only available
  39178. // if it was provided to the builder or after it was returned from the database.
  39179. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  39180. if m.id == nil {
  39181. return
  39182. }
  39183. return *m.id, true
  39184. }
  39185. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39186. // That means, if the mutation is applied within a transaction with an isolation level such
  39187. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39188. // or updated by the mutation.
  39189. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  39190. switch {
  39191. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39192. id, exists := m.ID()
  39193. if exists {
  39194. return []uint64{id}, nil
  39195. }
  39196. fallthrough
  39197. case m.op.Is(OpUpdate | OpDelete):
  39198. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  39199. default:
  39200. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39201. }
  39202. }
  39203. // SetCreatedAt sets the "created_at" field.
  39204. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  39205. m.created_at = &t
  39206. }
  39207. // CreatedAt returns the value of the "created_at" field in the mutation.
  39208. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  39209. v := m.created_at
  39210. if v == nil {
  39211. return
  39212. }
  39213. return *v, true
  39214. }
  39215. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  39216. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39218. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39219. if !m.op.Is(OpUpdateOne) {
  39220. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39221. }
  39222. if m.id == nil || m.oldValue == nil {
  39223. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39224. }
  39225. oldValue, err := m.oldValue(ctx)
  39226. if err != nil {
  39227. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39228. }
  39229. return oldValue.CreatedAt, nil
  39230. }
  39231. // ResetCreatedAt resets all changes to the "created_at" field.
  39232. func (m *WxCardMutation) ResetCreatedAt() {
  39233. m.created_at = nil
  39234. }
  39235. // SetUpdatedAt sets the "updated_at" field.
  39236. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  39237. m.updated_at = &t
  39238. }
  39239. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39240. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  39241. v := m.updated_at
  39242. if v == nil {
  39243. return
  39244. }
  39245. return *v, true
  39246. }
  39247. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  39248. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39250. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39251. if !m.op.Is(OpUpdateOne) {
  39252. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39253. }
  39254. if m.id == nil || m.oldValue == nil {
  39255. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39256. }
  39257. oldValue, err := m.oldValue(ctx)
  39258. if err != nil {
  39259. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39260. }
  39261. return oldValue.UpdatedAt, nil
  39262. }
  39263. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39264. func (m *WxCardMutation) ResetUpdatedAt() {
  39265. m.updated_at = nil
  39266. }
  39267. // SetDeletedAt sets the "deleted_at" field.
  39268. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39269. m.deleted_at = &t
  39270. }
  39271. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39272. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39273. v := m.deleted_at
  39274. if v == nil {
  39275. return
  39276. }
  39277. return *v, true
  39278. }
  39279. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39280. // If the WxCard 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 *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39283. if !m.op.Is(OpUpdateOne) {
  39284. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39285. }
  39286. if m.id == nil || m.oldValue == nil {
  39287. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  39292. }
  39293. return oldValue.DeletedAt, nil
  39294. }
  39295. // ClearDeletedAt clears the value of the "deleted_at" field.
  39296. func (m *WxCardMutation) ClearDeletedAt() {
  39297. m.deleted_at = nil
  39298. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39299. }
  39300. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39301. func (m *WxCardMutation) DeletedAtCleared() bool {
  39302. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39303. return ok
  39304. }
  39305. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39306. func (m *WxCardMutation) ResetDeletedAt() {
  39307. m.deleted_at = nil
  39308. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39309. }
  39310. // SetUserID sets the "user_id" field.
  39311. func (m *WxCardMutation) SetUserID(u uint64) {
  39312. m.user_id = &u
  39313. m.adduser_id = nil
  39314. }
  39315. // UserID returns the value of the "user_id" field in the mutation.
  39316. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39317. v := m.user_id
  39318. if v == nil {
  39319. return
  39320. }
  39321. return *v, true
  39322. }
  39323. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39324. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39326. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39327. if !m.op.Is(OpUpdateOne) {
  39328. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39329. }
  39330. if m.id == nil || m.oldValue == nil {
  39331. return v, errors.New("OldUserID requires an ID field in the mutation")
  39332. }
  39333. oldValue, err := m.oldValue(ctx)
  39334. if err != nil {
  39335. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39336. }
  39337. return oldValue.UserID, nil
  39338. }
  39339. // AddUserID adds u to the "user_id" field.
  39340. func (m *WxCardMutation) AddUserID(u int64) {
  39341. if m.adduser_id != nil {
  39342. *m.adduser_id += u
  39343. } else {
  39344. m.adduser_id = &u
  39345. }
  39346. }
  39347. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39348. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39349. v := m.adduser_id
  39350. if v == nil {
  39351. return
  39352. }
  39353. return *v, true
  39354. }
  39355. // ClearUserID clears the value of the "user_id" field.
  39356. func (m *WxCardMutation) ClearUserID() {
  39357. m.user_id = nil
  39358. m.adduser_id = nil
  39359. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39360. }
  39361. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39362. func (m *WxCardMutation) UserIDCleared() bool {
  39363. _, ok := m.clearedFields[wxcard.FieldUserID]
  39364. return ok
  39365. }
  39366. // ResetUserID resets all changes to the "user_id" field.
  39367. func (m *WxCardMutation) ResetUserID() {
  39368. m.user_id = nil
  39369. m.adduser_id = nil
  39370. delete(m.clearedFields, wxcard.FieldUserID)
  39371. }
  39372. // SetWxUserID sets the "wx_user_id" field.
  39373. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39374. m.wx_user_id = &u
  39375. m.addwx_user_id = nil
  39376. }
  39377. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39378. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39379. v := m.wx_user_id
  39380. if v == nil {
  39381. return
  39382. }
  39383. return *v, true
  39384. }
  39385. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39386. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39388. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39389. if !m.op.Is(OpUpdateOne) {
  39390. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39391. }
  39392. if m.id == nil || m.oldValue == nil {
  39393. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39394. }
  39395. oldValue, err := m.oldValue(ctx)
  39396. if err != nil {
  39397. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39398. }
  39399. return oldValue.WxUserID, nil
  39400. }
  39401. // AddWxUserID adds u to the "wx_user_id" field.
  39402. func (m *WxCardMutation) AddWxUserID(u int64) {
  39403. if m.addwx_user_id != nil {
  39404. *m.addwx_user_id += u
  39405. } else {
  39406. m.addwx_user_id = &u
  39407. }
  39408. }
  39409. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39410. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39411. v := m.addwx_user_id
  39412. if v == nil {
  39413. return
  39414. }
  39415. return *v, true
  39416. }
  39417. // ClearWxUserID clears the value of the "wx_user_id" field.
  39418. func (m *WxCardMutation) ClearWxUserID() {
  39419. m.wx_user_id = nil
  39420. m.addwx_user_id = nil
  39421. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39422. }
  39423. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39424. func (m *WxCardMutation) WxUserIDCleared() bool {
  39425. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39426. return ok
  39427. }
  39428. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39429. func (m *WxCardMutation) ResetWxUserID() {
  39430. m.wx_user_id = nil
  39431. m.addwx_user_id = nil
  39432. delete(m.clearedFields, wxcard.FieldWxUserID)
  39433. }
  39434. // SetAvatar sets the "avatar" field.
  39435. func (m *WxCardMutation) SetAvatar(s string) {
  39436. m.avatar = &s
  39437. }
  39438. // Avatar returns the value of the "avatar" field in the mutation.
  39439. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39440. v := m.avatar
  39441. if v == nil {
  39442. return
  39443. }
  39444. return *v, true
  39445. }
  39446. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39447. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39449. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39450. if !m.op.Is(OpUpdateOne) {
  39451. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39452. }
  39453. if m.id == nil || m.oldValue == nil {
  39454. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39455. }
  39456. oldValue, err := m.oldValue(ctx)
  39457. if err != nil {
  39458. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39459. }
  39460. return oldValue.Avatar, nil
  39461. }
  39462. // ResetAvatar resets all changes to the "avatar" field.
  39463. func (m *WxCardMutation) ResetAvatar() {
  39464. m.avatar = nil
  39465. }
  39466. // SetLogo sets the "logo" field.
  39467. func (m *WxCardMutation) SetLogo(s string) {
  39468. m.logo = &s
  39469. }
  39470. // Logo returns the value of the "logo" field in the mutation.
  39471. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39472. v := m.logo
  39473. if v == nil {
  39474. return
  39475. }
  39476. return *v, true
  39477. }
  39478. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39479. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39481. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39482. if !m.op.Is(OpUpdateOne) {
  39483. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39484. }
  39485. if m.id == nil || m.oldValue == nil {
  39486. return v, errors.New("OldLogo requires an ID field in the mutation")
  39487. }
  39488. oldValue, err := m.oldValue(ctx)
  39489. if err != nil {
  39490. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39491. }
  39492. return oldValue.Logo, nil
  39493. }
  39494. // ResetLogo resets all changes to the "logo" field.
  39495. func (m *WxCardMutation) ResetLogo() {
  39496. m.logo = nil
  39497. }
  39498. // SetName sets the "name" field.
  39499. func (m *WxCardMutation) SetName(s string) {
  39500. m.name = &s
  39501. }
  39502. // Name returns the value of the "name" field in the mutation.
  39503. func (m *WxCardMutation) Name() (r string, exists bool) {
  39504. v := m.name
  39505. if v == nil {
  39506. return
  39507. }
  39508. return *v, true
  39509. }
  39510. // OldName returns the old "name" field's value of the WxCard entity.
  39511. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39513. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39514. if !m.op.Is(OpUpdateOne) {
  39515. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39516. }
  39517. if m.id == nil || m.oldValue == nil {
  39518. return v, errors.New("OldName requires an ID field in the mutation")
  39519. }
  39520. oldValue, err := m.oldValue(ctx)
  39521. if err != nil {
  39522. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39523. }
  39524. return oldValue.Name, nil
  39525. }
  39526. // ResetName resets all changes to the "name" field.
  39527. func (m *WxCardMutation) ResetName() {
  39528. m.name = nil
  39529. }
  39530. // SetCompany sets the "company" field.
  39531. func (m *WxCardMutation) SetCompany(s string) {
  39532. m.company = &s
  39533. }
  39534. // Company returns the value of the "company" field in the mutation.
  39535. func (m *WxCardMutation) Company() (r string, exists bool) {
  39536. v := m.company
  39537. if v == nil {
  39538. return
  39539. }
  39540. return *v, true
  39541. }
  39542. // OldCompany returns the old "company" field's value of the WxCard entity.
  39543. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39545. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39546. if !m.op.Is(OpUpdateOne) {
  39547. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39548. }
  39549. if m.id == nil || m.oldValue == nil {
  39550. return v, errors.New("OldCompany requires an ID field in the mutation")
  39551. }
  39552. oldValue, err := m.oldValue(ctx)
  39553. if err != nil {
  39554. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39555. }
  39556. return oldValue.Company, nil
  39557. }
  39558. // ResetCompany resets all changes to the "company" field.
  39559. func (m *WxCardMutation) ResetCompany() {
  39560. m.company = nil
  39561. }
  39562. // SetAddress sets the "address" field.
  39563. func (m *WxCardMutation) SetAddress(s string) {
  39564. m.address = &s
  39565. }
  39566. // Address returns the value of the "address" field in the mutation.
  39567. func (m *WxCardMutation) Address() (r string, exists bool) {
  39568. v := m.address
  39569. if v == nil {
  39570. return
  39571. }
  39572. return *v, true
  39573. }
  39574. // OldAddress returns the old "address" field's value of the WxCard entity.
  39575. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39577. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39578. if !m.op.Is(OpUpdateOne) {
  39579. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39580. }
  39581. if m.id == nil || m.oldValue == nil {
  39582. return v, errors.New("OldAddress requires an ID field in the mutation")
  39583. }
  39584. oldValue, err := m.oldValue(ctx)
  39585. if err != nil {
  39586. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39587. }
  39588. return oldValue.Address, nil
  39589. }
  39590. // ResetAddress resets all changes to the "address" field.
  39591. func (m *WxCardMutation) ResetAddress() {
  39592. m.address = nil
  39593. }
  39594. // SetPhone sets the "phone" field.
  39595. func (m *WxCardMutation) SetPhone(s string) {
  39596. m.phone = &s
  39597. }
  39598. // Phone returns the value of the "phone" field in the mutation.
  39599. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39600. v := m.phone
  39601. if v == nil {
  39602. return
  39603. }
  39604. return *v, true
  39605. }
  39606. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39607. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39609. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39610. if !m.op.Is(OpUpdateOne) {
  39611. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39612. }
  39613. if m.id == nil || m.oldValue == nil {
  39614. return v, errors.New("OldPhone requires an ID field in the mutation")
  39615. }
  39616. oldValue, err := m.oldValue(ctx)
  39617. if err != nil {
  39618. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39619. }
  39620. return oldValue.Phone, nil
  39621. }
  39622. // ResetPhone resets all changes to the "phone" field.
  39623. func (m *WxCardMutation) ResetPhone() {
  39624. m.phone = nil
  39625. }
  39626. // SetOfficialAccount sets the "official_account" field.
  39627. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39628. m.official_account = &s
  39629. }
  39630. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39631. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39632. v := m.official_account
  39633. if v == nil {
  39634. return
  39635. }
  39636. return *v, true
  39637. }
  39638. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39639. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39641. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39642. if !m.op.Is(OpUpdateOne) {
  39643. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39644. }
  39645. if m.id == nil || m.oldValue == nil {
  39646. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39647. }
  39648. oldValue, err := m.oldValue(ctx)
  39649. if err != nil {
  39650. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39651. }
  39652. return oldValue.OfficialAccount, nil
  39653. }
  39654. // ResetOfficialAccount resets all changes to the "official_account" field.
  39655. func (m *WxCardMutation) ResetOfficialAccount() {
  39656. m.official_account = nil
  39657. }
  39658. // SetWechatAccount sets the "wechat_account" field.
  39659. func (m *WxCardMutation) SetWechatAccount(s string) {
  39660. m.wechat_account = &s
  39661. }
  39662. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39663. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39664. v := m.wechat_account
  39665. if v == nil {
  39666. return
  39667. }
  39668. return *v, true
  39669. }
  39670. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39671. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39673. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39674. if !m.op.Is(OpUpdateOne) {
  39675. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39676. }
  39677. if m.id == nil || m.oldValue == nil {
  39678. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39679. }
  39680. oldValue, err := m.oldValue(ctx)
  39681. if err != nil {
  39682. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39683. }
  39684. return oldValue.WechatAccount, nil
  39685. }
  39686. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39687. func (m *WxCardMutation) ResetWechatAccount() {
  39688. m.wechat_account = nil
  39689. }
  39690. // SetEmail sets the "email" field.
  39691. func (m *WxCardMutation) SetEmail(s string) {
  39692. m.email = &s
  39693. }
  39694. // Email returns the value of the "email" field in the mutation.
  39695. func (m *WxCardMutation) Email() (r string, exists bool) {
  39696. v := m.email
  39697. if v == nil {
  39698. return
  39699. }
  39700. return *v, true
  39701. }
  39702. // OldEmail returns the old "email" field's value of the WxCard entity.
  39703. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39705. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39706. if !m.op.Is(OpUpdateOne) {
  39707. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39708. }
  39709. if m.id == nil || m.oldValue == nil {
  39710. return v, errors.New("OldEmail requires an ID field in the mutation")
  39711. }
  39712. oldValue, err := m.oldValue(ctx)
  39713. if err != nil {
  39714. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39715. }
  39716. return oldValue.Email, nil
  39717. }
  39718. // ClearEmail clears the value of the "email" field.
  39719. func (m *WxCardMutation) ClearEmail() {
  39720. m.email = nil
  39721. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39722. }
  39723. // EmailCleared returns if the "email" field was cleared in this mutation.
  39724. func (m *WxCardMutation) EmailCleared() bool {
  39725. _, ok := m.clearedFields[wxcard.FieldEmail]
  39726. return ok
  39727. }
  39728. // ResetEmail resets all changes to the "email" field.
  39729. func (m *WxCardMutation) ResetEmail() {
  39730. m.email = nil
  39731. delete(m.clearedFields, wxcard.FieldEmail)
  39732. }
  39733. // SetAPIBase sets the "api_base" field.
  39734. func (m *WxCardMutation) SetAPIBase(s string) {
  39735. m.api_base = &s
  39736. }
  39737. // APIBase returns the value of the "api_base" field in the mutation.
  39738. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39739. v := m.api_base
  39740. if v == nil {
  39741. return
  39742. }
  39743. return *v, true
  39744. }
  39745. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39746. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39748. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39749. if !m.op.Is(OpUpdateOne) {
  39750. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39751. }
  39752. if m.id == nil || m.oldValue == nil {
  39753. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39754. }
  39755. oldValue, err := m.oldValue(ctx)
  39756. if err != nil {
  39757. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39758. }
  39759. return oldValue.APIBase, nil
  39760. }
  39761. // ClearAPIBase clears the value of the "api_base" field.
  39762. func (m *WxCardMutation) ClearAPIBase() {
  39763. m.api_base = nil
  39764. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39765. }
  39766. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39767. func (m *WxCardMutation) APIBaseCleared() bool {
  39768. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39769. return ok
  39770. }
  39771. // ResetAPIBase resets all changes to the "api_base" field.
  39772. func (m *WxCardMutation) ResetAPIBase() {
  39773. m.api_base = nil
  39774. delete(m.clearedFields, wxcard.FieldAPIBase)
  39775. }
  39776. // SetAPIKey sets the "api_key" field.
  39777. func (m *WxCardMutation) SetAPIKey(s string) {
  39778. m.api_key = &s
  39779. }
  39780. // APIKey returns the value of the "api_key" field in the mutation.
  39781. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39782. v := m.api_key
  39783. if v == nil {
  39784. return
  39785. }
  39786. return *v, true
  39787. }
  39788. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39789. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39791. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39792. if !m.op.Is(OpUpdateOne) {
  39793. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39794. }
  39795. if m.id == nil || m.oldValue == nil {
  39796. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39797. }
  39798. oldValue, err := m.oldValue(ctx)
  39799. if err != nil {
  39800. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39801. }
  39802. return oldValue.APIKey, nil
  39803. }
  39804. // ClearAPIKey clears the value of the "api_key" field.
  39805. func (m *WxCardMutation) ClearAPIKey() {
  39806. m.api_key = nil
  39807. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39808. }
  39809. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39810. func (m *WxCardMutation) APIKeyCleared() bool {
  39811. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39812. return ok
  39813. }
  39814. // ResetAPIKey resets all changes to the "api_key" field.
  39815. func (m *WxCardMutation) ResetAPIKey() {
  39816. m.api_key = nil
  39817. delete(m.clearedFields, wxcard.FieldAPIKey)
  39818. }
  39819. // SetAiInfo sets the "ai_info" field.
  39820. func (m *WxCardMutation) SetAiInfo(s string) {
  39821. m.ai_info = &s
  39822. }
  39823. // AiInfo returns the value of the "ai_info" field in the mutation.
  39824. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39825. v := m.ai_info
  39826. if v == nil {
  39827. return
  39828. }
  39829. return *v, true
  39830. }
  39831. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  39832. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39834. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  39835. if !m.op.Is(OpUpdateOne) {
  39836. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39837. }
  39838. if m.id == nil || m.oldValue == nil {
  39839. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  39840. }
  39841. oldValue, err := m.oldValue(ctx)
  39842. if err != nil {
  39843. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  39844. }
  39845. return oldValue.AiInfo, nil
  39846. }
  39847. // ClearAiInfo clears the value of the "ai_info" field.
  39848. func (m *WxCardMutation) ClearAiInfo() {
  39849. m.ai_info = nil
  39850. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39851. }
  39852. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39853. func (m *WxCardMutation) AiInfoCleared() bool {
  39854. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39855. return ok
  39856. }
  39857. // ResetAiInfo resets all changes to the "ai_info" field.
  39858. func (m *WxCardMutation) ResetAiInfo() {
  39859. m.ai_info = nil
  39860. delete(m.clearedFields, wxcard.FieldAiInfo)
  39861. }
  39862. // SetIntro sets the "intro" field.
  39863. func (m *WxCardMutation) SetIntro(s string) {
  39864. m.intro = &s
  39865. }
  39866. // Intro returns the value of the "intro" field in the mutation.
  39867. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39868. v := m.intro
  39869. if v == nil {
  39870. return
  39871. }
  39872. return *v, true
  39873. }
  39874. // OldIntro returns the old "intro" field's value of the WxCard entity.
  39875. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39877. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  39878. if !m.op.Is(OpUpdateOne) {
  39879. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39880. }
  39881. if m.id == nil || m.oldValue == nil {
  39882. return v, errors.New("OldIntro requires an ID field in the mutation")
  39883. }
  39884. oldValue, err := m.oldValue(ctx)
  39885. if err != nil {
  39886. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  39887. }
  39888. return oldValue.Intro, nil
  39889. }
  39890. // ClearIntro clears the value of the "intro" field.
  39891. func (m *WxCardMutation) ClearIntro() {
  39892. m.intro = nil
  39893. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39894. }
  39895. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39896. func (m *WxCardMutation) IntroCleared() bool {
  39897. _, ok := m.clearedFields[wxcard.FieldIntro]
  39898. return ok
  39899. }
  39900. // ResetIntro resets all changes to the "intro" field.
  39901. func (m *WxCardMutation) ResetIntro() {
  39902. m.intro = nil
  39903. delete(m.clearedFields, wxcard.FieldIntro)
  39904. }
  39905. // Where appends a list predicates to the WxCardMutation builder.
  39906. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39907. m.predicates = append(m.predicates, ps...)
  39908. }
  39909. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39910. // users can use type-assertion to append predicates that do not depend on any generated package.
  39911. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39912. p := make([]predicate.WxCard, len(ps))
  39913. for i := range ps {
  39914. p[i] = ps[i]
  39915. }
  39916. m.Where(p...)
  39917. }
  39918. // Op returns the operation name.
  39919. func (m *WxCardMutation) Op() Op {
  39920. return m.op
  39921. }
  39922. // SetOp allows setting the mutation operation.
  39923. func (m *WxCardMutation) SetOp(op Op) {
  39924. m.op = op
  39925. }
  39926. // Type returns the node type of this mutation (WxCard).
  39927. func (m *WxCardMutation) Type() string {
  39928. return m.typ
  39929. }
  39930. // Fields returns all fields that were changed during this mutation. Note that in
  39931. // order to get all numeric fields that were incremented/decremented, call
  39932. // AddedFields().
  39933. func (m *WxCardMutation) Fields() []string {
  39934. fields := make([]string, 0, 18)
  39935. if m.created_at != nil {
  39936. fields = append(fields, wxcard.FieldCreatedAt)
  39937. }
  39938. if m.updated_at != nil {
  39939. fields = append(fields, wxcard.FieldUpdatedAt)
  39940. }
  39941. if m.deleted_at != nil {
  39942. fields = append(fields, wxcard.FieldDeletedAt)
  39943. }
  39944. if m.user_id != nil {
  39945. fields = append(fields, wxcard.FieldUserID)
  39946. }
  39947. if m.wx_user_id != nil {
  39948. fields = append(fields, wxcard.FieldWxUserID)
  39949. }
  39950. if m.avatar != nil {
  39951. fields = append(fields, wxcard.FieldAvatar)
  39952. }
  39953. if m.logo != nil {
  39954. fields = append(fields, wxcard.FieldLogo)
  39955. }
  39956. if m.name != nil {
  39957. fields = append(fields, wxcard.FieldName)
  39958. }
  39959. if m.company != nil {
  39960. fields = append(fields, wxcard.FieldCompany)
  39961. }
  39962. if m.address != nil {
  39963. fields = append(fields, wxcard.FieldAddress)
  39964. }
  39965. if m.phone != nil {
  39966. fields = append(fields, wxcard.FieldPhone)
  39967. }
  39968. if m.official_account != nil {
  39969. fields = append(fields, wxcard.FieldOfficialAccount)
  39970. }
  39971. if m.wechat_account != nil {
  39972. fields = append(fields, wxcard.FieldWechatAccount)
  39973. }
  39974. if m.email != nil {
  39975. fields = append(fields, wxcard.FieldEmail)
  39976. }
  39977. if m.api_base != nil {
  39978. fields = append(fields, wxcard.FieldAPIBase)
  39979. }
  39980. if m.api_key != nil {
  39981. fields = append(fields, wxcard.FieldAPIKey)
  39982. }
  39983. if m.ai_info != nil {
  39984. fields = append(fields, wxcard.FieldAiInfo)
  39985. }
  39986. if m.intro != nil {
  39987. fields = append(fields, wxcard.FieldIntro)
  39988. }
  39989. return fields
  39990. }
  39991. // Field returns the value of a field with the given name. The second boolean
  39992. // return value indicates that this field was not set, or was not defined in the
  39993. // schema.
  39994. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39995. switch name {
  39996. case wxcard.FieldCreatedAt:
  39997. return m.CreatedAt()
  39998. case wxcard.FieldUpdatedAt:
  39999. return m.UpdatedAt()
  40000. case wxcard.FieldDeletedAt:
  40001. return m.DeletedAt()
  40002. case wxcard.FieldUserID:
  40003. return m.UserID()
  40004. case wxcard.FieldWxUserID:
  40005. return m.WxUserID()
  40006. case wxcard.FieldAvatar:
  40007. return m.Avatar()
  40008. case wxcard.FieldLogo:
  40009. return m.Logo()
  40010. case wxcard.FieldName:
  40011. return m.Name()
  40012. case wxcard.FieldCompany:
  40013. return m.Company()
  40014. case wxcard.FieldAddress:
  40015. return m.Address()
  40016. case wxcard.FieldPhone:
  40017. return m.Phone()
  40018. case wxcard.FieldOfficialAccount:
  40019. return m.OfficialAccount()
  40020. case wxcard.FieldWechatAccount:
  40021. return m.WechatAccount()
  40022. case wxcard.FieldEmail:
  40023. return m.Email()
  40024. case wxcard.FieldAPIBase:
  40025. return m.APIBase()
  40026. case wxcard.FieldAPIKey:
  40027. return m.APIKey()
  40028. case wxcard.FieldAiInfo:
  40029. return m.AiInfo()
  40030. case wxcard.FieldIntro:
  40031. return m.Intro()
  40032. }
  40033. return nil, false
  40034. }
  40035. // OldField returns the old value of the field from the database. An error is
  40036. // returned if the mutation operation is not UpdateOne, or the query to the
  40037. // database failed.
  40038. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40039. switch name {
  40040. case wxcard.FieldCreatedAt:
  40041. return m.OldCreatedAt(ctx)
  40042. case wxcard.FieldUpdatedAt:
  40043. return m.OldUpdatedAt(ctx)
  40044. case wxcard.FieldDeletedAt:
  40045. return m.OldDeletedAt(ctx)
  40046. case wxcard.FieldUserID:
  40047. return m.OldUserID(ctx)
  40048. case wxcard.FieldWxUserID:
  40049. return m.OldWxUserID(ctx)
  40050. case wxcard.FieldAvatar:
  40051. return m.OldAvatar(ctx)
  40052. case wxcard.FieldLogo:
  40053. return m.OldLogo(ctx)
  40054. case wxcard.FieldName:
  40055. return m.OldName(ctx)
  40056. case wxcard.FieldCompany:
  40057. return m.OldCompany(ctx)
  40058. case wxcard.FieldAddress:
  40059. return m.OldAddress(ctx)
  40060. case wxcard.FieldPhone:
  40061. return m.OldPhone(ctx)
  40062. case wxcard.FieldOfficialAccount:
  40063. return m.OldOfficialAccount(ctx)
  40064. case wxcard.FieldWechatAccount:
  40065. return m.OldWechatAccount(ctx)
  40066. case wxcard.FieldEmail:
  40067. return m.OldEmail(ctx)
  40068. case wxcard.FieldAPIBase:
  40069. return m.OldAPIBase(ctx)
  40070. case wxcard.FieldAPIKey:
  40071. return m.OldAPIKey(ctx)
  40072. case wxcard.FieldAiInfo:
  40073. return m.OldAiInfo(ctx)
  40074. case wxcard.FieldIntro:
  40075. return m.OldIntro(ctx)
  40076. }
  40077. return nil, fmt.Errorf("unknown WxCard field %s", name)
  40078. }
  40079. // SetField sets the value of a field with the given name. It returns an error if
  40080. // the field is not defined in the schema, or if the type mismatched the field
  40081. // type.
  40082. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  40083. switch name {
  40084. case wxcard.FieldCreatedAt:
  40085. v, ok := value.(time.Time)
  40086. if !ok {
  40087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40088. }
  40089. m.SetCreatedAt(v)
  40090. return nil
  40091. case wxcard.FieldUpdatedAt:
  40092. v, ok := value.(time.Time)
  40093. if !ok {
  40094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40095. }
  40096. m.SetUpdatedAt(v)
  40097. return nil
  40098. case wxcard.FieldDeletedAt:
  40099. v, ok := value.(time.Time)
  40100. if !ok {
  40101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40102. }
  40103. m.SetDeletedAt(v)
  40104. return nil
  40105. case wxcard.FieldUserID:
  40106. v, ok := value.(uint64)
  40107. if !ok {
  40108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40109. }
  40110. m.SetUserID(v)
  40111. return nil
  40112. case wxcard.FieldWxUserID:
  40113. v, ok := value.(uint64)
  40114. if !ok {
  40115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40116. }
  40117. m.SetWxUserID(v)
  40118. return nil
  40119. case wxcard.FieldAvatar:
  40120. v, ok := value.(string)
  40121. if !ok {
  40122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40123. }
  40124. m.SetAvatar(v)
  40125. return nil
  40126. case wxcard.FieldLogo:
  40127. v, ok := value.(string)
  40128. if !ok {
  40129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40130. }
  40131. m.SetLogo(v)
  40132. return nil
  40133. case wxcard.FieldName:
  40134. v, ok := value.(string)
  40135. if !ok {
  40136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40137. }
  40138. m.SetName(v)
  40139. return nil
  40140. case wxcard.FieldCompany:
  40141. v, ok := value.(string)
  40142. if !ok {
  40143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40144. }
  40145. m.SetCompany(v)
  40146. return nil
  40147. case wxcard.FieldAddress:
  40148. v, ok := value.(string)
  40149. if !ok {
  40150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40151. }
  40152. m.SetAddress(v)
  40153. return nil
  40154. case wxcard.FieldPhone:
  40155. v, ok := value.(string)
  40156. if !ok {
  40157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40158. }
  40159. m.SetPhone(v)
  40160. return nil
  40161. case wxcard.FieldOfficialAccount:
  40162. v, ok := value.(string)
  40163. if !ok {
  40164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40165. }
  40166. m.SetOfficialAccount(v)
  40167. return nil
  40168. case wxcard.FieldWechatAccount:
  40169. v, ok := value.(string)
  40170. if !ok {
  40171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40172. }
  40173. m.SetWechatAccount(v)
  40174. return nil
  40175. case wxcard.FieldEmail:
  40176. v, ok := value.(string)
  40177. if !ok {
  40178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40179. }
  40180. m.SetEmail(v)
  40181. return nil
  40182. case wxcard.FieldAPIBase:
  40183. v, ok := value.(string)
  40184. if !ok {
  40185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40186. }
  40187. m.SetAPIBase(v)
  40188. return nil
  40189. case wxcard.FieldAPIKey:
  40190. v, ok := value.(string)
  40191. if !ok {
  40192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40193. }
  40194. m.SetAPIKey(v)
  40195. return nil
  40196. case wxcard.FieldAiInfo:
  40197. v, ok := value.(string)
  40198. if !ok {
  40199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40200. }
  40201. m.SetAiInfo(v)
  40202. return nil
  40203. case wxcard.FieldIntro:
  40204. v, ok := value.(string)
  40205. if !ok {
  40206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40207. }
  40208. m.SetIntro(v)
  40209. return nil
  40210. }
  40211. return fmt.Errorf("unknown WxCard field %s", name)
  40212. }
  40213. // AddedFields returns all numeric fields that were incremented/decremented during
  40214. // this mutation.
  40215. func (m *WxCardMutation) AddedFields() []string {
  40216. var fields []string
  40217. if m.adduser_id != nil {
  40218. fields = append(fields, wxcard.FieldUserID)
  40219. }
  40220. if m.addwx_user_id != nil {
  40221. fields = append(fields, wxcard.FieldWxUserID)
  40222. }
  40223. return fields
  40224. }
  40225. // AddedField returns the numeric value that was incremented/decremented on a field
  40226. // with the given name. The second boolean return value indicates that this field
  40227. // was not set, or was not defined in the schema.
  40228. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  40229. switch name {
  40230. case wxcard.FieldUserID:
  40231. return m.AddedUserID()
  40232. case wxcard.FieldWxUserID:
  40233. return m.AddedWxUserID()
  40234. }
  40235. return nil, false
  40236. }
  40237. // AddField adds the value to the field with the given name. It returns an error if
  40238. // the field is not defined in the schema, or if the type mismatched the field
  40239. // type.
  40240. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  40241. switch name {
  40242. case wxcard.FieldUserID:
  40243. v, ok := value.(int64)
  40244. if !ok {
  40245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40246. }
  40247. m.AddUserID(v)
  40248. return nil
  40249. case wxcard.FieldWxUserID:
  40250. v, ok := value.(int64)
  40251. if !ok {
  40252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40253. }
  40254. m.AddWxUserID(v)
  40255. return nil
  40256. }
  40257. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40258. }
  40259. // ClearedFields returns all nullable fields that were cleared during this
  40260. // mutation.
  40261. func (m *WxCardMutation) ClearedFields() []string {
  40262. var fields []string
  40263. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40264. fields = append(fields, wxcard.FieldDeletedAt)
  40265. }
  40266. if m.FieldCleared(wxcard.FieldUserID) {
  40267. fields = append(fields, wxcard.FieldUserID)
  40268. }
  40269. if m.FieldCleared(wxcard.FieldWxUserID) {
  40270. fields = append(fields, wxcard.FieldWxUserID)
  40271. }
  40272. if m.FieldCleared(wxcard.FieldEmail) {
  40273. fields = append(fields, wxcard.FieldEmail)
  40274. }
  40275. if m.FieldCleared(wxcard.FieldAPIBase) {
  40276. fields = append(fields, wxcard.FieldAPIBase)
  40277. }
  40278. if m.FieldCleared(wxcard.FieldAPIKey) {
  40279. fields = append(fields, wxcard.FieldAPIKey)
  40280. }
  40281. if m.FieldCleared(wxcard.FieldAiInfo) {
  40282. fields = append(fields, wxcard.FieldAiInfo)
  40283. }
  40284. if m.FieldCleared(wxcard.FieldIntro) {
  40285. fields = append(fields, wxcard.FieldIntro)
  40286. }
  40287. return fields
  40288. }
  40289. // FieldCleared returns a boolean indicating if a field with the given name was
  40290. // cleared in this mutation.
  40291. func (m *WxCardMutation) FieldCleared(name string) bool {
  40292. _, ok := m.clearedFields[name]
  40293. return ok
  40294. }
  40295. // ClearField clears the value of the field with the given name. It returns an
  40296. // error if the field is not defined in the schema.
  40297. func (m *WxCardMutation) ClearField(name string) error {
  40298. switch name {
  40299. case wxcard.FieldDeletedAt:
  40300. m.ClearDeletedAt()
  40301. return nil
  40302. case wxcard.FieldUserID:
  40303. m.ClearUserID()
  40304. return nil
  40305. case wxcard.FieldWxUserID:
  40306. m.ClearWxUserID()
  40307. return nil
  40308. case wxcard.FieldEmail:
  40309. m.ClearEmail()
  40310. return nil
  40311. case wxcard.FieldAPIBase:
  40312. m.ClearAPIBase()
  40313. return nil
  40314. case wxcard.FieldAPIKey:
  40315. m.ClearAPIKey()
  40316. return nil
  40317. case wxcard.FieldAiInfo:
  40318. m.ClearAiInfo()
  40319. return nil
  40320. case wxcard.FieldIntro:
  40321. m.ClearIntro()
  40322. return nil
  40323. }
  40324. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40325. }
  40326. // ResetField resets all changes in the mutation for the field with the given name.
  40327. // It returns an error if the field is not defined in the schema.
  40328. func (m *WxCardMutation) ResetField(name string) error {
  40329. switch name {
  40330. case wxcard.FieldCreatedAt:
  40331. m.ResetCreatedAt()
  40332. return nil
  40333. case wxcard.FieldUpdatedAt:
  40334. m.ResetUpdatedAt()
  40335. return nil
  40336. case wxcard.FieldDeletedAt:
  40337. m.ResetDeletedAt()
  40338. return nil
  40339. case wxcard.FieldUserID:
  40340. m.ResetUserID()
  40341. return nil
  40342. case wxcard.FieldWxUserID:
  40343. m.ResetWxUserID()
  40344. return nil
  40345. case wxcard.FieldAvatar:
  40346. m.ResetAvatar()
  40347. return nil
  40348. case wxcard.FieldLogo:
  40349. m.ResetLogo()
  40350. return nil
  40351. case wxcard.FieldName:
  40352. m.ResetName()
  40353. return nil
  40354. case wxcard.FieldCompany:
  40355. m.ResetCompany()
  40356. return nil
  40357. case wxcard.FieldAddress:
  40358. m.ResetAddress()
  40359. return nil
  40360. case wxcard.FieldPhone:
  40361. m.ResetPhone()
  40362. return nil
  40363. case wxcard.FieldOfficialAccount:
  40364. m.ResetOfficialAccount()
  40365. return nil
  40366. case wxcard.FieldWechatAccount:
  40367. m.ResetWechatAccount()
  40368. return nil
  40369. case wxcard.FieldEmail:
  40370. m.ResetEmail()
  40371. return nil
  40372. case wxcard.FieldAPIBase:
  40373. m.ResetAPIBase()
  40374. return nil
  40375. case wxcard.FieldAPIKey:
  40376. m.ResetAPIKey()
  40377. return nil
  40378. case wxcard.FieldAiInfo:
  40379. m.ResetAiInfo()
  40380. return nil
  40381. case wxcard.FieldIntro:
  40382. m.ResetIntro()
  40383. return nil
  40384. }
  40385. return fmt.Errorf("unknown WxCard field %s", name)
  40386. }
  40387. // AddedEdges returns all edge names that were set/added in this mutation.
  40388. func (m *WxCardMutation) AddedEdges() []string {
  40389. edges := make([]string, 0, 0)
  40390. return edges
  40391. }
  40392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40393. // name in this mutation.
  40394. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40395. return nil
  40396. }
  40397. // RemovedEdges returns all edge names that were removed in this mutation.
  40398. func (m *WxCardMutation) RemovedEdges() []string {
  40399. edges := make([]string, 0, 0)
  40400. return edges
  40401. }
  40402. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40403. // the given name in this mutation.
  40404. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40405. return nil
  40406. }
  40407. // ClearedEdges returns all edge names that were cleared in this mutation.
  40408. func (m *WxCardMutation) ClearedEdges() []string {
  40409. edges := make([]string, 0, 0)
  40410. return edges
  40411. }
  40412. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40413. // was cleared in this mutation.
  40414. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40415. return false
  40416. }
  40417. // ClearEdge clears the value of the edge with the given name. It returns an error
  40418. // if that edge is not defined in the schema.
  40419. func (m *WxCardMutation) ClearEdge(name string) error {
  40420. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40421. }
  40422. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40423. // It returns an error if the edge is not defined in the schema.
  40424. func (m *WxCardMutation) ResetEdge(name string) error {
  40425. return fmt.Errorf("unknown WxCard edge %s", name)
  40426. }
  40427. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40428. type WxCardUserMutation struct {
  40429. config
  40430. op Op
  40431. typ string
  40432. id *uint64
  40433. created_at *time.Time
  40434. updated_at *time.Time
  40435. deleted_at *time.Time
  40436. wxid *string
  40437. account *string
  40438. avatar *string
  40439. nickname *string
  40440. remark *string
  40441. phone *string
  40442. open_id *string
  40443. union_id *string
  40444. session_key *string
  40445. is_vip *int
  40446. addis_vip *int
  40447. clearedFields map[string]struct{}
  40448. done bool
  40449. oldValue func(context.Context) (*WxCardUser, error)
  40450. predicates []predicate.WxCardUser
  40451. }
  40452. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40453. // wxcarduserOption allows management of the mutation configuration using functional options.
  40454. type wxcarduserOption func(*WxCardUserMutation)
  40455. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40456. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40457. m := &WxCardUserMutation{
  40458. config: c,
  40459. op: op,
  40460. typ: TypeWxCardUser,
  40461. clearedFields: make(map[string]struct{}),
  40462. }
  40463. for _, opt := range opts {
  40464. opt(m)
  40465. }
  40466. return m
  40467. }
  40468. // withWxCardUserID sets the ID field of the mutation.
  40469. func withWxCardUserID(id uint64) wxcarduserOption {
  40470. return func(m *WxCardUserMutation) {
  40471. var (
  40472. err error
  40473. once sync.Once
  40474. value *WxCardUser
  40475. )
  40476. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40477. once.Do(func() {
  40478. if m.done {
  40479. err = errors.New("querying old values post mutation is not allowed")
  40480. } else {
  40481. value, err = m.Client().WxCardUser.Get(ctx, id)
  40482. }
  40483. })
  40484. return value, err
  40485. }
  40486. m.id = &id
  40487. }
  40488. }
  40489. // withWxCardUser sets the old WxCardUser of the mutation.
  40490. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40491. return func(m *WxCardUserMutation) {
  40492. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40493. return node, nil
  40494. }
  40495. m.id = &node.ID
  40496. }
  40497. }
  40498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40499. // executed in a transaction (ent.Tx), a transactional client is returned.
  40500. func (m WxCardUserMutation) Client() *Client {
  40501. client := &Client{config: m.config}
  40502. client.init()
  40503. return client
  40504. }
  40505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40506. // it returns an error otherwise.
  40507. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40508. if _, ok := m.driver.(*txDriver); !ok {
  40509. return nil, errors.New("ent: mutation is not running in a transaction")
  40510. }
  40511. tx := &Tx{config: m.config}
  40512. tx.init()
  40513. return tx, nil
  40514. }
  40515. // SetID sets the value of the id field. Note that this
  40516. // operation is only accepted on creation of WxCardUser entities.
  40517. func (m *WxCardUserMutation) SetID(id uint64) {
  40518. m.id = &id
  40519. }
  40520. // ID returns the ID value in the mutation. Note that the ID is only available
  40521. // if it was provided to the builder or after it was returned from the database.
  40522. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40523. if m.id == nil {
  40524. return
  40525. }
  40526. return *m.id, true
  40527. }
  40528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40529. // That means, if the mutation is applied within a transaction with an isolation level such
  40530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40531. // or updated by the mutation.
  40532. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40533. switch {
  40534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40535. id, exists := m.ID()
  40536. if exists {
  40537. return []uint64{id}, nil
  40538. }
  40539. fallthrough
  40540. case m.op.Is(OpUpdate | OpDelete):
  40541. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40542. default:
  40543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40544. }
  40545. }
  40546. // SetCreatedAt sets the "created_at" field.
  40547. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40548. m.created_at = &t
  40549. }
  40550. // CreatedAt returns the value of the "created_at" field in the mutation.
  40551. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40552. v := m.created_at
  40553. if v == nil {
  40554. return
  40555. }
  40556. return *v, true
  40557. }
  40558. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40559. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40561. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40562. if !m.op.Is(OpUpdateOne) {
  40563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40564. }
  40565. if m.id == nil || m.oldValue == nil {
  40566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40567. }
  40568. oldValue, err := m.oldValue(ctx)
  40569. if err != nil {
  40570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40571. }
  40572. return oldValue.CreatedAt, nil
  40573. }
  40574. // ResetCreatedAt resets all changes to the "created_at" field.
  40575. func (m *WxCardUserMutation) ResetCreatedAt() {
  40576. m.created_at = nil
  40577. }
  40578. // SetUpdatedAt sets the "updated_at" field.
  40579. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40580. m.updated_at = &t
  40581. }
  40582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40583. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40584. v := m.updated_at
  40585. if v == nil {
  40586. return
  40587. }
  40588. return *v, true
  40589. }
  40590. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40591. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40593. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40594. if !m.op.Is(OpUpdateOne) {
  40595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40596. }
  40597. if m.id == nil || m.oldValue == nil {
  40598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40599. }
  40600. oldValue, err := m.oldValue(ctx)
  40601. if err != nil {
  40602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40603. }
  40604. return oldValue.UpdatedAt, nil
  40605. }
  40606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40607. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40608. m.updated_at = nil
  40609. }
  40610. // SetDeletedAt sets the "deleted_at" field.
  40611. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40612. m.deleted_at = &t
  40613. }
  40614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40615. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40616. v := m.deleted_at
  40617. if v == nil {
  40618. return
  40619. }
  40620. return *v, true
  40621. }
  40622. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40623. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40625. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40626. if !m.op.Is(OpUpdateOne) {
  40627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40628. }
  40629. if m.id == nil || m.oldValue == nil {
  40630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40631. }
  40632. oldValue, err := m.oldValue(ctx)
  40633. if err != nil {
  40634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40635. }
  40636. return oldValue.DeletedAt, nil
  40637. }
  40638. // ClearDeletedAt clears the value of the "deleted_at" field.
  40639. func (m *WxCardUserMutation) ClearDeletedAt() {
  40640. m.deleted_at = nil
  40641. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40642. }
  40643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40644. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40645. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40646. return ok
  40647. }
  40648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40649. func (m *WxCardUserMutation) ResetDeletedAt() {
  40650. m.deleted_at = nil
  40651. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40652. }
  40653. // SetWxid sets the "wxid" field.
  40654. func (m *WxCardUserMutation) SetWxid(s string) {
  40655. m.wxid = &s
  40656. }
  40657. // Wxid returns the value of the "wxid" field in the mutation.
  40658. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40659. v := m.wxid
  40660. if v == nil {
  40661. return
  40662. }
  40663. return *v, true
  40664. }
  40665. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40666. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40668. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40669. if !m.op.Is(OpUpdateOne) {
  40670. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40671. }
  40672. if m.id == nil || m.oldValue == nil {
  40673. return v, errors.New("OldWxid requires an ID field in the mutation")
  40674. }
  40675. oldValue, err := m.oldValue(ctx)
  40676. if err != nil {
  40677. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40678. }
  40679. return oldValue.Wxid, nil
  40680. }
  40681. // ResetWxid resets all changes to the "wxid" field.
  40682. func (m *WxCardUserMutation) ResetWxid() {
  40683. m.wxid = nil
  40684. }
  40685. // SetAccount sets the "account" field.
  40686. func (m *WxCardUserMutation) SetAccount(s string) {
  40687. m.account = &s
  40688. }
  40689. // Account returns the value of the "account" field in the mutation.
  40690. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40691. v := m.account
  40692. if v == nil {
  40693. return
  40694. }
  40695. return *v, true
  40696. }
  40697. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40698. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40700. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40701. if !m.op.Is(OpUpdateOne) {
  40702. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40703. }
  40704. if m.id == nil || m.oldValue == nil {
  40705. return v, errors.New("OldAccount requires an ID field in the mutation")
  40706. }
  40707. oldValue, err := m.oldValue(ctx)
  40708. if err != nil {
  40709. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40710. }
  40711. return oldValue.Account, nil
  40712. }
  40713. // ResetAccount resets all changes to the "account" field.
  40714. func (m *WxCardUserMutation) ResetAccount() {
  40715. m.account = nil
  40716. }
  40717. // SetAvatar sets the "avatar" field.
  40718. func (m *WxCardUserMutation) SetAvatar(s string) {
  40719. m.avatar = &s
  40720. }
  40721. // Avatar returns the value of the "avatar" field in the mutation.
  40722. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40723. v := m.avatar
  40724. if v == nil {
  40725. return
  40726. }
  40727. return *v, true
  40728. }
  40729. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40730. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40732. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40733. if !m.op.Is(OpUpdateOne) {
  40734. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40735. }
  40736. if m.id == nil || m.oldValue == nil {
  40737. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40738. }
  40739. oldValue, err := m.oldValue(ctx)
  40740. if err != nil {
  40741. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40742. }
  40743. return oldValue.Avatar, nil
  40744. }
  40745. // ResetAvatar resets all changes to the "avatar" field.
  40746. func (m *WxCardUserMutation) ResetAvatar() {
  40747. m.avatar = nil
  40748. }
  40749. // SetNickname sets the "nickname" field.
  40750. func (m *WxCardUserMutation) SetNickname(s string) {
  40751. m.nickname = &s
  40752. }
  40753. // Nickname returns the value of the "nickname" field in the mutation.
  40754. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40755. v := m.nickname
  40756. if v == nil {
  40757. return
  40758. }
  40759. return *v, true
  40760. }
  40761. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40762. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40764. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40765. if !m.op.Is(OpUpdateOne) {
  40766. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40767. }
  40768. if m.id == nil || m.oldValue == nil {
  40769. return v, errors.New("OldNickname requires an ID field in the mutation")
  40770. }
  40771. oldValue, err := m.oldValue(ctx)
  40772. if err != nil {
  40773. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40774. }
  40775. return oldValue.Nickname, nil
  40776. }
  40777. // ResetNickname resets all changes to the "nickname" field.
  40778. func (m *WxCardUserMutation) ResetNickname() {
  40779. m.nickname = nil
  40780. }
  40781. // SetRemark sets the "remark" field.
  40782. func (m *WxCardUserMutation) SetRemark(s string) {
  40783. m.remark = &s
  40784. }
  40785. // Remark returns the value of the "remark" field in the mutation.
  40786. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40787. v := m.remark
  40788. if v == nil {
  40789. return
  40790. }
  40791. return *v, true
  40792. }
  40793. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40794. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40796. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40797. if !m.op.Is(OpUpdateOne) {
  40798. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40799. }
  40800. if m.id == nil || m.oldValue == nil {
  40801. return v, errors.New("OldRemark requires an ID field in the mutation")
  40802. }
  40803. oldValue, err := m.oldValue(ctx)
  40804. if err != nil {
  40805. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40806. }
  40807. return oldValue.Remark, nil
  40808. }
  40809. // ResetRemark resets all changes to the "remark" field.
  40810. func (m *WxCardUserMutation) ResetRemark() {
  40811. m.remark = nil
  40812. }
  40813. // SetPhone sets the "phone" field.
  40814. func (m *WxCardUserMutation) SetPhone(s string) {
  40815. m.phone = &s
  40816. }
  40817. // Phone returns the value of the "phone" field in the mutation.
  40818. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40819. v := m.phone
  40820. if v == nil {
  40821. return
  40822. }
  40823. return *v, true
  40824. }
  40825. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40826. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40828. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40829. if !m.op.Is(OpUpdateOne) {
  40830. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40831. }
  40832. if m.id == nil || m.oldValue == nil {
  40833. return v, errors.New("OldPhone requires an ID field in the mutation")
  40834. }
  40835. oldValue, err := m.oldValue(ctx)
  40836. if err != nil {
  40837. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40838. }
  40839. return oldValue.Phone, nil
  40840. }
  40841. // ResetPhone resets all changes to the "phone" field.
  40842. func (m *WxCardUserMutation) ResetPhone() {
  40843. m.phone = nil
  40844. }
  40845. // SetOpenID sets the "open_id" field.
  40846. func (m *WxCardUserMutation) SetOpenID(s string) {
  40847. m.open_id = &s
  40848. }
  40849. // OpenID returns the value of the "open_id" field in the mutation.
  40850. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40851. v := m.open_id
  40852. if v == nil {
  40853. return
  40854. }
  40855. return *v, true
  40856. }
  40857. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40858. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40860. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40861. if !m.op.Is(OpUpdateOne) {
  40862. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40863. }
  40864. if m.id == nil || m.oldValue == nil {
  40865. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40866. }
  40867. oldValue, err := m.oldValue(ctx)
  40868. if err != nil {
  40869. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40870. }
  40871. return oldValue.OpenID, nil
  40872. }
  40873. // ResetOpenID resets all changes to the "open_id" field.
  40874. func (m *WxCardUserMutation) ResetOpenID() {
  40875. m.open_id = nil
  40876. }
  40877. // SetUnionID sets the "union_id" field.
  40878. func (m *WxCardUserMutation) SetUnionID(s string) {
  40879. m.union_id = &s
  40880. }
  40881. // UnionID returns the value of the "union_id" field in the mutation.
  40882. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40883. v := m.union_id
  40884. if v == nil {
  40885. return
  40886. }
  40887. return *v, true
  40888. }
  40889. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40890. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40892. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40893. if !m.op.Is(OpUpdateOne) {
  40894. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40895. }
  40896. if m.id == nil || m.oldValue == nil {
  40897. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40898. }
  40899. oldValue, err := m.oldValue(ctx)
  40900. if err != nil {
  40901. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40902. }
  40903. return oldValue.UnionID, nil
  40904. }
  40905. // ResetUnionID resets all changes to the "union_id" field.
  40906. func (m *WxCardUserMutation) ResetUnionID() {
  40907. m.union_id = nil
  40908. }
  40909. // SetSessionKey sets the "session_key" field.
  40910. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40911. m.session_key = &s
  40912. }
  40913. // SessionKey returns the value of the "session_key" field in the mutation.
  40914. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40915. v := m.session_key
  40916. if v == nil {
  40917. return
  40918. }
  40919. return *v, true
  40920. }
  40921. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40922. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40924. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40925. if !m.op.Is(OpUpdateOne) {
  40926. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40927. }
  40928. if m.id == nil || m.oldValue == nil {
  40929. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40930. }
  40931. oldValue, err := m.oldValue(ctx)
  40932. if err != nil {
  40933. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40934. }
  40935. return oldValue.SessionKey, nil
  40936. }
  40937. // ResetSessionKey resets all changes to the "session_key" field.
  40938. func (m *WxCardUserMutation) ResetSessionKey() {
  40939. m.session_key = nil
  40940. }
  40941. // SetIsVip sets the "is_vip" field.
  40942. func (m *WxCardUserMutation) SetIsVip(i int) {
  40943. m.is_vip = &i
  40944. m.addis_vip = nil
  40945. }
  40946. // IsVip returns the value of the "is_vip" field in the mutation.
  40947. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40948. v := m.is_vip
  40949. if v == nil {
  40950. return
  40951. }
  40952. return *v, true
  40953. }
  40954. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  40955. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40957. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  40958. if !m.op.Is(OpUpdateOne) {
  40959. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40960. }
  40961. if m.id == nil || m.oldValue == nil {
  40962. return v, errors.New("OldIsVip requires an ID field in the mutation")
  40963. }
  40964. oldValue, err := m.oldValue(ctx)
  40965. if err != nil {
  40966. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  40967. }
  40968. return oldValue.IsVip, nil
  40969. }
  40970. // AddIsVip adds i to the "is_vip" field.
  40971. func (m *WxCardUserMutation) AddIsVip(i int) {
  40972. if m.addis_vip != nil {
  40973. *m.addis_vip += i
  40974. } else {
  40975. m.addis_vip = &i
  40976. }
  40977. }
  40978. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40979. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40980. v := m.addis_vip
  40981. if v == nil {
  40982. return
  40983. }
  40984. return *v, true
  40985. }
  40986. // ResetIsVip resets all changes to the "is_vip" field.
  40987. func (m *WxCardUserMutation) ResetIsVip() {
  40988. m.is_vip = nil
  40989. m.addis_vip = nil
  40990. }
  40991. // Where appends a list predicates to the WxCardUserMutation builder.
  40992. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40993. m.predicates = append(m.predicates, ps...)
  40994. }
  40995. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40996. // users can use type-assertion to append predicates that do not depend on any generated package.
  40997. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40998. p := make([]predicate.WxCardUser, len(ps))
  40999. for i := range ps {
  41000. p[i] = ps[i]
  41001. }
  41002. m.Where(p...)
  41003. }
  41004. // Op returns the operation name.
  41005. func (m *WxCardUserMutation) Op() Op {
  41006. return m.op
  41007. }
  41008. // SetOp allows setting the mutation operation.
  41009. func (m *WxCardUserMutation) SetOp(op Op) {
  41010. m.op = op
  41011. }
  41012. // Type returns the node type of this mutation (WxCardUser).
  41013. func (m *WxCardUserMutation) Type() string {
  41014. return m.typ
  41015. }
  41016. // Fields returns all fields that were changed during this mutation. Note that in
  41017. // order to get all numeric fields that were incremented/decremented, call
  41018. // AddedFields().
  41019. func (m *WxCardUserMutation) Fields() []string {
  41020. fields := make([]string, 0, 13)
  41021. if m.created_at != nil {
  41022. fields = append(fields, wxcarduser.FieldCreatedAt)
  41023. }
  41024. if m.updated_at != nil {
  41025. fields = append(fields, wxcarduser.FieldUpdatedAt)
  41026. }
  41027. if m.deleted_at != nil {
  41028. fields = append(fields, wxcarduser.FieldDeletedAt)
  41029. }
  41030. if m.wxid != nil {
  41031. fields = append(fields, wxcarduser.FieldWxid)
  41032. }
  41033. if m.account != nil {
  41034. fields = append(fields, wxcarduser.FieldAccount)
  41035. }
  41036. if m.avatar != nil {
  41037. fields = append(fields, wxcarduser.FieldAvatar)
  41038. }
  41039. if m.nickname != nil {
  41040. fields = append(fields, wxcarduser.FieldNickname)
  41041. }
  41042. if m.remark != nil {
  41043. fields = append(fields, wxcarduser.FieldRemark)
  41044. }
  41045. if m.phone != nil {
  41046. fields = append(fields, wxcarduser.FieldPhone)
  41047. }
  41048. if m.open_id != nil {
  41049. fields = append(fields, wxcarduser.FieldOpenID)
  41050. }
  41051. if m.union_id != nil {
  41052. fields = append(fields, wxcarduser.FieldUnionID)
  41053. }
  41054. if m.session_key != nil {
  41055. fields = append(fields, wxcarduser.FieldSessionKey)
  41056. }
  41057. if m.is_vip != nil {
  41058. fields = append(fields, wxcarduser.FieldIsVip)
  41059. }
  41060. return fields
  41061. }
  41062. // Field returns the value of a field with the given name. The second boolean
  41063. // return value indicates that this field was not set, or was not defined in the
  41064. // schema.
  41065. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  41066. switch name {
  41067. case wxcarduser.FieldCreatedAt:
  41068. return m.CreatedAt()
  41069. case wxcarduser.FieldUpdatedAt:
  41070. return m.UpdatedAt()
  41071. case wxcarduser.FieldDeletedAt:
  41072. return m.DeletedAt()
  41073. case wxcarduser.FieldWxid:
  41074. return m.Wxid()
  41075. case wxcarduser.FieldAccount:
  41076. return m.Account()
  41077. case wxcarduser.FieldAvatar:
  41078. return m.Avatar()
  41079. case wxcarduser.FieldNickname:
  41080. return m.Nickname()
  41081. case wxcarduser.FieldRemark:
  41082. return m.Remark()
  41083. case wxcarduser.FieldPhone:
  41084. return m.Phone()
  41085. case wxcarduser.FieldOpenID:
  41086. return m.OpenID()
  41087. case wxcarduser.FieldUnionID:
  41088. return m.UnionID()
  41089. case wxcarduser.FieldSessionKey:
  41090. return m.SessionKey()
  41091. case wxcarduser.FieldIsVip:
  41092. return m.IsVip()
  41093. }
  41094. return nil, false
  41095. }
  41096. // OldField returns the old value of the field from the database. An error is
  41097. // returned if the mutation operation is not UpdateOne, or the query to the
  41098. // database failed.
  41099. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41100. switch name {
  41101. case wxcarduser.FieldCreatedAt:
  41102. return m.OldCreatedAt(ctx)
  41103. case wxcarduser.FieldUpdatedAt:
  41104. return m.OldUpdatedAt(ctx)
  41105. case wxcarduser.FieldDeletedAt:
  41106. return m.OldDeletedAt(ctx)
  41107. case wxcarduser.FieldWxid:
  41108. return m.OldWxid(ctx)
  41109. case wxcarduser.FieldAccount:
  41110. return m.OldAccount(ctx)
  41111. case wxcarduser.FieldAvatar:
  41112. return m.OldAvatar(ctx)
  41113. case wxcarduser.FieldNickname:
  41114. return m.OldNickname(ctx)
  41115. case wxcarduser.FieldRemark:
  41116. return m.OldRemark(ctx)
  41117. case wxcarduser.FieldPhone:
  41118. return m.OldPhone(ctx)
  41119. case wxcarduser.FieldOpenID:
  41120. return m.OldOpenID(ctx)
  41121. case wxcarduser.FieldUnionID:
  41122. return m.OldUnionID(ctx)
  41123. case wxcarduser.FieldSessionKey:
  41124. return m.OldSessionKey(ctx)
  41125. case wxcarduser.FieldIsVip:
  41126. return m.OldIsVip(ctx)
  41127. }
  41128. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  41129. }
  41130. // SetField sets the value of a field with the given name. It returns an error if
  41131. // the field is not defined in the schema, or if the type mismatched the field
  41132. // type.
  41133. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  41134. switch name {
  41135. case wxcarduser.FieldCreatedAt:
  41136. v, ok := value.(time.Time)
  41137. if !ok {
  41138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41139. }
  41140. m.SetCreatedAt(v)
  41141. return nil
  41142. case wxcarduser.FieldUpdatedAt:
  41143. v, ok := value.(time.Time)
  41144. if !ok {
  41145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41146. }
  41147. m.SetUpdatedAt(v)
  41148. return nil
  41149. case wxcarduser.FieldDeletedAt:
  41150. v, ok := value.(time.Time)
  41151. if !ok {
  41152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41153. }
  41154. m.SetDeletedAt(v)
  41155. return nil
  41156. case wxcarduser.FieldWxid:
  41157. v, ok := value.(string)
  41158. if !ok {
  41159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41160. }
  41161. m.SetWxid(v)
  41162. return nil
  41163. case wxcarduser.FieldAccount:
  41164. v, ok := value.(string)
  41165. if !ok {
  41166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41167. }
  41168. m.SetAccount(v)
  41169. return nil
  41170. case wxcarduser.FieldAvatar:
  41171. v, ok := value.(string)
  41172. if !ok {
  41173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41174. }
  41175. m.SetAvatar(v)
  41176. return nil
  41177. case wxcarduser.FieldNickname:
  41178. v, ok := value.(string)
  41179. if !ok {
  41180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41181. }
  41182. m.SetNickname(v)
  41183. return nil
  41184. case wxcarduser.FieldRemark:
  41185. v, ok := value.(string)
  41186. if !ok {
  41187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41188. }
  41189. m.SetRemark(v)
  41190. return nil
  41191. case wxcarduser.FieldPhone:
  41192. v, ok := value.(string)
  41193. if !ok {
  41194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41195. }
  41196. m.SetPhone(v)
  41197. return nil
  41198. case wxcarduser.FieldOpenID:
  41199. v, ok := value.(string)
  41200. if !ok {
  41201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41202. }
  41203. m.SetOpenID(v)
  41204. return nil
  41205. case wxcarduser.FieldUnionID:
  41206. v, ok := value.(string)
  41207. if !ok {
  41208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41209. }
  41210. m.SetUnionID(v)
  41211. return nil
  41212. case wxcarduser.FieldSessionKey:
  41213. v, ok := value.(string)
  41214. if !ok {
  41215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41216. }
  41217. m.SetSessionKey(v)
  41218. return nil
  41219. case wxcarduser.FieldIsVip:
  41220. v, ok := value.(int)
  41221. if !ok {
  41222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41223. }
  41224. m.SetIsVip(v)
  41225. return nil
  41226. }
  41227. return fmt.Errorf("unknown WxCardUser field %s", name)
  41228. }
  41229. // AddedFields returns all numeric fields that were incremented/decremented during
  41230. // this mutation.
  41231. func (m *WxCardUserMutation) AddedFields() []string {
  41232. var fields []string
  41233. if m.addis_vip != nil {
  41234. fields = append(fields, wxcarduser.FieldIsVip)
  41235. }
  41236. return fields
  41237. }
  41238. // AddedField returns the numeric value that was incremented/decremented on a field
  41239. // with the given name. The second boolean return value indicates that this field
  41240. // was not set, or was not defined in the schema.
  41241. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  41242. switch name {
  41243. case wxcarduser.FieldIsVip:
  41244. return m.AddedIsVip()
  41245. }
  41246. return nil, false
  41247. }
  41248. // AddField adds the value to the field with the given name. It returns an error if
  41249. // the field is not defined in the schema, or if the type mismatched the field
  41250. // type.
  41251. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  41252. switch name {
  41253. case wxcarduser.FieldIsVip:
  41254. v, ok := value.(int)
  41255. if !ok {
  41256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41257. }
  41258. m.AddIsVip(v)
  41259. return nil
  41260. }
  41261. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41262. }
  41263. // ClearedFields returns all nullable fields that were cleared during this
  41264. // mutation.
  41265. func (m *WxCardUserMutation) ClearedFields() []string {
  41266. var fields []string
  41267. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41268. fields = append(fields, wxcarduser.FieldDeletedAt)
  41269. }
  41270. return fields
  41271. }
  41272. // FieldCleared returns a boolean indicating if a field with the given name was
  41273. // cleared in this mutation.
  41274. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41275. _, ok := m.clearedFields[name]
  41276. return ok
  41277. }
  41278. // ClearField clears the value of the field with the given name. It returns an
  41279. // error if the field is not defined in the schema.
  41280. func (m *WxCardUserMutation) ClearField(name string) error {
  41281. switch name {
  41282. case wxcarduser.FieldDeletedAt:
  41283. m.ClearDeletedAt()
  41284. return nil
  41285. }
  41286. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41287. }
  41288. // ResetField resets all changes in the mutation for the field with the given name.
  41289. // It returns an error if the field is not defined in the schema.
  41290. func (m *WxCardUserMutation) ResetField(name string) error {
  41291. switch name {
  41292. case wxcarduser.FieldCreatedAt:
  41293. m.ResetCreatedAt()
  41294. return nil
  41295. case wxcarduser.FieldUpdatedAt:
  41296. m.ResetUpdatedAt()
  41297. return nil
  41298. case wxcarduser.FieldDeletedAt:
  41299. m.ResetDeletedAt()
  41300. return nil
  41301. case wxcarduser.FieldWxid:
  41302. m.ResetWxid()
  41303. return nil
  41304. case wxcarduser.FieldAccount:
  41305. m.ResetAccount()
  41306. return nil
  41307. case wxcarduser.FieldAvatar:
  41308. m.ResetAvatar()
  41309. return nil
  41310. case wxcarduser.FieldNickname:
  41311. m.ResetNickname()
  41312. return nil
  41313. case wxcarduser.FieldRemark:
  41314. m.ResetRemark()
  41315. return nil
  41316. case wxcarduser.FieldPhone:
  41317. m.ResetPhone()
  41318. return nil
  41319. case wxcarduser.FieldOpenID:
  41320. m.ResetOpenID()
  41321. return nil
  41322. case wxcarduser.FieldUnionID:
  41323. m.ResetUnionID()
  41324. return nil
  41325. case wxcarduser.FieldSessionKey:
  41326. m.ResetSessionKey()
  41327. return nil
  41328. case wxcarduser.FieldIsVip:
  41329. m.ResetIsVip()
  41330. return nil
  41331. }
  41332. return fmt.Errorf("unknown WxCardUser field %s", name)
  41333. }
  41334. // AddedEdges returns all edge names that were set/added in this mutation.
  41335. func (m *WxCardUserMutation) AddedEdges() []string {
  41336. edges := make([]string, 0, 0)
  41337. return edges
  41338. }
  41339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41340. // name in this mutation.
  41341. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41342. return nil
  41343. }
  41344. // RemovedEdges returns all edge names that were removed in this mutation.
  41345. func (m *WxCardUserMutation) RemovedEdges() []string {
  41346. edges := make([]string, 0, 0)
  41347. return edges
  41348. }
  41349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41350. // the given name in this mutation.
  41351. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41352. return nil
  41353. }
  41354. // ClearedEdges returns all edge names that were cleared in this mutation.
  41355. func (m *WxCardUserMutation) ClearedEdges() []string {
  41356. edges := make([]string, 0, 0)
  41357. return edges
  41358. }
  41359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41360. // was cleared in this mutation.
  41361. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41362. return false
  41363. }
  41364. // ClearEdge clears the value of the edge with the given name. It returns an error
  41365. // if that edge is not defined in the schema.
  41366. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41367. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41368. }
  41369. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41370. // It returns an error if the edge is not defined in the schema.
  41371. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41372. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41373. }
  41374. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41375. type WxCardVisitMutation struct {
  41376. config
  41377. op Op
  41378. typ string
  41379. id *uint64
  41380. created_at *time.Time
  41381. updated_at *time.Time
  41382. deleted_at *time.Time
  41383. user_id *uint64
  41384. adduser_id *int64
  41385. bot_id *uint64
  41386. addbot_id *int64
  41387. bot_type *uint8
  41388. addbot_type *int8
  41389. clearedFields map[string]struct{}
  41390. done bool
  41391. oldValue func(context.Context) (*WxCardVisit, error)
  41392. predicates []predicate.WxCardVisit
  41393. }
  41394. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41395. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41396. type wxcardvisitOption func(*WxCardVisitMutation)
  41397. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41398. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41399. m := &WxCardVisitMutation{
  41400. config: c,
  41401. op: op,
  41402. typ: TypeWxCardVisit,
  41403. clearedFields: make(map[string]struct{}),
  41404. }
  41405. for _, opt := range opts {
  41406. opt(m)
  41407. }
  41408. return m
  41409. }
  41410. // withWxCardVisitID sets the ID field of the mutation.
  41411. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41412. return func(m *WxCardVisitMutation) {
  41413. var (
  41414. err error
  41415. once sync.Once
  41416. value *WxCardVisit
  41417. )
  41418. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41419. once.Do(func() {
  41420. if m.done {
  41421. err = errors.New("querying old values post mutation is not allowed")
  41422. } else {
  41423. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41424. }
  41425. })
  41426. return value, err
  41427. }
  41428. m.id = &id
  41429. }
  41430. }
  41431. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41432. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41433. return func(m *WxCardVisitMutation) {
  41434. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41435. return node, nil
  41436. }
  41437. m.id = &node.ID
  41438. }
  41439. }
  41440. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41441. // executed in a transaction (ent.Tx), a transactional client is returned.
  41442. func (m WxCardVisitMutation) Client() *Client {
  41443. client := &Client{config: m.config}
  41444. client.init()
  41445. return client
  41446. }
  41447. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41448. // it returns an error otherwise.
  41449. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41450. if _, ok := m.driver.(*txDriver); !ok {
  41451. return nil, errors.New("ent: mutation is not running in a transaction")
  41452. }
  41453. tx := &Tx{config: m.config}
  41454. tx.init()
  41455. return tx, nil
  41456. }
  41457. // SetID sets the value of the id field. Note that this
  41458. // operation is only accepted on creation of WxCardVisit entities.
  41459. func (m *WxCardVisitMutation) SetID(id uint64) {
  41460. m.id = &id
  41461. }
  41462. // ID returns the ID value in the mutation. Note that the ID is only available
  41463. // if it was provided to the builder or after it was returned from the database.
  41464. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41465. if m.id == nil {
  41466. return
  41467. }
  41468. return *m.id, true
  41469. }
  41470. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41471. // That means, if the mutation is applied within a transaction with an isolation level such
  41472. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41473. // or updated by the mutation.
  41474. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41475. switch {
  41476. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41477. id, exists := m.ID()
  41478. if exists {
  41479. return []uint64{id}, nil
  41480. }
  41481. fallthrough
  41482. case m.op.Is(OpUpdate | OpDelete):
  41483. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41484. default:
  41485. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41486. }
  41487. }
  41488. // SetCreatedAt sets the "created_at" field.
  41489. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41490. m.created_at = &t
  41491. }
  41492. // CreatedAt returns the value of the "created_at" field in the mutation.
  41493. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41494. v := m.created_at
  41495. if v == nil {
  41496. return
  41497. }
  41498. return *v, true
  41499. }
  41500. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41501. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41503. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41504. if !m.op.Is(OpUpdateOne) {
  41505. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41506. }
  41507. if m.id == nil || m.oldValue == nil {
  41508. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41509. }
  41510. oldValue, err := m.oldValue(ctx)
  41511. if err != nil {
  41512. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41513. }
  41514. return oldValue.CreatedAt, nil
  41515. }
  41516. // ResetCreatedAt resets all changes to the "created_at" field.
  41517. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41518. m.created_at = nil
  41519. }
  41520. // SetUpdatedAt sets the "updated_at" field.
  41521. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41522. m.updated_at = &t
  41523. }
  41524. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41525. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41526. v := m.updated_at
  41527. if v == nil {
  41528. return
  41529. }
  41530. return *v, true
  41531. }
  41532. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41533. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41535. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41536. if !m.op.Is(OpUpdateOne) {
  41537. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41538. }
  41539. if m.id == nil || m.oldValue == nil {
  41540. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41541. }
  41542. oldValue, err := m.oldValue(ctx)
  41543. if err != nil {
  41544. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41545. }
  41546. return oldValue.UpdatedAt, nil
  41547. }
  41548. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41549. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41550. m.updated_at = nil
  41551. }
  41552. // SetDeletedAt sets the "deleted_at" field.
  41553. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41554. m.deleted_at = &t
  41555. }
  41556. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41557. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41558. v := m.deleted_at
  41559. if v == nil {
  41560. return
  41561. }
  41562. return *v, true
  41563. }
  41564. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41565. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41567. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41568. if !m.op.Is(OpUpdateOne) {
  41569. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41570. }
  41571. if m.id == nil || m.oldValue == nil {
  41572. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41573. }
  41574. oldValue, err := m.oldValue(ctx)
  41575. if err != nil {
  41576. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41577. }
  41578. return oldValue.DeletedAt, nil
  41579. }
  41580. // ClearDeletedAt clears the value of the "deleted_at" field.
  41581. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41582. m.deleted_at = nil
  41583. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41584. }
  41585. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41586. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41587. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41588. return ok
  41589. }
  41590. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41591. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41592. m.deleted_at = nil
  41593. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41594. }
  41595. // SetUserID sets the "user_id" field.
  41596. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41597. m.user_id = &u
  41598. m.adduser_id = nil
  41599. }
  41600. // UserID returns the value of the "user_id" field in the mutation.
  41601. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41602. v := m.user_id
  41603. if v == nil {
  41604. return
  41605. }
  41606. return *v, true
  41607. }
  41608. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41609. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41611. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41612. if !m.op.Is(OpUpdateOne) {
  41613. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41614. }
  41615. if m.id == nil || m.oldValue == nil {
  41616. return v, errors.New("OldUserID requires an ID field in the mutation")
  41617. }
  41618. oldValue, err := m.oldValue(ctx)
  41619. if err != nil {
  41620. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41621. }
  41622. return oldValue.UserID, nil
  41623. }
  41624. // AddUserID adds u to the "user_id" field.
  41625. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41626. if m.adduser_id != nil {
  41627. *m.adduser_id += u
  41628. } else {
  41629. m.adduser_id = &u
  41630. }
  41631. }
  41632. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41633. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41634. v := m.adduser_id
  41635. if v == nil {
  41636. return
  41637. }
  41638. return *v, true
  41639. }
  41640. // ClearUserID clears the value of the "user_id" field.
  41641. func (m *WxCardVisitMutation) ClearUserID() {
  41642. m.user_id = nil
  41643. m.adduser_id = nil
  41644. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41645. }
  41646. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41647. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41648. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41649. return ok
  41650. }
  41651. // ResetUserID resets all changes to the "user_id" field.
  41652. func (m *WxCardVisitMutation) ResetUserID() {
  41653. m.user_id = nil
  41654. m.adduser_id = nil
  41655. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41656. }
  41657. // SetBotID sets the "bot_id" field.
  41658. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41659. m.bot_id = &u
  41660. m.addbot_id = nil
  41661. }
  41662. // BotID returns the value of the "bot_id" field in the mutation.
  41663. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41664. v := m.bot_id
  41665. if v == nil {
  41666. return
  41667. }
  41668. return *v, true
  41669. }
  41670. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41671. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41673. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41674. if !m.op.Is(OpUpdateOne) {
  41675. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41676. }
  41677. if m.id == nil || m.oldValue == nil {
  41678. return v, errors.New("OldBotID requires an ID field in the mutation")
  41679. }
  41680. oldValue, err := m.oldValue(ctx)
  41681. if err != nil {
  41682. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41683. }
  41684. return oldValue.BotID, nil
  41685. }
  41686. // AddBotID adds u to the "bot_id" field.
  41687. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41688. if m.addbot_id != nil {
  41689. *m.addbot_id += u
  41690. } else {
  41691. m.addbot_id = &u
  41692. }
  41693. }
  41694. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41695. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41696. v := m.addbot_id
  41697. if v == nil {
  41698. return
  41699. }
  41700. return *v, true
  41701. }
  41702. // ResetBotID resets all changes to the "bot_id" field.
  41703. func (m *WxCardVisitMutation) ResetBotID() {
  41704. m.bot_id = nil
  41705. m.addbot_id = nil
  41706. }
  41707. // SetBotType sets the "bot_type" field.
  41708. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41709. m.bot_type = &u
  41710. m.addbot_type = nil
  41711. }
  41712. // BotType returns the value of the "bot_type" field in the mutation.
  41713. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41714. v := m.bot_type
  41715. if v == nil {
  41716. return
  41717. }
  41718. return *v, true
  41719. }
  41720. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41721. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41723. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41724. if !m.op.Is(OpUpdateOne) {
  41725. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41726. }
  41727. if m.id == nil || m.oldValue == nil {
  41728. return v, errors.New("OldBotType requires an ID field in the mutation")
  41729. }
  41730. oldValue, err := m.oldValue(ctx)
  41731. if err != nil {
  41732. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41733. }
  41734. return oldValue.BotType, nil
  41735. }
  41736. // AddBotType adds u to the "bot_type" field.
  41737. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41738. if m.addbot_type != nil {
  41739. *m.addbot_type += u
  41740. } else {
  41741. m.addbot_type = &u
  41742. }
  41743. }
  41744. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41745. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41746. v := m.addbot_type
  41747. if v == nil {
  41748. return
  41749. }
  41750. return *v, true
  41751. }
  41752. // ResetBotType resets all changes to the "bot_type" field.
  41753. func (m *WxCardVisitMutation) ResetBotType() {
  41754. m.bot_type = nil
  41755. m.addbot_type = nil
  41756. }
  41757. // Where appends a list predicates to the WxCardVisitMutation builder.
  41758. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41759. m.predicates = append(m.predicates, ps...)
  41760. }
  41761. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41762. // users can use type-assertion to append predicates that do not depend on any generated package.
  41763. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41764. p := make([]predicate.WxCardVisit, len(ps))
  41765. for i := range ps {
  41766. p[i] = ps[i]
  41767. }
  41768. m.Where(p...)
  41769. }
  41770. // Op returns the operation name.
  41771. func (m *WxCardVisitMutation) Op() Op {
  41772. return m.op
  41773. }
  41774. // SetOp allows setting the mutation operation.
  41775. func (m *WxCardVisitMutation) SetOp(op Op) {
  41776. m.op = op
  41777. }
  41778. // Type returns the node type of this mutation (WxCardVisit).
  41779. func (m *WxCardVisitMutation) Type() string {
  41780. return m.typ
  41781. }
  41782. // Fields returns all fields that were changed during this mutation. Note that in
  41783. // order to get all numeric fields that were incremented/decremented, call
  41784. // AddedFields().
  41785. func (m *WxCardVisitMutation) Fields() []string {
  41786. fields := make([]string, 0, 6)
  41787. if m.created_at != nil {
  41788. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41789. }
  41790. if m.updated_at != nil {
  41791. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41792. }
  41793. if m.deleted_at != nil {
  41794. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41795. }
  41796. if m.user_id != nil {
  41797. fields = append(fields, wxcardvisit.FieldUserID)
  41798. }
  41799. if m.bot_id != nil {
  41800. fields = append(fields, wxcardvisit.FieldBotID)
  41801. }
  41802. if m.bot_type != nil {
  41803. fields = append(fields, wxcardvisit.FieldBotType)
  41804. }
  41805. return fields
  41806. }
  41807. // Field returns the value of a field with the given name. The second boolean
  41808. // return value indicates that this field was not set, or was not defined in the
  41809. // schema.
  41810. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41811. switch name {
  41812. case wxcardvisit.FieldCreatedAt:
  41813. return m.CreatedAt()
  41814. case wxcardvisit.FieldUpdatedAt:
  41815. return m.UpdatedAt()
  41816. case wxcardvisit.FieldDeletedAt:
  41817. return m.DeletedAt()
  41818. case wxcardvisit.FieldUserID:
  41819. return m.UserID()
  41820. case wxcardvisit.FieldBotID:
  41821. return m.BotID()
  41822. case wxcardvisit.FieldBotType:
  41823. return m.BotType()
  41824. }
  41825. return nil, false
  41826. }
  41827. // OldField returns the old value of the field from the database. An error is
  41828. // returned if the mutation operation is not UpdateOne, or the query to the
  41829. // database failed.
  41830. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41831. switch name {
  41832. case wxcardvisit.FieldCreatedAt:
  41833. return m.OldCreatedAt(ctx)
  41834. case wxcardvisit.FieldUpdatedAt:
  41835. return m.OldUpdatedAt(ctx)
  41836. case wxcardvisit.FieldDeletedAt:
  41837. return m.OldDeletedAt(ctx)
  41838. case wxcardvisit.FieldUserID:
  41839. return m.OldUserID(ctx)
  41840. case wxcardvisit.FieldBotID:
  41841. return m.OldBotID(ctx)
  41842. case wxcardvisit.FieldBotType:
  41843. return m.OldBotType(ctx)
  41844. }
  41845. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41846. }
  41847. // SetField sets the value of a field with the given name. It returns an error if
  41848. // the field is not defined in the schema, or if the type mismatched the field
  41849. // type.
  41850. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41851. switch name {
  41852. case wxcardvisit.FieldCreatedAt:
  41853. v, ok := value.(time.Time)
  41854. if !ok {
  41855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41856. }
  41857. m.SetCreatedAt(v)
  41858. return nil
  41859. case wxcardvisit.FieldUpdatedAt:
  41860. v, ok := value.(time.Time)
  41861. if !ok {
  41862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41863. }
  41864. m.SetUpdatedAt(v)
  41865. return nil
  41866. case wxcardvisit.FieldDeletedAt:
  41867. v, ok := value.(time.Time)
  41868. if !ok {
  41869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41870. }
  41871. m.SetDeletedAt(v)
  41872. return nil
  41873. case wxcardvisit.FieldUserID:
  41874. v, ok := value.(uint64)
  41875. if !ok {
  41876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41877. }
  41878. m.SetUserID(v)
  41879. return nil
  41880. case wxcardvisit.FieldBotID:
  41881. v, ok := value.(uint64)
  41882. if !ok {
  41883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41884. }
  41885. m.SetBotID(v)
  41886. return nil
  41887. case wxcardvisit.FieldBotType:
  41888. v, ok := value.(uint8)
  41889. if !ok {
  41890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41891. }
  41892. m.SetBotType(v)
  41893. return nil
  41894. }
  41895. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41896. }
  41897. // AddedFields returns all numeric fields that were incremented/decremented during
  41898. // this mutation.
  41899. func (m *WxCardVisitMutation) AddedFields() []string {
  41900. var fields []string
  41901. if m.adduser_id != nil {
  41902. fields = append(fields, wxcardvisit.FieldUserID)
  41903. }
  41904. if m.addbot_id != nil {
  41905. fields = append(fields, wxcardvisit.FieldBotID)
  41906. }
  41907. if m.addbot_type != nil {
  41908. fields = append(fields, wxcardvisit.FieldBotType)
  41909. }
  41910. return fields
  41911. }
  41912. // AddedField returns the numeric value that was incremented/decremented on a field
  41913. // with the given name. The second boolean return value indicates that this field
  41914. // was not set, or was not defined in the schema.
  41915. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41916. switch name {
  41917. case wxcardvisit.FieldUserID:
  41918. return m.AddedUserID()
  41919. case wxcardvisit.FieldBotID:
  41920. return m.AddedBotID()
  41921. case wxcardvisit.FieldBotType:
  41922. return m.AddedBotType()
  41923. }
  41924. return nil, false
  41925. }
  41926. // AddField adds the value to the field with the given name. It returns an error if
  41927. // the field is not defined in the schema, or if the type mismatched the field
  41928. // type.
  41929. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41930. switch name {
  41931. case wxcardvisit.FieldUserID:
  41932. v, ok := value.(int64)
  41933. if !ok {
  41934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41935. }
  41936. m.AddUserID(v)
  41937. return nil
  41938. case wxcardvisit.FieldBotID:
  41939. v, ok := value.(int64)
  41940. if !ok {
  41941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41942. }
  41943. m.AddBotID(v)
  41944. return nil
  41945. case wxcardvisit.FieldBotType:
  41946. v, ok := value.(int8)
  41947. if !ok {
  41948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41949. }
  41950. m.AddBotType(v)
  41951. return nil
  41952. }
  41953. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41954. }
  41955. // ClearedFields returns all nullable fields that were cleared during this
  41956. // mutation.
  41957. func (m *WxCardVisitMutation) ClearedFields() []string {
  41958. var fields []string
  41959. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41960. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41961. }
  41962. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41963. fields = append(fields, wxcardvisit.FieldUserID)
  41964. }
  41965. return fields
  41966. }
  41967. // FieldCleared returns a boolean indicating if a field with the given name was
  41968. // cleared in this mutation.
  41969. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41970. _, ok := m.clearedFields[name]
  41971. return ok
  41972. }
  41973. // ClearField clears the value of the field with the given name. It returns an
  41974. // error if the field is not defined in the schema.
  41975. func (m *WxCardVisitMutation) ClearField(name string) error {
  41976. switch name {
  41977. case wxcardvisit.FieldDeletedAt:
  41978. m.ClearDeletedAt()
  41979. return nil
  41980. case wxcardvisit.FieldUserID:
  41981. m.ClearUserID()
  41982. return nil
  41983. }
  41984. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41985. }
  41986. // ResetField resets all changes in the mutation for the field with the given name.
  41987. // It returns an error if the field is not defined in the schema.
  41988. func (m *WxCardVisitMutation) ResetField(name string) error {
  41989. switch name {
  41990. case wxcardvisit.FieldCreatedAt:
  41991. m.ResetCreatedAt()
  41992. return nil
  41993. case wxcardvisit.FieldUpdatedAt:
  41994. m.ResetUpdatedAt()
  41995. return nil
  41996. case wxcardvisit.FieldDeletedAt:
  41997. m.ResetDeletedAt()
  41998. return nil
  41999. case wxcardvisit.FieldUserID:
  42000. m.ResetUserID()
  42001. return nil
  42002. case wxcardvisit.FieldBotID:
  42003. m.ResetBotID()
  42004. return nil
  42005. case wxcardvisit.FieldBotType:
  42006. m.ResetBotType()
  42007. return nil
  42008. }
  42009. return fmt.Errorf("unknown WxCardVisit field %s", name)
  42010. }
  42011. // AddedEdges returns all edge names that were set/added in this mutation.
  42012. func (m *WxCardVisitMutation) AddedEdges() []string {
  42013. edges := make([]string, 0, 0)
  42014. return edges
  42015. }
  42016. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42017. // name in this mutation.
  42018. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  42019. return nil
  42020. }
  42021. // RemovedEdges returns all edge names that were removed in this mutation.
  42022. func (m *WxCardVisitMutation) RemovedEdges() []string {
  42023. edges := make([]string, 0, 0)
  42024. return edges
  42025. }
  42026. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42027. // the given name in this mutation.
  42028. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  42029. return nil
  42030. }
  42031. // ClearedEdges returns all edge names that were cleared in this mutation.
  42032. func (m *WxCardVisitMutation) ClearedEdges() []string {
  42033. edges := make([]string, 0, 0)
  42034. return edges
  42035. }
  42036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42037. // was cleared in this mutation.
  42038. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  42039. return false
  42040. }
  42041. // ClearEdge clears the value of the edge with the given name. It returns an error
  42042. // if that edge is not defined in the schema.
  42043. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  42044. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  42045. }
  42046. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42047. // It returns an error if the edge is not defined in the schema.
  42048. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  42049. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  42050. }